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(条件表达式){ 语句体: ...
随机推荐
- final 、finally 和 finalize()的区别
1. final 是一个关键字.可以修饰数据.方法.类. 1)final 数据:final 用来修饰一个永不改变的编译时常量,或者运行时初始化但是不希望被改变的常量.一个既是 static又是 fin ...
- 阿里云Linux启动tomcat并能外网访问
问题描述: 先描述一下我的心路历程吧,新买了阿里云服务器,由于需求不是很大,只是为了备案,所以买了个最低配的,而且是Windows server2012的.那现在需要做的是在这个乞丐版的server上 ...
- 有个程序猿要去当CEO了:(二)扬帆起航
合同签好了. 从昨天下午三点半,一直修改到晚上七点半,才确定签下. 这过程中,有一点讨论得比较久: 就是甲方要不要也拿底薪. 甲方是这样说的:"总经理拿N仟元,董事长不要说比总经理高,但是也 ...
- 给 Virtualbox 中 Ubuntu 系统设置静态 IP ,让 DNS 配置信息不会在重启后被清除
虚拟机网络选择 桥接网卡 模式. 主要涉及两个步骤: 1. 修改 /etc/network/interfaces 文件: 2. 修改 dns : 第一步,修改 interfaces 文件: sudo ...
- 对于用div+css随心所欲布局的思考
在div+css取代Table成为主流的时代,学会用其进行随心所欲的布局是一个不可回避的技能.那么,重点掌握哪几个要点呢? 整体布局:从整体到局部的顺序进行布局,逐步定义div集css样式: 灵活运用 ...
- Kruskal算法的实现
#include "stdio.h" #include "stdlib.h" struct edge { int m; int n; int d; }a[]; ...
- Atom 编辑器试用
简介 它号称"21世纪可黑客的文本编辑器".GitHub支持并开源,并支持跨平台.和brackets编辑器一样基于浏览器开发,意味着你可以使用less(包含css)来定制编辑器界面 ...
- Java EE基础之JSP(二)
接着上篇文章,我们上篇文章讲到了jsp的基本原理以及和servlet的关系,还介绍了jsp的基本语法部分,本篇文章就继续介绍余下的内容. 编译指令Page和include 基本的动作指令 内置对象 一 ...
- [.NET] 一步步打造一个简单的 MVC 网站 - BooksStore(一)
一步步打造一个简单的 MVC 网站 - BooksStore(一) 本系列的 GitHub地址:https://github.com/liqingwen2015/Wen.BooksStore 简介 主 ...
- python 爬取w3shcool的JQuery的课程并且保存到本地
最近在忙于找工作,闲暇之余,也找点爬虫项目练练手,写写代码,知道自己是个菜鸟,但是要多加练习,书山有路勤为径.各位爷有测试坑可以给我介绍个啊,自动化,功能,接口都可以做. 首先呢,我们明确需求,很多同 ...