内核中s3c2440的LCD控制器驱动文件是:drivers/video/s3c2410fb.c,三星已经帮我们把LCD控制器和Framebuffer的驱动都做好了,
我们不需要修改这个驱动,只需要在mach-xc2440.c中创建我们所使用的LCD的平台数据,填充s3c2410fb_mach_info结构体。
我们使用的是4.3寸的LCD,标准的RGB接口,分辨率480X272,颜色位数使用16位的,带有PWM调光功能(关于PWM调光在第11节)
要包含lcd驱动的头文件:
- #include <mach/fb.h>
定义所使用的LCD类型:
- #define LCD480272 0
- #define LCD800480 1
- #define LCD_TYPE LCD480272 //4.3 inch lcd
在xc2440_devices[ ]平台设备结构体数组中加入lcd设备:
&s3c_device_lcd,
在xc2440_machine_init函数中加入设置lcd平台数据函数:
s3c24xx_fb_set_platdata(&xc2440_fb_info);
构建xc2440_fb_info结构体:
- static struct s3c2410fb_mach_info xc2440_fb_info __initdata = {
- .displays = &xc2440_lcd_cfg,
- .num_displays = 1,
- .default_display = 0,
- };
构建LCD配置结构体xc2440_lcd_cfg:
- /* LCD driver info */
- static struct s3c2410fb_display xc2440_lcd_cfg __initdata = {
- .lcdcon5 = S3C2410_LCDCON5_FRM565 |
- S3C2410_LCDCON5_INVVLINE |
- S3C2410_LCDCON5_INVVFRAME |
- S3C2410_LCDCON5_PWREN |
- S3C2410_LCDCON5_HWSWP,
- .type = S3C2410_LCDCON1_TFT,
-
- #if (LCD_TYPE == LCD480272)
- .width = 480,
- .height = 272,
- .pixclock = (2*1000000000000LL)/80 * \
- 317B(8 + 43 + 2 + 480) * \
- 318B(12 + 4 + 10 + 272),
- .xres = 480,
- .yres = 272,
- .bpp = 16,
- .left_margin = 8,
- .right_margin = 43,
- .hsync_len = 2,
- .upper_margin = 4,
- .lower_margin = 12,
- .vsync_len = 10,
- #elif(LCD_TYPE == LCD800480)
- .width = 800,
- .height = 480,
- .pixclock = (2*1000000000000LL)/60 * \
- (48 + 40 + 40 + 800) * \
- (3 + 13 + 29 + 480),
- .xres = 800,
- .yres = 480,
- .bpp = 16,
- .left_margin = 40,
- .right_margin = 40,
- .hsync_len = 48,
- .upper_margin = 13,
- .lower_margin = 29,
- .vsync_len = 3,
- #endif
- };
说明:s3c2410fb_display结构体设置屏的所有参数,包括分辨率,颜色位数,像素时钟,和行场信号一些参数,这些值都传递给S3C2440的LCD控制器,在s3c2410fb.c中设置
其中像素时钟有一个算法,请见上面的代码pixclock,具体的值也要根据LCD的显示效果来调节
配置内核,支持LCD:
- Device Drivers:
- Graphics Support --->
- <*>support for frame buffer devices --->
- [*] Enable frameware EDID
- [*] Enable Vidoe Mode Handling Helpers
- <*> S3C24X0 LCD framebuffer support
- Console display driver support --->
- <*> Framebuffer Console Support
- [*] Bootup Logo --->
- <*> Standard 224-color Linux logo
启动时输出:
Console: switching to colour frame buffer device 40x30
fb0: s3c2410fb frame buffer device
屏点亮后会在LCD上看到linux的企鹅LOGO