[RESEND,2/9] drm/i915/audio: port is going to be just fine, simplify checks

Submitted by Jani Nikula on Oct. 10, 2016, 3:04 p.m.

Details

Message ID 8cf454ccefc05b234aa81c45a4ce9018e7c9324f.1476111629.git.jani.nikula@intel.com
State New
Headers show
Series "drm/i915/audio: audio cleanups, 4k fixes" ( rev: 4 3 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Jani Nikula Oct. 10, 2016, 3:04 p.m.
If it was wrong, we'd be screwed already.

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

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
index 0a54f7cdce37..5d0bd07afa51 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -251,8 +251,9 @@  static void hsw_audio_config_update(struct intel_crtc *intel_crtc,
 {
 	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;
 	enum pipe pipe = intel_crtc->pipe;
-	int n, rate;
+	int n;
 	u32 tmp;
 
 	tmp = I915_READ(HSW_AUD_CFG(pipe));
@@ -265,15 +266,6 @@  static void hsw_audio_config_update(struct intel_crtc *intel_crtc,
 
 	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);

Comments

Reviewed-by: Libin Yang <libin.yang@intel.com>


Regards,
Libin


> -----Original Message-----

> From: Intel-gfx [mailto:intel-gfx-bounces@lists.freedesktop.org] On Behalf Of

> Jani Nikula

> Sent: Monday, October 10, 2016 11:04 PM

> To: intel-gfx@lists.freedesktop.org

> Cc: Nikula, Jani <jani.nikula@intel.com>; libin.yang@linux.intel.com;

> Pandiyan, Dhinakaran <dhinakaran.pandiyan@intel.com>

> Subject: [Intel-gfx] [PATCH RESEND 2/9] drm/i915/audio: port is going to be

> just fine, simplify checks

> 

> If it was wrong, we'd be screwed already.

> 

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

> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

> ---

>  drivers/gpu/drm/i915/intel_audio.c | 12 ++----------

>  1 file changed, 2 insertions(+), 10 deletions(-)

> 

> diff --git a/drivers/gpu/drm/i915/intel_audio.c

> b/drivers/gpu/drm/i915/intel_audio.c

> index 0a54f7cdce37..5d0bd07afa51 100644

> --- a/drivers/gpu/drm/i915/intel_audio.c

> +++ b/drivers/gpu/drm/i915/intel_audio.c

> @@ -251,8 +251,9 @@ static void hsw_audio_config_update(struct intel_crtc

> *intel_crtc,  {

>  	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;

>  	enum pipe pipe = intel_crtc->pipe;

> -	int n, rate;

> +	int n;

>  	u32 tmp;

> 

>  	tmp = I915_READ(HSW_AUD_CFG(pipe));

> @@ -265,15 +266,6 @@ static void hsw_audio_config_update(struct

> intel_crtc *intel_crtc,

> 

>  	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);

> --

> 2.1.4

> 

> _______________________________________________

> Intel-gfx mailing list

> Intel-gfx@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/intel-gfx