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(条件表达式){ 语句体: ...
随机推荐
- @Required 注释应用于 bean 属性的 setter 方法,它表明受影响的 bean 属性在配置时必须放在 XML 配置文件中,否则容器就会抛出一个 BeanInitializationException 异常。
@Required 注释应用于 bean 属性的 setter 方法,它表明受影响的 bean 属性在配置时必须放在 XML 配置文件中,否则容器就会抛出一个 BeanInitializationEx ...
- python 接口自动化测试--代码实现(八)
用例读入数据库: #! /usr/bin/python # coding:utf-8 import sys,os from Engine import DataEngine reload(sys) s ...
- JavaWeb之JSON
一.什么是JSON? JSON: JavaScript Object Notation(JavaScript 对象表示法) JSON 是存储和交换文本信息的语法.类似 XML. JSON 比 XML ...
- ###服务(Service)
Start服务开启方式 1) 创建服务 public class MyService extends Service 2) 添加注册表 <service android:name=&qu ...
- SQL注入相关的知识【Mysql为例子】
以DVWA的sql注入初级为例,结合网上搜索的相关利用方式,总结成这一篇文章,内容会有点跳跃. 大纲: 1.初级手工注入 2.order by的使用 3.union查询注意点 4.Mysql相关的注释 ...
- sqrt()平方根计算函数的实现1——二分法
C语言标准库: http://www.cplusplus.com/reference/cmath/ 在一个区间中,每次拿中间数的平方来试验,如果大了,就再试左区间的中间数:如果小了,就再拿右区间的中间 ...
- Storm(2015.08.12笔记)
2015.08.12Storm 一.Storm简介 Storm是Twitter开源的一个类似于Hadoop的实时数据处理框架. Storm能实现高频数据和大规模数据的实时处理. 官网资料显示s ...
- Eclipse中将含有图片资源的项目打包成jar文件
前言: 最近学了GUI编程和UDP协议,心血来潮想做一个局域网内的聊天软件,前期都还算顺利,直到后来将整个项目打包成jar文件时遇到了困难.如图: 自己设置的图标不见了,但是也没有默认的图标,说明图片 ...
- AndroidAnnotations框架简单使用方法
当我们配置好了框架后,那么久可以来使用了.使用教程网上一大堆,官方也有提供!!!可自行学习深造.下面我简单的贴出几个常用的方法,作为HelloWorld入门: @EActivity(R.layout. ...
- Oracle常用数据字典
1.查看所有存储过程.索引.表格.PACKAGE.PACKAGE BODY select * from user_objects; 2.查询所有的Job select * from user_jobs ...