drm/amd/display: some backlight fixes
Subsystems (3)
cover drm/amd/display: some backlight fixes
Hi,
here are two patches handling the issues in the backlight control. The first one is to fix the sysfs brightness read for devices with the backlight controlled by aux channel. The second one is to add a new module option, aux_backlight, to forcibly enable/disable the aux channel backlight control. It's no direct solution for the bug we've hit, but it gives at least a workaround.
thanks,
Takashi
===
Takashi Iwai (2):
drm/amd/display: Fix the brightness read via aux drm/amd/display: Add aux_backlight module option
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-)
Signature · 6 lines
2.26.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/2 drm/amd/display: Fix the brightness read via aux
The current code tries to read the brightness value via dc_link_get_backlight_level() no matter whether it's controlled via aux or not, and this results in a bogus value returned. Fix it to read the current value via dc_link_get_backlight_level_nits() for the aux.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16 -1
@@ -3140,6 +3140,16 @@ static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)return rc ?0 :1 ; } +static int get_backlight_via_aux (struct dc_link *link) +{ +uint32_t avg, peak; + +if (!link || + !dc_link_get_backlight_level_nits (link, &avg, &peak)) +return DC_ERROR_UNEXPECTED ; +return avg; +} +static int get_brightness_range (const struct amdgpu_dm_backlight_caps *caps,unsigned *min,unsigned *max) {
@@ -3212,8 +3222,13 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)static int amdgpu_dm_backlight_get_brightness (struct backlight_device *bd) {struct amdgpu_display_manager *dm =bl_get_data (bd); -int ret =dc_link_get_backlight_level (dm->backlight_link); +struct dc_link *link = (struct dc_link *)dm->backlight_link; +int ret; +if (dm->backlight_caps.aux_support) + ret =get_backlight_via_aux (link); +else + ret =dc_link_get_backlight_level (link);if (ret ==DC_ERROR_UNEXPECTED )return bd->props.brightness;return convert_brightness_to_user (&dm->backlight_caps, ret);
Signature · 6 lines
2.26.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 1/2] drm/amd/display: Fix the brightness read via aux
Quoted 10 lines · Takashi Iwai
The current code tries to read the brightness value via
dc_link_get_backlight_level()no matter whether it's controlled via aux or not, and this results in a bogus value returned. Fix it to read the current value viadc_link_get_backlight_level_nits()for the aux.
This looks fine to me. FWIW, I have a similar patch set here:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=backlight_wip
Alex
Quoted 43 lines
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16
-2@@ -3140,6 +3140,16 @@ static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)return rc ?0 :1 ; } +static int get_backlight_via_aux (struct dc_link *link) +{ +uint32_t avg, peak; + +if (!link || + !dc_link_get_backlight_level_nits (link, &avg, &peak)) +return DC_ERROR_UNEXPECTED ; +return avg; +} +static int get_brightness_range (const struct amdgpu_dm_backlight_caps *caps,unsigned *min,unsigned *max) {@@ -3212,8 +3222,13 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)static int amdgpu_dm_backlight_get_brightness (struct backlight_device *bd) {struct amdgpu_display_manager *dm =bl_get_data (bd); -int ret =dc_link_get_backlight_level (dm->backlight_link); +struct dc_link *link = (struct dc_link *)dm->backlight_link; +int ret; +if (dm->backlight_caps.aux_support) + ret =get_backlight_via_aux (link); +else + ret =dc_link_get_backlight_level (link);if (ret ==DC_ERROR_UNEXPECTED )return bd->props.brightness;return convert_brightness_to_user (&dm->backlight_caps, ret); --2.26.2
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm/amd/display: Fix the brightness read via aux
Quoted 9 lines · Alex Deucher
Quoted 7 lines · Takashi Iwai
The current code tries to read the brightness value via
dc_link_get_backlight_level()no matter whether it's controlled via aux or not, and this results in a bogus value returned. Fix it to read the current value viadc_link_get_backlight_level_nits()for the aux.
Quoted 6 lines
Quoted 3 lines
This looks fine to me. FWIW, I have a similar patch set here:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=backlight_wip
I'm fine to scratch mine as long as the issue gets fixed :)
FWIW, the biggest problem so far was the aux channel backlight didn't work as expected, the actual backlight isn't changed by the backlight sysfs write. (And the sysfs read gives a bogus value, but it's not the cause of the non-working backlight control.)
Does the aux channel backlight really work with the current code? Or is this rather a device-specific issue (e.g. broken BIOS) and we might need to come up with a deny list or such?
thanks,
Takashi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Deucher, Alexander
maintainerRE: [PATCH 1/2] drm/amd/display: Fix the brightness read via aux
[AMD Public Use]
Quoted 82 lines
-----Original Message-----
From: Takashi Iwai <[email protected]>
Sent: Saturday, February 6, 2021 7:29 AM
To: Alex Deucher <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Wentland, Harry <[email protected]>; Maling list - DRI developers <[email protected]>; amd-gfx list <amd- [email protected]>
Subject: Re: [PATCH 1/2] drm/amd/display: Fix the brightness read via auxQuoted 11 lines · Alex Deucher
Quoted 9 lines · Takashi Iwai
The current code tries to read the brightness value via
dc_link_get_backlight_level()no matter whether it's controlled via aux or not, and this results in a bogus value returned. Fix it to read the current value viadc_link_get_backlight_level_nits()for the aux.BugLink:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbu
Quoted 1 line
Quoted 1 line
gzilla.opensuse.org%2Fshow_bug.cgi%3Fid%3D1180749&data=04%7C01 %7
Quoted 1 line
Quoted 1 line
Calexander.deucher%40amd.com%7Ce5579cfe56f74b572f1508d8ca9ad0ac%7 C3d
Quoted 1 line
Quoted 1 line
d8961fe4884e608e11a82d994e183d%7C0%7C0%7C637482113562863043%7CU nknow
Quoted 1 line
Quoted 1 line
n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha Wwi
Quoted 1 line
Quoted 1 line
LCJXVCI6Mn0%3D%7C1000&sdata=HVtqM2r6oxSWd3XGGQZotO8wrvM qCTcwfq1L
Quoted 3 lines
Quoted 3 lines
2%2FeCmSE%3D&reserved=0
BugLink:https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgi
Quoted 1 line
Quoted 1 line
tlab.freedesktop.org%2Fdrm%2Famd%2F-
%2Fissues%2F1438&data=04%7C0
Quoted 1 line
Quoted 1 line
1%7Calexander.deucher%40amd.com%7Ce5579cfe56f74b572f1508d8ca9ad0 ac%7
Quoted 1 line
Quoted 1 line
C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637482113562863043% 7CUnk
Quoted 1 line
Quoted 1 line
nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6I k1ha
Quoted 1 line
Quoted 1 line
WwiLCJXVCI6Mn0%3D%7C1000&sdata=TdYgwNJ%2FvkuoDLNb9ATFb1P yznlp%2F
Quoted 6 lines
Quoted 2 lines
P8TLuYSR%2BVkNqY%3D&reserved=0
Signed-off-by Takashi Iwai <[email protected]>This looks fine to me. FWIW, I have a similar patch set here:
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~agd5f%2Flinux%2Flog%2F%3Fh%3Dbacklight_wip& data=
Quoted 1 line
04%7C01%7Calexander.deucher%40amd.com%7Ce5579cfe56f74b572f1508d8 ca9ad0
Quoted 1 line
ac%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637482113562863 043%7CU
Quoted 1 line
nknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI 6Ik1ha
Quoted 1 line
WwiLCJXVCI6Mn0%3D%7C1000&sdata=aoMSY0nvHjrLocUPJtdgckqIH7x LUPbwpH0
Quoted 1 line
ZjhuuJO8%3D&reserved=0
I'm fine to scratch mine as long as the issue gets fixed :)
Quoted 9 lines
FWIW, the biggest problem so far was the aux channel backlight didn't work as expected, the actual backlight isn't changed by the backlight sysfs write. (And the sysfs read gives a bogus value, but it's not the cause of the non- working backlight control.)
Does the aux channel backlight really work with the current code? Or is this rather a device-specific issue (e.g. broken BIOS) and we might need to come up with a deny list or such?
@Kazlauskas, Nicholas, @Siqueira, Rodrigo
Has there been any progress on the backlight fixes?
Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amd/display: Add aux_backlight module option
In reply to Takashi IwaiThere seem devices that don't work with the aux channel backlight control. For allowing such users to test with the other backlight control method, provide a new module option, aux_backlight, to specify enabling or disabling the aux backport support explicitly. As default, the aux support is detected by the hardware capability.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 3 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -179,6 +179,7 @@ extern uint amdgpu_smu_memory_pool_size;extern uint amdgpu_dc_feature_mask;extern uint amdgpu_dc_debug_mask;extern uint amdgpu_dm_abm_level; +extern int amdgpu_aux_backlight;extern struct amdgpu_mgpu_info mgpu_info;extern int amdgpu_ras_enable;extern uint amdgpu_ras_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -0
@@ -777,6 +777,10 @@ uint amdgpu_dm_abm_level;MODULE_PARM_DESC (abmlevel,"ABM level (0 = off (default), 1-4 = backlight reduction level) " );module_param_named (abmlevel, amdgpu_dm_abm_level, uint,0444 ); +int amdgpu_aux_backlight =-1 ; +MODULE_PARM_DESC (aux_backlight,"Aux backlight control (0 = off, 1 = on, default auto)" ); +module_param_named (aux_backlight, amdgpu_aux_backlight, bint,0444 ); +/** * DOC: tmz (int) * Trusted Memory Zone (TMZ) is a method to protect data being written
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
@@ -2209,6 +2209,9 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector) caps->ext_caps->bits.hdr_aux_backlight_control == 1) caps->aux_support = true; +if (amdgpu_aux_backlight >=0 ) + caps->aux_support = amdgpu_aux_backlight; +/* From the specification (CTA-861-G), for calculating the maximum * luminance we need to use: * Luminance = 50*2**(CV/32)
Signature · 6 lines
2.26.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amd/display: Add aux_backlight module option
Quoted 33 lines · Takashi Iwai
There seem devices that don't work with the aux channel backlight control. For allowing such users to test with the other backlight control method, provide a new module option,
aux_backlight, to specify enabling or disabling the aux backport support explicitly. As default, the aux support is detected by the hardware capability.Signed-off-by Takashi Iwai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 3 files changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -179,6 +179,7 @@ extern uint amdgpu_smu_memory_pool_size;extern uint amdgpu_dc_feature_mask;extern uint amdgpu_dc_debug_mask;extern uint amdgpu_dm_abm_level; +extern int amdgpu_aux_backlight;extern struct amdgpu_mgpu_info mgpu_info;extern int amdgpu_ras_enable;extern uint amdgpu_ras_mask;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c uint amdgpu_dm_abm_level; · line 782
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -777,6 +777,10 @@ uint amdgpu_dm_abm_level;MODULE_PARM_DESC (abmlevel,"ABM level (0 = off (default), 1-4 = backlight reduction level) " );module_param_named (abmlevel, amdgpu_dm_abm_level, uint,0444 ); +int amdgpu_aux_backlight =-1 ; +MODULE_PARM_DESC (aux_backlight,"Aux backlight control (0 = off, 1 = on, default auto)" ); +module_param_named (aux_backlight, amdgpu_aux_backlight, bint,0444 );
I'd suggest making this something more generic like "backlight" and make -1 auto, 0 pwm, 1 aux. That way we can handle potential future types more cleanly.
Alex
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0+/** * DOC: tmz (int) * Trusted Memory Zone (TMZ) is a method to protect data being written drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-1@@ -2209,6 +2209,9 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector) caps->ext_caps->bits.hdr_aux_backlight_control == 1) caps->aux_support = true; +if (amdgpu_aux_backlight >=0 ) + caps->aux_support = amdgpu_aux_backlight; +/* From the specification (CTA-861-G), for calculating the maximum * luminance we need to use: * Luminance = 50*2**(CV/32) -- 2.26.2
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amd/display: Add aux_backlight module option
Quoted 38 lines · Alex Deucher
Quoted 36 lines · Takashi Iwai
There seem devices that don't work with the aux channel backlight control. For allowing such users to test with the other backlight control method, provide a new module option,
aux_backlight, to specify enabling or disabling the aux backport support explicitly. As default, the aux support is detected by the hardware capability.Signed-off-by Takashi Iwai <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 3 files changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -179,6 +179,7 @@ extern uint amdgpu_smu_memory_pool_size;extern uint amdgpu_dc_feature_mask;extern uint amdgpu_dc_debug_mask;extern uint amdgpu_dm_abm_level; +extern int amdgpu_aux_backlight;extern struct amdgpu_mgpu_info mgpu_info;extern int amdgpu_ras_enable;extern uint amdgpu_ras_mask;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0@@ -777,6 +777,10 @@ uint amdgpu_dm_abm_level;MODULE_PARM_DESC (abmlevel,"ABM level (0 = off (default), 1-4 = backlight reduction level) " );module_param_named (abmlevel, amdgpu_dm_abm_level, uint,0444 );
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c uint amdgpu_dm_abm_level; · line 782
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0+int amdgpu_aux_backlight =-1 ; +MODULE_PARM_DESC (aux_backlight,"Aux backlight control (0 = off, 1 = on, default auto)" ); +module_param_named (aux_backlight, amdgpu_aux_backlight, bint,0444 );I'd suggest making this something more generic like "backlight" and make -1 auto, 0 pwm, 1 aux. That way we can handle potential future types more cleanly.
OK, will respin later.
thanks,
Takashi
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx