滴滴FAE

如果不是生活、情怀、使命所迫,谁愿意把自己搞得才华横溢!滴滴调屏,分享经验。

LH320H04(LG3.2+NT35410)在全志R16平台调试

0
阅读(231) 评论(0)


#include "NT35410.h"


static void LCD_power_on(__u32 sel);

static void LCD_power_off(__u32 sel);

static void LCD_bl_open(__u32 sel);

static void LCD_bl_close(__u32 sel);


static void LCD_panel_init(__u32 sel);

static void LCD_panel_exit(__u32 sel);

extern __s32 dsi_dcs_wr_0para(__u32 sel,__u8 cmd);

extern __s32 dsi_dcs_wr_1para(__u32 sel,__u8 cmd,__u8 para);

extern __s32 dsi_dcs_wr(__u32 sel,__u8 cmd,__u8* para_p,__u32 para_num);

#define Delay(x) sunxi_lcd_delay_ms(x)

static void LCD_cfg_panel_info(panel_extend_para * info)

{

    u32 i = 0, j=0;

    u32 items;

    u8 lcd_gamma_tbl[][2] =

    {

        //{input value, corrected value}

        {0, 0},

        {15, 15},

        {30, 30},

        {45, 45},

        {60, 60},

        {75, 75},

        {90, 90},

        {105, 105},

        {120, 120},

        {135, 135},

        {150, 150},

        {165, 165},

        {180, 180},

        {195, 195},

        {210, 210},

        {225, 225},

        {240, 240},

        {255, 255},

    };



    u32 lcd_cmap_tbl[2][3][4] = {

        {

            {LCD_CMAP_G0,LCD_CMAP_B1,LCD_CMAP_G2,LCD_CMAP_B3},

            {LCD_CMAP_B0,LCD_CMAP_R1,LCD_CMAP_B2,LCD_CMAP_R3},

            {LCD_CMAP_R0,LCD_CMAP_G1,LCD_CMAP_R2,LCD_CMAP_G3},

        },

        {

            {LCD_CMAP_B3,LCD_CMAP_G2,LCD_CMAP_B1,LCD_CMAP_G0},

            {LCD_CMAP_R3,LCD_CMAP_B2,LCD_CMAP_R1,LCD_CMAP_B0},

            {LCD_CMAP_G3,LCD_CMAP_R2,LCD_CMAP_G1,LCD_CMAP_R0},

        },

    };

    items = sizeof(lcd_gamma_tbl)/2;

    for(i=0; i<items-1; i++) {

        u32 num = lcd_gamma_tbl[i+1][0] - lcd_gamma_tbl[i][0];


        for(j=0; j<num; j++) {

            u32 value = 0;


            value = lcd_gamma_tbl[i][1] + ((lcd_gamma_tbl[i+1][1] - lcd_gamma_tbl[i][1]) * j)/num;

            info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] = (value<<16) + (value<<8) + value;

        }

    }

    info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items-1][1]<<16) + (lcd_gamma_tbl[items-1][1]<<8) + lcd_gamma_tbl[items-1][1];


    memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));


}


static __s32 LCD_open_flow(__u32 sel)

{

    printk("sclu %s\n", __func__);

    LCD_OPEN_FUNC(sel, LCD_power_on, 30);   //open lcd power, and delay 50ms

    LCD_OPEN_FUNC(sel, LCD_panel_init, 10);   //open lcd power, than delay 200ms

    LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 100);     //open lcd controller, and delay 100ms

    LCD_OPEN_FUNC(sel, LCD_bl_open, 0);     //open lcd backlight, and delay 0ms


    return 0;

}


static __s32 LCD_close_flow(__u32 sel)

{

    LCD_CLOSE_FUNC(sel, LCD_bl_close, 0);       //close lcd backlight, and delay 0ms

    LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);         //close lcd controller, and delay 0ms

    LCD_CLOSE_FUNC(sel, LCD_panel_exit, 20);   //open lcd power, than delay 200ms

    LCD_CLOSE_FUNC(sel, LCD_power_off, 50);   //close lcd power, and delay 500ms


    return 0;

}


static void LCD_power_on(__u32 sel)

{

    printk(KERN_ERR "<<<<<<<<<<<<<<<<<<<<<<<<<<<<11111<<<<<<<<<<<<<<<<<<<<<<<<<<");

    sunxi_lcd_power_enable(sel, 0);//config lcd_power pin to open lcd power0

    sunxi_lcd_pin_cfg(sel, 1);

    sunxi_lcd_delay_us(100);

sunxi_lcd_gpio_set_value(0,1,1);//stby

sunxi_lcd_delay_ms(1);

printk(KERN_ERR "raoyiming +++ sunxi_lcd_gpio_set_value\n");

sunxi_lcd_gpio_set_value(0,0,1);//reset

    printk(KERN_ERR "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<22222<<<<<<<<<<<<<<<<<<<<<<<<<");


}


static void LCD_power_off(__u32 sel)

{

    sunxi_lcd_pin_cfg(sel, 0);

    sunxi_lcd_power_disable(sel, 0);//config lcd_power pin to close lcd power0

    sunxi_lcd_power_disable(sel, 1);//config lcd_power pin to close lcd power1

    sunxi_lcd_power_disable(sel, 2);//config lcd_power pin to close lcd power2

    sunxi_lcd_dsi_clk_disable(sel);

}


static void LCD_bl_open(__u32 sel)

{

    sunxi_lcd_pwm_enable(sel);//open pwm module

    sunxi_lcd_backlight_enable(sel);//config lcd_bl_en pin to open lcd backlight

}


static void LCD_bl_close(__u32 sel)

{

    sunxi_lcd_backlight_disable(sel);//config lcd_bl_en pin to close lcd backlight

    sunxi_lcd_pwm_disable(sel);//close pwm module

}


#define REGFLAG_DELAY              0X01

#define REGFLAG_END_OF_TABLE      0x02   // END OF REGISTERS MARKER



static void LCD_panel_init(__u32 sel)

{

#define Generic_Short_Write_NP(cmd) dsi_dcs_wr_0para(0, cmd)

#define Generic_Short_Write_1P(cmd, para) dsi_dcs_wr_1para(0, cmd, para)

#define Generic_Long_Write_FIFO(cmd, para) dsi_dcs_wr(0, cmd, para, sizeof(para)/sizeof(para[0]))

    u8 rx_bf0[3] ={0};

    u32 rx_num = 0 ;

     u8 data0[] = {0xAA,0x55,0x52};

    u8 data1[] = {0x25,0x25,0x25,0xFF,0x05,0x10};

    u8 data4[] = {0x00,0x00,0x01,0x67};

    u8 data5[] = {0x00,0x00,0x01,0xDF};

    u8 data6[] = {0x00,0x7A};

    u8 data7[] = {0xBA,0x01,0x30,0x00,0x00};

    u8 data8[] = {0x01,0x01,0x01};

    u8 data9[] = {0x1B,0x02};//反扫=0x1B,正扫=0x18

    u8 data11[] = {0x71,0x7B,0x00,0x00,0x00,0x00,0x00,0x00};

    u8 data12[] = {0x61,0x04,0x61,0x53};

    u8 data13[] = {0x00,0x1D,0x42,0x5D,0x1D,0x31,0x61,0x70,0x1D,0x25,0xC9,0x26,0x5B,0x6C,0xC5,0xD4,0x66,0x6E};

    u8 data14[] = {0x40,0x10};


    sunxi_lcd_dsi_clk_enable(sel);

    printk(KERN_ERR "%s, huangjinjin nt35410  command start\n", __func__);

    printk(KERN_ERR " nt35410  id manufacturer:%d version: %d  driver:%d ,rx_num:%d\n", rx_bf0[0],rx_bf0[1],rx_bf0[2],rx_num);

    Generic_Long_Write_FIFO(0xF0,data0);//Enable extend command

    Generic_Long_Write_FIFO(0xC1,data1);//VGH/VGL Booster Clock Control

    Delay(2);

    Generic_Short_Write_1P(0x35,0x00);//Tearing Effect On,video mode不写也没事

    Generic_Short_Write_1P(0x26,0x10);//Gamma Set

    Generic_Long_Write_FIFO(0x2A,data4);//Column Address Set

    Generic_Long_Write_FIFO(0x2B,data5);//Row Address Set

    Generic_Long_Write_FIFO(0xB0,data6);//Display Interface Mode Control vedio mode;video=0x7A,cmd=0x5A

    Generic_Long_Write_FIFO(0xB1,data7);//Display Normal mode Frame rate Control

    Generic_Long_Write_FIFO(0xB4,data8);//Inversion Control

    Generic_Long_Write_FIFO(0xB5,data14);//Display Function Selection set scan dirction

    Generic_Long_Write_FIFO(0xB8,data9);//控制正反扫

    Generic_Short_Write_1P(0xBF,0x40);//Chopper mode

    Generic_Long_Write_FIFO(0xC0,data11);//Set the Gamma regulator output voltage

    Generic_Long_Write_FIFO(0xC2,data12);//Booster clamp voltage & frequence control

    Generic_Long_Write_FIFO(0xE0,data13);/Gamma Correction for Positive Red

    Generic_Long_Write_FIFO(0xE1,data13);

    Generic_Long_Write_FIFO(0xE2,data13);

    Generic_Long_Write_FIFO(0xE3,data13);

    Generic_Long_Write_FIFO(0xE4,data13);

    Generic_Long_Write_FIFO(0xE5,data13);

    Generic_Short_Write_1P(0xFE,0x08);

     Generic_Short_Write_1P(0x36,0x00);

     Generic_Short_Write_1P(0x3A,0x77);////Interface Pixel Format:0X77=RGB888

     Delay(10);

    Generic_Short_Write_NP(0x11);

    Delay(100);

    Generic_Short_Write_NP(0x29);

    Delay(20);

    //Generic_Short_Write_NP(0x2c);//CMD MODE才要写2C

    Delay(60);

    return;

}


static void LCD_panel_exit(__u32 sel)

{

dsi_dcs_wr_0para(sel,DSI_DCS_SET_DISPLAY_OFF);

sunxi_lcd_delay_ms(50);

dsi_dcs_wr_0para(sel,DSI_DCS_ENTER_SLEEP_MODE);

sunxi_lcd_delay_ms(20);

    return ;

}


//sel: 0:lcd0; 1:lcd1

static __s32 LCD_user_defined_func(__u32 sel, __u32 para1, __u32 para2, __u32 para3)

{

    return 0;

}


__lcd_panel_t nt35410_panel = {

    .name = "nt35410",

    .func = {

        .cfg_panel_info = LCD_cfg_panel_info,

        .cfg_open_flow = LCD_open_flow,

        .cfg_close_flow = LCD_close_flow,

        .lcd_user_defined_func = LCD_user_defined_func,

    },

};

Porch设置如下:

image.png