Getting framebuffer to work on Raspberry Pi
Posted: Tue Mar 17, 2020 10:49 pm
I've been trying to get framebuffer working on Raspberry Pi 2. This is the code that I used to initialize it:
The problem is that it works well on Qemu, but not on real hardware. Anyone know how to fix it?
BTW, here's the hardware implementations for the Raspberry Pi on my OS: https://gitlab.com/weedboi6969/fusion/- ... rpi-common
Code: Select all
typedef struct {
uint32_t width, height;
uint32_t vwidth, vheight;
uint32_t pitch, depth;
uint32_t xoff, yoff;
uint32_t ptr, size;
} __attribute__ ((packed)) pifb_info_t;
pifb_info_t __attribute__ ((aligned(16))) pifb_info;
fb_device_t pifb_device;
void pifb_init(uint32_t width, uint32_t height) {
pifb_info.width = width; pifb_info.height = height;
pifb_info.vwidth = width; pifb_info.vheight = height;
pifb_info.depth = 24;
pifb_info.xoff = 0; pifb_info.yoff = 0; pifb_info.pitch = 0; pifb_info.ptr = 0; pifb_info.size = 0;
uint32_t dat = ((uint32_t) &pifb_info) >> 4;
if(rpi_board >= 2) dat |= 0xC000000; // convert to GPU address
mbox_write(1, dat);
//pifb_info_t *pifb_out = (pifb_info_t*) ((mbox_read(1) << 4) & ((rpi_board >= 2) ? ~0xC0000000 : 0xFFFFFFFF));
pifb_info_t *pifb_out = &pifb_info;
pifb_device.width = width; pifb_device.height = height;
pifb_device.pitch = pifb_out->pitch; pifb_device.bpp = pifb_out->depth;
pifb_device.color.endian = 0; pifb_device.color.bytes = 3;
pifb_device.color.r_start = 16; pifb_device.color.r_bits = 8;
pifb_device.color.g_start = 8; pifb_device.color.g_bits = 8;
pifb_device.color.b_start = 0; pifb_device.color.b_bits = 8;
pifb_device.buffer = (uint8_t*) (pifb_out->ptr & ((rpi_board >= 2) ? ~0xC0000000 : 0xFFFFFFFF));
if(fb_default == NULL) fb_default = &pifb_device;
}
BTW, here's the hardware implementations for the Raspberry Pi on my OS: https://gitlab.com/weedboi6969/fusion/- ... rpi-common