http://pandorawiki.org/Kernel_interface
double buffering
This can be achieved using FBIOPAN_DISPLAY ioctl system call. For this you need to mmap framebuffer of double size
buffer1 = mmap(0, 800*480*2 * 2, PROT_WRITE, MAP_SHARED, fbdev, 0); buffer2 = (char *)mem + 800*480*2;
Then to display buffer2 you would call:
struct fb_var_screeninfo fbvar; ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar); fbvar.yoffset = 480; ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar);
going back to buffer1 would be repeating above with fbvar.yoffset = 0. Tripple or quad buffering can be implemented using the same technique.
vertical sync
Linux has standard FBIO_WAITFORVSYNC for this:
int arg = 0; ioctl(fbdev, FBIO_WAITFORVSYNC, &arg);
be sure to pass argument value 0 or it will not work.
Some toolchains don't have FBIO_WAITFORVSYNC defined in <linux/fb.h>, in which case you can define it in the following manner:
#ifndef FBIO_WAITFORVSYNC #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) #endif
经过测试发现,双缓冲绘图,切换频率超过显示器刷新频率60时,会出现闪烁,还未找到解决办法,也许就是不能超过刷新频率吧。