drm/i915: set proper N/M in modeset
Subsystems (2)
PATCH 1/1 drm/i915: set proper N/M in modeset
From: Libin Yang <[email protected]>
When modeset occurs and the LS_CLK is set to some special values in DP mode, the N/M need to be set manually if audio is playing.
The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs / f_LS_Clk
Please refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit 7e8275c2f2bb ("drm/i915: set proper N/CTS in modeset") to APL platform.
--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe, _HSW_AUD_CONFIG_A, _HSW_AUD_CONFIG_B) +#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe, _HSW_AUD_M_CTS_ENABLE_A, _HSW_AUD_M_CTS_ENABLE_B) +#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe, _HSW_AUD_MISC_CTRL_A, _HSW_AUD_MISC_CTRL_B)
drivers/gpu/drm/i915/intel_audio.c +105 -17
206 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for drm/i915: set proper N/M in modeset (rev2)
== Series Details ==
== Series Details ==
Series: drm/i915: set proper N/M in modeset (rev2)
URL : https://patchwork.freedesktop.org/series/9857/
State : failure
== Summary ==
Series 9857v2 drm/i915: set proper N/M in modeset
http://patchwork.freedesktop.org/api/1.0/series/9857/revisions/2/mbox
Test gem_exec_gttfill:
Subgroup basic:
pass -> SKIP (fi-snb-i7-2600)
Test kms_cursor_legacy:
Subgroup basic-cursor-vs-flip-legacy:
fail -> PASS (ro-ilk1-i5-650)
Subgroup basic-flip-vs-cursor-legacy:
fail -> PASS (fi-hsw-i7-4770k)
pass -> FAIL (ro-bdw-i5-5250u)
Subgroup basic-flip-vs-cursor-varying-size:
fail -> PASS (ro-hsw-i7-4770r)
fail -> PASS (ro-bdw-i5-5250u)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> INCOMPLETE (fi-hsw-i7-4770k)fi-hsw-i7-4770k total:207 pass:186 dwarn:0 dfail:0 fail:0 skip:20 fi-kbl-qkkr total:240 pass:181 dwarn:30 dfail:0 fail:2 skip:27 fi-skl-i5-6260u total:240 pass:224 dwarn:0 dfail:0 fail:2 skip:14 fi-skl-i7-6700k total:240 pass:208 dwarn:0 dfail:0 fail:4 skip:28 fi-snb-i7-2600 total:240 pass:197 dwarn:0 dfail:0 fail:0 skip:43 ro-bdw-i5-5250u total:240 pass:219 dwarn:4 dfail:0 fail:1 skip:16 ro-bdw-i7-5600u total:240 pass:207 dwarn:0 dfail:0 fail:1 skip:32 ro-bsw-n3050 total:240 pass:194 dwarn:0 dfail:0 fail:4 skip:42 ro-byt-n2820 total:240 pass:197 dwarn:0 dfail:0 fail:3 skip:40 ro-hsw-i3-4010u total:240 pass:214 dwarn:0 dfail:0 fail:0 skip:26 ro-hsw-i7-4770r total:240 pass:214 dwarn:0 dfail:0 fail:0 skip:26 ro-ilk-i7-620lm total:240 pass:173 dwarn:1 dfail:0 fail:1 skip:65 ro-ilk1-i5-650 total:235 pass:174 dwarn:0 dfail:0 fail:1 skip:60 ro-ivb-i7-3770 total:240 pass:205 dwarn:0 dfail:0 fail:0 skip:35 ro-ivb2-i7-3770 total:240 pass:209 dwarn:0 dfail:0 fail:0 skip:31 ro-skl3-i5-6260u total:240 pass:222 dwarn:0 dfail:0 fail:4 skip:14 ro-snb-i7-2620M total:240 pass:198 dwarn:0 dfail:0 fail:1 skip:41
ro-bdw-i7-5557U failed to connect after reboot
Results at /archive/results/CI_IGT_test/RO_Patchwork_1660/
6f87e85 drm-intel-nightly: 2016y-08m-01d-14h-53m-17s UTC integration manifest 1608e48 drm/i915: set proper N/M in modeset
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 44 lines · On Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)drivers/gpu/drm/i915/i915_reg.h +6
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe, _HSW_AUD_CONFIG_A, _HSW_AUD_CONFIG_B) +#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe, _HSW_AUD_M_CTS_ENABLE_A, _HSW_AUD_M_CTS_ENABLE_B) +#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe, _HSW_AUD_MISC_CTRL_A, _HSW_AUD_MISC_CTRL_B)drivers/gpu/drm/i915/intel_audio.c +0
-0
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_540M 540000 +#define LC_162M 162000
Do we have some explanation why 2.7 doesn't need M/N programming, but 1.62 and 5.4 do?
And I see you're only doing this on HSW+. Earlier platforms don't need this?
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;
Can save a bit of space by using u16 for m and n.
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};
The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 150 lines
drivers/gpu/drm/i915/intel_audio.c +75
-13+/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static u32 audio_config_hdmi_pixel_clock (const struct drm_display_mode *adjusted_mode) {@@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjustedreturn hdmi_audio_clock[i].config; } -static int audio_config_get_n (const struct drm_display_mode *mode,int rate) +static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)) { +return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)) { +return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n, uint32_t val) tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m; + tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) +const struct drm_display_mode *adjusted_mode) { -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false; }@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1@@ -645,7 +722,8 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDI perhaps?
Quoted 42 lines
drivers/gpu/drm/i915/intel_audio.c +13
-3mutex_lock (&dev_priv->av_mutex);@@ -653,7 +731,8 @@ static int i915_audio_component_sync_audio_rate(struct device *dev, intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev, goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) {DRM_DEBUG_KMS ("Using automatic mode for N value on port %c\n" ,port_name (port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:mutex_unlock (&dev_priv->av_mutex);Signature · 1 line
1.9.1
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerQuoted 10 lines · On Tue, 02 Aug 2016, [email protected] wrote:
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_Clk
Quoted 5 lines
Please refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.
Whenever a commit message says "also", it makes me think the patch should probably be split to several patches. And that is certainly true here.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville
Quoted 59 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 27 lines · On Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but 1.62 and 5.4 do?
I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the test. 5.4 is for 4K and 1.62 is for 1080p.
Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Our test only includes 32K, 44.1K and 48K :)
I will add the support if you think we should.
Quoted 160 lines
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static u32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusteddrivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode *mode,int rate)
drivers/gpu/drm/i915/intel_audio.c +9
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) &&drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n,
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false; }@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static int
Quoted 28 lines
drivers/gpu/drm/i915/intel_audio.c +12
-2DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?
Do you mean we should add "&& HAS_DDI"?
Could you please give me more details?
Regards,
Libin
Quoted 43 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock (&dev_priv->av_mutex);@@ -653,7 +731,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 19 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + }
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0unlock:
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Jani,
Quoted 20 lines
-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:53 PM
To: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Cc: Yang, Libin <[email protected]>; Libin Yang <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 9 lines · On Tue, 02 Aug 2016, [email protected] wrote:
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_Clk
Quoted 8 lines
Quoted 5 lines
Please refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Whenever a commit message says "also", it makes me think the patch should probably be split to several patches. And that is certainly true here.
I will split the patch in next version.
Regards,
Libin
Quoted 4 lines
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 61 lines · Libin
Hi Ville
Quoted 59 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 27 lines · On Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };
Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but 1.62 and 5.4 do?
I didn't use 2.7 because I can't find a mode using 2.7.
Hmm. Maybe we should add some knobs to force a specific bpc/link rate/number of lanes to help with this kind of testing. Currently you just get what you get, which isn't so nice when you want to test all variations.
...
OK, so I just went ahead and did that. Here's a branch:
git://github.com/vsyrjala/linux.git modparam_clock_bpp_limit
For your DP testing just setting i915.max_port_clock=162000 or i915.max_port_clock=270000 and then forcing a modeset should do the trick.
Quoted 8 lines
So I can't do the test.
5.4 is for 4K and 1.62 is for 1080p.Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
SNB-IVB dotclock can go up to 360Mhz, ILK up to 405 Mhz. At least in theory. The DP link is limited to 4 x 2.7 for all. From the those the dotclock limit is the one you should hit first since DP can always fall back to 6bpc and that should be correspond to a dotclock of 480 MHz. Anyways, 360MHz is plenty for 4k@30.
The question really is why we need to do this in the first place. There's nothing in the spec telling is it's really required. All I can find in the DP spec is "Maud value is set to 2^15 (=32,768) when the audio clock is asynchronous to the LS_Clk.", and then
Thinking about it a bit more, on HSW+ we do drive DP ports with the LCPLL, which is also reponsible for cdclk, and there are some vague hints that audio may be clocked via cdclk. So if the DDI clock and the audio clock are coming from the same reference, I suppose they are considered synchronous, which may explain why this is needed. It's all very poorly documented though, so I can't be sure.
As for the older platforms, the clocks are even less well documented. The audio stuff is in the PCH, which is also where the DPLLs live, but I have no idea where any audio clocks come from.
Quoted 25 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :)
I will add the support if you think we should.
What sample rates can the user select? That should be the only relevant question here.
Quoted 171 lines
Quoted 161 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static u32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusteddrivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode *mode,int rate)
drivers/gpu/drm/i915/intel_audio.c +9
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) &&drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n,
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false; }@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static int
Quoted 28 lines
drivers/gpu/drm/i915/intel_audio.c +12
-2DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?
Quoted 2 lines
Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?
HAS_DDI alone should be enough.
Quoted 55 lines
Regards,
LibinQuoted 51 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock (&dev_priv->av_mutex);@@ -653,7 +731,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:Quoted 3 lines
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
Quoted 110 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected]
Quoted 50 lines · wrote:
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but 1.62 and 5.4 do?
I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the test. 5.4 is for 4K and 1.62 is for 1080p.
Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
Quoted 171 lines
Quoted 161 lines
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static u32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusteddrivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode *mode,int rate)
drivers/gpu/drm/i915/intel_audio.c +9
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) &&drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static int
Quoted 28 lines
drivers/gpu/drm/i915/intel_audio.c +12
-2DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?
Quoted 57 lines
Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 51 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock (&dev_priv->av_mutex);@@ -653,7 +731,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:Quoted 3 lines
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 112 lines · Libin
Hi Ville,
Quoted 110 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected]
Quoted 50 lines · wrote:
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but 1.62 and 5.4 do?
I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the test. 5.4 is for 4K and 1.62 is for 1080p.
Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 5 lines
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
How about basing that decision on what's actually allowed by the driver? I can do 96kHz DP audio on my HSW just fine here. So clearly if the display supports it, there is nothing on the ALSA side that would prevent it from being used.
Quoted 229 lines
Quoted 229 lines
Quoted 162 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static u32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusteddrivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode *mode,int rate)
drivers/gpu/drm/i915/intel_audio.c +9
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) &&drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static int
Quoted 28 lines
drivers/gpu/drm/i915/intel_audio.c +12
-2DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 51 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock (&dev_priv->av_mutex);@@ -653,7 +731,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:Quoted 3 lines
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
Quoted 89 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Wednesday, August 3, 2016 12:59 AM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 12 lines · Libin
Hi Ville
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected]
Quoted 31 lines · wrote:
Quoted 31 lines
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 16 lines
Quoted 16 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 102
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?I didn't use 2.7 because I can't find a mode using 2.7.
Hmm. Maybe we should add some knobs to force a specific bpc/link rate/number of lanes to help with this kind of testing. Currently you just get what you get, which isn't so nice when you want to test all variations.
...
OK, so I just went ahead and did that. Here's a branch:
Quoted 5 lines
git://github.com/vsyrjala/linux.gitmodparam_clock_bpp_limitFor your DP testing just setting i915.max_port_clock=162000 or i915.max_port_clock=270000 and then forcing a modeset should do the trick.
Thanks for the new branch. It seems download is very slow, less than 10Kib/s. So I will submit the new patches firstly and then do the test. Fortunately, I found there is recommended data for 340MHz in the spec. I copied the data to the patch and suppose the data should be accurate.
Quoted 17 lines
Quoted 9 lines
So I can't do the test.
5.4 is for 4K and 1.62 is for 1080p.Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
SNB-IVB dotclock can go up to 360Mhz, ILK up to 405 Mhz. At least in theory. The DP link is limited to 4 x 2.7 for all. From the those the dotclock limit is the one you should hit first since DP can always fall back to 6bpc and that should be correspond to a dotclock of 480 MHz.
Anyways, 360MHz is plenty for 4k@30.
Quoted 4 lines
The question really is why we need to do this in the first place. There's nothing in the spec telling is it's really required. All I can find in the DP spec is "Maud value is set to 2^15 (=32,768) when the audio clock is asynchronous to the
LS_Clk.", and then
We made the patch because we found the HW can't calculate the value this will cause there is several seconds silence at the beginning of audio playback. With this patch, the silence is much shorter than before and is acceptable.
Quoted 7 lines
Thinking about it a bit more, on HSW+ we do drive DP ports with the LCPLL, which is also reponsible for cdclk, and there are some vague hints that audio may be clocked via cdclk. So if the DDI clock and the audio clock are coming from the same reference, I suppose they are considered synchronous, which may explain why this is needed. It's all very poorly documented though, so I can't be sure.
Yes, audio is using cdclk. Changing the cdclk will impact audio function. However N/M, N/CTS is used to recover the audio clock in monitor. Monitor's PLL will use these values, together with the clock transferred by the lanes, to recover the clock for audio.
Quoted 30 lines
As for the older platforms, the clocks are even less well documented. The audio stuff is in the PCH, which is also where the DPLLs live, but I have no idea where any audio clocks come from.
Quoted 25 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 5 lines
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
What sample rates can the user select? That should be the only relevant question here.
I have tested, other sample rates is not valid on DP.
Quoted 173 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ staticu32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 164 lines
Quoted 163 lines
Quoted 13 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode*mode, int rate)
drivers/gpu/drm/i915/intel_audio.c +9
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) &&drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (adjusted_mode->clock == aud_ncts[i].clock)) { +return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4int i; -for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static int
Quoted 28 lines
drivers/gpu/drm/i915/intel_audio.c +12
-2DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n =audio_config_get_n (intel_crtc, adjusted_mode, rate);if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (intel_crtc, n, tmp);else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (intel_crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?
Quoted 4 lines
Quoted 2 lines
Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?
HAS_DDIalone should be enough.
Get it. Thanks.
Regards,
Libin
Quoted 4 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
Quoted 131 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 1:39 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 56 lines · Libin
Hi Ville,
Quoted 54 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 11 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800,
[email protected]Quoted 31 lines · wrote:
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?Quoted 5 lines
Quoted 5 lines
I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the test. 5.4 is for 4K and 1.62 is for 1080p.
Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need
this?
Quoted 31 lines
Quoted 30 lines
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
Quoted 7 lines
Quoted 2 lines
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
How about basing that decision on what's actually allowed by the driver? I can do 96kHz DP audio on my HSW just fine here. So clearly if the display supports it, there is nothing on the ALSA side that would prevent it from being used.
For 96KHz, audio will convert to 48KHz. You can try to print the sample rate in i915_audio_component_sync_audio_rate(). So we can't test it for the real 96kHz.
In DP spec, table 2-50 only says 48kHz, 32kHz, 44.1kHz, 384kHz and 768kHz. However, the latter two sample rates is not supported in audio driver and can't be tested so far. 88kHz, 96kHz and 192kHz cannot be tested, either.
Regards,
Libin
Quoted 243 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ staticu32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode*mode, int rate)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static int audio_config_get_n (struct intel_crtc *crtc, + const struct drm_display_mode
*adjusted_mode,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+ int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock ==aud_ncts[i].clock)) {
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
{
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int +rate) {int i;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4-for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
{
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n = audio_config_get_n(intel_crtc, adjusted_mode,rate);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp = audio_config_setup_n_reg(intel_crtc, n,tmp);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )){
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct · line 427
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ tmp = audio_config_setup_m_reg(intel_crtc,m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct · line 428
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),tmp);
Quoted 77 lines
Quoted 77 lines
Quoted 18 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 43 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock(&dev_priv->av_mutex); @@ -653,7 +731,8 @@ staticint
i915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 19 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + }Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0unlock:
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
Quoted 3 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 91 lines · Libin
Hi Ville,
Quoted 89 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Wednesday, August 3, 2016 12:59 AM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 12 lines · Libin
Hi Ville
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800, [email protected]
Quoted 31 lines · wrote:
Quoted 31 lines
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 16 lines
Quoted 16 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?I didn't use 2.7 because I can't find a mode using 2.7.
Hmm. Maybe we should add some knobs to force a specific bpc/link rate/number of lanes to help with this kind of testing. Currently you just get what you get, which isn't so nice when you want to test all variations.
...
OK, so I just went ahead and did that. Here's a branch:
Quoted 8 lines
Quoted 5 lines
git://github.com/vsyrjala/linux.gitmodparam_clock_bpp_limitFor your DP testing just setting i915.max_port_clock=162000 or i915.max_port_clock=270000 and then forcing a modeset should do the trick.
Thanks for the new branch. It seems download is very slow, less than 10Kib/s.
github that slow for you? Weird.
And I can't see a way to grab the raw patches from the github web interface :( so I've attached the patches to this mail in case you can't finish the git fetch in reasonable time.
Quoted 2 lines
So I will submit the new patches firstly and then do the test. Fortunately, I found there is recommended data for 340MHz in the spec.
340 MHz? There's no such link rate for DP. I'm not sure what you're saying here...
Quoted 19 lines
I copied the data to the patch and suppose the data should be accurate.
Quoted 17 lines
Quoted 9 lines
So I can't do the test.
5.4 is for 4K and 1.62 is for 1080p.Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need this?
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
SNB-IVB dotclock can go up to 360Mhz, ILK up to 405 Mhz. At least in theory. The DP link is limited to 4 x 2.7 for all. From the those the dotclock limit is the one you should hit first since DP can always fall back to 6bpc and that should be correspond to a dotclock of 480 MHz.
Anyways, 360MHz is plenty for 4k@30.
Quoted 8 lines
Quoted 4 lines
The question really is why we need to do this in the first place. There's nothing in the spec telling is it's really required. All I can find in the DP spec is "Maud value is set to 2^15 (=32,768) when the audio clock is asynchronous to the
LS_Clk.", and thenWe made the patch because we found the HW can't calculate the value this will cause there is several seconds silence at the beginning of audio playback. With this patch, the silence is much shorter than before and is acceptable.
I see. Must be sink specific since at least my current monitor (ASUS PB278) has no apparent delays with the current code. I guess some sinks are just slower in clock recovery than others, and starting out with better M/N values can speed it up a bit.
Anyways, please specify this reason for the change in the commit message, otherwise no one can figure out why it's needed.
Signature · 2 lines
Ville Syrjälä Intel OTC
Quoted 1 line
From
4416baa8ef415e9aa760309fc864aad8fb2ab807Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <[email protected]>
Date: Wed, 27 Jul 2016 17:21:21 +0300
Subject: [PATCH 1/3] drm/i915: Remove useless rate_to_index() usage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
No need to iterate the rates array in intel_dp_max_link_rate(). We know the max rate will be the last entry, and we already know the size.
--- drivers/gpu/drm/i915/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -1447,7 +1447,7 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp)if (WARN_ON (len <=0 ))return 162000 ; -return rates[rate_to_index (0 , rates) -1 ]; +return rates[len -1 ]; }int intel_dp_rate_select (struct intel_dp *intel_dp,int rate)
Signature · 1 line
2.7.4
Quoted 1 line
From
6b99092b0dce3edd3567da4b29ad0d5d36240f38Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <[email protected]>
Date: Wed, 27 Jul 2016 17:19:16 +0300
Subject: [PATCH 2/3] drm/i915: Allow rate_to_index() to return non-exact
matches
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Let's make rate_to_index() return the highest rate available that's less than or equal to the rate requested by the caller. The function can then be used to filter out rates higher than a certain maximum rate.
--- drivers/gpu/drm/i915/intel_dp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +5 -2
@@ -1431,10 +1431,13 @@ static int rate_to_index(int find, const int *rates)int i =0 ;for (i =0 ; i <DP_MAX_SUPPORTED_RATES ; ++i) -if (find == rates[i]) +if (find < rates[i])break ; -return i; +if (WARN_ON (i ==0 )) +return 0 ; + +return i -1 ; }int
Signature · 1 line
2.7.4
Quoted 1 line
From
4bc405c7b5fb1dcabd668bfcd50e67baae456353Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <[email protected]>
Date: Tue, 2 Aug 2016 18:16:32 +0300
Subject: [PATCH 3/3] drm/i915: Add
max_pipe_bpp,max_dot_clock,max_port_clock,max_lanes modparams
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Eg.
limit DP to 2.7G link rate by setting max_port_clock=270000 limit DP to use at most 2 lanes by setting set max_lanes=2
--- drivers/gpu/drm/i915/i915_params.c | 13 ++++++++++++ drivers/gpu/drm/i915/i915_params.h | 4 ++++ drivers/gpu/drm/i915/intel_crt.c | 3 +++ drivers/gpu/drm/i915/intel_display.c | 13 ++++++++++++ drivers/gpu/drm/i915/intel_dp.c | 41 ++++++++++++++++++++++-------------- drivers/gpu/drm/i915/intel_dp_mst.c | 3 +++ drivers/gpu/drm/i915/intel_dsi.c | 3 +++ drivers/gpu/drm/i915/intel_dvo.c | 3 +++ drivers/gpu/drm/i915/intel_hdmi.c | 6 ++++++ drivers/gpu/drm/i915/intel_lvds.c | 3 +++ drivers/gpu/drm/i915/intel_sdvo.c | 3 +++ drivers/gpu/drm/i915/intel_tv.c | 3 +++ 12 files changed, 82 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_params.c +13 -0
@@ -63,6 +63,19 @@ struct i915_params i915 __read_mostly = { .enable_gvt = false, }; +module_param_named_unsafe (max_lanes, i915.max_lanes, int,0600 ); +MODULE_PARM_DESC (max_lanes, +"Maximum DP lanes (0=default, 1,2,4)" ); +module_param_named_unsafe (max_port_clock, i915.max_port_clock, int,0600 ); +MODULE_PARM_DESC (max_port_clock, +"Maximum port clock limit (0=default, eg. 270000)" ); +module_param_named_unsafe (max_dot_clock, i915.max_dot_clock, int,0600 ); +MODULE_PARM_DESC (max_dot_clock, +"Maximum dot clock limit (0=default, eg. 148500)" ); +module_param_named_unsafe (max_pipe_bpp, i915.max_pipe_bpp, int,0600 ); +MODULE_PARM_DESC (max_pipe_bpp, +"Maximum pipe bpp used (0=default, 18,24,30,36)" ); +module_param_named (modeset, i915.modeset, int,0400 );MODULE_PARM_DESC (modeset, "Use kernel modesetting [KMS] (0=disable, "
drivers/gpu/drm/i915/i915_params.h +4 -0
@@ -52,6 +52,10 @@ struct i915_params {int mmio_debug;int edp_vswing;unsigned int inject_load_failure; +int max_lanes; +int max_port_clock; +int max_dot_clock; +int max_pipe_bpp;/* leave bools at the end to not create holes */ bool enable_hangcheck;bool fastboot;
drivers/gpu/drm/i915/intel_crt.c +3 -0
@@ -220,6 +220,9 @@ intel_crt_mode_valid(struct drm_connector *connector,int max_dotclk =to_i915 (dev)->max_dotclk_freq;int max_clock; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +if (mode->flags &DRM_MODE_FLAG_DBLSCAN )return MODE_NO_DBLESCAN ;
drivers/gpu/drm/i915/intel_display.c +13 -0
@@ -6618,6 +6618,9 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc, } } +if (i915.max_dot_clock) + clock_limit =min (i915.max_dot_clock, clock_limit); +if (adjusted_mode->crtc_clock > clock_limit) { DRM_DEBUG_KMS("requested pixel clock (%d kHz) too high (max: %d kHz, double wide: %s)\n", adjusted_mode->crtc_clock, clock_limit,
@@ -12139,6 +12142,16 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,else bpp =8 *3 ; +switch (i915.max_pipe_bpp) { +case 12 *3 : +case 10 *3 : +case 8 *3 : +case 6 *3 : + bpp =min (i915.max_pipe_bpp, bpp); +break ; +default : +break ; + } pipe_config->pipe_bpp = bpp;
drivers/gpu/drm/i915/intel_dp.c +25 -16
77 lines not on this page · raw message
drivers/gpu/drm/i915/intel_dp_mst.c +3 -0
@@ -354,6 +354,9 @@ intel_dp_mst_mode_valid(struct drm_connector *connector, {int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +/* TODO - validate mode against available PBN for link */ if (mode->clock <10000 )return MODE_CLOCK_LOW ;
drivers/gpu/drm/i915/intel_dsi.c +3 -0
@@ -985,6 +985,9 @@ intel_dsi_mode_valid(struct drm_connector *connector,const struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +DRM_DEBUG_KMS ("\n" );if (mode->flags &DRM_MODE_FLAG_DBLSCAN ) {
drivers/gpu/drm/i915/intel_dvo.c +3 -0
@@ -214,6 +214,9 @@ intel_dvo_mode_valid(struct drm_connector *connector,int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq;int target_clock = mode->clock; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +if (mode->flags &DRM_MODE_FLAG_DBLSCAN )return MODE_NO_DBLESCAN ;
drivers/gpu/drm/i915/intel_hdmi.c +6 -0
@@ -1203,6 +1203,9 @@ static int hdmi_port_clock_limit(struct intel_hdmi *hdmi,struct drm_device *dev =intel_hdmi_to_dev (hdmi);int max_tmds_clock =intel_hdmi_source_max_tmds_clock (to_i915 (dev)); +if (i915.max_port_clock) + max_tmds_clock =min (i915.max_port_clock, max_tmds_clock); +if (respect_downstream_limits) {if (hdmi->dp_dual_mode.max_tmds_clock) max_tmds_clock = min(max_tmds_clock,
@@ -1246,6 +1249,9 @@ intel_hdmi_mode_valid(struct drm_connector *connector,int clock;int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +if (mode->flags &DRM_MODE_FLAG_DBLSCAN )return MODE_NO_DBLESCAN ;
drivers/gpu/drm/i915/intel_lvds.c +3 -0
@@ -293,6 +293,9 @@ intel_lvds_mode_valid(struct drm_connector *connector,struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;int max_pixclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_pixclk =min (i915.max_dot_clock, max_pixclk); +if (mode->hdisplay > fixed_mode->hdisplay)return MODE_PANEL ;if (mode->vdisplay > fixed_mode->vdisplay)
drivers/gpu/drm/i915/intel_sdvo.c +3 -0
@@ -1527,6 +1527,9 @@ intel_sdvo_mode_valid(struct drm_connector *connector,struct intel_sdvo *intel_sdvo =intel_attached_sdvo (connector);int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +if (mode->flags &DRM_MODE_FLAG_DBLSCAN )return MODE_NO_DBLESCAN ;
drivers/gpu/drm/i915/intel_tv.c +3 -0
@@ -887,6 +887,9 @@ intel_tv_mode_valid(struct drm_connector *connector,const struct tv_mode *tv_mode =intel_tv_mode_find (intel_tv);int max_dotclk =to_i915 (connector->dev)->max_dotclk_freq; +if (i915.max_dot_clock) + max_dotclk =min (i915.max_dot_clock, max_dotclk); +if (mode->clock > max_dotclk)return MODE_CLOCK_HIGH ;
Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
Quoted 122 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 2:06 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 31 lines · Libin
Hi Ville,
Quoted 29 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Wednesday, August 3, 2016 12:59 AM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 14 lines · Libin
Hi Ville
Quoted 12 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800,
[email protected]Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio isplaying.
Quoted 56 lines
Quoted 56 lines
Quoted 29 lines
Quoted 29 lines
Quoted 25 lines
The relationship of Maud and Naud is expressed in the following
equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 23 lines
Quoted 22 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?Quoted 5 lines
Quoted 5 lines
Quoted 1 line
I didn't use 2.7 because I can't find a mode using 2.7.
Hmm. Maybe we should add some knobs to force a specific bpc/link rate/number of lanes to help with this kind of testing. Currently you just get what you get, which isn't so nice when you want to test all
variations.
Quoted 11 lines
Quoted 8 lines
...
OK, so I just went ahead and did that. Here's a branch:
git://github.com/vsyrjala/linux.gitmodparam_clock_bpp_limitFor your DP testing just setting i915.max_port_clock=162000 or i915.max_port_clock=270000 and then forcing a modeset should do the trick.
Thanks for the new branch. It seems download is very slow, less than 10Kib/s.
github that slow for you? Weird.
And I can't see a way to grab the raw patches from the github web interface :( so I've attached the patches to this mail in case you can't finish the git fetch in reasonable time.
Quoted 7 lines
Quoted 2 lines
So I will submit the new patches firstly and then do the test. Fortunately, I found there is recommended data for 340MHz in the spec.
340 MHz? There's no such link rate for DP. I'm not sure what you're saying here...
Quoted 1 line
I copied the data to the patch and suppose the data should be accurate.
Thanks for the patch. Sorry, I mean 270MHz, not 340MHz.
Quoted 27 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
So I can't do the test.
5.4 is for 4K and 1.62 is for 1080p.Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need
this?
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
SNB-IVB dotclock can go up to 360Mhz, ILK up to 405 Mhz. At least in
theory.
Quoted 6 lines
Quoted 6 lines
The DP link is limited to 4 x 2.7 for all. From the those the dotclock limit is the one you should hit first since DP can always fall back to 6bpc and that should be correspond to a dotclock of 480 MHz. Anyways, 360MHz is plenty for 4k@30.
Quoted 7 lines
Quoted 4 lines
The question really is why we need to do this in the first place. There's nothing in the spec telling is it's really required. All I can find in the DP spec is "Maud value is set to 2^15 (=32,768) when the audio clock is asynchronous to the
LS_Clk.", and thenWe made the patch because we found the HW can't calculate the value this will cause there is several seconds silence at the beginning of audio
Quoted 7 lines
playback.
Quoted 1 line
With this patch, the silence is much shorter than before and is acceptable.
I see. Must be sink specific since at least my current monitor (ASUS PB278) has no apparent delays with the current code. I guess some sinks are just slower in clock recovery than others, and starting out with better M/N values can speed it up a bit.
Yes, behaviors are different between different monitors.
Quoted 3 lines
Anyways, please specify this reason for the change in the commit message, otherwise no one can figure out why it's needed.
Get it. I will add it.
Regards,
Libin
Quoted 4 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 136 lines · Libin
Hi Ville,
Quoted 134 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 1:39 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 56 lines · Libin
Hi Ville,
Quoted 54 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 11 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800,
[email protected]Quoted 31 lines · wrote:
Quoted 27 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio is playing.The relationship of Maud and Naud is expressed in the following equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?Quoted 5 lines
Quoted 5 lines
I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the test. 5.4 is for 4K and 1.62 is for 1080p.
Quoted 2 lines
And I see you're only doing this on HSW+. Earlier platforms don't need
this?
Quoted 33 lines
Quoted 28 lines
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 107
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 115
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 +};The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
Quoted 8 lines
Quoted 4 lines
How about basing that decision on what's actually allowed by the driver? I can do 96kHz DP audio on my HSW just fine here. So clearly if the display supports it, there is nothing on the ALSA side that would prevent it from being used.
For 96KHz, audio will convert to 48KHz. You can try to print the sample rate in
i915_audio_component_sync_audio_rate(). So we can't test it for the real 96kHz.
Wrong.
# grep rate /proc/asound/HDMI/eld#0.0 sad0_rates [0x4e0] 32000 44100 48000 96000
# grep rate /proc/asound/HDMI/pcm3p/sub0/hw_params rate: 96000 (96000/1)
[drm:i915_audio_component_sync_audio_rate] sample rate 96000 kHz
Quoted 2 lines
In DP spec, table 2-50 only says 48kHz, 32kHz, 44.1kHz, 384kHz and 768kHz.
That table is just for informative purposes. The values are the ones you get from the formula. And the ELD can contain exactly the same SADs as with HDMI, so all the same sample rates can be used.
Quoted 252 lines
However, the latter two sample rates is not supported in audio driver and can't be tested so far. 88kHz, 96kHz and 192kHz cannot be tested, either.
Regards,
LibinQuoted 246 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ staticu32
audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted_mode){ @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode*mode, int rate)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static int audio_config_get_n (struct intel_crtc *crtc, + const struct drm_display_mode
*adjusted_mode,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+ int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock ==aud_ncts[i].clock)) {
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
{
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int +rate) {int i;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4-for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
{
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg (int n,uint32_t val) +static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 17 lines
drivers/gpu/drm/i915/intel_audio.c +14
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m;drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog (struct intel_crtc *crtc, -const struct drm_display_mode *mode) + const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +6
-2{ -if (((mode->clock ==TMDS_297M ) || - (mode->clock ==TMDS_296M )) && +if (((adjusted_mode->clock ==TMDS_297M ) || + (adjusted_mode->clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; +else if (((crtc->config->port_clock ==LC_540M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return true;else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +410,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n = audio_config_get_n(intel_crtc, adjusted_mode,rate);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp = audio_config_setup_n_reg(intel_crtc, n,tmp);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0else DRM_DEBUG_KMS ("no suitable N value is found\n" ); }I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config,INTEL_OUTPUT_DP )){
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct · line 427
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ tmp = audio_config_setup_m_reg(intel_crtc,m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct · line 428
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),tmp);
Quoted 77 lines
Quoted 77 lines
Quoted 18 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct drm_display_mode *mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 43 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock(&dev_priv->av_mutex); @@ -653,7 +731,8 @@ staticint
i915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) {DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for N value onport %c\n",
Quoted 19 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + }Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0unlock:
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC--
Ville Syrjälä
Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for drm/i915: set proper N/M in modeset (rev3)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: drm/i915: set proper N/M in modeset (rev3)
URL : https://patchwork.freedesktop.org/series/9857/
State : failure
== Summary ==
Applying: drm/i915: set proper N/M in modeset
fatal: sha1 information is lacking or useless (drivers/gpu/drm/i915/intel_dp.c).
error: could not build fake ancestor
Patch failed at 0001 drm/i915: set proper N/M in modeset
The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
Quoted 165 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 2:24 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 45 lines · Libin
Hi Ville,
Quoted 43 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 1:39 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 31 lines · Libin
Hi Ville,
Quoted 29 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 12 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800,
[email protected]Quoted 4 lines · wrote:
Quoted 4 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio isplaying.
Quoted 49 lines
Quoted 49 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 25 lines
The relationship of Maud and Naud is expressed in the following
equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the
test.
Quoted 39 lines
Quoted 39 lines
Quoted 5 lines
Quoted 5 lines
5.4 is for 4K and 1.62 is for 1080p.
Quoted 3 lines
And I see you're only doing this on HSW+. Earlier platforms don't need
this?
Quoted 32 lines
Quoted 27 lines
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 106
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 113
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 };The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
Quoted 8 lines
Quoted 4 lines
How about basing that decision on what's actually allowed by the driver? I can do 96kHz DP audio on my HSW just fine here. So clearly if the display supports it, there is nothing on the ALSA side that would prevent it from being used.
For 96KHz, audio will convert to 48KHz. You can try to print the sample rate in
i915_audio_component_sync_audio_rate(). So we can't test it for the real 96kHz.Wrong.
Quoted 7 lines
# grep rate /proc/asound/HDMI/eld#0.0 sad0_rates [0x4e0] 32000 44100 48000 96000# grep rate /proc/asound/HDMI/pcm3p/sub0/hw_params rate: 96000 (96000/1)[drm:i915_audio_component_sync_audio_rate] sample rate 96000 kHz
Interesting, maybe my monitor doesn't support. And my driver will convert it to 48KHz.
Quoted 7 lines
Quoted 3 lines
In DP spec, table 2-50 only says 48kHz, 32kHz, 44.1kHz, 384kHz and 768kHz.
That table is just for informative purposes. The values are the ones you get from the formula. And the ELD can contain exactly the same SADs as with HDMI, so all the same sample rates can be used.
Yes. I will add the other sample rates support. But these date will not be test as I can't play 96KHz audio with hardware support here.
Regards,
Libin
Quoted 262 lines
Quoted 109 lines
However, the latter two sample rates is not supported in audio driver and can't be tested so far. 88kHz, 96kHz and 192kHz cannot be tested, either.
Regards,
LibinQuoted 102 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static
u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted_mode) { @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode*mode, int rate)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static int audio_config_get_n (struct intel_crtc *crtc, + const struct drm_display_mode
*adjusted_mode,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+ int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock ==aud_ncts[i].clock)) {
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
{
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int +rate) {int i;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4-for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
{
Quoted 16 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg(int n, uint32_tval)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 23 lines
drivers/gpu/drm/i915/intel_audio.c +17
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m; + tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 154
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog(struct intel_crtc *crtc, - const struct drm_display_mode*mode)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 217
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 221
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +2
-2{ - if (((mode->clock == TMDS_297M) || - (mode->clock == TMDS_296M)) && + if (((adjusted_mode->clock == TMDS_297M) || + (adjusted_mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config,
INTEL_OUTPUT_HDMI))Quoted 28 lines
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP)) + return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static voidhsw_audio_codec_enable(struct
drm_connector*connector,Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +410,25 @@ static voidhsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n = audio_config_get_n(intel_crtc, adjusted_mode,rate);
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp = audio_config_setup_n_reg(intel_crtc, n,tmp);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 55 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0}I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config, +INTEL_OUTPUT_DP )){
Quoted 18 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ tmp = audio_config_setup_m_reg(intel_crtc,m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),tmp);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0struct drm_display_mode *mode; struct i915_audio_component *acomp = dev_priv-
audio_component;Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock(&dev_priv->av_mutex); @@ -653,7 +731,8 @@static int
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
i915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) { DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int · line 765
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for Nvalue on
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
port %c\n",
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:Quoted 3 lines
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
--
Ville Syrjälä
Intel OTC--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 180 lines · Libin
Hi Ville,
Quoted 165 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 2:24 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 45 lines · Libin
Hi Ville,
Quoted 43 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 1:39 PM
To: Yang, Libin <[email protected]>
Cc: '[email protected]' <[email protected]>; 'intel- [email protected]' <[email protected]>; '[email protected]' <[email protected]>; Vetter, Daniel <[email protected]>; '[email protected]' <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetQuoted 31 lines · Libin
Hi Ville,
Quoted 29 lines
-----Original Message-----
From: Yang, Libin
Sent: Tuesday, August 2, 2016 9:59 PM
To: Ville Syrjälä <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/i915: set proper N/M in modesetHi Ville
Quoted 12 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, August 2, 2016 6:47 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH] drm/i915: set proper N/M in modesetOn Tue, Aug 02, 2016 at 09:35:10AM +0800,
[email protected]Quoted 4 lines · wrote:
Quoted 4 lines
From: Libin Yang <[email protected]>
When modeset occurs and the
LS_CLKis set to some special values in DP mode, the N/M need to be set manually if audio isplaying.
Quoted 49 lines
Quoted 49 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 25 lines
The relationship of Maud and Naud is expressed in the following
equation:
Maud/Naud = 512 * fs /f_LS_ClkPlease refer VESA DisplayPort Standard spec for details.
Also, the patch applies
commit7e8275c2f2bb("drm/i915: set proper N/CTS in modeset") to APL platform.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 122 +++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/gpu/drm/i915/i915_reg.h enum { · line 7352
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -7351,6 +7351,12 @@ enum {#define _HSW_AUD_CONFIG_B 0x65100#define HSW_AUD_CFG (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_CONFIG_A,_HSW_AUD_CONFIG_B)Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h
Quoted 3 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define _HSW_AUD_M_CTS_ENABLE_A 0x65028 +#define _HSW_AUD_M_CTS_ENABLE_B 0x65128 +#define HSW_AUD_M_CTS_ENABLE (pipe)_MMIO_PIPE(pipe,
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 6 lines
drivers/gpu/drm/i915/i915_reg.h +3
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20) +#define _HSW_AUD_MISC_CTRL_A 0x65010#define _HSW_AUD_MISC_CTRL_B 0x65110#define HSW_AUD_MISC_CTRL (pipe) _MMIO_PIPE(pipe,
_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 101
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +2
-0+#define LC_540M 540000 +#define LC_162M 162000Do we have some explanation why 2.7 doesn't need M/N programming, but
1.62 and 5.4 do?I didn't use 2.7 because I can't find a mode using 2.7. So I can't do the
test.
Quoted 39 lines
Quoted 39 lines
Quoted 5 lines
Quoted 5 lines
5.4 is for 4K and 1.62 is for 1080p.
Quoted 3 lines
And I see you're only doing this on HSW+. Earlier platforms don't need
this?
Quoted 32 lines
Quoted 27 lines
We are not supporting earlier platforms and I'm not sure whether the old platforms supports 4K DP or not.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 106
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+static const struct { + int sample_rate; + int clock; + int n; + int m;Can save a bit of space by using u16 for m and n.
OK, I will do it in next version.
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 113
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+} aud_nm[] = { + {48000, LC_540M, 5625, 256},` + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024 };The numbers look good, but what about other sample rates? For HDMI we go up to 192kHz, why not for DP?
Quoted 2 lines
Our test only includes 32K, 44.1K and 48K :) I will add the support if you think we should.
I will not add 192KHz, 96KHz and etc rate support as based on my test these rate will be not used in DP. It will be converted to 48KHz.
Quoted 8 lines
Quoted 4 lines
How about basing that decision on what's actually allowed by the driver? I can do 96kHz DP audio on my HSW just fine here. So clearly if the display supports it, there is nothing on the ALSA side that would prevent it from being used.
For 96KHz, audio will convert to 48KHz. You can try to print the sample rate in
i915_audio_component_sync_audio_rate(). So we can't test it for the real 96kHz.Wrong.
Quoted 7 lines
# grep rate /proc/asound/HDMI/eld#0.0 sad0_rates [0x4e0] 32000 44100 48000 96000# grep rate /proc/asound/HDMI/pcm3p/sub0/hw_params rate: 96000 (96000/1)[drm:i915_audio_component_sync_audio_rate] sample rate 96000 kHz
Interesting, maybe my monitor doesn't support. And my driver will convert it to 48KHz.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
In DP spec, table 2-50 only says 48kHz, 32kHz, 44.1kHz, 384kHz and 768kHz.
That table is just for informative purposes. The values are the ones you get from the formula. And the ELD can contain exactly the same SADs as with HDMI, so all the same sample rates can be used.
Yes. I will add the other sample rates support. But these date will not be test as I can't play 96KHz audio with hardware support here.
Yeah, we can't always test all the combinations. Just have to go on faith that it works out ;)
Quoted 273 lines
Regards,
LibinQuoted 269 lines
Quoted 109 lines
However, the latter two sample rates is not supported in audio driver and can't be tested so far. 88kHz, 96kHz and 192kHz cannot be tested, either.
Regards,
LibinQuoted 102 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ static
u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted_mode) { @@ -121,20 +137,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1return hdmi_audio_clock[i].config; } -static int audio_config_get_n(const struct drm_display_mode*mode, int rate)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static int audio_config_get_n (struct intel_crtc *crtc, + const struct drm_display_mode
*adjusted_mode,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +8
-0+ int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { + if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock ==aud_ncts[i].clock)) {
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_ncts[i].n; + } + } + } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
{
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +9
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int +rate) {int i;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4-for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { -if ((rate == aud_ncts[i].sample_rate) && - (mode->clock == aud_ncts[i].clock)) { -return aud_ncts[i].n; +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { +for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { + if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock ==aud_nm[i].clock))
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
{
Quoted 16 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1+return aud_nm[i].m; + } } } +return 0 ; } -static uint32_t audio_config_setup_n_reg(int n, uint32_tval)
drivers/gpu/drm/i915/intel_audio.c +2
-0+static uint32_t audio_config_setup_n_reg (struct intel_crtc *crtc, +int n,uint32_t val) {int n_low, n_up;uint32_t tmp = val;drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 191
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +191,38 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)Quoted 23 lines
drivers/gpu/drm/i915/intel_audio.c +17
-0tmp |= ((n_up <<AUD_CONFIG_UPPER_N_SHIFT ) | (n_low <<AUD_CONFIG_LOWER_N_SHIFT ) |AUD_CONFIG_N_PROG_ENABLE ); +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) + tmp |=AUD_CONFIG_N_VALUE_INDEX ; +return tmp; +} + +static uint32_t audio_config_setup_m_reg (struct intel_crtc *crtc, +int m,uint32_t val) +{ +uint32_t tmp = val; + +if (!intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +return 0 ; + + tmp |= m; + tmp |=AUD_M_CTS_M_VALUE_INDEX ; + tmp |=AUD_M_CTS_M_PROG_ENABLE ; +return tmp; }Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 154
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1/* check whether N/CTS/M need be set manually */ static bool audio_rate_need_prog(struct intel_crtc *crtc, - const struct drm_display_mode*mode)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 217
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ const struct drm_display_mode
*adjusted_mode)drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 221
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +2
-2{ - if (((mode->clock == TMDS_297M) || - (mode->clock == TMDS_296M)) && + if (((adjusted_mode->clock == TMDS_297M) || + (adjusted_mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config,
INTEL_OUTPUT_HDMI))Quoted 28 lines
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP)) + return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +354,7 @@ static voidhsw_audio_codec_enable(struct
drm_connector*connector,Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1struct intel_digital_port *intel_dig_port =enc_to_dig_port (&encoder->base);enum port port = intel_dig_port->port; -uint32_t tmp; +uint32_t tmp, m;int len, i;int n, rate;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +410,25 @@ static voidhsw_audio_codec_enable(struct
drm_connector*connector,drivers/gpu/drm/i915/intel_audio.c
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1DRM_ERROR ("invalid port: %d\n" , port); rate =0 ; } - n =audio_config_get_n (adjusted_mode, rate); + n = audio_config_get_n(intel_crtc, adjusted_mode,rate);
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1if (n !=0 ) - tmp =audio_config_setup_n_reg (n, tmp); + tmp = audio_config_setup_n_reg(intel_crtc, n,tmp);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 55 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0}I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (intel_crtc->config, +INTEL_OUTPUT_DP )){
Quoted 18 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ m =audio_config_get_m (intel_crtc, rate); +if (m !=0 ) { + tmp =I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ tmp = audio_config_setup_m_reg(intel_crtc,m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +1
-0+ I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),tmp);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +714,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0struct drm_display_mode *mode; struct i915_audio_component *acomp = dev_priv-
audio_component;Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1enum pipe pipe =INVALID_PIPE ; -u32 tmp; +u32 tmp, m;int n;int err =0 ;@@ -645,7 +722,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c static int · line 727
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1if (!IS_SKYLAKE (dev_priv) && !IS_KABYLAKE (dev_priv) && !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) + !IS_HASWELL (dev_priv) && + !IS_BROXTON (dev_priv))return 0 ;
HAS_DDIperhaps?Do you mean we should add "&&
HAS_DDI"?
Could you please give me more details?Regards,
LibinQuoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0mutex_lock(&dev_priv->av_mutex); @@ -653,7 +731,8 @@static int
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
i915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1intel_encoder = dev_priv->dig_port_map[port];/* intel_encoder might be NULL for DP MST */ if (!intel_encoder || !intel_encoder->base.crtc || - intel_encoder->type !=INTEL_OUTPUT_HDMI ) { + ((intel_encoder->type !=INTEL_OUTPUT_HDMI ) && + (intel_encoder->type !=INTEL_OUTPUT_DP ))) { DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0err = -ENODEV ; goto unlock;@@ -681,7 +760,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int · line 765
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1goto unlock; } - n =audio_config_get_n (mode, rate); + n =audio_config_get_n (crtc, mode, rate);if (n ==0 ) { DRM_DEBUG_KMS("Using automatic mode for Nvalue on
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
port %c\n",
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +10
-1port_name(port));@@ -693,8 +772,17 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,/* 3. set the N/CTS/M */ tmp =I915_READ (HSW_AUD_CFG (pipe)); - tmp =audio_config_setup_n_reg (n, tmp); + tmp =audio_config_setup_n_reg (crtc, n, tmp);I915_WRITE (HSW_AUD_CFG (pipe), tmp); +/* setup m value for DP */ +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) { + m =audio_config_get_m (crtc, rate); +if (m ==0 ) + goto unlock; + tmp =I915_READ (HSW_AUD_M_CTS_ENABLE (pipe)); + tmp =audio_config_setup_m_reg (crtc, m, tmp); +I915_WRITE (HSW_AUD_M_CTS_ENABLE (pipe), tmp); + } unlock:Quoted 3 lines
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTCQuoted 3 lines
Quoted 3 lines
--
Ville Syrjälä
Intel OTC--
Ville Syrjälä
Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx