FrameBuffer系列 之 相关结构与结构体
在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
http://blog.csdn.net/younger_china/article/details/14481755
http://blog.csdn.net/younger_china/article/details/14482049
FrameBuffer系列 之 相关结构与结构体的更多相关文章
- FrameBuffer系列 之 一点资源
Iamonlyme的FrameBuffer编程实例http://download.csdn.net/detail/iamonlyme/6512955 light588的通过framebuffer直接写 ...
- FrameBuffer系列 之 显示图片
摘自:http://blog.csdn.net/luxiaoxun/article/details/7622988 #include <unistd.h> #include < ...
- FrameBuffer系列 之 介绍
1. 来由 FrameBuffer是出现在2.2.xx内核当中的一种驱动程序接口.Linux工作在保护模式下,所以用户态进程是无法象 DOS 那样使用显卡 BIOS里提供的中断调用来实现直接写 ...
- FrameBuffer系列 之 简单编程
一.Linux的帧缓冲设备 帧缓冲(framebuffer)是 Linux为显示设备提供的一个接口,把显存抽象后的一种设备,他允许上层应用程序在图形模式下直接对显示缓冲区进行读写操作.这种操作是抽象的 ...
- openssl之EVP系列之7---信息摘要算法结构概述
openssl之EVP系列之7---信息摘要算法结构概述 ---依据openssl doc/crypto/EVP_DigestInit.pod翻译和自己的理解写成 (作者:Dragon ...
- CRL快速开发框架系列教程十(导出对象结构)
本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...
- 精通awk系列(6):awk命令结构和awk语法结构
回到: Linux系列文章 Shell系列文章 Awk系列文章 awk命令行结构和语法结构 awk命令行结构 awk [ -- ] program-text file ... (1) awk -f p ...
- Java基础系列(17)- 顺序结构
顺序结构 JAVA的基本结构就是顺序结构,除非特别说明,否则就按照顺序一句一句执行 顺序结构是最简单的算法结构 语句与语句之间,框与框之间是按从上到下的顺序进行的,它是由若干个依次执行的处理步骤组成的 ...
- Java基础-程序流程控制第一弹(分支结构/选择结构)
Java基础-程序流程控制第一弹(分支结构/选择结构) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.if语句 1>.if语句的第一种格式 if(条件表达式){ 语句体: ...
随机推荐
- js数组,字符串常用方法汇总(面试必备)
字符串: 1.concat() – 将两个或多个字符的文本组合起来,返回一个新的字符串. 2.indexOf() – 返回字符串中一个子串第一处出现的索引.如果没有匹配项,返回 -1 . 3.ch ...
- python 接口自动化测试(一)
一.测试需求描述 对服务后台一系列SOAP接口功能测试 参数传入:根据接口描述构造不同的参数输入值(Json格式) 二.程序设计 通过Excel配置具体的测试用例数据 保存参数为Json格式,预写入预 ...
- (21)IO流之对象的序列化和反序列化流ObjectOutputStream和ObjectInputStream
当创建对象时,程序运行时它就会存在,但是程序停止时,对象也就消失了.但是如果希望对象在程序不运行的情况下仍能存在并保存其信息,将会非常有用,对象将被重建并且拥有与程序上次运行时拥有的信息相同.可以使用 ...
- 【子非鱼】归并排序过程呈现之java内置GUI表示
在网上看到一个视频将各种排序用视频表示出来,配上音乐,挺好玩的样子,就算是不会编程的人看到也会觉得很舒服,碰巧我也正在写归并算法,于是就用java的GUI实现一个. 归并排序的时间复杂度是T(n)=O ...
- Android 使用纯Java代码布局
java布局 java代码布局和xml布局的区别 1.Java纯布局更加的灵活,比如自定义控件或一些特殊要求时,使用java代码布局 2.常用的xml布局是所见即所得的编写方式,以及xml本身拥有一些 ...
- java学习笔记 --- java基础语法
一.java标识符,关键字,保留字 1.标识符 用来增强程序阅读性自定义的名字.类名,变量名,方法名等都可以被称为标识符 标识符的组成: 1.由数字(0-9),字母(a-z,A-Z),下划线(_),美 ...
- ng2响应式表单-翻译与概括官网REACTIVE FORMS页面
本文将半翻译半总结的讲讲ng2官网的另一个未翻译高级教程页面. 原文地址. 文章目的是使用ng2提供的响应式表单技术快速搭出功能完善丰富的界面表单组件. 响应式表单是一项响应式风格的ng2技术,本文将 ...
- CSS -- 练习之制作简单商品图
只加深了印象,出错点:未给左侧人物大图宽高,致使第二行图层叠在其上: <!DOCTYPE html> <html lang="en"> <head&g ...
- 谈谈在DevOps实践中,感觉最重要的这三个技术……
从国内众多DevOps实践中,我们能看到下面三个技术尤其重要和火热: 容器:容器从根本上解决了软件对环境的依懒性,解决了各个环境之间的差异问题:它可以加速部署的速度,提高部署的效率:降低部署的成本.容 ...
- Activity猫的一生-故事讲解Activity生命周期
大家好,关于Android中Activity的生命周期,网上大多数文章基本都是直接贴图.翻译API,比较笼统含糊不清. 我就用故事来说一说: 有个人叫User,TA养了几只猫,有只猫叫Activity ...