All of lore.kernel.org
 help / color / mirror / Atom feed
* drm/i915/audio: m/n value fixes
@ 2016-10-25 14:54 Jani Nikula
  2016-10-25 14:54 ` [PATCH 1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Jani Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jani Nikula @ 2016-10-25 14:54 UTC (permalink / raw)
  To: intel-gfx

Remaining patch from https://patchwork.freedesktop.org/series/12754/
plus a cleanup.

BR,
Jani.


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH 1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup
  2016-10-25 14:54 drm/i915/audio: m/n value fixes Jani Nikula
@ 2016-10-25 14:54 ` Jani Nikula
  2016-10-25 14:54 ` [PATCH 2/2] drm/i915/audio: set proper N/M in modeset Jani Nikula
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2016-10-25 14:54 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Libin Yang

The array contains the crtc clock, rely on that. While at it, debug log
the HDMI N value or automatic mode.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: "Lin, Mengdong" <mengdong.lin@intel.com>
Cc: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_audio.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
index 7093cfbb62b1..1a5c21209446 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -254,16 +254,15 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
 	tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
 	tmp |= audio_config_hdmi_pixel_clock(adjusted_mode);
 
-	if (adjusted_mode->crtc_clock == TMDS_296M ||
-	    adjusted_mode->crtc_clock == TMDS_297M) {
-		n = audio_config_hdmi_get_n(adjusted_mode, rate);
-		if (n != 0) {
-			tmp &= ~AUD_CONFIG_N_MASK;
-			tmp |= AUD_CONFIG_N(n);
-			tmp |= AUD_CONFIG_N_PROG_ENABLE;
-		} else {
-			DRM_DEBUG_KMS("no suitable N value is found\n");
-		}
+	n = audio_config_hdmi_get_n(adjusted_mode, rate);
+	if (n != 0) {
+		DRM_DEBUG_KMS("using N %d\n", n);
+
+		tmp &= ~AUD_CONFIG_N_MASK;
+		tmp |= AUD_CONFIG_N(n);
+		tmp |= AUD_CONFIG_N_PROG_ENABLE;
+	} else {
+		DRM_DEBUG_KMS("using automatic N\n");
 	}
 
 	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH 2/2] drm/i915/audio: set proper N/M in modeset
  2016-10-25 14:54 drm/i915/audio: m/n value fixes Jani Nikula
  2016-10-25 14:54 ` [PATCH 1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Jani Nikula
@ 2016-10-25 14:54 ` Jani Nikula
  2016-10-25 15:32 ` drm/i915/audio: m/n value fixes Ville Syrjälä
  2016-10-25 15:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Patchwork
  3 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2016-10-25 14:54 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Zhang, Keqiao, Libin Yang

From: Libin Yang <libin.yang@linux.intel.com>

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.

v2 by Jani:
- organize Maud/Naud table according to DP 1.4 spec
- add 64k and 128k audio rates
- update HSW_AUD_M_CTS_ENABLE register when Maud not found
- remove extra checks for port clock
- simplify Maud/Naud lookup
- reset patch author back to Libin

Cc: "Zhang, Keqiao" <keqiao.zhang@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: "Lin, Mengdong" <mengdong.lin@intel.com>
Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h    |  7 +++
 drivers/gpu/drm/i915/intel_audio.c | 93 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index bdc7b3591e1c..542e570b3578 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -7370,6 +7370,13 @@ enum {
 #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)
 
+#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   AUD_CONFIG_M_MASK		0xfffff
+
 #define _HSW_AUD_DIP_ELD_CTRL_ST_A	0x650b4
 #define _HSW_AUD_DIP_ELD_CTRL_ST_B	0x651b4
 #define HSW_AUD_DIP_ELD_CTRL(pipe)	_MMIO_PIPE(pipe, _HSW_AUD_DIP_ELD_CTRL_ST_A, _HSW_AUD_DIP_ELD_CTRL_ST_B)
diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
index 1a5c21209446..813fd74d9c8d 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -57,6 +57,63 @@
  * struct &i915_audio_component_audio_ops @audio_ops is called from i915 driver.
  */
 
+/* DP N/M table */
+#define LC_540M	540000
+#define LC_270M	270000
+#define LC_162M	162000
+
+struct dp_aud_n_m {
+	int sample_rate;
+	int clock;
+	u16 m;
+	u16 n;
+};
+
+/* Values according to DP 1.4 Table 2-104 */
+static const struct dp_aud_n_m dp_aud_n_m[] = {
+	{ 32000, LC_162M, 1024, 10125 },
+	{ 44100, LC_162M, 784, 5625 },
+	{ 48000, LC_162M, 512, 3375 },
+	{ 64000, LC_162M, 2048, 10125 },
+	{ 88200, LC_162M, 1568, 5625 },
+	{ 96000, LC_162M, 1024, 3375 },
+	{ 128000, LC_162M, 4096, 10125 },
+	{ 176400, LC_162M, 3136, 5625 },
+	{ 192000, LC_162M, 2048, 3375 },
+	{ 32000, LC_270M, 1024, 16875 },
+	{ 44100, LC_270M, 784, 9375 },
+	{ 48000, LC_270M, 512, 5625 },
+	{ 64000, LC_270M, 2048, 16875 },
+	{ 88200, LC_270M, 1568, 9375 },
+	{ 96000, LC_270M, 1024, 5625 },
+	{ 128000, LC_270M, 4096, 16875 },
+	{ 176400, LC_270M, 3136, 9375 },
+	{ 192000, LC_270M, 2048, 5625 },
+	{ 32000, LC_540M, 1024, 33750 },
+	{ 44100, LC_540M, 784, 18750 },
+	{ 48000, LC_540M, 512, 11250 },
+	{ 64000, LC_540M, 2048, 33750 },
+	{ 88200, LC_540M, 1568, 18750 },
+	{ 96000, LC_540M, 1024, 11250 },
+	{ 128000, LC_540M, 4096, 33750 },
+	{ 176400, LC_540M, 3136, 18750 },
+	{ 192000, LC_540M, 2048, 11250 },
+};
+
+static const struct dp_aud_n_m *
+audio_config_dp_get_n_m(struct intel_crtc *intel_crtc, int rate)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) {
+		if (rate == dp_aud_n_m[i].sample_rate &&
+		    intel_crtc->config->port_clock == dp_aud_n_m[i].clock)
+			return &dp_aud_n_m[i];
+	}
+
+	return NULL;
+}
+
 static const struct {
 	int clock;
 	u32 config;
@@ -225,16 +282,43 @@ hsw_dp_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
 			   const struct drm_display_mode *adjusted_mode)
 {
 	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
+	struct i915_audio_component *acomp = dev_priv->audio_component;
+	int rate = acomp ? acomp->aud_sample_rate[port] : 0;
+	const struct dp_aud_n_m *nm = audio_config_dp_get_n_m(intel_crtc, rate);
 	enum pipe pipe = intel_crtc->pipe;
 	u32 tmp;
 
+	if (nm)
+		DRM_DEBUG_KMS("using Maud %u, Naud %u\n", nm->m, nm->n);
+	else
+		DRM_DEBUG_KMS("using automatic Maud, Naud\n");
+
 	tmp = I915_READ(HSW_AUD_CFG(pipe));
 	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
 	tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
 	tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
 	tmp |= AUD_CONFIG_N_VALUE_INDEX;
 
+	if (nm) {
+		tmp &= ~AUD_CONFIG_N_MASK;
+		tmp |= AUD_CONFIG_N(nm->n);
+		tmp |= AUD_CONFIG_N_PROG_ENABLE;
+	}
+
 	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
+
+	tmp = I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
+	tmp &= ~AUD_CONFIG_M_MASK;
+	tmp &= ~AUD_M_CTS_M_VALUE_INDEX;
+	tmp &= ~AUD_M_CTS_M_PROG_ENABLE;
+
+	if (nm) {
+		tmp |= nm->m;
+		tmp |= AUD_M_CTS_M_VALUE_INDEX;
+		tmp |= AUD_M_CTS_M_PROG_ENABLE;
+	}
+
+	I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe), tmp);
 }
 
 static void
@@ -266,6 +350,12 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
 	}
 
 	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
+
+	tmp = I915_READ(HSW_AUD_M_CTS_ENABLE(pipe));
+	tmp &= ~AUD_CONFIG_M_MASK;
+	tmp &= ~AUD_M_CTS_M_VALUE_INDEX;
+	tmp |= AUD_M_CTS_M_PROG_ENABLE;
+	I915_WRITE(HSW_AUD_M_CTS_ENABLE(pipe), tmp);
 }
 
 static void
@@ -686,7 +776,8 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port,
 	/* 1. get the pipe */
 	intel_encoder = get_saved_enc(dev_priv, port, pipe);
 	if (!intel_encoder || !intel_encoder->base.crtc ||
-	    intel_encoder->type != INTEL_OUTPUT_HDMI) {
+	    (intel_encoder->type != INTEL_OUTPUT_HDMI &&
+	     intel_encoder->type != INTEL_OUTPUT_DP)) {
 		DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port));
 		err = -ENODEV;
 		goto unlock;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: drm/i915/audio: m/n value fixes
  2016-10-25 14:54 drm/i915/audio: m/n value fixes Jani Nikula
  2016-10-25 14:54 ` [PATCH 1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Jani Nikula
  2016-10-25 14:54 ` [PATCH 2/2] drm/i915/audio: set proper N/M in modeset Jani Nikula
@ 2016-10-25 15:32 ` Ville Syrjälä
  2016-10-26  9:41   ` Jani Nikula
  2016-10-25 15:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Patchwork
  3 siblings, 1 reply; 6+ messages in thread
From: Ville Syrjälä @ 2016-10-25 15:32 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Tue, Oct 25, 2016 at 05:54:16PM +0300, Jani Nikula wrote:
> Remaining patch from https://patchwork.freedesktop.org/series/12754/
> plus a cleanup.

I'm not feeling like checking bspec for the nuts and bolts details on
the registers again, but at least the code looks sane to me and the
M/N values what my test application generates (if I double the values
for HBR2). Based on that

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

for both patches.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup
  2016-10-25 14:54 drm/i915/audio: m/n value fixes Jani Nikula
                   ` (2 preceding siblings ...)
  2016-10-25 15:32 ` drm/i915/audio: m/n value fixes Ville Syrjälä
@ 2016-10-25 15:46 ` Patchwork
  3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2016-10-25 15:46 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup
URL   : https://patchwork.freedesktop.org/series/14342/
State : warning

== Summary ==

Series 14342v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/14342/revisions/1/mbox/

Test drv_module_reload_basic:
                dmesg-warn -> PASS       (fi-skl-6770hq)
                pass       -> DMESG-WARN (fi-skl-6700hq)
Test gem_exec_suspend:
        Subgroup basic-s3:
                dmesg-warn -> PASS       (fi-skl-6770hq)
                dmesg-warn -> PASS       (fi-skl-6700hq)
Test kms_frontbuffer_tracking:
        Subgroup basic:
                fail       -> PASS       (fi-skl-6770hq)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> PASS       (fi-skl-6700hq)
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-skl-6700hq)
        Subgroup suspend-read-crc-pipe-c:
                dmesg-warn -> PASS       (fi-skl-6700hq)

fi-bdw-5557u     total:246  pass:231  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:246  pass:204  dwarn:0   dfail:0   fail:0   skip:42 
fi-bxt-t5700     total:246  pass:216  dwarn:0   dfail:0   fail:0   skip:30 
fi-byt-j1900     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-byt-n2820     total:246  pass:211  dwarn:0   dfail:0   fail:0   skip:35 
fi-hsw-4770      total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-hsw-4770r     total:246  pass:223  dwarn:0   dfail:0   fail:0   skip:23 
fi-ilk-650       total:246  pass:185  dwarn:0   dfail:0   fail:0   skip:61 
fi-ivb-3520m     total:246  pass:220  dwarn:0   dfail:0   fail:0   skip:26 
fi-ivb-3770      total:246  pass:220  dwarn:0   dfail:0   fail:0   skip:26 
fi-kbl-7200u     total:246  pass:222  dwarn:0   dfail:0   fail:0   skip:24 
fi-skl-6260u     total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:246  pass:222  dwarn:1   dfail:0   fail:0   skip:23 
fi-skl-6700k     total:246  pass:222  dwarn:1   dfail:0   fail:0   skip:23 
fi-skl-6770hq    total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m     total:246  pass:209  dwarn:0   dfail:0   fail:0   skip:37 
fi-snb-2600      total:246  pass:208  dwarn:0   dfail:0   fail:0   skip:38 

3ce99d02d8f2b7d1414d20d5972f8e277b33693e drm-intel-nightly: 2016y-10m-25d-13h-55m-46s UTC integration manifest
8ee7f93 drm/i915/audio: set proper N/M in modeset
76ec280 drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup

Full results at https://intel-gfx-ci.01.org/CI/Patchwork_2812/

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2812/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: drm/i915/audio: m/n value fixes
  2016-10-25 15:32 ` drm/i915/audio: m/n value fixes Ville Syrjälä
@ 2016-10-26  9:41   ` Jani Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2016-10-26  9:41 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Libin Yang

On Tue, 25 Oct 2016, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Tue, Oct 25, 2016 at 05:54:16PM +0300, Jani Nikula wrote:
>> Remaining patch from https://patchwork.freedesktop.org/series/12754/
>> plus a cleanup.
>
> I'm not feeling like checking bspec for the nuts and bolts details on
> the registers again, but at least the code looks sane to me and the
> M/N values what my test application generates (if I double the values
> for HBR2). Based on that
>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> for both patches.

And both pushed, thanks for the review.

Libin, Mengdong, please (have someone) do final testing on
drm-intel-nightly to ensure we've got everything covered now.


Thanks,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2016-10-26  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 14:54 drm/i915/audio: m/n value fixes Jani Nikula
2016-10-25 14:54 ` [PATCH 1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Jani Nikula
2016-10-25 14:54 ` [PATCH 2/2] drm/i915/audio: set proper N/M in modeset Jani Nikula
2016-10-25 15:32 ` drm/i915/audio: m/n value fixes Ville Syrjälä
2016-10-26  9:41   ` Jani Nikula
2016-10-25 15:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/audio: drop extra crtc clock check from HDMI audio N lookup Patchwork

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