S5PV210(TQ210)学习笔记——LCD驱动编写
时间:11-28
来源:互联网
点击:
- lcd_info->lcd_info->screen_base=dma_alloc_writecombine(NULL,
- lcd_info->fix.smem_len,(dma_addr_t*)&(lcd_info->fix.smem_start),GFP_KERNEL);
- *vidw00add0b0=lcd_info->fix.smem_start;
- *vidw00add1b0=lcd_info->fix.smem_start+lcd_info->fix.smem_len;
- *shodowcon=0x1;
- //开启状态
- *wincon0|=1;
- *vidcon0|=3;
- /*注册fb_info*/
- ret=register_framebuffer(lcd_info);
- returnret;
- }
- staticvoidlcd_exit(void){
- unregister_framebuffer(lcd_info);
- dma_free_writecombine(NULL,lcd_info->fix.smem_len,
- (void*)lcd_info->screen_base,(dma_addr_t)lcd_info->fix.smem_start);
- iounmap(shodowcon);
- iounmap(vidw00add1b0);
- iounmap(vidw00add0b0);
- iounmap(vidosd0c);
- iounmap(vidosd0b);
- iounmap(vidosd0a);
- iounmap(wincon0);
- iounmap(vidtcon2);
- iounmap(vidtcon1);
- iounmap(vidtcon0);
- iounmap(vidcon1);
- iounmap(vidcon0);
- iounmap(gpd0dat);
- iounmap(gpd0con);
- iounmap(gpf3con);
- iounmap(gpf2con);
- iounmap(gpf1con);
- iounmap(gpf0con);
- framebuffer_release(lcd_info);
- }
- module_init(lcd_init);
- module_exit(lcd_exit);
- MODULE_LICENSE("GPL");
将上面的代码在自己的内核环境下编译,然后下载到开发板上试运行即可。
在安装驱动程序前执行指令:
- ls/dev/fb*
测试前还需要修改下内核配置,有两个原因:
(1) 内核默认配置下不支持Frame buffer
(2) 我们的驱动程序中用到了三个函数:
- .fb_fillrect=cfb_fillrect,
- .fb_copyarea=cfb_copyarea,
- .fb_imageblit=cfb_imageblit,
鉴于上面两个原因,我们需要配置内核支持Frame buffer和列举出的三个函数,另外,内核中并没有直接配置支持这三个函数的选项,权宜之计,修改下drivers/video目录下的Kconfig文件,在config FB项中添加
- selectFB_CFB_FILLRECT
- selectFB_CFB_COPYAREA
- selectFB_CFB_IMAGEBLIT
- DeviceDrivers--->
- Graphicssupport--->
- <*>Supportforframebufferdevices--->
- insmodlcd.ko
(1) 在Linux主机上编译下面的C++程序
- #include
- unsignedlongbuffer[480][800]={0};
- voidput_long_hex(unsignedlongv){
- for(inti=0;i!=4;++i){
- std::cout.put(static_cast
(0xff&(v>>(8*(3-i))))); - }
- }
- intmain(){
- for(inti=0;i!=480;++i){
- buffer[i][0]=0x00ff0000;
- buffer[i][799]=0x0000ff00;
- }
- for(inti=0;i!=800;++i){
- buffer[0][i]=0xff000000;
- buffer[479][i]=0x00ffff00;
- }
- for(inti=0;i!=480;++i){
- for(intj=0;j!=800;++j){
- put_long_hex(buffer[i][j]);
- }
- }
- }
- g++-omainmain.cpp
- ./main>/nfsroot/rootfs/test.img
- cattest.img>/dev/fb0
如果想将驱动编译进内核,并在启动时可以看到小企鹅,可以将上面的驱动拷贝到内核的drivers/video/目录下,命名为tq210_fb.c,然后在该目录下做如下修改:
(1)修改Kconfig,添加TQ210的LCD驱动配置选项
在config FB_S4C项的后面添加如下内容:
- configFB_TQ210
- tristate"TQ210lcdsupport"
- dependsonFB
- selectFB_CFB_FILLRECT
- selectFB_CFB_COPYAREA
- selectFB_CFB_IMAGEBLIT
- ---help---
- CurrentlythesuportisonlyfortheTQ210
- obj-$(CONFIG_FB_TQ210)+=tq210_fb.o
(3)退回到内核根目录下,执行make menuconfig并按如下方式配置内核
- DeviceDrivers--->
- Graphicssupport--->
- <*>Supportforframebufferdevices--->
- <*>TQ210lcdsupport
- [*]Bootuplogo--->
- [*]StandardblackandwhiteLinuxlogo
- [*]Standard16-colorLinuxlogo
- [*]Standard224-color
S5PV210LCD驱动编 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)