From: shaochan.liu Date: Mon, 2 Sep 2019 05:37:06 +0000 (+0800) Subject: lcd: tcon: add load flash data to update gamma voltage for lcd driver [2/2] X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=13d0c5750d874d6ac1e061a590fe267f72b79498;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git lcd: tcon: add load flash data to update gamma voltage for lcd driver [2/2] 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 --- diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c b/drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c index b0e76ba8de67..45e47ce91777 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c @@ -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; diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c index 2d3a70b2357f..92e763917099 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c @@ -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; } diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c index 63ebcb7a9ba7..840ae1f60a89 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c @@ -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; } diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c index 49cf9dc7a13e..4138bcb5259f 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c @@ -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 { diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c index 9bb3f72aec84..6369c67163c2 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c @@ -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( diff --git a/include/linux/amlogic/media/vout/lcd/lcd_extern.h b/include/linux/amlogic/media/vout/lcd/lcd_extern.h index a979577ab25e..1732a33d3d96 100644 --- a/include/linux/amlogic/media/vout/lcd/lcd_extern.h +++ b/include/linux/amlogic/media/vout/lcd/lcd_extern.h @@ -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;