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 <[email protected]>
Tested-by: Alessandro Rinaldi <[email protected]>
---
This overlaps with the "force backlight type" patches for TUXEDO devices
(amd and i915). If a single shared mechanism for forcing PWM is preferred,
I'm happy to respin on top of it.

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c  | 7 +++++--
 drivers/gpu/drm/drm_panel_backlight_quirks.c             | 9 +++++++++
 include/drm/drm_utils.h                                  | 1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
index f19092a32..9ae1c1b0f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
@@ -486,6 +486,8 @@ void amdgpu_dm_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
            /*
             * ||
@@ -498,6 +500,9 @@ void amdgpu_dm_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;
 
@@ -513,8 +518,6 @@ void amdgpu_dm_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 537dc6dd0..2d0238382 100644
--- a/drivers/gpu/drm/drm_panel_backlight_quirks.c
+++ b/drivers/gpu/drm/drm_panel_backlight_quirks.c
@@ -21,6 +21,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 6a46f755d..7e077484c 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 *
-- 
2.53.0


Reply via email to