我们这一篇来说与具体的TFT显示器有关的部分,当遇到具体的显示器是我们应该设置什么参数,怎样设置这些参数。
1、在s3cfb_WXCAT43.c (linux2.6.28driversvideosamsung)文件中是有关具体显示器的设置。我们一段一段来看。
#include #include #include #include #include #include #include "s3cfb.h" #define S3CFB_HFP 2/* front porch */ #define S3CFB_HSW 41/* hsync width */ #define S3CFB_HBP 2/* back porch */ #define S3CFB_VFP 2/* front porch */ #define S3CFB_VSW 10/* vsync width */ #define S3CFB_VBP 2/* back porch */ #define S3CFB_HRES 480/* horizon pixel x resolition */ #define S3CFB_VRES 272/* line cnt y resolution */ #define S3CFB_HRES_VIRTUAL 480/* horizon pixel x resolition */ #define S3CFB_VRES_VIRTUAL 544/* line cnt y resolution */ #define S3CFB_HRES_OSD 480/* horizon pixel x resolition */ #define S3CFB_VRES_OSD 272/* line cnt y resolution */ #define S3CFB_VFRAME_FREQ 60/* frame rate freq */ #define S3CFB_PIXEL_CLOCK (S3CFB_VFRAME_FREQ * (S3CFB_HFP + S3CFB_HSW + S3CFB_HBP + S3CFB_HRES) * (S3CFB_VFP + S3CFB_VSW + S3CFB_VBP + S3CFB_VRES))这个不太明白是干嘛用的? 那么上面这些参数的值是在那里得到的呢?那就要看具体的显示器的手册了。如下所示: 2、在这个文件中,还有两个函数,源码如下: void s3cfb_init_hw(void) { printk(KERN_INFO "LCD TYPE :: LTE480WV will be initializedn"); s3cfb_set_fimd_info(); s3cfb_set_gpio(); } 这个函数在s3cfb_init_fbinfo函数中被调用,其实就是在LCD对应的probe函数中被调用。 static void s3cfb_init_fbinfo(s3cfb_info_t *finfo, char *drv_name, int index) { int i = 0; if (index == 0) s3cfb_init_hw(); ......... } 2.1、现在来分析s3cfb_set_fimd_info函数,源码如下: static void s3cfb_set_fimd_info(void) { s3cfb_fimd.vidcon1 = S3C_VIDCON1_IHSYNC_INVERT | S3C_VIDCON1_IVSYNC_INVERT | S3C_VIDCON1_IVDEN_NORMAL; 其中有#define S3C_VIDCON1_IHSYNC_INVERT(1<<6) #define S3C_VIDCON1_IVSYNC_INVERT(1 << 5) #define S3C_VIDCON1_IVDEN_NORMAL(0<<4) 看下图: s3cfb_fimd.vidtcon0 = S3C_VIDTCON0_VBPD(S3CFB_VBP - 1) | S3C_VIDTCON0_VFPD(S3CFB_VFP - 1) | S3C_VIDTCON0_VSPW(S3CFB_VSW - 1); 其中有: /* VIDEO Time Control 0 register - VIDTCON0 */ #define S3C_VIDTCON0_VBPDE(x) (((x)&0xFF)<<24) #define S3C_VIDTCON0_VBPD(x) (((x)&0xFF)<<16) #define S3C_VIDTCON0_VFPD(x) (((x)&0xFF)<<8) #define S3C_VIDTCON0_VSPW(x) (((x)&0xFF)<<0) s3cfb_fimd.vidtcon1 = S3C_VIDTCON1_HBPD(S3CFB_HBP - 1) | S3C_VIDTCON1_HFPD(S3CFB_HFP - 1) | S3C_VIDTCON1_HSPW(S3CFB_HSW - 1); s3cfb_fimd.vidtcon2 = S3C_VIDTCON2_LINEVAL(S3CFB_VRES - 1) | S3C_VIDTCON2_HOZVAL(S3CFB_HRES - 1); s3cfb_fimd.vidosd0a = S3C_VIDOSDxA_OSD_LTX_F(0) | S3C_VIDOSDxA_OSD_LTY_F(0); s3cfb_fimd.vidosd0b = S3C_VIDOSDxB_OSD_RBX_F(S3CFB_HRES - 1) | S3C_VIDOSDxB_OSD_RBY_F(S3CFB_VRES - 1); s3cfb_fimd.vidosd1a = S3C_VIDOSDxA_OSD_LTX_F(0) | S3C_VIDOSDxA_OSD_LTY_F(0); s3cfb_fimd.vidosd1b = S3C_VIDOSDxB_OSD_RBX_F(S3CFB_HRES_OSD - 1) | S3C_VIDOSDxB_OSD_RBY_F(S3CFB_VRES_OSD - 1); 这些也和上面一样的,对照手册,设置就可以了。 s3cfb_fimd.width = S3CFB_HRES; 屏幕的大小信息 s3cfb_fimd.height = S3CFB_VRES; s3cfb_fimd.xres = S3CFB_HRES; s3cfb_fimd.yres = S3CFB_VRES; #if defined(CONFIG_FB_S3C_VIRTUAL_SCREEN) 与虚拟屏有关 s3cfb_fimd.xres_virtual = S3CFB_HRES_VIRTUAL; s3cfb_fimd.yres_virtual = S3CFB_VRES_VIRTUAL; #else s3cfb_fimd.xres_virtual = S3CFB_HRES; s3cfb_fimd.yres_virtual = S3CFB_VRES; #endif s3cfb_fimd.osd_width = S3CFB_HRES_OSD; 还记得上一篇中OSD的含义吗? s3cfb_fimd.osd_height = S3CFB_VRES_OSD; s3cfb_fimd.osd_xres = S3CFB_HRES_OSD; s3cfb_fimd.osd_yres = S3CFB_VRES_OSD; s3cfb_fimd.osd_xres_virtual = S3CFB_HRES_OSD; s3cfb_fimd.osd_yres_virtual = S3CFB_VRES_OSD; s3cfb_fimd.pixclock = S3CFB_PIXEL_CLOCK; s3cfb_fimd.hsync_len = S3CFB_HSW; s3cfb_fimd.vsync_len = S3CFB_VSW; s3cfb_fimd.left_margin = S3CFB_HFP; s3cfb_fimd.upper_margin = S3CFB_VFP; s3cfb_fimd.right_margin = S3CFB_HBP; s3cfb_fimd.lower_margin = S3CFB_VBP; } 2.2、接着分析另外一个函数s3cfb_set_gpio(),这个函数的源码如下: int s3cfb_set_gpio(void) { unsigned long val; int i, err; /* Must be '0' for Normal-path instead of By-pass */ writel(0x0, S3C_HOSTIFB_MIFPCON); 其中有:#define S3C_HOSTIFB_MIFPCONS3C_HOSTIFBREG(0x800C) #define S3C_HOSTIFAREG(x)((x) + S3C64XX_VA_HOSTIFA) 同时在s3c6410的手册上有这么一句话: Caution 1: In normal display mode, SEL_BYPASS@ MIFPCON (0x7410_800C) register must be set “0”. /* enable clock to LCD */使能LCD的时钟 val = readl(S3C_HCLK_GATE); val |= S3C_CLKCON_HCLK_LCD; writel(val, S3C_HCLK_GATE); /* phantom */也和时钟有关 val = readl(S3C_SCLK_GATE); val |= (1<<14); writel(val, S3C_SCLK_GATE); /* ------- */ /* select TFT LCD type (RGB I/F) */设置RGB的数据格式 val = readl(S3C64XX_SPC_BASE); val &= ~0x3; val |= (1 << 0); writel(val, S3C64XX_SPC_BASE); 其中有:#define S3C64XX_SPC_BASE(S3C64XX_VA_GPIO + 0x01A0) 这个参数的设置,和具体的TFT屏有关,在TFT屏的手册中有:24bit RGB Interface /* VD */主要是芯片引脚的设置,看下图:不过你可能对s3c_gpio_cfgpin函数不明白,它是怎样实现的,我在以前的写的一篇博客中有说明,你可以去查看,本篇后面我会给出链接地址。 for (i = 0; i < 16; i++) s3c_gpio_cfgpin(S3C64XX_GPI(i), S3C_GPIO_SFN(2)); for (i = 0; i < 12; i++) s3c_gpio_cfgpin(S3C64XX_GPJ(i), S3C_GPIO_SFN(2)); #ifndef CONFIG_BACKLIGHT_PWM /* backlight ON */ //printk("oPEN LCD BACKLIGHT1.n"); 和LCD背光灯有关,看下面的图: if (gpio_is_valid(S3C64XX_GPF(14))) { //NOTE: orign GPF15 here err = gpio_request(S3C64XX_GPF(14), "GPF"); if (err) { printk(KERN_ERR "failed to request GPF for " "lcd backlight controln"); return err; } gpio_direction_output(S3C64XX_GPF(14), 1); gpio_set_value(S3C64XX_GPF(14), 1); } #endif //printk("oPEN LCD BACKLIGHT2.n"); if (gpio_is_valid(S3C64XX_GPE(0))) { err = gpio_request(S3C64XX_GPE(0), "GPE"); if (err) { printk(KERN_ERR "failed to request GPE for " "lcd reset controln"); return err; } gpio_direction_output(S3C64XX_GPE(0), 1); } gpio_set_value(S3C64XX_GPE(0), 1); gpio_free(S3C64XX_GPE(0)); /* module reset */ /*if (gpio_is_valid(S3C64XX_GPN(5))) { err = gpio_request(S3C64XX_GPN(5), "GPN"); if (err) { printk(KERN_ERR "failed to request GPN for " "lcd reset controln"); return err; } gpio_direction_output(S3C64XX_GPN(5), 1); } mdelay(100); gpio_set_value(S3C64XX_GPN(5), 0); mdelay(10); gpio_set_value(S3C64XX_GPN(5), 1); mdelay(10); */ #ifndef CONFIG_BACKLIGHT_PWM gpio_free(S3C64XX_GPF(14)); #endif //gpio_free(S3C64XX_GPN(5)); return 0; } 在这个函数出现了许多对GPIO操作的函数,如:s3c_gpio_cfgpin,gpio_direction_output等等,你可能不熟悉这些,下面这个地址链接对这些讲解的很详细。
上一篇:linux中LCD设备驱动(6)——Fbmem.c文件
下一篇:linux中LCD设备驱动(1)——framebuffer(帧缓冲)
推荐阅读最新更新时间:2024-11-06 11:57
设计资源 培训 开发板 精华推荐
- SX1308_正负电源
- 使用 Cypress Semiconductor 的 MB39C022L 的参考设计
- USB转TTL模块【USB-A与TYPE-C双口输入,带开关】
- LT3990IMSE 5V 降压转换器的典型应用
- NCL30288LED1GEVB:功率因数校正准谐振初级侧电流模式控制器评估板
- OP184ESZ-REEL7 高端负载电流监控器的典型应用
- Eizz Factory 电吉他法滋效果器
- LT6656AIDC-3、3V 升压输出电流电压基准的典型应用
- 使用 Richtek Technology Corporation 的 RT8110A 的参考设计
- 具有关断功能的 LTC1407HMSE 串行 12 位、3Msps 同时采样 ADC 的典型应用