drm/i915: set proper N/M in modeset
Subsystems (2)
PATCH v3 1/3 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. Otherwise the first several seconds may be silent in audio playback.
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.
--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 +117 -16
211 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
PATCH v3 2/3 drm/i915: set proper N/MCTS on more platforms
From: Libin Yang <[email protected]>
This patch applies setting proper N/M, N/CTS on more platforms.
--- drivers/gpu/drm/i915/intel_audio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +1 -5
@@ -732,11 +732,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,int n;int err =0 ; -/* HSW, BDW, SKL, KBL need this fix */ -if (!IS_SKYLAKE (dev_priv) && - !IS_KABYLAKE (dev_priv) && - !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) +if (!HAS_DDI (dev_priv))return 0 ;mutex_lock (&dev_priv->av_mutex);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 2/3] drm/i915: set proper N/MCTS on more platforms
Quoted 5 lines · On Thu, Aug 04, 2016 at 03:58:03PM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
This patch applies setting proper N/M, N/CTS on more platforms.
Signed-off-by Libin Yang <[email protected]>
Not that I particularly like this special casing of platforms. We should really try to unify this across the board, and I thought we already agreed that that was going to happen?
Quoted 23 lines
--- drivers/gpu/drm/i915/intel_audio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/i915/intel_audio.c +1
-5@@ -732,11 +732,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,int n;int err =0 ; -/* HSW, BDW, SKL, KBL need this fix */ -if (!IS_SKYLAKE (dev_priv) && - !IS_KABYLAKE (dev_priv) && - !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) +if (!HAS_DDI (dev_priv))return 0 ;mutex_lock (&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
Re: [PATCH v3 2/3] drm/i915: set proper N/MCTS on more platforms
Quoted 14 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:54 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 2/3] drm/i915: set proper N/MCTS on more platformsQuoted 4 lines · On Thu, Aug 04, 2016 at 03:58:03PM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
This patch applies setting proper N/M, N/CTS on more platforms.
Quoted 7 lines
Quoted 1 line
Signed-off-by Libin Yang <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>Not that I particularly like this special casing of platforms. We should really try to unify this across the board, and I thought we already agreed that that was going to happen?
Yes, and based on the spec, even it is not supporting 4K resolution, the n/mcts should also be OK. It is for clock, not for resolution. So I agree to apply the patches to other platforms.
Regards,
Libin
Quoted 23 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 11 lines
--- drivers/gpu/drm/i915/intel_audio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -732,11 +732,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +1
-5int n;int err =0 ; -/* HSW, BDW, SKL, KBL need this fix */ -if (!IS_SKYLAKE (dev_priv) && - !IS_KABYLAKE (dev_priv) && - !IS_BROADWELL (dev_priv) && - !IS_HASWELL (dev_priv)) +if (!HAS_DDI (dev_priv))return 0 ;
Quoted 7 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +0
-1mutex_lock (&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
PATCH v3 3/3 drm/i915: HDMI audio gets the TMDS clock by crtc_clock
In reply to [email protected]From: Libin Yang <[email protected]>
HDMI audio should use crtc_clock to get the TMDS clock.
Besides, this patch renames mode to adjusted_mode to unify the name.
--- drivers/gpu/drm/i915/intel_audio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +7 -7
@@ -159,7 +159,7 @@ static int audio_config_get_n(struct intel_crtc *crtc,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)) { + (adjusted_mode->crtc_clock == aud_ncts[i].clock)) {return aud_ncts[i].n; } }
@@ -228,8 +228,8 @@ static uint32_t audio_config_setup_m_reg(struct intel_crtc *crtc,static bool audio_rate_need_prog (struct intel_crtc *crtc,const struct drm_display_mode *adjusted_mode) { -if (((adjusted_mode->clock ==TMDS_297M ) || - (adjusted_mode->clock ==TMDS_296M )) && +if (((adjusted_mode->crtc_clock ==TMDS_297M ) || + (adjusted_mode->crtc_clock ==TMDS_296M )) &&intel_crtc_has_type (crtc->config,INTEL_OUTPUT_HDMI ))return true; else if (((crtc->config->port_clock == LC_540M) ||
@@ -725,7 +725,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,struct drm_i915_private *dev_priv =dev_to_i915 (dev);struct intel_encoder *intel_encoder;struct intel_crtc *crtc; -struct drm_display_mode *mode; +struct drm_display_mode *adjusted_mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ;u32 tmp, m;
@@ -756,20 +756,20 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,DRM_DEBUG_KMS ("pipe %c connects port %c\n" ,pipe_name (pipe),port_name (port)); - mode = &crtc->config->base.adjusted_mode; + adjusted_mode = &crtc->config->base.adjusted_mode;/* port must be valid now, otherwise the pipe will be invalid */ acomp->aud_sample_rate[port] = rate;/* 2. check whether to set the N/CTS/M manually or not */ -if (!audio_rate_need_prog (crtc, mode)) { +if (!audio_rate_need_prog (crtc, adjusted_mode)) { tmp =I915_READ (HSW_AUD_CFG (pipe)); tmp &= ~AUD_CONFIG_N_PROG_ENABLE ;I915_WRITE (HSW_AUD_CFG (pipe), tmp); goto unlock; } - n =audio_config_get_n (crtc, mode, rate); + n =audio_config_get_n (crtc, adjusted_mode, rate);if (n ==0 ) {DRM_DEBUG_KMS ("Using automatic mode for N value on port %c\n" ,port_name (port));
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v3 3/3] drm/i915: HDMI audio gets the TMDS clock by crtc_clock
Quoted 25 lines · On Thu, Aug 04, 2016 at 03:58:04PM +0800, [email protected] wrote:
From: Libin Yang <[email protected]>
HDMI audio should use
crtc_clockto get the TMDS clock.Besides, this patch renames mode to
adjusted_modeto unify the name.Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/intel_audio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/intel_audio.c +1
-1@@ -159,7 +159,7 @@ static int audio_config_get_n(struct intel_crtc *crtc,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)) { + (adjusted_mode->crtc_clock == aud_ncts[i].clock)) {return aud_ncts[i].n; } }
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_m_reg(struct intel_crtc *crtc, · line 232
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +2
-2@@ -228,8 +228,8 @@ static uint32_t audio_config_setup_m_reg(struct intel_crtc *crtc,static bool audio_rate_need_prog (struct intel_crtc *crtc,const struct drm_display_mode *adjusted_mode) { - if (((adjusted_mode->clock == TMDS_297M) || - (adjusted_mode->clock == TMDS_296M)) && + if (((adjusted_mode->crtc_clock == TMDS_297M) || + (adjusted_mode->crtc_clock == TMDS_296M)) &&
Indentation is still a bit off here, but that looks like a more systemic problem for intel_audio.c. Probably better to clean it all up separately.
So yeah, this patch looks all right
Quoted 38 lines
drivers/gpu/drm/i915/intel_audio.c +4
-4intel_crtc_has_type(crtc->config, INTEL_OUTPUT_HDMI))return true; else if (((crtc->config->port_clock == LC_540M) ||@@ -725,7 +725,7 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,struct drm_i915_private *dev_priv =dev_to_i915 (dev);struct intel_encoder *intel_encoder;struct intel_crtc *crtc; -struct drm_display_mode *mode; +struct drm_display_mode *adjusted_mode;struct i915_audio_component *acomp = dev_priv->audio_component;enum pipe pipe =INVALID_PIPE ;u32 tmp, m;@@ -756,20 +756,20 @@ static int i915_audio_component_sync_audio_rate(struct device *dev,DRM_DEBUG_KMS ("pipe %c connects port %c\n" ,pipe_name (pipe),port_name (port)); - mode = &crtc->config->base.adjusted_mode; + adjusted_mode = &crtc->config->base.adjusted_mode;/* port must be valid now, otherwise the pipe will be invalid */ acomp->aud_sample_rate[port] = rate;/* 2. check whether to set the N/CTS/M manually or not */ -if (!audio_rate_need_prog (crtc, mode)) { +if (!audio_rate_need_prog (crtc, adjusted_mode)) { tmp =I915_READ (HSW_AUD_CFG (pipe)); tmp &= ~AUD_CONFIG_N_PROG_ENABLE ;I915_WRITE (HSW_AUD_CFG (pipe), tmp); goto unlock; } - n =audio_config_get_n (crtc, mode, rate); + n =audio_config_get_n (crtc, adjusted_mode, rate);if (n ==0 ) {DRM_DEBUG_KMS ("Using automatic mode for N value on port %c\n" ,port_name (port));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
Quoted 7 lines · On Thu, Aug 04, 2016 at 03:58:02PM +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. Otherwise the first several seconds may be silent in audio playback.
Quoted 5 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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whatever
Quoted 12 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/i915_reg.h +0
-0
drivers/gpu/drm/i915/i915_reg.h enum { · line 7358
Quoted 8 lines
drivers/gpu/drm/i915/i915_reg.h +5
-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)
Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after HSW_AUD_MISC_CTRL.
Quoted 12 lines
drivers/gpu/drm/i915/i915_reg.h +1
-0+#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@@ -98,6 +98,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 110
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },
^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},
drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},
The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 14 lines
drivers/gpu/drm/i915/intel_audio.c +5
-1+}; +/* 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 +150,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) {
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 162
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_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) {
Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate &&
adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder() will make this work for MST as well.
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the LS_Clk of the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not an MST Source device."
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 171
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)) {
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +12
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) +{ +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 171
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)) {
indent + parens
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +7
-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 n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0@@ -145,17 +204,39 @@ 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 ))
intel_has_dp_encoder()
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;
The caller already checked that.
Quoted 13 lines
drivers/gpu/drm/i915/intel_audio.c +6
-1+ + 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) {
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 10 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_270M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP ))
intel_has_dp_encoder()
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c +3
-2+return true; else return false; }@@ -287,7 +368,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 +424,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 )
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 437
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1- 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 )) {
intel_has_dp_encoder()
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 442
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+ 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);
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from DP->HDMI.
Quoted 16 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +728,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 748
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +2
-1@@ -653,7 +744,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 ))) {
Hmm. Should probablt move this stuff later so that we can use check crtc->config->output_types instead. But I guess that's more appropriately left to any MST patch.
Quoted 13 lines
drivers/gpu/drm/i915/intel_audio.c +1
-1DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +773,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));
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 791
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1@@ -693,8 +785,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 )) {
intel_has_dp_encoder()
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 150 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 11 lines · On Thu, Aug 04, 2016 at 03:58:02PM +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. Otherwise the first several seconds may be silent in audio playback.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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 13 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 { · line 7358
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +1
-0+#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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,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 +3
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 162
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_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) {Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well."In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not an MST Source device."
Quoted 3 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
Quoted 128 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
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 +7
-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 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +6
-1+ + 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)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 11 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_270M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false; }@@ -287,7 +368,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 +424,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 6 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);if (n !=0 )drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 437
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1- 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 )) {
intel_has_dp_encoder()
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 442
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+ 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);We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Quoted 19 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +728,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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.
The same reason as intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.
Regards,
Libin
Quoted 36 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +773,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",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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
Quoted 158 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 150 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 11 lines · On Thu, Aug 04, 2016 at 03:58:02PM +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. Otherwise the first several seconds may be silent in audio playback.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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 13 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 { · line 7358
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.drivers/gpu/drm/i915/i915_reg.h enum {
Quoted 4 lines
drivers/gpu/drm/i915/i915_reg.h +1
-0+#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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,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 +3
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 162
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_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) {Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well."In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not an MST Source device."Quoted 3 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
Quoted 8 lines
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use intel_dp_encoder() from the start. It will make the MST patch smaller too, which will make it easier to review.
Quoted 138 lines
Quoted 129 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
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 +7
-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 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +6
-1+ + 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)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 11 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_270M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false; }@@ -287,7 +368,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 +424,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 6 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);if (n !=0 )drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 437
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1- 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 )) {
intel_has_dp_encoder()Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 442
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+ 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);We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.
Quoted 2 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
Quoted 31 lines
Quoted 20 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +728,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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.
Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.
Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 48 lines
Regards,
LibinQuoted 44 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +773,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",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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 178 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 14 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +0800, [email protected]
Quoted 35 lines · wrote:
Quoted 35 lines
Quoted 11 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. Otherwise the first several seconds may be silent in audio playback.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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 13 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 54 lines
Quoted 54 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum { · line 7358
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 34 lines
Quoted 34 lines
Quoted 8 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 +3
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 162
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_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) {Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well.Quoted 7 lines
Quoted 7 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 7 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier to review.
OK, I will use intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)
Quoted 140 lines
Quoted 140 lines
Quoted 139 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +7
-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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +6
-1+ + 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)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 11 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_270M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +368,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 +424,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 6 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);if (n !=0 )drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 437
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1- 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 )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 442
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+ 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);We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.
Quoted 5 lines
Quoted 2 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP -> HDMI and HDMI -> DP. What's more it can handle sample rate/tmds changes.
Regards,
Libin
Quoted 88 lines
Quoted 32 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +728,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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 48 lines
Regards,
LibinQuoted 44 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +773,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",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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 3 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 330 lines · Libin
Hi Ville,
Quoted 178 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 14 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +0800, [email protected]
Quoted 35 lines · wrote:
Quoted 35 lines
Quoted 11 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. Otherwise the first several seconds may be silent in audio playback.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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 13 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 54 lines
Quoted 54 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum { · line 7358
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 34 lines
Quoted 34 lines
Quoted 8 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 +3
-0+static int audio_config_get_n (struct intel_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +int rate) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 162
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_HDMI )) { +for (i =0 ; i <ARRAY_SIZE (aud_ncts); i++) { +if ((rate == aud_ncts[i].sample_rate) && + (adjusted_mode->clock == aud_ncts[i].clock)) {Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well.Quoted 7 lines
Quoted 7 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 7 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier to review.OK, I will use
intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)Quoted 140 lines
Quoted 140 lines
Quoted 139 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+for (i =0 ; i <ARRAY_SIZE (aud_nm); i++) { +if ((rate == aud_nm[i].sample_rate) && + (crtc->config->port_clock == aud_nm[i].clock)){
indent + parens
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +7
-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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +6
-1+ + 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)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 11 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_270M ) || + (crtc->config->port_clock ==LC_162M )) && +intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +368,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 +424,25 @@ static void hsw_audio_codec_enable(struct
drm_connector*connector,Quoted 6 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);if (n !=0 )drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 437
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1- 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 )) {
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector, · line 442
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+ 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);We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP -> HDMI and HDMI -> DP.
Did you make sure eg. that the power well didn't get toggled in between? That would reset the register anyway.
Quoted 96 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 91 lines
Quoted 32 lines
Quoted 21 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }@@ -637,7 +728,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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 48 lines
Regards,
LibinQuoted 44 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS ("no valid port %c\n" ,port_name (port)); err = -ENODEV ; goto unlock;@@ -681,7 +773,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",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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--
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
Quoted 369 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 2:36 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 33 lines · Libin
Hi Ville,
Quoted 31 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 16 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 12 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +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 100 lines
Quoted 100 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines
Otherwise the first several seconds may be silent in audio playback.
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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 14 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 54 lines
Quoted 54 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h enum { · line 7358
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 127
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
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 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ int rate) {int i;Quoted 8 lines
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_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 36 lines
Quoted 36 lines
Quoted 16 lines
Quoted 16 lines
Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 168
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well.Quoted 8 lines
Quoted 8 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier toreview.
Quoted 10 lines
OK, I will use
intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+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 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
{
indent + parens
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted · line 183
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c static u32 audio_config_hdmi_pixel_clock(const struct drm_display_mode *adjusted
Quoted 3 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+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 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
{
indent + parens
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +7
-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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 207
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 218
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +5
-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
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
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 230
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 audio_config_setup_n_reg(int n, uint32_t val)
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 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t audio_config_setup_n_reg(int n, uint32_t val) · line 238
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_270M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +368,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 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +424,25 @@ static voidhsw_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
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 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct drm_connector *connector,
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 )) {
intel_has_dp_encoder()Quoted 3 lines
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
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
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 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP -> HDMI and HDMI -> DP.
Did you make sure eg. that the power well didn't get toggled in between? That would reset the register anyway.
We have done the test for this case. So far it is OK.
Regards,
Libin
Quoted 98 lines
Quoted 15 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }Quoted 38 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -637,7 +728,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 33 lines
Quoted 20 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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int i915_audio_component_sync_audio_rate(struct device *dev, · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 6 lines
Regards,
LibinQuoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));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 +773,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 Nvalue on
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 31 lines
port %c\n",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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 372 lines · Libin
Quoted 372 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 2:36 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 33 lines · Libin
Hi Ville,
Quoted 31 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 16 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 12 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +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 100 lines
Quoted 100 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines
Otherwise the first several seconds may be silent in audio playback.
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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 14 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 54 lines
Quoted 54 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 126
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
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 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ int rate) {int i;Quoted 8 lines
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_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 36 lines
Quoted 36 lines
Quoted 16 lines
Quoted 16 lines
Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c
Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()will make this work for MST as well.Quoted 8 lines
Quoted 8 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier toreview.
Quoted 10 lines
OK, I will use
intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)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 +3
-0+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 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
{
indent + parens
drivers/gpu/drm/i915/intel_audio.c
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) {
intel_has_dp_encoder()Quoted 3 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+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 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
{
indent + parens
Quoted 15 lines
drivers/gpu/drm/i915/intel_audio.c +7
-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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 208
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 219
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +11
-0+ 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 ;The caller already checked that.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +5
-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
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
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 230
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 234
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 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 239
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_270M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static void hsw_audio_codec_enable(struct
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false;}
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -287,7 +368,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 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +424,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 3 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
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 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 )) {
intel_has_dp_encoder()Quoted 3 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
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
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 9 lines
Quoted 6 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The silicon seems to be able to handle the situation of DP -> HDMI and HDMI -> DP.
Did you make sure eg. that the power well didn't get toggled in between? That would reset the register anyway.
We have done the test for this case. So far it is OK.
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
Quoted 109 lines
Regards,
LibinQuoted 105 lines
Quoted 15 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }Quoted 38 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -637,7 +728,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 33 lines
Quoted 20 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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 6 lines
Regards,
LibinQuoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));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 +773,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int · line 778
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 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 31 lines
port %c\n",
drivers/gpu/drm/i915/intel_audio.c static int · line 792
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +3
-1port_name(port));@@ -693,8 +785,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 )) {
intel_has_dp_encoder()Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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
Quoted 396 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 3:17 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 41 lines · Libin
Quoted 41 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 2:36 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 29 lines · Libin
Hi Ville,
Quoted 27 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 17 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 13 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +0800,
[email protected]Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 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 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Otherwise the first several seconds may be silent in audio
playback.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 32 lines
Quoted 32 lines
Quoted 7 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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 14 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 7 lines
Quoted 7 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_AUD_MISC_CTRL(pipe)_MMIO_PIPE(pipe,
Quoted 287 lines
Quoted 287 lines
Quoted 53 lines
Quoted 53 lines
Quoted 43 lines
Quoted 43 lines
_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 126
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
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 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ int rate) {int i;Quoted 8 lines
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_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 38 lines
Quoted 38 lines
Quoted 17 lines
Quoted 17 lines
Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +{
intel_has_dp_encoder()will make this work for MST as well.Quoted 9 lines
Quoted 9 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier toreview.
Quoted 10 lines
OK, I will use
intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)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 +3
-0+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 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
{
indent + parens
drivers/gpu/drm/i915/intel_audio.c
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +12
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +{
intel_has_dp_encoder()Quoted 3 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+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 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
{
indent + parens
Quoted 16 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_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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 208
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 218
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ 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 ;The caller already checked that.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +5
-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
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
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 229
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 233
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 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 238
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_270M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP))
intel_has_dp_encoder()Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false; }@@ -287,7 +368,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 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +424,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 3 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
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 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 )) {
intel_has_dp_encoder()Quoted 3 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
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
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 12 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP -> HDMI and HDMI -> DP.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Did you make sure eg. that the power well didn't get toggled in between? That would reset the register anyway.
We have done the test for this case. So far it is OK.
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
The register is used to set m/cts, which will impacts the audio clock sync. We didn't check the register reset or not. But the HDMI audio and DP will both works smoothly. And for your consideration, it is for HDMI. Let's make another patch for this issue if we really met the issue that hdmi can't sync the clock. What do you think?
Quoted 108 lines
Quoted 108 lines
Regards,
LibinQuoted 103 lines
Quoted 15 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }Quoted 38 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -637,7 +728,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 33 lines
Quoted 20 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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 6 lines
Regards,
LibinQuoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));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 +773,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int · line 778
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 36 lines
Quoted 36 lines
Quoted 24 lines
Quoted 24 lines
port %c\n",
drivers/gpu/drm/i915/intel_audio.c static int · line 793
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1port_name(port));@@ -693,8 +785,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 )) +{
intel_has_dp_encoder()Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ 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 4 lines
unlock:
mutex_unlock(&dev_priv->av_mutex);
--
1.9.1--
Ville Syrjälä
Intel OTC--
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 400 lines · Libin
Quoted 400 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 3:17 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 41 lines · Libin
Quoted 41 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 2:36 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 29 lines · Libin
Hi Ville,
Quoted 27 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 1:57 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 17 lines · Libin
Hi Ville,
Sorry for delay reply. Please see my comments below.
Quoted 13 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Thursday, August 4, 2016 4:53 PM
To: [email protected]
Cc: [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]; Yang, Libin <[email protected]>
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetOn Thu, Aug 04, 2016 at 03:58:02PM +0800,
[email protected]Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 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 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Otherwise the first several seconds may be silent in audio
playback.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 32 lines
Quoted 32 lines
Quoted 7 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.
Pleas include a small changelog here so that I know what has changed with each revision of the patch. Eg:
v2: blah
v3: whateverQuoted 14 lines
Signed-off-by Libin Yang <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 6 ++ drivers/gpu/drm/i915/intel_audio.c | 133 ++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 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 7 lines
Quoted 7 lines
_HSW_AUD_M_CTS_ENABLE_A,_HSW_AUD_M_CTS_ENABLE_B)drivers/gpu/drm/i915/i915_reg.h
Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define AUD_M_CTS_M_VALUE_INDEX (1 << 21) +#define AUD_M_CTS_M_PROG_ENABLE (1 << 20)Please try to keep the register defines in order by the register offset. Ie. these registers should be placed just after
HSW_AUD_MISC_CTRL.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+
#define_HSW_AUD_MISC_CTRL_A0x65010
#define_HSW_AUD_MISC_CTRL_B0x65110
#defineHSW_AUD_MISC_CTRL(pipe)_MMIO_PIPE(pipe,
Quoted 290 lines
Quoted 281 lines
Quoted 53 lines
Quoted 53 lines
Quoted 43 lines
Quoted 43 lines
_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,35 @@ static const struct { { 192000, TMDS_297M, 20480, 247500 }, };drivers/gpu/drm/i915/intel_audio.c static const struct { · line 109
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+#define LC_540M 540000 +#define LC_270M 270000 +#define LC_162M 162000 +static const struct { +int sample_rate; +int clock; +u16 n; +u16 m; +} aud_nm[] = { + {192000 ,LC_540M ,5625 ,1024 },^ ^
Style nit: please add spaces here
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +7
-0+ {96000, LC_540M, 5625, 512}, + {88200, LC_540M, 9375, 784}, + {48000, LC_540M, 5625, 256}, + {44100, LC_540M, 9375, 392}, + {32000, LC_540M, 16875, 512}, + {192000, LC_270M, 5625, 2048}, + {96000, LC_270M, 5625, 1024},drivers/gpu/drm/i915/intel_audio.c static const struct { · line 126
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ {88200, LC_270M, 9375, 1568}, + {48000, LC_270M, 5625, 512}, + {44100, LC_270M, 9375, 784}, + {32000, LC_270M, 16875, 1024}, + {192000, LC_162M, 3375, 2048}, + {96000, LC_162M, 3375, 1024}, + {88200, LC_162M, 5625, 1568}, + {48000, LC_162M, 3375, 512}, + {44100, LC_162M, 5625, 784}, + {32000, LC_162M, 10125, 1024},The numbers looks good. But looks like you forgot about 176.4 kHz?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +2
-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 +150,50 @@ static u32 audio_config_hdmi_pixel_clock(const structdrm_display_mode*adjusted
Quoted 6 lines
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 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+ int rate) {int i;Quoted 8 lines
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_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 38 lines
Quoted 38 lines
Quoted 17 lines
Quoted 17 lines
Indent fail, and a bit too many parens for my taste. Should look like:
if (rate == aud_ncts[i].sample_rate && adjusted_mode->clock == aud_ncts[i].clock) {drivers/gpu/drm/i915/intel_audio.c
Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +5
-0+return aud_ncts[i].n; + } } } + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +{
intel_has_dp_encoder()will make this work for MST as well.Quoted 9 lines
Quoted 9 lines
"In MST mode, the Sink device must ignore the Maud and Mvid values sent by an MST Source device unless the MST Sink device is directly connected to the MST Source device via a single link as the Source device generates those values based on the
LS_Clkof the link it is driving. An MST Sink device must be able to regenerate a stream clock without depending on Mvid and Mvid time stamp values because the MST Sink device might be plugged into an MST Branch device, not anMST Source device."
Quoted 11 lines
Quoted 4 lines
So if I'm reading that right, an MST sink can still use the M/N values if it's direclty hooked up to a MST source. Hence we probably want to fill out the M/N even for MST.
My understanding is this is the requirement for sink device. Non-mst and MST, source will send the N/M value, and if it is Non-mst/single link, sink device should use these data to generate the clock. If it is in MST, sink device should ignore the data and regenerate the clock without depending on N/M value.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
So this code should OK be for both non-mst and MST. If not, I think we can make a separate patch for DP MST.
It's only OK for SST. We could of course delay dealing with MST, but that seems like unnecessary churn. You're touching all these places in this patch, so might as well use
intel_dp_encoder()from the start. It will make the MST patch smaller too, which will make it easier toreview.
Quoted 10 lines
OK, I will use
intel_crtc_has_dp_encoder(). Hope it still works for DP MST :)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 +3
-0+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 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
{
indent + parens
drivers/gpu/drm/i915/intel_audio.c
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +12
-0+return aud_nm[i].n; + } + } + } +return 0 ; +} + +static int audio_config_get_m (struct intel_crtc *crtc,int rate) { +int i; + +if (intel_crtc_has_type (crtc->config,INTEL_OUTPUT_DP )) +{
intel_has_dp_encoder()Quoted 3 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+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 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
{
indent + parens
Quoted 16 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_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 204
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -145,17 +204,39 @@ static uint32_t audio_config_setup_n_reg(int n,
uint32_tval)drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 208
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c +1
-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 ))
intel_has_dp_encoder()drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 218
Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +10
-0+ 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 ;The caller already checked that.
Quoted 8 lines
drivers/gpu/drm/i915/intel_audio.c +5
-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
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
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 229
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 233
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 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/intel_audio.c static uint32_t · line 238
Quoted 5 lines
drivers/gpu/drm/i915/intel_audio.c +4
-0return true; + else if (((crtc->config->port_clock == LC_540M) || + (crtc->config->port_clock == LC_270M) || + (crtc->config->port_clock == LC_162M)) && + intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DP))
intel_has_dp_encoder()Quoted 6 lines
drivers/gpu/drm/i915/intel_audio.c +1
-0+return true; else return false; }@@ -287,7 +368,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 8 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -343,15 +424,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 3 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
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0else DRM_DEBUG_KMS("no suitable N value isfound\n");
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 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 )) {
intel_has_dp_encoder()Quoted 3 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
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
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 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from
DP->HDMI.HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP -> HDMI > > > > > and HDMI -> DP.
Did you make sure eg. that the power well didn't get toggled in between? That would reset the register anyway.
We have done the test for this case. So far it is OK.
Quoted 8 lines
Quoted 2 lines
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
The register is used to set m/cts, which will impacts the audio clock sync. We didn't check the register reset or not. But the HDMI audio and DP will both works smoothly. And for your consideration, it is for HDMI. Let's make another patch for this issue if we really met the issue that hdmi can't sync the clock. What do you think?
How about we just always write the register to make sure we won't get any stupid bugs because of this.
Quoted 116 lines
Quoted 116 lines
Quoted 112 lines
Regards,
LibinQuoted 106 lines
Quoted 15 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3
-0+ } + } +mutex_unlock (&dev_priv->av_mutex); }Quoted 38 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_audio.c static int
Quoted 1 line
drivers/gpu/drm/i915/intel_audio.c +0
-0@@ -637,7 +728,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 33 lines
Quoted 20 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 ;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c static int · line 748
Quoted 6 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 ))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that's more appropriately left to any MST patch.Quoted 3 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we support DP MST. At that time, we can do a full test on DP MST.Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if statement.
Quoted 6 lines
Regards,
LibinQuoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_audio.c +0
-0DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));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 +773,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
drivers/gpu/drm/i915/intel_audio.c static int · line 778
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 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
port %c\n",
drivers/gpu/drm/i915/intel_audio.c static int · line 793
Quoted 12 lines
drivers/gpu/drm/i915/intel_audio.c +4
-1port_name(port));@@ -693,8 +785,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 )) +{
intel_has_dp_encoder()Quoted 11 lines
drivers/gpu/drm/i915/intel_audio.c +7
-1+ 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); --Quoted 1 line
1.9.1
--
Ville Syrjälä
Intel OTCQuoted 3 lines
Quoted 3 lines
--
Ville Syrjälä
Intel OTC--
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
Quoted 54 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 4:45 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 10 lines · Libin
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 3:17 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +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
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ tmp =audio_config_setup_m_reg(intel_crtc,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tmp);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from DP-
HDMI.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP ->
HDMI > > > > > and HDMI -> DP.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Did you make sure eg. that the power well didn't get toggled in
between?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
That would reset the register anyway.
We have done the test for this case. So far it is OK.
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
Quoted 8 lines
Quoted 5 lines
The register is used to set m/cts, which will impacts the audio clock sync. We didn't check the register reset or not. But the HDMI audio and DP will both works smoothly. And for your consideration, it is for HDMI. Let's make another patch for this issue if we really met the issue that hdmi can't sync the clock. What do you think?
How about we just always write the register to make sure we won't get any stupid bugs because of this.
OK. Do you think it is OK I will write a separate patch for it, not included in the patch series?
This is for HDMI N/CTS setting and this needs a lot of test on HDMI platforms.
Regards,
Libin
Quoted 122 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Regards,
LibinQuoted 41 lines
Quoted 41 lines
What's more it can handle sample rate/tmds changes.
Regards,
LibinQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +3
-0+ } + } + mutex_unlock(&dev_priv->av_mutex); }Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review static int
Quoted 1 line
(quoted diff) +0
-0@@ -637,7 +728,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 2 lines
(quoted diff) +0
-0struct drm_display_mode *mode; struct i915_audio_component *acomp = dev_priv-
audio_component;Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Review static int
Quoted 7 lines
(quoted diff) +1
-1enum pipe pipe = INVALID_PIPE; - u32 tmp; + u32 tmp, m; int n; int err = 0;@@ -653,7 +744,8 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Review static int · line 748
Quoted 6 lines
(quoted diff) +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))) {Hmm. Should probablt move this stuff later so that we can use check
crtc->config->output_typesinstead. But I guess that'scrtc->config->more
appropriately left to any MST patch.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
The same reason as
intel_has_dp_encoder(). And if it is wrong for DP MST, let's have a separate patch when we supportDP MST.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
At that time, we can do a full test on DP MST.
Yeah this part we can leave for the MST patch as it'll involve a bit more than just adding another check to the if
statement.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Regards,
LibinQuoted 2 lines
Quoted 2 lines
(quoted diff) +0
-0DRM_DEBUG_KMS("no valid port %c\n",
port_name(port));Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review static int
Quoted 3 lines
(quoted diff) +0
-0err = -ENODEV; goto unlock;@@ -681,7 +773,7 @@ static inti915_audio_component_sync_audio_rate(struct device *dev,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review static int · line 778
Quoted 7 lines
(quoted diff) +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 modefor N
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
value on
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
port %c\n",
Quoted 1 line
(quoted diff) +0
-0port_name(port));(quoted diff) +0
-0@@ -693,8 +785,17 @@ staticQuoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Review
Quoted 11 lines
int i915_audio_component_sync_audio_rate(struct device *dev,
(quoted diff) +4
-1/* 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)) {
intel_has_dp_encoder()Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ m = audio_config_get_m(crtc, rate); + if (m == 0) + goto unlock; + tmp =I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ tmp = audio_config_setup_m_reg(crtc, m,tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),tmp);
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
(quoted diff) +1
-1+ } unlock: 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
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 60 lines · Libin
Quoted 60 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 4:45 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 10 lines · Libin
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 3:17 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +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
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ tmp =audio_config_setup_m_reg(intel_crtc,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tmp);
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from DP-
HDMI.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we programmed in for DP previously.
The silicon seems to be able to handle the situation of DP ->
HDMI > > > > > and HDMI -> DP.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Did you make sure eg. that the power well didn't get toggled in
between?
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
That would reset the register anyway.
We have done the test for this case. So far it is OK.
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
The register is used to set m/cts, which will impacts the audio clock sync. We didn't check the register reset or not. But the HDMI audio and DP will both works smoothly. And for your consideration, it is for HDMI. Let's make another patch for this issue if we really met the issue that hdmi can't sync the clock. What do you think?
Quoted 7 lines
Quoted 2 lines
How about we just always write the register to make sure we won't get any stupid bugs because of this.
OK. Do you think it is OK I will write a separate patch for it, not included in the patch series?
This is for HDMI N/CTS setting and this needs a lot of test on HDMI platforms.
I don't mean you should write the CTS value there, that would change the behaviour. Just make sure the manual programming bit is cleared etc. like it was before this DP patch. Ie. probably just overwrite the register with 0, or something.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 82 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 6:54 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 54 lines · Libin
Quoted 54 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 4:45 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 10 lines · Libin
Quoted 10 lines
-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, August 5, 2016 3:17 PM
To: Yang, Libin <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vetter, Daniel <[email protected]>; [email protected]
Subject: Re: [PATCH v3 1/3] drm/i915: set proper N/M in modesetQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +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
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ tmp =audio_config_setup_m_reg(intel_crtc,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
m, tmp);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe),Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tmp);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
We should program this register even for HDMI, so that we don't leak invalid register values eg. when changing from DP-
HDMI.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
HDMI doesn't need set these values based on our test. It seems silicon can handle smoothly for HDMI.
Yes, but we nee to make sure we clear whatever we
programmed in for DP previously.The silicon seems to be able to handle the situation of DP ->
HDMI > > > > > and HDMI -> DP.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Did you make sure eg. that the power well didn't get toggled in
between?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
That would reset the register anyway.
We have done the test for this case. So far it is OK.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Test what? Checking that the register gets reset w/o any power well toggling and the like? So what event does reset that register?
The register is used to set m/cts, which will impacts the audio clock sync. We didn't check the register reset or not. But the HDMI audio and DP will both works smoothly. And for your consideration, it is for HDMI. Let's make another patch for this issue if we really met the issue that hdmi can't sync the clock. What do
you think?
Quoted 7 lines
Quoted 3 lines
How about we just always write the register to make sure we won't get any stupid bugs because of this.
OK. Do you think it is OK I will write a separate patch for it, not included in the patch series?
Quoted 6 lines
Quoted 1 line
This is for HDMI N/CTS setting and this needs a lot of test on HDMI platforms.
I don't mean you should write the CTS value there, that would change the behaviour. Just make sure the manual programming bit is cleared etc. like it was before this DP patch. Ie. probably just overwrite the register with 0, or something.
Get it. I was thinking you are saying setting the CTS.
Regards,
Libin
Quoted 4 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 series starting with [v3,1/3] drm/i915: set proper N/M in modeset
In reply to [email protected]== Series Details ==
== Series Details ==
Series: series starting with [v3,1/3] drm/i915: set proper N/M in modeset
URL : https://patchwork.freedesktop.org/series/10645/
State : failure
== Summary ==
Series 10645v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/10645/revisions/1/mbox
Test kms_cursor_legacy:
Subgroup basic-cursor-vs-flip-varying-size:
fail -> PASS (ro-ilk1-i5-650)
Subgroup basic-flip-vs-cursor-legacy:
fail -> PASS (ro-bdw-i7-5600u)
fail -> PASS (ro-bdw-i5-5250u)
pass -> FAIL (ro-skl3-i5-6260u)fi-kbl-qkkr total:240 pass:181 dwarn:29 dfail:0 fail:3 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:198 dwarn:0 dfail:0 fail:0 skip:42 ro-bdw-i5-5250u total:240 pass:219 dwarn:4 dfail:0 fail:1 skip:16 ro-bdw-i7-5557U total:240 pass:224 dwarn:0 dfail:0 fail:0 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
fi-hsw-i7-4770k failed to connect after reboot
Results at /archive/results/CI_IGT_test/RO_Patchwork_1701/
4a66cc6 drm-intel-nightly: 2016y-08m-04d-08h-20m-44s UTC integration manifest e795b85 drm/i915: HDMI audio gets the TMDS clock by crtc_clock 683ab01 drm/i915: set proper N/MCTS on more platforms
fc34824 drm/i915: set proper N/M in modeset
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx