amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6.
@ 2025-08-02 15:51 Timur Kristóf
  2025-08-04 15:49 ` Alex Deucher
  2025-08-07 23:31 ` Rodrigo Siqueira
  0 siblings, 2 replies; 4+ messages in thread
From: Timur Kristóf @ 2025-08-02 15:51 UTC (permalink / raw)
  To: amd-gfx; +Cc: Timur Kristóf

On DCE 6, DP audio was not working. However, it worked when an
HDMI monitor was also plugged in.

Looking at dce_aud_wall_dto_setup it seems that the main
difference is that we use DTO1 when only DP is plugged in.

When programming DTO1, it uses audio_dto_source_clock_in_khz
which is set from get_dp_ref_freq_khz

The dce60_get_dp_ref_freq_khz implementation looks incorrect,
because DENTIST_DISPCLK_CNTL seems to be always zero on DCE 6,
so it isn't usable.
I compared dce60_get_dp_ref_freq_khz to the legacy display code,
specifically dce_v6_0_audio_set_dto, and it turns out that in
case of DCE 6, it needs to use the display clock. With that,
DP audio started working on Pitcairn, Oland and Cape Verde.

However, it still didn't work on Tahiti. Despite having the
same DCE version, Tahiti seems to have a different audio device.
After some trial and error I realized that it works with the
default display clock as reported by the VBIOS, not the current
display clock.

The patch was tested on all four SI GPUs:

* Pitcairn (DCE 6.0)
* Oland (DCE 6.4)
* Cape Verde (DCE 6.0)
* Tahiti (DCE 6.0 but different)

The testing was done on Samsung Odyssey G7 LS28BG700EPXEN on
each of the above GPUs, at the following settings:

* 4K 60 Hz
* 1080p 60 Hz
* 1080p 144 Hz

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
---
 .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c  | 21 ++++++-------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
index 0267644717b2..883591706db9 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
@@ -83,22 +83,13 @@ static const struct state_dependent_clocks dce60_max_clks_by_state[] = {
 static int dce60_get_dp_ref_freq_khz(struct clk_mgr *clk_mgr_base)
 {
 	struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
-	int dprefclk_wdivider;
-	int dp_ref_clk_khz;
-	int target_div;
+	struct dc_context *ctx = clk_mgr_base->ctx;
+	int dp_ref_clk_khz = 0;
 
-	/* DCE6 has no DPREFCLK_CNTL to read DP Reference Clock source */
-
-	/* Read the mmDENTIST_DISPCLK_CNTL to get the currently
-	 * programmed DID DENTIST_DPREFCLK_WDIVIDER*/
-	REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, &dprefclk_wdivider);
-
-	/* Convert DENTIST_DPREFCLK_WDIVIDERto actual divider*/
-	target_div = dentist_get_divider_from_did(dprefclk_wdivider);
-
-	/* Calculate the current DFS clock, in kHz.*/
-	dp_ref_clk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
-		* clk_mgr->base.dentist_vco_freq_khz) / target_div;
+	if (ASIC_REV_IS_TAHITI_P(ctx->asic_id.hw_internal_rev))
+		dp_ref_clk_khz = ctx->dc_bios->fw_info.default_display_engine_pll_frequency;
+	else
+		dp_ref_clk_khz = clk_mgr_base->clks.dispclk_khz;
 
 	return dce_adjust_dp_ref_freq_for_ss(clk_mgr, dp_ref_clk_khz);
 }
-- 
2.50.1


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

* Re: [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6.
  2025-08-02 15:51 [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6 Timur Kristóf
@ 2025-08-04 15:49 ` Alex Deucher
  2025-08-07 23:31 ` Rodrigo Siqueira
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2025-08-04 15:49 UTC (permalink / raw)
  To: Timur Kristóf, Wentland, Harry, Leo (Sunpeng) Li; +Cc: amd-gfx

On Sat, Aug 2, 2025 at 11:58 AM Timur Kristóf <timur.kristof@gmail.com> wrote:
>
> On DCE 6, DP audio was not working. However, it worked when an
> HDMI monitor was also plugged in.
>
> Looking at dce_aud_wall_dto_setup it seems that the main
> difference is that we use DTO1 when only DP is plugged in.
>
> When programming DTO1, it uses audio_dto_source_clock_in_khz
> which is set from get_dp_ref_freq_khz
>
> The dce60_get_dp_ref_freq_khz implementation looks incorrect,
> because DENTIST_DISPCLK_CNTL seems to be always zero on DCE 6,
> so it isn't usable.
> I compared dce60_get_dp_ref_freq_khz to the legacy display code,
> specifically dce_v6_0_audio_set_dto, and it turns out that in
> case of DCE 6, it needs to use the display clock. With that,
> DP audio started working on Pitcairn, Oland and Cape Verde.
>
> However, it still didn't work on Tahiti. Despite having the
> same DCE version, Tahiti seems to have a different audio device.
> After some trial and error I realized that it works with the
> default display clock as reported by the VBIOS, not the current
> display clock.
>

This looks good to me, but it would be good to get an ack from Harry or Leo.
Acked-by: Alex Deucher <alexander.deucher@amd.com>

> The patch was tested on all four SI GPUs:
>
> * Pitcairn (DCE 6.0)
> * Oland (DCE 6.4)
> * Cape Verde (DCE 6.0)
> * Tahiti (DCE 6.0 but different)
>
> The testing was done on Samsung Odyssey G7 LS28BG700EPXEN on
> each of the above GPUs, at the following settings:
>
> * 4K 60 Hz
> * 1080p 60 Hz
> * 1080p 144 Hz
>
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
>  .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c  | 21 ++++++-------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> index 0267644717b2..883591706db9 100644
> --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> @@ -83,22 +83,13 @@ static const struct state_dependent_clocks dce60_max_clks_by_state[] = {
>  static int dce60_get_dp_ref_freq_khz(struct clk_mgr *clk_mgr_base)
>  {
>         struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
> -       int dprefclk_wdivider;
> -       int dp_ref_clk_khz;
> -       int target_div;
> +       struct dc_context *ctx = clk_mgr_base->ctx;
> +       int dp_ref_clk_khz = 0;
>
> -       /* DCE6 has no DPREFCLK_CNTL to read DP Reference Clock source */
> -
> -       /* Read the mmDENTIST_DISPCLK_CNTL to get the currently
> -        * programmed DID DENTIST_DPREFCLK_WDIVIDER*/
> -       REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, &dprefclk_wdivider);
> -
> -       /* Convert DENTIST_DPREFCLK_WDIVIDERto actual divider*/
> -       target_div = dentist_get_divider_from_did(dprefclk_wdivider);
> -
> -       /* Calculate the current DFS clock, in kHz.*/
> -       dp_ref_clk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
> -               * clk_mgr->base.dentist_vco_freq_khz) / target_div;
> +       if (ASIC_REV_IS_TAHITI_P(ctx->asic_id.hw_internal_rev))
> +               dp_ref_clk_khz = ctx->dc_bios->fw_info.default_display_engine_pll_frequency;
> +       else
> +               dp_ref_clk_khz = clk_mgr_base->clks.dispclk_khz;
>
>         return dce_adjust_dp_ref_freq_for_ss(clk_mgr, dp_ref_clk_khz);
>  }
> --
> 2.50.1
>

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

* Re: [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6.
  2025-08-02 15:51 [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6 Timur Kristóf
  2025-08-04 15:49 ` Alex Deucher
@ 2025-08-07 23:31 ` Rodrigo Siqueira
  2025-08-18 17:07   ` Alex Deucher
  1 sibling, 1 reply; 4+ messages in thread
From: Rodrigo Siqueira @ 2025-08-07 23:31 UTC (permalink / raw)
  To: Timur Kristóf, Daniel Wheeler, Aurabindo Pillai, Alex Hung
  Cc: amd-gfx, Harry Wentland, Leo Li

On 08/02, Timur Kristóf wrote:
> On DCE 6, DP audio was not working. However, it worked when an
> HDMI monitor was also plugged in.
> 
> Looking at dce_aud_wall_dto_setup it seems that the main
> difference is that we use DTO1 when only DP is plugged in.
> 
> When programming DTO1, it uses audio_dto_source_clock_in_khz
> which is set from get_dp_ref_freq_khz
> 
> The dce60_get_dp_ref_freq_khz implementation looks incorrect,
> because DENTIST_DISPCLK_CNTL seems to be always zero on DCE 6,
> so it isn't usable.
> I compared dce60_get_dp_ref_freq_khz to the legacy display code,
> specifically dce_v6_0_audio_set_dto, and it turns out that in
> case of DCE 6, it needs to use the display clock. With that,
> DP audio started working on Pitcairn, Oland and Cape Verde.
> 
> However, it still didn't work on Tahiti. Despite having the
> same DCE version, Tahiti seems to have a different audio device.
> After some trial and error I realized that it works with the
> default display clock as reported by the VBIOS, not the current
> display clock.
> 
> The patch was tested on all four SI GPUs:
> 
> * Pitcairn (DCE 6.0)
> * Oland (DCE 6.4)
> * Cape Verde (DCE 6.0)
> * Tahiti (DCE 6.0 but different)
> 
> The testing was done on Samsung Odyssey G7 LS28BG700EPXEN on
> each of the above GPUs, at the following settings:
> 
> * 4K 60 Hz
> * 1080p 60 Hz
> * 1080p 144 Hz
> 
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
>  .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c  | 21 ++++++-------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> index 0267644717b2..883591706db9 100644
> --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> @@ -83,22 +83,13 @@ static const struct state_dependent_clocks dce60_max_clks_by_state[] = {
>  static int dce60_get_dp_ref_freq_khz(struct clk_mgr *clk_mgr_base)
>  {
>  	struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
> -	int dprefclk_wdivider;
> -	int dp_ref_clk_khz;
> -	int target_div;
> +	struct dc_context *ctx = clk_mgr_base->ctx;
> +	int dp_ref_clk_khz = 0;
>  
> -	/* DCE6 has no DPREFCLK_CNTL to read DP Reference Clock source */
> -
> -	/* Read the mmDENTIST_DISPCLK_CNTL to get the currently
> -	 * programmed DID DENTIST_DPREFCLK_WDIVIDER*/
> -	REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, &dprefclk_wdivider);
> -
> -	/* Convert DENTIST_DPREFCLK_WDIVIDERto actual divider*/
> -	target_div = dentist_get_divider_from_did(dprefclk_wdivider);
> -
> -	/* Calculate the current DFS clock, in kHz.*/
> -	dp_ref_clk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
> -		* clk_mgr->base.dentist_vco_freq_khz) / target_div;
> +	if (ASIC_REV_IS_TAHITI_P(ctx->asic_id.hw_internal_rev))
> +		dp_ref_clk_khz = ctx->dc_bios->fw_info.default_display_engine_pll_frequency;
> +	else
> +		dp_ref_clk_khz = clk_mgr_base->clks.dispclk_khz;
>  
>  	return dce_adjust_dp_ref_freq_for_ss(clk_mgr, dp_ref_clk_khz);
>  }
> -- 
> 2.50.1
>

Very nice patch! I checked the mentioned functions, and it looks correct
to me.

I added other display folks for further review/validation. It could be a
good idea to include this patch in the next week's promotion.

Reviewed-by: Rodrigo Siqueira <siqueira@igalia.com>

Thanks

-- 
Rodrigo Siqueira

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

* Re: [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6.
  2025-08-07 23:31 ` Rodrigo Siqueira
@ 2025-08-18 17:07   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2025-08-18 17:07 UTC (permalink / raw)
  To: Rodrigo Siqueira
  Cc: Timur Kristóf, Daniel Wheeler, Aurabindo Pillai, Alex Hung,
	amd-gfx, Harry Wentland, Leo Li

Applied.  Thanks!

Alex

On Fri, Aug 8, 2025 at 2:39 AM Rodrigo Siqueira <siqueira@igalia.com> wrote:
>
> On 08/02, Timur Kristóf wrote:
> > On DCE 6, DP audio was not working. However, it worked when an
> > HDMI monitor was also plugged in.
> >
> > Looking at dce_aud_wall_dto_setup it seems that the main
> > difference is that we use DTO1 when only DP is plugged in.
> >
> > When programming DTO1, it uses audio_dto_source_clock_in_khz
> > which is set from get_dp_ref_freq_khz
> >
> > The dce60_get_dp_ref_freq_khz implementation looks incorrect,
> > because DENTIST_DISPCLK_CNTL seems to be always zero on DCE 6,
> > so it isn't usable.
> > I compared dce60_get_dp_ref_freq_khz to the legacy display code,
> > specifically dce_v6_0_audio_set_dto, and it turns out that in
> > case of DCE 6, it needs to use the display clock. With that,
> > DP audio started working on Pitcairn, Oland and Cape Verde.
> >
> > However, it still didn't work on Tahiti. Despite having the
> > same DCE version, Tahiti seems to have a different audio device.
> > After some trial and error I realized that it works with the
> > default display clock as reported by the VBIOS, not the current
> > display clock.
> >
> > The patch was tested on all four SI GPUs:
> >
> > * Pitcairn (DCE 6.0)
> > * Oland (DCE 6.4)
> > * Cape Verde (DCE 6.0)
> > * Tahiti (DCE 6.0 but different)
> >
> > The testing was done on Samsung Odyssey G7 LS28BG700EPXEN on
> > each of the above GPUs, at the following settings:
> >
> > * 4K 60 Hz
> > * 1080p 60 Hz
> > * 1080p 144 Hz
> >
> > Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> > ---
> >  .../display/dc/clk_mgr/dce60/dce60_clk_mgr.c  | 21 ++++++-------------
> >  1 file changed, 6 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> > index 0267644717b2..883591706db9 100644
> > --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> > +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce60/dce60_clk_mgr.c
> > @@ -83,22 +83,13 @@ static const struct state_dependent_clocks dce60_max_clks_by_state[] = {
> >  static int dce60_get_dp_ref_freq_khz(struct clk_mgr *clk_mgr_base)
> >  {
> >       struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
> > -     int dprefclk_wdivider;
> > -     int dp_ref_clk_khz;
> > -     int target_div;
> > +     struct dc_context *ctx = clk_mgr_base->ctx;
> > +     int dp_ref_clk_khz = 0;
> >
> > -     /* DCE6 has no DPREFCLK_CNTL to read DP Reference Clock source */
> > -
> > -     /* Read the mmDENTIST_DISPCLK_CNTL to get the currently
> > -      * programmed DID DENTIST_DPREFCLK_WDIVIDER*/
> > -     REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, &dprefclk_wdivider);
> > -
> > -     /* Convert DENTIST_DPREFCLK_WDIVIDERto actual divider*/
> > -     target_div = dentist_get_divider_from_did(dprefclk_wdivider);
> > -
> > -     /* Calculate the current DFS clock, in kHz.*/
> > -     dp_ref_clk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
> > -             * clk_mgr->base.dentist_vco_freq_khz) / target_div;
> > +     if (ASIC_REV_IS_TAHITI_P(ctx->asic_id.hw_internal_rev))
> > +             dp_ref_clk_khz = ctx->dc_bios->fw_info.default_display_engine_pll_frequency;
> > +     else
> > +             dp_ref_clk_khz = clk_mgr_base->clks.dispclk_khz;
> >
> >       return dce_adjust_dp_ref_freq_for_ss(clk_mgr, dp_ref_clk_khz);
> >  }
> > --
> > 2.50.1
> >
>
> Very nice patch! I checked the mentioned functions, and it looks correct
> to me.
>
> I added other display folks for further review/validation. It could be a
> good idea to include this patch in the next week's promotion.
>
> Reviewed-by: Rodrigo Siqueira <siqueira@igalia.com>
>
> Thanks
>
> --
> Rodrigo Siqueira

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

end of thread, other threads:[~2025-08-18 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02 15:51 [PATCH] drm/amd/display: Fix DP audio DTO1 clock source on DCE 6 Timur Kristóf
2025-08-04 15:49 ` Alex Deucher
2025-08-07 23:31 ` Rodrigo Siqueira
2025-08-18 17:07   ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).