0x00 环境说明:

所使用的开发板为锐尔威视的插针版A33_Vstar

屏幕是买的第三方的KD050FWFPA011-C009A,其中LCD驱动IC为ILI9806E,所使用的接口为RGB666

0x01 修改系统配置文件:

笔者所使用的A33开发板的系统配置文件路径问:

/root/a33_linux/dragonboard/tools/pack/chips/sun8iw5p1/configs/vstar/sys_config.fex

全志A33移植LCD驱动(ILI9806E)-冯金伟博客园

打开该文件,搜索 [disp_init] ,修改[disp_init]配置如下:

[disp_init]
disp_init_enable         = 1
disp_mode                = 0

screen0_output_type      = 1
screen0_output_mode      = 2

screen1_output_type      = 0
screen1_output_mode      = 4

fb0_format               = 9
fb0_pixel_sequence       = 1
fb0_scaler_mode_enable   = 0
fb0_width                = 0
fb0_height               = 0

fb1_format               = 10
fb1_pixel_sequence       = 0
fb1_scaler_mode_enable   = 0
fb1_width                = 0
fb1_height               = 0

lcd0_backlight           = 255
lcd1_backlight           = 255

lcd0_bright              = 50
lcd0_contrast            = 50
lcd0_saturation          = 57
lcd0_hue                 = 50

lcd1_bright              = 50
lcd1_contrast            = 50
lcd1_saturation          = 57
lcd1_hue                 = 50

修改[lcd0_para]配置如下:

lcd_used            = 1

lcd_driver_name     = “default_lcd”
lcd_if              = 0
lcd_x               = 480
lcd_y               = 854
lcd_width           =
lcd_height          =
lcd_dclk_freq       = 33
lcd_pwm_used        = 1
lcd_pwm_ch          = 0
lcd_pwm_freq        = 50000
lcd_pwm_pol         = 1
lcd_hbp             = 50
lcd_ht              = 640
lcd_hfp            = 100
lcd_hspw            = 10
lcd_vbp             = 16
lcd_vt              = 1254
lcd_vfp          = 20
lcd_vspw            = 4
lcd_lvds_if         = 0
lcd_lvds_colordepth = 0
lcd_lvds_mode       = 0
lcd_frm             = 1
lcd_io_phase        = 0x0100
lcd_gamma_en        = 0
lcd_bright_curve_en = 0
lcd_cmap_en         = 0

deu_mode            = 0
lcdgamma4iep        = 22
smart_color        = 90

lcd_bl_en           =
lcd_power           =
lcd_gpio_0          =port:PH04<1><0><default><1>
lcd_gpio_1          =port:PH05<1><0><default><1>
lcd_gpio_2          =port:PH06<1><0><default><1>
lcd_gpio_3          =port:PH07<1><0><default><1>

lcdd0                    = port:PD02<2><0><default><default>
lcdd1                    = port:PD03<2><0><default><default>
lcdd2                    = port:PD04<2><0><default><default>
lcdd3                    = port:PD05<2><0><default><default>
lcdd4                    = port:PD06<2><0><default><default>
lcdd5                    = port:PD07<2><0><default><default>
lcdd6                    =
lcdd7                    =
lcdd8                    = port:PD10<2><0><default><default>
lcdd9                    = port:PD11<2><0><default><default>
lcdd10                   = port:PD12<2><0><default><default>
lcdd11                   = port:PD13<2><0><default><default>
lcdd12                   = port:PD14<2><0><default><default>
lcdd13                   = port:PD15<2><0><default><default>
lcdd14                   =
lcdd15                   =
lcdd16                   = port:PD18<2><0><default><default>
lcdd17                   = port:PD19<2><0><default><default>
lcdd18                   = port:PD20<2><0><default><default>
lcdd19                   = port:PD21<2><0><default><default>
lcdd20                   = port:PD22<2><0><default><default>
lcdd21                   = port:PD23<2><0><default><default>
lcdd22                   =
lcdd23                   =
lcdclk                   = port:PD24<2><0><default><default>
lcdde                    = port:PD25<2><0><default><default>
lcdhsync                 = port:PD26<2><0><default><default>
lcdvsync                 = port:PD27<2><0><default><default>

修改完毕之后保存退出

0x02 修改LCD驱动代码:

uboot中默认的LCD驱动初始化文件路径为:

/root/a33_linux/dragonboard/brandy/u-boot-2011.09/drivers/video_sunxi/sunxi_v2/de_bsp/lcd/panels/default_panel.c

全志A33移植LCD驱动(ILI9806E)-冯金伟博客园

首先添加头文件包含:

#include  “default_panel.h”

修改 LCD_panel_init 函数:

static void LCD_panel_init(u32 sel)
{
     LCD_KD050FW_init();
     return;
}

在前面添加 LCD_KD050FW_init 函数的定义:

static void LCD_KD050FW_init(void)
{
     RST(1);
     sunxi_lcd_delay_ms(1);
     RST(0);
     sunxi_lcd_delay_ms(10);
     RST(1);
     sunxi_lcd_delay_ms(200);

    //***************************************************************//LCD SETING
     write_cmd(0xFF);        // Change to Page 1 CMD
     write_data(0xFF);
     write_data(0x98);
     write_data(0x06);
     write_data(0x04);
     write_data(0x01);
     
     write_cmd(0x08); //Output    SDA
     write_data(0x10);

    write_cmd(0x20);//set DE/VSYNC mode   
     write_data(0x00);    

    write_cmd(0x21); //DE = 1 Active
     write_data(0x01);
     
     write_cmd(0x30);//Resolution setting 480 X 854
     write_data(0x01);
     
     write_cmd(0x31); //Inversion setting 2-dot
     write_data(0x00);
     
     write_cmd(0x40); //BT  AVDD,AVDD
     write_data(0x16); //
     
     write_cmd(0x41);  
     write_data(0x33);//22 
     
     write_cmd(0x42);       
     write_data(0x03); //VGL=DDVDH+VCIP -DDVDL,VGH=2DDVDL-VCIP
     
     write_cmd(0x43);      
     write_data(0x09); //SET VGH clamp level
     
     write_cmd(0x44);      
     write_data(0x06); //SET VGL clamp level
     
     write_cmd(0x50); //VREG1
     write_data(0x88);
     
     write_cmd(0x51); //VREG2
     write_data(0x88);
     
     write_cmd(0x52); //Flicker MSB
     write_data(0x00);
     
     write_cmd(0x53); //Flicker LSB
     write_data(0x44); //VCOM

    write_cmd(0x55); // //Flicker             
     write_data(0x49);

    write_cmd(0x60);      
     write_data(0x07);
     
     write_cmd(0x61);       
     write_data(0x00);
     
     write_cmd(0x62);     
     write_data(0x07);
     
     write_cmd(0x63);     
     write_data(0x00);
     //++++++++++++++++++ Gamma Setting ++++++++++++++++++//
     write_cmd(0xA0);  //Positive Gamma
     write_data(0x00);
     write_cmd(0xA1);        //
     write_data(0x09);
     write_cmd(0xA2);        //
     write_data(0x11);
     write_cmd(0xA3);        //
     write_data(0x0B);
     write_cmd(0xA4);        //
     write_data(0x05);
     write_cmd(0xA5);        //
     write_data(0x08);
     write_cmd(0xA6);        //
     write_data(0x06);
     write_cmd(0xA7);        //
     write_data(0x04);
     write_cmd(0xA8);        //
     write_data(0x09);
     write_cmd(0xA9);        //
     write_data(0x0C);
     write_cmd(0xAA);        //
     write_data(0x15);
     write_cmd(0xAB);        //
     write_data(0x08);
     write_cmd(0xAC);        //
     write_data(0x0F);
     write_cmd(0xAD);        //
     write_data(0x12);
     write_cmd(0xAE);        //
     write_data(0x09);
     write_cmd(0xAF);        //
     write_data(0x00);
      ///==============Nagitive
     write_cmd(0xC0);        //Negative Gamma
     write_data(0x00);
     write_cmd(0xC1);        //
     write_data(0x09);
     write_cmd(0xC2);        //
     write_data(0x10);
     write_cmd(0xC3);        //
     write_data(0x0C);
     write_cmd(0xC4);        //
     write_data(0x05);
     write_cmd(0xC5);        //
     write_data(0x08);
     write_cmd(0xC6);        //
     write_data(0x06);
     write_cmd(0xC7);        //
     write_data(0x04);
     write_cmd(0xC8);        //
     write_data(0x08);
     write_cmd(0xC9);        //
     write_data(0x0C);
     write_cmd(0xCA);        //
     write_data(0x14);
     write_cmd(0xCB);        //
     write_data(0x08);
     write_cmd(0xCC);        //
     write_data(0x0F);
     write_cmd(0xCD);        //
     write_data(0x11);
     write_cmd(0xCE);        //
     write_data(0x09);
     write_cmd(0xCF);        //
     write_data(0x00);
     
     write_cmd(0xFF); // Change to Page 6 CMD for GIP timing  
     write_data(0xFF);
     write_data(0x98);
     write_data(0x06);
     write_data(0x04);
     write_data(0x06);

    write_cmd(0x00);        //
     write_data(0x20);
     write_cmd(0x01);        //
     write_data(0x0A);
     write_cmd(0x02);        //
     write_data(0x00);
     write_cmd(0x03);        //
     write_data(0x00);
     write_cmd(0x04);        //
     write_data(0x01);
     write_cmd(0x05);        //
     write_data(0x01);
     write_cmd(0x06);        //
     write_data(0x98);
     write_cmd(0x07);        //
     write_data(0x06);
     write_cmd(0x08);        //
     write_data(0x01);
     write_cmd(0x09);        //
     write_data(0x80);
     write_cmd(0x0A);        //
     write_data(0x00);
     write_cmd(0x0B);        //
     write_data(0x00);
     write_cmd(0x0C);        //
     write_data(0x01);
     write_cmd(0x0D);        //
     write_data(0x01);
     write_cmd(0x0E);        //
     write_data(0x05);
     write_cmd(0x0F);        //
     write_data(0x00);

    write_cmd(0x10);        //
     write_data(0xF0);
     write_cmd(0x11);        //
     write_data(0xF4);
     write_cmd(0x12);        //
     write_data(0x01);
     write_cmd(0x13);        //
     write_data(0x00);
     write_cmd(0x14);        //
     write_data(0x00);
     write_cmd(0x15);        //
     write_data(0xC0);
     write_cmd(0x16);        //
     write_data(0x08);
     write_cmd(0x17);        //
     write_data(0x00);
     write_cmd(0x18);        //
     write_data(0x00);
     write_cmd(0x19);        //
     write_data(0x00);
     write_cmd(0x1A);        //
     write_data(0x00);
     write_cmd(0x1B);        //
     write_data(0x00);
     write_cmd(0x1C);        //
     write_data(0x00);
     write_cmd(0x1D);        //
     write_data(0x00);

    write_cmd(0x20);        //
     write_data(0x01);
     write_cmd(0x21);        //
     write_data(0x23);
     write_cmd(0x22);        //
     write_data(0x45);
     write_cmd(0x23);        //
     write_data(0x67);
     write_cmd(0x24);        //
     write_data(0x01);
     write_cmd(0x25);        //
     write_data(0x23);
     write_cmd(0x26);        //
     write_data(0x45);
     write_cmd(0x27);        //
     write_data(0x67);

    write_cmd(0x30);        //
     write_data(0x11);
     write_cmd(0x31);        //
     write_data(0x11);
     write_cmd(0x32);        //
     write_data(0x00);
     write_cmd(0x33);        //
     write_data(0xEE);
     write_cmd(0x34);        //
     write_data(0xFF);
     write_cmd(0x35);        //
     write_data(0xBB);
     write_cmd(0x36);        //
     write_data(0xAA);
     write_cmd(0x37);        //
     write_data(0xDD);
     write_cmd(0x38);        //
     write_data(0xCC);
     write_cmd(0x39);        //
     write_data(0x66);
     write_cmd(0x3A);        //
     write_data(0x77);
     write_cmd(0x3B);        //
     write_data(0x22);
     write_cmd(0x3C);        //
     write_data(0x22);
     write_cmd(0x3D);        //
     write_data(0x22);
     write_cmd(0x3E);        //
     write_data(0x22);
     write_cmd(0x3F);        //
     write_data(0x22);
     write_cmd(0x40);        //
     write_data(0x22);

    write_cmd(0xFF);// Change to Page 7 CMD for GIP timing  
     write_data(0xFF);
     write_data(0x98);
     write_data(0x06);
     write_data(0x04);
     write_data(0x07);

    write_cmd(0x17);      
     write_data(0x22);
     
     write_cmd(0x02);       
     write_data(0x77);

    write_cmd(0x26);       
     write_data(0xB2);

    write_cmd(0xFF); // Change to Page 0 CMD for Normal command
     write_data(0xFF);
     write_data(0x98);
     write_data(0x06);
     write_data(0x04);
     write_data(0x00);

    write_cmd(0x3A);     
     write_data(0x60);

    write_cmd(0x11);
     sunxi_lcd_delay_ms(120);
     write_cmd(0x29);
     sunxi_lcd_delay_ms(25);

}

在前面添加一些相关函数的实现:

#define SCLB(x)    sunxi_lcd_gpio_set_value(0, 0, x)
#define SDI(x)    sunxi_lcd_gpio_set_value(0, 1, x)
#define RST(x)    sunxi_lcd_gpio_set_value(0, 2, x)
#define CSB(x)    sunxi_lcd_gpio_set_value(0, 3, x)

static void write_cmd(unsigned char cmd)
{
     unsigned char i;
     CSB(0);
     SCLB(0);
     SDI(0);
     SCLB(1);
     for(i=0;i<8;i++){
         SCLB(0);  
         if(cmd & 0x80)
             SDI(1);
         else
             SDI(0);
         SCLB(1);
         cmd = cmd << 1;
     }
     CSB(1);   
}

void write_data(unsigned char data)
{
     unsigned char i;
     CSB(0);
     SCLB(0);
     SDI(1);
     SCLB(1);
     for(i=0;i<8;i++){
         SCLB(0);  
         if(data & 0x80)
             SDI(1);
         else
             SDI(0);
         SCLB(1);
         data = data << 1;
     }
     CSB(1);   
}

保存退出之后重新编译uboot

0x03 重新编译uboot:

切换到uboot目录下:

cd  ~/a33_linux/dragonboard/brandy/u-boot-2011.09/

重新编译uboot:

make  distclean

make  sun8iw5p1_config

make  -j8

编译成功之后重新打包烧录到板子即可验证