[v4,3/3] drm/panel-edp: Avoid adding multiple preferred modes
Commit Message
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
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.
@@ -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");