S5PV210(TQ210)学习笔记——LCD驱动编写
网上S5PV210内核移植的文章不是很多,而描述2440和6410内核移植的文章多数是讲如何移植,而非手动编写,但是,韦东山老师的视频中讲述了如何从头编写LCD驱动,当然是以2440为例的,我看过视频之后在TQ210平台上进行了实验,实验成功,详细的原理部分以我现在的水平还难以表达清楚。下载是我自己写的代码,适用于TQ210的7寸电容屏。
- #include
- #include
- #include
- #include
- staticstructfb_info*lcd_info;
- unsignedlongpseudo_palette[16];
- unsignedlong*display_control;
- volatileunsignedlong*gpf0con;
- volatileunsignedlong*gpf1con;
- volatileunsignedlong*gpf2con;
- volatileunsignedlong*gpf3con;
- volatileunsignedlong*gpd0con;
- volatileunsignedlong*gpd0dat;
- volatileunsignedlong*vidcon0;
- volatileunsignedlong*vidcon1;
- volatileunsignedlong*vidtcon0;
- volatileunsignedlong*vidtcon1;
- volatileunsignedlong*vidtcon2;
- volatileunsignedlong*wincon0;
- volatileunsignedlong*vidosd0a;
- volatileunsignedlong*vidosd0b;
- volatileunsignedlong*vidosd0c;
- volatileunsignedlong*vidw00add0b0;
- volatileunsignedlong*vidw00add1b0;
- volatileunsignedlong*shodowcon;
- structclk*lcd_clk;
- staticinlineunsignedintchan_to_field(unsignedintchan,structfb_bitfield*bf)
- {
- chan&=0xffff;
- chan>>=16-bf->length;
- returnchan<
offset; - }
- staticintlcdfb_setcolreg(unsignedintregno,unsignedintred,
- unsignedintgreen,unsignedintblue,
- unsignedinttransp,structfb_info*info)
- {
- unsignedintval;
- if(regno>16)
- return1;
- /*用red,green,blue三原色构造出val*/
- val=chan_to_field(red,&info->var.red);
- val|=chan_to_field(green,&info->var.green);
- val|=chan_to_field(blue,&info->var.blue);
- //((u32*)(info->pseudo_palette))[regno]=val;
- pseudo_palette[regno]=val;
- return0;
- }
- staticstructfb_opslcd_fbops={
- .owner=THIS_MODULE,
- .fb_setcolreg=lcdfb_setcolreg,
- .fb_fillrect=cfb_fillrect,
- .fb_copyarea=cfb_copyarea,
- .fb_imageblit=cfb_imageblit,
- };
- staticintlcd_init(void){
- intret;
- /*分配fb_info*/
- lcd_info=framebuffer_alloc(0,NULL);
- if(lcd_info==NULL){
- printk(KERN_ERR"allocframebufferfailed!");
- return-ENOMEM;
- }
- /*配置fb_info各成员*/
- /*fix*/
- strcpy(lcd_info->fix.id,"s5pv210_lcd");
- lcd_info->fix.smem_len=800*480*4;
- lcd_info->fix.type=FB_TYPE_PACKED_PIXELS;
- lcd_info->fix.visual=FB_VISUAL_TRUECOLOR;
- lcd_info->fix.line_length=800*4;
- /*var*/
- lcd_info->var.xres=800;
- lcd_info->var.yres=480;
- lcd_info->var.xres_virtual=800;
- lcd_info->var.yres_virtual=480;
- lcd_info->var.bits_per_pixel=32;
- lcd_info->var.red.offset=16;
- lcd_info->var.red.length=8;
- lcd_info->var.green.offset=8;
- lcd_info->var.green.length=8;
- lcd_info->var.blue.offset=0;
- lcd_info->var.blue.length=8;
- lcd_info->var.activate=FB_ACTIVATE_NOW;
-
关键词: S5PV210LCD驱动编

加入微信
获取电子行业最新资讯
搜索微信公众号:EEPW
或用微信扫描左侧二维码
相关文章
-
嵌入式系统 2016-11-28