All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: update bios scratch when setting backlight
@ 2021-11-24 16:36 Alex Deucher
  2021-11-24 16:36 ` [PATCH] drm/amd/display: fix 64 bit divide Alex Deucher
  2021-11-24 18:52 ` [PATCH] drm/amd/display: update bios scratch when setting backlight Harry Wentland
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Deucher @ 2021-11-24 16:36 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

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
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c      | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h      |  2 ++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 ++++
 3 files changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 96b7bb13a2dd..12a6b1c99c93 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1569,6 +1569,18 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
 	WREG32(adev->bios_scratch_reg_offset + 3, tmp);
 }
 
+void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
+						      u32 backlight_level)
+{
+	u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
+
+	tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
+	tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &
+		ATOM_S2_CURRENT_BL_LEVEL_MASK;
+
+	WREG32(adev->bios_scratch_reg_offset + 2, tmp);
+}
+
 bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev)
 {
 	u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
index 8cc0222dba19..27e74b1fc260 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
@@ -185,6 +185,8 @@ bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);
 void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
 void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
 					      bool hung);
+void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
+						      u32 backlight_level);
 bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);
 
 void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
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 40a4269770fa..05e4a0952a2b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -51,6 +51,7 @@
 #include <drm/drm_hdcp.h>
 #endif
 #include "amdgpu_pm.h"
+#include "amdgpu_atombios.h"
 
 #include "amd_shared.h"
 #include "amdgpu_dm_irq.h"
@@ -3918,6 +3919,9 @@ static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
 	caps = dm->backlight_caps[bl_idx];
 
 	dm->brightness[bl_idx] = user_brightness;
+	/* update scratch register */
+	if (bl_idx == 0)
+		amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
 	brightness = convert_brightness_from_user(&caps, dm->brightness[bl_idx]);
 	link = (struct dc_link *)dm->backlight_link[bl_idx];
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] drm/amd/display: fix 64 bit divide
  2021-11-24 16:36 [PATCH] drm/amd/display: update bios scratch when setting backlight Alex Deucher
@ 2021-11-24 16:36 ` Alex Deucher
  2021-11-24 18:37   ` Guo, Bing
  2021-11-24 21:07   ` Randy Dunlap
  2021-11-24 18:52 ` [PATCH] drm/amd/display: update bios scratch when setting backlight Harry Wentland
  1 sibling, 2 replies; 7+ messages in thread
From: Alex Deucher @ 2021-11-24 16:36 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Bing Guo, Randy Dunlap, kernel test robot

Use do_div.

Fixes: c34f1652a18c4b ("drm/amd/display: fixed an error related to 4:2:0/4:2:2 DSC")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Bing Guo <Bing.Guo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
index 381561ee0026..7e306aa3e2b9 100644
--- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
+++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
@@ -100,6 +100,7 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
 	int              ret;
 	struct rc_params rc;
 	struct drm_dsc_config   dsc_cfg;
+	unsigned long long tmp;
 
 	calc_rc_params(&rc, pps);
 	dsc_params->pps = *pps;
@@ -111,9 +112,9 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
 	dsc_cfg.mux_word_size = dsc_params->pps.bits_per_component <= 10 ? 48 : 64;
 
 	ret = drm_dsc_compute_rc_parameters(&dsc_cfg);
-	dsc_params->bytes_per_pixel =
-			(uint32_t)(((unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1))
-							/ (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
+	tmp = (unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1);
+	do_div(tmp, (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
+	dsc_params->bytes_per_pixel = (uint32_t)tmp;
 
 	copy_pps_fields(&dsc_params->pps, &dsc_cfg);
 	dsc_params->rc_buffer_model_size = dsc_cfg.rc_bits;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] drm/amd/display: fix 64 bit divide
  2021-11-24 16:36 ` [PATCH] drm/amd/display: fix 64 bit divide Alex Deucher
@ 2021-11-24 18:37   ` Guo, Bing
  2021-11-24 21:07   ` Randy Dunlap
  1 sibling, 0 replies; 7+ messages in thread
From: Guo, Bing @ 2021-11-24 18:37 UTC (permalink / raw)
  To: Deucher, Alexander, amd-gfx; +Cc: Randy Dunlap, kernel test robot

[AMD Official Use Only]

Reviewed-by: Bing Guo < <Bing.Guo@amd.com >

-----Original Message-----
From: Deucher, Alexander <Alexander.Deucher@amd.com> 
Sent: Wednesday, November 24, 2021 11:36 AM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; kernel test robot <lkp@intel.com>; Randy Dunlap <rdunlap@infradead.org>; Guo, Bing <Bing.Guo@amd.com>
Subject: [PATCH] drm/amd/display: fix 64 bit divide

Use do_div.

Fixes: c34f1652a18c4b ("drm/amd/display: fixed an error related to 4:2:0/4:2:2 DSC")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Bing Guo <Bing.Guo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
index 381561ee0026..7e306aa3e2b9 100644
--- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
+++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
@@ -100,6 +100,7 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
 	int              ret;
 	struct rc_params rc;
 	struct drm_dsc_config   dsc_cfg;
+	unsigned long long tmp;
 
 	calc_rc_params(&rc, pps);
 	dsc_params->pps = *pps;
@@ -111,9 +112,9 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
 	dsc_cfg.mux_word_size = dsc_params->pps.bits_per_component <= 10 ? 48 : 64;
 
 	ret = drm_dsc_compute_rc_parameters(&dsc_cfg);
-	dsc_params->bytes_per_pixel =
-			(uint32_t)(((unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1))
-							/ (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
+	tmp = (unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1);
+	do_div(tmp, (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
+	dsc_params->bytes_per_pixel = (uint32_t)tmp;
 
 	copy_pps_fields(&dsc_params->pps, &dsc_cfg);
 	dsc_params->rc_buffer_model_size = dsc_cfg.rc_bits;
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: update bios scratch when setting backlight
  2021-11-24 16:36 [PATCH] drm/amd/display: update bios scratch when setting backlight Alex Deucher
  2021-11-24 16:36 ` [PATCH] drm/amd/display: fix 64 bit divide Alex Deucher
@ 2021-11-24 18:52 ` Harry Wentland
  2021-11-24 18:55   ` Alex Deucher
  1 sibling, 1 reply; 7+ messages in thread
From: Harry Wentland @ 2021-11-24 18:52 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx

On 2021-11-24 11:36, Alex Deucher wrote:
> 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
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Maybe dce_driver_set_backlight should handle this but doing this
in amdgpu also works. I don't know if I have a preference either
way.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c      | 12 ++++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h      |  2 ++
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 ++++
>  3 files changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> index 96b7bb13a2dd..12a6b1c99c93 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> @@ -1569,6 +1569,18 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
>  	WREG32(adev->bios_scratch_reg_offset + 3, tmp);
>  }
>  
> +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
> +						      u32 backlight_level)
> +{
> +	u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
> +
> +	tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
> +	tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &
> +		ATOM_S2_CURRENT_BL_LEVEL_MASK;
> +
> +	WREG32(adev->bios_scratch_reg_offset + 2, tmp);
> +}
> +
>  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev)
>  {
>  	u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> index 8cc0222dba19..27e74b1fc260 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> @@ -185,6 +185,8 @@ bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);
>  void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
>  void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
>  					      bool hung);
> +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
> +						      u32 backlight_level);
>  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);
>  
>  void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
> 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 40a4269770fa..05e4a0952a2b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -51,6 +51,7 @@
>  #include <drm/drm_hdcp.h>
>  #endif
>  #include "amdgpu_pm.h"
> +#include "amdgpu_atombios.h"
>  
>  #include "amd_shared.h"
>  #include "amdgpu_dm_irq.h"
> @@ -3918,6 +3919,9 @@ static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
>  	caps = dm->backlight_caps[bl_idx];
>  
>  	dm->brightness[bl_idx] = user_brightness;
> +	/* update scratch register */
> +	if (bl_idx == 0)
> +		amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
>  	brightness = convert_brightness_from_user(&caps, dm->brightness[bl_idx]);
>  	link = (struct dc_link *)dm->backlight_link[bl_idx];
>  
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: update bios scratch when setting backlight
  2021-11-24 18:52 ` [PATCH] drm/amd/display: update bios scratch when setting backlight Harry Wentland
@ 2021-11-24 18:55   ` Alex Deucher
  2021-11-24 18:59     ` Harry Wentland
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Deucher @ 2021-11-24 18:55 UTC (permalink / raw)
  To: Harry Wentland; +Cc: Alex Deucher, amd-gfx list

On Wed, Nov 24, 2021 at 1:52 PM Harry Wentland <harry.wentland@amd.com> wrote:
>
> On 2021-11-24 11:36, Alex Deucher wrote:
> > 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
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>
> Maybe dce_driver_set_backlight should handle this but doing this
> in amdgpu also works. I don't know if I have a preference either
> way.

Might be helpful for other OSes unless they handle the bios scratch
registers some other way.  Also does dce_driver_set_backlight() handle
OLED and aux controlled backlights?

Alex

>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c      | 12 ++++++++++++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h      |  2 ++
> >  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 ++++
> >  3 files changed, 18 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> > index 96b7bb13a2dd..12a6b1c99c93 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
> > @@ -1569,6 +1569,18 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
> >       WREG32(adev->bios_scratch_reg_offset + 3, tmp);
> >  }
> >
> > +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
> > +                                                   u32 backlight_level)
> > +{
> > +     u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
> > +
> > +     tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
> > +     tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &
> > +             ATOM_S2_CURRENT_BL_LEVEL_MASK;
> > +
> > +     WREG32(adev->bios_scratch_reg_offset + 2, tmp);
> > +}
> > +
> >  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev)
> >  {
> >       u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> > index 8cc0222dba19..27e74b1fc260 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
> > @@ -185,6 +185,8 @@ bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);
> >  void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
> >  void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
> >                                             bool hung);
> > +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
> > +                                                   u32 backlight_level);
> >  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);
> >
> >  void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
> > 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 40a4269770fa..05e4a0952a2b 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -51,6 +51,7 @@
> >  #include <drm/drm_hdcp.h>
> >  #endif
> >  #include "amdgpu_pm.h"
> > +#include "amdgpu_atombios.h"
> >
> >  #include "amd_shared.h"
> >  #include "amdgpu_dm_irq.h"
> > @@ -3918,6 +3919,9 @@ static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
> >       caps = dm->backlight_caps[bl_idx];
> >
> >       dm->brightness[bl_idx] = user_brightness;
> > +     /* update scratch register */
> > +     if (bl_idx == 0)
> > +             amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
> >       brightness = convert_brightness_from_user(&caps, dm->brightness[bl_idx]);
> >       link = (struct dc_link *)dm->backlight_link[bl_idx];
> >
> >
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: update bios scratch when setting backlight
  2021-11-24 18:55   ` Alex Deucher
@ 2021-11-24 18:59     ` Harry Wentland
  0 siblings, 0 replies; 7+ messages in thread
From: Harry Wentland @ 2021-11-24 18:59 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Alex Deucher, amd-gfx list



On 2021-11-24 13:55, Alex Deucher wrote:
> On Wed, Nov 24, 2021 at 1:52 PM Harry Wentland <harry.wentland@amd.com> wrote:
>>
>> On 2021-11-24 11:36, Alex Deucher wrote:
>>> 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>>>> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
>>
>> Maybe dce_driver_set_backlight should handle this but doing this
>> in amdgpu also works. I don't know if I have a preference either
>> way.
> 
> Might be helpful for other OSes unless they handle the bios scratch
> registers some other way.  Also does dce_driver_set_backlight() handle
> OLED and aux controlled backlights?
> 

No, that has its own codepath and other OSes tend to always use the ABM
path which uses DMCU/DMUB for programming backlight. I'm not sure if they
let FW handle that or deal with it in the DM for the OS. Hence your approach
is possibly more sensible in amdgpu.

Harry

> Alex
> 
>>
>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>
>> Harry
>>
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c      | 12 ++++++++++++
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h      |  2 ++
>>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 ++++
>>>  3 files changed, 18 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
>>> index 96b7bb13a2dd..12a6b1c99c93 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
>>> @@ -1569,6 +1569,18 @@ void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
>>>       WREG32(adev->bios_scratch_reg_offset + 3, tmp);
>>>  }
>>>
>>> +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
>>> +                                                   u32 backlight_level)
>>> +{
>>> +     u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2);
>>> +
>>> +     tmp &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
>>> +     tmp |= (backlight_level << ATOM_S2_CURRENT_BL_LEVEL_SHIFT) &
>>> +             ATOM_S2_CURRENT_BL_LEVEL_MASK;
>>> +
>>> +     WREG32(adev->bios_scratch_reg_offset + 2, tmp);
>>> +}
>>> +
>>>  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev)
>>>  {
>>>       u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7);
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
>>> index 8cc0222dba19..27e74b1fc260 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
>>> @@ -185,6 +185,8 @@ bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev);
>>>  void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock);
>>>  void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev,
>>>                                             bool hung);
>>> +void amdgpu_atombios_scratch_regs_set_backlight_level(struct amdgpu_device *adev,
>>> +                                                   u32 backlight_level);
>>>  bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev);
>>>
>>>  void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
>>> 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 40a4269770fa..05e4a0952a2b 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -51,6 +51,7 @@
>>>  #include <drm/drm_hdcp.h>
>>>  #endif
>>>  #include "amdgpu_pm.h"
>>> +#include "amdgpu_atombios.h"
>>>
>>>  #include "amd_shared.h"
>>>  #include "amdgpu_dm_irq.h"
>>> @@ -3918,6 +3919,9 @@ static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
>>>       caps = dm->backlight_caps[bl_idx];
>>>
>>>       dm->brightness[bl_idx] = user_brightness;
>>> +     /* update scratch register */
>>> +     if (bl_idx == 0)
>>> +             amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
>>>       brightness = convert_brightness_from_user(&caps, dm->brightness[bl_idx]);
>>>       link = (struct dc_link *)dm->backlight_link[bl_idx];
>>>
>>>
>>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: fix 64 bit divide
  2021-11-24 16:36 ` [PATCH] drm/amd/display: fix 64 bit divide Alex Deucher
  2021-11-24 18:37   ` Guo, Bing
@ 2021-11-24 21:07   ` Randy Dunlap
  1 sibling, 0 replies; 7+ messages in thread
From: Randy Dunlap @ 2021-11-24 21:07 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx; +Cc: Bing Guo, kernel test robot

On 11/24/21 8:36 AM, Alex Deucher wrote:
> Use do_div.
> 
> Fixes: c34f1652a18c4b ("drm/amd/display: fixed an error related to 4:2:0/4:2:2 DSC")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Bing Guo <Bing.Guo@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>   drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> index 381561ee0026..7e306aa3e2b9 100644
> --- a/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> +++ b/drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
> @@ -100,6 +100,7 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
>   	int              ret;
>   	struct rc_params rc;
>   	struct drm_dsc_config   dsc_cfg;
> +	unsigned long long tmp;
>   
>   	calc_rc_params(&rc, pps);
>   	dsc_params->pps = *pps;
> @@ -111,9 +112,9 @@ int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_par
>   	dsc_cfg.mux_word_size = dsc_params->pps.bits_per_component <= 10 ? 48 : 64;
>   
>   	ret = drm_dsc_compute_rc_parameters(&dsc_cfg);
> -	dsc_params->bytes_per_pixel =
> -			(uint32_t)(((unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1))
> -							/ (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
> +	tmp = (unsigned long long)dsc_cfg.slice_chunk_size * 0x10000000 + (dsc_cfg.slice_width - 1);
> +	do_div(tmp, (uint32_t)dsc_cfg.slice_width);  //ROUND-UP
> +	dsc_params->bytes_per_pixel = (uint32_t)tmp;
>   
>   	copy_pps_fields(&dsc_params->pps, &dsc_cfg);
>   	dsc_params->rc_buffer_model_size = dsc_cfg.rc_bits;
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-24 21:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 16:36 [PATCH] drm/amd/display: update bios scratch when setting backlight Alex Deucher
2021-11-24 16:36 ` [PATCH] drm/amd/display: fix 64 bit divide Alex Deucher
2021-11-24 18:37   ` Guo, Bing
2021-11-24 21:07   ` Randy Dunlap
2021-11-24 18:52 ` [PATCH] drm/amd/display: update bios scratch when setting backlight Harry Wentland
2021-11-24 18:55   ` Alex Deucher
2021-11-24 18:59     ` Harry Wentland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.