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.
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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 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 +102 -14
198 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
== Series Details ==
== Series Details ==
Series: drm/i915: set proper N/M in modeset
URL : https://patchwork.freedesktop.org/series/9857/
State : failure
== Summary ==
Series 9857v1 drm/i915: set proper N/M in modeset
http://patchwork.freedesktop.org/api/1.0/series/9857/revisions/1/mbox
Test drv_module_reload_basic:
dmesg-warn -> SKIP (fi-skl-i5-6260u)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> DMESG-WARN (ro-skl3-i5-6260u)
Test prime_self_import:
Subgroup basic-with_fd_dup:
pass -> INCOMPLETE (ro-byt-n2820)
Subgroup basic-with_one_bo_two_files:
pass -> INCOMPLETE (ro-byt-n2820)
Subgroup basic-with_two_bos:
pass -> INCOMPLETE (ro-byt-n2820)fi-kbl-qkkr total:237 pass:174 dwarn:27 dfail:2 fail:7 skip:27 fi-skl-i5-6260u total:237 pass:189 dwarn:26 dfail:2 fail:7 skip:13 fi-skl-i7-6700k total:237 pass:200 dwarn:2 dfail:0 fail:9 skip:26 fi-snb-i7-2600 total:237 pass:188 dwarn:0 dfail:0 fail:9 skip:40 ro-bdw-i5-5250u total:237 pass:210 dwarn:2 dfail:0 fail:9 skip:16 ro-bdw-i7-5600u total:237 pass:195 dwarn:2 dfail:0 fail:9 skip:31 ro-bsw-n3050 total:217 pass:170 dwarn:0 dfail:0 fail:4 skip:42 ro-byt-n2820 total:237 pass:174 dwarn:0 dfail:0 fail:7 skip:38 ro-hsw-i3-4010u total:237 pass:199 dwarn:5 dfail:2 fail:7 skip:24 ro-hsw-i7-4770r total:237 pass:204 dwarn:0 dfail:0 fail:9 skip:24 ro-ilk-i7-620lm total:237 pass:166 dwarn:0 dfail:0 fail:8 skip:63 ro-ilk1-i5-650 total:232 pass:166 dwarn:0 dfail:0 fail:8 skip:58 ro-ivb-i7-3770 total:237 pass:197 dwarn:0 dfail:0 fail:7 skip:33 ro-skl3-i5-6260u total:237 pass:212 dwarn:4 dfail:0 fail:9 skip:12 ro-snb-i7-2620M total:237 pass:187 dwarn:0 dfail:0 fail:9 skip:41
ro-bdw-i7-5557U failed to connect after reboot
Results at /archive/results/CI_IGT_test/RO_Patchwork_1490/
5cd2699 drm-intel-nightly: 2016y-07m-13d-14h-43m-27s UTC integration manifest 9ea6eab drm/i915: set proper N/M in modeset
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Ro.CI.BAT: failure for drm/i915: set proper N/M in modeset
Hi All,
I submitted a patch and it show to fail in CI.
Does the message means it is failed because of "ro-bdw-i7-5557U failed to connect after reboot". And how can I get the dmesg?
Regards,
Libin
Quoted 52 lines
-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Patchwork
Sent: Thursday, July 14, 2016 3:39 PM
To: [email protected]
Cc: [email protected]
Subject: [Intel-gfx] ✗ Ro.CI.BAT: failure for drm/i915: set proper N/M in modeset== Series Details ==
Series: drm/i915: set proper N/M in modeset
URL : https://patchwork.freedesktop.org/series/9857/
State : failure== Summary ==
Series 9857v1 drm/i915: set proper N/M in modeset
http://patchwork.freedesktop.org/api/1.0/series/9857/revisions/1/mboxTest
drv_module_reload_basic:dmesg-warn -> SKIP (fi-skl-i5-6260u) Test kms_pipe_crc_basic: Subgroup suspend-read-crc-pipe-b: pass -> DMESG-WARN (ro-skl3-i5-6260u) Test prime_self_import: Subgroup basic-with_fd_dup: pass -> INCOMPLETE (ro-byt-n2820) Subgroup basic-with_one_bo_two_files: pass -> INCOMPLETE (ro-byt-n2820) Subgroup basic-with_two_bos: pass -> INCOMPLETE (ro-byt-n2820)fi-kbl-qkkr total:237 pass:174 dwarn:27 dfail:2 fail:7 skip:27 fi-skl-i5-6260u total:237 pass:189 dwarn:26 dfail:2 fail:7 skip:13 fi-skl-i7-6700k total:237 pass:200 dwarn:2 dfail:0 fail:9 skip:26 fi-snb-i7-2600 total:237 pass:188 dwarn:0 dfail:0 fail:9 skip:40 ro-bdw-i5-5250u total:237 pass:210 dwarn:2 dfail:0 fail:9 skip:16 ro-bdw-i7-5600u total:237 pass:195 dwarn:2 dfail:0 fail:9 skip:31 ro-bsw-n3050 total:217 pass:170 dwarn:0 dfail:0 fail:4 skip:42 ro-byt-n2820 total:237 pass:174 dwarn:0 dfail:0 fail:7 skip:38 ro-hsw-i3-4010u total:237 pass:199 dwarn:5 dfail:2 fail:7 skip:24 ro-hsw-i7-4770r total:237 pass:204 dwarn:0 dfail:0 fail:9 skip:24 ro-ilk-i7-620lm total:237 pass:166 dwarn:0 dfail:0 fail:8 skip:63 ro-ilk1-i5-650 total:232 pass:166 dwarn:0 dfail:0 fail:8 skip:58 ro-ivb-i7-3770 total:237 pass:197 dwarn:0 dfail:0 fail:7 skip:33 ro-skl3-i5-6260u total:237 pass:212 dwarn:4 dfail:0 fail:9 skip:12 ro-snb-i7-2620M total:237 pass:187 dwarn:0 dfail:0 fail:9 skip:41ro-bdw-i7-5557U failed to connect after reboot
Results at /archive/results/CI_IGT_test/RO_Patchwork_1490/
Quoted 7 lines
5cd2699 drm-intel-nightly: 2016y-07m-13d-14h-43m-27s UTC integration manifest 9ea6eab drm/i915: set proper N/M in modeset
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi all,
Is there anyone can help review this patch? This patch is set N/M for audio in DP 4k resolution. Thanks.
I calculate these values based on the DP1.2 spec chapter 6.6 on page 469:
Maud / Naud = 512 * fs / f_LS_Clk
Regards,
Libin
Quoted 270 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, July 14, 2016 3:06 PM
To: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Cc: Yang, Libin <[email protected]>; Libin Yang <[email protected]>
Subject: [PATCH] drm/i915: set proper N/M in modesetFrom: 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.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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hindex 8bfde75..2f9d00e 100644drivers/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_B0x65110
#defineHSW_AUD_MISC_CTRL(pipe)_MMIO_PIPE(pipe,_HSW_AUD_MISC_CTRL_A,_HSW_AUD_MISC_CTRL_B)drivers/gpu/drm/i915/intel_audio.c +16
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_533M 533250 +#define LC_148M 148500 +static const struct { +int sample_rate; +int clock; +int n; +int m; +} aud_nm[] = { + {48000 ,LC_533M ,88875 ,4096 }, + {44100 ,LC_533M ,148125 ,6272 }, + {32000 ,LC_533M ,266625 ,8192 }, + {48000 ,LC_148M ,12375 ,2048 }, + {44100 ,LC_148M ,20625 ,3136 }, + {32000 ,LC_148M ,37125 ,4096 }, +}; + /* 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, intrate)
drivers/gpu/drm/i915/intel_audio.c +56
-5+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *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) && + (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) && + (mode->clock == aud_nm[i].clock)) { +return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc, +const struct drm_display_mode *mode,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) && + (mode->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,6 +191,23 @@ 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; }@@ -156,6 +219,10 @@ static bool audio_rate_need_prog(struct intel_crtc *crtc, (mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config, INTEL_OUTPUT_HDMI))return true; + else if (((mode->clock == LC_533M) || + (mode->clock == LC_148M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP)) + return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +14
-4@@ -287,7 +354,7 @@ static void hsw_audio_codec_enable(structdrm_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, adjusted_mode, 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;drivers/gpu/drm/i915/intel_audio.c +2
-1int err =0 ;@@ -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;drivers/gpu/drm/i915/intel_audio.c +2
-1mutex_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 ;drivers/gpu/drm/i915/intel_audio.c +1
-1goto 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 onport %c\n",
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, mode, 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
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 73 lines · On Thu, Jul 14, 2016 at 03:06:21PM +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.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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 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 +24
-1@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_533M 533250 +#define LC_148M 148500 +static const struct { +int sample_rate; +int clock; +int n; +int m; +} aud_nm[] = { + {48000 ,LC_533M ,88875 ,4096 }, + {44100 ,LC_533M ,148125 ,6272 }, + {32000 ,LC_533M ,266625 ,8192 }, + {48000 ,LC_148M ,12375 ,2048 }, + {44100 ,LC_148M ,20625 ,3136 }, + {32000 ,LC_148M ,37125 ,4096 }, +}; +/* 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 *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 · line 157
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (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) && + (mode->clock == aud_nm[i].clock)) {
So the spec says we should have "Maud / Naud = 512 * fs / f_LS_Clk", where fs is the audio sample rate, and f_LS_CLK is the link symbol clock. With that in mind this should not be looking at mode->clock but crtc->config->port_clock.
So I don't actually understand why you say LS_CLK has "special" values. It shouldn't. It's always either 162, 270, or 540 MHz.
Actually even the HDMI case is wrong in the code, it should be looking at mode->crtc_clock instead of mode->clock. Or perhaps even port_clock, if my reading of the HDMI spec is correct, but I never got any sane answer from any hw folks to my questions about this :(
Quoted 165 lines
drivers/gpu/drm/i915/intel_audio.c +68
-13+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc, +const struct drm_display_mode *mode,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) && + (mode->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,6 +191,23 @@ 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; }@@ -156,6 +219,10 @@ static bool audio_rate_need_prog(struct intel_crtc *crtc, (mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config, INTEL_OUTPUT_HDMI))return true; + else if (((mode->clock == LC_533M) || + (mode->clock == LC_148M)) && + 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, adjusted_mode, 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 ;@@ -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 ;mutex_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, mode, 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
Hi Ville,
Quoted 102 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, July 28, 2016 3:42 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 21 lines · On Thu, Jul 14, 2016 at 03:06:21PM +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.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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 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 40 lines
drivers/gpu/drm/i915/intel_audio.c +16
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_533M 533250 +#define LC_148M 148500 +static const struct { +int sample_rate; +int clock; +int n; +int m; +} aud_nm[] = { + {48000 ,LC_533M ,88875 ,4096 }, + {44100 ,LC_533M ,148125 ,6272 }, + {32000 ,LC_533M ,266625 ,8192 }, + {48000 ,LC_148M ,12375 ,2048 }, + {44100 ,LC_148M ,20625 ,3136 }, + {32000 ,LC_148M ,37125 ,4096 }, +}; + /* 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 +7
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *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 · line 157
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (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) && + (mode->clock == aud_nm[i].clock)) {So the spec says we should have "Maud / Naud = 512 * fs /
f_LS_Clk", where fs is the audio sample rate, andf_LS_CLKis the link symbol clock. With that in mind this should not be looking atmode->clockbutcrtc->config->port_clock.
Quoted 2 lines
So I don't actually understand why you say
LS_CLKhas "special" values. It shouldn't. It's always either 162, 270, or 540 MHz.
Thanks for the correction. I will use crtc->config->port_clock.
Quoted 5 lines
Actually even the HDMI case is wrong in the code, it should be looking at
mode->crtc_clockinstead ofmode->clock. Or perhaps evenport_clock, if my reading of the HDMI spec is correct, but I never got any sane answer from any hw folks to my questions about this :(
I will try mode->crtc_clock later for HDMI. Thanks.
Regards,
Libin
Quoted 173 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n,
Quoted 36 lines
drivers/gpu/drm/i915/intel_audio.c +18
-5+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc, +const struct drm_display_mode *mode,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) && + (mode->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,6 +191,23 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static bool audio_rate_need_prog(struct intel_crtc
Quoted 24 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; }@@ -156,6 +219,10 @@ static bool audio_rate_need_prog(struct intel_crtc*crtc,
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0(mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config, INTEL_OUTPUT_HDMI))return true; + else if (((mode->clock == LC_533M) || + (mode->clock == LC_148M)) && + 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, adjusted_mode, 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 10 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
Quoted 10 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 ;mutex_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, mode, 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
Quoted 104 lines · Libin
Hi Ville,
Quoted 102 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, July 28, 2016 3:42 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 21 lines · On Thu, Jul 14, 2016 at 03:06:21PM +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.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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 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 40 lines
drivers/gpu/drm/i915/intel_audio.c +16
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_533M 533250 +#define LC_148M 148500 +static const struct { +int sample_rate; +int clock; +int n; +int m; +} aud_nm[] = { + {48000 ,LC_533M ,88875 ,4096 }, + {44100 ,LC_533M ,148125 ,6272 }, + {32000 ,LC_533M ,266625 ,8192 }, + {48000 ,LC_148M ,12375 ,2048 }, + {44100 ,LC_148M ,20625 ,3136 }, + {32000 ,LC_148M ,37125 ,4096 }, +}; + /* 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 +7
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *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 · line 157
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (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) && + (mode->clock == aud_nm[i].clock)) {So the spec says we should have "Maud / Naud = 512 * fs /
f_LS_Clk", where fs is the audio sample rate, andf_LS_CLKis the link symbol clock. With that in mind this should not be looking atmode->clockbutcrtc->config->port_clock.
Quoted 4 lines
Quoted 2 lines
So I don't actually understand why you say
LS_CLKhas "special" values. It shouldn't. It's always either 162, 270, or 540 MHz.Thanks for the correction. I will use
crtc->config->port_clock.
But why do you need to do it at all? The hardware can't deal with one of the standard link rates on its own?
Quoted 8 lines
Quoted 6 lines
Actually even the HDMI case is wrong in the code, it should be looking at
mode->crtc_clockinstead ofmode->clock. Or perhaps evenport_clock, if my reading of the HDMI spec is correct, but I never got any sane answer from any hw folks to my questions about this :(I will try
mode->crtc_clocklater for HDMI. Thanks.
While you're at it, can you pls do s/mode/adjusted_mode/ ? A while back I unified our naming convention for these things, but looks like the audio code has since gone back to the inconsisten old way.
Quoted 185 lines
Regards,
LibinQuoted 181 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n,
Quoted 36 lines
drivers/gpu/drm/i915/intel_audio.c +18
-5+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc, +const struct drm_display_mode *mode,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) && + (mode->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,6 +191,23 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static bool audio_rate_need_prog(struct intel_crtc
Quoted 24 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; }@@ -156,6 +219,10 @@ static bool audio_rate_need_prog(struct intel_crtc*crtc,
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0(mode->clock == TMDS_296M)) && intel_crtc_has_type(crtc->config, INTEL_OUTPUT_HDMI))return true; + else if (((mode->clock == LC_533M) || + (mode->clock == LC_148M)) && + 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, adjusted_mode, 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 10 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
Quoted 10 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 ;mutex_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, mode, 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 116 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, July 29, 2016 5:47 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 12 lines · Libin
Hi Ville,
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, July 28, 2016 3:42 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 Thu, Jul 14, 2016 at 03:06:21PM +0800, [email protected]
Quoted 25 lines · wrote:
Quoted 25 lines
Quoted 21 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.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 | 116 ++++++++++++++++++++++++++++++++----- 2 files changed, 108 insertions(+), 14 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 28 lines
Quoted 28 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 20 lines
drivers/gpu/drm/i915/intel_audio.c +12
-0@@ -98,6 +98,22 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, }; +#define LC_533M 533250 +#define LC_148M 148500 +static const struct { +int sample_rate; +int clock; +int n; +int m; +} aud_nm[] = { + {48000 ,LC_533M ,88875 ,4096 }, + {44100 ,LC_533M ,148125 ,6272 }, + {32000 ,LC_533M ,266625 ,8192 }, + {48000, LC_148M, 12375, 2048},Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+ {44100, LC_148M, 20625, 3136}, + {32000, LC_148M, 37125, 4096}, +}; + /* 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 27 lines
Quoted 27 lines
Quoted 11 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 +7
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *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 · line 157
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ (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) && + (mode->clock == aud_nm[i].clock)) {So the spec says we should have "Maud / Naud = 512 * fs /
f_LS_Clk", where fs is the audio sample rate, andf_LS_CLKis the link symbol clock. With that in mind this should not be looking atmode->clockbutcrtc->config->port_clock.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
So I don't actually understand why you say
LS_CLKhas "special" values. It shouldn't. It's always either 162, 270, or 540 MHz.Thanks for the correction. I will use
crtc->config->port_clock.But why do you need to do it at all? The hardware can't deal with one of the standard link rates on its own?
Yes, we found that the HW can't set the N/M automatically. This will cause there is several seconds of silence at the beginning of audio playback.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Actually even the HDMI case is wrong in the code, it should be looking at
mode->crtc_clockinstead ofmode->clock. Or perhaps evenport_clock,mode->ifmy
reading of the HDMI spec is correct, but I never got any sane answer from any hw folks to my questions about this :(
Quoted 5 lines
Quoted 1 line
I will try
mode->crtc_clocklater for HDMI. Thanks.While you're at it, can you pls do s/mode/adjusted_mode/ ? A while back I unified our naming convention for these things, but looks like the audio code has since gone back to the inconsisten old way.
Yes, I will do it, replace mode with adjusted_mode.
Regards,
Libin
Quoted 6 lines
Quoted 6 lines
Regards,
LibinQuoted 1 line
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx