[PATCH] drm/radeon: properly select encoder in radeon_audio_detect (v2)

Alex Deucher alexdeucher at gmail.com
Tue May 19 09:08:37 PDT 2015


Need to handle DVI where we way end up with an analog encoder
in some cases.

v2: rework checks.  always set use_digital for DVI-D, HDMI-A

Reported-by: Julian Margetson <runaway at candw.ms>
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
Cc: stable at vger.kernel.org
---
 drivers/gpu/drm/radeon/radeon_audio.c      | 20 +++++++++++---------
 drivers/gpu/drm/radeon/radeon_connectors.c |  6 ++++--
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c
index dcb7796..ace2b4b 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -453,22 +453,24 @@ void radeon_audio_enable(struct radeon_device *rdev,
 void radeon_audio_detect(struct drm_connector *connector,
 			 enum drm_connector_status status)
 {
-	struct radeon_device *rdev;
-	struct radeon_encoder *radeon_encoder;
+	struct drm_device *dev = connector->dev;
+	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_encoder_atom_dig *dig;
+	const struct drm_connector_helper_funcs *connector_funcs =
+		connector->helper_private;
+	struct drm_encoder *encoder = connector_funcs->best_encoder(connector);
+	struct radeon_encoder *radeon_encoder;
 
-	if (!connector || !connector->encoder)
+	if (!radeon_audio_chipset_supported(rdev))
 		return;
 
-	if (!radeon_encoder_is_digital(connector->encoder))
+	if (!encoder)
 		return;
 
-	rdev = connector->encoder->dev->dev_private;
-
-	if (!radeon_audio_chipset_supported(rdev))
+	if (!radeon_encoder_is_digital(encoder))
 		return;
 
-	radeon_encoder = to_radeon_encoder(connector->encoder);
+	radeon_encoder = to_radeon_encoder(encoder);
 	dig = radeon_encoder->enc_priv;
 
 	if (!dig->afmt)
@@ -484,7 +486,7 @@ void radeon_audio_detect(struct drm_connector *connector,
 		else
 			radeon_encoder->audio = rdev->audio.hdmi_funcs;
 
-		dig->afmt->pin = radeon_audio_get_pin(connector->encoder);
+		dig->afmt->pin = radeon_audio_get_pin(encoder);
 		if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
 			radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
 		} else {
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index d17d251..8052759 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1303,8 +1303,10 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
 
 	/* DVI-D and HDMI-A are digital only */
 	if ((connector->connector_type == DRM_MODE_CONNECTOR_DVID) ||
-	    (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA))
+	    (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA)) {
+		radeon_connector->use_digital = true;
 		goto out;
+	}
 
 	/* if we aren't forcing don't do destructive polling */
 	if (!force) {
@@ -1379,7 +1381,7 @@ out:
 	/* updated in get modes as well since we need to know if it's analog or digital */
 	radeon_connector_update_scratch_regs(connector, ret);
 
-	if (radeon_audio != 0) {
+	if ((radeon_audio != 0) && (radeon_connector->use_digital)) {
 		radeon_connector_get_edid(connector);
 		radeon_audio_detect(connector, ret);
 	}
-- 
1.8.3.1



More information about the dri-devel mailing list