drm: msm: dsi-staging: Add support for High Brightness Mode

Author: Arian <arian.kulmer@web.de>
Date:   Wed Jun 24 15:44:22 2020 +0200

    drm: msm: Use type_map array index 0 for invalid hbm values

    Change-Id: I8b29ad7227be9f01f945af136747a5924b0b628a

[ghostrider-reborn] Adapted to surya LCD HBM
Change-Id: Id133e30c7bf645386053c42d4d121a053b03bac7
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Danny Baumann 2018-07-19 09:41:23 +02:00 committed by azrim
parent 6980172c8f
commit 1d3bf88605
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C
4 changed files with 102 additions and 0 deletions

View File

@ -308,6 +308,9 @@ enum dsi_cmd_set_type {
DSI_CMD_SET_POST_TIMING_SWITCH,
DSI_CMD_SET_QSYNC_ON,
DSI_CMD_SET_QSYNC_OFF,
DSI_CMD_SET_DISP_LCD_HBM_L1_ON,
DSI_CMD_SET_DISP_LCD_HBM_L2_ON,
DSI_CMD_SET_DISP_LCD_HBM_OFF,
DSI_CMD_SET_MAX
};

View File

@ -5060,7 +5060,68 @@ error:
return rc;
}
static ssize_t sysfs_hbm_read(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dsi_display *display = dev_get_drvdata(dev);
if (!display->panel)
return 0;
return scnprintf(buf, PAGE_SIZE, "%d\n", display->panel->hbm_mode);
}
static ssize_t sysfs_hbm_write(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct dsi_display *display = dev_get_drvdata(dev);
int ret, hbm_mode;
if (!display->panel)
return -EINVAL;
ret = kstrtoint(buf, 10, &hbm_mode);
if (ret) {
pr_err("kstrtoint failed. ret=%d\n", ret);
return ret;
}
mutex_lock(&display->display_lock);
display->panel->hbm_mode = hbm_mode;
if (!dsi_panel_initialized(display->panel))
goto error;
ret = dsi_display_clk_ctrl(display->dsi_clk_handle,
DSI_CORE_CLK, DSI_CLK_ON);
if (ret) {
pr_err("[%s] failed to enable DSI core clocks, rc=%d\n",
display->name, ret);
goto error;
}
ret = dsi_panel_apply_hbm_mode(display->panel);
if (ret)
pr_err("unable to set hbm mode\n");
ret = dsi_display_clk_ctrl(display->dsi_clk_handle,
DSI_CORE_CLK, DSI_CLK_OFF);
if (ret) {
pr_err("[%s] failed to disable DSI core clocks, rc=%d\n",
display->name, ret);
goto error;
}
error:
mutex_unlock(&display->display_lock);
return ret == 0 ? count : ret;
}
static DEVICE_ATTR(hbm, 0644,
sysfs_hbm_read,
sysfs_hbm_write);
static struct attribute *display_fs_attrs[] = {
&dev_attr_hbm.attr,
NULL,
};

View File

@ -1768,6 +1768,9 @@ const char *cmd_set_prop_map[DSI_CMD_SET_MAX] = {
"qcom,mdss-dsi-post-mode-switch-on-command",
"qcom,mdss-dsi-qsync-on-commands",
"qcom,mdss-dsi-qsync-off-commands",
"qcom,mdss-dsi-dispparam-lcd-hbm-l1-on-command",
"qcom,mdss-dsi-dispparam-lcd-hbm-l2-on-command",
"qcom,mdss-dsi-dispparam-lcd-hbm-off-command",
};
const char *cmd_set_state_map[DSI_CMD_SET_MAX] = {
@ -1794,6 +1797,9 @@ const char *cmd_set_state_map[DSI_CMD_SET_MAX] = {
"qcom,mdss-dsi-post-mode-switch-on-command-state",
"qcom,mdss-dsi-qsync-on-commands-state",
"qcom,mdss-dsi-qsync-off-commands-state",
"qcom,mdss-dsi-dispparam-lcd-hbm-l1-on-command-state",
"qcom,mdss-dsi-dispparam-lcd-hbm-l2-on-command-state",
"qcom,mdss-dsi-dispparam-lcd-hbm-off-command-state",
};
static int dsi_panel_get_cmd_pkt_count(const char *data, u32 length, u32 *cnt)
@ -4283,6 +4289,10 @@ int dsi_panel_enable(struct dsi_panel *panel)
else
panel->panel_initialized = true;
mutex_unlock(&panel->panel_lock);
if (panel->hbm_mode)
dsi_panel_apply_hbm_mode(panel);
return rc;
}
@ -4418,3 +4428,27 @@ error:
mutex_unlock(&panel->panel_lock);
return rc;
}
int dsi_panel_apply_hbm_mode(struct dsi_panel *panel)
{
static const enum dsi_cmd_set_type type_map[] = {
DSI_CMD_SET_DISP_LCD_HBM_OFF,
DSI_CMD_SET_DISP_LCD_HBM_L1_ON,
DSI_CMD_SET_DISP_LCD_HBM_L2_ON
};
enum dsi_cmd_set_type type;
int rc;
if (panel->hbm_mode >= 0 &&
panel->hbm_mode < ARRAY_SIZE(type_map))
type = type_map[panel->hbm_mode];
else
type = type_map[0];
mutex_lock(&panel->panel_lock);
rc = dsi_panel_tx_cmd_set(panel, type);
mutex_unlock(&panel->panel_lock);
return rc;
}

View File

@ -218,6 +218,8 @@ struct dsi_panel {
bool sync_broadcast_en;
int power_mode;
enum dsi_panel_physical_type panel_type;
int hbm_mode;
};
static inline bool dsi_panel_ulps_feature_enabled(struct dsi_panel *panel)
@ -338,4 +340,6 @@ int dsi_panel_parse_esd_reg_read_configs(struct dsi_panel *panel);
void dsi_panel_ext_bridge_put(struct dsi_panel *panel);
int dsi_panel_apply_hbm_mode(struct dsi_panel *panel);
#endif /* _DSI_PANEL_H_ */