lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a411d5f9-8764-428f-9ffe-33d0fb2639e3@amd.com>
Date: Mon, 25 Aug 2025 12:53:09 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Antheas Kapenekakis <lkml@...heas.dev>, amd-gfx@...ts.freedesktop.org
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
 philm@...jaro.org, Alex Deucher <alexander.deucher@....com>,
 Christian König <christian.koenig@....com>
Subject: Re: [PATCH v1 2/5] drm: panel-backlight-quirks: Convert brightness
 quirk to generic structure

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@...heas.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);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ