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:
		| @@ -25,16 +25,16 @@ | ||||
| #include <drivers/bcm2835_mailbox.h> | ||||
|  | ||||
| struct bcm2835_config { | ||||
| 	uint32 width; | ||||
| 	uint32 height; | ||||
| 	uint32 vwidth; | ||||
| 	uint32 vheight; | ||||
| 	uint32 pitch; | ||||
| 	uint32 color_depth; | ||||
| 	uint32 xoffset; | ||||
| 	uint32 yoffset; | ||||
| 	uint32 fb_base_addr; | ||||
| 	uint32 size; | ||||
| 	volatile uint32 width; | ||||
| 	volatile uint32 height; | ||||
| 	volatile uint32 vwidth; | ||||
| 	volatile uint32 vheight; | ||||
| 	volatile uint32 pitch; | ||||
| 	volatile uint32 color_depth; | ||||
| 	volatile uint32 xoffset; | ||||
| 	volatile uint32 yoffset; | ||||
| 	volatile uint32 fb_base_addr; | ||||
| 	volatile uint32 size; | ||||
| }; | ||||
|  | ||||
| #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); | ||||
| 	result = mailbox_read(MBOX_FB); | ||||
|  | ||||
| 	if (result || !cfg->fb_base_addr) { | ||||
| 	if (result) { | ||||
| 		print("Error: did not request a proper framebuffer\n"); | ||||
| 		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->fbaddr = (void*)cfg->fb_base_addr; | ||||
| 	f->width = cfg->width; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user