From 13d0c5750d874d6ac1e061a590fe267f72b79498 Mon Sep 17 00:00:00 2001 From: "shaochan.liu" Date: Mon, 2 Sep 2019 13:37:06 +0800 Subject: [PATCH] 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 --- .../media/vout/lcd/lcd_extern/ext_default.c | 9 ++---- .../media/vout/lcd/lcd_extern/i2c_ANX6862_7911.c | 8 ++--- .../amlogic/media/vout/lcd/lcd_extern/i2c_CS602.c | 9 +++++- .../amlogic/media/vout/lcd/lcd_extern/i2c_T5800Q.c | 37 +++++++++++++++++----- .../amlogic/media/vout/lcd/lcd_extern/lcd_extern.c | 9 ++++-- include/linux/amlogic/media/vout/lcd/lcd_extern.h | 2 +- 6 files changed, 49 insertions(+), 25 deletions(-) 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 b0e76ba..45e47ce 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 2d3a70b..92e7639 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 63ebcb7..840ae1f 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 49cf9dc..4138bcb 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 9bb3f72..6369c67 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 a979577..1732a33 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; -- 2.7.4