From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43DDB606A32C for ; Thu, 3 Dec 2026 12:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=P4sUjmoK Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D0A510E652; Thu, 3 Dec 2026 12:27:37 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31C9B10E6ED; Thu, 3 Dec 2026 12:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796300851; x=1827836851; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=yexH/7RwvMetbDFmP/h2T75m7O3XRoF1xEgMe/kt+6k=; b=P4sUjmoKiLKq2x+S9Zn6dUPqTbxihM/H6/B9NZ38DCNi3POa6ejAtu9m fasqPSTkwpmNLKvQH5M4re2D4w8reOxrd26SLQFmDVri5ggWNWyTGCJ3e hzOcp6uqBw/UDUeC/6iwgdUhydRGJxg9I/lMm5BKJ1GcJMn0rokRmZvFc L7/CWjimzA4nqxUz7JdEPtAnY3wqrFepT71SKJl6qmumsF2FY0hcYjW6P 9UrdnVGgXr+ntjqzoNtmDVCBdCufK1kdumhFHri5zUAG3mRg+Sk9uHk+T yZIfeccXsiS0OuBjSL7xHyrWKEFCcI/4U2yGaab9jfJ6GHaZm9kDLZuDi Q==; X-CSE-ConnectionGUID: rkuoiwOqR++6e8dW7aDa7g== X-CSE-MsgGUID: /1U2JVDKRaqdld3EfmxkWw== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5157026" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5157026" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:27:31 -0800 X-CSE-ConnectionGUID: 88Y+6Dt5SZut5apzUfw0DQ== X-CSE-MsgGUID: ANelyXiRQKmTK58/MnDwlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="13983900" Received: from abityuts-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.117]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 04:27:30 -0800 Date: Thu, 3 Dec 2026 14:27:25 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: cengjianeng Cc: dri-devel@lists.freedesktop.org, dri-misc@lists.freedesktop.org Subject: Re: [PATCH v2] drm/edid: prefer highest refresh mode within native resolution on eDP Message-ID: References: <20261202120153.1051508-1-cengjianeng@huaqin.corp-partner.google.com> <20261203034601.675116-1-cengjianeng@huaqin.corp-partner.google.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261203034601.675116-1-cengjianeng@huaqin.corp-partner.google.com> X-Patchwork-Hint: comment Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 03, 2026 at 11:46:01AM +0800, cengjianeng wrote: > From: Jianeng Ceng > > 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 one thing we're missing is considering the DisplayID vs. EDID factor in the selection of the preferred mode. IIRC DisplayID is maybe supposed to take precedence over the EDID, at least in some cases. And IIRC there is also some kind of mode preference EDID block that we're not using. It seems to me that this patch would basically amount to just removing the idea of the preferred mode completely, and just picking the first mode from the sorted list. > > 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 > --- > 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; > } > -- Ville Syrjälä Intel