disp: msm: sde: refactor dsi_display_get_modes function
Refactor the function 'dsi_display_get_modes' to reduce its complexity. Change-Id: I1a8ecaa780e5070bac7fa40404677c0a8a5d7cd8 Signed-off-by: Shamika Joshi <quic_shamjosh@quicinc.com>
Este commit está contenido en:
@@ -6970,58 +6970,15 @@ void dsi_display_put_mode(struct dsi_display *display,
|
|||||||
dsi_panel_put_mode(mode);
|
dsi_panel_put_mode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dsi_display_get_modes(struct dsi_display *display,
|
int dsi_display_get_modes_helper(struct dsi_display *display,
|
||||||
struct dsi_display_mode **out_modes)
|
struct dsi_display_ctrl *ctrl, u32 timing_mode_count,
|
||||||
|
struct dsi_dfps_capabilities dfps_caps, struct dsi_qsync_capabilities *qsync_caps,
|
||||||
|
struct dsi_dyn_clk_caps *dyn_clk_caps)
|
||||||
{
|
{
|
||||||
struct dsi_dfps_capabilities dfps_caps;
|
int dsc_modes = 0, nondsc_modes = 0, rc = 0, i, start, end;
|
||||||
struct dsi_display_ctrl *ctrl;
|
u32 num_dfps_rates, mode_idx, sublinks_count, array_idx = 0;
|
||||||
struct dsi_host_common_cfg *host = &display->panel->host_config;
|
|
||||||
bool is_split_link, support_cmd_mode, support_video_mode;
|
bool is_split_link, support_cmd_mode, support_video_mode;
|
||||||
u32 num_dfps_rates, timing_mode_count, display_mode_count;
|
struct dsi_host_common_cfg *host = &display->panel->host_config;
|
||||||
u32 sublinks_count, mode_idx, array_idx = 0;
|
|
||||||
struct dsi_dyn_clk_caps *dyn_clk_caps;
|
|
||||||
int i, start, end, rc = -EINVAL;
|
|
||||||
int dsc_modes = 0, nondsc_modes = 0;
|
|
||||||
struct dsi_qsync_capabilities *qsync_caps;
|
|
||||||
|
|
||||||
if (!display || !out_modes) {
|
|
||||||
DSI_ERR("Invalid params\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*out_modes = NULL;
|
|
||||||
ctrl = &display->ctrl[0];
|
|
||||||
|
|
||||||
mutex_lock(&display->display_lock);
|
|
||||||
|
|
||||||
if (display->modes)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
display_mode_count = display->panel->num_display_modes;
|
|
||||||
|
|
||||||
display->modes = kcalloc(display_mode_count, sizeof(*display->modes),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!display->modes) {
|
|
||||||
rc = -ENOMEM;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = dsi_panel_get_dfps_caps(display->panel, &dfps_caps);
|
|
||||||
if (rc) {
|
|
||||||
DSI_ERR("[%s] failed to get dfps caps from panel\n",
|
|
||||||
display->name);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
qsync_caps = &(display->panel->qsync_caps);
|
|
||||||
dyn_clk_caps = &(display->panel->dyn_clk_caps);
|
|
||||||
|
|
||||||
timing_mode_count = display->panel->num_timing_nodes;
|
|
||||||
|
|
||||||
/* Validate command line timing */
|
|
||||||
if ((display->cmdline_timing != NO_OVERRIDE) &&
|
|
||||||
(display->cmdline_timing >= timing_mode_count))
|
|
||||||
display->cmdline_timing = NO_OVERRIDE;
|
|
||||||
|
|
||||||
for (mode_idx = 0; mode_idx < timing_mode_count; mode_idx++) {
|
for (mode_idx = 0; mode_idx < timing_mode_count; mode_idx++) {
|
||||||
struct dsi_display_mode display_mode;
|
struct dsi_display_mode display_mode;
|
||||||
@@ -7038,7 +6995,8 @@ int dsi_display_get_modes(struct dsi_display *display,
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
DSI_ERR("[%s] failed to get mode idx %d from panel\n",
|
DSI_ERR("[%s] failed to get mode idx %d from panel\n",
|
||||||
display->name, mode_idx);
|
display->name, mode_idx);
|
||||||
goto error;
|
rc = -EINVAL;
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display->cmdline_timing == display_mode.mode_idx) {
|
if (display->cmdline_timing == display_mode.mode_idx) {
|
||||||
@@ -7104,7 +7062,7 @@ int dsi_display_get_modes(struct dsi_display *display,
|
|||||||
if (!sub_mode) {
|
if (!sub_mode) {
|
||||||
DSI_ERR("invalid mode data\n");
|
DSI_ERR("invalid mode data\n");
|
||||||
rc = -EFAULT;
|
rc = -EFAULT;
|
||||||
goto error;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(sub_mode, &display_mode, sizeof(display_mode));
|
memcpy(sub_mode, &display_mode, sizeof(display_mode));
|
||||||
@@ -7130,14 +7088,14 @@ int dsi_display_get_modes(struct dsi_display *display,
|
|||||||
sizeof(*sub_mode->priv_info), GFP_KERNEL);
|
sizeof(*sub_mode->priv_info), GFP_KERNEL);
|
||||||
if (!sub_mode->priv_info) {
|
if (!sub_mode->priv_info) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto error;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = dsi_display_mode_dyn_clk_cpy(display,
|
rc = dsi_display_mode_dyn_clk_cpy(display,
|
||||||
&display_mode, sub_mode);
|
&display_mode, sub_mode);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
DSI_ERR("unable to copy dyn clock list\n");
|
DSI_ERR("unable to copy dyn clock list\n");
|
||||||
goto error;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_mode->mode_idx += (array_idx - 1);
|
sub_mode->mode_idx += (array_idx - 1);
|
||||||
@@ -7178,6 +7136,63 @@ int dsi_display_get_modes(struct dsi_display *display,
|
|||||||
if (dsc_modes && nondsc_modes)
|
if (dsc_modes && nondsc_modes)
|
||||||
display->panel->dsc_switch_supported = true;
|
display->panel->dsc_switch_supported = true;
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dsi_display_get_modes(struct dsi_display *display,
|
||||||
|
struct dsi_display_mode **out_modes)
|
||||||
|
{
|
||||||
|
struct dsi_dfps_capabilities dfps_caps;
|
||||||
|
struct dsi_display_ctrl *ctrl;
|
||||||
|
u32 timing_mode_count, display_mode_count;
|
||||||
|
struct dsi_dyn_clk_caps *dyn_clk_caps;
|
||||||
|
int rc = -EINVAL;
|
||||||
|
struct dsi_qsync_capabilities *qsync_caps;
|
||||||
|
|
||||||
|
if (!display || !out_modes) {
|
||||||
|
DSI_ERR("Invalid params\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_modes = NULL;
|
||||||
|
ctrl = &display->ctrl[0];
|
||||||
|
|
||||||
|
mutex_lock(&display->display_lock);
|
||||||
|
|
||||||
|
if (display->modes)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
display_mode_count = display->panel->num_display_modes;
|
||||||
|
|
||||||
|
display->modes = kcalloc(display_mode_count, sizeof(*display->modes),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!display->modes) {
|
||||||
|
rc = -ENOMEM;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = dsi_panel_get_dfps_caps(display->panel, &dfps_caps);
|
||||||
|
if (rc) {
|
||||||
|
DSI_ERR("[%s] failed to get dfps caps from panel\n",
|
||||||
|
display->name);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
qsync_caps = &(display->panel->qsync_caps);
|
||||||
|
dyn_clk_caps = &(display->panel->dyn_clk_caps);
|
||||||
|
|
||||||
|
timing_mode_count = display->panel->num_timing_nodes;
|
||||||
|
|
||||||
|
/* Validate command line timing */
|
||||||
|
if ((display->cmdline_timing != NO_OVERRIDE) &&
|
||||||
|
(display->cmdline_timing >= timing_mode_count))
|
||||||
|
display->cmdline_timing = NO_OVERRIDE;
|
||||||
|
|
||||||
|
rc = dsi_display_get_modes_helper(display, ctrl, timing_mode_count,
|
||||||
|
dfps_caps, qsync_caps, dyn_clk_caps);
|
||||||
|
if (rc)
|
||||||
|
goto error;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
*out_modes = display->modes;
|
*out_modes = display->modes;
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
Referencia en una nueva incidencia
Block a user