framebuffer驱动全篇(三)

来源:互联网 发布:宝宝成长日记软件 编辑:程序博客网 时间:2024/05/22 04:44

Color Map 剖析
在framebuffer驱动程序设计中,cmap这个东东太晕了。现在我要把他赤裸裸的剖析给大家:)

1. struct fb_cmap


/*颜色映射表*/
struct fb_cmap {
__u32 start; /* First entry */
__u32 len; /* Number of entries */
__u16 *red; /* 红色 */
__u16 *green; /*绿色*/
__u16 *blue; /*蓝色*/
__u16 *transp; /* 透明度,允许 NULL */
};
该结构在fb.h文件中定义,在struct fb_ops结构中有两个成员函数与其相关:
/*获取颜色表*/
int (*fb_get_cmap)(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
/*设定颜色表*/
int (*fb_set_cmap)(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
在struct fb_info结构中有变量:
struct fb_cmap cmap; /* Current cmap */
在fpgen基础操作下提供:
extern int fbgen_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
extern int fbgen_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info);
在文件/* drivers/video/fbcmap.c */中提供更多的cmap应用
extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
extern void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto);
extern int fb_get_cmap(struct fb_cmap *cmap, int kspc,
int (*getcolreg)(u_int, u_int *, u_int *, u_int *,u_int *, struct fb_info *),
struct fb_info *fb_info);
extern int fb_set_cmap(struct fb_cmap *cmap, int kspc,
int (*setcolreg)(u_int, u_int, u_int, u_int, u_int,struct fb_info *),
struct fb_info *fb_info);
extern struct fb_cmap *fb_default_cmap(int len);
extern void fb_invert_cmaps(void);

2. 通过文件解析

在anakinfb.c文件中,cmap如图


在stifb.c

原创粉丝点击