[Intel-gfx] [PATCH 5/5] drm/i915/dp: Refactor force_audio -> has_audio coupling

Chris Wilson chris at chris-wilson.co.uk
Tue Sep 2 21:04:03 CEST 2014


Similar to the previous commit for HDMI, refector the common routine
for setting the audio flags between detection and set-property.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_dp.c | 47 ++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d5f769788f95..34af2beb34b7 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3824,6 +3824,25 @@ intel_dp_get_edid(struct intel_dp *intel_dp)
 				    &intel_dp->aux.ddc);
 }
 
+static bool
+intel_dp_update_audio(struct intel_dp *intel_dp)
+{
+	struct intel_connector *intel_connector = intel_dp->attached_connector;
+	struct edid *edid = intel_connector->detect_edid ;
+	bool has_audio;
+
+	if (intel_dp->force_audio != HDMI_AUDIO_AUTO)
+		has_audio = intel_dp->force_audio == HDMI_AUDIO_ON;
+	else
+		has_audio = drm_detect_monitor_audio(edid);
+
+	if (has_audio == intel_dp->has_audio)
+		return false;
+
+	intel_dp->has_audio = has_audio;
+	return true;
+}
+
 static void
 intel_dp_set_edid(struct intel_dp *intel_dp)
 {
@@ -3833,10 +3852,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp)
 	edid = intel_dp_get_edid(intel_dp);
 	intel_connector->detect_edid = edid;
 
-	if (intel_dp->force_audio != HDMI_AUDIO_AUTO)
-		intel_dp->has_audio = intel_dp->force_audio == HDMI_AUDIO_ON;
-	else
-		intel_dp->has_audio = drm_detect_monitor_audio(edid);
+	intel_dp_update_audio(intel_dp);
 }
 
 static void
@@ -3979,19 +3995,6 @@ static int intel_dp_get_modes(struct drm_connector *connector)
 	return 0;
 }
 
-static bool
-intel_dp_detect_audio(struct drm_connector *connector)
-{
-	bool has_audio = false;
-	struct edid *edid;
-
-	edid = to_intel_connector(connector)->detect_edid;
-	if (edid)
-		has_audio = drm_detect_monitor_audio(edid);
-
-	return has_audio;
-}
-
 static int
 intel_dp_set_property(struct drm_connector *connector,
 		      struct drm_property *property,
@@ -4009,22 +4012,14 @@ intel_dp_set_property(struct drm_connector *connector,
 
 	if (property == dev_priv->force_audio_property) {
 		int i = val;
-		bool has_audio;
 
 		if (i == intel_dp->force_audio)
 			return 0;
 
 		intel_dp->force_audio = i;
-
-		if (i == HDMI_AUDIO_AUTO)
-			has_audio = intel_dp_detect_audio(connector);
-		else
-			has_audio = (i == HDMI_AUDIO_ON);
-
-		if (has_audio == intel_dp->has_audio)
+		if (!intel_dp_update_audio(intel_dp))
 			return 0;
 
-		intel_dp->has_audio = has_audio;
 		goto done;
 	}
 
-- 
2.1.0




More information about the Intel-gfx mailing list