I am using the rasbperry pi 3. I am working on an embedded project. I wrote some frame buffer initialization code, which seems to work since the color palette rectangle disappears and I get a black screen. However I have been unsuccessful at setting the value of a single pixel so far.
My goal is to get a white screen at the end, but I only get a black screen, I don't even see changes in the individual pixels.
I am using the 8th channel (property tags ARM->VC) to communicate with the mailbox, since it seems channel 1 is unreliable.
This is my structure:
struct temp
{
int size;
int request;
int tag1;
int buff_size1;
int val_length1;
int widthP;
int heightP;
int tag2;
int buff_size2;
int val_length2;
int widthV;
int heightV;
int tag3;
int buff_size3;
int val_length3;
int depth;
int tag4;
int buff_size4;
int val_length4;
int fb_ptr;
int fb_size;
int end;
};
Which is statically initialized as follows:
volatile temp t __attribute__ ((aligned (16)))=
{
.size = sizeof(temp),
.request = 0,
.tag1 = SET_PHYSICAL_WIDTH_HEIGHT,
.buff_size1 = 8,
.val_length1 = 8,
.widthP = 1024,
.heightP = 768,
.tag2 = SET_VIRTUAL_WIDTH_HEIGHT,
.buff_size2 = 8,
.val_length2 = 8,
.widthV = 1024,
.heightV = 768,
.tag3 = SET_DEPTH,
.buff_size3 = 4,
.val_length3 = 4,
.depth = 16,
.tag4 = ALLOCATE,
.buff_size4 = 8,
.val_length4 = 8,
.fb_ptr = 0,
.fb_size = 0,
.end = END,
};
And then I finally do:
void init_display()
{
write_to_mailbox((uint32_t) &t, (Channel)(PTAG_ARM_TO_VC));
for(int i=0; i<t.fb_size; i++)
{
*(volatile uint32_t *)(t.fb_ptr + i) = 0xFFFF;
}
}
I have been successful at blinking the ACT led so I think write_to_mailbox() works as intended, which is why I didn't post it here.
-
What are your main goal on your project : Making a user interface ? Just Displaying images, movies ?Technico.top– Technico.top2017年06月02日 02:23:10 +00:00Commented Jun 2, 2017 at 2:23
-
Making a user interfaceMakogan– Makogan2017年06月02日 20:42:54 +00:00Commented Jun 2, 2017 at 20:42
-
As you want to use framebuffer, i suppose you won't work with X11. I can suggest you to use SDL library (or it's python binding, pygame), that can manage user events, display without X, sounds ...Technico.top– Technico.top2017年06月02日 21:12:23 +00:00Commented Jun 2, 2017 at 21:12
-
I am doing a bare metal project, all I can use is and assembly and probably not may librariesMakogan– Makogan2017年06月02日 21:17:24 +00:00Commented Jun 2, 2017 at 21:17
2 Answers 2
Seen your project, I would advice you to work with the OpenMax display system.
Pros :
- It will give you draw and display functions
- It allow you to use GPU instead of CPU
- It is lightweight
- It can manage multiple display layers with transparency
Cons :
- Don't provide user input management
- It lacks documentation
- It lacks community
I had good result with OMX, to replace SDL, being a total newbie in C.
You can find code samples here
Here is another way to achieve the most bare-metal display system i can imagine :
Writing raw pixel data to the frambuffer device :
Prerequites :
- the touchscreen has to be recognized as /dev/fb0.
- the frambuffer resolution has to be defined in /boot/config.txt
or via fbset
command.
You can aquire raw pixel data by reading /dev/fb0 :
cat /dev/fb0 > image.raw
and display in the same way :
cat image.raw > /dev/fb0
Raw image data can be edited with Gimp, as long as you respect original image format and resolution, or can be computed on-the-fly, using some usual graphic functions.
I use this trick to get a boot splashscreen before plymouth launch, it may be enough for a simple UI.