在linux中,fb设备驱动的源码主要在Fb.h (linux2.6.28\include\linux)和Fbmem.c(linux2.6.28\drivers\video)两个文件中,它们是fb设备驱动的中间层,为上层提供系统调用,为底层驱动提供接口。

在fb.h文件中有fb驱动需要使用的很多结构,我们先对这些结构体进行说明:

1.  帧缓冲区描述符fb_info

一个帧缓冲区对应一个struct fb_info结构,它包括了帧缓冲设备的属性和操作的完整集合,每个帧设备都有一个fb_info结构体。源码如下:

struct fb_info {

atomic_tcount;

intnode;

intflags;

structmutex lock;             /* Lock foropen/release/ioctl funcs */

structmutex mm_lock;              /* Lock forfb_mmap and smem_* fields */

structfb_var_screeninfo var;    /* Current var缓冲区的可变参数
*/

structfb_fix_screeninfo fix;       /* Currentfix缓冲区的固定参数*/

structfb_monspecs monspecs;/* Current Monitorspecs当前显示器标示*/

structwork_struct queue; /* Framebuffer eventqueue
帧缓冲事件队列*/

structfb_pixmap pixmap; /* Image hardwaremapper图像硬件mapper*/

structfb_pixmap sprite;    /* Cursor hardwaremapper光标硬件mapper
*/

structfb_cmap cmap;               /* Currentcmap */

structlist_head modelist;     /* mode list */

structfb_videomode *mode;     /* current mode
当前视频模式*/

#ifdef CONFIG_FB_BACKLIGHT /*如果配置了LCD支持背光灯
*/

/*assigned backlight device */

/*set before framebuffer registration,

remove after unregister */

structbacklight_device *bl_dev;

/*Backlight level curve */

structmutex bl_curve_mutex;

u8bl_curve[FB_BACKLIGHT_LEVELS];

#endif

#ifdef CONFIG_FB_DEFERRED_IO

structdelayed_work deferred_work;

structfb_deferred_io *fbdefio;

#endif

structfb_ops *fbops;/*帧缓冲区操作函数*/

structdevice *device;       /* This is theparent
父设备 */

structdevice *dev;            /* This is thisfb devicefb设备*/

intclass_flag;                   /* privatesysfs flags */

#ifdef CONFIG_FB_TILEBLITTING

structfb_tile_ops *tileops;   /* Tile Blitting*/

#endif

char__iomem *screen_base;   /* Virtualaddress */

unsignedlong screen_size;      /* Amount ofioremapped VRAM or 0 */

void*pseudo_palette;               /* Fakepalette of 16 colors位调色板*/

#define FBINFO_STATE_RUNNING0

#define FBINFO_STATE_SUSPENDED   1

u32state;                 /* Hardware statei.e suspend */

void*fbcon_par;               /* fbconuse-only private area */

/*From here on everything is device dependent */

void*par;

/*we need the PCI or similar aperture base/size not

smem_start/size as smem_start may just be anobject

allocated inside the aperture so may notactually overlap */

structapertures_struct {

unsignedint count;

structaperture {

resource_size_tbase;

resource_size_tsize;

}ranges[0];

}*apertures;

};

2.  帧缓冲区操作符表fb_ops

fb_ops结构体用来实现对帧缓冲设备的操作,这些函数需要驱动开发人员编写,

/*

* Frame bufferoperations

*

* LOCKING NOTE: thosefunctions must _ALL_ be called with the console

* semaphore held, thisis the only suitable locking mechanism we have

* in 2.6. Some may becalled at interrupt time at this point though.

*

* The exception tothis is the debug related hooks. Puttingthe fb

* into a debug state(e.g. flipping to the kernel console) and restoring

* it must be done in alock-free manner, so low level drivers should

* keep track of theinitial console (if applicable) and may need to

* perform direct,unlocked hardware writes in these hooks.

*/

struct fb_ops {

/* open/releaseand usage marking */

struct module*owner;

/*打开与释放操作
*/

int(*fb_open)(struct fb_info *info, int user);

int(*fb_release)(struct fb_info *info, int user);

/* Forframebuffers with strange non linear layouts or that do not

* work with normal memory mapped access针对非线性布局或标准内存映射无法访问

*/

ssize_t (*fb_read)(structfb_info *info, char __user *buf,

size_t count, loff_t *ppos);

ssize_t(*fb_write)(struct fb_info *info, const char __user *buf,

size_t count, loff_t *ppos);

/* checks varand eventually tweaks it to something supported,

* DO NOT MODIFY PAR

*检测帧缓冲区可变变量,并调整为可用值*/

int(*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);

/* set the videomode according to info->var设置视频模式
*/

int(*fb_set_par)(struct fb_info *info);

/* set colorregister设置color寄存器*/

int(*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,

unsigned blue, unsigned transp, structfb_info *info);

/* set colorregisters in batch批量设置color寄存器,设置颜色表
*/

int(*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);

/* blank display空白显示*/

int(*fb_blank)(int blank, struct fb_info *info);

/* pan displaypan显示*/

int(*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);

/* Draws arectangle画矩形*/

void(*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);

/* Copy datafrom area to another复制缓存区数据到指定区域
*/

void(*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);

/* Draws a imageto the display在帧缓冲区显示一个图片
*/

void(*fb_imageblit) (struct fb_info *info, const struct fb_image *image);

/* Draws cursor光标绘制*/

int (*fb_cursor)(struct fb_info *info, struct fb_cursor *cursor);

/* Rotates thedisplay旋转显示*/

void(*fb_rotate)(struct fb_info *info, int angle);

/* wait for blitidle, optional 等待blit空闲,可选*/

int(*fb_sync)(struct fb_info *info);

/* perform fbspecific ioctl (optional)fb特定的ioctl操作*/

int(*fb_ioctl)(struct fb_info *info, unsigned int cmd,

unsignedlong arg);

/* Handle 32bitcompat ioctl (optional) */

int(*fb_compat_ioctl)(struct fb_info *info, unsigned cmd,

unsignedlong arg);

/* perform fbspecific mmapfb特定的mmap操作*/

int(*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);

/* getcapability given var */

void(*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,

struct fb_var_screeninfo *var);

/* teardown anyresources to do with this framebuffer */

void(*fb_destroy)(struct fb_info *info);

/* called at KDBenter and leave time to prepare the console */

int(*fb_debug_enter)(struct fb_info *info);

int(*fb_debug_leave)(struct fb_info *info);

};

3.  帧缓冲区固定参数描述符

fb_fix_screeninfo结构体中,记录了用户不能修改的固定显示控制器参数。这些固定的参数如缓冲区的物理地址、缓冲区的长度等等。

struct fb_fix_screeninfo {

char id[16];                       /* identification stringeg "TT Builtin" */

unsigned longsmem_start;      /* Start of frame buffermemFB开始的位置*/

/*(physical address)物理地址
*/

__u32 smem_len;                     /* Length of frame buffermemFB的长度*/

__u32 type;                       /* see FB_TYPE_*   FB类型  */

__u32 type_aux;               /* Interleave for interleavedPlanes分界*/

__u32 visual;                    /* see FB_VISUAL_*FB使用的色彩模式       */

__u16 xpanstep;/*zero if no hardware panning */

__u16 ypanstep;               /* zero if no hardwarepanning */

__u16 ywrapstep;             /* zero if no hardware ywrap   */

__u32line_length;            /* length of aline in bytes 1行的字节数 */

unsigned longmmio_start;       /* Start of MemoryMapped I/O */

/*(physical address)内存IO映射的开始位置 物理地址*/

__u32 mmio_len;                      /* Length of MemoryMapped I/O 长度*/

__u32 accel;                     /* Indicate to driverwhich */

/* specific chip/card we have 
*/

__u16reserved[3];           /* Reserved forfuture compatibility */

};

4.  帧缓冲区可变参数描述符

fb_var_screeninfo结构体中存储了用户可以修改的显示器控制参数,例如屏幕分辨率、透明度等等

struct fb_var_screeninfo {

__u32 xres;                       /* visible resolution   可见解析度,即分辨率*/

__u32 yres;

__u32xres_virtual;           /* virtual resolution   虚拟解析度     */

__u32yres_virtual;

__u32 xoffset;                   /* offset from virtual tovisible */

__u32 yoffset;                   /* resolution     虚拟与可见之间的偏移   */

__u32bits_per_pixel;        /* guess what           每像素位数     */

__u32 grayscale;      /* != 0 Graylevels instead of colors时为灰度
*/

structfb_bitfield red;/* bitfield in fb mem iftrue color, */

structfb_bitfield green;     /* else onlylength is significant */

structfb_bitfield blue; /*RGB位域
*/

struct fb_bitfieldtransp;    /* transparency
透明度*/

__u32 nonstd;  /* != 0 Non standard pixel format
!=0非标准像素格式*/

__u32 activate;         /* see FB_ACTIVATE_*            */

__u32 height;                    /* height of picture inmm mm中的屏幕高度 */

__u32 width;                     /* width of picture inmm mm中的屏幕宽度  */

__u32accel_flags;            /* (OBSOLETE) seefb_info.flags标示
*/

/* Timing: Allvalues in pixclocks, except pixclock (of course) */

__u32 pixclock;/* pixel clock in ps (pico seconds)
像素时钟皮秒*/

/*  行切换:绘图与同步间的延时 */

__u32left_margin;   /* time from sync topicture */

__u32right_margin;/* time from picture to sync */

      /*  
帧切换:绘图与同步间的延时 */

__u32upper_margin;/* time from sync to picture */

__u32lower_margin;

__u32 hsync_len;             /* length of horizontal sync       水平同步长度*/

__u32 vsync_len;              /* length of vertical sync垂直同步长度*/

__u32 sync;                      /* see FB_SYNC_*           */

__u32 vmode;                   /* see FB_VMODE_*        */

__u32 rotate;   /* angle we rotate counter clockwise顺时针旋转的角度*/

__u32reserved[5];           /* Reserved forfuture compatibility */

}

5.  帧缓冲区调色板描述符

fb_cmap结构体中记录了颜色板信息,即调色板信息。,用户空间可以通过ioctl()的FBIOGETCMAP和FBIOPUTCMAP命令读取或设定颜色表。

struct fb_cmap {

__u32 start;               /* First entry 第一个颜色入口*/

__u32 len;                  /* Number of entries
元素个数*/

__u16 *red;                /* Red values      RGB的值*/

__u16 *green;

__u16 *blue;

__u16 *transp;                  /* transparency, can be NULL透明度*/

};

上面这些结构体之间有什么关系呢?看下图:

6.  帧缓冲区像素描述符

fb_bitfield结构体描述每一像素显示缓冲区的组织方式,包含位域偏移、位域长度和MSB指示,

/* Interpretation of offset for color fields: All offsets arefrom the right,

* inside a"pixel" value, which is exactly 'bits_per_pixel' wide (means: you

* can use the offsetas right argument to <<). A pixel afterwards is a bit

* stream and iswritten to video memory as that unmodified.

*

* For pseudocolor:offset and length should be the same for all color

* components. Offsetspecifies the position of the least significant bit

* of the palletteindex in a pixel value. Length indicates the number

* of available paletteentries (i.e. # of entries = 1 << length).

*/

struct fb_bitfield {

__u32 offset;              /* beginning of bitfield位于偏移*/

__u32 length;                    /* length of bitfield     位域长度   */

__u32 msb_right;       /* != 0 : Most significant bit is */

/*rightMSB
*/

};

FrameBuffer系列 之 介绍

http://blog.csdn.net/younger_china/article/details/14479859

FrameBuffer系列 之 相关结构与结构体

http://blog.csdn.net/younger_china/article/details/14480967

FrameBuffer系列 之 简单编程

http://blog.csdn.net/younger_china/article/details/14236251

FrameBuffer系列

显示图片

http://blog.csdn.net/younger_china/article/details/14481755

FrameBuffer系列

一点资源

http://blog.csdn.net/younger_china/article/details/14482049





FrameBuffer系列 之 相关结构与结构体的更多相关文章

  1. FrameBuffer系列 之 一点资源

    Iamonlyme的FrameBuffer编程实例http://download.csdn.net/detail/iamonlyme/6512955 light588的通过framebuffer直接写 ...

  2. FrameBuffer系列 之 显示图片

     摘自:http://blog.csdn.net/luxiaoxun/article/details/7622988 #include <unistd.h> #include < ...

  3. FrameBuffer系列 之 介绍

    1.     来由 FrameBuffer是出现在2.2.xx内核当中的一种驱动程序接口.Linux工作在保护模式下,所以用户态进程是无法象 DOS 那样使用显卡 BIOS里提供的中断调用来实现直接写 ...

  4. FrameBuffer系列 之 简单编程

    一.Linux的帧缓冲设备 帧缓冲(framebuffer)是 Linux为显示设备提供的一个接口,把显存抽象后的一种设备,他允许上层应用程序在图形模式下直接对显示缓冲区进行读写操作.这种操作是抽象的 ...

  5. openssl之EVP系列之7---信息摘要算法结构概述

    openssl之EVP系列之7---信息摘要算法结构概述     ---依据openssl doc/crypto/EVP_DigestInit.pod翻译和自己的理解写成     (作者:Dragon ...

  6. CRL快速开发框架系列教程十(导出对象结构)

    本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...

  7. 精通awk系列(6):awk命令结构和awk语法结构

    回到: Linux系列文章 Shell系列文章 Awk系列文章 awk命令行结构和语法结构 awk命令行结构 awk [ -- ] program-text file ... (1) awk -f p ...

  8. Java基础系列(17)- 顺序结构

    顺序结构 JAVA的基本结构就是顺序结构,除非特别说明,否则就按照顺序一句一句执行 顺序结构是最简单的算法结构 语句与语句之间,框与框之间是按从上到下的顺序进行的,它是由若干个依次执行的处理步骤组成的 ...

  9. Java基础-程序流程控制第一弹(分支结构/选择结构)

    Java基础-程序流程控制第一弹(分支结构/选择结构) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.if语句 1>.if语句的第一种格式 if(条件表达式){ 语句体: ...

随机推荐

  1. 关于cursor的各种属性应用

    <html> <body> <p>请把鼠标移动到单词上,可以看到鼠标指针发生变化:</p> <span style="cursor:au ...

  2. Javascript——依赖注入

    本人才学疏浅,本文只为抛砖引玉,欢迎各路大牛前来斧正,不胜感激! 如今各个框架都在模块化,连前端的javascript也不例外.每个模块负责一定的功能,模块与模块之间又有相互依赖,那么问题来了:jav ...

  3. css——样式表分类,选择器

    一,样式表分类 (1)内联样式[优先级最高][常用][代码重复使用性最差] (当特殊的样式需要应用到个别元素时,就可以使用内联样式. 使用内联样式的方法是在相关的标签中使用样式属性.样式属性可以包含任 ...

  4. pyqt样式表语法笔记(下)--原创

    pyqt样式表语法笔记(下) python 启动界面 QSS pyqt 一.启动界面的设置 简单点~说话的方式简单点用一张静态图片作为程序启动界面为例. 原来的语句     python    7行 ...

  5. MYSQL数据库-修改和删除

    删除数据库: $ DROP DATABASE t_name; 重命名一张表: $ RENAME TABLE ori_name TO new_name; $ ALTER TABLE ori_name R ...

  6. 老李分享:jvm内存原型剖析

    老李分享:jvm内存原型剖析   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:9088214 ...

  7. 腾讯IVWEB团队:WebRTC 点对点直播

    作者:villainthr 摘自:villainhr WebRTC 全称为:Web Real-Time Communication.它是为了解决 Web 端无法捕获音视频的能力,并且提供了 peer- ...

  8. MAT(Memory Analyzer Tool)使用心得

    起因:最近在跟踪产品的性能问题,期间主要问题体现在JVM的内存回收问题,使用MAT工具进行JVM内存分析(也可对android 的应用内存分析) 问题描述: 1.部分后端服务在运行一段时间后会突然年老 ...

  9. day001-html知识点总结(二)不常见但很重要的元素汇总

    一..vertical-align:设置垂直对齐方式,主要用于: 1.单元格内容的垂直对齐 2.对于行内块级元素,如<img>,设置行内元素的基线相对于该行内块级元素的所在行的基线对齐,例 ...

  10. 1102: 零起点学算法09——继续练习简单的输入和计算(a-b)

    1102: 零起点学算法09--继续练习简单的输入和计算(a-b) Time Limit: 1 Sec  Memory Limit: 520 MB   64bit IO Format: %lldSub ...