2013-02-25 82 views
3

我正在尝试为Linux直接写入到framebuffer/dev/fb0的应用程序。为了使它具有双缓冲功能,我尝试使虚拟屏幕的大小增加一倍。这是我写的程序:在fb_var_screeninfo中设置yres_virtual时发生无效参数错误

struct fb_var_screeninfo screeninfo_var; 
struct fb_fix_screeninfo screeninfo_fixed; 
unsigned int* screenbuffer; 

void gfx_init() 
{ 
    fb0 = open("/dev/fb0", O_RDWR); 
    if(fb0 == 0) 
     error("Could not open framebuffer located in /dev/fb0!"); 

    if (ioctl(fb0, FBIOGET_FSCREENINFO, &screeninfo_fixed) == -1) 
     error("Could not retrive fixed screen info!"); 

    if (ioctl(fb0, FBIOGET_VSCREENINFO, &screeninfo_var) == -1) 
     error("Could not retrive variable screen info!"); 

    screeninfo_var.xres_virtual = screeninfo_var.xres; 
    screeninfo_var.yres_virtual = screeninfo_var.yres * 2; 
    screeninfo_var.width = screeninfo_var.xres; 
    screeninfo_var.height = screeninfo_var.yres; 
    screeninfo_var.xoffset = 0; 
    screeninfo_var.yoffset = 0; 

    if (ioctl(fb0, FBIOPUT_VSCREENINFO, &screeninfo_var) == -1) 
     error("Could not set variable screen info!"); 

    info("Detected monitor of %ix%i pixels using %i bit colors.",screeninfo_var.xres, screeninfo_var.yres, screeninfo_var.bits_per_pixel); 

    screenbuffersize = screeninfo_var.xres_virtual * screeninfo_var.yres_virtual * screeninfo_var.bits_per_pixel/8; 
    screenbuffer = (unsigned int *)mmap(0, screenbuffersize, PROT_READ | PROT_WRITE, MAP_SHARED, fb0, 0); 
    if((long)screenbuffer == 0 || (long)screenbuffer == -1) 
     error("Failed to map framebuffer to device memory!"); 
} 

ioctl(fb0, FBIOPUT_VSCREENINFO, &screeninfo_var)程序failes报告错误无效的参数。当删除行screeninfo_var.yres_virtual = screeninfo_var.yres * 2;它运行良好(但没有双缓冲)。

有人看到我在这里做错了吗?

+1

你有没有想出解决办法?我目前有类似的问题。 – 2016-01-16 20:18:52

回答

0

这是一个常见问题,它是由视频驱动程序的限制造成的。例如,英特尔的810芯片组只允许640x480分辨率,Broadcom的宽度限制为不超过1200(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=29968)。

没有太多的你可以在这里做,除非你改变驱动程序或视频卡本身(如果可能的话)。

编辑:如果您在PC上,请尝试使用vesafb,而不是英特尔的驱动程序。

有一个提示的位置:http://www.mail-archive.com/[email protected]/msg27725.html

+1

Nvidea Quadro 200M不能处理更大的帧缓冲似乎是不合逻辑的。我使用的屏幕是1600x900,1600x901的虚拟屏幕尺寸已经给出错误。 有什么方法可以实际查找最大虚拟屏幕大小? – STS 2013-02-26 08:39:05

相关问题