LCD 驱动中最关键的就是时钟频率(Clock frequency)的设置,时钟频率设置不对,LCD的显示就会闪,或者根本没有显示。关于这个时钟频率的推倒有点复杂,下面只是就显示驱动的设置过程做一个简要的介绍,还没有涉及代码等面。
在内核中添加各种LCD 类型的支持
打开 arch/arm/mach-s3c2440/mach-mini2440.c,先屏蔽之前的LCD 设备平台代码(蓝色部分),再把友善之臂已经移植好的代码加入(红色部分),如下:
/* LCD driver info */
/*这是以前LCD驱动的代码,移植的时候不用这个,将他屏蔽掉
static struct s3c2410fb_display mini2440_lcd_cfg __initdata = {
.lcdcon5= S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
.type= S3C2410_LCDCON1_TFT,
.width= 240,
.height= 320,
.pixclock= 166667,
.xres= 240,
.yres= 320,
.bpp= 16,
.left_margin= 20,
.right_margin= 8,
.hsync_len= 4,
.upper_margin= 8,
.lower_margin= 7,
.vsync_len= 4,
};
static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
.displays= &mini2440_lcd_cfg,
.num_displays= 1,
.default_display = 0,
#if 0
.gpccon= 0xaa940659,
.gpccon_mask= 0xffffffff,
.gpcup= 0x0000ffff,
.gpcup_mask= 0xffffffff,
.gpdcon= 0xaa84aaa0,
.gpdcon_mask= 0xffffffff,
.gpdup= 0x0000faff,
.gpdup_mask= 0xffffffff,
#endif
.lpcsel= ((0xCE6) & ~7) | 1<<4,
};*/
/新增的LCD驱动/
/* LCD driver info */
//;NEC 3.5”LCD 的配置和参数设置
#if defined(CONFIG_FB_S3C2410_N240320)
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_PIXCLOCK 100000
#define LCD_RIGHT_MARGIN 36
#define LCD_LEFT_MARGIN 19
#define LCD_HSYNC_LEN 5
#define LCD_UPPER_MARGIN 1
#define LCD_LOWER_MARGIN 5
#define LCD_VSYNC_LEN 1
//;夏普8”LCD 的配置和参数设置
#elif defined(CONFIG_FB_S3C2410_TFT640480)
#define LCD_WIDTH 640
#define LCD_HEIGHT 480
#define LCD_PIXCLOCK 80000
#define LCD_RIGHT_MARGIN 67
#define LCD_LEFT_MARGIN 40
#define LCD_HSYNC_LEN 31
#define LCD_UPPER_MARGIN 25
#define LCD_LOWER_MARGIN 5
#define LCD_VSYNC_LEN 1
//;统宝3.5”LCD 的配置和参数设置
#elif defined(CONFIG_FB_S3C2410_T240320)
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_PIXCLOCK 146250//170000
#define LCD_RIGHT_MARGIN 25
#define LCD_LEFT_MARGIN 0
#define LCD_HSYNC_LEN 4
#define LCD_UPPER_MARGIN 1
#define LCD_LOWER_MARGIN 4
#define LCD_VSYNC_LEN 1
//;群创7”LCD 的配置和参数设置
#elif defined(CONFIG_FB_S3C2410_TFT800480)
#define LCD_WIDTH 800
#define LCD_HEIGHT 480
#define LCD_PIXCLOCK 11463//40000
#define LCD_RIGHT_MARGIN 67
#define LCD_LEFT_MARGIN 40
#define LCD_HSYNC_LEN 31
#define LCD_UPPER_MARGIN 25
#define LCD_LOWER_MARGIN 5
#define LCD_VSYNC_LEN 1
//;LCD2VGA(分辨率为1024x768)模块的配置和参数设置
#elif defined(CONFIG_FB_S3C2410_VGA1024768)
#define LCD_WIDTH 1024
#define LCD_HEIGHT 768
#define LCD_PIXCLOCK 80000
#define LCD_RIGHT_MARGIN 15
#define LCD_LEFT_MARGIN 199
#define LCD_HSYNC_LEN 15
#define LCD_UPPER_MARGIN 1
#define LCD_LOWER_MARGIN 1
#define LCD_VSYNC_LEN 1
#define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_HWSWP)
#endif
然后打开drivers/video/Kconfig,在大概1935 行加入以下配置信息:
config FB_S3C2410_DEBUG
bool "S3C2410 lcd debug messages"
depends on FB_S3C2410
help
Turn on debugging messages. Note that you can set/unset at run time
through sysfs
choice
prompt "LCD select"
depends on FB_S3C2410
help
S3C24x0 LCD size select
config FB_S3C2410_T240320
boolean "3.5 inch 240X320 Toppoly LCD"
depends on FB_S3C2410
help
3.5 inch 240X320 Toppoly LCD
config FB_S3C2410_N240320
boolean "3.5 inch 240X320 NEC LCD"
depends on FB_S3C2410
help
3.5 inch 240x320 NEC LCD
config FB_S3C2410_TFT640480
boolean "8 inch 640X480 L80 LCD"
depends on FB_S3C2410
help
8 inch 640X480 LCD
config FB_S3C2410_TFT800480
boolean "7 inch 800x480 TFT LCD"
depends on FB_S3C2410
help
7 inch 800x480 TFT LCD
config FB_S3C2410_VGA1024768
boolean "VGA 1024x768"
depends on FB_S3C2410
help
VGA 1024x768
endchoice
这样,我们就完成了LCD 驱动的移植
执行make menuconfig依次展开
Device Drivers --->
Graphics support --->
<*> Support for frame buffer devices --->
LCD select (3.5 inch 240X320 Toppoly LCD) --->
然后根据自己板中LCD的实际情况
我的板子是选择第二个
make zImage之后,下载到板子上的时候,就可以看见启动的画面了。这个启动画面其实对应的就是
linux-2.6.32.2/drivers/video/logo/linux_logo_clut224.ppm
该文件是一个特殊格式的图像文件,有很多方法可以把普通的图片转换为 logo 文件,最常用的就是netpbm 工具组。使用这个工具可以生成自己的logo图像。