From b990bd6a04dbde0d1b262d6a6c186494ad48fb25 Mon Sep 17 00:00:00 2001 From: Rajeev Nandan Date: Mon, 13 Apr 2020 12:01:50 +0530 Subject: [PATCH] disp: msm: dsi: select timing mode shared from kernel command line If the command line timing is given, select corresponding drm display mode as preferred mode. Select first sub mode of that timing as preferred mode if dynamic clock or dynamic fps is enabled. Change-Id: I688b3bc07f79f4d014b8a7797204d3d6a873222d Signed-off-by: Rajeev Nandan --- msm/dsi/dsi_defs.h | 2 ++ msm/dsi/dsi_display.c | 44 +++++++++++++++++++++++++------------------ msm/dsi/dsi_drm.c | 10 ++++++++-- msm/dsi/dsi_drm.h | 4 +++- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/msm/dsi/dsi_defs.h b/msm/dsi/dsi_defs.h index be7b239482..e6f18da8cf 100644 --- a/msm/dsi/dsi_defs.h +++ b/msm/dsi/dsi_defs.h @@ -623,6 +623,7 @@ struct dsi_display_mode_priv_info { * @pixel_clk_khz: Pixel clock in Khz. * @dsi_mode_flags: Flags to signal other drm components via private flags * @panel_mode: Panel mode + * @is_preferred: Is mode preferred * @priv_info: Mode private info */ struct dsi_display_mode { @@ -630,6 +631,7 @@ struct dsi_display_mode { u32 pixel_clk_khz; u32 dsi_mode_flags; enum dsi_op_mode panel_mode; + bool is_preferred; struct dsi_display_mode_priv_info *priv_info; }; diff --git a/msm/dsi/dsi_display.c b/msm/dsi/dsi_display.c index ba39abc53f..756403df2d 100644 --- a/msm/dsi/dsi_display.c +++ b/msm/dsi/dsi_display.c @@ -23,7 +23,6 @@ #define to_dsi_display(x) container_of(x, struct dsi_display, host) #define INT_BASE_10 10 -#define NO_OVERRIDE -1 #define MISR_BUFF_SIZE 256 #define ESD_MODE_STRING_MAX_LEN 256 @@ -2196,25 +2195,22 @@ static void dsi_display_parse_cmdline_topology(struct dsi_display *display, } str = strnstr(boot_str, ":config", strlen(boot_str)); - if (!str) - goto end; - - if (kstrtol(str + strlen(":config"), INT_BASE_10, - (unsigned long *)&cmdline_topology)) { - DSI_ERR("invalid config index override: %s\n", boot_str); - goto end; + if (str) { + if (sscanf(str, ":config%lu", &cmdline_topology) != 1) { + DSI_ERR("invalid config index override: %s\n", + boot_str); + goto end; + } } str = strnstr(boot_str, ":timing", strlen(boot_str)); - if (!str) - goto end; - - if (kstrtol(str + strlen(":timing"), INT_BASE_10, - (unsigned long *)&cmdline_timing)) { - DSI_ERR("invalid timing index override: %s. resetting both timing and config\n", - boot_str); - cmdline_topology = NO_OVERRIDE; - goto end; + if (str) { + if (sscanf(str, ":timing%lu", &cmdline_timing) != 1) { + DSI_ERR("invalid timing index override: %s\n", + boot_str); + cmdline_topology = NO_OVERRIDE; + goto end; + } } DSI_DEBUG("successfully parsed command line topology and timing\n"); end: @@ -6167,13 +6163,21 @@ int dsi_display_get_modes(struct dsi_display *display, 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++) { struct dsi_display_mode display_mode; int topology_override = NO_OVERRIDE; + bool is_preferred = false; u32 frame_threshold_us = ctrl->ctrl->frame_threshold_time_us; - if (display->cmdline_timing == mode_idx) + if (display->cmdline_timing == mode_idx) { topology_override = display->cmdline_topology; + is_preferred = true; + } memset(&display_mode, 0, sizeof(display_mode)); @@ -6266,6 +6270,10 @@ int dsi_display_get_modes(struct dsi_display *display, continue; _dsi_display_populate_bit_clks(display, start, end, &array_idx); + if (is_preferred) { + /* Set first timing sub mode as preferred mode */ + display->modes[start].is_preferred = true; + } } exit: diff --git a/msm/dsi/dsi_drm.c b/msm/dsi/dsi_drm.c index 14aa3481be..937c565606 100644 --- a/msm/dsi/dsi_drm.c +++ b/msm/dsi/dsi_drm.c @@ -882,9 +882,15 @@ int dsi_connector_get_modes(struct drm_connector *connector, void *data, } m->width_mm = connector->display_info.width_mm; m->height_mm = connector->display_info.height_mm; - /* set the first mode in list as preferred */ - if (i == 0) + + if (display->cmdline_timing != NO_OVERRIDE) { + /* get the preferred mode from dsi display mode */ + if (modes[i].is_preferred) + m->type |= DRM_MODE_TYPE_PREFERRED; + } else if (i == 0) { + /* set the first mode in list as preferred */ m->type |= DRM_MODE_TYPE_PREFERRED; + } drm_mode_probed_add(connector, m); } diff --git a/msm/dsi/dsi_drm.h b/msm/dsi/dsi_drm.h index 676e2bf9c8..5a67bbc8e9 100644 --- a/msm/dsi/dsi_drm.h +++ b/msm/dsi/dsi_drm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #ifndef _DSI_DRM_H_ @@ -14,6 +14,8 @@ #include "dsi_display.h" +#define NO_OVERRIDE -1 + struct dsi_bridge { struct drm_bridge base; u32 id;