Commit bad177fa75e6 for kernel

commit bad177fa75e607e396cd57daaaed881450d7a471
Author: Alessandro Rinaldi <ale@alerinaldi.it>
Date:   Fri Jun 26 16:36:00 2026 +0200

    drm/amd/display: Force PWM backlight on Lenovo Legion 5 15ARH05

    The Lenovo Legion 5 15ARH05 (Renoir) ships a BOE 0x08DF eDP panel that
    advertises AUX/DPCD backlight control, so amdgpu's automatic detection
    (amdgpu_backlight == -1) selects AUX. On this panel the AUX backlight
    path has no effect: brightness writes are accepted but the panel level
    never changes, the display is stuck at a fixed brightness and
    max_brightness is reported as a bogus 511000. As a result neither the
    desktop brightness slider nor the brightness hotkeys do anything.

    Forcing PWM backlight (amdgpu.backlight=0) restores working control:
    max_brightness becomes 65535 and the level tracks writes. This has long
    been applied by users as a manual kernel-parameter workaround.

    Extend the generic panel backlight quirk with a force_pwm flag, add an
    entry for the Legion 5 15ARH05 / BOE 0x08DF panel, and have amdgpu
    disable AUX backlight (use PWM) when the quirk matches and the user
    lets the driver auto-select the backlight type.

    Signed-off-by: Alessandro Rinaldi <ale@alerinaldi.it>
    Tested-by: Alessandro Rinaldi <ale@alerinaldi.it>
    Reviewed-by: George Zhang <george.zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    (cherry picked from commit 81b39f43e7e53589491e2eef6bad5389626b4b9c)
    Cc: stable@vger.kernel.org

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 fe6eea28d119..6210a1ff7cc2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4069,6 +4069,8 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 	caps->ext_caps = &aconnector->dc_link->dpcd_sink_ext_caps;
 	caps->aux_support = false;

+	panel_backlight_quirk = drm_get_panel_backlight_quirk(aconnector->drm_edid);
+
 	if (caps->ext_caps->bits.oled == 1
 	    /*
 	     * ||
@@ -4081,6 +4083,9 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 		caps->aux_support = false;
 	else if (amdgpu_backlight == 1)
 		caps->aux_support = true;
+	else if (!IS_ERR_OR_NULL(panel_backlight_quirk) &&
+		 panel_backlight_quirk->force_pwm)
+		caps->aux_support = false;
 	if (caps->aux_support)
 		aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;

@@ -4096,8 +4101,6 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 	else
 		caps->aux_min_input_signal = 1;

-	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 =
diff --git a/drivers/gpu/drm/drm_panel_backlight_quirks.c b/drivers/gpu/drm/drm_panel_backlight_quirks.c
index f85cb293a3db..e417c7533053 100644
--- a/drivers/gpu/drm/drm_panel_backlight_quirks.c
+++ b/drivers/gpu/drm/drm_panel_backlight_quirks.c
@@ -20,6 +20,15 @@ struct drm_get_panel_backlight_quirk {
 };

 static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks[] = {
+	/* Lenovo Legion 5 15ARH05, AUX backlight non-functional, force PWM */
+	{
+		.dmi_match.field = DMI_SYS_VENDOR,
+		.dmi_match.value = "LENOVO",
+		.dmi_match_other.field = DMI_PRODUCT_VERSION,
+		.dmi_match_other.value = "Lenovo Legion 5 15ARH05",
+		.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x08df),
+		.quirk = { .force_pwm = true, },
+	},
 	/* 13 inch matte panel */
 	{
 		.dmi_match.field = DMI_BOARD_VENDOR,
diff --git a/include/drm/drm_utils.h b/include/drm/drm_utils.h
index 6a46f755daba..7e077484c5bb 100644
--- a/include/drm/drm_utils.h
+++ b/include/drm/drm_utils.h
@@ -19,6 +19,7 @@ int drm_get_panel_orientation_quirk(int width, int height);
 struct drm_panel_backlight_quirk {
 	u16 min_brightness;
 	u32 brightness_mask;
+	bool force_pwm;
 };

 const struct drm_panel_backlight_quirk *