p { margin-bottom: 0.21cm; }
Linux2.6.24 移植:LCD 驱动
平台信息
:
目标板
:
MagicARM2410
OS
:
Ubuntu10.0.4
LCD
:
SUMSANG
的
LQ080V3DG01
8
寸
640
x480
系统内核:linux2.6.24.4
在 Linux2.6.2 4 下移植 LCD 驱动程序 十分简单,只要在 内核源码 arch/arm/mach-s3c2410/mach-smdk2410.c 里添加初始化 s3c2410 的 LCD 控制器时所需要的参数。 而这些参数可以参考 arch/arm/mach-s3c2410/mach-qt2410.c 文件中对 SHARP LQ080V3DG01 型 LCD 控制器初始化的相关代码。
如果移植的内核是 linux2.6.22 的话就 有很多的区别,主要区别:
一、在
2.6.24
内核中有了重大的数据结构变化,首先他把结构拆成了二部分,一个结构是
s3c2410fb_display
另一个结构是
s3c2410fb_mach_info
,所以先根据这二个数据结构进行拆分上述结构;
二、
2.6.24
结构中对寄存器
lcdcon1-4
全部用函数进行了自动设置,我们只需对
lcdcon5
进行设置,但是并不说明其他的数据不重要,或者不用设置,只是重点在
lcdcon5
这几个数值上。
可以参考 http://hi.baidu.com/operationsystem/blog/item/eed58d2ef5727c301e30894b.html
现在我介绍一下 inux2.6.2 4 的 LCD 移植过程:
1 . 修改 arch/arm/mach-s3c2410/mach-smdk2410.c 文件
( 1 )添加头文件
#include <asm-arm/arch-s3c2410/fb.h>
( 2 )添加初始化 s3c2410 的 LCD 控制器时所需的参数
这些参数可参考 arch/arm/mach-s3c2410/mach-qt2410.c 文件中对 SHARP LQ080V3DG01 型 LCD 控制器初始化的相关代码,如下:
/* LCD driver info */
static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
{
/* Configuration for 640x480 SHARP LQ080V3DG01 */
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
.type = S3C2410_LCDCON1_TFT,
.width = 640,
.height = 480,
.pixclock = 40000, /* HCLK/4 */
.xres = 640,
.yres = 480,
.bpp = 16,
.left_margin = 44,
.right_margin = 116,
.hsync_len = 96,
.upper_margin = 19,
.lower_margin = 11,
.vsync_len = 15,
},
{
/* Configuration for 480x640 toppoly TD028TTEC1 */
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
.type = S3C2410_LCDCON1_TFT,
.width = 480,
.height = 640,
.pixclock = 40000, /* HCLK/4 */
.xres = 480,
.yres = 640,
.bpp = 16,
.left_margin = 8,
.right_margin = 24,
.hsync_len = 8,
.upper_margin = 2,
.lower_margin = 4,
.vsync_len = 2,
},
{
/* Config for 240x320 LCD */
.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 = 100000, /* HCLK/10 */
.xres = 240,
.yres = 320,
.bpp = 16,
.left_margin = 13,
.right_margin = 8,
.hsync_len = 4,
.upper_margin = 2,
.lower_margin = 7,
.vsync_len = 4,
},
};
static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
.displays = qt2410_lcd_cfg,
.num_displays = ARRAY_SIZE(qt2410_lcd_cfg),
.default_display = 0,
.lpcsel = ((0xCE6) & ~7) | 1<<4,
};
所以在 arch/arm/mach-s3c2410/mach-smdk2410.c 里的 添加如下代码:
/* Configuration for 640x480 SHARP LQ080V3DG01 */
static struct s3c2410fb_display edukit2410_lcd_cfg[] __initdata = {
{
/* Configuration for 640x480 SHARP LQ080V3DG01 */
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVVFRAME |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
.type = S3C2410_LCDCON1_TFT,
.width = 640,
.height = 480,
.pixclock = 40000, /* HCLK/4 */
.xres = 640,
.yres = 480,
.bpp = 16,
.left_margin = 44,
.right_margin = 116,
.hsync_len = 96,
.upper_margin = 19,
.lower_margin = 11,
.vsync_len = 15,
}
};
/* LCD driver info */
static struct s3c2410fb_mach_info edukit2410_fb_info __initdata = {
.displays = edukit2410_lcd_cfg,
.num_displays = ARRAY_SIZE(edukit2410_lcd_cfg),
.default_display = 0,
/* GPIOs */
.gpccon = 0xaa8002a8,
.gpccon_mask = 0xffc003fc,
.gpcup = 0xf81e,
.gpcup_mask = 0xf81e,
.gpdcon = 0xaa80aaa0,
.gpdcon_mask = 0xffc0fff0,
.gpdup = 0xf8fc,
.gpdup_mask = 0xf8fc,
/* lpc3600 control register */
.lpcsel = ((0xCE6) & ~7) | 1<<4,
};
( 3 )添加 LCD 控制器 的寄存器参数设置 函数
在 smdk2410_init 函数中添加如下代码 :
s3c24xx_fb_set_platdata(&qt2410_lcd_ info ); // 设置 LCD 控制器 的寄存器参数
效果如下:
static void __init smdk2410_init(void)
{
s3c24xx_fb_set_platdata(&edukit2410_fb_info); // 设置 LCD 控制器 的寄存器参数
platform_add_devices(smdk2410_devices, ARRAY_SIZE(smdk2410_devices));
smdk_machine_init();
}
2 . 配置内核
输入以下命令,开始配置内核。
#make menuconfig
添加如下选项:
Device Drivers --->
Graphics support --->
<*> Support for frame buffer devices --->
<*> S3C2410 LCD framebuffer support
Display device support --->
<*> Display panel/monitor support
Console display driver support --->
<*> Framebuffer Console support
[*] Framebuffer Console Rotation
[*] Select compiled-in fonts
[*] VGA 8x8 font
[*] VGA 8x16 font
[*] Mini 4x6 font
[*] Sparc console 8x16 font
[*] Bootup logo --->
--- Bootup logo
[*] Standard 224-color Linux logo
上面只涉及移植 LCD 驱动必须添加的选项,内核详细配置过程可参考网络上相关资料。
配置好内核后,输入以下命令, 重新编译内核 。
看看启动信息
……
io scheduler cfq registered
Console: switching to colour frame buffer device 30x40
fb0: s2410fb frame buffer device
……
同时可以看到 LCD 上出现了一只可爱的小企鹅 ~~~
接着我把 nfs 文件挂载到开发板后,运行 ./mplayer video.mpeg, 但是开发板屏幕上没有任何图像,而且打印了错误信息:
Can't open /dev/fb0: No such file or directory
[fbdev2] Can't open /dev/fb0: No such file or directory
解决方法:在 dev 下创建 fb0 节点
[root@(none) /dev]# mknod /dev/fb0 c 29 0
再播放 ./mplayer -nosoudn video.mpeg 就可以看到视频了