From: Jani Nikula <jani.nikula@linux.intel.com>
To: cengjianeng <cengjianeng@huaqin.corp-partner.google.com>,
dri-devel@lists.freedesktop.org
Cc: dri-misc@lists.freedesktop.org,
Jianeng Ceng <cengjianeng@huaqin.corp-partner.google.com>
Subject: Re: [PATCH v2] drm/edid: prefer highest refresh mode within native resolution on eDP
Date: Thu, 03 Dec 2026 14:01:43 +0200 [thread overview]
Message-ID: <90e1693d5eefc418439d044f6849b6091b5b4e2a@intel.com> (raw)
In-Reply-To: <20261203034601.675116-1-cengjianeng@huaqin.corp-partner.google.com>
On Thu, 03 Dec 2026, cengjianeng <cengjianeng@huaqin.corp-partner.google.com> wrote:
> From: Jianeng Ceng <cengjianeng@huaqin.corp-partner.google.com>
>
> Some eDP panels advertise the same native resolution at multiple refresh
> rates, but mark the lowest refresh rate (typically 60Hz) as the preferred
> mode in their EDID. The panel is capable of multi-refresh-rate operation
> and is meant to be driven at its highest refresh rate by default, so the
> kernel hands userspace a preferred mode below the panel capability. The
> compositor then picks a non-preferred mode, or keeps the panel at its
> lowest refresh rate until userspace makes an explicit choice.
I think we could use the EDID before even evaluating the patch further.
Did you see or try [1], for example?
BR,
Jani.
[1] https://lore.kernel.org/r/20261202-displayid-t7-y420-v2-1-de5f730655d2@gmail.com
>
> Re-point DRM_MODE_TYPE_PREFERRED to the mode with the highest vertical
> refresh rate among the detailed timings that share the resolution of the
> original preferred mode, for eDP connectors. This keeps the native
> resolution selected by the EDID untouched, and only resolves which refresh
> rate within that resolution is reported as preferred. The mode ordering
> and the panel fixed-mode anchor userspace sees then match the panel's
> capability.
>
> Only detailed modes are considered. Inferred, CVT, standard timing and
> DisplayID modes are not derived from the panel's own timing descriptors,
> so they can never replace the panel timing as preferred. If the EDID does
> not mark any mode preferred there is nothing to re-point and the mode list
> is left untouched.
>
> This mirrors what vendors ship as an EDID override for such panels, but
> handles it generically in the kernel so panels cannot regress on a
> factory EDID update.
>
> Tested on eDP panels that report a 60Hz preferred timing while also
> supporting 120Hz at the same native resolution, and on panels that already
> report 120Hz as preferred: userspace reports the 120Hz mode as preferred
> in both cases.
>
> Signed-off-by: Jianeng Ceng <cengjianeng@huaqin.corp-partner.google.com>
> ---
> Changes in v2:
> - Only modes that carry DRM_MODE_TYPE_DRIVER are considered, both when
> selecting the candidate and when clearing the flag, so inferred, CVT,
> standard timing and DisplayID modes can never replace the panel timing.
> - Return early when the EDID marks no mode preferred instead of falling
> back to the first mode in the list and forcing PREFERRED onto it.
> - Scan the whole mode list for the preferred mode instead of breaking out
> on the first hit, so mode lists with several PREFERRED bits converge.
> - Clear the old PREFERRED bit only after a different candidate has been
> confirmed, leaving the mode list untouched when the highest refresh mode
> is already the preferred one.
> drivers/gpu/drm/drm_edid.c | 76 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 76 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index b8f882a17c8f..13c5a4d099b0 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3076,6 +3076,79 @@ static void edid_fixup_preferred(struct drm_connector *connector)
> preferred_mode->type |= DRM_MODE_TYPE_PREFERRED;
> }
>
> +/* Only modes parsed from detailed timings describe the panel itself. */
> +static bool is_detailed_mode(const struct drm_display_mode *mode)
> +{
> + return mode->type & DRM_MODE_TYPE_DRIVER;
> +}
> +
> +/*
> + * Walk the mode list for connector and re-point the preferred status to the
> + * mode with the highest vertical refresh rate among the detailed modes that
> + * share the resolution of the current preferred mode.
> + *
> + * Only detailed timings are considered: inferred, CVT and standard timing
> + * modes are not derived from the panel's own timing descriptors and must not
> + * replace it as preferred.
> + */
> +static void edid_fixup_preferred_max_vrefresh(struct drm_connector *connector)
> +{
> + struct drm_display_mode *cur_mode, *preferred_mode = NULL;
> + struct drm_display_mode *candidate_mode = NULL;
> + int hdisplay, vdisplay;
> +
> + /* Nothing to do if the EDID does not mark any mode preferred. */
> + list_for_each_entry(cur_mode, &connector->probed_modes, head) {
> + if (cur_mode->type & DRM_MODE_TYPE_PREFERRED) {
> + preferred_mode = cur_mode;
> + break;
> + }
> + }
> +
> + if (!preferred_mode)
> + return;
> +
> + if (!is_detailed_mode(preferred_mode))
> + return;
> +
> + /* The preferred mode defines the native resolution. */
> + hdisplay = preferred_mode->hdisplay;
> + vdisplay = preferred_mode->vdisplay;
> +
> + list_for_each_entry(cur_mode, &connector->probed_modes, head) {
> + if (!is_detailed_mode(cur_mode))
> + continue;
> +
> + if (cur_mode->hdisplay != hdisplay ||
> + cur_mode->vdisplay != vdisplay)
> + continue;
> +
> + if (!candidate_mode ||
> + drm_mode_vrefresh(cur_mode) > drm_mode_vrefresh(candidate_mode))
> + candidate_mode = cur_mode;
> + }
> +
> + if (!candidate_mode || candidate_mode == preferred_mode)
> + return;
> +
> + list_for_each_entry(cur_mode, &connector->probed_modes, head) {
> + if (!is_detailed_mode(cur_mode))
> + continue;
> +
> + if (cur_mode->hdisplay != hdisplay ||
> + cur_mode->vdisplay != vdisplay)
> + continue;
> +
> + cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
> + }
> +
> + candidate_mode->type |= DRM_MODE_TYPE_PREFERRED;
> +
> + drm_dbg_kms(connector->dev, "[CONNECTOR:%d:%s] preferred mode: "
> + DRM_MODE_FMT "\n", connector->base.id, connector->name,
> + DRM_MODE_ARG(candidate_mode));
> +}
> +
> static bool
> mode_is_rb(const struct drm_display_mode *mode)
> {
> @@ -7242,6 +7315,9 @@ static int _drm_edid_connector_add_modes(struct drm_connector *connector,
> drm_edid_has_internal_quirk(connector, EDID_QUIRK_PREFER_LARGE_75))
> edid_fixup_preferred(connector);
>
> + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP)
> + edid_fixup_preferred_max_vrefresh(connector);
> +
> return num_modes;
> }
>
--
Jani Nikula, Intel
next prev parent reply other threads:[~2026-12-03 12:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:01 [PATCH] drm/edid: prefer highest refresh mode within native resolution on eDP cengjianeng
2026-12-02 12:18 ` sashiko-bot
2026-12-03 3:47 ` Jianeng Ceng
2026-12-03 3:46 ` [PATCH v2] " cengjianeng
2026-12-03 3:59 ` sashiko-bot
2026-12-03 12:01 ` Jani Nikula [this message]
2026-12-03 12:27 ` Ville Syrjälä
2026-12-03 12:33 ` Ville Syrjälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=90e1693d5eefc418439d044f6849b6091b5b4e2a@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=cengjianeng@huaqin.corp-partner.google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=dri-misc@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox