[PATCH 5/6] drm: Read out DP dual mode registers in one go

Imre Deak imre.deak at intel.com
Wed Nov 16 20:44:09 UTC 2016


Some buggy adaptors may ignore the offset in the I2C transfer ending up
reading/writing always at offset 0. This happened not to cause a problem
during identification based on the HDMI and adaptor ID so far (see comment
in drm_dp_dual_mode_detect()), but it can be a problem when using the
adaptor descriptor registers for identification or querying the max TMDS
clock register. To make the readout work on these adaptors too, try
first to read out all the important registers in one go. Keep the
current way as a fall-back, since it's possible that some adaptors
reject reading past beyond their last supported register address.

According to the above this is also needed - together with the next
patch - to work around the I2C access problem on a Parad Tech LSPCON
adaptor.

Reference: https://bugs.freedesktop.org/show_bug.cgi?id=98353
Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 13 +++++++++++++
 include/drm/drm_dp_dual_mode_helper.h     |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
index d0e0fa0..de079ea 100644
--- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
+++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
@@ -167,6 +167,18 @@ static int drm_dp_dual_mode_read_regs(struct drm_dp_dual_mode_adaptor *adaptor)
 	int dev_id_len;
 	ssize_t ret;
 
+	/*
+	 * First try to read out all regs in one go, if that fails fall back
+	 * to reading out them in logical parts.
+	 */
+	ret = drm_dp_dual_mode_read(adaptor, DP_DUAL_MODE_HDMI_ID,
+				    regs, sizeof(*regs));
+	if (!ret)
+		goto out;
+
+	DRM_DEBUG_KMS("Failed to read all regs (%zd)\n", ret);
+	memset(regs, 0, sizeof(*regs));
+
 	ret = drm_dp_dual_mode_read(adaptor, DP_DUAL_MODE_HDMI_ID,
 				    regs->hdmi_id, sizeof(regs->hdmi_id));
 	if (ret) {
@@ -203,6 +215,7 @@ static int drm_dp_dual_mode_read_regs(struct drm_dp_dual_mode_adaptor *adaptor)
 		regs->max_tmds_clock = 0;
 	}
 
+out:
 	dev_id_len = strnlen(regs->desc.device_id,
 			     sizeof(regs->desc.device_id));
 	DRM_DEBUG_KMS("DP dual-mode: HDMI-ID %*pE adaptor-ID %#02x\n"
diff --git a/include/drm/drm_dp_dual_mode_helper.h b/include/drm/drm_dp_dual_mode_helper.h
index 6054013..a06352c 100644
--- a/include/drm/drm_dp_dual_mode_helper.h
+++ b/include/drm/drm_dp_dual_mode_helper.h
@@ -113,7 +113,7 @@ struct drm_dp_dual_mode_adaptor {
 			uint8_t sw_minor_rev;
 		} __packed desc;
 		uint8_t max_tmds_clock;
-	} regs;
+	} __packed regs;
 
 	int max_tmds_clock;
 };
-- 
2.5.0



More information about the Intel-gfx-trybot mailing list