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)
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;
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
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;
}
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;
}
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;
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 {
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 {
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");
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(
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;