I have been looking at this frame buffer problem I have and it is very odd. It looks like the pointer to the frame buffers is pointing 640 bytes (one row with 2 bytes per pixel) before the start of the frame buffer.
Has anyone encountered this before. Is there something that I am missing?
Found the problem the code on the wiki for flipping the buffers seems to be wrong. In the bellow code their is a line in the fb_flip routine that adds 640 to the frame buffers address. I remove this and sure enough the frame buffer is working as I would expect.
Unless someone can show me why it's needed I will update the wiki to remove the line. (Unless someone beats me too it.)
CODE
static volatile uint16_t *memregs16;
static volatile uint32_t *memregs32;
int32_t devmem;
int32_t devfb0;
int32_t devfb1;
void fb_flip(uint32_t fb_addr)
{
memregs16[0x290E>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2910>>1] = (uint16_t)(fb_addr >> 16);
fb_addr += 640;
memregs16[0x2912>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2914>>1] = (uint16_t)(fb_addr >> 16);
}
int main()
{
devmem = open("/dev/mem", O_RDWR);
devfb0 = open("/dev/fb0", O_RDWR);
devfb1 = open("/dev/fb1", O_RDWR);
fb0 = (uint16_t *) mmap(0, 320*240*sizeof(uint16_t), PROT_WRITE, MAP_SHARED, devfb0, 0);
fb1 = (uint16_t *) mmap(0, 320*240*sizeof(uint16_t), PROT_WRITE, MAP_SHARED, devfb1, 0);
fb_flip((uint32_t) 0x03101000); // flips to fb0
fb_flip((uint32_t) 0x03381000); // flips to fb1
}