分类: LINUX
2008-11-26 15:11:02
uClinux 的framebuffer简介 下面的内容主要是关于framebuffer 的一些知识, 主要是根据我们实际开发过程中的一些体会,其中难免错漏之处, 欢迎指正。 什么是framebuffer 设备? framebuffer 是一种能够提取图形的硬件设备,是用户进入图形界面很好的接口。有了framebuffer,用户的应用程序不需要对底层的驱动的深入了解就能够做出很好的图形。对于用户而言,它和/dev 下面的其他设备没有什么区别,用户可以把framebuffer 看成一块内存,既可以向这块内存中写入数据,也可以从这块内存中读取数据。第一个被注册的framebuffer 的minor 等于0,第二个被注册的framebuffer的minor 等于1,以此类推。 framebuffer 内部结构 数据结构:framebuffer 设备很大程度上依靠了下面四个数据结构。这三个结构在fb.h 中声明。 Struct fb_var_screeninfo Struct fb_fix_screeninfo Struct fb_info 第一个结构是用来描述图形卡的特性的。通常是被用户设置的。 第二个结构定义了图形卡的硬件特性,是不能改变的,用户选定了哪一个图形卡,那么它的硬件特性也就定下来了。 第三个结构定义了当前图形卡framebuffer 设备的独立状态,一个图形卡可能有两个framebuffer, 在这种情况下,就需要两个fb_info 结构。这个结构是唯一在内核空间可见的。 设计自己的framebuffer 设备驱动 用户首先需要添加下面的代码到fbmem.c static struct { const char *name; int (*init)(void); int (*setup)(char*); } fb_drivers[] __initdata = { #ifdef CONFIG_FB_YOURCARD { "driver_name", xxxfb_init, xxxfb_setup }, #endif 其次在xxfb.c 中根据自己的需要重新分配显存大小。例如: #define VIDEOMEMSIZE (1*1024*1024) /* 1 MB */ 再次根据自己的硬件设备修改相应的var 信息。主要修改xxfb_set_var(structfb_var_screeninfo *var, int con, struct fb_info *info)函数。 如何添加framebuffer 设备驱动 在make menuconfig 的时候首先进入Character devices,选中里面的Virtualterminal.如果希望控制台在液晶上输出,则选中Support for console on virtual terminal。(选用了msh(minix shell),再在rc中放入了一条sh < /dev/ttyS0,通过串口输入的键值显示输出就能在LCD上显示了。) 退到上一层界面我们就可以看到Console device 的选项,进入后将光标落在Framebuffer Support 上,按回车键进入,在里面选择自己所需要的framebuffer设备即可。自己所添加的设备驱动的类型(如果在uclinux 下,应该以*选中,而不是M 选中),在编译的时候就会产生相应的.o 文件。 在Advanced low level 中可以配置bpp packed pixel support,然后选中Selectcompiled-in fonts 即可。等操作系统运行以后就会在/dev 下面看到fb 这个设备。它的major 应该是29,第一个设备的minor 应该是0。 如何使用framebuffer 设备 我们可以在几个支持图形显示的平台上开发一些图形界面。例如microwindows,minigui,Qtembed,等等。 阅读代码后确认应该是如下信息!呵呵 static struct { const char *name; int (*init)(void); int (*setup)(char*); } fb_drivers[] __initdata = { #ifdef CONFIG_FB_SBUS /* * Sbusfb must be initialized _before_ other frame buffer devices that * use PCI probing */ { "sbus", sbusfb_init, sbusfb_setup }, #endif /* * Chipset specific drivers that use resource management */ . /* * Generic drivers that are used as fallbacks * * These depend on resource management and must be initialized * _after_ all other frame buffer devices that use resource * management! */ #ifdef CONFIG_FB_M68328 { "68328fb", m68328fb_init,m68328fb_setup }, #endif #ifdef CONFIG_FB_MC68X328 { "mc68x328fb", mc68x328fb_init, mc68x328fb_setup }, #endif #ifdef CONFIG_FB_OF { "offb", offb_init, NULL }, #endif #ifdef CONFIG_FB_VESA { "vesa", vesafb_init, vesafb_setup }, #endif /* * Chipset specific drivers that don't use resource management (yet) */ #ifdef CONFIG_FB_3DFX { "tdfx", tdfxfb_init, tdfxfb_setup }, #endif #ifdef CONFIG_FB_SGIVW { "sgivw", sgivwfb_init, sgivwfb_setup }, #endif #ifdef CONFIG_FB_ACORN { "acorn", acornfb_init, acornfb_setup }, #endif #ifdef CONFIG_FB_ATARI { "atafb", atafb_init, atafb_setup }, #endif #ifdef CONFIG_FB_MAC { "macfb", macfb_init, macfb_setup }, #endif #ifdef CONFIG_FB_HGA { "hga", hgafb_init, hgafb_setup }, #endif #ifdef CONFIG_FB_MAXINE { "maxinefb", maxinefb_init, NULL }, #endif #ifdef CONFIG_FB_AU1100 { "au1100fb", au1100fb_init, au1100fb_setup }, #endif #ifdef CONFIG_FB_S3C44B0X { "s3c44b0xfb", s3c44b0xfb_init, s3c44b0xfb_setup }, #endif }; 的点屏工作有所进展。可以在lcd上看到uclinux的标志性图标小企鹅了,图像较为清晰!同时通过进一步更改选项并编译,也能够通过lcd看到uclinux的启动过程,但很不清楚,不只是何原因?我向按照楼主的文章应该没错了,但是通过lcd将串口控制台的信息显示到lcd上还是有问题,明天贴出相关的图片望讨论一下! |