Chinaunix首页 | 论坛 | 博客
  • 博客访问: 915315
  • 博文数量: 84
  • 博客积分: 4334
  • 博客等级: 上校
  • 技术积分: 1610
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-27 07:49
文章分类

全部博文(84)

文章存档

2012年(5)

2011年(21)

2010年(58)

分类: 嵌入式

2010-11-07 10:37:27

内核里已经有很完善的 LCD 驱动了,只要根据所用的 LCD 进行简单的修改。
#vi arch/arm/mach-s3c2440/mach-smdk2440.c

修改smdk2440_lcd_cfg函数和smdk2440_fb_info函数,设置LCD参数,我的是SONY3.5寸(X35)TFT屏。如下:

参照mini2440源码:

首先定义:

  1. #define LCD_WIDTH 240
  2. #define LCD_HEIGHT 320
  3. #define LCD_PIXCLOCK 170000
  4. #define LCD_RIGHT_MARGIN 25
  5. #define LCD_LEFT_MARGIN 0
  6. #define LCD_HSYNC_LEN 4
  7. #define LCD_UPPER_MARGIN 0
  8. #define LCD_LOWER_MARGIN 4
  9. #define LCD_VSYNC_LEN 9
  10. #define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVDEN | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVCLK | S3C2410_LCDCON5_HWSWP )

然后修改smdk2440_lcd_cfg函数和smdk2440_fb_info函数。

  1. static struct s3c2410fb_display mini2440_lcd_cfg __initdata = {

  2. #if !defined (LCD_CON5)
  3.     .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  4.               S3C2410_LCDCON5_INVVLINE |
  5.               S3C2410_LCDCON5_INVVFRAME |
  6.               S3C2410_LCDCON5_PWREN |
  7.               S3C2410_LCDCON5_HWSWP,
  8. #else
  9.     .lcdcon5 = LCD_CON5,
  10. #endif

  11.     .type = S3C2410_LCDCON1_TFT,

  12.     .width = LCD_WIDTH,
  13.     .height = LCD_HEIGHT,

  14.     .pixclock = LCD_PIXCLOCK,
  15.     .xres = LCD_WIDTH,
  16.     .yres = LCD_HEIGHT,
  17.     .bpp = 16,
  18.     .left_margin = LCD_LEFT_MARGIN + 1,
  19.     .right_margin = LCD_RIGHT_MARGIN + 1,
  20.     .hsync_len = LCD_HSYNC_LEN + 1,
  21.     .upper_margin = LCD_UPPER_MARGIN + 1,
  22.     .lower_margin = LCD_LOWER_MARGIN + 1,
  23.     .vsync_len = LCD_VSYNC_LEN + 1,
  24. };

 

  1. static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
  2.     .displays = &mini2440_lcd_cfg,
  3.     .num_displays = 1,
  4.     .default_display = 0,

  5.     .gpccon = 0xaa955699,
  6.     .gpccon_mask = 0xffc003cc,
  7.     .gpcup = 0x0000ffff,
  8.     .gpcup_mask = 0xffffffff,

  9.     .gpdcon = 0xaa95aaa1,
  10.     .gpdcon_mask = 0xffc0fff0,
  11.     .gpdup = 0x0000faff,
  12.     .gpdup_mask = 0xffffffff,


  13.     .lpcsel = 0xf82,
  14. };

打开LCD的背光,如不打开就无法观测LCD是否正常工作。由开发板原理图可以看到LCD的背光电源LCD_PWR接到S3C2440的GPG4引脚上,故在mach-smdk2440.c中作如下修改:

  1. static void __init smdk2440_machine_init(void)
  2. {
  3.     s3c24xx_fb_set_platdata(&smdk2440_fb_info);

  4.     //添加下面两句代码
  5.     s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT);
  6.     s3c2410_gpio_setpin(S3C2410_GPG(4),1);

  7.     s3c_i2c0_set_platdata(NULL);
  8.     platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
  9.     smdk_machine_init();
  10. }

linux-2.6.32以上版本需要在mach-smdk2440.c中加入头文件,否则提示找不到函数。

  1. #include <linux/gpio.h>

配置内核,支持 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
启动时LCD上显示可爱的小企鹅,终端输出:
Console: switching to colour frame buffer device 40x30
fb0: s3c2410fb frame buffer device


板子启动后,查看硬件信息:

  1. cat /proc/devices

可以看到:29 fb

  1. mknod /dev/fb0 c 29 0


阅读(3656) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~