All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com, libin.yang@linux.intel.com,
	Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Subject: [PATCH RESEND 1/9] drm/i915/audio: abstract audio config update
Date: Mon, 10 Oct 2016 18:04:00 +0300	[thread overview]
Message-ID: <56fe0662990289c647f998c11089133ca92ebb68.1476111629.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1476111629.git.jani.nikula@intel.com>
In-Reply-To: <cover.1476111629.git.jani.nikula@intel.com>

Prepare for using the same code for updating HSW_AUD_CFG register. No
functional changes.

Cc: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_audio.c | 68 ++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
index 9583f432e02e..0a54f7cdce37 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -245,6 +245,45 @@ static void g4x_audio_codec_enable(struct drm_connector *connector,
 	I915_WRITE(G4X_AUD_CNTL_ST, tmp);
 }
 
+static void hsw_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;
+	enum pipe pipe = intel_crtc->pipe;
+	int n, rate;
+	u32 tmp;
+
+	tmp = I915_READ(HSW_AUD_CFG(pipe));
+	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
+	tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
+	if (intel_crtc_has_dp_encoder(intel_crtc->config))
+		tmp |= AUD_CONFIG_N_VALUE_INDEX;
+	else
+		tmp |= audio_config_hdmi_pixel_clock(adjusted_mode);
+
+	tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
+	if (audio_rate_need_prog(intel_crtc, adjusted_mode)) {
+		if (!acomp)
+			rate = 0;
+		else if (port >= PORT_A && port <= PORT_E)
+			rate = acomp->aud_sample_rate[port];
+		else {
+			DRM_ERROR("invalid port: %d\n", port);
+			rate = 0;
+		}
+
+		n = audio_config_get_n(adjusted_mode, rate);
+		if (n != 0)
+			tmp = audio_config_setup_n_reg(n, tmp);
+		else
+			DRM_DEBUG_KMS("no suitable N value is found\n");
+	}
+
+	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
+}
+
 static void hsw_audio_codec_disable(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
@@ -283,11 +322,9 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,
 	struct intel_crtc *intel_crtc = to_intel_crtc(intel_encoder->base.crtc);
 	enum pipe pipe = intel_crtc->pipe;
 	enum port port = intel_encoder->port;
-	struct i915_audio_component *acomp = dev_priv->audio_component;
 	const uint8_t *eld = connector->eld;
 	uint32_t tmp;
 	int len, i;
-	int n, rate;
 
 	DRM_DEBUG_KMS("Enable audio codec on pipe %c, %u bytes ELD\n",
 		      pipe_name(pipe), drm_eld_size(eld));
@@ -323,32 +360,7 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,
 	I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
 
 	/* Enable timestamps */
-	tmp = I915_READ(HSW_AUD_CFG(pipe));
-	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
-	tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
-	if (intel_crtc_has_dp_encoder(intel_crtc->config))
-		tmp |= AUD_CONFIG_N_VALUE_INDEX;
-	else
-		tmp |= audio_config_hdmi_pixel_clock(adjusted_mode);
-
-	tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
-	if (audio_rate_need_prog(intel_crtc, adjusted_mode)) {
-		if (!acomp)
-			rate = 0;
-		else if (port >= PORT_A && port <= PORT_E)
-			rate = acomp->aud_sample_rate[port];
-		else {
-			DRM_ERROR("invalid port: %d\n", port);
-			rate = 0;
-		}
-		n = audio_config_get_n(adjusted_mode, rate);
-		if (n != 0)
-			tmp = audio_config_setup_n_reg(n, tmp);
-		else
-			DRM_DEBUG_KMS("no suitable N value is found\n");
-	}
-
-	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
+	hsw_audio_config_update(intel_crtc, port, adjusted_mode);
 
 	mutex_unlock(&dev_priv->av_mutex);
 }
-- 
2.1.4

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

  reply	other threads:[~2016-10-10 15:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 15:03 [PATCH RESEND 0/9] drm/i915/audio: audio cleanups, 4k fixes Jani Nikula
2016-10-10 15:04 ` Jani Nikula [this message]
2016-10-11  1:59   ` [PATCH RESEND 1/9] drm/i915/audio: abstract audio config update Yang, Libin
2016-10-10 15:04 ` [PATCH RESEND 2/9] drm/i915/audio: port is going to be just fine, simplify checks Jani Nikula
2016-10-11  2:37   ` Yang, Libin
2016-10-10 15:04 ` [PATCH RESEND 3/9] drm/i915/audio: use the same code for updating audio config Jani Nikula
2016-10-11  5:25   ` Yang, Libin
2016-10-10 15:04 ` [PATCH RESEND 4/9] drm/i915/audio: split dp and hdmi audio config update Jani Nikula
2016-10-11  5:42   ` Yang, Libin
2016-10-10 15:04 ` [PATCH RESEND 5/9] drm/i915/audio: set proper N/MCTS on more platforms Jani Nikula
2016-10-10 15:04 ` [PATCH RESEND 6/9] drm/i915/audio: HDMI audio gets the TMDS clock by crtc_clock Jani Nikula
2016-10-10 15:04 ` [PATCH RESEND 7/9] drm/i915/audio: add register macros for audio config N value Jani Nikula
2016-10-11  5:52   ` Yang, Libin
2016-10-10 15:04 ` [PATCH RESEND 8/9] drm/i915/audio: rename N value getter to emphasize it's for hdmi Jani Nikula
2016-10-11  5:55   ` Yang, Libin
2016-10-11 14:25     ` Jani Nikula
2016-10-10 15:04 ` [PATCH RESEND 9/9] drm/i915: set proper N/M in modeset Jani Nikula
2016-10-12  2:45   ` Lin, Mengdong
2016-10-12  6:29     ` Yang, Libin
2016-10-19 15:08       ` Jani Nikula
2016-10-20  2:00         ` Yang, Libin
2016-10-20  8:33           ` Jani Nikula
2016-10-20  8:42             ` Yang, Libin
2016-10-20 11:34               ` Jani Nikula
2016-10-20 12:02                 ` Ville Syrjälä
2016-10-21  6:47                   ` Yang, Libin
2016-10-21  6:21                 ` Yang, Libin
2016-10-12  6:41   ` Zhang, Keqiao
2016-10-10 18:19 ` ✗ Fi.CI.BAT: warning for drm/i915/audio: audio cleanups, 4k fixes (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56fe0662990289c647f998c11089133ca92ebb68.1476111629.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=libin.yang@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.