int dsi_panel_set_backlight(struct dsi_panel *panel, u32 bl_lvl) { int rc = 0; struct dsi_backlight_config *bl = &panel->bl_config; if (panel->host_config.ext_bridge_mode) return 0; DSI_DEBUG("backlight type:%d lvl:%d\n", bl->type, bl_lvl); switch (bl->type) { case DSI_BACKLIGHT_WLED: rc = backlight_device_set_brightness(bl->raw_bd, bl_lvl); break; case DSI_BACKLIGHT_DCS: rc = dsi_panel_update_backlight(panel, bl_lvl); break; case DSI_BACKLIGHT_EXTERNAL: rc = lcd_bl_set_led_brightness(bl_lvl); //pr_err("dsi set bias brightness: %d\n", bl_lvl); rc = lcd_bias_set_led_brightness(bl_lvl); //pr_err("dsi set brightness: %d\n", bl_lvl); break; case DSI_BACKLIGHT_PWM: rc = dsi_panel_update_pwm_backlight(panel, bl_lvl); break; default: DSI_ERR("Backlight type(%d) not supported\n", bl->type); rc = -ENOTSUPP; } return rc; } int lcd_bl_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_i2c_client->dev, "value=%d\n", value); return 0; } if (value > 0) { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); /* BL enabled and Current sink 1/2/3/4 enabled;*/ } else { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); /* BL enabled and Current sink 1/2/3/4 disabled;*/ } return 0; } int lcd_bias_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_bias_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_bias_i2c_client->dev, "invalid value=%d\n", value); return 0; } if (value > 0) { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); /* BL enabled and Current sink 1/2/3/4 enabled;*/ } else { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); /* BL enabled and Current sink 1/2/3/4 disabled;*/ } return 0; } dsi_panel_set_backlight、lcd_bl_set_led_brightness和lcd_bias_set_led_brightness源码如上,帮忙用内核线程的方式,同时实现在case DSI_BACKLIGHT_EXTERNAL:下并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数
时间: 2023-08-28 19:03:38 浏览: 123
inet_dsi_panel20200703_BOE_FHD_8279_A55_
可以使用内核线程的方式实现在case DSI_BACKLIGHT_EXTERNAL下并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数。具体实现方法如下:
1. 新建一个内核线程函数,用于并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数。
```
static int dsi_panel_set_backlight_external(int value)
{
int ret = 0;
ret = kthread_run(lcd_bl_set_led_brightness, (void *)value, "lcd_bl_set_led_brightness");
if (ret < 0) {
pr_err("Failed to create lcd_bl_set_led_brightness thread\n");
}
ret = kthread_run(lcd_bias_set_led_brightness, (void *)value, "lcd_bias_set_led_brightness");
if (ret < 0) {
pr_err("Failed to create lcd_bias_set_led_brightness thread\n");
}
return ret;
}
```
2. 在case DSI_BACKLIGHT_EXTERNAL下调用新建的内核线程函数。
```
case DSI_BACKLIGHT_EXTERNAL:
rc = dsi_panel_set_backlight_external(bl_lvl);
break;
```
3. 注意修改lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数的参数类型,改为void *类型,以便在内核线程函数中传递bl_lvl参数。
```
int lcd_bl_set_led_brightness(void *data)
{
int value = (int)data;
...
}
int lcd_bias_set_led_brightness(void *data)
{
int value = (int)data;
...
}
```
以上是一种实现方式,可以在case DSI_BACKLIGHT_EXTERNAL下并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数。
阅读全文