mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
bl: bl_extern: add i2c_lp8556 support 12bit data [2/2]
PD#SWPL-27180 Problem: 1, need add bl_extern i2c_lp8556 12bit data support Solution: 1, add bl_extern i2c_lp8556 12bit data support 2, optimized code, fix copy err and add null pointer check Verify: a311d_w400 Change-Id: Ifeb25e5b434233ae9dd088899e9e1e849303d3d9 Signed-off-by: shaochan.liu <shaochan.liu@amlogic.com> Signed-off-by: chunlong.cao <chunlong.cao@amlogic.com>
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
obj-$(CONFIG_AMLOGIC_BACKLIGHT) += aml_bl.o
|
||||
obj-$(CONFIG_AMLOGIC_BL_EXTERN) += bl_extern/
|
||||
obj-$(CONFIG_AMLOGIC_LOCAL_DIMMING) += aml_ldim/
|
||||
obj-$(CONFIG_AMLOGIC_LOCAL_DIMMING) += aml_ldim/
|
||||
obj-$(CONFIG_AMLOGIC_BACKLIGHT) += aml_bl.o
|
||||
|
||||
@@ -742,8 +742,9 @@ static void bl_power_on(void)
|
||||
/* step 1: power on ldim */
|
||||
if (ldim_drv->power_on) {
|
||||
ret = ldim_drv->power_on();
|
||||
if (ret)
|
||||
BLERR("ldim: power on error\n");
|
||||
if (ret < 0)
|
||||
BLERR("bl: power on error, ret = %d\n",
|
||||
ret);
|
||||
} else {
|
||||
BLPR("ldim: power on is null\n");
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ static int bl_extern_table_init_save(struct bl_extern_config_s *extconf)
|
||||
return -1;
|
||||
}
|
||||
memcpy(extconf->init_on, table_init_on_dft,
|
||||
extconf->init_off_cnt*sizeof(unsigned char));
|
||||
extconf->init_on_cnt * sizeof(unsigned char));
|
||||
}
|
||||
if (extconf->init_off_cnt > 0) {
|
||||
extconf->init_off = kcalloc(extconf->init_off_cnt,
|
||||
@@ -575,6 +575,11 @@ static int bl_extern_config_from_dts(struct device_node *np, int index)
|
||||
int ret = 0;
|
||||
struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
|
||||
|
||||
if (!bl_extern) {
|
||||
BLEXERR("%s: bl_extern is null\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = of_property_read_string(np, "i2c_bus", &str);
|
||||
if (ret == 0)
|
||||
bl_extern->config.i2c_bus = LCD_EXT_I2C_BUS_MAX;
|
||||
@@ -804,6 +809,11 @@ int aml_bl_extern_device_load(int index)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!bl_extern_driver.dev) {
|
||||
BLEXERR("%s: bl_extern_driver dev is null\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bl_extern_config_from_dts(bl_extern_driver.dev->of_node, index);
|
||||
ret = bl_extern_add_driver();
|
||||
bl_extern_driver.config_print = bl_extern_config_print;
|
||||
|
||||
@@ -215,7 +215,8 @@ static int i2c_lp8556_power_off(void)
|
||||
|
||||
static int i2c_lp8556_set_level(unsigned int level)
|
||||
{
|
||||
unsigned char tData[3];
|
||||
struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
|
||||
unsigned char tData[5];
|
||||
int ret = 0;
|
||||
|
||||
if (i2c_dev == NULL) {
|
||||
@@ -223,9 +224,17 @@ static int i2c_lp8556_set_level(unsigned int level)
|
||||
return -1;
|
||||
}
|
||||
|
||||
tData[0] = 0x0;
|
||||
tData[1] = level & 0xff;
|
||||
ret = bl_extern_i2c_write(i2c_dev->client, tData, 2);
|
||||
if (bl_extern->config.dim_max > 255) {
|
||||
tData[0] = 0x10;
|
||||
tData[1] = level & 0xff;
|
||||
tData[2] = 0x11;
|
||||
tData[3] = (level >> 8) & 0xf;
|
||||
ret = bl_extern_i2c_write(i2c_dev->client, tData, 4);
|
||||
} else {
|
||||
tData[0] = 0x0;
|
||||
tData[1] = level & 0xff;
|
||||
ret = bl_extern_i2c_write(i2c_dev->client, tData, 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -246,10 +255,12 @@ static int i2c_lp8556_update(void)
|
||||
bl_extern->device_bri_update = i2c_lp8556_set_level;
|
||||
|
||||
bl_extern->config.cmd_size = BL_EXTERN_CMD_SIZE;
|
||||
bl_extern->config.init_on = init_on_table;
|
||||
bl_extern->config.init_on_cnt = sizeof(init_on_table);
|
||||
bl_extern->config.init_off = init_off_table;
|
||||
bl_extern->config.init_off_cnt = sizeof(init_off_table);
|
||||
if (!bl_extern->config.init_loaded) {
|
||||
bl_extern->config.init_on = init_on_table;
|
||||
bl_extern->config.init_on_cnt = sizeof(init_on_table);
|
||||
bl_extern->config.init_off = init_off_table;
|
||||
bl_extern->config.init_off_cnt = sizeof(init_off_table);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user