lcd: sync linux3.14 lcd driver
authorWeiming Liu <weiming.liu@amlogic.com>
Mon, 26 Mar 2018 08:32:40 +0000 (16:32 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Thu, 29 Mar 2018 06:41:31 +0000 (22:41 -0800)
PD#163027: lcd: synchronous lcd driver from linux3.14

1.add the frame rate adaptive to each panel control alone

2.optimize vx1 phy large vswing

3.perfect the unifykey read way to improve efficiency

4.add i2c_pinmux for power sequence

Change-Id: I548591a5f54a9080e2d721b3b944d5bc511728cc
Signed-off-by: Weiming Liu <weiming.liu@amlogic.com>
19 files changed:
arch/arm64/boot/dts/amlogic/mesontxlx_r311-panel.dtsi
drivers/amlogic/media/vout/backlight/aml_bl.c
drivers/amlogic/media/vout/lcd/lcd_common.c
drivers/amlogic/media/vout/lcd/lcd_common.h
drivers/amlogic/media/vout/lcd/lcd_debug.c
drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_DLPC3439.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_anx6345.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_tc101.c
drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c
drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.h
drivers/amlogic/media/vout/lcd/lcd_tablet/lcd_drv.c
drivers/amlogic/media/vout/lcd/lcd_tablet/lcd_tablet.c
drivers/amlogic/media/vout/lcd/lcd_tv/lcd_drv.c
drivers/amlogic/media/vout/lcd/lcd_tv/lcd_tv.c
drivers/amlogic/media/vout/lcd/lcd_vout.c
include/linux/amlogic/media/vout/lcd/lcd_extern.h
include/linux/amlogic/media/vout/lcd/lcd_unifykey.h

index e6e9c29..36be2a9 100644 (file)
                        &gpio GPIOZ_10 GPIO_ACTIVE_HIGH
                        &gpio GPIOH_4 GPIO_ACTIVE_HIGH
                        &gpio GPIOH_5 GPIO_ACTIVE_HIGH>;
+                       /*&gpio GPIOH_2 GPIO_ACTIVE_HIGH*/
+                       /*&gpio GPIOH_3 GPIO_ACTIVE_HIGH*/
                lcd_cpu_gpio_names = "GPIOZ_13","GPIOZ_8",
                        "GPIOZ_9","GPIOZ_10","GPIOH_4","GPIOH_5";
+                       /*"GPIOH_2","GPIOH_3"*/
 
                lvds_0{
                        model_name = "1080p-vfreq";
                dev_name = "lcd_extern";
                status = "okay";
                key_valid = <0>;
+               i2c_bus = "i2c_bus_c";
+               /*pinctrl-names="extern_pins";*/
+               /*pinctrl_names_uboot = "i2c_c";*/ /* i2c_a, i2c_b, i2c_c */
+               /*pinctrl-0=<&i2c_c_master>;*/
+               /*extern-gpios = <&gpio GPIOH_2 1*/
+                               /*&gpio GPIOH_3 1>;*/
+               /*extern_gpio_names = "GPIOH_2","GPIOH_3";*/
+               /*i2c_gpio_off = <0 0 1 0>; */
+               /* I2C_SCK_gpio_index, I2C_SCK_gpio_off,
+                * I2C_SDA_gpio_index, I2C_SCK_gpio_off
+                */
 
                extern_0{
                        index = <0>;
index 84f4ff4..7c3575b 100644 (file)
@@ -1678,26 +1678,25 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
        }
 
        /* basic: 30byte */
-       p = para + LCD_UKEY_HEAD_SIZE;
-       str = (const char *)p;
+       p = para;
+       str = (const char *)(p + LCD_UKEY_HEAD_SIZE);
        strncpy(bconf->name, str, BL_NAME_MAX);
        /* ensure string ending */
        bconf->name[BL_NAME_MAX-1] = '\0';
-       p += LCD_UKEY_BL_NAME;
 
        /* level: 6byte */
-       bl_level_uboot = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_UBOOT;
-       bconf->level_default = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_KERNEL;
-       bconf->level_max = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_MAX;
-       bconf->level_min = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_MIN;
-       bconf->level_mid = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_MID;
-       bconf->level_mid_mapping = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_LEVEL_MID_MAP;
+       bl_level_uboot = (*(p + LCD_UKEY_BL_LEVEL_UBOOT) |
+               ((*(p + LCD_UKEY_BL_LEVEL_UBOOT + 1)) << 8));
+       bconf->level_default = (*(p + LCD_UKEY_BL_LEVEL_KERNEL) |
+               ((*(p + LCD_UKEY_BL_LEVEL_KERNEL + 1)) << 8));
+       bconf->level_max = (*(p + LCD_UKEY_BL_LEVEL_MAX) |
+               ((*(p + LCD_UKEY_BL_LEVEL_MAX + 1)) << 8));
+       bconf->level_min = (*(p + LCD_UKEY_BL_LEVEL_MIN) |
+               ((*(p  + LCD_UKEY_BL_LEVEL_MIN + 1)) << 8));
+       bconf->level_mid = (*(p + LCD_UKEY_BL_LEVEL_MID) |
+               ((*(p + LCD_UKEY_BL_LEVEL_MID + 1)) << 8));
+       bconf->level_mid_mapping = (*(p + LCD_UKEY_BL_LEVEL_MID_MAP) |
+               ((*(p + LCD_UKEY_BL_LEVEL_MID_MAP + 1)) << 8));
 
        /* adjust brightness_bypass by level_default */
        if (bconf->level_default > bconf->level_max) {
@@ -1706,26 +1705,21 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
        }
 
        /* method: 8byte */
-       temp = *p;
+       temp = *(p + LCD_UKEY_BL_METHOD);
        bconf->method = (temp >= BL_CTRL_MAX) ? BL_CTRL_MAX : temp;
-       p += LCD_UKEY_BL_METHOD;
 
-       temp = *p;
-       if (temp >= BL_GPIO_NUM_MAX) {
+       if (*(p + LCD_UKEY_BL_EN_GPIO) >= BL_GPIO_NUM_MAX) {
                bconf->en_gpio = BL_GPIO_MAX;
        } else {
-               bconf->en_gpio = temp;
+               bconf->en_gpio = *(p + LCD_UKEY_BL_EN_GPIO);
                bl_gpio_probe(bconf->en_gpio);
        }
-       p += LCD_UKEY_BL_EN_GPIO;
-       bconf->en_gpio_on = *p;
-       p += LCD_UKEY_BL_EN_GPIO_ON;
-       bconf->en_gpio_off = *p;
-       p += LCD_UKEY_BL_EN_GPIO_OFF;
-       bconf->power_on_delay = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_ON_DELAY;
-       bconf->power_off_delay = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_BL_OFF_DELAY;
+       bconf->en_gpio_on = *(p + LCD_UKEY_BL_EN_GPIO_ON);
+       bconf->en_gpio_off = *(p + LCD_UKEY_BL_EN_GPIO_OFF);
+       bconf->power_on_delay = (*(p + LCD_UKEY_BL_ON_DELAY) |
+               ((*(p + LCD_UKEY_BL_ON_DELAY + 1)) << 8));
+       bconf->power_off_delay = (*(p + LCD_UKEY_BL_OFF_DELAY) |
+               ((*(p + LCD_UKEY_BL_OFF_DELAY + 1)) << 8));
 
        /* pwm: 24byte */
        switch (bconf->method) {
@@ -1743,16 +1737,16 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
                bl_pwm->level_max = bconf->level_max;
                bl_pwm->level_min = bconf->level_min;
 
-               bconf->pwm_on_delay = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_ON_DELAY;
-               bconf->pwm_off_delay = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_OFF_DELAY;
-               bl_pwm->pwm_method =  *p;
-               p += LCD_UKEY_BL_PWM_METHOD;
-               bl_pwm->pwm_port = *p;
-               p += LCD_UKEY_BL_PWM_PORT;
-               bl_pwm->pwm_freq = (*p | ((*(p + 1)) << 8) |
-                               ((*(p + 2)) << 8) | ((*(p + 3)) << 8));
+               bconf->pwm_on_delay = (*(p + LCD_UKEY_BL_PWM_ON_DELAY) |
+                       ((*(p + LCD_UKEY_BL_PWM_ON_DELAY + 1)) << 8));
+               bconf->pwm_off_delay = (*(p + LCD_UKEY_BL_PWM_OFF_DELAY) |
+                       ((*(p + LCD_UKEY_BL_PWM_OFF_DELAY + 1)) << 8));
+               bl_pwm->pwm_method =  *(p + LCD_UKEY_BL_PWM_METHOD);
+               bl_pwm->pwm_port = *(p + LCD_UKEY_BL_PWM_PORT);
+               bl_pwm->pwm_freq = (*(p + LCD_UKEY_BL_PWM_FREQ) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 1)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 2)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 3)) << 8));
                if (bl_pwm->pwm_port == BL_PWM_VS) {
                        if (bl_pwm->pwm_freq > 4) {
                                BLERR("bl_pwm_vs wrong freq %d\n",
@@ -1762,28 +1756,15 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
                } else {
                        if (bl_pwm->pwm_freq > XTAL_HALF_FREQ_HZ)
                                bl_pwm->pwm_freq = XTAL_HALF_FREQ_HZ;
-                       if (bl_pwm->pwm_freq < 50)
-                               bl_pwm->pwm_freq = 50;
                }
-               p += LCD_UKEY_BL_PWM_FREQ;
-               bl_pwm->pwm_duty_max = *p;
-               p += LCD_UKEY_BL_PWM_DUTY_MAX;
-               bl_pwm->pwm_duty_min = *p;
-               p += LCD_UKEY_BL_PWM_DUTY_MIN;
+               bl_pwm->pwm_duty_max = *(p + LCD_UKEY_BL_PWM_DUTY_MAX);
+               bl_pwm->pwm_duty_min = *(p + LCD_UKEY_BL_PWM_DUTY_MIN);
 
-               p += LCD_UKEY_BL_PWM_GPIO;
-               p += LCD_UKEY_BL_PWM_GPIO_OFF;
-
-               if (bl_header.version == 2) {
+               if (bl_header.version == 2)
                        bconf->pwm_en_sequence_reverse =
-                               (*p | ((*(p + 1)) << 8));
-                       p += LCD_UKEY_BL_CUST_VAL_0;
-                       /* dummy pointer */
-                       p += LCD_UKEY_BL_CUST_VAL_1;
-                       p += LCD_UKEY_BL_CUST_VAL_2;
-                       p += LCD_UKEY_BL_CUST_VAL_3;
-                       p += LCD_UKEY_BL_CUST_VAL_4;
-               } else
+                               (*(p + LCD_UKEY_BL_CUST_VAL_0) |
+                               ((*(p + LCD_UKEY_BL_CUST_VAL_0 + 1)) << 8));
+               else
                        bconf->pwm_en_sequence_reverse = 0;
 
                bl_pwm->pwm_duty = bl_pwm->pwm_duty_min;
@@ -1809,17 +1790,17 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
                pwm_combo0->index = 0;
                pwm_combo1->index = 1;
 
-               bconf->pwm_on_delay = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_ON_DELAY;
-               bconf->pwm_off_delay = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_OFF_DELAY;
-
-               pwm_combo0->pwm_method = *p;
-               p += LCD_UKEY_BL_PWM_METHOD;
-               pwm_combo0->pwm_port = *p;
-               p += LCD_UKEY_BL_PWM_PORT;
-               pwm_combo0->pwm_freq = (*p | ((*(p + 1)) << 8) |
-                               ((*(p + 2)) << 8) | ((*(p + 3)) << 8));
+               bconf->pwm_on_delay = (*(p + LCD_UKEY_BL_PWM_ON_DELAY) |
+                       ((*(p + LCD_UKEY_BL_PWM_ON_DELAY + 1)) << 8));
+               bconf->pwm_off_delay = (*(p + LCD_UKEY_BL_PWM_OFF_DELAY) |
+                       ((*(p + LCD_UKEY_BL_PWM_OFF_DELAY + 1)) << 8));
+
+               pwm_combo0->pwm_method = *(p + LCD_UKEY_BL_PWM_METHOD);
+               pwm_combo0->pwm_port = *(p + LCD_UKEY_BL_PWM_PORT);
+               pwm_combo0->pwm_freq = (*(p + LCD_UKEY_BL_PWM_FREQ) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 1)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 2)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM_FREQ + 3)) << 8));
                if (pwm_combo0->pwm_port == BL_PWM_VS) {
                        if (pwm_combo0->pwm_freq > 4) {
                                BLERR("bl_pwm_0_vs wrong freq %d\n",
@@ -1829,24 +1810,16 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
                } else {
                        if (pwm_combo0->pwm_freq > XTAL_HALF_FREQ_HZ)
                                pwm_combo0->pwm_freq = XTAL_HALF_FREQ_HZ;
-                       if (pwm_combo0->pwm_freq < 50)
-                               pwm_combo0->pwm_freq = 50;
                }
-               p += LCD_UKEY_BL_PWM_FREQ;
-               pwm_combo0->pwm_duty_max = *p;
-               p += LCD_UKEY_BL_PWM_DUTY_MAX;
-               pwm_combo0->pwm_duty_min = *p;
-               p += LCD_UKEY_BL_PWM_DUTY_MIN;
-
-               p += LCD_UKEY_BL_PWM_GPIO;
-               p += LCD_UKEY_BL_PWM_GPIO_OFF;
-
-               pwm_combo1->pwm_method = *p;
-               p += LCD_UKEY_BL_PWM2_METHOD;
-               pwm_combo1->pwm_port =  *p;
-               p += LCD_UKEY_BL_PWM2_PORT;
-               pwm_combo1->pwm_freq = (*p | ((*(p + 1)) << 8) |
-                               ((*(p + 2)) << 8) | ((*(p + 3)) << 8));
+               pwm_combo0->pwm_duty_max = *(p + LCD_UKEY_BL_PWM_DUTY_MAX);
+               pwm_combo0->pwm_duty_min = *(p + LCD_UKEY_BL_PWM_DUTY_MIN);
+
+               pwm_combo1->pwm_method = *(p + LCD_UKEY_BL_PWM2_METHOD);
+               pwm_combo1->pwm_port = *(p + LCD_UKEY_BL_PWM2_PORT);
+               pwm_combo1->pwm_freq = (*(p + LCD_UKEY_BL_PWM2_FREQ) |
+                       ((*(p + LCD_UKEY_BL_PWM2_FREQ + 1)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM2_FREQ + 2)) << 8) |
+                       ((*(p + LCD_UKEY_BL_PWM2_FREQ + 3)) << 8));
                if (pwm_combo1->pwm_port == BL_PWM_VS) {
                        if (pwm_combo1->pwm_freq > 4) {
                                BLERR("bl_pwm_1_vs wrong freq %d\n",
@@ -1856,37 +1829,24 @@ static int aml_bl_config_load_from_unifykey(struct bl_config_s *bconf)
                } else {
                        if (pwm_combo1->pwm_freq > XTAL_HALF_FREQ_HZ)
                                pwm_combo1->pwm_freq = XTAL_HALF_FREQ_HZ;
-                       if (pwm_combo1->pwm_freq < 50)
-                               pwm_combo1->pwm_freq = 50;
                }
-               p += LCD_UKEY_BL_PWM2_FREQ;
-               pwm_combo1->pwm_duty_max = *p;
-               p += LCD_UKEY_BL_PWM2_DUTY_MAX;
-               pwm_combo1->pwm_duty_min = *p;
-               p += LCD_UKEY_BL_PWM2_DUTY_MIN;
-
-               p += LCD_UKEY_BL_PWM2_GPIO;
-               p += LCD_UKEY_BL_PWM2_GPIO_OFF;
-
-               pwm_combo0->level_max = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_LEVEL_MAX;
-               pwm_combo0->level_min = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM_LEVEL_MIN;
-               pwm_combo1->level_max = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM2_LEVEL_MAX;
-               pwm_combo1->level_min = (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_BL_PWM2_LEVEL_MIN;
-
-               if (bl_header.version == 2) {
-                       bconf->pwm_en_sequence_reverse =
-                               (*p | ((*(p + 1)) << 8));
-                       p += LCD_UKEY_BL_CUST_VAL_0;
-                       /* dummy pointer */
-                       p += LCD_UKEY_BL_CUST_VAL_1;
-                       p += LCD_UKEY_BL_CUST_VAL_2;
-                       p += LCD_UKEY_BL_CUST_VAL_3;
-                       p += LCD_UKEY_BL_CUST_VAL_4;
-               } else
+               pwm_combo1->pwm_duty_max = *(p + LCD_UKEY_BL_PWM2_DUTY_MAX);
+               pwm_combo1->pwm_duty_min = *(p + LCD_UKEY_BL_PWM2_DUTY_MIN);
+
+               pwm_combo0->level_max = (*(p + LCD_UKEY_BL_PWM_LEVEL_MAX) |
+                       ((*(p + LCD_UKEY_BL_PWM_LEVEL_MAX + 1)) << 8));
+               pwm_combo0->level_min = (*(p + LCD_UKEY_BL_PWM_LEVEL_MIN) |
+                       ((*(p + LCD_UKEY_BL_PWM_LEVEL_MIN + 1)) << 8));
+               pwm_combo1->level_max = (*(p + LCD_UKEY_BL_PWM2_LEVEL_MAX) |
+                       ((*(p + LCD_UKEY_BL_PWM2_LEVEL_MAX + 1)) << 8));
+               pwm_combo1->level_min = (*(p + LCD_UKEY_BL_PWM2_LEVEL_MIN) |
+                       ((*(p + LCD_UKEY_BL_PWM2_LEVEL_MIN + 1)) << 8));
+
+               if (bl_header.version == 2)
+                       bconf->pwm_en_sequence_reverse = (*(p +
+                               LCD_UKEY_BL_CUST_VAL_0) |
+                               ((*(p + LCD_UKEY_BL_CUST_VAL_0 + 1)) << 8));
+               else
                        bconf->pwm_en_sequence_reverse = 0;
 
                pwm_combo0->pwm_duty = pwm_combo0->pwm_duty_min;
index b5ed2ec..7e72b3c 100644 (file)
@@ -560,7 +560,7 @@ int lcd_power_load_from_dts(struct lcd_config_s *pconf,
 int lcd_power_load_from_unifykey(struct lcd_config_s *pconf,
                unsigned char *buf, int key_len, int len)
 {
-       int i;
+       int i, j;
        unsigned char *p;
        unsigned int index;
        int ret;
@@ -571,7 +571,6 @@ int lcd_power_load_from_unifykey(struct lcd_config_s *pconf,
                LCDPR("power_on step:\n");
        i = 0;
        while (i < LCD_PWR_STEP_MAX) {
-               pconf->lcd_power->power_on_step_max = i;
                len += 5;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret < 0) {
@@ -582,15 +581,15 @@ int lcd_power_load_from_unifykey(struct lcd_config_s *pconf,
                        LCDERR("unifykey power_on length is incorrect\n");
                        return -1;
                }
-               pconf->lcd_power->power_on_step[i].type = *p;
-               p += LCD_UKEY_PWR_TYPE;
-               pconf->lcd_power->power_on_step[i].index = *p;
-               p += LCD_UKEY_PWR_INDEX;
-               pconf->lcd_power->power_on_step[i].value = *p;
-               p += LCD_UKEY_PWR_VAL;
+               pconf->lcd_power->power_on_step[i].type =
+                       *(p + LCD_UKEY_PWR_TYPE + 5*i);
+               pconf->lcd_power->power_on_step[i].index =
+                       *(p + LCD_UKEY_PWR_INDEX + 5*i);
+               pconf->lcd_power->power_on_step[i].value =
+                       *(p + LCD_UKEY_PWR_VAL + 5*i);
                pconf->lcd_power->power_on_step[i].delay =
-                               (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_PWR_DELAY;
+                       (*(p + LCD_UKEY_PWR_DELAY + 5*i) |
+                       ((*(p + LCD_UKEY_PWR_DELAY + 5*i + 1)) << 8));
 
                /* gpio probe */
                switch (pconf->lcd_power->power_on_step[i].type) {
@@ -609,40 +608,41 @@ int lcd_power_load_from_unifykey(struct lcd_config_s *pconf,
                                pconf->lcd_power->power_on_step[i].value,
                                pconf->lcd_power->power_on_step[i].delay);
                }
-               if (pconf->lcd_power->power_on_step[i].type <
+               if (pconf->lcd_power->power_on_step[i].type >=
                        LCD_POWER_TYPE_MAX)
-                       i++;
+                       break;
+               i++;
        }
 
        if (lcd_debug_print_flag)
                LCDPR("power_off step:\n");
-       i = 0;
-       while (i < LCD_PWR_STEP_MAX) {
-               pconf->lcd_power->power_off_step_max = i;
+       p += (5*(i + 1));
+       j = 0;
+       while (j < LCD_PWR_STEP_MAX) {
                len += 5;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret < 0) {
-                       pconf->lcd_power->power_off_step[i].type = 0xff;
-                       pconf->lcd_power->power_off_step[i].index = 0;
-                       pconf->lcd_power->power_off_step[i].value = 0;
-                       pconf->lcd_power->power_off_step[i].delay = 0;
+                       pconf->lcd_power->power_off_step[j].type = 0xff;
+                       pconf->lcd_power->power_off_step[j].index = 0;
+                       pconf->lcd_power->power_off_step[j].value = 0;
+                       pconf->lcd_power->power_off_step[j].delay = 0;
                        LCDERR("unifykey power_off length is incorrect\n");
                        return -1;
                }
-               pconf->lcd_power->power_off_step[i].type = *p;
-               p += LCD_UKEY_PWR_TYPE;
-               pconf->lcd_power->power_off_step[i].index = *p;
-               p += LCD_UKEY_PWR_INDEX;
-               pconf->lcd_power->power_off_step[i].value = *p;
-               p += LCD_UKEY_PWR_VAL;
-               pconf->lcd_power->power_off_step[i].delay =
-                               (*p | ((*(p + 1)) << 8));
-               p += LCD_UKEY_PWR_DELAY;
+               pconf->lcd_power->power_off_step[j].type =
+                       *(p + LCD_UKEY_PWR_TYPE + 5*j);
+               pconf->lcd_power->power_off_step[j].index =
+                       *(p + LCD_UKEY_PWR_INDEX + 5*j);
+               pconf->lcd_power->power_off_step[j].value =
+                       *(p + LCD_UKEY_PWR_VAL + 5*j);
+               pconf->lcd_power->power_off_step[j].delay =
+                               (*(p + LCD_UKEY_PWR_DELAY + 5*j) |
+                               ((*(p + LCD_UKEY_PWR_DELAY + 5*j + 1)) << 8));
 
                /* gpio probe */
-               switch (pconf->lcd_power->power_off_step[i].type) {
+               switch (pconf->lcd_power->power_off_step[j].type) {
                case LCD_POWER_TYPE_CPU:
-                       index = pconf->lcd_power->power_off_step[i].index;
+                       index = pconf->lcd_power->power_off_step[j].index;
                        if (index < LCD_CPU_GPIO_NUM_MAX)
                                lcd_cpu_gpio_probe(index);
                        break;
@@ -651,14 +651,15 @@ int lcd_power_load_from_unifykey(struct lcd_config_s *pconf,
                }
                if (lcd_debug_print_flag) {
                        LCDPR("%d: type=%d, index=%d, value=%d, delay=%d\n",
-                               i, pconf->lcd_power->power_off_step[i].type,
-                               pconf->lcd_power->power_off_step[i].index,
-                               pconf->lcd_power->power_off_step[i].value,
-                               pconf->lcd_power->power_off_step[i].delay);
+                               j, pconf->lcd_power->power_off_step[j].type,
+                               pconf->lcd_power->power_off_step[j].index,
+                               pconf->lcd_power->power_off_step[j].value,
+                               pconf->lcd_power->power_off_step[j].delay);
                }
-               if (pconf->lcd_power->power_off_step[i].type <
+               if (pconf->lcd_power->power_off_step[j].type >=
                        LCD_POWER_TYPE_MAX)
-                       i++;
+                       break;
+               j++;
        }
 
        return 0;
index f024c3c..c816585 100644 (file)
 /* 20170905: fix coverity errors */
 /* 20180122: support txlx, optimize lcd noitfier event */
 /* 20180226: g12a support */
-#define LCD_DRV_VERSION    "20180226"
+#define LCD_DRV_VERSION    "20180321"
 
 #define VPP_OUT_SATURATE            (1 << 0)
 
+/* -------------------------- */
+/* lvsd phy parameters define */
+/* -------------------------- */
+#define LVDS_PHY_CNTL1_G9TV    0x606cca80
+#define LVDS_PHY_CNTL2_G9TV    0x0000006c
+#define LVDS_PHY_CNTL3_G9TV    0x00000800
+/* -------------------------- */
+
+/* -------------------------- */
+/* vbyone phy parameters define */
+/* -------------------------- */
+#define VX1_PHY_CNTL1_G9TV            0x6e0ec900
+#define VX1_PHY_CNTL1_G9TV_PULLUP     0x6e0f4d00
+#define VX1_PHY_CNTL2_G9TV            0x0000007c
+#define VX1_PHY_CNTL3_G9TV            0x00ff0800
+/* -------------------------- */
+
+
 /* ******** mipi_dsi_phy ******** */
 /* bit[15:11] */
 #define MIPI_PHY_LANE_BIT        11
index ebe82fc..08aaa48 100644 (file)
@@ -2632,6 +2632,7 @@ static void lcd_phy_config_update(unsigned int *para, int cnt)
        struct lvds_config_s *lvdsconf;
        int type;
        unsigned int data32, vswing, preem, ext_pullup;
+       unsigned int rinner_table[] = {0xa, 0xa, 0x6, 0x4};
 
        pconf = lcd_drv->lcd_config;
        type = pconf->lcd_basic.lcd_type;
@@ -2642,9 +2643,9 @@ static void lcd_phy_config_update(unsigned int *para, int cnt)
                        if ((para[0] > 7) || (para[1] > 7) ||
                                (para[2] > 3) || (para[3] > 7)) {
                                LCDERR("%s: wrong value:\n", __func__);
-                               pr_info("vswing=0x%x, preemphasis=0x%x\n",
+                                       pr_info("vswing=%d, preem=%d\n",
                                        para[0], para[1]);
-                               pr_info("clk_vswing=0x%x, clk_preem=0x%x\n",
+                                       pr_info("clk vswing=%d, preem=%d\n",
                                        para[2], para[3]);
                                return;
                        }
@@ -2666,12 +2667,12 @@ static void lcd_phy_config_update(unsigned int *para, int cnt)
                        LCDPR("%s:\n", __func__);
                        pr_info("vswing=0x%x, preemphasis=0x%x\n",
                                para[0], para[1]);
-                       pr_info("clk_vswing=0x%x, clk_preemphasis=0x%x\n",
+                               pr_info("clk_vswing=0x%x, clk_preem=0x%x\n",
                                para[2], para[3]);
                } else if (cnt == 2) {
                        if ((para[0] > 7) || (para[1] > 7)) {
                                LCDERR("%s: wrong value:\n", __func__);
-                               pr_info("vswing=0x%x, preemphasis=0x%x\n",
+                                       pr_info("vswing=%d, preem=%d\n",
                                        para[0], para[1]);
                                return;
                        }
@@ -2693,12 +2694,12 @@ static void lcd_phy_config_update(unsigned int *para, int cnt)
                break;
        case LCD_VBYONE:
                if (cnt >= 2) {
-                       ext_pullup = (para[0] >> 4) & 1;
+                       ext_pullup = (para[0] >> 4) & 0x3;
                        vswing = para[0] & 0xf;
                        preem = para[1];
                        if ((vswing > 7) || (preem > 7)) {
                                LCDERR("%s: wrong value:\n", __func__);
-                               pr_info("vswing=0x%x, preemphasis=0x%x\n",
+                               pr_info("vswing=%d, preemphasis=%d\n",
                                        vswing, preem);
                                return;
                        }
@@ -2707,14 +2708,18 @@ static void lcd_phy_config_update(unsigned int *para, int cnt)
                        pconf->lcd_control.vbyone_config->phy_preem = para[1];
 
                        data32 = lcd_hiu_read(HHI_DIF_CSI_PHY_CNTL1);
-                       data32 &= ~((0x7 << 3) | (1 << 10));
-                       data32 |= ((vswing << 3) | (ext_pullup << 10));
+                       data32 &= ~((0x7 << 3) | (1 << 10) |
+                               (1 << 15) | (1 << 16));
+                       data32 |= (vswing << 3);
                        if (ext_pullup)
-                               data32 &= ~(1 << 15);
+                               data32 |= ((1 << 10) | (1 << 16));
+                       else
+                               data32 |= (1 << 15);
                        lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, data32);
                        data32 =  lcd_hiu_read(HHI_DIF_CSI_PHY_CNTL2);
-                       data32 &= ~(0x7 << 20);
-                       data32 |= (preem << 20);
+                       data32 &= ~((0x7 << 20) | (0xf << 8));
+                       data32 |= ((preem << 20) |
+                               (rinner_table[ext_pullup] << 8));
                        lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, data32);
 
                        LCDPR("%s: vswing=0x%x, preemphasis=0x%x\n",
index 5c23c8d..7b87765 100644 (file)
@@ -434,18 +434,20 @@ static int lcd_extern_power_ctrl(int flag)
        return ret;
 }
 
-static int lcd_extern_power_on(void)
+static int lcd_extern_power_on(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret;
 
+       lcd_extern_pinmux_set(ext_drv, 1);
        ret = lcd_extern_power_ctrl(1);
        return ret;
 }
 
-static int lcd_extern_power_off(void)
+static int lcd_extern_power_off(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret;
 
+       lcd_extern_pinmux_set(ext_drv, 0);
        ret = lcd_extern_power_ctrl(0);
        return ret;
 }
@@ -545,6 +547,10 @@ int aml_lcd_extern_default_probe(struct aml_lcd_extern_driver_s *ext_drv)
        case LCD_EXTERN_I2C:
                aml_default_i2c_client = NULL;
                aml_default_i2c2_client = NULL;
+               if (ext_drv->config.i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+                       EXTERR("invalid i2c bus\n");
+                       return -1;
+               }
                memset(&i2c_info, 0, sizeof(i2c_info));
                adapter = i2c_get_adapter(ext_drv->config.i2c_bus);
                if (!adapter) {
index d666df1..506bdd5 100644 (file)
@@ -76,10 +76,11 @@ static int lcd_extern_i2c_write(struct i2c_client *i2client,
        return ret;
 }
 
-static int lcd_extern_power_on(void)
+static int lcd_extern_power_on(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 1);
        lcd_extern_i2c_write(aml_DLPC3439_i2c_client, data_1, 9);
        lcd_extern_i2c_write(aml_DLPC3439_i2c_client, data_2, 5);
        lcd_extern_i2c_write(aml_DLPC3439_i2c_client, data_3, 5);
@@ -90,10 +91,12 @@ static int lcd_extern_power_on(void)
        return ret;
 }
 
-static int lcd_extern_power_off(void)
+static int lcd_extern_power_off(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 0);
+
        return ret;
 }
 
@@ -154,6 +157,10 @@ int aml_lcd_extern_i2c_DLPC3439_probe(struct aml_lcd_extern_driver_s *ext_drv)
        int ret = 0;
 
        ext_config = &ext_drv->config;
+       if (ext_drv->config.i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+               EXTERR("invalid i2c bus\n");
+               return -1;
+       }
        memset(&i2c_info, 0, sizeof(i2c_info));
 
        adapter = i2c_get_adapter(ext_drv->config.i2c_bus);
index 94df58a..784d1e2 100644 (file)
@@ -181,18 +181,20 @@ static int lcd_extern_power_ctrl(int flag)
        return ret;
 }
 
-static int lcd_extern_power_on(void)
+static int lcd_extern_power_on(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret;
 
+       lcd_extern_pinmux_set(ext_drv, 1);
        ret = lcd_extern_power_ctrl(1);
        return ret;
 }
 
-static int lcd_extern_power_off(void)
+static int lcd_extern_power_off(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret;
 
+       lcd_extern_pinmux_set(ext_drv, 0);
        ret = lcd_extern_power_ctrl(0);
        return ret;
 }
@@ -344,6 +346,10 @@ int aml_lcd_extern_i2c_T5800Q_probe(struct aml_lcd_extern_driver_s *ext_drv)
        int ret = 0;
 
        ext_config = &ext_drv->config;
+       if (ext_drv->config.i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+               EXTERR("invalid i2c bus\n");
+               return -1;
+       }
        memset(&i2c_info, 0, sizeof(i2c_info));
 
        adapter = i2c_get_adapter(ext_drv->config.i2c_bus);
index 31280a6..df2fa82 100644 (file)
@@ -192,7 +192,7 @@ static int SP_TX_AUX_DPCDRead_Bytes(unsigned char addrh, unsigned char addrm,
        return 0; /* aux ok */
 }
 
-static int lcd_extern_power_on(void)
+static int lcd_extern_power_on(struct aml_lcd_extern_driver_s *ext_drv)
 {
        unsigned int lane_num;
        unsigned int link_rate;
@@ -203,6 +203,7 @@ static int lcd_extern_power_on(void)
        unsigned int count = 0;
        unsigned int count1 = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 1);
        lane_num = edp_tx_lane; /* 1 lane */
        link_rate = VAL_EDP_TX_LINK_BW_SET_270; /* 2.7G */
        bits = 0; /* 0x00: 6bit;  0x10:8bit */
@@ -344,10 +345,12 @@ static int lcd_extern_power_on(void)
        return 0;
 }
 
-static int lcd_extern_power_off(void)
+static int lcd_extern_power_off(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 0);
+
        return ret;
 }
 
@@ -439,6 +442,10 @@ int aml_lcd_extern_i2c_anx6345_probe(struct aml_lcd_extern_driver_s *ext_drv)
        int ret = 0;
 
        ext_config = &ext_drv->config;
+       if (ext_config->i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+               EXTERR("invalid i2c bus\n");
+               return -1;
+       }
        for (i = 0; i < 2; i++)
                memset(&i2c_info[i], 0, sizeof(i2c_info[i]));
 
index bbeb459..6438bfd 100644 (file)
@@ -108,12 +108,13 @@ static int i2c_reg_write(unsigned char reg, unsigned char value)
 }
 #endif
 
-static int lcd_extern_power_on(void)
+static int lcd_extern_power_on(struct aml_lcd_extern_driver_s *ext_drv)
 {
        unsigned char tData[4];
        int i = 0, ending_flag = 0;
        int ret = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 1);
        while (ending_flag == 0) {
                if ((i2c_init_table[i][0] == 0xff) &&
                        (i2c_init_table[i][1] == 0xff)) { /* special mark */
@@ -133,10 +134,11 @@ static int lcd_extern_power_on(void)
        return ret;
 }
 
-static int lcd_extern_power_off(void)
+static int lcd_extern_power_off(struct aml_lcd_extern_driver_s *ext_drv)
 {
        int ret = 0;
 
+       lcd_extern_pinmux_set(ext_drv, 0);
        return ret;
 }
 
@@ -197,6 +199,10 @@ int aml_lcd_extern_i2c_tc101_probe(struct aml_lcd_extern_driver_s *ext_drv)
        int ret = 0;
 
        ext_config = &ext_drv->config;
+       if (ext_drv->config.i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+               EXTERR("invalid i2c bus\n");
+               return -1;
+       }
        memset(&i2c_info, 0, sizeof(i2c_info));
 
        adapter = i2c_get_adapter(ext_drv->config.i2c_bus);
index 65a6d2f..1e1397c 100644 (file)
@@ -36,6 +36,11 @@ static int lcd_extern_add_driver(struct lcd_extern_config_s *extconf);
 
 static unsigned int lcd_ext_key_valid;
 static unsigned char lcd_ext_config_load;
+static unsigned char lcd_ext_i2c_bus = LCD_EXTERN_I2C_BUS_INVALID;
+static unsigned char lcd_ext_i2c_sck_gpio = LCD_EXTERN_GPIO_NUM_MAX;
+static unsigned char lcd_ext_i2c_sck_gpio_off = 2;
+static unsigned char lcd_ext_i2c_sda_gpio = LCD_EXTERN_GPIO_NUM_MAX;
+static unsigned char lcd_ext_i2c_sda_gpio_off = 2;
 
 struct lcd_ext_gpio_s {
        char name[15];
@@ -126,6 +131,43 @@ void lcd_extern_gpio_probe(unsigned char index)
        ext_gpio->register_flag = 0;
 }
 
+void lcd_extern_gpio_unregister(int index)
+{
+       struct lcd_ext_gpio_s *ext_gpio;
+
+       if (index >= LCD_EXTERN_GPIO_NUM_MAX) {
+               EXTERR("gpio index %d, exit\n", index);
+               return;
+       }
+       ext_gpio = &lcd_extern_gpio[index];
+       if (ext_gpio->probe_flag == 0) {
+               if (lcd_debug_print_flag) {
+                       EXTPR("gpio %s[%d] is already registered\n",
+                               ext_gpio->name, index);
+               }
+               return;
+       }
+       if (ext_gpio->register_flag) {
+               EXTPR("%s: gpio %s[%d] is already registered\n",
+                       __func__, ext_gpio->name, index);
+               return;
+       }
+       if (IS_ERR(ext_gpio->gpio)) {
+               EXTERR("register gpio %s[%d]: %p, err: %d\n",
+                       ext_gpio->name, index, ext_gpio->gpio,
+                       IS_ERR(ext_gpio->gpio));
+               ext_gpio->gpio = NULL;
+               return;
+       }
+
+       /* release gpio */
+       devm_gpiod_put(lcd_extern_dev, ext_gpio->gpio);
+       ext_gpio->probe_flag = 0;
+       ext_gpio->register_flag = 0;
+       if (lcd_debug_print_flag)
+               EXTPR("release gpio %s[%d]\n", ext_gpio->name, index);
+}
+
 static int lcd_extern_gpio_register(unsigned char index, int init_value)
 {
        struct lcd_ext_gpio_s *ext_gpio;
@@ -248,6 +290,74 @@ unsigned int lcd_extern_gpio_get(unsigned char index)
        return gpiod_get_value(ext_gpio->gpio);
 }
 
+void lcd_extern_pinmux_set(struct aml_lcd_extern_driver_s *ext_drv, int status)
+{
+       struct lcd_ext_gpio_s *ext_gpio_sck;
+       struct lcd_ext_gpio_s *ext_gpio_sda;
+
+       ext_gpio_sck = &lcd_extern_gpio[ext_drv->config.i2c_sck_gpio];
+       ext_gpio_sda = &lcd_extern_gpio[ext_drv->config.i2c_sda_gpio];
+
+       if (lcd_debug_print_flag)
+               EXTPR("%s: %d\n", __func__, status);
+
+       if (status) {
+               /* release gpio */
+               if (ext_drv->pinmux_flag) {
+                       EXTPR("drv_index %d pinmux is already selected\n",
+                               ext_drv->config.index);
+                       return;
+               }
+               if (ext_drv->config.type == LCD_EXTERN_I2C) {
+                       if (ext_drv->config.i2c_sck_gpio <
+                               LCD_EXTERN_GPIO_NUM_MAX)
+                               lcd_extern_gpio_unregister(
+                                       ext_drv->config.i2c_sck_gpio);
+                       if (ext_drv->config.i2c_sda_gpio <
+                               LCD_EXTERN_GPIO_NUM_MAX)
+                               lcd_extern_gpio_unregister(
+                                       ext_drv->config.i2c_sda_gpio);
+               }
+               /* request pinmux */
+               ext_drv->pin = devm_pinctrl_get_select(lcd_extern_dev,
+                       "extern_pins");
+               if (IS_ERR(ext_drv->pin)) {
+                       EXTERR("set drv_index %d pinmux error\n",
+                               ext_drv->config.index);
+               } else {
+                       if (lcd_debug_print_flag) {
+                               EXTPR("set drv_index %d pinmux ok\n",
+                                       ext_drv->config.index);
+                       }
+               }
+               ext_drv->pinmux_flag = 1;
+       } else {
+               if (ext_drv->pinmux_flag) {
+                       if (lcd_debug_print_flag)
+                               EXTPR("release pinmux: %p\n", ext_drv->pin);
+                        /* release pinmux */
+                       if (!IS_ERR(ext_drv->pin))
+                               devm_pinctrl_put(ext_drv->pin);
+                       ext_drv->pinmux_flag = 0;
+               }
+               /* request gpio &  set gpio */
+               if (ext_drv->config.type == LCD_EXTERN_I2C) {
+                       if (ext_drv->config.i2c_sck_gpio <
+                                       LCD_EXTERN_GPIO_NUM_MAX) {
+                               lcd_extern_gpio_set(
+                                       ext_drv->config.i2c_sck_gpio,
+                                       ext_drv->config.i2c_sck_gpio_off);
+                       }
+                       if (ext_drv->config.i2c_sda_gpio <
+                                       LCD_EXTERN_GPIO_NUM_MAX) {
+                               lcd_extern_gpio_set(
+                                       ext_drv->config.i2c_sda_gpio,
+                                       ext_drv->config.i2c_sda_gpio_off);
+                       }
+               }
+       }
+}
+
 #ifdef CONFIG_OF
 static unsigned char lcd_extern_get_i2c_bus_str(const char *str)
 {
@@ -264,7 +374,7 @@ static unsigned char lcd_extern_get_i2c_bus_str(const char *str)
        else if (strncmp(str, "i2c_bus_d", 9) == 0)
                i2c_bus = AML_I2C_MASTER_D;
        else {
-               i2c_bus = AML_I2C_MASTER_A;
+               i2c_bus = LCD_EXTERN_I2C_BUS_INVALID;
                EXTERR("invalid i2c_bus: %s\n", str);
        }
 
@@ -453,6 +563,21 @@ static int lcd_extern_get_config_dts(struct device_node *of_node,
 
        switch (extconf->type) {
        case LCD_EXTERN_I2C:
+               if (lcd_ext_i2c_bus == LCD_EXTERN_I2C_BUS_INVALID) {
+                       ret = of_property_read_string(of_node, "i2c_bus", &str);
+                       if (ret) {
+                               EXTERR("get %s i2c_bus failed, exit\n",
+                                       extconf->name);
+                               extconf->i2c_bus = LCD_EXTERN_I2C_BUS_INVALID;
+                               return -1;
+                       }
+                       extconf->i2c_bus = lcd_extern_get_i2c_bus_str(str);
+               } else
+                       extconf->i2c_bus = lcd_ext_i2c_bus;
+               if (lcd_debug_print_flag) {
+                       EXTPR("%s i2c_bus=%d\n",
+                               extconf->name, extconf->i2c_bus);
+               }
                ret = of_property_read_u32(of_node, "i2c_address", &val);
                if (ret) {
                        EXTERR("get %s i2c_address failed, exit\n",
@@ -478,16 +603,15 @@ static int lcd_extern_get_config_dts(struct device_node *of_node,
                                extconf->name, extconf->i2c_addr2);
                }
 
-               ret = of_property_read_string(of_node, "i2c_bus", &str);
-               if (ret) {
-                       EXTERR("get %s i2c_bus failed, exit\n", extconf->name);
-                       extconf->i2c_bus = AML_I2C_MASTER_A;
-                       return -1;
-               }
-               extconf->i2c_bus = lcd_extern_get_i2c_bus_str(str);
-               if (lcd_debug_print_flag) {
-                       EXTPR("%s i2c_bus=%s[%d]\n",
-                               extconf->name, str, extconf->i2c_bus);
+               extconf->i2c_sck_gpio = lcd_ext_i2c_sck_gpio;
+               extconf->i2c_sck_gpio_off = lcd_ext_i2c_sck_gpio_off;
+               extconf->i2c_sda_gpio = lcd_ext_i2c_sda_gpio;
+               extconf->i2c_sda_gpio_off = lcd_ext_i2c_sda_gpio_off;
+               if ((lcd_ext_i2c_sck_gpio < LCD_EXTERN_GPIO_NUM_MAX) ||
+                       (lcd_ext_i2c_sda_gpio < LCD_EXTERN_GPIO_NUM_MAX)) {
+                       EXTPR("find i2c_gpio_off config\n");
+                       lcd_extern_gpio_probe(extconf->i2c_sck_gpio);
+                       lcd_extern_gpio_probe(extconf->i2c_sda_gpio);
                }
 
                ret = of_property_read_u32(of_node, "cmd_size", &val);
@@ -642,62 +766,51 @@ static int lcd_extern_get_config_dts(struct device_node *of_node,
 }
 #endif
 
-static unsigned char aml_lcd_extern_i2c_bus_table[][2] = {
-       {LCD_EXTERN_I2C_BUS_AO, AML_I2C_MASTER_AO},
-       {LCD_EXTERN_I2C_BUS_A, AML_I2C_MASTER_A},
-       {LCD_EXTERN_I2C_BUS_B, AML_I2C_MASTER_B},
-       {LCD_EXTERN_I2C_BUS_C, AML_I2C_MASTER_C},
-       {LCD_EXTERN_I2C_BUS_D, AML_I2C_MASTER_D},
-};
 
 static unsigned char lcd_extern_get_i2c_bus_unifykey(unsigned char val)
 {
-       unsigned char i2c_bus = LCD_EXTERN_I2C_BUS_INVALID;
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(aml_lcd_extern_i2c_bus_table); i++) {
-               if (aml_lcd_extern_i2c_bus_table[i][0] == val) {
-                       i2c_bus = aml_lcd_extern_i2c_bus_table[i][1];
-                       break;
-               }
-       }
+       if (lcd_ext_i2c_bus == LCD_EXTERN_I2C_BUS_INVALID)
+               EXTERR("get i2c_bus failed\n");
+       if (lcd_debug_print_flag)
+               EXTPR("i2c_bus=%d\n", lcd_ext_i2c_bus);
 
-       return i2c_bus;
+       return lcd_ext_i2c_bus;
 }
 
 static int lcd_extern_init_table_dynamic_size_load_unifykey(
                struct lcd_extern_config_s *extconf, unsigned char *p,
                int key_len, int len, int flag)
 {
-       unsigned char cmd_size;
+       unsigned char cmd_size = 0;
        unsigned char index;
-       int i, j, max_len, step = 0, ret = 0;
-       unsigned char *init_table;
+       int i, j, max_len, ret = 0;
+       unsigned char *init_table, *buf;
        char propname[20];
 
        if (flag) {
                init_table = extconf->table_init_on;
                max_len = LCD_EXTERN_INIT_ON_MAX;
                sprintf(propname, "init_on");
+               buf = p;
        } else {
                init_table = extconf->table_init_off;
                max_len = LCD_EXTERN_INIT_OFF_MAX;
                sprintf(propname, "init_off");
+               buf = p + extconf->table_init_on_cnt;
        }
 
        i = 0;
-       while ((i + 2) < max_len) { /* type & cmd_size detect */
+       while (i < max_len) { /* type & cmd_size detect */
                /* step1: type */
                len += 1;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret) {
-                       EXTERR("get %s %s type failed, step %d\n",
-                               extconf->name, propname, step);
+                       EXTERR("get %s %s failed\n",
+                               extconf->name, propname);
                        init_table[i] = LCD_EXTERN_INIT_END;
                        return -1;
                }
-               init_table[i] = *p;
-               p++;
+               init_table[i] = *(buf + LCD_UKEY_EXT_INIT + i);
                if (init_table[i] == LCD_EXTERN_INIT_END)
                        break;
 
@@ -705,14 +818,13 @@ static int lcd_extern_init_table_dynamic_size_load_unifykey(
                len += 1;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret) {
-                       EXTERR("get %s %s cmd_size failed, step %d\n",
-                               extconf->name, propname, step);
+                       EXTERR("get %s %s failed\n",
+                               extconf->name, propname);
                        init_table[i] = LCD_EXTERN_INIT_END;
                        return -1;
                }
-               init_table[i+1] = *p;
+               init_table[i+1] = *(buf + LCD_UKEY_EXT_INIT + i + 1);
                cmd_size = init_table[i+1];
-               p++;
                if (cmd_size == 0) {
                        i += 2;
                        continue;
@@ -724,17 +836,16 @@ static int lcd_extern_init_table_dynamic_size_load_unifykey(
                len += cmd_size;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret) {
-                       EXTERR("get %s %s data failed, step %d\n",
-                               extconf->name, propname, step);
+                       EXTERR("get %s %s failed\n",
+                               extconf->name, propname);
                        init_table[i] = LCD_EXTERN_INIT_END;
                        for (j = 0; j < cmd_size; j++)
                                init_table[i+2+j] = 0x0;
                        return -1;
                }
-               for (j = 0; j < cmd_size; j++) {
-                       init_table[i+2+j] = *p;
-                       p++;
-               }
+               for (j = 0; j < cmd_size; j++)
+                       init_table[i+2+j] = *(buf +
+                               LCD_UKEY_EXT_INIT + i + 2 + j);
                if (init_table[i] == LCD_EXTERN_INIT_END) {
                        break;
                } else if (init_table[i] == LCD_EXTERN_INIT_GPIO) {
@@ -743,9 +854,10 @@ static int lcd_extern_init_table_dynamic_size_load_unifykey(
                        if (index < LCD_EXTERN_GPIO_NUM_MAX)
                                lcd_extern_gpio_probe(index);
                }
-               step++;
                i += (cmd_size + 2);
        }
+       if (flag)
+               extconf->table_init_on_cnt = i + 2;
 
        return 0;
 }
@@ -756,8 +868,8 @@ static int lcd_extern_init_table_fixed_size_load_unifykey(
 {
        unsigned char cmd_size;
        unsigned char index;
-       int i, j, max_len, step = 0, ret = 0;
-       unsigned char *init_table;
+       int i, j, max_len, ret = 0;
+       unsigned char *init_table, *buf;
        char propname[20];
 
        cmd_size = extconf->cmd_size;
@@ -765,26 +877,27 @@ static int lcd_extern_init_table_fixed_size_load_unifykey(
                init_table = extconf->table_init_on;
                max_len = LCD_EXTERN_INIT_ON_MAX;
                sprintf(propname, "init_on");
+               buf = p;
        } else {
                init_table = extconf->table_init_off;
                max_len = LCD_EXTERN_INIT_OFF_MAX;
                sprintf(propname, "init_off");
+               buf = p + extconf->table_init_on_cnt;
        }
 
        i = 0;
-       while ((i + cmd_size) <= max_len) { /* group detect */
+       while (i < max_len) {
                len += cmd_size;
                ret = lcd_unifykey_len_check(key_len, len);
                if (ret) {
-                       EXTERR("get %s %s failed, step %d\n",
-                               extconf->name, propname, step);
+                       EXTERR("get %s %s failed\n",
+                               extconf->name, propname);
                        init_table[i] = LCD_EXTERN_INIT_END;
                        return -1;
                }
-               for (j = 0; j < cmd_size; j++) {
-                       init_table[i+j] = *p;
-                       p++;
-               }
+               for (j = 0; j < cmd_size; j++)
+                       init_table[i+j] = *(buf +
+                               LCD_UKEY_EXT_INIT + i + j);
                if (init_table[i] == LCD_EXTERN_INIT_END) {
                        break;
                } else if (init_table[i] == LCD_EXTERN_INIT_GPIO) {
@@ -793,9 +906,10 @@ static int lcd_extern_init_table_fixed_size_load_unifykey(
                        if (index < LCD_EXTERN_GPIO_NUM_MAX)
                                lcd_extern_gpio_probe(index);
                }
-               step++;
                i += cmd_size;
        }
+       if (flag)
+               extconf->table_init_on_cnt = i + cmd_size;
 
        return 0;
 }
@@ -846,37 +960,33 @@ static int lcd_extern_get_config_unifykey(struct lcd_extern_config_s *extconf)
        }
 
        /* basic: 33byte */
-       p = para + LCD_UKEY_HEAD_SIZE;
-       str = (const char *)p;
+       p = para;
+       str = (const char *)(p + LCD_UKEY_HEAD_SIZE);
        strncpy(extconf->name, str, LCD_EXTERN_NAME_LEN_MAX);
        /* ensure string ending */
        extconf->name[LCD_EXTERN_NAME_LEN_MAX-1] = '\0';
-       p += LCD_UKEY_EXT_NAME;
-       extconf->index = *p;
-       p += LCD_UKEY_EXT_INDEX;
-       extconf->type = *p;
-       p += LCD_UKEY_EXT_TYPE;
-       extconf->status = *p;
-       p += LCD_UKEY_EXT_STATUS;
+       extconf->index = *(p + LCD_UKEY_EXT_INDEX);
+       extconf->type = *(p + LCD_UKEY_EXT_TYPE);
+       extconf->status = *(p + LCD_UKEY_EXT_STATUS);
 
        /* type: 10byte */
        switch (extconf->type) {
        case LCD_EXTERN_I2C:
-               extconf->i2c_addr = *p;
-               p += LCD_UKEY_EXT_TYPE_VAL_0;
-               extconf->i2c_addr2 = *p;
-               p += LCD_UKEY_EXT_TYPE_VAL_1;
-               extconf->i2c_bus = lcd_extern_get_i2c_bus_unifykey(*p);
-               p += LCD_UKEY_EXT_TYPE_VAL_2;
-               extconf->cmd_size = *p;
-               p += LCD_UKEY_EXT_TYPE_VAL_3;
-               /* dummy pointer */
-               p += LCD_UKEY_EXT_TYPE_VAL_4;
-               p += LCD_UKEY_EXT_TYPE_VAL_5;
-               p += LCD_UKEY_EXT_TYPE_VAL_6;
-               p += LCD_UKEY_EXT_TYPE_VAL_7;
-               p += LCD_UKEY_EXT_TYPE_VAL_8;
-               p += LCD_UKEY_EXT_TYPE_VAL_9;
+               extconf->i2c_addr = *(p + LCD_UKEY_EXT_TYPE_VAL_0);
+               extconf->i2c_addr2 = *(p + LCD_UKEY_EXT_TYPE_VAL_1);
+               extconf->i2c_bus = lcd_extern_get_i2c_bus_unifykey(
+                       *(p + LCD_UKEY_EXT_TYPE_VAL_2));
+               extconf->i2c_sck_gpio = lcd_ext_i2c_sck_gpio;
+               extconf->i2c_sck_gpio_off = lcd_ext_i2c_sck_gpio_off;
+               extconf->i2c_sda_gpio = lcd_ext_i2c_sda_gpio;
+               extconf->i2c_sda_gpio_off = lcd_ext_i2c_sda_gpio_off;
+               if ((lcd_ext_i2c_sck_gpio < LCD_EXTERN_GPIO_NUM_MAX) ||
+                       (lcd_ext_i2c_sda_gpio < LCD_EXTERN_GPIO_NUM_MAX)) {
+                       EXTPR("find i2c_gpio_off config\n");
+                       lcd_extern_gpio_probe(extconf->i2c_sck_gpio);
+                       lcd_extern_gpio_probe(extconf->i2c_sda_gpio);
+               }
+               extconf->cmd_size = *(p + LCD_UKEY_EXT_TYPE_VAL_3);
 
                /* init */
                if (extconf->cmd_size <= 1) {
@@ -902,28 +1012,18 @@ static int lcd_extern_get_config_unifykey(struct lcd_extern_config_s *extconf)
                        extconf->table_init_loaded = 1;
                break;
        case LCD_EXTERN_SPI:
-               extconf->spi_gpio_cs = *p;
-               lcd_extern_gpio_probe(*p);
-               p += LCD_UKEY_EXT_TYPE_VAL_0;
-               extconf->spi_gpio_clk = *p;
-               lcd_extern_gpio_probe(*p);
-               p += LCD_UKEY_EXT_TYPE_VAL_1;
-               extconf->spi_gpio_data = *p;
-               lcd_extern_gpio_probe(*p);
-               p += LCD_UKEY_EXT_TYPE_VAL_2;
-               extconf->spi_clk_freq = (*p | ((*(p + 1)) << 8) |
-                                       ((*(p + 2)) << 16) |
-                                       ((*(p + 3)) << 24));
-               p += LCD_UKEY_EXT_TYPE_VAL_3;
-               p += LCD_UKEY_EXT_TYPE_VAL_4;
-               p += LCD_UKEY_EXT_TYPE_VAL_5;
-               p += LCD_UKEY_EXT_TYPE_VAL_6;
-               extconf->spi_clk_pol = *p;
-               p += LCD_UKEY_EXT_TYPE_VAL_7;
-               extconf->cmd_size = *p;
-               p += LCD_UKEY_EXT_TYPE_VAL_8;
-               /* dummy pointer */
-               p += LCD_UKEY_EXT_TYPE_VAL_9;
+               extconf->spi_gpio_cs = *(p + LCD_UKEY_EXT_TYPE_VAL_0);
+               lcd_extern_gpio_probe(*(p + LCD_UKEY_EXT_TYPE_VAL_0));
+               extconf->spi_gpio_clk = *(p + LCD_UKEY_EXT_TYPE_VAL_1);
+               lcd_extern_gpio_probe(*(p + LCD_UKEY_EXT_TYPE_VAL_1));
+               extconf->spi_gpio_data = *(p + LCD_UKEY_EXT_TYPE_VAL_2);
+               lcd_extern_gpio_probe(*(p + LCD_UKEY_EXT_TYPE_VAL_2));
+               extconf->spi_clk_freq = (*(p + LCD_UKEY_EXT_TYPE_VAL_3) |
+                       ((*(p + LCD_UKEY_EXT_TYPE_VAL_3 + 1)) << 8) |
+                       ((*(p + LCD_UKEY_EXT_TYPE_VAL_3 + 2)) << 16) |
+                       ((*(p + LCD_UKEY_EXT_TYPE_VAL_3 + 3)) << 24));
+               extconf->spi_clk_pol = *(p + LCD_UKEY_EXT_TYPE_VAL_7);
+               extconf->cmd_size = *(p + LCD_UKEY_EXT_TYPE_VAL_8);
 
                /* init */
                if (extconf->cmd_size <= 1) {
@@ -949,18 +1049,6 @@ static int lcd_extern_get_config_unifykey(struct lcd_extern_config_s *extconf)
                        extconf->table_init_loaded = 1;
                break;
        case LCD_EXTERN_MIPI:
-               /* dummy pointer */
-               p += LCD_UKEY_EXT_TYPE_VAL_0;
-               p += LCD_UKEY_EXT_TYPE_VAL_1;
-               p += LCD_UKEY_EXT_TYPE_VAL_2;
-               p += LCD_UKEY_EXT_TYPE_VAL_3;
-               p += LCD_UKEY_EXT_TYPE_VAL_4;
-               p += LCD_UKEY_EXT_TYPE_VAL_5;
-               p += LCD_UKEY_EXT_TYPE_VAL_6;
-               p += LCD_UKEY_EXT_TYPE_VAL_7;
-               p += LCD_UKEY_EXT_TYPE_VAL_8;
-               p += LCD_UKEY_EXT_TYPE_VAL_9;
-
                /* init */
                /* to do */
                break;
@@ -978,6 +1066,8 @@ static int lcd_extern_get_config(void)
        struct lcd_extern_config_s extconf;
        unsigned char *lcd_ext_init_on_table;
        unsigned char *lcd_ext_init_off_table;
+       unsigned int extern_para[5];
+       const char *str;
        int load_id = 0;
        int ret;
 
@@ -1003,6 +1093,29 @@ static int lcd_extern_get_config(void)
        lcd_ext_init_on_table[0] = LCD_EXTERN_INIT_END;
        lcd_ext_init_off_table[0] = LCD_EXTERN_INIT_END;
 
+       ret = of_property_read_string(lcd_extern_dev->of_node,
+                       "i2c_bus", &str);
+       if (ret)
+               lcd_ext_i2c_bus = LCD_EXTERN_I2C_BUS_INVALID;
+       else
+               lcd_ext_i2c_bus = lcd_extern_get_i2c_bus_str(str);
+       if (lcd_debug_print_flag)
+               EXTPR("i2c_bus=%s[%d]\n", str, lcd_ext_i2c_bus);
+
+       ret = of_property_read_u32_array(lcd_extern_dev->of_node,
+               "i2c_gpio_off", &extern_para[0], 4);
+       if (ret) {
+               lcd_ext_i2c_sck_gpio = LCD_EXTERN_GPIO_NUM_MAX;
+               lcd_ext_i2c_sck_gpio_off = 2;
+               lcd_ext_i2c_sda_gpio = LCD_EXTERN_GPIO_NUM_MAX;
+               lcd_ext_i2c_sda_gpio_off = 2;
+       } else {
+               lcd_ext_i2c_sck_gpio = extern_para[0];
+               lcd_ext_i2c_sck_gpio_off = extern_para[1];
+               lcd_ext_i2c_sda_gpio = extern_para[2];
+               lcd_ext_i2c_sda_gpio_off = extern_para[3];
+       }
+
        ret = of_property_read_u32(lcd_extern_dev->of_node,
                        "key_valid", &lcd_ext_key_valid);
        if (ret) {
@@ -1172,7 +1285,7 @@ static int lcd_extern_add_driver(struct lcd_extern_config_s *extconf)
                        extconf->name, extconf->index);
                return -1;
        }
-
+       lcd_ext_driver[i]->pinmux_flag = 0;
        ext_drv = lcd_ext_driver[i];
        /* fill config parameters */
        ext_drv->config.index = extconf->index;
@@ -1182,6 +1295,7 @@ static int lcd_extern_add_driver(struct lcd_extern_config_s *extconf)
        ext_drv->config.table_init_on = NULL;
        ext_drv->config.table_init_off = NULL;
        ext_drv->config.table_init_loaded = extconf->table_init_loaded;
+       ext_drv->config.table_init_on_cnt = extconf->table_init_on_cnt;
        if (ext_drv->config.table_init_loaded) {
                ext_drv->config.table_init_on =
                        kmalloc(sizeof(unsigned char) * LCD_EXTERN_INIT_ON_MAX,
@@ -1211,6 +1325,10 @@ static int lcd_extern_add_driver(struct lcd_extern_config_s *extconf)
                ext_drv->config.i2c_addr = extconf->i2c_addr;
                ext_drv->config.i2c_addr2 = extconf->i2c_addr2;
                ext_drv->config.i2c_bus = extconf->i2c_bus;
+               ext_drv->config.i2c_sck_gpio = extconf->i2c_sck_gpio;
+               ext_drv->config.i2c_sck_gpio_off = extconf->i2c_sck_gpio_off;
+               ext_drv->config.i2c_sda_gpio = extconf->i2c_sda_gpio;
+               ext_drv->config.i2c_sda_gpio_off = extconf->i2c_sda_gpio_off;
                ext_drv->config.cmd_size = extconf->cmd_size;
                ret = lcd_extern_add_i2c(ext_drv);
                break;
@@ -1364,6 +1482,8 @@ static void lcd_extern_config_dump(struct aml_lcd_extern_driver_s *ext_drv)
                        econf->cmd_size, econf->i2c_addr,
                        econf->i2c_addr2, econf->i2c_bus,
                        econf->table_init_loaded);
+               if (econf->cmd_size == 0)
+                       break;
                if (econf->cmd_size == LCD_EXTERN_CMD_SIZE_DYNAMIC) {
                        lcd_extern_init_table_dynamic_size_print(econf, 1);
                        lcd_extern_init_table_dynamic_size_print(econf, 0);
@@ -1386,6 +1506,8 @@ static void lcd_extern_config_dump(struct aml_lcd_extern_driver_s *ext_drv)
                        econf->spi_gpio_clk, econf->spi_gpio_data,
                        econf->spi_clk_freq, econf->spi_delay_us,
                        econf->spi_clk_pol, econf->table_init_loaded);
+               if (econf->cmd_size == 0)
+                       break;
                if (econf->cmd_size == LCD_EXTERN_CMD_SIZE_DYNAMIC) {
                        lcd_extern_init_table_dynamic_size_print(econf, 1);
                        lcd_extern_init_table_dynamic_size_print(econf, 0);
@@ -1483,10 +1605,10 @@ static ssize_t lcd_extern_debug_test_store(struct class *class,
        if (ext_drv) {
                if (flag) {
                        if (ext_drv->power_on)
-                               ext_drv->power_on();
+                               ext_drv->power_on(ext_drv);
                } else {
                        if (ext_drv->power_off)
-                               ext_drv->power_off();
+                               ext_drv->power_off(ext_drv);
                }
        }
 
index b0f2387..bd896e6 100644 (file)
@@ -34,6 +34,8 @@ extern struct device_node *aml_lcd_extern_get_dts_child(int index);
 extern void lcd_extern_gpio_probe(unsigned char index);
 extern void lcd_extern_gpio_set(unsigned char index, int value);
 extern unsigned int lcd_extern_gpio_get(unsigned char index);
+extern void lcd_extern_pinmux_set(
+       struct aml_lcd_extern_driver_s *ext_drv, int status);
 
 #define LCD_EXTERN_DEFAULT_ENABLE
 
index d68ab81..48433eb 100644 (file)
@@ -74,7 +74,7 @@ static void lcd_lvds_phy_set(struct lcd_config_s *pconf, int status)
                clk_vswing = pconf->lcd_control.lvds_config->phy_clk_vswing;
                clk_preem = pconf->lcd_control.lvds_config->phy_clk_preem;
                if (vswing > 7) {
-                       LCDERR("%s: wrong vswing_level=0x%x, use default\n",
+                       LCDERR("%s: wrong vswing_level=%d, use default\n",
                                __func__, vswing);
                        vswing = LVDS_PHY_VSWING_DFT;
                }
@@ -114,13 +114,14 @@ static void lcd_vbyone_phy_set(struct lcd_config_s *pconf, int status)
 {
        unsigned int vswing, preem, ext_pullup;
        unsigned int data32;
+       unsigned int rinner_table[] = {0xa, 0xa, 0x6, 0x4};
 
        if (lcd_debug_print_flag)
                LCDPR("%s: %d\n", __func__, status);
 
        if (status) {
-               ext_pullup =
-                       (pconf->lcd_control.vbyone_config->phy_vswing >> 4) & 1;
+               ext_pullup = (pconf->lcd_control.vbyone_config->phy_vswing >> 4)
+                               & 0x3;
                vswing = pconf->lcd_control.vbyone_config->phy_vswing & 0xf;
                preem = pconf->lcd_control.vbyone_config->phy_preem;
                if (vswing > 7) {
@@ -133,15 +134,16 @@ static void lcd_vbyone_phy_set(struct lcd_config_s *pconf, int status)
                                __func__, preem);
                        preem = VX1_PHY_PREEM_DFT;
                }
-               data32 = 0x6e0ec900 | (vswing << 3) | (ext_pullup << 10);
                if (ext_pullup)
-                       data32 &= ~(1 << 15);
+                       data32 = VX1_PHY_CNTL1_G9TV_PULLUP | (vswing << 3);
+               else
+                       data32 = VX1_PHY_CNTL1_G9TV | (vswing << 3);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, data32);
-               data32 = 0x00000a7c | (preem << 20);
+               data32 = VX1_PHY_CNTL2_G9TV | (preem << 20) |
+                       (rinner_table[ext_pullup] << 8);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, data32);
-               /*lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, 0x6e0ec918);
-               lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, 0x00000a7c);*/
-               lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL3, 0x00ff0800);
+               data32 = VX1_PHY_CNTL3_G9TV;
+               lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL3, data32);
        } else {
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, 0x0);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, 0x0);
index 4b36cf7..15a52c1 100644 (file)
@@ -921,10 +921,10 @@ static int lcd_config_load_from_unifykey(struct lcd_config_s *pconf)
        LCDPR("unifykey version: 0x%04x\n", lcd_header.version);
        switch (lcd_header.version) {
        case 2:
-               len = 10 + 36 + 18 + 31 + 20 + 44 + 10;
+               len = LCD_UKEY_DATA_LEN_V2; /*10+36+18+31+20+44+10*/
                break;
        default:
-               len = 10 + 36 + 18 + 31 + 20;
+               len = LCD_UKEY_DATA_LEN_V1; /*10+36+18+31+20*/
                break;
        }
        if (lcd_debug_print_flag) {
@@ -946,285 +946,193 @@ static int lcd_config_load_from_unifykey(struct lcd_config_s *pconf)
        sprintf(pconf->lcd_propname, "%s", "unifykey");
 
        /* basic: 36byte */
-       p = para + LCD_UKEY_HEAD_SIZE;
-       str = (const char *)p;
+       p = para;
+       str = (const char *)(p + LCD_UKEY_HEAD_SIZE);
        strncpy(pconf->lcd_basic.model_name, str, MOD_LEN_MAX);
        /* ensure string ending */
        pconf->lcd_basic.model_name[MOD_LEN_MAX-1] = '\0';
-       p += LCD_UKEY_MODEL_NAME;
-       pconf->lcd_basic.lcd_type = *p;
-       p += LCD_UKEY_INTERFACE;
-       pconf->lcd_basic.lcd_bits = *p;
-       p += LCD_UKEY_LCD_BITS;
-       pconf->lcd_basic.screen_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_SCREEN_WIDTH;
-       pconf->lcd_basic.screen_height = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_SCREEN_HEIGHT;
+       pconf->lcd_basic.lcd_type = *(p + LCD_UKEY_INTERFACE);
+       pconf->lcd_basic.lcd_bits = *(p + LCD_UKEY_LCD_BITS);
+       pconf->lcd_basic.screen_width = (*(p + LCD_UKEY_SCREEN_WIDTH) |
+               ((*(p + LCD_UKEY_SCREEN_WIDTH + 1)) << 8));
+       pconf->lcd_basic.screen_height = (*(p + LCD_UKEY_SCREEN_HEIGHT) |
+               ((*(p + LCD_UKEY_SCREEN_HEIGHT + 1)) << 8));
 
        /* timing: 18byte */
-       pconf->lcd_basic.h_active = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_ACTIVE;
-       pconf->lcd_basic.v_active = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_ACTIVE;
-       pconf->lcd_basic.h_period = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD;
-       pconf->lcd_basic.v_period = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD;
-       pconf->lcd_timing.hsync_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_HS_WIDTH;
-       pconf->lcd_timing.hsync_bp = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_HS_BP;
-       pconf->lcd_timing.hsync_pol = *p;
-       p += LCD_UKEY_HS_POL;
-       pconf->lcd_timing.vsync_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_VS_WIDTH;
-       pconf->lcd_timing.vsync_bp = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_VS_BP;
-       pconf->lcd_timing.vsync_pol = *p;
-       p += LCD_UKEY_VS_POL;
+       pconf->lcd_basic.h_active = (*(p + LCD_UKEY_H_ACTIVE) |
+               ((*(p + LCD_UKEY_H_ACTIVE + 1)) << 8));
+       pconf->lcd_basic.v_active = (*(p + LCD_UKEY_V_ACTIVE)) |
+               ((*(p + LCD_UKEY_V_ACTIVE + 1)) << 8);
+       pconf->lcd_basic.h_period = (*(p + LCD_UKEY_H_PERIOD)) |
+               ((*(p + LCD_UKEY_H_PERIOD + 1)) << 8);
+       pconf->lcd_basic.v_period = (*(p + LCD_UKEY_V_PERIOD)) |
+               ((*(p + LCD_UKEY_V_PERIOD + 1)) << 8);
+       pconf->lcd_timing.hsync_width = (*(p + LCD_UKEY_HS_WIDTH) |
+               ((*(p + LCD_UKEY_HS_WIDTH + 1)) << 8));
+       pconf->lcd_timing.hsync_bp = (*(p + LCD_UKEY_HS_BP) |
+               ((*(p + LCD_UKEY_HS_BP + 1)) << 8));
+       pconf->lcd_timing.hsync_pol = *(p + LCD_UKEY_HS_POL);
+       pconf->lcd_timing.vsync_width = (*(p + LCD_UKEY_VS_WIDTH) |
+               ((*(p + LCD_UKEY_VS_WIDTH + 1)) << 8));
+       pconf->lcd_timing.vsync_bp = (*(p + LCD_UKEY_VS_BP) |
+               ((*(p + LCD_UKEY_VS_BP + 1)) << 8));
+       pconf->lcd_timing.vsync_pol = *(p + LCD_UKEY_VS_POL);
 
        /* customer: 31byte */
-       pconf->lcd_timing.fr_adjust_type = *p;
-       p += LCD_UKEY_FR_ADJ_TYPE;
-       pconf->lcd_timing.ss_level = *p;
-       p += LCD_UKEY_SS_LEVEL;
-       pconf->lcd_timing.clk_auto = *p;
-       p += LCD_UKEY_CLK_AUTO_GEN;
-       pconf->lcd_timing.lcd_clk = (*p | ((*(p + 1)) << 8) |
-               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-       p += LCD_UKEY_PCLK;
-       pconf->lcd_basic.h_period_min = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD_MIN;
-       pconf->lcd_basic.h_period_max = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD_MAX;
-       pconf->lcd_basic.v_period_min = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD_MIN;
-       pconf->lcd_basic.v_period_max = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD_MAX;
-       pconf->lcd_basic.lcd_clk_min = (*p | ((*(p + 1)) << 8) |
-               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-       p += LCD_UKEY_PCLK_MIN;
-       pconf->lcd_basic.lcd_clk_max = (*p | ((*(p + 1)) << 8) |
-               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-       p += LCD_UKEY_PCLK_MAX;
-       /* dummy pointer */
-       p += LCD_UKEY_CUST_VAL_8;
-       p += LCD_UKEY_CUST_VAL_9;
+       pconf->lcd_timing.fr_adjust_type = *(p + LCD_UKEY_FR_ADJ_TYPE);
+       pconf->lcd_timing.ss_level = *(p + LCD_UKEY_SS_LEVEL);
+       pconf->lcd_timing.clk_auto = *(p + LCD_UKEY_CLK_AUTO_GEN);
+       pconf->lcd_timing.lcd_clk = (*(p + LCD_UKEY_PCLK) |
+               ((*(p + LCD_UKEY_PCLK + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK + 3)) << 24));
+       pconf->lcd_basic.h_period_min = (*(p + LCD_UKEY_H_PERIOD_MIN) |
+               ((*(p + LCD_UKEY_H_PERIOD_MIN + 1)) << 8));
+       pconf->lcd_basic.h_period_max = (*(p + LCD_UKEY_H_PERIOD_MAX) |
+               ((*(p + LCD_UKEY_H_PERIOD_MAX + 1)) << 8));
+       pconf->lcd_basic.v_period_min = (*(p + LCD_UKEY_V_PERIOD_MIN) |
+               ((*(p  + LCD_UKEY_V_PERIOD_MIN + 1)) << 8));
+       pconf->lcd_basic.v_period_max = (*(p + LCD_UKEY_V_PERIOD_MAX) |
+               ((*(p + LCD_UKEY_V_PERIOD_MAX + 1)) << 8));
+       pconf->lcd_basic.lcd_clk_min = (*(p + LCD_UKEY_PCLK_MIN) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 3)) << 24));
+       pconf->lcd_basic.lcd_clk_max = (*(p + LCD_UKEY_PCLK_MAX) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 3)) << 24));
 
        /* interface: 20byte */
        if (pconf->lcd_basic.lcd_type == LCD_LVDS) {
                if (lcd_header.version == 2) {
                        pconf->lcd_control.lvds_config->lvds_repack =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
+                               (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->dual_port =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
+                               (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->pn_swap =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
+                               (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->port_swap =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
+                               (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->lane_reverse =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_5;
-                       p += LCD_UKEY_IF_ATTR_6;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                               (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
                } else {
                        pconf->lcd_control.lvds_config->lvds_repack =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
+                               (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->dual_port =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
+                               (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->pn_swap =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
+                               (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->port_swap =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
+                               (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->phy_vswing =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
+                               (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->phy_preem =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
+                               (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->phy_clk_vswing =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_6;
+                               (*(p + LCD_UKEY_IF_ATTR_6) |
+                               ((*(p + LCD_UKEY_IF_ATTR_6 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.lvds_config->phy_clk_preem =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                               (*(p + LCD_UKEY_IF_ATTR_7) |
+                               ((*(p + LCD_UKEY_IF_ATTR_7 + 1)) << 8)) & 0xff;
 
                        pconf->lcd_control.lvds_config->lane_reverse = 0;
                }
        } else if (pconf->lcd_basic.lcd_type == LCD_TTL) {
                pconf->lcd_control.ttl_config->clk_pol =
-                       (*p | ((*(p + 1)) << 8)) & 0x1;
-               p += LCD_UKEY_IF_ATTR_0;
-               temp = (*p | ((*(p + 1)) << 8)) & 0x1; /* de_valid */
+                       (*(p + LCD_UKEY_IF_ATTR_0) |
+                       ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0x1;
+               temp = (*(p + LCD_UKEY_IF_ATTR_1) |
+                       ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0x1;
                pconf->lcd_control.ttl_config->sync_valid = (temp << 1);
-               p += LCD_UKEY_IF_ATTR_1;
-               temp = (*p | ((*(p + 1)) << 8)) & 0x1; /* hvsync_valid */
+               temp = (*(p + LCD_UKEY_IF_ATTR_2) |
+                       ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0x1;
                pconf->lcd_control.ttl_config->sync_valid |= (temp << 0);
-               p += LCD_UKEY_IF_ATTR_2;
-               temp = (*p | ((*(p + 1)) << 8)) & 0x1; /* rb_swap */
+               temp = (*(p + LCD_UKEY_IF_ATTR_3) |
+                       ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0x1;
                pconf->lcd_control.ttl_config->swap_ctrl = (temp << 1);
-               p += LCD_UKEY_IF_ATTR_3;
-               temp = (*p | ((*(p + 1)) << 8)) & 0x1; /* bit_swap */
+               temp = (*(p + LCD_UKEY_IF_ATTR_4) |
+                       ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0x1;
                pconf->lcd_control.ttl_config->swap_ctrl |= (temp << 0);
-               p += LCD_UKEY_IF_ATTR_4;
-               /* dummy pointer */
-               p += LCD_UKEY_IF_ATTR_5;
-               p += LCD_UKEY_IF_ATTR_6;
-               p += LCD_UKEY_IF_ATTR_7;
-               p += LCD_UKEY_IF_ATTR_8;
-               p += LCD_UKEY_IF_ATTR_9;
        } else if (pconf->lcd_basic.lcd_type == LCD_VBYONE) {
                if (lcd_header.version == 2) {
                        pconf->lcd_control.vbyone_config->lane_count =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
+                               (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->region_num =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
+                               (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->byte_mode  =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
+                               (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->color_fmt  =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
+                               (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
+                               (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->vsync_intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_6;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                               (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
                } else {
                        pconf->lcd_control.vbyone_config->lane_count =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
+                               (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->region_num =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
+                               (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->byte_mode  =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
+                               (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->color_fmt  =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
+                               (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->phy_vswing =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
+                               (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->phy_preem =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
+                               (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_6;
+                               (*(p + LCD_UKEY_IF_ATTR_6) |
+                               ((*(p + LCD_UKEY_IF_ATTR_6 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->vsync_intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                               (*(p + LCD_UKEY_IF_ATTR_7) |
+                               ((*(p + LCD_UKEY_IF_ATTR_7 + 1)) << 8)) & 0xff;
                }
-       } else {
+       } else
                LCDERR("unsupport lcd_type: %d\n", pconf->lcd_basic.lcd_type);
-               p += LCD_UKEY_IF_ATTR_0;
-               p += LCD_UKEY_IF_ATTR_1;
-               p += LCD_UKEY_IF_ATTR_2;
-               p += LCD_UKEY_IF_ATTR_3;
-               p += LCD_UKEY_IF_ATTR_4;
-               p += LCD_UKEY_IF_ATTR_5;
-               p += LCD_UKEY_IF_ATTR_6;
-               p += LCD_UKEY_IF_ATTR_7;
-               p += LCD_UKEY_IF_ATTR_8;
-               p += LCD_UKEY_IF_ATTR_9;
-       }
 
        if (lcd_header.version == 2) {
                /* ctrl: 44byte */ /* v2 */
-               /* dummy pointer */
-               p += LCD_UKEY_CTRL_FLAG;
-               p += LCD_UKEY_CTRL_ATTR_0;
-               p += LCD_UKEY_CTRL_ATTR_1;
-               p += LCD_UKEY_CTRL_ATTR_2;
-               p += LCD_UKEY_CTRL_ATTR_3;
-               p += LCD_UKEY_CTRL_ATTR_4;
-               p += LCD_UKEY_CTRL_ATTR_5;
-               p += LCD_UKEY_CTRL_ATTR_6;
-               p += LCD_UKEY_CTRL_ATTR_7;
-               p += LCD_UKEY_CTRL_ATTR_8;
-               p += LCD_UKEY_CTRL_ATTR_9;
-               p += LCD_UKEY_CTRL_ATTR_10;
-               p += LCD_UKEY_CTRL_ATTR_11;
-               p += LCD_UKEY_CTRL_ATTR_12;
-               p += LCD_UKEY_CTRL_ATTR_13;
-               p += LCD_UKEY_CTRL_ATTR_14;
-               p += LCD_UKEY_CTRL_ATTR_15;
-               p += LCD_UKEY_CTRL_ATTR_16;
-               p += LCD_UKEY_CTRL_ATTR_17;
-               p += LCD_UKEY_CTRL_ATTR_18;
-               p += LCD_UKEY_CTRL_ATTR_19;
-
                /* phy: 10byte */ /* v2 */
                if (pconf->lcd_basic.lcd_type == LCD_LVDS) {
-                       pconf->lcd_control.lvds_config->phy_vswing = *p;
-                       p += LCD_UKEY_PHY_ATTR_0;
-                       pconf->lcd_control.lvds_config->phy_preem = *p;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       pconf->lcd_control.lvds_config->phy_clk_vswing = *p;
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       pconf->lcd_control.lvds_config->phy_clk_preem = *p;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       /* dummy pointer */
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
+                       pconf->lcd_control.lvds_config->phy_vswing =
+                               *(p + LCD_UKEY_PHY_ATTR_0);
+                       pconf->lcd_control.lvds_config->phy_preem =
+                               *(p + LCD_UKEY_PHY_ATTR_1);
+                       pconf->lcd_control.lvds_config->phy_clk_vswing =
+                               *(p + LCD_UKEY_PHY_ATTR_2);
+                       pconf->lcd_control.lvds_config->phy_clk_preem =
+                               *(p + LCD_UKEY_PHY_ATTR_3);
                } else if (pconf->lcd_basic.lcd_type == LCD_VBYONE) {
                        pconf->lcd_control.vbyone_config->phy_vswing =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_PHY_ATTR_0;
+                               (*(p + LCD_UKEY_PHY_ATTR_0) |
+                               ((*(p + LCD_UKEY_PHY_ATTR_0 + 1)) << 8)) & 0xff;
                        pconf->lcd_control.vbyone_config->phy_preem =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       /* dummy pointer */
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
-               } else {
-                       p += LCD_UKEY_PHY_ATTR_0;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
+                               (*(p + LCD_UKEY_PHY_ATTR_1) |
+                               ((*(p + LCD_UKEY_PHY_ATTR_1 + 1)) << 8)) & 0xff;
                }
        }
 
index 5eea707..b7e3a0a 100644 (file)
@@ -73,13 +73,14 @@ static void lcd_vbyone_phy_set(struct lcd_config_s *pconf, int status)
 {
        unsigned int vswing, preem, ext_pullup;
        unsigned int data32;
+       unsigned int rinner_table[] = {0xa, 0xa, 0x6, 0x4};
 
        if (lcd_debug_print_flag)
                LCDPR("%s: %d\n", __func__, status);
 
        if (status) {
-               ext_pullup =
-                       (pconf->lcd_control.vbyone_config->phy_vswing >> 4) & 1;
+               ext_pullup = (pconf->lcd_control.vbyone_config->phy_vswing >> 4)
+                               & 0x3;
                vswing = pconf->lcd_control.vbyone_config->phy_vswing & 0xf;
                preem = pconf->lcd_control.vbyone_config->phy_preem;
                if (vswing > 7) {
@@ -92,15 +93,17 @@ static void lcd_vbyone_phy_set(struct lcd_config_s *pconf, int status)
                                __func__, preem);
                        preem = VX1_PHY_PREEM_DFT;
                }
-               data32 = 0x6e0ec900 | (vswing << 3) | (ext_pullup << 10);
                if (ext_pullup)
-                       data32 &= ~(1 << 15);
+                       data32 = VX1_PHY_CNTL1_G9TV_PULLUP | (vswing << 3);
+               else
+                       data32 = VX1_PHY_CNTL1_G9TV | (vswing << 3);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, data32);
-               data32 = 0x00000a7c | (preem << 20);
+               data32 = VX1_PHY_CNTL2_G9TV | (preem << 20) |
+                       (rinner_table[ext_pullup] << 8);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, data32);
-               /*lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, 0x6e0ec918);*/
+               data32 = VX1_PHY_CNTL3_G9TV;
                /*lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, 0x00000a7c);*/
-               lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL3, 0x00ff0800);
+               lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL3, data32);
        } else {
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL1, 0x0);
                lcd_hiu_write(HHI_DIF_CSI_PHY_CNTL2, 0x0);
index 3f6c253..c2c724e 100644 (file)
@@ -199,6 +199,7 @@ static void lcd_vmode_vinfo_update(enum vmode_e mode)
        struct aml_lcd_drv_s *lcd_drv = aml_lcd_get_driver();
        struct lcd_config_s *pconf;
 
+       pconf = lcd_drv->lcd_config;
        lcd_output_vmode = lcd_get_vmode(mode);
        info = &lcd_vmode_info[lcd_output_vmode];
        sprintf(lcd_output_name, "%s%dhz", info->name, info->frame_rate);
@@ -208,8 +209,16 @@ static void lcd_vmode_vinfo_update(enum vmode_e mode)
        }
 
        /* store standard duration */
-       lcd_drv->std_duration.duration_num = info->frame_rate;
-       lcd_drv->std_duration.duration_den = 1;
+       if (pconf->lcd_timing.fr_adjust_type == 0xff) {
+               lcd_drv->std_duration.duration_num =
+                       ((pconf->lcd_timing.lcd_clk /
+                       pconf->lcd_basic.h_period) * 100) /
+                       pconf->lcd_basic.v_period;
+               lcd_drv->std_duration.duration_den = 100;
+       } else {
+               lcd_drv->std_duration.duration_num = info->frame_rate;
+               lcd_drv->std_duration.duration_den = 1;
+       }
 
        /* update vinfo */
        pconf = lcd_drv->lcd_config;
@@ -222,8 +231,10 @@ static void lcd_vmode_vinfo_update(enum vmode_e mode)
        lcd_drv->lcd_info->aspect_ratio_den = pconf->lcd_basic.screen_height;
        lcd_drv->lcd_info->screen_real_width = pconf->lcd_basic.screen_width;
        lcd_drv->lcd_info->screen_real_height = pconf->lcd_basic.screen_height;
-       lcd_drv->lcd_info->sync_duration_num = info->frame_rate;
-       lcd_drv->lcd_info->sync_duration_den = 1;
+       lcd_drv->lcd_info->sync_duration_num =
+               lcd_drv->std_duration.duration_num;
+       lcd_drv->lcd_info->sync_duration_den =
+               lcd_drv->std_duration.duration_den;
        lcd_drv->lcd_info->video_clk = pconf->lcd_timing.lcd_clk;
        lcd_drv->lcd_info->htotal = pconf->lcd_basic.h_period;
        lcd_drv->lcd_info->vtotal = pconf->lcd_basic.v_period;
@@ -240,6 +251,7 @@ static enum vmode_e lcd_validate_vmode(char *mode)
 {
        int lcd_vmode, frame_rate;
        int ret;
+       struct aml_lcd_drv_s *lcd_drv = aml_lcd_get_driver();
 
        if (lcd_vout_serve_bypass) {
                LCDPR("vout_serve bypass\n");
@@ -255,8 +267,11 @@ static enum vmode_e lcd_validate_vmode(char *mode)
                return VMODE_MAX;
        }
        frame_rate = lcd_outputmode_to_lcd_frame_rate(mode);
+       if (lcd_drv->lcd_config->lcd_timing.fr_adjust_type == 0xff)
+               return lcd_vmode_info[lcd_vmode].mode;
        if (frame_rate == 0) {
                LCDERR("%s: frame_rate is not support\n", __func__);
+               return VMODE_MAX;
        } else {
                lcd_vmode_info[lcd_vmode].frame_rate = frame_rate;
                if (lcd_vmode < LCD_VMODE_MAX)
@@ -284,6 +299,10 @@ static int lcd_set_current_vmode(enum vmode_e mode)
                LCDPR("vout_serve bypass\n");
                return 0;
        }
+       if (lcd_drv->lcd_config->lcd_timing.fr_adjust_type == 0xff) {
+               LCDPR("fixed timing, exit vmode change\n");
+               return -1;
+       }
        mutex_lock(&lcd_drv->power_mutex);
 
        /* do not change mode value here, for bit mask is useful */
@@ -441,6 +460,10 @@ static int lcd_set_vframe_rate_hint(int duration)
                return 0;
        }
 
+       if (lcd_drv->lcd_config->lcd_timing.fr_adjust_type == 0xff) {
+               LCDPR("%s: fixed timing, exit\n", __func__);
+               return 0;
+       }
        info = lcd_drv->lcd_info;
 
        fr_policy = lcd_drv->fr_auto_policy;
@@ -500,6 +523,10 @@ static int lcd_set_vframe_rate_end_hint(void)
                return 0;
        }
 
+       if (lcd_drv->lcd_config->lcd_timing.fr_adjust_type == 0xff) {
+               LCDPR("%s: fixed timing, exit\n", __func__);
+               return 0;
+       }
        if (lcd_debug_print_flag)
                LCDPR("fr_auto_policy = %d\n", lcd_drv->fr_auto_policy);
        if (lcd_drv->fr_auto_policy) {
@@ -823,10 +850,15 @@ static int lcd_config_load_from_dts(struct lcd_config_s *pconf,
        ret = of_property_read_u32_array(child, "clk_attr", &para[0], 4);
        if (ret) {
                LCDERR("failed to get clk_attr\n");
+               pconf->lcd_timing.fr_adjust_type = 0;
+               pconf->lcd_timing.ss_level = 0;
+               pconf->lcd_timing.clk_auto = 1;
+               pconf->lcd_timing.lcd_clk = 60;
        } else {
                pconf->lcd_timing.fr_adjust_type = (unsigned char)(para[0]);
                pconf->lcd_timing.ss_level = (unsigned char)(para[1]);
                pconf->lcd_timing.clk_auto = (unsigned char)(para[2]);
+               pconf->lcd_timing.lcd_clk = (unsigned char)(para[3]);
        }
 
        switch (pconf->lcd_basic.lcd_type) {
@@ -999,10 +1031,10 @@ static int lcd_config_load_from_unifykey(struct lcd_config_s *pconf)
        LCDPR("unifykey version: 0x%04x\n", lcd_header.version);
        switch (lcd_header.version) {
        case 2:
-               len = 10 + 36 + 18 + 31 + 20 + 44 + 10;
+               len = LCD_UKEY_DATA_LEN_V2; /*10+36+18+31+20+44+10*/
                break;
        default:
-               len = 10 + 36 + 18 + 31 + 20;
+               len = LCD_UKEY_DATA_LEN_V1; /*10+36+18+31+20*/
                break;
        }
        if (lcd_debug_print_flag) {
@@ -1024,269 +1056,157 @@ static int lcd_config_load_from_unifykey(struct lcd_config_s *pconf)
        sprintf(pconf->lcd_propname, "%s", "unifykey");
 
        /* basic: 36byte */
-       p = para + LCD_UKEY_HEAD_SIZE;
-       str = (const char *)p;
+       p = para;
+       str = (const char *)(p + LCD_UKEY_HEAD_SIZE);
        strncpy(pconf->lcd_basic.model_name, str, MOD_LEN_MAX);
        /* ensure string ending */
        pconf->lcd_basic.model_name[MOD_LEN_MAX-1] = '\0';
-       p += LCD_UKEY_MODEL_NAME;
-       pconf->lcd_basic.lcd_type = *p;
-       p += LCD_UKEY_INTERFACE;
-       pconf->lcd_basic.lcd_bits = *p;
-       p += LCD_UKEY_LCD_BITS;
-       pconf->lcd_basic.screen_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_SCREEN_WIDTH;
-       pconf->lcd_basic.screen_height = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_SCREEN_HEIGHT;
+       pconf->lcd_basic.lcd_type = *(p + LCD_UKEY_INTERFACE);
+       pconf->lcd_basic.lcd_bits = *(p + LCD_UKEY_LCD_BITS);
+       pconf->lcd_basic.screen_width = (*(p + LCD_UKEY_SCREEN_WIDTH) |
+               ((*(p + LCD_UKEY_SCREEN_WIDTH + 1)) << 8));
+       pconf->lcd_basic.screen_height = (*(p + LCD_UKEY_SCREEN_HEIGHT) |
+               ((*(p + LCD_UKEY_SCREEN_HEIGHT + 1)) << 8));
 
        /* timing: 18byte */
-       pconf->lcd_basic.h_active = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_ACTIVE;
-       pconf->lcd_basic.v_active = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_ACTIVE;
-       pconf->lcd_basic.h_period = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD;
-       pconf->lcd_basic.v_period = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD;
-       pconf->lcd_timing.hsync_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_HS_WIDTH;
-       pconf->lcd_timing.hsync_bp = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_HS_BP;
-       pconf->lcd_timing.hsync_pol = *p;
-       p += LCD_UKEY_HS_POL;
-       pconf->lcd_timing.vsync_width = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_VS_WIDTH;
-       pconf->lcd_timing.vsync_bp = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_VS_BP;
-       pconf->lcd_timing.vsync_pol = *p;
-       p += LCD_UKEY_VS_POL;
+       pconf->lcd_basic.h_active = (*(p + LCD_UKEY_H_ACTIVE) |
+               ((*(p + LCD_UKEY_H_ACTIVE + 1)) << 8));
+       pconf->lcd_basic.v_active = (*(p + LCD_UKEY_V_ACTIVE)) |
+               ((*(p + LCD_UKEY_V_ACTIVE + 1)) << 8);
+       pconf->lcd_basic.h_period = (*(p + LCD_UKEY_H_PERIOD)) |
+               ((*(p + LCD_UKEY_H_PERIOD + 1)) << 8);
+       pconf->lcd_basic.v_period = (*(p + LCD_UKEY_V_PERIOD)) |
+               ((*(p + LCD_UKEY_V_PERIOD + 1)) << 8);
+       pconf->lcd_timing.hsync_width = (*(p + LCD_UKEY_HS_WIDTH) |
+               ((*(p + LCD_UKEY_HS_WIDTH + 1)) << 8));
+       pconf->lcd_timing.hsync_bp = (*(p + LCD_UKEY_HS_BP) |
+               ((*(p + LCD_UKEY_HS_BP + 1)) << 8));
+       pconf->lcd_timing.hsync_pol = *(p + LCD_UKEY_HS_POL);
+       pconf->lcd_timing.vsync_width = (*(p + LCD_UKEY_VS_WIDTH) |
+               ((*(p + LCD_UKEY_VS_WIDTH + 1)) << 8));
+       pconf->lcd_timing.vsync_bp = (*(p + LCD_UKEY_VS_BP) |
+               ((*(p + LCD_UKEY_VS_BP + 1)) << 8));
+       pconf->lcd_timing.vsync_pol = *(p + LCD_UKEY_VS_POL);
 
        /* customer: 31byte */
-       pconf->lcd_timing.fr_adjust_type = *p;
-       p += LCD_UKEY_FR_ADJ_TYPE;
-       pconf->lcd_timing.ss_level = *p;
-       p += LCD_UKEY_SS_LEVEL;
-       pconf->lcd_timing.clk_auto = *p;
-       p += LCD_UKEY_CLK_AUTO_GEN;
-       /* dummy pointer */
-       p += LCD_UKEY_PCLK;
-       pconf->lcd_basic.h_period_min = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD_MIN;
-       pconf->lcd_basic.h_period_max = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_H_PERIOD_MAX;
-       pconf->lcd_basic.v_period_min = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD_MIN;
-       pconf->lcd_basic.v_period_max = (*p | ((*(p + 1)) << 8));
-       p += LCD_UKEY_V_PERIOD_MAX;
-       pconf->lcd_basic.lcd_clk_min = (*p | ((*(p + 1)) << 8) |
-               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-       p += LCD_UKEY_PCLK_MIN;
-       pconf->lcd_basic.lcd_clk_max = (*p | ((*(p + 1)) << 8) |
-               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-       p += LCD_UKEY_PCLK_MAX;
-       /* dummy pointer */
-       p += LCD_UKEY_CUST_VAL_8;
-       p += LCD_UKEY_CUST_VAL_9;
+       pconf->lcd_timing.fr_adjust_type = *(p + LCD_UKEY_FR_ADJ_TYPE);
+       pconf->lcd_timing.ss_level = *(p + LCD_UKEY_SS_LEVEL);
+       pconf->lcd_timing.clk_auto = *(p + LCD_UKEY_CLK_AUTO_GEN);
+       pconf->lcd_timing.lcd_clk = (*(p + LCD_UKEY_PCLK) |
+               ((*(p + LCD_UKEY_PCLK + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK + 3)) << 24));
+       pconf->lcd_basic.h_period_min = (*(p + LCD_UKEY_H_PERIOD_MIN) |
+               ((*(p + LCD_UKEY_H_PERIOD_MIN + 1)) << 8));
+       pconf->lcd_basic.h_period_max = (*(p + LCD_UKEY_H_PERIOD_MAX) |
+               ((*(p + LCD_UKEY_H_PERIOD_MAX + 1)) << 8));
+       pconf->lcd_basic.v_period_min = (*(p + LCD_UKEY_V_PERIOD_MIN) |
+               ((*(p + LCD_UKEY_V_PERIOD_MIN + 1)) << 8));
+       pconf->lcd_basic.v_period_max = (*(p + LCD_UKEY_V_PERIOD_MAX) |
+               ((*(p + LCD_UKEY_V_PERIOD_MAX + 1)) << 8));
+       pconf->lcd_basic.lcd_clk_min = (*(p + LCD_UKEY_PCLK_MIN) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK_MIN + 3)) << 24));
+       pconf->lcd_basic.lcd_clk_max = (*(p + LCD_UKEY_PCLK_MAX) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 1)) << 8) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 2)) << 16) |
+               ((*(p + LCD_UKEY_PCLK_MAX + 3)) << 24));
 
        /* interface: 20byte */
        if (pconf->lcd_basic.lcd_type == LCD_VBYONE) {
                if (lcd_header.version == 2) {
-                       vx1_conf->lane_count = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
-                       vx1_conf->region_num = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
-                       vx1_conf->byte_mode = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
-                       vx1_conf->color_fmt = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
-                       vx1_conf->intr_en = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
-                       vx1_conf->vsync_intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_6;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                       vx1_conf->lane_count = (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
+                       vx1_conf->region_num = (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
+                       vx1_conf->byte_mode = (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
+                       vx1_conf->color_fmt = (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
+                       vx1_conf->intr_en = (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
+                       vx1_conf->vsync_intr_en = (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
                } else {
-                       vx1_conf->lane_count = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
-                       vx1_conf->region_num = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
-                       vx1_conf->byte_mode = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
-                       vx1_conf->color_fmt = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
-                       vx1_conf->phy_vswing = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
-                       vx1_conf->phy_preem = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
-                       vx1_conf->intr_en = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_6;
-                       vx1_conf->vsync_intr_en =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                       vx1_conf->lane_count = (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
+                       vx1_conf->region_num = (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
+                       vx1_conf->byte_mode = (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
+                       vx1_conf->color_fmt = (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
+                       vx1_conf->phy_vswing = (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
+                       vx1_conf->phy_preem = (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
+                       vx1_conf->intr_en = (*(p + LCD_UKEY_IF_ATTR_6) |
+                               ((*(p + LCD_UKEY_IF_ATTR_6 + 1)) << 8)) & 0xff;
+                       vx1_conf->vsync_intr_en = (*(p + LCD_UKEY_IF_ATTR_7) |
+                               ((*(p + LCD_UKEY_IF_ATTR_7 + 1)) << 8)) & 0xff;
                }
        } else if (pconf->lcd_basic.lcd_type == LCD_LVDS) {
                if (lcd_header.version == 2) {
-                       lvdsconf->lvds_repack = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
-                       lvdsconf->dual_port = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
-                       lvdsconf->pn_swap = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
-                       lvdsconf->port_swap = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
-                       lvdsconf->lane_reverse =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_5;
-                       p += LCD_UKEY_IF_ATTR_6;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
+                       lvdsconf->lvds_repack = (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
+                       lvdsconf->dual_port = (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
+                       lvdsconf->pn_swap = (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
+                       lvdsconf->port_swap = (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
+                       lvdsconf->lane_reverse = (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
                } else {
-                       lvdsconf->lvds_repack = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_0;
-                       lvdsconf->dual_port = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_1;
-                       lvdsconf->pn_swap = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_2;
-                       lvdsconf->port_swap = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_3;
-                       lvdsconf->phy_vswing = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_4;
-                       lvdsconf->phy_preem = (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_5;
-                       lvdsconf->phy_clk_vswing =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_6;
-                       lvdsconf->phy_clk_preem =
-                                       (*p | ((*(p + 1)) << 8)) & 0xff;
-                       p += LCD_UKEY_IF_ATTR_7;
-                       /* dummy pointer */
-                       p += LCD_UKEY_IF_ATTR_8;
-                       p += LCD_UKEY_IF_ATTR_9;
-
+                       lvdsconf->lvds_repack = (*(p + LCD_UKEY_IF_ATTR_0) |
+                               ((*(p + LCD_UKEY_IF_ATTR_0 + 1)) << 8)) & 0xff;
+                       lvdsconf->dual_port = (*(p + LCD_UKEY_IF_ATTR_1) |
+                               ((*(p + LCD_UKEY_IF_ATTR_1 + 1)) << 8)) & 0xff;
+                       lvdsconf->pn_swap = (*(p + LCD_UKEY_IF_ATTR_2) |
+                               ((*(p + LCD_UKEY_IF_ATTR_2 + 1)) << 8)) & 0xff;
+                       lvdsconf->port_swap = (*(p + LCD_UKEY_IF_ATTR_3) |
+                               ((*(p + LCD_UKEY_IF_ATTR_3 + 1)) << 8)) & 0xff;
+                       lvdsconf->phy_vswing = (*(p + LCD_UKEY_IF_ATTR_4) |
+                               ((*(p + LCD_UKEY_IF_ATTR_4 + 1)) << 8)) & 0xff;
+                       lvdsconf->phy_preem = (*(p + LCD_UKEY_IF_ATTR_5) |
+                               ((*(p + LCD_UKEY_IF_ATTR_5 + 1)) << 8)) & 0xff;
+                       lvdsconf->phy_clk_vswing = (*(p + LCD_UKEY_IF_ATTR_6) |
+                               ((*(p + LCD_UKEY_IF_ATTR_6 + 1)) << 8)) & 0xff;
+                       lvdsconf->phy_clk_preem = (*(p + LCD_UKEY_IF_ATTR_7) |
+                               ((*(p + LCD_UKEY_IF_ATTR_7 + 1)) << 8)) & 0xff;
                        lvdsconf->lane_reverse = 0;
                }
-       } else {
+       } else
                LCDERR("unsupport lcd_type: %d\n", pconf->lcd_basic.lcd_type);
-               p += LCD_UKEY_IF_ATTR_0;
-               p += LCD_UKEY_IF_ATTR_1;
-               p += LCD_UKEY_IF_ATTR_2;
-               p += LCD_UKEY_IF_ATTR_3;
-               p += LCD_UKEY_IF_ATTR_4;
-               p += LCD_UKEY_IF_ATTR_5;
-               p += LCD_UKEY_IF_ATTR_6;
-               p += LCD_UKEY_IF_ATTR_7;
-               p += LCD_UKEY_IF_ATTR_8;
-               p += LCD_UKEY_IF_ATTR_9;
-       }
 
        if (lcd_header.version == 2) {
                /* ctrl: 44byte */ /* v2 */
                if (pconf->lcd_basic.lcd_type == LCD_VBYONE) {
-                       vx1_conf->ctrl_flag = (*p | ((*(p + 1)) << 8) |
-                               ((*(p + 2)) << 16) | ((*(p + 3)) << 24));
-                       p += LCD_UKEY_CTRL_FLAG;
+                       vx1_conf->ctrl_flag = (*(p + LCD_UKEY_CTRL_FLAG) |
+                               ((*(p + LCD_UKEY_CTRL_FLAG + 1)) << 8) |
+                               ((*(p + LCD_UKEY_CTRL_FLAG + 2)) << 16) |
+                               ((*(p + LCD_UKEY_CTRL_FLAG + 3)) << 24));
                        vx1_conf->power_on_reset_delay =
-                               (*p | ((*(p + 1)) << 8));
-                       p += LCD_UKEY_CTRL_ATTR_0;
-                       vx1_conf->hpd_data_delay = (*p | ((*(p + 1)) << 8));
-                       p += LCD_UKEY_CTRL_ATTR_1;
-                       vx1_conf->cdr_training_hold = (*p | ((*(p + 1)) << 8));
-                       p += LCD_UKEY_CTRL_ATTR_2;
-                       /* dummy pointer */
-                       p += LCD_UKEY_CTRL_ATTR_3;
-                       p += LCD_UKEY_CTRL_ATTR_4;
-                       p += LCD_UKEY_CTRL_ATTR_5;
-                       p += LCD_UKEY_CTRL_ATTR_6;
-                       p += LCD_UKEY_CTRL_ATTR_7;
-                       p += LCD_UKEY_CTRL_ATTR_8;
-                       p += LCD_UKEY_CTRL_ATTR_9;
-                       p += LCD_UKEY_CTRL_ATTR_10;
-                       p += LCD_UKEY_CTRL_ATTR_11;
-                       p += LCD_UKEY_CTRL_ATTR_12;
-                       p += LCD_UKEY_CTRL_ATTR_13;
-                       /* dummy pointer */
-                       p += LCD_UKEY_CTRL_ATTR_14;
-                       p += LCD_UKEY_CTRL_ATTR_15;
-                       p += LCD_UKEY_CTRL_ATTR_16;
-                       p += LCD_UKEY_CTRL_ATTR_17;
-                       p += LCD_UKEY_CTRL_ATTR_18;
-                       p += LCD_UKEY_CTRL_ATTR_19;
-               } else {
-                       p += LCD_UKEY_CTRL_FLAG;
-                       p += LCD_UKEY_CTRL_ATTR_0;
-                       p += LCD_UKEY_CTRL_ATTR_1;
-                       p += LCD_UKEY_CTRL_ATTR_2;
-                       p += LCD_UKEY_CTRL_ATTR_3;
-                       p += LCD_UKEY_CTRL_ATTR_4;
-                       p += LCD_UKEY_CTRL_ATTR_5;
-                       p += LCD_UKEY_CTRL_ATTR_6;
-                       p += LCD_UKEY_CTRL_ATTR_7;
-                       p += LCD_UKEY_CTRL_ATTR_8;
-                       p += LCD_UKEY_CTRL_ATTR_9;
-                       p += LCD_UKEY_CTRL_ATTR_10;
-                       p += LCD_UKEY_CTRL_ATTR_11;
-                       p += LCD_UKEY_CTRL_ATTR_12;
-                       p += LCD_UKEY_CTRL_ATTR_13;
-                       p += LCD_UKEY_CTRL_ATTR_14;
-                       p += LCD_UKEY_CTRL_ATTR_15;
-                       p += LCD_UKEY_CTRL_ATTR_16;
-                       p += LCD_UKEY_CTRL_ATTR_17;
-                       p += LCD_UKEY_CTRL_ATTR_18;
-                       p += LCD_UKEY_CTRL_ATTR_19;
+                               (*(p + LCD_UKEY_CTRL_ATTR_0) |
+                               ((*(p + LCD_UKEY_CTRL_ATTR_0 + 1)) << 8));
+                       vx1_conf->hpd_data_delay =
+                               (*(p + LCD_UKEY_CTRL_ATTR_1) |
+                               ((*(p  + LCD_UKEY_CTRL_ATTR_1 + 1)) << 8));
+                       vx1_conf->cdr_training_hold =
+                               (*(p + LCD_UKEY_CTRL_ATTR_2) |
+                               ((*(p + LCD_UKEY_CTRL_ATTR_2 + 1)) << 8));
                }
 
                /* phy: 10byte */ /* v2 */
                if (pconf->lcd_basic.lcd_type == LCD_VBYONE) {
-                       vx1_conf->phy_vswing = *p;
-                       p += LCD_UKEY_PHY_ATTR_0;
-                       vx1_conf->phy_preem = *p;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       /* dummy pointer */
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
+                       vx1_conf->phy_vswing = *(p + LCD_UKEY_PHY_ATTR_0);
+                       vx1_conf->phy_preem = *(p + LCD_UKEY_PHY_ATTR_1);
                } else if (pconf->lcd_basic.lcd_type == LCD_LVDS) {
-                       lvdsconf->phy_vswing = *p;
-                       p += LCD_UKEY_PHY_ATTR_0;
-                       lvdsconf->phy_preem = *p;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       lvdsconf->phy_clk_vswing = *p;
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       lvdsconf->phy_clk_preem = *p;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       /* dummy pointer */
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
-               } else {
-                       p += LCD_UKEY_PHY_ATTR_0;
-                       p += LCD_UKEY_PHY_ATTR_1;
-                       p += LCD_UKEY_PHY_ATTR_2;
-                       p += LCD_UKEY_PHY_ATTR_3;
-                       p += LCD_UKEY_PHY_ATTR_4;
-                       p += LCD_UKEY_PHY_ATTR_5;
-                       p += LCD_UKEY_PHY_ATTR_6;
-                       p += LCD_UKEY_PHY_ATTR_7;
-                       p += LCD_UKEY_PHY_ATTR_8;
-                       p += LCD_UKEY_PHY_ATTR_9;
+                       lvdsconf->phy_vswing = *(p + LCD_UKEY_PHY_ATTR_0);
+                       lvdsconf->phy_preem = *(p + LCD_UKEY_PHY_ATTR_1);
+                       lvdsconf->phy_clk_vswing = *(p + LCD_UKEY_PHY_ATTR_2);
+                       lvdsconf->phy_clk_preem = *(p + LCD_UKEY_PHY_ATTR_3);
                }
        }
 
@@ -1322,16 +1242,23 @@ static void lcd_config_init(struct lcd_config_s *pconf)
        unsigned int ss_level;
        unsigned int clk;
 
-       clk = pconf->lcd_basic.h_period * pconf->lcd_basic.v_period * 60;
-       pconf->lcd_timing.lcd_clk = clk;
+       if (pconf->lcd_timing.lcd_clk == 0) /* default 0 for 60hz */
+               pconf->lcd_timing.lcd_clk = 60;
+       else
+               LCDPR("custome clk: %d\n", pconf->lcd_timing.lcd_clk);
+       clk = pconf->lcd_timing.lcd_clk;
+       if (clk < 200) { /* regard as frame_rate */
+               pconf->lcd_timing.lcd_clk = clk * pconf->lcd_basic.h_period *
+                       pconf->lcd_basic.v_period;
+       } else /* regard as pixel clock */
+               pconf->lcd_timing.lcd_clk = clk;
+
        pconf->lcd_timing.lcd_clk_dft = pconf->lcd_timing.lcd_clk;
        pconf->lcd_timing.h_period_dft = pconf->lcd_basic.h_period;
        pconf->lcd_timing.v_period_dft = pconf->lcd_basic.v_period;
        /* before vmode_init to avoid period changing */
        lcd_timing_init_config(pconf);
-
        lcd_vmode_init(pconf);
-
        lcd_tv_config_update(pconf);
        lcd_clk_generate_parameter(pconf);
        ss_level = pconf->lcd_timing.ss_level;
@@ -1368,7 +1295,6 @@ static int lcd_get_config(struct lcd_config_s *pconf, struct device *dev)
        }
        lcd_init_load_from_dts(pconf, dev);
        lcd_config_print(pconf);
-
        lcd_config_init(pconf);
 
        return 0;
index 91b2a45..f2afba6 100644 (file)
@@ -257,12 +257,12 @@ static void lcd_power_ctrl(int status)
                        if (ext_drv) {
                                if (status) {
                                        if (ext_drv->power_on)
-                                               ext_drv->power_on();
+                                               ext_drv->power_on(ext_drv);
                                        else
                                                LCDERR("no ext power on\n");
                                } else {
                                        if (ext_drv->power_off)
-                                               ext_drv->power_off();
+                                               ext_drv->power_off(ext_drv);
                                        else
                                                LCDERR("no ext power off\n");
                                }
index 66f8cb2..deda0ee 100644 (file)
@@ -60,6 +60,10 @@ struct lcd_extern_config_s {
        unsigned char i2c_addr;
        unsigned char i2c_addr2;
        unsigned char i2c_bus;
+       unsigned char i2c_sck_gpio;
+       unsigned char i2c_sck_gpio_off;
+       unsigned char i2c_sda_gpio;
+       unsigned char i2c_sda_gpio_off;
        unsigned char spi_gpio_cs;
        unsigned char spi_gpio_clk;
        unsigned char spi_gpio_data;
@@ -70,6 +74,7 @@ struct lcd_extern_config_s {
        unsigned char table_init_loaded; /* internal use */
        unsigned char *table_init_on;
        unsigned char *table_init_off;
+       unsigned int table_init_on_cnt;
 };
 
 /* global API */
@@ -78,8 +83,10 @@ struct aml_lcd_extern_driver_s {
        struct lcd_extern_config_s config;
        int (*reg_read)(unsigned char reg, unsigned char *buf);
        int (*reg_write)(unsigned char reg, unsigned char value);
-       int (*power_on)(void);
-       int (*power_off)(void);
+       int (*power_on)(struct aml_lcd_extern_driver_s *ext_drv);
+       int (*power_off)(struct aml_lcd_extern_driver_s *ext_drv);
+       struct pinctrl *pin;
+       unsigned int pinmux_flag;
 };
 
 extern struct aml_lcd_extern_driver_s *aml_lcd_extern_get_driver(int index);
index 9dccb3e..f2caae4 100644 (file)
@@ -62,84 +62,86 @@ struct aml_lcd_unifykey_header_s {
 /* header (10Byte) */
 /* LCD_UKEY_HEAD_SIZE */
 /* basic (36Byte) */
-#define LCD_UKEY_MODEL_NAME        30
-#define LCD_UKEY_INTERFACE         1
-#define LCD_UKEY_LCD_BITS          1
-#define LCD_UKEY_SCREEN_WIDTH      2
-#define LCD_UKEY_SCREEN_HEIGHT     2
+#define LCD_UKEY_MODEL_NAME      (LCD_UKEY_HEAD_SIZE + 0)
+#define LCD_UKEY_INTERFACE       (LCD_UKEY_MODEL_NAME + 30)
+#define LCD_UKEY_LCD_BITS        (LCD_UKEY_MODEL_NAME + 31)
+#define LCD_UKEY_SCREEN_WIDTH    (LCD_UKEY_MODEL_NAME + 32)
+#define LCD_UKEY_SCREEN_HEIGHT   (LCD_UKEY_MODEL_NAME + 34)
 /* timing (18Byte) */
-#define LCD_UKEY_H_ACTIVE          2
-#define LCD_UKEY_V_ACTIVE          2
-#define LCD_UKEY_H_PERIOD          2
-#define LCD_UKEY_V_PERIOD          2
-#define LCD_UKEY_HS_WIDTH          2
-#define LCD_UKEY_HS_BP             2
-#define LCD_UKEY_HS_POL            1
-#define LCD_UKEY_VS_WIDTH          2
-#define LCD_UKEY_VS_BP             2
-#define LCD_UKEY_VS_POL            1
+#define LCD_UKEY_H_ACTIVE        (LCD_UKEY_MODEL_NAME + 36)/* +36 byte */
+#define LCD_UKEY_V_ACTIVE        (LCD_UKEY_MODEL_NAME + 38)
+#define LCD_UKEY_H_PERIOD        (LCD_UKEY_MODEL_NAME + 40)
+#define LCD_UKEY_V_PERIOD        (LCD_UKEY_MODEL_NAME + 42)
+#define LCD_UKEY_HS_WIDTH        (LCD_UKEY_MODEL_NAME + 44)
+#define LCD_UKEY_HS_BP           (LCD_UKEY_MODEL_NAME + 46)
+#define LCD_UKEY_HS_POL          (LCD_UKEY_MODEL_NAME + 48)
+#define LCD_UKEY_VS_WIDTH        (LCD_UKEY_MODEL_NAME + 49)
+#define LCD_UKEY_VS_BP           (LCD_UKEY_MODEL_NAME + 51)
+#define LCD_UKEY_VS_POL          (LCD_UKEY_MODEL_NAME + 53)
 /* customer (31Byte) */
-#define LCD_UKEY_FR_ADJ_TYPE       1
-#define LCD_UKEY_SS_LEVEL          1
-#define LCD_UKEY_CLK_AUTO_GEN      1
-#define LCD_UKEY_PCLK              4
-#define LCD_UKEY_H_PERIOD_MIN      2
-#define LCD_UKEY_H_PERIOD_MAX      2
-#define LCD_UKEY_V_PERIOD_MIN      2
-#define LCD_UKEY_V_PERIOD_MAX      2
-#define LCD_UKEY_PCLK_MIN          4
-#define LCD_UKEY_PCLK_MAX          4
-#define LCD_UKEY_CUST_VAL_8        4
-#define LCD_UKEY_CUST_VAL_9        4
+#define LCD_UKEY_FR_ADJ_TYPE     (LCD_UKEY_MODEL_NAME + 54)/* +36+18 byte */
+#define LCD_UKEY_SS_LEVEL        (LCD_UKEY_MODEL_NAME + 55)
+#define LCD_UKEY_CLK_AUTO_GEN    (LCD_UKEY_MODEL_NAME + 56)
+#define LCD_UKEY_PCLK            (LCD_UKEY_MODEL_NAME + 57)
+#define LCD_UKEY_H_PERIOD_MIN    (LCD_UKEY_MODEL_NAME + 61)
+#define LCD_UKEY_H_PERIOD_MAX    (LCD_UKEY_MODEL_NAME + 63)
+#define LCD_UKEY_V_PERIOD_MIN    (LCD_UKEY_MODEL_NAME + 65)
+#define LCD_UKEY_V_PERIOD_MAX    (LCD_UKEY_MODEL_NAME + 67)
+#define LCD_UKEY_PCLK_MIN        (LCD_UKEY_MODEL_NAME + 69)
+#define LCD_UKEY_PCLK_MAX        (LCD_UKEY_MODEL_NAME + 73)
+#define LCD_UKEY_CUST_VAL_8      (LCD_UKEY_MODEL_NAME + 77)
+#define LCD_UKEY_CUST_VAL_9      (LCD_UKEY_MODEL_NAME + 81)
 /* interface (20Byte) */
-#define LCD_UKEY_IF_ATTR_0         2
-#define LCD_UKEY_IF_ATTR_1         2
-#define LCD_UKEY_IF_ATTR_2         2
-#define LCD_UKEY_IF_ATTR_3         2
-#define LCD_UKEY_IF_ATTR_4         2
-#define LCD_UKEY_IF_ATTR_5         2
-#define LCD_UKEY_IF_ATTR_6         2
-#define LCD_UKEY_IF_ATTR_7         2
-#define LCD_UKEY_IF_ATTR_8         2
-#define LCD_UKEY_IF_ATTR_9         2
+#define LCD_UKEY_IF_ATTR_0       (LCD_UKEY_MODEL_NAME + 85)/* +36+18+31 byte */
+#define LCD_UKEY_IF_ATTR_1       (LCD_UKEY_MODEL_NAME + 87)
+#define LCD_UKEY_IF_ATTR_2       (LCD_UKEY_MODEL_NAME + 89)
+#define LCD_UKEY_IF_ATTR_3       (LCD_UKEY_MODEL_NAME + 91)
+#define LCD_UKEY_IF_ATTR_4       (LCD_UKEY_MODEL_NAME + 93)
+#define LCD_UKEY_IF_ATTR_5       (LCD_UKEY_MODEL_NAME + 95)
+#define LCD_UKEY_IF_ATTR_6       (LCD_UKEY_MODEL_NAME + 97)
+#define LCD_UKEY_IF_ATTR_7       (LCD_UKEY_MODEL_NAME + 99)
+#define LCD_UKEY_IF_ATTR_8       (LCD_UKEY_MODEL_NAME + 101)
+#define LCD_UKEY_IF_ATTR_9       (LCD_UKEY_MODEL_NAME + 103)
 /* ctrl (44Byte) */ /* V2 */
-#define LCD_UKEY_CTRL_FLAG         4
-#define LCD_UKEY_CTRL_ATTR_0       2
-#define LCD_UKEY_CTRL_ATTR_1       2
-#define LCD_UKEY_CTRL_ATTR_2       2
-#define LCD_UKEY_CTRL_ATTR_3       2
-#define LCD_UKEY_CTRL_ATTR_4       2
-#define LCD_UKEY_CTRL_ATTR_5       2
-#define LCD_UKEY_CTRL_ATTR_6       2
-#define LCD_UKEY_CTRL_ATTR_7       2
-#define LCD_UKEY_CTRL_ATTR_8       2
-#define LCD_UKEY_CTRL_ATTR_9       2
-#define LCD_UKEY_CTRL_ATTR_10      2
-#define LCD_UKEY_CTRL_ATTR_11      2
-#define LCD_UKEY_CTRL_ATTR_12      2
-#define LCD_UKEY_CTRL_ATTR_13      2
-#define LCD_UKEY_CTRL_ATTR_14      2
-#define LCD_UKEY_CTRL_ATTR_15      2
-#define LCD_UKEY_CTRL_ATTR_16      2
-#define LCD_UKEY_CTRL_ATTR_17      2
-#define LCD_UKEY_CTRL_ATTR_18      2
-#define LCD_UKEY_CTRL_ATTR_19      2
+#define LCD_UKEY_CTRL_FLAG      (LCD_UKEY_MODEL_NAME + 105)
+#define LCD_UKEY_CTRL_ATTR_0    (LCD_UKEY_MODEL_NAME + 109)
+#define LCD_UKEY_CTRL_ATTR_1    (LCD_UKEY_MODEL_NAME + 111)
+#define LCD_UKEY_CTRL_ATTR_2    (LCD_UKEY_MODEL_NAME + 113)
+#define LCD_UKEY_CTRL_ATTR_3    (LCD_UKEY_MODEL_NAME + 115)
+#define LCD_UKEY_CTRL_ATTR_4    (LCD_UKEY_MODEL_NAME + 117)
+#define LCD_UKEY_CTRL_ATTR_5    (LCD_UKEY_MODEL_NAME + 119)
+#define LCD_UKEY_CTRL_ATTR_6    (LCD_UKEY_MODEL_NAME + 121)
+#define LCD_UKEY_CTRL_ATTR_7    (LCD_UKEY_MODEL_NAME + 123)
+#define LCD_UKEY_CTRL_ATTR_8    (LCD_UKEY_MODEL_NAME + 125)
+#define LCD_UKEY_CTRL_ATTR_9    (LCD_UKEY_MODEL_NAME + 127)
+#define LCD_UKEY_CTRL_ATTR_10   (LCD_UKEY_MODEL_NAME + 129)
+#define LCD_UKEY_CTRL_ATTR_11   (LCD_UKEY_MODEL_NAME + 131)
+#define LCD_UKEY_CTRL_ATTR_12   (LCD_UKEY_MODEL_NAME + 133)
+#define LCD_UKEY_CTRL_ATTR_13   (LCD_UKEY_MODEL_NAME + 135)
+#define LCD_UKEY_CTRL_ATTR_14   (LCD_UKEY_MODEL_NAME + 137)
+#define LCD_UKEY_CTRL_ATTR_15   (LCD_UKEY_MODEL_NAME + 139)
+#define LCD_UKEY_CTRL_ATTR_16   (LCD_UKEY_MODEL_NAME + 141)
+#define LCD_UKEY_CTRL_ATTR_17   (LCD_UKEY_MODEL_NAME + 143)
+#define LCD_UKEY_CTRL_ATTR_18   (LCD_UKEY_MODEL_NAME + 145)
+#define LCD_UKEY_CTRL_ATTR_19   (LCD_UKEY_MODEL_NAME + 147)
 /* phy (10Byte) */ /* V2 */
-#define LCD_UKEY_PHY_ATTR_0        1
-#define LCD_UKEY_PHY_ATTR_1        1
-#define LCD_UKEY_PHY_ATTR_2        1
-#define LCD_UKEY_PHY_ATTR_3        1
-#define LCD_UKEY_PHY_ATTR_4        1
-#define LCD_UKEY_PHY_ATTR_5        1
-#define LCD_UKEY_PHY_ATTR_6        1
-#define LCD_UKEY_PHY_ATTR_7        1
-#define LCD_UKEY_PHY_ATTR_8        1
-#define LCD_UKEY_PHY_ATTR_9        1
+#define LCD_UKEY_PHY_ATTR_0     (LCD_UKEY_MODEL_NAME + 149)
+#define LCD_UKEY_PHY_ATTR_1     (LCD_UKEY_MODEL_NAME + 150)
+#define LCD_UKEY_PHY_ATTR_2     (LCD_UKEY_MODEL_NAME + 151)
+#define LCD_UKEY_PHY_ATTR_3     (LCD_UKEY_MODEL_NAME + 152)
+#define LCD_UKEY_PHY_ATTR_4     (LCD_UKEY_MODEL_NAME + 153)
+#define LCD_UKEY_PHY_ATTR_5     (LCD_UKEY_MODEL_NAME + 154)
+#define LCD_UKEY_PHY_ATTR_6     (LCD_UKEY_MODEL_NAME + 155)
+#define LCD_UKEY_PHY_ATTR_7     (LCD_UKEY_MODEL_NAME + 156)
+#define LCD_UKEY_PHY_ATTR_8     (LCD_UKEY_MODEL_NAME + 157)
+#define LCD_UKEY_PHY_ATTR_9     (LCD_UKEY_MODEL_NAME + 158)
+#define LCD_UKEY_DATA_LEN_V1        (LCD_UKEY_MODEL_NAME + 105)
+#define LCD_UKEY_DATA_LEN_V2        (LCD_UKEY_MODEL_NAME + 159)
 /* power (5Byte * n) */
-#define LCD_UKEY_PWR_TYPE          1
-#define LCD_UKEY_PWR_INDEX         1
-#define LCD_UKEY_PWR_VAL           1
-#define LCD_UKEY_PWR_DELAY         2
+#define LCD_UKEY_PWR_TYPE          (0)
+#define LCD_UKEY_PWR_INDEX         (1)
+#define LCD_UKEY_PWR_VAL           (2)
+#define LCD_UKEY_PWR_DELAY         (3)
 
 /* ********************************
  * lcd extern
@@ -150,25 +152,26 @@ struct aml_lcd_unifykey_header_s {
 /* header (10Byte) */
 /* LCD_UKEY_HEAD_SIZE */
 /* basic (33Byte) */
-#define LCD_UKEY_EXT_NAME           30
-#define LCD_UKEY_EXT_INDEX          1
-#define LCD_UKEY_EXT_TYPE           1
-#define LCD_UKEY_EXT_STATUS         1
+#define LCD_UKEY_EXT_NAME           (LCD_UKEY_HEAD_SIZE + 0)
+#define LCD_UKEY_EXT_INDEX          (LCD_UKEY_EXT_NAME + 30)
+#define LCD_UKEY_EXT_TYPE           (LCD_UKEY_EXT_NAME + 31)
+#define LCD_UKEY_EXT_STATUS         (LCD_UKEY_EXT_NAME + 32)
 /* type (10Byte) */
-#define LCD_UKEY_EXT_TYPE_VAL_0     1
-#define LCD_UKEY_EXT_TYPE_VAL_1     1
-#define LCD_UKEY_EXT_TYPE_VAL_2     1
-#define LCD_UKEY_EXT_TYPE_VAL_3     1
-#define LCD_UKEY_EXT_TYPE_VAL_4     1
-#define LCD_UKEY_EXT_TYPE_VAL_5     1
-#define LCD_UKEY_EXT_TYPE_VAL_6     1
-#define LCD_UKEY_EXT_TYPE_VAL_7     1
-#define LCD_UKEY_EXT_TYPE_VAL_8     1
-#define LCD_UKEY_EXT_TYPE_VAL_9     1
+#define LCD_UKEY_EXT_TYPE_VAL_0     (LCD_UKEY_EXT_NAME + 33)/* +33 byte */
+#define LCD_UKEY_EXT_TYPE_VAL_1     (LCD_UKEY_EXT_NAME + 34)
+#define LCD_UKEY_EXT_TYPE_VAL_2     (LCD_UKEY_EXT_NAME + 35)
+#define LCD_UKEY_EXT_TYPE_VAL_3     (LCD_UKEY_EXT_NAME + 36)
+#define LCD_UKEY_EXT_TYPE_VAL_4     (LCD_UKEY_EXT_NAME + 37)
+#define LCD_UKEY_EXT_TYPE_VAL_5     (LCD_UKEY_EXT_NAME + 38)
+#define LCD_UKEY_EXT_TYPE_VAL_6     (LCD_UKEY_EXT_NAME + 39)
+#define LCD_UKEY_EXT_TYPE_VAL_7     (LCD_UKEY_EXT_NAME + 40)
+#define LCD_UKEY_EXT_TYPE_VAL_8     (LCD_UKEY_EXT_NAME + 41)
+#define LCD_UKEY_EXT_TYPE_VAL_9     (LCD_UKEY_EXT_NAME + 42)
 /* init (cmd_size) */
-#define LCD_UKEY_EXT_INIT_TYPE       1
+#define LCD_UKEY_EXT_INIT           (LCD_UKEY_EXT_NAME + 43)/* +33+10 byte */
+/*#define LCD_UKEY_EXT_INIT_TYPE      (0)*/
 /*#define LCD_UKEY_EXT_INIT_VAL        1   //not defined */
-#define LCD_UKEY_EXT_INIT_DELAY      1
+/*#define LCD_UKEY_EXT_INIT_DELAY     (n)*/
 
 /* ********************************
  * backlight
@@ -181,48 +184,48 @@ struct aml_lcd_unifykey_header_s {
 /* header (10Byte) */
 /* LCD_UKEY_HEAD_SIZE */
 /* basic (30Byte) */
-#define LCD_UKEY_BL_NAME            30
+#define LCD_UKEY_BL_NAME            (LCD_UKEY_HEAD_SIZE + 0)
 /* level (12Byte) */
-#define LCD_UKEY_BL_LEVEL_UBOOT     2
-#define LCD_UKEY_BL_LEVEL_KERNEL    2
-#define LCD_UKEY_BL_LEVEL_MAX       2
-#define LCD_UKEY_BL_LEVEL_MIN       2
-#define LCD_UKEY_BL_LEVEL_MID       2
-#define LCD_UKEY_BL_LEVEL_MID_MAP   2
+#define LCD_UKEY_BL_LEVEL_UBOOT     (LCD_UKEY_BL_NAME + 30)/* +30 byte */
+#define LCD_UKEY_BL_LEVEL_KERNEL    (LCD_UKEY_BL_NAME + 32)
+#define LCD_UKEY_BL_LEVEL_MAX       (LCD_UKEY_BL_NAME + 34)
+#define LCD_UKEY_BL_LEVEL_MIN       (LCD_UKEY_BL_NAME + 36)
+#define LCD_UKEY_BL_LEVEL_MID       (LCD_UKEY_BL_NAME + 38)
+#define LCD_UKEY_BL_LEVEL_MID_MAP   (LCD_UKEY_BL_NAME + 40)
 /* method (8Byte) */
-#define LCD_UKEY_BL_METHOD          1
-#define LCD_UKEY_BL_EN_GPIO         1
-#define LCD_UKEY_BL_EN_GPIO_ON      1
-#define LCD_UKEY_BL_EN_GPIO_OFF     1
-#define LCD_UKEY_BL_ON_DELAY        2
-#define LCD_UKEY_BL_OFF_DELAY       2
+#define LCD_UKEY_BL_METHOD          (LCD_UKEY_BL_NAME + 42)/* +30+12 byte */
+#define LCD_UKEY_BL_EN_GPIO         (LCD_UKEY_BL_NAME + 43)
+#define LCD_UKEY_BL_EN_GPIO_ON      (LCD_UKEY_BL_NAME + 44)
+#define LCD_UKEY_BL_EN_GPIO_OFF     (LCD_UKEY_BL_NAME + 45)
+#define LCD_UKEY_BL_ON_DELAY        (LCD_UKEY_BL_NAME + 46)
+#define LCD_UKEY_BL_OFF_DELAY       (LCD_UKEY_BL_NAME + 48)
 /* pwm (32Byte) */
-#define LCD_UKEY_BL_PWM_ON_DELAY    2
-#define LCD_UKEY_BL_PWM_OFF_DELAY   2
-#define LCD_UKEY_BL_PWM_METHOD      1
-#define LCD_UKEY_BL_PWM_PORT        1
-#define LCD_UKEY_BL_PWM_FREQ        4
-#define LCD_UKEY_BL_PWM_DUTY_MAX    1
-#define LCD_UKEY_BL_PWM_DUTY_MIN    1
-#define LCD_UKEY_BL_PWM_GPIO        1
-#define LCD_UKEY_BL_PWM_GPIO_OFF    1
-#define LCD_UKEY_BL_PWM2_METHOD     1
-#define LCD_UKEY_BL_PWM2_PORT       1
-#define LCD_UKEY_BL_PWM2_FREQ       4
-#define LCD_UKEY_BL_PWM2_DUTY_MAX   1
-#define LCD_UKEY_BL_PWM2_DUTY_MIN   1
-#define LCD_UKEY_BL_PWM2_GPIO       1
-#define LCD_UKEY_BL_PWM2_GPIO_OFF   1
-#define LCD_UKEY_BL_PWM_LEVEL_MAX   2
-#define LCD_UKEY_BL_PWM_LEVEL_MIN   2
-#define LCD_UKEY_BL_PWM2_LEVEL_MAX  2
-#define LCD_UKEY_BL_PWM2_LEVEL_MIN  2
+#define LCD_UKEY_BL_PWM_ON_DELAY    (LCD_UKEY_BL_NAME + 50)/* +30+12+8 byte */
+#define LCD_UKEY_BL_PWM_OFF_DELAY   (LCD_UKEY_BL_NAME + 52)
+#define LCD_UKEY_BL_PWM_METHOD      (LCD_UKEY_BL_NAME + 54)
+#define LCD_UKEY_BL_PWM_PORT        (LCD_UKEY_BL_NAME + 55)
+#define LCD_UKEY_BL_PWM_FREQ        (LCD_UKEY_BL_NAME + 56)
+#define LCD_UKEY_BL_PWM_DUTY_MAX    (LCD_UKEY_BL_NAME + 60)
+#define LCD_UKEY_BL_PWM_DUTY_MIN    (LCD_UKEY_BL_NAME + 61)
+#define LCD_UKEY_BL_PWM_GPIO        (LCD_UKEY_BL_NAME + 62)
+#define LCD_UKEY_BL_PWM_GPIO_OFF    (LCD_UKEY_BL_NAME + 63)
+#define LCD_UKEY_BL_PWM2_METHOD     (LCD_UKEY_BL_NAME + 64)
+#define LCD_UKEY_BL_PWM2_PORT       (LCD_UKEY_BL_NAME + 65)
+#define LCD_UKEY_BL_PWM2_FREQ       (LCD_UKEY_BL_NAME + 66)
+#define LCD_UKEY_BL_PWM2_DUTY_MAX   (LCD_UKEY_BL_NAME + 70)
+#define LCD_UKEY_BL_PWM2_DUTY_MIN   (LCD_UKEY_BL_NAME + 71)
+#define LCD_UKEY_BL_PWM2_GPIO       (LCD_UKEY_BL_NAME + 72)
+#define LCD_UKEY_BL_PWM2_GPIO_OFF   (LCD_UKEY_BL_NAME + 73)
+#define LCD_UKEY_BL_PWM_LEVEL_MAX   (LCD_UKEY_BL_NAME + 74)
+#define LCD_UKEY_BL_PWM_LEVEL_MIN   (LCD_UKEY_BL_NAME + 76)
+#define LCD_UKEY_BL_PWM2_LEVEL_MAX  (LCD_UKEY_BL_NAME + 78)
+#define LCD_UKEY_BL_PWM2_LEVEL_MIN  (LCD_UKEY_BL_NAME + 80)
 /* customer(10Byte) */ /* V2 */
-#define LCD_UKEY_BL_CUST_VAL_0      2
-#define LCD_UKEY_BL_CUST_VAL_1      2
-#define LCD_UKEY_BL_CUST_VAL_2      2
-#define LCD_UKEY_BL_CUST_VAL_3      2
-#define LCD_UKEY_BL_CUST_VAL_4      2
+#define LCD_UKEY_BL_CUST_VAL_0      (LCD_UKEY_BL_NAME + 82)
+#define LCD_UKEY_BL_CUST_VAL_1      (LCD_UKEY_BL_NAME + 84)
+#define LCD_UKEY_BL_CUST_VAL_2      (LCD_UKEY_BL_NAME + 86)
+#define LCD_UKEY_BL_CUST_VAL_3      (LCD_UKEY_BL_NAME + 88)
+#define LCD_UKEY_BL_CUST_VAL_4      (LCD_UKEY_BL_NAME + 90)
 
 /* ********************************
  * API