由于SMDK2440的BSP中使用的LCD驱动,是基于320*240的LCD,而开发板使用的是480*272的,时序也有所不同,因此需要修改驱动程序,才能让LCD正常显示。
一、修改public\common\oak\CSP\arm\samsung\s3c2440a\Inc\s3c2440a_lcd.h头文件:
修改分辨率和虚拟屏幕大小:
- #define LCD_XSIZE_TFT (480)
- #define LCD_YSIZE_TFT (272)
- #define LCD_SCR_XSIZE_TFT (960) // virtual screen
- #define LCD_SCR_YSIZE_TFT (544)
修改时序的配置:
LTE430WQ时序图
S3C2440的LCD控制器时序图
如上图,比较LTE430WQ-F0C和s3c2440两个手册中的时序图,可以得出:
VBP = (VBPD+1)+(VSPW+1) = 12 =》VBPD=1
VLW = VSPW+1 = 10 =》VSPW=9
VFP = VFPD+1 = 4 =》VFPD=3
HBP = (HBPD+1)+(HSPW+1) = 45 =》HBPD=3
HLW = HSPW+1 = 41 =》HSPW=40
HFP = HFPD+1 = 8 =》HFPD=7
其中,VBP、VLW、VFP、HBP、HLW、HFP是LTE430WQ-F0C手册中的术语,VBPD、VSPW、VFPD、HBPD、HSPW、HFPD是S3C2440手册中需要设置的寄存器。
修改如下:
- #define LCD_VBPD ((1)&0xff)
- #define LCD_VFPD ((3)&0xff)
- #define LCD_VSPW ((9)&0x3f)
- #define LCD_HBPD ((3)&0x7f)
- #define LCD_HFPD ((7)&0xff)
- #define LCD_HSPW ((40)&0xff)
计算CLKVAL:
查s3c2440手册 VCLK = HCLK / ((CLKVAL + 1) * 2)
则CLKVAL = HCLK / (VCLK * 2) - 1
查LCD手册,取 VCLK = 9.2MHz
则
Frame Rate = VCLK / (HSPW + HBPD + HOZVAL + HFPD) / (VSPW + VBPD + LINEVAL + VFPD)
= 9.2MHz / (40 + 3 + 480 + 7) / (9 + 1 + 272 + 3)
= 60Hz
二、修改PLATFORM\SMDK2440A\Src\bootloader\eboot\main.c文件的InitDisplay函数:
设置LCD_PWREN:
- s2440IOP->GPGUP |= (1<<4);
- s2440IOP->GPGCON |= (3<<8);
修改CLKVAL:
- clkval_calc = (WORD)((float)(S3C2440A_HCLK)/(2.0*9200000)+0.5)-1;
修改LCDCON1和LCDCON5的配置:
- s2440LCD->LCDCON1 = (clkval_calc << 8) | /* VCLK = HCLK / ((CLKVAL + 1) * 2) -> About 9 Mhz */
- ( 0 << 7 ) | /* 0 : Each Frame */
- ( 3 << 5 ) | /* TFT LCD Pannel */
- ( 12 << 1 ) | /* 16bpp Mode */
- ( 0 << 0 ) ; /* Disable LCD Output */
- s2440LCD->LCDCON5 = (0 << 12) | /* BPP24BL : LSB valid */
- (1 << 11) | /* FRM565 MODE : 5:6:5 Format */
- (0 << 10) | /* INVVCLK : VCLK Falling Edge */
- (1 << 9) | /* INVVLINE : Inverted Polarity */
- (1 << 8) | /* INVVFRAME : Inverted Polarity */
- (0 << 7) | /* INVVD : Normal */
- (0 << 6) | /* INVVDEN : Normal */
- (0 << 5) | /* INVPWREN : Normal */
- (0 << 4) | /* INVENDLINE : Normal */
- (1 << 3) | /* PWREN : Enable PWREN */
- (0 << 2) | /* ENLEND : Disable LEND signal */
- (0 << 1) | /* BSWP : Swap Disable */
- (1 << 0) ; /* HWSWP : Swap Enable */
删除配置TCONSEL寄存器的语句:
- //s2440LCD->TCONSEL |= (0x1<<4);
三、按照步骤2的方法修改PLATFORM\SMDK2440A\Src\Kernel\Oal\init.c的InitDisplay函数。