Backlight fixes
Subsystems (3)
Alex Deucher
maintainercover Backlight fixes
This builds on the debugging and patches that Takashi did on the bugs referenced in the patches. It seems some latops claim to support aux backlight control, but actually use the old pwm controller.
The code also currently warns in the backlight control function if there is no pipe assigned, but this is a common case if the display happens to be off when the backlight level is changed and it just spams the logs, so remove it.
This set wires up the aux controller to the backlight control, cleans up the code an bit, removes the assert, and adds an option to override the backlight type.
@Display team, can you check if there are any quirks or differences in the backlight control detection on windows? Presumably this is properly detected there. The systems in question claim to support aux backlight control in their DPCDs, but that doesn't seem to work.
Alex Deucher (3):
drm/amdgpu/display: simplify backlight setting drm/amdgpu/display: don't assert in set backlight function drm/amdgpu/display: handle aux backlight in backlight_get_brightness
Takashi Iwai (1):
drm/amd/display: Add a 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 | 49 +++++++++++-------- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 1 - 4 files changed, 34 insertions(+), 21 deletions(-)
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu/display: simplify backlight setting
Avoid the extra wrapper function.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -16
@@ -3200,19 +3200,6 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)#endif } -static int set_backlight_via_aux (struct dc_link *link,uint32_t brightness) -{ -bool rc; - -if (!link) -return 1 ; - - rc =dc_link_set_backlight_level_nits (link, true, brightness, -AUX_BL_DEFAULT_TRANSITION_TIME_MS ); - -return rc ?0 :1 ; -} -static int get_brightness_range (const struct amdgpu_dm_backlight_caps *caps,unsigned *min,unsigned *max) {
@@ -3275,9 +3262,10 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd) brightness =convert_brightness_from_user (&caps, bd->props.brightness);// Change brightness based on AUX property if (caps.aux_support) -return set_backlight_via_aux (link, brightness); - - rc =dc_link_set_backlight_level (dm->backlight_link, brightness,0 ); + rc =dc_link_set_backlight_level_nits (link, true, brightness, +AUX_BL_DEFAULT_TRANSITION_TIME_MS ); +else + rc =dc_link_set_backlight_level (dm->backlight_link, brightness,0 );return rc ?0 :1 ; }
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu/display: don't assert in set backlight function
In reply to Alex DeucherIt just spams the logs.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0 -1
@@ -2614,7 +2614,6 @@ bool dc_link_set_backlight_level(const struct dc_link *link,if (pipe_ctx->plane_state ==NULL ) frame_ramp =0 ; }else { -ASSERT (false);return false; }
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/4] drm/amdgpu/display: don't assert in set backlight function
Quoted 3 lines · Alex Deucher
It just spams the logs.
Signed-off-by Alex Deucher <[email protected]>
This series in general looks reasonable to me:
drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_set_backlight_level(const struct dc_link *link, · line 2617
Quoted 13 lines
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-1@@ -2614,7 +2614,6 @@ bool dc_link_set_backlight_level(const struct dc_link *link,if (pipe_ctx->plane_state ==NULL ) frame_ramp =0 ; }else { -ASSERT (false);
Just a comment on what's actually going on here with this warning:
Technically we can't apply the backlight level without a plane_state in the context but the panel is also off anyway.
I think there might be a bug here when the panel turns on and we're not applying values set when it was off but I don't think anyone's reported this as an issue.
I'm not entirely sure if the value gets cached and reapplied with the correct value later, but it's something to keep in mind.
Regards,
Nicholas Kazlauskas
drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_set_backlight_level(const struct dc_link *link, · line 2619
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-0return false; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/4] drm/amdgpu/display: don't assert in set backlight function
Quoted 28 lines · Nicholas
Quoted 3 lines · Alex Deucher
It just spams the logs.
Signed-off-by Alex Deucher <[email protected]>This series in general looks reasonable to me:
Reviewed-by Nicholas Kazlauskas <[email protected]>drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_set_backlight_level(const struct dc_link *link, · line 2617
Quoted 13 lines
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-1@@ -2614,7 +2614,6 @@ bool dc_link_set_backlight_level(const struct dc_link *link,if (pipe_ctx->plane_state ==NULL ) frame_ramp =0 ; }else { -ASSERT (false);Just a comment on what's actually going on here with this warning:
Technically we can't apply the backlight level without a
plane_statein the context but the panel is also off anyway.
Quoted 6 lines
I think there might be a bug here when the panel turns on and we're not applying values set when it was off but I don't think anyone's reported this as an issue.
I'm not entirely sure if the value gets cached and reapplied with the correct value later, but it's something to keep in mind.
It doesn't. I have additional patches here to cache it:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=backlight_wip
Alex
Quoted 9 lines
Regards,
Nicholas Kazlauskasdrivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_set_backlight_level(const struct dc_link *link, · line 2619
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-0return false; }
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/4] drm/amdgpu/display: don't assert in set backlight function
Quoted 34 lines · Alex Deucher
Quoted 32 lines · Nicholas
Quoted 3 lines · Alex Deucher
It just spams the logs.
Signed-off-by Alex Deucher <[email protected]>This series in general looks reasonable to me:
Reviewed-by Nicholas Kazlauskas <[email protected]>drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_set_backlight_level(const struct dc_link *link, · line 2617
Quoted 13 lines
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 1 - 1 file changed, 1 deletion(-)drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-1@@ -2614,7 +2614,6 @@ bool dc_link_set_backlight_level(const struct dc_link *link,if (pipe_ctx->plane_state ==NULL ) frame_ramp =0 ; }else { -ASSERT (false);Just a comment on what's actually going on here with this warning:
Technically we can't apply the backlight level without a
plane_statein the context but the panel is also off anyway.I think there might be a bug here when the panel turns on and we're not applying values set when it was off but I don't think anyone's reported this as an issue.
Quoted 7 lines
Quoted 2 lines
I'm not entirely sure if the value gets cached and reapplied with the correct value later, but it's something to keep in mind.
It doesn't. I have additional patches here to cache it:
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~agd5f%2Flinux%2Flog%2F%3Fh%3Dbacklight_wip&data=04%7C01%7Cnicholas.kazlauskas%40amd.com%7Cf259e9290b0e4ffbc87308d8df3d3121%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637504801203988045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4ROSclecKkfu2km3YeeM7sZK%2FP%2BcC8BajHSxJXQQCRw%3D&reserved=0Alex
That's aligned with my expectations then.
I can take a peek at the branch and help review the patches.
Regards,
Nicholas Kazlauskas
Quoted 10 lines
Quoted 10 lines
Regards,
Nicholas KazlauskasQuoted 4 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +0
-0return false; }
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cnicholas.kazlauskas%40amd.com%7Cf259e9290b0e4ffbc87308d8df3d3121%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637504801203988045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2BbwO5oOXuXFWD%2F8qNTygROj%2B9ZItRsXJb1U7ilcICh4%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu/display: handle aux backlight in backlight_get_brightness
In reply to Alex DeucherNeed to fetch it via aux.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +20 -4
@@ -3273,11 +3273,27 @@ 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 amdgpu_dm_backlight_caps caps; + +amdgpu_dm_update_backlight_caps (dm); + caps = dm->backlight_caps; -if (ret ==DC_ERROR_UNEXPECTED ) -return bd->props.brightness; -return convert_brightness_to_user (&dm->backlight_caps, ret); +if (caps.aux_support) { +struct dc_link *link = (struct dc_link *)dm->backlight_link; +u32 avg, peak; +bool rc; + + rc =dc_link_get_backlight_level_nits (link, &avg, &peak); +if (!rc) +return bd->props.brightness; +return convert_brightness_to_user (&caps, avg); + }else { +int ret =dc_link_get_backlight_level (dm->backlight_link); + +if (ret ==DC_ERROR_UNEXPECTED ) +return bd->props.brightness; +return convert_brightness_to_user (&caps, ret); + } }static const struct backlight_ops amdgpu_dm_backlight_ops = {
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 4/4 drm/amd/display: Add a backlight module option
In reply to Alex DeucherFrom: Takashi Iwai <[email protected]>
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.
v2: make the backlight option generic in case we add future backlight types (Alex)
--- 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 | 5 +++++ 3 files changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -181,6 +181,7 @@ extern uint amdgpu_dc_feature_mask;extern uint amdgpu_freesync_vid_mode;extern uint amdgpu_dc_debug_mask;extern uint amdgpu_dm_abm_level; +extern int amdgpu_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
@@ -784,6 +784,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_backlight =-1 ; +MODULE_PARM_DESC (backlight,"Backlight control (0 = pwm, 1 = aux, -1 auto (default))" ); +module_param_named (backlight, amdgpu_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 +5 -0
@@ -2282,6 +2282,11 @@ 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_backlight ==0 ) + caps->aux_support = false; +else if (amdgpu_backlight ==1 ) + caps->aux_support = true; +/* From the specification (CTA-861-G), for calculating the maximum * luminance we need to use: * Luminance = 50*2**(CV/32)
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx