rlyeh
Certified Guru
I've tried to do a double buffering code using ioctl() to use /dev/fb directly
Here's my initial setup:
Ok, now gp2x_screen elements are mapped to framebuffers, and writing into [0] paints the screen as desired.
My problem is that I don't know how to switch the LCD to the [1] buffer
Trying a different approach, I've tried to pan the display, here it is how it should be done:
By doing this, that Linux does it ok with no errors, our VSCREENINFO virtual size changes from 320x240 to 640x480.
In theory, we should call now FBIO_PANDISPLAY to scroll through the virtual area.
But ioctl() returns error 22 'Invalid argument'.
So, how can I do double buffering through ioctl() ?
I have two methods:
- exchanging /fb/dev0 and /fb/dev1 which i dont know how to do it
- using FBIOPAN_DISPLAY to scroll /fb/dev0 which does not work at all
any idea?
Here's my initial setup:
Code:
struct fb_fix_screeninfo fixed_info;
struct fb_var_screeninfo variable_info;
int fbdev[2];
u16 *gp2x_screen[2], gp2x_screenc=0;
fbdev[0]=open("/dev/fb0", O_RDWR);
fbdev[1]=open("/dev/fb1", O_RDWR);
gp2x_screen[0]=(u16 *)mmap(0, 320*240*sizeof(u16), PROT_WRITE, MAP_SHARED, fbdev[0], 0);
gp2x_screen[1]=(u16 *)mmap(0, 320*240*sizeof(u16), PROT_WRITE, MAP_SHARED, fbdev[1], 0);
Ok, now gp2x_screen elements are mapped to framebuffers, and writing into [0] paints the screen as desired.
My problem is that I don't know how to switch the LCD to the [1] buffer
Trying a different approach, I've tried to pan the display, here it is how it should be done:
Code:
ioctl (fbdev[0], FBIOGET_VSCREENINFO, &variable_info);
variable_info.xres_virtual=640; //*=2
variable_info.yres_virtual=480; //*=2
ioctl (fbdev[0], FBIOPUT_VSCREENINFO, &variable_info);
By doing this, that Linux does it ok with no errors, our VSCREENINFO virtual size changes from 320x240 to 640x480.
In theory, we should call now FBIO_PANDISPLAY to scroll through the virtual area.
Code:
variable_info.xoffset = 0;
variable_info.yoffset = (gp2x_screenc^=1) ? 0 : 240;
variable_info.activate = FB_ACTIVATE_VBL;
if(ioctl (fbdev[0], FBIOPAN_DISPLAY, &variable_info) < 0)
{
printf("FBIOPAN_DISPLAY error %d = %s\n",errno,strerror(errno));
}
But ioctl() returns error 22 'Invalid argument'.
So, how can I do double buffering through ioctl() ?
I have two methods:
- exchanging /fb/dev0 and /fb/dev1 which i dont know how to do it
- using FBIOPAN_DISPLAY to scroll /fb/dev0 which does not work at all
any idea?