Skip to content

Commit 1f57925

Browse files
committed
drm/amd/display: update bios scratch when setting backlight
Update the bios scratch register when updating the backlight level. Some platforms apparently read this scratch register and do additional operations in their hotkey handlers. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1518 Reviewed-by: Harry Wentland <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 081664e commit 1f57925

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,18 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
15691569
WREG32(adev->bios_scratch_reg_offset + 3, tmp);
15701570
}
15711571

1572+
void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
1573+
u32 backlight_level)
1574+
{
1575+
u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
1576+
1577+
tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
1578+
tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &
1579+
ATOM_S2_CURRENT_BL_LEVEL_MASK;
1580+
1581+
WREG32(adev->bios_scratch_reg_offset + 2, tmp);
1582+
}
1583+
15721584
bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev)
15731585
{
15741586
u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7);

drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);
185185
void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
186186
void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
187187
bool hung);
188+
void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
189+
u32 backlight_level);
188190
bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);
189191

190192
void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <drm/drm_hdcp.h>
5252
#endif
5353
#include "amdgpu_pm.h"
54+
#include "amdgpu_atombios.h"
5455

5556
#include "amd_shared.h"
5657
#include "amdgpu_dm_irq.h"
@@ -3918,6 +3919,9 @@ static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
39183919
caps = dm->backlight_caps[bl_idx];
39193920

39203921
dm->brightness[bl_idx] = user_brightness;
3922+
/* update scratch register */
3923+
if (bl_idx == 0)
3924+
amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
39213925
brightness = convert_brightness_from_user(&caps, dm->brightness[bl_idx]);
39223926
link = (struct dc_link *)dm->backlight_link[bl_idx];
39233927

0 commit comments

Comments
 (0)