2013-02-25 86 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

相關問題