diff mbox

drm/i915: ELD info update during HDMI hot plug

Message ID 1346821576-18024-1-git-send-email-xingchao.wang@intel.com (mailing list archive)
State Rejected
Headers show

Commit Message

Wang Xingchao Sept. 5, 2012, 5:06 a.m. UTC
ELD infomation should update immediately when detected HDMI hot plug event.
The related ELD_VALID bit should be set/clear to generate unsolicited event
to notify Alsa driver this change.

Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
---
 drivers/gpu/drm/i915/intel_hdmi.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Fengguang Wu Sept. 5, 2012, 5:29 a.m. UTC | #1
Xingchao,

We have the drm_i915_display_funcs.write_eld() for such
functionalities.

Thanks,
Fengguang

On Wed, Sep 05, 2012 at 01:06:16PM +0800, Wang Xingchao wrote:
> ELD infomation should update immediately when detected HDMI hot plug event.
> The related ELD_VALID bit should be set/clear to generate unsolicited event
> to notify Alsa driver this change.
> 
> Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_hdmi.c |   28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> index e4c37bb..1d9aaa9 100644
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -719,6 +719,10 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
>  	struct drm_i915_private *dev_priv = connector->dev->dev_private;
>  	struct edid *edid;
>  	enum drm_connector_status status = connector_status_disconnected;
> +	enum drm_connector_status old_status = connector->status;
> +	int aud_cntrl_st2;
> +	uint32_t eldv;
> +	int i;
>  
>  	if (IS_G4X(connector->dev) && !g4x_hdmi_connected(intel_hdmi))
>  		return status;
> @@ -747,6 +751,30 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
>  				(intel_hdmi->force_audio == HDMI_AUDIO_ON);
>  	}
>  
> +	if (status != old_status) {
> +		if (HAS_PCH_IBX(connector->dev))
> +			aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
> +		else if (IS_HASWELL(connector->dev))
> +			aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
> +		else
> +			aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
> +
> +		eldv = (AUDIO_ELD_VALID_A |
> +			AUDIO_ELD_VALID_B |
> +			AUDIO_ELD_VALID_C) ;
> +		if (status == connector_status_connected) {
> +			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Pluged In\n", connector->base.id,
> +					drm_get_connector_name(connector));
> +			I915_WRITE(aud_cntrl_st2, eldv);
> +		} else {
> +			i = I915_READ(aud_cntrl_st2);
> +			i &= ~eldv;
> +			I915_WRITE(aud_cntrl_st2, i);
> +			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Pluged Out\n", connector->base.id,
> +					drm_get_connector_name(connector));
> +		}
> +	}
> +
>  	return status;
>  }
>  
> -- 
> 1.7.9.5
Wang Xingchao Sept. 12, 2012, 7:19 a.m. UTC | #2
> -----Original Message-----
> From: Wu, Fengguang
> Sent: Wednesday, September 05, 2012 1:30 PM
> To: Wang, Xingchao
> Cc: intel-gfx@lists.freedesktop.org; daniel.vetter@ffwll.ch; Zhao, Yakui
> Subject: Re: [PATCH] drm/i915: ELD info update during HDMI hot plug
> 
> Xingchao,
> 
> We have the drm_i915_display_funcs.write_eld() for such functionalities.
> 
I have another simple patch to replace this one, will send it out later.

thanks
--xingchao
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index e4c37bb..1d9aaa9 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -719,6 +719,10 @@  intel_hdmi_detect(struct drm_connector *connector, bool force)
 	struct drm_i915_private *dev_priv = connector->dev->dev_private;
 	struct edid *edid;
 	enum drm_connector_status status = connector_status_disconnected;
+	enum drm_connector_status old_status = connector->status;
+	int aud_cntrl_st2;
+	uint32_t eldv;
+	int i;
 
 	if (IS_G4X(connector->dev) && !g4x_hdmi_connected(intel_hdmi))
 		return status;
@@ -747,6 +751,30 @@  intel_hdmi_detect(struct drm_connector *connector, bool force)
 				(intel_hdmi->force_audio == HDMI_AUDIO_ON);
 	}
 
+	if (status != old_status) {
+		if (HAS_PCH_IBX(connector->dev))
+			aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
+		else if (IS_HASWELL(connector->dev))
+			aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
+		else
+			aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
+
+		eldv = (AUDIO_ELD_VALID_A |
+			AUDIO_ELD_VALID_B |
+			AUDIO_ELD_VALID_C) ;
+		if (status == connector_status_connected) {
+			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Pluged In\n", connector->base.id,
+					drm_get_connector_name(connector));
+			I915_WRITE(aud_cntrl_st2, eldv);
+		} else {
+			i = I915_READ(aud_cntrl_st2);
+			i &= ~eldv;
+			I915_WRITE(aud_cntrl_st2, i);
+			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] Pluged Out\n", connector->base.id,
+					drm_get_connector_name(connector));
+		}
+	}
+
 	return status;
 }