diff mbox

[28/29] drm/i915/hdmi: Only enable audio if supported by the monitor

Message ID 1282475148-15951-29-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State Deferred, archived
Headers show

Commit Message

Chris Wilson Aug. 22, 2010, 11:05 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index ccd4c97..88faa0b 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -40,6 +40,7 @@ 
 struct intel_hdmi {
 	struct intel_encoder base;
 	u32 sdvox_reg;
+	bool has_audio_sink;
 	bool has_hdmi_sink;
 };
 
@@ -65,11 +66,10 @@  static void intel_hdmi_mode_set(struct drm_encoder *encoder,
 	if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
 		sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
 
-	if (intel_hdmi->has_hdmi_sink) {
+	if (intel_hdmi->has_audio_sink)
 		sdvox |= SDVO_AUDIO_ENABLE;
-		if (HAS_PCH_CPT(dev))
-			sdvox |= HDMI_MODE_SELECT;
-	}
+	if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev))
+		sdvox |= HDMI_MODE_SELECT;
 
 	if (intel_crtc->pipe == 1) {
 		if (HAS_PCH_CPT(dev))
@@ -147,12 +147,16 @@  intel_hdmi_detect(struct drm_connector *connector)
 	enum drm_connector_status status = connector_status_disconnected;
 
 	intel_hdmi->has_hdmi_sink = false;
+	intel_hdmi->has_audio_sink = false;
+
 	edid = drm_get_edid(connector, intel_hdmi->base.ddc_bus);
 
 	if (edid) {
 		if (edid->input & DRM_EDID_INPUT_DIGITAL) {
 			status = connector_status_connected;
 			intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
+			if (intel_hdmi->has_hdmi_sink)
+				intel_hdmi->has_audio_sink = drm_edid_supports_audio(edid);
 		}
 		connector->display_info.raw_edid = NULL;
 		kfree(edid);
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 41962f8..dfaa547 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -104,6 +104,7 @@  struct intel_sdvo {
 	 * This is set if we treat the device as HDMI, instead of DVI.
 	 */
 	bool is_hdmi;
+	bool has_hdmi_audio;
 
 	/**
 	 * This is set if we detect output of sdvo device as LVDS.
@@ -1114,12 +1115,12 @@  static void intel_sdvo_mode_set(struct drm_encoder *encoder,
 				  &in_out, sizeof(in_out)))
 		return;
 
-	if (intel_sdvo->is_hdmi) {
+	if (intel_sdvo->is_hdmi)
 		if (!intel_sdvo_set_avi_infoframe(intel_sdvo, mode))
 			return;
 
+	if (intel_sdvo->has_hdmi_audio)
 		sdvox |= SDVO_AUDIO_ENABLE;
-	}
 
 	/* We have tried to get input timing in mode_fixup, and filled into
 	   adjusted_mode */
@@ -1476,9 +1477,11 @@  intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
 		bool need_digital = !!(intel_sdvo_connector->output_flag & SDVO_TMDS_MASK);
 
 		/* DDC bus is shared, match EDID to connector type */
-		if (is_digital && need_digital)
+		if (is_digital && need_digital) {
 			intel_sdvo->is_hdmi = drm_detect_hdmi_monitor(edid);
-		else if (is_digital != need_digital)
+			if (intel_sdvo->is_hdmi)
+				intel_sdvo->has_hdmi_audio = drm_edid_supports_audio(edid);
+		} else if (is_digital != need_digital)
 			status = connector_status_disconnected;
 
 		connector->display_info.raw_edid = NULL;