1
0

Raspberry Pi VideoCore: Wait for framebuffer address if not available

Sometimes the VideoCore does not immediately provide the framebuffer
address, even after it has returned success via a mailbox read.
This commit is contained in:
Aaron Lindsay 2012-10-06 18:54:37 -04:00
parent 8cb4100463
commit 828beb45bd

View File

@ -25,16 +25,16 @@
#include <drivers/bcm2835_mailbox.h> #include <drivers/bcm2835_mailbox.h>
struct bcm2835_config { struct bcm2835_config {
uint32 width; volatile uint32 width;
uint32 height; volatile uint32 height;
uint32 vwidth; volatile uint32 vwidth;
uint32 vheight; volatile uint32 vheight;
uint32 pitch; volatile uint32 pitch;
uint32 color_depth; volatile uint32 color_depth;
uint32 xoffset; volatile uint32 xoffset;
uint32 yoffset; volatile uint32 yoffset;
uint32 fb_base_addr; volatile uint32 fb_base_addr;
uint32 size; volatile uint32 size;
}; };
#define MAILBOX_BUFFER_SIZE (32*4*2) #define MAILBOX_BUFFER_SIZE (32*4*2)
@ -75,11 +75,27 @@ int bcm2835_videocore_init(struct fb *f, unsigned int color_depth) {
mailbox_write(MBOX_FB, (uint32)cfg); mailbox_write(MBOX_FB, (uint32)cfg);
result = mailbox_read(MBOX_FB); result = mailbox_read(MBOX_FB);
if (result || !cfg->fb_base_addr) { if (result) {
print("Error: did not request a proper framebuffer\n"); print("Error: did not request a proper framebuffer\n");
return -1; return -1;
} }
if (!cfg->fb_base_addr) {
int i;
print("BCM2835 VideoCore returned success from framebuffer "
"setup mailbox call, but framebuffer address is "
"not yet available. Waiting...\n");
for (i = 0; i < 1<<30 && !cfg->fb_base_addr; i++);
if (!cfg->fb_base_addr) {
print("Error: VideoCore did not provide framebuffer "
"base address.\n");
return -1;
}
print("VideoCore provided framebuffer base address after %d loops.\n", i);
}
f->device = &bcm2835_fb_device; f->device = &bcm2835_fb_device;
f->device->fbaddr = (void*)cfg->fb_base_addr; f->device->fbaddr = (void*)cfg->fb_base_addr;
f->width = cfg->width; f->width = cfg->width;