From: Mario Limonciello <mario.limonciello@amd.com>
To: Antheas Kapenekakis <lkml@antheas.dev>, amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
philm@manjaro.org, "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH v1 2/5] drm: panel-backlight-quirks: Convert brightness quirk to generic structure
Date: Mon, 25 Aug 2025 12:53:09 -0500 [thread overview]
Message-ID: <a411d5f9-8764-428f-9ffe-33d0fb2639e3@amd.com> (raw)
In-Reply-To: <20250824200202.1744335-3-lkml@antheas.dev>
On 8/24/2025 3:01 PM, Antheas Kapenekakis wrote:
> Currently, the brightness quirk is limited to minimum brightness only.
> Refactor it to a structure, so that more quirks can be added in the
> future. Reserve 0 value for "no quirk", and use u16 to allow minimum
> brightness up to 255.
>
> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
'Conceptually' this idea makes sense to me if we do end up having a need
for new types of quirks besides minimum brightness.
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++--
> .../link/protocols/link_edp_panel_control.c | 2 +-
> drivers/gpu/drm/drm_panel_backlight_quirks.c | 41 ++++++++++---------
> include/drm/drm_utils.h | 7 +++-
> 4 files changed, 36 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index cd0e2976e268..4ad80ae615a2 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3612,11 +3612,11 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
>
> static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
> {
> + const struct drm_panel_backlight_quirk *panel_backlight_quirk;
> struct amdgpu_dm_backlight_caps *caps;
> struct drm_connector *conn_base;
> struct amdgpu_device *adev;
> struct drm_luminance_range_info *luminance_range;
> - int min_input_signal_override;
>
> if (aconnector->bl_idx == -1 ||
> aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
> @@ -3656,9 +3656,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
> else
> caps->aux_min_input_signal = 1;
>
> - min_input_signal_override = drm_get_panel_min_brightness_quirk(aconnector->drm_edid);
> - if (min_input_signal_override >= 0)
> - caps->min_input_signal = min_input_signal_override;
> + panel_backlight_quirk =
> + drm_get_panel_backlight_quirk(aconnector->drm_edid);
> + if (!IS_ERR_OR_NULL(panel_backlight_quirk)) {
> + if (panel_backlight_quirk->min_brightness)
> + caps->min_input_signal =
> + panel_backlight_quirk->min_brightness - 1;
> + }
> }
>
> DEFINE_FREE(sink_release, struct dc_sink *, if (_T) dc_sink_release(_T))
> diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
> index e7927b8f5ba3..a1f37267b85e 100644
> --- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
> +++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
> @@ -201,7 +201,7 @@ bool edp_set_backlight_level_nits(struct dc_link *link,
> return false;
> } else if (link->backlight_control_type == BACKLIGHT_CONTROL_AMD_AUX) {
> struct dpcd_source_backlight_set dpcd_backlight_set;
> - *(uint32_t *)&dpcd_backlight_set.backlight_level_millinits = backlight_millinits;
> + *(uint32_t *)&dpcd_backlight_set.backlight_level_millinits = backlight_millinits | 3;
This seems like a spurious change that was perhaps meant to be tied to a
new conceptual quirk.
> *(uint16_t *)&dpcd_backlight_set.backlight_transition_time_ms = (uint16_t)transition_time_in_ms;
>
> uint8_t backlight_control = isHDR ? 1 : 0;
> diff --git a/drivers/gpu/drm/drm_panel_backlight_quirks.c b/drivers/gpu/drm/drm_panel_backlight_quirks.c
> index b38b33e26ea5..702726c20ccc 100644
> --- a/drivers/gpu/drm/drm_panel_backlight_quirks.c
> +++ b/drivers/gpu/drm/drm_panel_backlight_quirks.c
> @@ -8,23 +8,23 @@
> #include <drm/drm_edid.h>
> #include <drm/drm_utils.h>
>
> -struct drm_panel_min_backlight_quirk {
> +struct drm_get_panel_backlight_quirk {
> struct {
> enum dmi_field field;
> const char * const value;
> } dmi_match;
> struct drm_edid_ident ident;
> - u8 min_brightness;
> + struct drm_panel_backlight_quirk quirk;
> };
>
> -static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks[] = {
> +static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks[] = {
> /* 13 inch matte panel */
> {
> .dmi_match.field = DMI_BOARD_VENDOR,
> .dmi_match.value = "Framework",
> .ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0bca),
> .ident.name = "NE135FBM-N41",
> - .min_brightness = 0,
> + .quirk = { .min_brightness = 1, },
> },
> /* 13 inch glossy panel */
> {
> @@ -32,7 +32,7 @@ static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks
> .dmi_match.value = "Framework",
> .ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x095f),
> .ident.name = "NE135FBM-N41",
> - .min_brightness = 0,
> + .quirk = { .min_brightness = 1, },
> },
> /* 13 inch 2.8k panel */
> {
> @@ -40,12 +40,13 @@ static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks
> .dmi_match.value = "Framework",
> .ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0cb4),
> .ident.name = "NE135A1M-NY1",
> - .min_brightness = 0,
> + .quirk = { .min_brightness = 1, },
> },
> };
>
> -static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_backlight_quirk *quirk,
> - const struct drm_edid *edid)
> +static bool drm_panel_min_backlight_quirk_matches(
> + const struct drm_get_panel_backlight_quirk *quirk,
> + const struct drm_edid *edid)
> {
> if (!dmi_match(quirk->dmi_match.field, quirk->dmi_match.value))
> return false;
> @@ -57,39 +58,39 @@ static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_bac
> }
>
> /**
> - * drm_get_panel_min_brightness_quirk - Get minimum supported brightness level for a panel.
> + * drm_get_panel_backlight_quirk - Get backlight quirks for a panel
> * @edid: EDID of the panel to check
> *
> * This function checks for platform specific (e.g. DMI based) quirks
> * providing info on the minimum backlight brightness for systems where this
> - * cannot be probed correctly from the hard-/firm-ware.
> + * cannot be probed correctly from the hard-/firm-ware and other sources.
> *
> * Returns:
> - * A negative error value or
> - * an override value in the range [0, 255] representing 0-100% to be scaled to
> - * the drivers target range.
> + * a drm_panel_backlight_quirk struct if a quirk was found, otherwise an
> + * error pointer.
> */
> -int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid)
> +const struct drm_panel_backlight_quirk *
> +drm_get_panel_backlight_quirk(const struct drm_edid *edid)
> {
> - const struct drm_panel_min_backlight_quirk *quirk;
> + const struct drm_get_panel_backlight_quirk *quirk;
> size_t i;
>
> if (!IS_ENABLED(CONFIG_DMI))
> - return -ENODATA;
> + return ERR_PTR(-ENODATA);
>
> if (!edid)
> - return -EINVAL;
> + return ERR_PTR(-EINVAL);
>
> for (i = 0; i < ARRAY_SIZE(drm_panel_min_backlight_quirks); i++) {
> quirk = &drm_panel_min_backlight_quirks[i];
>
> if (drm_panel_min_backlight_quirk_matches(quirk, edid))
> - return quirk->min_brightness;
> + return &quirk->quirk;
> }
>
> - return -ENODATA;
> + return ERR_PTR(-ENODATA);
> }
> -EXPORT_SYMBOL(drm_get_panel_min_brightness_quirk);
> +EXPORT_SYMBOL(drm_get_panel_backlight_quirk);
>
> MODULE_DESCRIPTION("Quirks for panel backlight overrides");
> MODULE_LICENSE("GPL");
> diff --git a/include/drm/drm_utils.h b/include/drm/drm_utils.h
> index 15fa9b6865f4..82eeee4a58ab 100644
> --- a/include/drm/drm_utils.h
> +++ b/include/drm/drm_utils.h
> @@ -16,7 +16,12 @@ struct drm_edid;
>
> int drm_get_panel_orientation_quirk(int width, int height);
>
> -int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid);
> +struct drm_panel_backlight_quirk {
> + u16 min_brightness;
> +};
> +
> +const struct drm_panel_backlight_quirk *
> +drm_get_panel_backlight_quirk(const struct drm_edid *edid);
>
> signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec);
>
next prev parent reply other threads:[~2025-08-25 17:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-24 20:01 [PATCH v1 0/5] drm: panel-backlight-quirks: Do partial refactor and apply OLED fix Antheas Kapenekakis
2025-08-24 20:01 ` [PATCH v1 1/5] drm: panel-backlight-quirks: Make ident optional Antheas Kapenekakis
2025-08-24 20:01 ` [PATCH v1 2/5] drm: panel-backlight-quirks: Convert brightness quirk to generic structure Antheas Kapenekakis
2025-08-25 17:53 ` Mario Limonciello [this message]
2025-08-26 12:29 ` Philip Müller
2025-08-24 20:02 ` [PATCH v1 3/5] drm: panel-backlight-quirks: Add secondary DMI match Antheas Kapenekakis
2025-08-26 12:29 ` Philip Müller
2025-08-24 20:02 ` [PATCH v1 4/5] drm: panel-backlight-quirks: Add brightness mask quirk Antheas Kapenekakis
2025-08-25 18:02 ` Mario Limonciello
2025-08-25 21:17 ` Antheas Kapenekakis
2025-08-25 21:22 ` Mario Limonciello
2025-08-25 21:26 ` Antheas Kapenekakis
2025-08-26 12:28 ` Philip Müller
2025-08-24 20:02 ` [PATCH v1 5/5] drm: panel-backlight-quirks: Add Steam Decks Antheas Kapenekakis
2025-08-25 16:47 ` Mario Limonciello
2025-08-25 21:02 ` Antheas Kapenekakis
2025-08-25 21:05 ` Mario Limonciello
2025-08-25 21:20 ` Antheas Kapenekakis
2025-08-26 11:38 ` Robert Beckett
2025-08-25 16:45 ` [PATCH v1 0/5] drm: panel-backlight-quirks: Do partial refactor and apply OLED fix Mario Limonciello
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=a411d5f9-8764-428f-9ffe-33d0fb2639e3@amd.com \
--to=mario.limonciello@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@antheas.dev \
--cc=philm@manjaro.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
all inboxes | Powered by JetHome®