lcd: tcon: add load flash data to update gamma voltage for lcd driver [2/2]
authorshaochan.liu <shaochan.liu@amlogic.com>
Mon, 2 Sep 2019 05:37:06 +0000 (13:37 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Tue, 3 Sep 2019 09:00:14 +0000 (02:00 -0700)
PD#TV-6676

Problem:
the auto gamma function need load flash data to update gamma voltage
gor lcd driver

Solution:
add load flash data to update gamma voltage

Verify:
t962x2_x301

Change-Id: I80176e4a146fe453c3d3b5919c96b659be1286ea
Signed-off-by: shaochan.liu <shaochan.liu@amlogic.com>
drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c
drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c
drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c
include/linux/amlogic/media/vout/lcd/lcd_extern.h

index b0e76ba8de67b93e118c2e2ad928c36dbda66960..45e47ce917774736e51517daca493202b015707f 100644 (file)
@@ -134,14 +134,11 @@ static int lcd_extern_reg_read(unsigned char reg, unsigned char *buf)
        return ret;
 }
 
-static int lcd_extern_reg_write(unsigned char reg, unsigned char value)
+static int lcd_extern_reg_write(unsigned char *buf, unsigned int len)
 {
        struct aml_lcd_extern_i2c_dev_s *i2c_dev;
-       unsigned char tmp[2];
        int ret = 0;
 
-       tmp[0] = reg;
-       tmp[1] = value;
        switch (ext_config->type) {
        case LCD_EXTERN_I2C:
                if (ext_config->addr_sel)
@@ -152,10 +149,10 @@ static int lcd_extern_reg_write(unsigned char reg, unsigned char value)
                        EXTERR("invalid i2c device\n");
                        return -1;
                }
-               lcd_extern_i2c_write(i2c_dev->client, tmp, 2);
+               lcd_extern_i2c_write(i2c_dev->client, buf, len);
                break;
        case LCD_EXTERN_SPI:
-               lcd_extern_spi_write(tmp, 2);
+               lcd_extern_spi_write(buf, 2);
                break;
        default:
                break;
index 2d3a70b2357faacf514919142ba7339aaad0ac3b..92e7639170993806064ad765dd11bf1d8da76bfe 100644 (file)
@@ -105,15 +105,11 @@ static int lcd_extern_reg_read(unsigned char reg, unsigned char *buf)
        return ret;
 }
 
-static int lcd_extern_reg_write(unsigned char reg, unsigned char value)
+static int lcd_extern_reg_write(unsigned char *buf, unsigned int len)
 {
        struct aml_lcd_extern_i2c_dev_s *i2c_dev;
-       unsigned char tmp[2];
        int ret = 0;
 
-       tmp[0] = reg;
-       tmp[1] = value;
-
        if (ext_config->addr_sel)
                i2c_dev = i2c1_dev;
        else
@@ -122,7 +118,7 @@ static int lcd_extern_reg_write(unsigned char reg, unsigned char value)
                EXTERR("invalid i2c device\n");
                return -1;
        }
-       lcd_extern_i2c_write(i2c_dev->client, tmp, 2);
+       lcd_extern_i2c_write(i2c_dev->client, buf, 2);
 
        return ret;
 }
index 63ebcb7a9ba72b2044d3e10c4d1cc9875a977123..840ae1f60a8939a3a2d4c429b7ccb6fbb4ef7b0f 100644 (file)
@@ -79,16 +79,23 @@ static int lcd_extern_init_check(int len)
 
        if (i2c_dev->client == NULL) {
                EXTERR("%s: invalid i2c client\n", __func__);
+               kfree(chk_table);
+               chk_table = NULL;
                return -1;
        }
        ret = lcd_extern_i2c_read(i2c_dev->client, chk_table, len);
        if (ret == 0) {
                for (i = 0; i < len; i++) {
-                       if (chk_table[i] != ext_config->table_init_on[i+3])
+                       if (chk_table[i] != ext_config->table_init_on[i+3]) {
+                               kfree(chk_table);
+                               chk_table = NULL;
                                return -1;
+                       }
                }
        }
 
+       kfree(chk_table);
+       chk_table = NULL;
        return 0;
 }
 
index 49cf9dc7a13e00dcaf5962f676eb7f46d40dbd46..4138bcb5259f14915abba4fb07b38a20691cfc3b 100644 (file)
@@ -55,6 +55,31 @@ static unsigned char init_off_table[] = {
        0xff, 0,  /* ending */
 };
 
+static int lcd_extern_reg_read(unsigned char reg, unsigned char *buf)
+{
+       int ret = 0;
+
+       return ret;
+}
+
+static int lcd_extern_reg_write(unsigned char *buf, unsigned int len)
+{
+       int ret = 0;
+
+       if (buf == NULL) {
+               EXTERR("%s: buf is full\n", __func__);
+               return -1;
+       }
+
+       if (!len) {
+               EXTERR("%s: invalid len\n", __func__);
+               return -1;
+       }
+
+       ret = lcd_extern_i2c_write(i2c_dev->client, buf, len);
+       return ret;
+}
+
 static int lcd_extern_power_cmd_dynamic_size(unsigned char *table, int flag)
 {
        int i = 0, j, step = 0, max_len = 0;
@@ -106,15 +131,13 @@ static int lcd_extern_power_cmd_dynamic_size(unsigned char *table, int flag)
                                EXTERR("invalid i2c device\n");
                                return -1;
                        }
-                       ret = lcd_extern_i2c_write(i2c_dev->client,
-                               &table[i+2], cmd_size);
+                       ret = lcd_extern_reg_write(&table[i+2], cmd_size);
                } else if (type == LCD_EXT_CMD_TYPE_CMD_DELAY) {
                        if (i2c_dev == NULL) {
                                EXTERR("invalid i2c device\n");
                                return -1;
                        }
-                       ret = lcd_extern_i2c_write(i2c_dev->client,
-                               &table[i+2], (cmd_size-1));
+                       ret = lcd_extern_reg_write(&table[i+2], (cmd_size-1));
                        if (table[i+cmd_size+1] > 0)
                                mdelay(table[i+cmd_size+1]);
                } else {
@@ -175,15 +198,13 @@ static int lcd_extern_power_cmd_fixed_size(unsigned char *table, int flag)
                                EXTERR("invalid i2c device\n");
                                return -1;
                        }
-                       ret = lcd_extern_i2c_write(i2c_dev->client,
-                               &table[i+1], (cmd_size-1));
+                       ret = lcd_extern_reg_write(&table[i+1], (cmd_size-1));
                } else if (type == LCD_EXT_CMD_TYPE_CMD_DELAY) {
                        if (i2c_dev == NULL) {
                                EXTERR("invalid i2c device\n");
                                return -1;
                        }
-                       ret = lcd_extern_i2c_write(i2c_dev->client,
-                               &table[i+1], (cmd_size-2));
+                       ret = lcd_extern_reg_write(&table[i+1], (cmd_size-2));
                        if (table[i+cmd_size-1] > 0)
                                mdelay(table[i+cmd_size-1]);
                } else {
index 9bb3f72aec84058265cb4c8d214485078738781a..6369c67163c26a03086f71d9f1e21183f5c440fd 100644 (file)
@@ -1924,9 +1924,10 @@ static ssize_t lcd_extern_debug_show(struct class *class,
 static ssize_t lcd_extern_debug_store(struct class *class,
                struct class_attribute *attr, const char *buf, size_t count)
 {
-       unsigned int ret;
-       unsigned int val[3], i;
+       unsigned int ret, i;
+       unsigned int val[3];
        unsigned char reg, value;
+       unsigned char reg_buf[2];
 
        if (lcd_ext_driver == NULL) {
                pr_info("lcd_extern_driver is null\n");
@@ -1992,7 +1993,9 @@ static ssize_t lcd_extern_debug_store(struct class *class,
                        reg = (unsigned char)val[1];
                        value = (unsigned char)val[2];
                        if (lcd_ext_driver->reg_write) {
-                               lcd_ext_driver->reg_write(reg, value);
+                               reg_buf[0] = (unsigned char)val[1];
+                               reg_buf[1] = (unsigned char)val[2];
+                               lcd_ext_driver->reg_write(reg_buf, 2);
                                if (lcd_ext_driver->reg_read) {
                                        lcd_ext_driver->reg_read(reg, &value);
                                        pr_info(
index a979577ab25e89d9c646dbdee0c737915ef599f8..1732a33d3d9685484caa6c6534c33724197326ae 100644 (file)
@@ -68,7 +68,7 @@ struct lcd_extern_config_s {
 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 (*reg_write)(unsigned char *buf, unsigned int len);
        int (*power_on)(void);
        int (*power_off)(void);
        struct pinctrl *pin;