[v4,3/3] drm/panel-edp: Avoid adding multiple preferred modes

Message ID 20231106210337.2900034-4-hsinyi@chromium.org
State New
Headers
Series Add a few panels and use correct modes |

Commit Message

Hsin-Yi Wang Nov. 6, 2023, 9 p.m. UTC
  If a non generic edp-panel is under aux-bus, the mode read from edid would
still be selected as preferred and results in multiple preferred modes,
which is ambiguous.

If both hard-coded mode and edid exists, only add mode from hard-coded.

Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
v3->v4: don't skip read edid. only skip add modes.
---
 drivers/gpu/drm/panel/panel-edp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  

Comments

Doug Anderson Nov. 6, 2023, 9:12 p.m. UTC | #1
Hi,

On Mon, Nov 6, 2023 at 1:03 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
>
> @@ -622,7 +627,7 @@ static int panel_edp_get_modes(struct drm_panel *panel,
>          * and no modes (the generic edp-panel case) because it will clobber
>          * the display_info that was already set by drm_add_edid_modes().
>          */
> -       if (p->desc->num_timings || p->desc->num_modes)
> +       if (has_hard_coded_modes)

nit: the comment above this line is a bit confusing now and probably
needs to be updated or removed.
  

Patch

diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c
index 0fb439b5efb1..c8bb4baf1d45 100644
--- a/drivers/gpu/drm/panel/panel-edp.c
+++ b/drivers/gpu/drm/panel/panel-edp.c
@@ -590,6 +590,7 @@  static int panel_edp_get_modes(struct drm_panel *panel,
 {
 	struct panel_edp *p = to_panel_edp(panel);
 	int num = 0;
+	bool has_hard_coded_modes = p->desc->num_timings || p->desc->num_modes;
 	bool has_override_edid_mode = p->detected_panel &&
 				      p->detected_panel != ERR_PTR(-EINVAL) &&
 				      p->detected_panel->override_edid_mode;
@@ -600,7 +601,11 @@  static int panel_edp_get_modes(struct drm_panel *panel,
 
 		if (!p->edid)
 			p->edid = drm_get_edid(connector, p->ddc);
-		if (p->edid) {
+		/*
+		 * If both edid and hard-coded modes exists, skip edid modes to
+		 * avoid multiple preferred modes.
+		 */
+		if (p->edid && !has_hard_coded_modes) {
 			if (has_override_edid_mode) {
 				/*
 				 * override_edid_mode is specified. Use
@@ -622,7 +627,7 @@  static int panel_edp_get_modes(struct drm_panel *panel,
 	 * and no modes (the generic edp-panel case) because it will clobber
 	 * the display_info that was already set by drm_add_edid_modes().
 	 */
-	if (p->desc->num_timings || p->desc->num_modes)
+	if (has_hard_coded_modes)
 		num += panel_edp_get_non_edid_modes(p, connector);
 	else if (!num)
 		dev_warn(p->base.dev, "No display modes\n");