FrameBuffer在Linux中的实现和机制


Framebuffer对应的源文件在linux/drivers/video/目录下。总的抽象设备文件为fbcon.c,在这个目录下还有与各种显卡驱动相关的源文件。

(一)、分析Framebuffer设备驱动

需要特别提出的是在INTEL平台上,老式的VESA1.2卡,如CGA/EGA卡,是不能支持Framebuffer的,因为Framebuffer要求显卡支持线性帧缓冲,即CPU可以访问显缓冲中的每一位, 但是VESA1.2 卡只能允许CPU一次访问64K的地址空间。

FrameBuffer设备驱动基于如下两个文件:

1) linux/include/linux/fb.h

2) linux/drivers/video/fbmem.c 下面分析这两个文件。

1、fb.h

几乎主要的结构都是在这个中文件定义的。这些结构包括:

1)fb_var_screeninfo

【帮客之家 http://www.bkjia.com 】

这个结构描述了显示卡的特性:

  1. struct fb_var_screeninfo  
  2. {  
  3. __u32 xres; /* visible resolution */  
  4. __u32 yres;  
  5. __u32 xres_virtual; /* virtual resolution */  
  6. __u32 yres_virtual;  
  7. __u32 xoffset; /* offset from virtual to visible resolution */  
  8. __u32 yoffset;  
  9. __u32 bits_per_pixel; /* guess what */  
  10. __u32 grayscale; /* != 0 Gray levels instead of colors */  
  11. struct fb_bitfield red; /* bitfield in fb mem if true color, */  
  12. struct fb_bitfield green; /* else only length is significant */  
  13. struct fb_bitfield blue;  
  14. struct fb_bitfield transp; /* transparency */  
  15. __u32 nonstd; /* != 0 Non standard pixel format */  
  16. __u32 activate; /* see FB_ACTIVATE_* */  
  17. __u32 height; /* height of picture in mm */  
  18. __u32 width; /* width of picture in mm */  
  19. __u32 accel_flags; /* acceleration flags (hints) */  
  20. /* Timing: All values in pixclocks, except pixclock (of course) */  
  21. __u32 pixclock; /* pixel clock in ps (pico seconds) */  
  22. __u32 left_margin; /* time from sync to picture */  
  23. __u32 right_margin; /* time from picture to sync */  
  24. __u32 upper_margin; /* time from sync to picture */  
  25. __u32 lower_margin;  
  26. __u32 hsync_len; /* length of horizontal sync */  
  27. __u32 vsync_len; /* length of vertical sync */  
  28. __u32 sync; /* see FB_SYNC_* */  
  29. __u32 vmode; /* see FB_VMODE_* */  
  30. __u32 reserved[6]; /* Reserved for future compatibility */  
  31. };  
  • 1
  • 2
  • 3
  • 4
  • 下一页

相关内容