Skip to contentSkip to conversation

drm: Add SCDC helpers

PATCH In review Thierry Reding 6 participants 23 messages Dec 2, 2016 – Dec 19, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 drm: Add SCDC helpers

From: Thierry Reding <[email protected]>

SCDC is a mechanism defined in the HDMI 2.0 specification that allows the source and sink devices to communicate.

This commit introduces helpers to access the SCDC and provides the symbolic names for the various registers defined in the specification.

---
Changes in v2:
- indent register field definitions for readability (Ville Syrjälä)
- use GFP_TEMPORARY for temporary buffer allocation (Jani Nikula)

 Documentation/gpu/drm-kms-helpers.rst |  12 ++++
 drivers/gpu/drm/Kconfig               |   4 ++
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/drm_scdc_helper.c     | 111 ++++++++++++++++++++++++++++
 include/drm/drm_scdc_helper.h         | 132 ++++++++++++++++++++++++++++++++++
 5 files changed, 260 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_scdc_helper.c
 create mode 100644 include/drm/drm_scdc_helper.h
Documentation/gpu/drm-kms-helpers.rst +12 -0
index 03040aa14fe8..759275629fcf 100644
@@ -217,6 +217,18 @@ EDID Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_edid.c
    :export:
 
+SCDC Helper Functions Reference
+===============================
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :doc: scdc helpers
+
+.. kernel-doc:: include/drm/drm_scdc_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :export:
+
 Rectangle Utilities Reference
 =============================
 
drivers/gpu/drm/Kconfig +4 -0
index 95fc0410e129..d0031fe45bab 100644
@@ -84,6 +84,10 @@ config DRM_FBDEV_EMULATION
 
 	  If in doubt, say "Y".
 
+config DRM_SCDC
+	bool
+	depends on DRM_KMS_HELPER
+
 config DRM_LOAD_EDID_FIRMWARE
 	bool "Allow to specify an EDID data set instead of probing for it"
 	depends on DRM_KMS_HELPER
drivers/gpu/drm/Makefile +1 -0
index 883f3e75cfbc..71c38b6dd546 100644
@@ -31,6 +31,7 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
 		drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
 		drm_simple_kms_helper.o drm_modeset_helper.o
 
+drm_kms_helper-$(CONFIG_DRM_SCDC) += drm_scdc_helper.o
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
drivers/gpu/drm/drm_scdc_helper.c new file +111 -0

111 lines not on this page · raw message

include/drm/drm_scdc_helper.h new file +132 -0

132 lines not on this page · raw message

Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v2 2/3 drm/edid: Implement SCDC support detection

From: Thierry Reding <[email protected]>

Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC.

---
Changes in v2:
- rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä)

 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 include/linux/hdmi.h       |  1 +
 3 files changed, 51 insertions(+)
drivers/gpu/drm/drm_edid.c +49 -0
index 336be31ff3de..369961597ee5 100644
@@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 	return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
+{
+	unsigned int oui;
+
+	if (cea_db_tag(db) != VENDOR_BLOCK)
+		return false;
+
+	if (cea_db_payload_len(db) < 7)
+		return false;
+
+	oui = db[3] << 16 | db[2] << 8 | db[1];
+
+	return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
 	for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
 
@@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid)
 EXPORT_SYMBOL(drm_detect_hdmi_monitor);
 
 /**
+ * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink supports SCDC, false otherwise.
+ */
+bool drm_detect_hdmi_scdc(struct edid *edid)
+{
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x80)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +1 -0
index 38eabf65f19d..7ea7e90846d8 100644
@@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
+bool drm_detect_hdmi_scdc(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
 int drm_add_modes_noedid(struct drm_connector *connector,
include/linux/hdmi.h +1 -0
index edbb4fc674ed..d271ff23984f 100644
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {
 };
 
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE    13
 #define HDMI_SPD_INFOFRAME_SIZE    25
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH v2 3/3 drm/edid: Implement SCDC Read Request capability detection

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Sinks that support SCDC can optionally have the capability to initiate read requests, which are a mechanism by which a sink can notify its source that it should read the Update Flags. If either the sink or the source are not Read Request capable, polling of the Update Flags shall be employed.

---
Changes in v2:
- new patch

 drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 2 files changed, 37 insertions(+)
drivers/gpu/drm/drm_edid.c +36 -0
index 369961597ee5..8211cce3e09e 100644
@@ -3736,6 +3736,42 @@ bool drm_detect_hdmi_scdc(struct edid *edid)
 EXPORT_SYMBOL(drm_detect_hdmi_scdc);
 
 /**
+ * drm_detect_hdmi_scdc_rr_capable - detect whether an HDMI sink is capable of
+ *    initiating an SCDC Read Request
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the RR_Capable bit (bit 6 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink is capable of initiating an SCDC Read Request, false
+ * otherwise.
+ */
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid)
+{
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x40)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc_rr_capable);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +1 -0
index 7ea7e90846d8..d1c29586035e 100644
@@ -441,6 +441,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
 bool drm_detect_hdmi_scdc(struct edid *edid);
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
 int drm_add_modes_noedid(struct drm_connector *connector,
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

RE: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Thierry Reding

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Regards
Shashank
-----Original Message-----
From: Thierry Reding [mailto:[email protected]]
Sent: Saturday, December 3, 2016 12:54 AM
To: [email protected]
Cc: Jani Nikula <[email protected]>; Sharma, Shashank <[email protected]>; Ville Syrjälä <[email protected]>; Jose Abreu <[email protected]>
Subject: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

From: Thierry Reding <[email protected]>

Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC.

---
Changes in v2:
- rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä)

 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 include/linux/hdmi.h       |  1 +
 3 files changed, 51 insertions(+)
drivers/gpu/drm/drm_edid.c +47 -0
@@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 	return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) {
+	unsigned int oui;
+
+	if (cea_db_tag(db) != VENDOR_BLOCK)
+		return false;
+
+	if (cea_db_payload_len(db) < 7)
+		return false;
+
+	oui = db[3] << 16 | db[2] << 8 | db[1];
+
+	return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
 	for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
 
@@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid)  EXPORT_SYMBOL(drm_detect_hdmi_monitor);
 
 /**
+ * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink supports SCDC, false otherwise.
+ */
+bool drm_detect_hdmi_scdc(struct edid *edid) {
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x80)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +3 -2
@@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match);  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);  bool drm_detect_hdmi_monitor(struct edid *edid);
+bool drm_detect_hdmi_scdc(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);  bool drm_rgb_quant_range_selectable(struct edid *edid);  int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index edbb4fc674ed..d271ff23984f 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {  };
 
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE    13
 #define HDMI_SPD_INFOFRAME_SIZE    25
--

2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Other than that the patches are mostly equivalent, except yours parses more information than just the SCDC bits.

Thierry

Quoted 102 lines

-----Original Message-----
From: Thierry Reding [mailto:[email protected]]
Sent: Saturday, December 3, 2016 12:54 AM
To: [email protected]
Cc: Jani Nikula <[email protected]>; Sharma, Shashank <[email protected]>; Ville Syrjälä <[email protected]>; Jose Abreu <[email protected]>
Subject: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

From: Thierry Reding <[email protected]>

Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC.

---
Changes in v2:
- rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä)

 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 include/linux/hdmi.h       |  1 +
 3 files changed, 51 insertions(+)
drivers/gpu/drm/drm_edid.c +47 -0
@@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 	return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) {
+	unsigned int oui;
+
+	if (cea_db_tag(db) != VENDOR_BLOCK)
+		return false;
+
+	if (cea_db_payload_len(db) < 7)
+		return false;
+
+	oui = db[3] << 16 | db[2] << 8 | db[1];
+
+	return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
 	for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
 
@@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid)  EXPORT_SYMBOL(drm_detect_hdmi_monitor);
 
 /**
+ * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink supports SCDC, false otherwise.
+ */
+bool drm_detect_hdmi_scdc(struct edid *edid) {
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x80)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +1 -0
@@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match);  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);  bool drm_detect_hdmi_monitor(struct edid *edid);
+bool drm_detect_hdmi_scdc(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);  bool drm_rgb_quant_range_selectable(struct edid *edid);  int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index edbb4fc674ed..d271ff23984f 100644
include/linux/hdmi.h +1 -1
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {  };
 
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE    13
 #define HDMI_SPD_INFOFRAME_SIZE    25
--
Quoted 2 lines

2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

Quoted 9 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info. I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

Quoted 2 lines

Other than that the patches are mostly equivalent, except yours parses more information than just the SCDC bits.

So merge patch 1 from your series + Shashank's parsing patch? Everyone agrees and can you pls cross-r-b stamp so I can apply it all?

Thanks, Daniel

Quoted 114 lines

Thierry

Quoted 102 lines

-----Original Message-----
From: Thierry Reding [mailto:[email protected]]
Sent: Saturday, December 3, 2016 12:54 AM
To: [email protected]
Cc: Jani Nikula <[email protected]>; Sharma, Shashank <[email protected]>; Ville Syrjälä <[email protected]>; Jose Abreu <[email protected]>
Subject: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

From: Thierry Reding <[email protected]>

Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC.

---
Changes in v2:
- rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä)

 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 include/linux/hdmi.h       |  1 +
 3 files changed, 51 insertions(+)
drivers/gpu/drm/drm_edid.c +47 -0
@@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 	return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) {
+	unsigned int oui;
+
+	if (cea_db_tag(db) != VENDOR_BLOCK)
+		return false;
+
+	if (cea_db_payload_len(db) < 7)
+		return false;
+
+	oui = db[3] << 16 | db[2] << 8 | db[1];
+
+	return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
 	for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
 
@@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid)  EXPORT_SYMBOL(drm_detect_hdmi_monitor);
 
 /**
+ * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink supports SCDC, false otherwise.
+ */
+bool drm_detect_hdmi_scdc(struct edid *edid) {
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x80)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +1 -0
@@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match);  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);  bool drm_detect_hdmi_monitor(struct edid *edid);
+bool drm_detect_hdmi_scdc(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);  bool drm_rgb_quant_range_selectable(struct edid *edid);  int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index edbb4fc674ed..d271ff23984f 100644
include/linux/hdmi.h +1 -1
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {  };
 
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE    13
 #define HDMI_SPD_INFOFRAME_SIZE    25
--
Quoted 2 lines

2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#19 lore raw
In reply to Thierry Reding

Hi Thierry,

Quoted 172 lines · Thierry Reding

From: Thierry Reding <[email protected]>

SCDC is a mechanism defined in the HDMI 2.0 specification that allows the source and sink devices to communicate.

This commit introduces helpers to access the SCDC and provides the symbolic names for the various registers defined in the specification.

---
Changes in v2:
- indent register field definitions for readability (Ville Syrjälä)
- use GFP_TEMPORARY for temporary buffer allocation (Jani Nikula)

 Documentation/gpu/drm-kms-helpers.rst |  12 ++++
 drivers/gpu/drm/Kconfig               |   4 ++
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/drm_scdc_helper.c     | 111 ++++++++++++++++++++++++++++
 include/drm/drm_scdc_helper.h         | 132 ++++++++++++++++++++++++++++++++++
 5 files changed, 260 insertions(+)
 create mode 100644 drivers/gpu/drm/drm_scdc_helper.c
 create mode 100644 include/drm/drm_scdc_helper.h
Documentation/gpu/drm-kms-helpers.rst +12 -0
index 03040aa14fe8..759275629fcf 100644
@@ -217,6 +217,18 @@ EDID Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_edid.c
    :export:
 
+SCDC Helper Functions Reference
+===============================
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :doc: scdc helpers
+
+.. kernel-doc:: include/drm/drm_scdc_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :export:
+
 Rectangle Utilities Reference
 =============================
 
drivers/gpu/drm/Kconfig +4 -0
index 95fc0410e129..d0031fe45bab 100644
@@ -84,6 +84,10 @@ config DRM_FBDEV_EMULATION
 
 	  If in doubt, say "Y".
 
+config DRM_SCDC
+	bool
+	depends on DRM_KMS_HELPER
+
 config DRM_LOAD_EDID_FIRMWARE
 	bool "Allow to specify an EDID data set instead of probing for it"
 	depends on DRM_KMS_HELPER
drivers/gpu/drm/Makefile +1 -0
index 883f3e75cfbc..71c38b6dd546 100644
@@ -31,6 +31,7 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
 		drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
 		drm_simple_kms_helper.o drm_modeset_helper.o
 
+drm_kms_helper-$(CONFIG_DRM_SCDC) += drm_scdc_helper.o
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
drivers/gpu/drm/drm_scdc_helper.c new file +93 -0
new file mode 100644
index 000000000000..fe0e1211e873
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2015 NVIDIA Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <linux/slab.h>
+
+#include <drm/drm_scdc_helper.h>
+
+/**
+ * DOC: scdc helpers
+ *
+ * Status and Control Data Channel (SCDC) is a mechanism introduced by the
+ * HDMI 2.0 specification. It is a point-to-point protocol that allows the
+ * HDMI source and HDMI sink to exchange data. The same I2C interface that
+ * is used to access EDID serves as the transport mechanism for SCDC.
+ */
+
+#define SCDC_I2C_SLAVE_ADDRESS 0x54
+
+/**
+ * drm_scdc_read - read a block of data from SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to read
+ * @buffer: return location for the block to read
+ * @size: size of the block to read
+ *
+ * Reads a block of data from SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes read from SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
+		      size_t size)
+{
+	struct i2c_msg msgs[2] = {
+		{
+			.addr = SCDC_I2C_SLAVE_ADDRESS,
+			.flags = 0,
+			.len = 1,
+			.buf = &offset,
+		}, {
+			.addr = SCDC_I2C_SLAVE_ADDRESS,
+			.flags = I2C_M_RD,
+			.len = size,
+			.buf = buffer,
+		}
+	};
+
+	return i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
+}
+EXPORT_SYMBOL(drm_scdc_read);
+
+/**
+ * drm_scdc_write - write a block of data to SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to write
+ * @buffer: block of data to write
+ * @size: size of the block to write
+ *
+ * Writes a block of data to SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes written to SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
+		       const void *buffer, size_t size)
+{
+	struct i2c_msg msg = {
+		.addr = SCDC_I2C_SLAVE_ADDRESS,
+		.flags = 0,
+		.len = 1 + size,
+		.buf = NULL,
+	};
+	void *data;

drivers/gpu/drm/drm_scdc_helper.c line 103

Quoted 10 lines
drivers/gpu/drm/drm_scdc_helper.c new file +10 -0
+	int err;
+
+	data = kmalloc(1 + size, GFP_TEMPORARY);
+	if (!data)
+		return -ENOMEM;
+
+	msg.buf = data;
+
+	memcpy(data, &offset, sizeof(offset));
+	memcpy(data + 1, buffer, size);

Don't you agree it would be better if you use the same scheme as drm_scdc_read()? Something like:

struct i2c_msg msgs[] = {
    {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = 1,
        .buf = &offset,
    }, {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = size,
        .buf = buffer,
    },
};
Quoted 136 lines
drivers/gpu/drm/drm_scdc_helper.c new file +8 -0
+
+	err = i2c_transfer(adapter, &msg, 1);
+
+	kfree(data);
+
+	return err;
+}
+EXPORT_SYMBOL(drm_scdc_write);
include/drm/drm_scdc_helper.h new file +122 -0
new file mode 100644
index 000000000000..93b07bcf0291
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2015 NVIDIA Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef DRM_SCDC_HELPER_H
+#define DRM_SCDC_HELPER_H
+
+#include <linux/i2c.h>
+#include <linux/types.h>
+
+#define SCDC_SINK_VERSION 0x01
+
+#define SCDC_SOURCE_VERSION 0x02
+
+#define SCDC_UPDATE_0 0x10
+#define  SCDC_READ_REQUEST_TEST (1 << 2)
+#define  SCDC_CED_UPDATE (1 << 1)
+#define  SCDC_STATUS_UPDATE (1 << 0)
+
+#define SCDC_UPDATE_1 0x11
+
+#define SCDC_TMDS_CONFIG 0x20
+#define  SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 (1 << 1)
+#define  SCDC_TMDS_BIT_CLOCK_RATIO_BY_10 (0 << 1)
+#define  SCDC_SCRAMBLING_ENABLE (1 << 0)
+
+#define SCDC_SCRAMBLER_STATUS 0x21
+#define  SCDC_SCRAMBLING_STATUS (1 << 0)
+
+#define SCDC_CONFIG_0 0x30
+#define  SCDC_READ_REQUEST_ENABLE (1 << 0)
+
+#define SCDC_STATUS_FLAGS_0 0x40
+#define  SCDC_CH2_LOCK (1 < 3)
+#define  SCDC_CH1_LOCK (1 < 2)
+#define  SCDC_CH0_LOCK (1 < 1)
+#define  SCDC_CH_LOCK_MASK (SCDC_CH2_LOCK | SCDC_CH1_LOCK | SCDC_CH0_LOCK)
+#define  SCDC_CLOCK_DETECT (1 << 0)
+
+#define SCDC_STATUS_FLAGS_1 0x41
+
+#define SCDC_ERR_DET_0_L 0x50
+#define SCDC_ERR_DET_0_H 0x51
+#define SCDC_ERR_DET_1_L 0x52
+#define SCDC_ERR_DET_1_H 0x53
+#define SCDC_ERR_DET_2_L 0x54
+#define SCDC_ERR_DET_2_H 0x55
+#define  SCDC_CHANNEL_VALID (1 << 7)
+
+#define SCDC_ERR_DET_CHECKSUM 0x56
+
+#define SCDC_TEST_CONFIG_0 0xc0
+#define  SCDC_TEST_READ_REQUEST (1 << 7)
+#define  SCDC_TEST_READ_REQUEST_DELAY(x) ((x) & 0x7f)
+
+#define SCDC_MANUFACTURER_IEEE_OUI 0xd0
+#define SCDC_MANUFACTURER_IEEE_OUI_SIZE 3
+
+#define SCDC_DEVICE_ID 0xd3
+#define SCDC_DEVICE_ID_SIZE 8
+
+#define SCDC_DEVICE_HARDWARE_REVISION 0xdb
+#define  SCDC_DEVICE_HARDWARE_REVISION_MAJOR(x) (((x) >> 4) & 0xf)
+#define  SCDC_DEVICE_HARDWARE_REVISION_MINOR(x) (((x) >> 0) & 0xf)
+
+#define SCDC_DEVICE_SOFTWARE_MAJOR_REVISION 0xdc
+#define SCDC_DEVICE_SOFTWARE_MINOR_REVISION 0xdd
+
+#define SCDC_MANUFACTURER_SPECIFIC 0xde
+#define SCDC_MANUFACTURER_SPECIFIC_SIZE 34
+
+ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
+		      size_t size);
+ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
+		       const void *buffer, size_t size);
+
+/**
+ * drm_scdc_readb - read a single byte from SCDC
+ * @adapter: I2C adapter
+ * @offset: offset of register to read
+ * @value: return location for the register value
+ *
+ * Reads a single byte from SCDC. This is a convenience wrapper around the
+ * drm_scdc_read() function.
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ */
+static inline int drm_scdc_readb(struct i2c_adapter *adapter, u8 offset,
+				 u8 *value)
+{
+	return drm_scdc_read(adapter, offset, value, sizeof(*value));
+}
+
+/**
+ * drm_scdc_writeb - write a single byte to SCDC
+ * @adapter: I2C adapter
+ * @offset: offset of register to read
+ * @value: return location for the register value
+ *
+ * Writes a single byte to SCDC. This is a convenience wrapper around the
+ * drm_scdc_write() function.
+ *

include/drm/drm_scdc_helper.h line 132

Quoted 10 lines
include/drm/drm_scdc_helper.h new file +10 -0
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ */
+static inline int drm_scdc_writeb(struct i2c_adapter *adapter, u8 offset,
+				  u8 value)
+{
+	return drm_scdc_write(adapter, offset, &value, sizeof(value));
+}
+
+#endif

Best regards,
Jose Miguel Abreu
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

In reply to Thierry Reding

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Best regards,

Jose Miguel Abreu

Quoted 69 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Sinks that support SCDC can optionally have the capability to initiate read requests, which are a mechanism by which a sink can notify its source that it should read the Update Flags. If either the sink or the source are not Read Request capable, polling of the Update Flags shall be employed.

---
Changes in v2:
- new patch

 drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 2 files changed, 37 insertions(+)
drivers/gpu/drm/drm_edid.c +36 -0
index 369961597ee5..8211cce3e09e 100644
@@ -3736,6 +3736,42 @@ bool drm_detect_hdmi_scdc(struct edid *edid)
 EXPORT_SYMBOL(drm_detect_hdmi_scdc);
 
 /**
+ * drm_detect_hdmi_scdc_rr_capable - detect whether an HDMI sink is capable of
+ *    initiating an SCDC Read Request
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the RR_Capable bit (bit 6 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink is capable of initiating an SCDC Read Request, false
+ * otherwise.
+ */
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid)
+{
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x40)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc_rr_capable);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +0 -0
index 7ea7e90846d8..d1c29586035e 100644

include/drm/drm_edid.h u8 drm_match_cea_mode(const struct drm_display_mode *to_match); · line 447

Quoted 7 lines
include/drm/drm_edid.h +1 -0
@@ -441,6 +441,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
 bool drm_detect_hdmi_scdc(struct edid *edid);
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
 int drm_add_modes_noedid(struct drm_connector *connector,

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Daniel Vetter
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Quoted 6 lines
Quoted 3 lines

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

	https://patchwork.freedesktop.org/patch/104806/
Quoted 4 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

Quoted 5 lines
Quoted 2 lines

Other than that the patches are mostly equivalent, except yours parses more information than just the SCDC bits.

So merge patch 1 from your series + Shashank's parsing patch? Everyone agrees and can you pls cross-r-b stamp so I can apply it all?

I think I spotted a mistake in Shashank's parsing patch. Let me take another look.

If we can agree on a common way forward on how to deal with this kind of static data, I have no objections to caching data for the duration of a hotplug period.

Thierry

Quoted 96 lines
Quoted 96 lines
Quoted 96 lines

-----Original Message-----
From: Thierry Reding [mailto:[email protected]]
Sent: Saturday, December 3, 2016 12:54 AM
To: [email protected]
Cc: Jani Nikula <[email protected]>; Sharma, Shashank <[email protected]>; Ville Syrjälä <[email protected]>; Jose Abreu <[email protected]>
Subject: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

From: Thierry Reding <[email protected]>

Sinks compliant with the HDMI 2.0 specification may support SCDC, a mechanism for the source and the sink to communicate. Sinks advertise support for this feature in the HDMI Forum Vendor Specific Data Block as defined in the HDMI 2.0 specification, section 10.4 "Status and Control Data Channel". Implement a small helper that find the HF-VSDB and parses it to check if the sink supports SCDC.

---
Changes in v2:
- rename internal function to cea_db_is_hdmi_forum_vsdb() for more clarity (Ville Syrjälä)

 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 include/linux/hdmi.h       |  1 +
 3 files changed, 51 insertions(+)
drivers/gpu/drm/drm_edid.c +47 -0
@@ -3238,6 +3238,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 	return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) {
+	unsigned int oui;
+
+	if (cea_db_tag(db) != VENDOR_BLOCK)
+		return false;
+
+	if (cea_db_payload_len(db) < 7)
+		return false;
+
+	oui = db[3] << 16 | db[2] << 8 | db[1];
+
+	return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
 	for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
 
@@ -3687,6 +3702,40 @@ bool drm_detect_hdmi_monitor(struct edid *edid)  EXPORT_SYMBOL(drm_detect_hdmi_monitor);
 
 /**
+ * drm_detect_hdmi_scdc - detect whether an HDMI sink supports SCDC
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the SCDC_Present bit (bit 7 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink supports SCDC, false otherwise.
+ */
+bool drm_detect_hdmi_scdc(struct edid *edid) {
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x80)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +1 -0
@@ -440,6 +440,7 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match);  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);  bool drm_detect_hdmi_monitor(struct edid *edid);
+bool drm_detect_hdmi_scdc(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);  bool drm_rgb_quant_range_selectable(struct edid *edid);  int drm_add_modes_noedid(struct drm_connector *connector, diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index edbb4fc674ed..d271ff23984f 100644
include/linux/hdmi.h +0 -0
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {  };
 
Quoted 21 lines
Quoted 15 lines
Quoted 8 lines
include/linux/hdmi.h +1 -1
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE    13
 #define HDMI_SPD_INFOFRAME_SIZE    25
--

2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

In reply to Jose Abreu
Quoted 10 lines · Jose Abreu

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Yeah, agreed. I was actually thinking about going one step further and provide more of the polling functionality as a helper. Even if we have accessors that wrap the low-level functionality, most drivers would still have to provide their own delayed workqueue to deal with sinks (or sources) that don't support read requests. Having this in standard helpers would help reduce the boilerplate a lot further.

Does your hardware by any chance support read requests on SCDC? It'd be interesting to see how that works in practice. Unfortunately Tegra does not seem to support it.

Thierry

Quoted 69 lines · Thierry Reding
Quoted 68 lines

From: Thierry Reding <[email protected]>

Sinks that support SCDC can optionally have the capability to initiate read requests, which are a mechanism by which a sink can notify its source that it should read the Update Flags. If either the sink or the source are not Read Request capable, polling of the Update Flags shall be employed.

---
Changes in v2:
- new patch

 drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 2 files changed, 37 insertions(+)
drivers/gpu/drm/drm_edid.c +36 -0
index 369961597ee5..8211cce3e09e 100644
@@ -3736,6 +3736,42 @@ bool drm_detect_hdmi_scdc(struct edid *edid)
 EXPORT_SYMBOL(drm_detect_hdmi_scdc);
 
 /**
+ * drm_detect_hdmi_scdc_rr_capable - detect whether an HDMI sink is capable of
+ *    initiating an SCDC Read Request
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the RR_Capable bit (bit 6 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink is capable of initiating an SCDC Read Request, false
+ * otherwise.
+ */
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid)
+{
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x40)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc_rr_capable);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +0 -0
index 7ea7e90846d8..d1c29586035e 100644
Quoted 9 lines

include/drm/drm_edid.h u8 drm_match_cea_mode(const struct drm_display_mode *to_match); · line 447

Quoted 8 lines
include/drm/drm_edid.h +1 -0
@@ -441,6 +441,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
 bool drm_detect_hdmi_scdc(struct edid *edid);
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
 int drm_add_modes_noedid(struct drm_connector *connector,

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw
In reply to Jose Abreu
Quoted 1 line · Jose Abreu

On 02-12-2016 19:24, Thierry Reding wrote:

[...]

Quoted 36 lines
Quoted 22 lines
drivers/gpu/drm/drm_scdc_helper.c new file +22 -0
+/**
+ * drm_scdc_write - write a block of data to SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to write
+ * @buffer: block of data to write
+ * @size: size of the block to write
+ *
+ * Writes a block of data to SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes written to SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
+		       const void *buffer, size_t size)
+{
+	struct i2c_msg msg = {
+		.addr = SCDC_I2C_SLAVE_ADDRESS,
+		.flags = 0,
+		.len = 1 + size,
+		.buf = NULL,
+	};
+	void *data;

drivers/gpu/drm/drm_scdc_helper.c line 103

Quoted 10 lines
drivers/gpu/drm/drm_scdc_helper.c new file +10 -0
+	int err;
+
+	data = kmalloc(1 + size, GFP_TEMPORARY);
+	if (!data)
+		return -ENOMEM;
+
+	msg.buf = data;
+
+	memcpy(data, &offset, sizeof(offset));
+	memcpy(data + 1, buffer, size);

Don't you agree it would be better if you use the same scheme as drm_scdc_read()? Something like:

Quoted 13 lines
struct i2c_msg msgs[] = {
    {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = 1,
        .buf = &offset,
    }, {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = size,
        .buf = buffer,
    },
};

Ville had a similar comment on a prior iteration. It looks as if the above should work, but it's probably best to test it a little more widely to make sure we're not running into cases where it breaks.

Have you by any chance verified that it works on your hardware?

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#21 lore raw
Quoted 53 lines · Thierry Reding
Quoted 1 line · Jose Abreu

On 02-12-2016 19:24, Thierry Reding wrote:

[...]

Quoted 36 lines
Quoted 22 lines
drivers/gpu/drm/drm_scdc_helper.c new file +22 -0
+/**
+ * drm_scdc_write - write a block of data to SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to write
+ * @buffer: block of data to write
+ * @size: size of the block to write
+ *
+ * Writes a block of data to SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes written to SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
+		       const void *buffer, size_t size)
+{
+	struct i2c_msg msg = {
+		.addr = SCDC_I2C_SLAVE_ADDRESS,
+		.flags = 0,
+		.len = 1 + size,
+		.buf = NULL,
+	};
+	void *data;

drivers/gpu/drm/drm_scdc_helper.c line 103

Quoted 10 lines
drivers/gpu/drm/drm_scdc_helper.c new file +10 -0
+	int err;
+
+	data = kmalloc(1 + size, GFP_TEMPORARY);
+	if (!data)
+		return -ENOMEM;
+
+	msg.buf = data;
+
+	memcpy(data, &offset, sizeof(offset));
+	memcpy(data + 1, buffer, size);

Don't you agree it would be better if you use the same scheme as drm_scdc_read()? Something like:

Quoted 13 lines
struct i2c_msg msgs[] = {
    {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = 1,
        .buf = &offset,
    }, {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = size,
        .buf = buffer,
    },
};
Quoted 3 lines

Ville had a similar comment on a prior iteration. It looks as if the above should work, but it's probably best to test it a little more widely to make sure we're not running into cases where it breaks.

AFAICS the spec says we shouldn't use a repeated start for writes. I guess it might work for some devices, but going against the spec sounds questionable to me.

Quoted 4 lines

Have you by any chance verified that it works on your hardware?

Thierry

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Thierry Reding
Quoted 12 lines · Thierry Reding
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Quoted 8 lines
Quoted 2 lines

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

	https://patchwork.freedesktop.org/patch/104806/

Yeah, the same old "adding stuff all over without actual users" story. It's near impossible to judge whether the added things are actually useful (or if the implementation is the best) without seeing how it's going to be used.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw
In reply to Ville Syrjälä

Hi,

Quoted 52 lines · Ville Syrjälä
Quoted 51 lines · Thierry Reding
Quoted 1 line · Jose Abreu

On 02-12-2016 19:24, Thierry Reding wrote:

[...]

Quoted 48 lines
Quoted 22 lines
drivers/gpu/drm/drm_scdc_helper.c new file +22 -0
+/**
+ * drm_scdc_write - write a block of data to SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to write
+ * @buffer: block of data to write
+ * @size: size of the block to write
+ *
+ * Writes a block of data to SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes written to SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
+		       const void *buffer, size_t size)
+{
+	struct i2c_msg msg = {
+		.addr = SCDC_I2C_SLAVE_ADDRESS,
+		.flags = 0,
+		.len = 1 + size,
+		.buf = NULL,
+	};
+	void *data;

drivers/gpu/drm/drm_scdc_helper.c line 103

Quoted 10 lines
drivers/gpu/drm/drm_scdc_helper.c new file +10 -0
+	int err;
+
+	data = kmalloc(1 + size, GFP_TEMPORARY);
+	if (!data)
+		return -ENOMEM;
+
+	msg.buf = data;
+
+	memcpy(data, &offset, sizeof(offset));
+	memcpy(data + 1, buffer, size);

Don't you agree it would be better if you use the same scheme as drm_scdc_read()? Something like:

struct i2c_msg msgs[] = {
    {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = 1,
        .buf = &offset,
    }, {
        .addr = SCDC_I2C_SLAVE_ADDRESS,
        .flags = 0,
        .len = size,
        .buf = buffer,
    },
};
Quoted 10 lines
Quoted 3 lines

Ville had a similar comment on a prior iteration. It looks as if the above should work, but it's probably best to test it a little more widely to make sure we're not running into cases where it breaks.

AFAICS the spec says we shouldn't use a repeated start for writes. I guess it might work for some devices, but going against the spec sounds questionable to me.

Quoted 3 lines

Have you by any chance verified that it works on your hardware?

Thierry

Actually, I do not do two writes. My I2C controller is accessible through the HDMI controller and has direct mapping in the regbank of the slave address, reg address and data. I am using a I2C adapter driver but it was modified to when the slave address is SCDC and we are doing the first write then store the data and only send it in the next write. Something like this:
http://lxr.free-electrons.com/source/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/anx9805.c#L43
(but modified to SCDC).

Anyway, I was not remembering this so just disregard my comment. We should follow the spec as Ville said.

Quoted 2 lines

Best regards,
Jose Miguel Abreu
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

In reply to Thierry Reding

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 10 lines · Jose Abreu

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Yeah, agreed. I was actually thinking about going one step further and provide more of the polling functionality as a helper. Even if we have accessors that wrap the low-level functionality, most drivers would still have to provide their own delayed workqueue to deal with sinks (or sources) that don't support read requests. Having this in standard helpers would help reduce the boilerplate a lot further.

Quoted 5 lines

Does your hardware by any chance support read requests on SCDC? It'd be interesting to see how that works in practice. Unfortunately Tegra does not seem to support it.

Thierry

Yes, my HW supports it though I don't have the setup here to test right now (but it was used before). In our controller it is pretty straight forward:
1) Enable interrupt for rr indication [source]
2) Enable update read on a rr [source]
3) Set rr flag in the sink [sink]

Point 2) makes it clear: Whenever we get a rr then the source will automatically read the sink and dump the contents read in the regbank. Then the SW gets an interrupt and it should read the contents of the registers.

Quoted 70 lines
Quoted 70 lines · Thierry Reding
Quoted 68 lines

From: Thierry Reding <[email protected]>

Sinks that support SCDC can optionally have the capability to initiate read requests, which are a mechanism by which a sink can notify its source that it should read the Update Flags. If either the sink or the source are not Read Request capable, polling of the Update Flags shall be employed.

---
Changes in v2:
- new patch

 drivers/gpu/drm/drm_edid.c | 36 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  1 +
 2 files changed, 37 insertions(+)
drivers/gpu/drm/drm_edid.c +36 -0
index 369961597ee5..8211cce3e09e 100644
@@ -3736,6 +3736,42 @@ bool drm_detect_hdmi_scdc(struct edid *edid)
 EXPORT_SYMBOL(drm_detect_hdmi_scdc);
 
 /**
+ * drm_detect_hdmi_scdc_rr_capable - detect whether an HDMI sink is capable of
+ *    initiating an SCDC Read Request
+ * @edid: sink EDID information
+ *
+ * Parse the CEA extension according to CEA-861-B to find an HF-VSDB as
+ * defined in HDMI 2.0, section 10.3.2 "HDMI Forum Vendor Specific Data
+ * Block" and checks if the RR_Capable bit (bit 6 of byte 6) is set.
+ *
+ * Returns:
+ * True if the sink is capable of initiating an SCDC Read Request, false
+ * otherwise.
+ */
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid)
+{
+	unsigned int start, end, i;
+	const u8 *cea;
+
+	cea = drm_find_cea_extension(edid);
+	if (!cea)
+		return false;
+
+	if (cea_db_offsets(cea, &start, &end))
+		return false;
+
+	for_each_cea_db(cea, i, start, end) {
+		if (cea_db_is_hdmi_forum_vsdb(&cea[i])) {
+			if (cea[i + 6] & 0x40)
+				return true;
+		}
+	}
+
+	return false;
+}
+EXPORT_SYMBOL(drm_detect_hdmi_scdc_rr_capable);
+
+/**
  * drm_detect_monitor_audio - check monitor audio capability
  * @edid: EDID block to scan
  *
include/drm/drm_edid.h +0 -0
index 7ea7e90846d8..d1c29586035e 100644
Quoted 8 lines
Quoted 8 lines

include/drm/drm_edid.h u8 drm_match_cea_mode(const struct drm_display_mode *to_match); · line 447

Quoted 8 lines
include/drm/drm_edid.h +1 -0
@@ -441,6 +441,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
 bool drm_detect_hdmi_scdc(struct edid *edid);
+bool drm_detect_hdmi_scdc_rr_capable(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
 int drm_add_modes_noedid(struct drm_connector *connector,

Best regards,
Jose Miguel Abreu
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Thierry Reding
Quoted 12 lines · Thierry Reding
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Quoted 8 lines
Quoted 2 lines

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

	https://patchwork.freedesktop.org/patch/104806/

DPCD I complained about because somehow we ended up with 2 sets of helpers, one filling a struct and the others returning directly. I objected to the fact that there's 2 (and imo your patch duplicated even more), not that I think one approach is clearly inferior to the other.

Demanding that there's some real users is also a valid point.

Quoted 11 lines
Quoted 4 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Quoted 4 lines

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

We're pretty good at consuming fairly invasive refactorings in drm-misc. So it just boils down to get some agreement on what things should look like (+1 from my side to parsing stuff into structs as a general idea), and then massaging all the existing users of the "wrong" interface using cocci and sed.

Unfortunately "just" ;-)

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Other than that the patches are mostly equivalent, except yours parses more information than just the SCDC bits.

So merge patch 1 from your series + Shashank's parsing patch? Everyone agrees and can you pls cross-r-b stamp so I can apply it all?

Quoted 6 lines

I think I spotted a mistake in Shashank's parsing patch. Let me take another look.

If we can agree on a common way forward on how to deal with this kind of static data, I have no objections to caching data for the duration of a hotplug period.

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

In reply to Jose Abreu
Quoted 35 lines · Jose Abreu

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 10 lines · Jose Abreu

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Yeah, agreed. I was actually thinking about going one step further and provide more of the polling functionality as a helper. Even if we have accessors that wrap the low-level functionality, most drivers would still have to provide their own delayed workqueue to deal with sinks (or sources) that don't support read requests. Having this in standard helpers would help reduce the boilerplate a lot further.

Quoted 5 lines

Does your hardware by any chance support read requests on SCDC? It'd be interesting to see how that works in practice. Unfortunately Tegra does not seem to support it.

Thierry

Yes, my HW supports it though I don't have the setup here to test right now (but it was used before). In our controller it is pretty straight forward:
1) Enable interrupt for rr indication [source]
2) Enable update read on a rr [source]
3) Set rr flag in the sink [sink]

Quoted 4 lines

Point 2) makes it clear: Whenever we get a rr then the source will automatically read the sink and dump the contents read in the regbank. Then the SW gets an interrupt and it should read the contents of the registers.

Yes, I suspect that there will be three types of setups:

1) fully supported and integrated RR capability (such as in your case)

2) external I2C controller with the means of detecting the read request (and signal via an interrupt)

3) no read request support at all, in which case a delayed work queue is needed to poll periodically

For cases 1) and 3) it's probably only useful to have a helper to enable scrambling. For 2) there might be some use in having a helper that can setup the delayed work queue.

Given that we don't have any implementation yet, maybe it's better to defer the creation of helpers until we see common patterns emerge. The helper to enable scrambling could be useful in any case, though, so I'll add one.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Daniel Vetter
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Thierry Reding
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Quoted 6 lines
Quoted 3 lines

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

Quoted 6 lines
Quoted 1 line
	https://patchwork.freedesktop.org/patch/104806/

DPCD I complained about because somehow we ended up with 2 sets of helpers, one filling a struct and the others returning directly. I objected to the fact that there's 2 (and imo your patch duplicated even more), not that I think one approach is clearly inferior to the other.

My recollection is that I had proposed that I do the work of transitioning users of the parsers to the cached information but you had said that it wasn't worth the churn and that we should just go with the existing scheme of passing around the DPCD buffer and extending the parsers as necessary.

From that I inferred that the same would be true for EDID and since we already have a couple of helpers that operate on struct edid * and which return features, continuing that scheme was preferred.

Anyway, I don't really care either way. Maybe you and Ville can duke it out whether or not we want all of the fields parsed, irrespective of whether or not they will be used. Then I'll go with whatever you decide.

Quoted 18 lines

Demanding that there's some real users is also a valid point.

Quoted 11 lines
Quoted 4 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Quoted 4 lines

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

Quoted 7 lines

We're pretty good at consuming fairly invasive refactorings in drm-misc. So it just boils down to get some agreement on what things should look like (+1 from my side to parsing stuff into structs as a general idea), and then massaging all the existing users of the "wrong" interface using cocci and sed.

Unfortunately "just" ;-)

I think by now it would be useful to have a nested structure within struct drm_display_info that contains HDMI specific bits. We already have a number of candidates that could be extracted into such a structure (drm_detect_hdmi_monitor(), drm_detect_monitor_audio(), drm_rgb_quant_range_selectable(), ...).

Another possibility would be to subclass struct drm_display_info, as in:

	struct drm_hdmi_info {
		struct drm_display_info display;

		/* HDMI specific information */
		...
	};

Or yet another would be to create struct drm_hdmi_info as a separate structure and provide a helper which will extract the necessary info from the EDID. Drivers could then store that in driver-private data whereas struct drm_display_info could be reduced to the generic bits that it used to have.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

Quoted 28 lines · Thierry Reding
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Thierry Reding
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Quoted 6 lines
Quoted 3 lines

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

Quoted 6 lines
Quoted 1 line
	https://patchwork.freedesktop.org/patch/104806/

DPCD I complained about because somehow we ended up with 2 sets of helpers, one filling a struct and the others returning directly. I objected to the fact that there's 2 (and imo your patch duplicated even more), not that I think one approach is clearly inferior to the other.

Quoted 5 lines

My recollection is that I had proposed that I do the work of transitioning users of the parsers to the cached information but you had said that it wasn't worth the churn and that we should just go with the existing scheme of passing around the DPCD buffer and extending the parsers as necessary.

Hm, I guess it wasn't clear to me that you've offered to do all the conversions. Doing that would be awesome I think (but quite a bit of work), and if we bother with it, parsing into a struct is imo the better idea long-term.

Quoted 50 lines

From that I inferred that the same would be true for EDID and since we already have a couple of helpers that operate on struct edid * and which return features, continuing that scheme was preferred.

Anyway, I don't really care either way. Maybe you and Ville can duke it out whether or not we want all of the fields parsed, irrespective of whether or not they will be used. Then I'll go with whatever you decide.

Quoted 18 lines

Demanding that there's some real users is also a valid point.

Quoted 11 lines
Quoted 4 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Quoted 4 lines

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

Quoted 7 lines

We're pretty good at consuming fairly invasive refactorings in drm-misc. So it just boils down to get some agreement on what things should look like (+1 from my side to parsing stuff into structs as a general idea), and then massaging all the existing users of the "wrong" interface using cocci and sed.

Unfortunately "just" ;-)

I think by now it would be useful to have a nested structure within struct drm_display_info that contains HDMI specific bits. We already have a number of candidates that could be extracted into such a structure (drm_detect_hdmi_monitor(), drm_detect_monitor_audio(), drm_rgb_quant_range_selectable(), ...).

Another possibility would be to subclass struct drm_display_info, as in:

	struct drm_hdmi_info {
		struct drm_display_info display;

		/* HDMI specific information */
		...
	};
Quoted 5 lines

Or yet another would be to create struct drm_hdmi_info as a separate structure and provide a helper which will extract the necessary info from the EDID. Drivers could then store that in driver-private data whereas struct drm_display_info could be reduced to the generic bits that it used to have.

I think nested drm_hdmi_info within drm_display_info sounds like a fine idea.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

In reply to Thierry Reding
Quoted 53 lines · Thierry Reding
Quoted 35 lines · Jose Abreu

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 10 lines · Jose Abreu

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Yeah, agreed. I was actually thinking about going one step further and provide more of the polling functionality as a helper. Even if we have accessors that wrap the low-level functionality, most drivers would still have to provide their own delayed workqueue to deal with sinks (or sources) that don't support read requests. Having this in standard helpers would help reduce the boilerplate a lot further.

Quoted 5 lines

Does your hardware by any chance support read requests on SCDC? It'd be interesting to see how that works in practice. Unfortunately Tegra does not seem to support it.

Thierry

Yes, my HW supports it though I don't have the setup here to test right now (but it was used before). In our controller it is pretty straight forward:
1) Enable interrupt for rr indication [source]
2) Enable update read on a rr [source]
3) Set rr flag in the sink [sink]

Quoted 4 lines

Point 2) makes it clear: Whenever we get a rr then the source will automatically read the sink and dump the contents read in the regbank. Then the SW gets an interrupt and it should read the contents of the registers.

Yes, I suspect that there will be three types of setups:

1) fully supported and integrated RR capability (such as in your case)

2) external I2C controller with the means of detecting the read request (and signal via an interrupt)

3) no read request support at all, in which case a delayed work queue is needed to poll periodically

Quoted 8 lines

For cases 1) and 3) it's probably only useful to have a helper to enable scrambling. For 2) there might be some use in having a helper that can setup the delayed work queue.

Given that we don't have any implementation yet, maybe it's better to defer the creation of helpers until we see common patterns emerge. The helper to enable scrambling could be useful in any case, though, so I'll add one.

So no idea how this works, but how is a read request signalled? On the DP side there's just a short pulse hpd when the sink wants the source's attention. And iirc hdcp uses similar tricks when e.g. a downstream device has changed. We don't yet have it for DP, but some helper to handle hdp interrupts with a parameter to indicate long/short pulse is probably all that's really needed. But we don't yet have that for DP either :( -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

Re: [PATCH v2 3/3] drm/edid: Implement SCDC Read Request capability detection

Hi Daniel,

Quoted 56 lines · Daniel Vetter
Quoted 55 lines · Thierry Reding
Quoted 34 lines · Jose Abreu

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 10 lines · Jose Abreu

Hi Thierry,

Do you think while you are at it you could implement a set_scrambling() callback? It should be pretty straight forward:
you read the SCDC_TMDS_CONFIG reg, do a mask, and then write it again.

I think this is an important feature that we should have.

Yeah, agreed. I was actually thinking about going one step further and provide more of the polling functionality as a helper. Even if we have accessors that wrap the low-level functionality, most drivers would still have to provide their own delayed workqueue to deal with sinks (or sources) that don't support read requests. Having this in standard helpers would help reduce the boilerplate a lot further.

Quoted 5 lines

Does your hardware by any chance support read requests on SCDC? It'd be interesting to see how that works in practice. Unfortunately Tegra does not seem to support it.

Thierry

Yes, my HW supports it though I don't have the setup here to test right now (but it was used before). In our controller it is pretty straight forward:
1) Enable interrupt for rr indication [source]
2) Enable update read on a rr [source]
3) Set rr flag in the sink [sink]

Quoted 4 lines

Point 2) makes it clear: Whenever we get a rr then the source will automatically read the sink and dump the contents read in the regbank. Then the SW gets an interrupt and it should read the contents of the registers.

Yes, I suspect that there will be three types of setups:

1) fully supported and integrated RR capability (such as in your case)

2) external I2C controller with the means of detecting the read request (and signal via an interrupt)

3) no read request support at all, in which case a delayed work queue is needed to poll periodically

For cases 1) and 3) it's probably only useful to have a helper to enable scrambling. For 2) there might be some use in having a helper that can setup the delayed work queue.

Quoted 5 lines
Quoted 4 lines

Given that we don't have any implementation yet, maybe it's better to defer the creation of helpers until we see common patterns emerge. The helper to enable scrambling could be useful in any case, though, so I'll add one.

So no idea how this works, but how is a read request signalled?

On HDMI this is done in the I2C line. When the sink wants the source attention it pulses the SDA low when the bus is free. This should be correctly handled by the I2C controller that is connected or included in the HDMI controller.

Quoted 7 lines

On the DP
side there's just a short pulse hpd when the sink wants the source's attention. And iirc hdcp uses similar tricks when e.g. a downstream device has changed. We don't yet have it for DP, but some helper to handle hdp interrupts with a parameter to indicate long/short pulse is probably all that's really needed. But we don't yet have that for DP either :( -Daniel

Best regards,
Jose Miguel Abreu
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Daniel Vetter
Quoted 35 lines · Daniel Vetter
Quoted 28 lines · Thierry Reding
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Thierry Reding
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Quoted 6 lines
Quoted 3 lines

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

Quoted 6 lines
Quoted 1 line
	https://patchwork.freedesktop.org/patch/104806/

DPCD I complained about because somehow we ended up with 2 sets of helpers, one filling a struct and the others returning directly. I objected to the fact that there's 2 (and imo your patch duplicated even more), not that I think one approach is clearly inferior to the other.

Quoted 5 lines

My recollection is that I had proposed that I do the work of transitioning users of the parsers to the cached information but you had said that it wasn't worth the churn and that we should just go with the existing scheme of passing around the DPCD buffer and extending the parsers as necessary.

Quoted 4 lines

Hm, I guess it wasn't clear to me that you've offered to do all the conversions. Doing that would be awesome I think (but quite a bit of work), and if we bother with it, parsing into a struct is imo the better idea long-term.

I'm concerned about invalidating the data in the structs at the right times. We keep having issues with that whenever we cache stuff.

BR,
Jani.

Quoted 60 lines
Quoted 51 lines

From that I inferred that the same would be true for EDID and since we already have a couple of helpers that operate on struct edid * and which return features, continuing that scheme was preferred.

Anyway, I don't really care either way. Maybe you and Ville can duke it out whether or not we want all of the fields parsed, irrespective of whether or not they will be used. Then I'll go with whatever you decide.

Quoted 18 lines

Demanding that there's some real users is also a valid point.

Quoted 11 lines
Quoted 4 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Quoted 4 lines

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

Quoted 7 lines

We're pretty good at consuming fairly invasive refactorings in drm-misc. So it just boils down to get some agreement on what things should look like (+1 from my side to parsing stuff into structs as a general idea), and then massaging all the existing users of the "wrong" interface using cocci and sed.

Unfortunately "just" ;-)

I think by now it would be useful to have a nested structure within struct drm_display_info that contains HDMI specific bits. We already have a number of candidates that could be extracted into such a structure (drm_detect_hdmi_monitor(), drm_detect_monitor_audio(), drm_rgb_quant_range_selectable(), ...).

Another possibility would be to subclass struct drm_display_info, as in:

	struct drm_hdmi_info {
		struct drm_display_info display;

		/* HDMI specific information */
		...
	};
Quoted 5 lines

Or yet another would be to create struct drm_hdmi_info as a separate structure and provide a helper which will extract the necessary info from the EDID. Drivers could then store that in driver-private data whereas struct drm_display_info could be reduced to the generic bits that it used to have.

I think nested drm_hdmi_info within drm_display_info sounds like a fine idea.
-Daniel

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

RE: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

In reply to Daniel Vetter

Thanks Thierry and Daniel for concluding this discussion, while I was on vacation.

Here are the next steps, which I am planning to go for (Please correct me if my understanding is not right)
- Shashank to review first of the SCDC patch, and give comments or R-B.
- Shashank to work on Thierry's review comments on HF-VSDB parsing patch (including creation of a sub-class nested drm_hdmi_info within drm_display_info) and publish V2
- Thierry/Daniel to review V2 and give comments or R-B

Regards
Shashank
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, December 6, 2016 1:49 PM
To: Thierry Reding <[email protected]>
Cc: Daniel Vetter <[email protected]>; Sharma, Shashank <[email protected]>; Jose Abreu <[email protected]>; [email protected]
Subject: Re: [PATCH v2 2/3] drm/edid: Implement SCDC support detection

Quoted 28 lines · Thierry Reding
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Thierry Reding
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Thierry Reding
Quoted 4 lines · Shashank

Hi Thierry,

If you can please have a look on this patch, I had written one to parse HF-VSDB, which was covering SCDC detection too.
https://patchwork.kernel.org/patch/9452259/

Quoted 6 lines
Quoted 3 lines

I think there had been pushback before about caching capabilities from EDID, so from that point of view my patch is more inline with existing EDID parsing API.

Hm, where was that pushback? We do have a bit a mess between explicitly parsing stuff (e.g. eld) and stuffing parsed data into drm_display_info.

You did object to a very similar patch some time ago that did a similar thing for DPCD stuff. And also Villa had commented on an earlier patch from Jose about concerns of bloating core structures:

Quoted 6 lines
Quoted 1 line
	https://patchwork.freedesktop.org/patch/104806/

DPCD I complained about because somehow we ended up with 2 sets of helpers, one filling a struct and the others returning directly. I objected to the fact that there's 2 (and imo your patch duplicated even more), not that I think one approach is clearly inferior to the other.

Quoted 5 lines

My recollection is that I had proposed that I do the work of transitioning users of the parsers to the cached information but you had said that it wasn't worth the churn and that we should just go with the existing scheme of passing around the DPCD buffer and extending the parsers as necessary.

Hm, I guess it wasn't clear to me that you've offered to do all the conversions. Doing that would be awesome I think (but quite a bit of work), and if we bother with it, parsing into a struct is imo the better idea long-term.

Quoted 51 lines

From that I inferred that the same would be true for EDID and since we already have a couple of helpers that operate on struct edid * and which return features, continuing that scheme was preferred.

Anyway, I don't really care either way. Maybe you and Ville can duke it out whether or not we want all of the fields parsed, irrespective of whether or not they will be used. Then I'll go with whatever you decide.

Quoted 19 lines

Demanding that there's some real users is also a valid point.

Quoted 12 lines
Quoted 5 lines

I think long-term stuffing it into drm_display_info is probably better, since then we only have 1 interaction point between the probe code and the atomic_check code. That should be useful for eventually fixing the lack of locking between the two, if I ever get around to that ;-)

I don't really have objections to caching the results of parsing, it's what I had proposed and what seemed most natural back when I was working on the DPCD helpers. But if we now agree that this is the preferred way to do things, then we should at least agree that it applies to all areas for the sake of consistency.

Quoted 4 lines

Also, it might be worth looking into improving the structures, and maybe adding new ones to order things more conveniently or at least group them in some logical way. In my opinion some of our data structures are becoming somewhat... unwieldy.

Quoted 7 lines

We're pretty good at consuming fairly invasive refactorings in drm-misc. So it just boils down to get some agreement on what things should look like (+1 from my side to parsing stuff into structs as a general idea), and then massaging all the existing users of the "wrong" interface using cocci and sed.

Unfortunately "just" ;-)

I think by now it would be useful to have a nested structure within struct drm_display_info that contains HDMI specific bits. We already have a number of candidates that could be extracted into such a structure (drm_detect_hdmi_monitor(), drm_detect_monitor_audio(), drm_rgb_quant_range_selectable(), ...).

Another possibility would be to subclass struct drm_display_info, as in:

	struct drm_hdmi_info {
		struct drm_display_info display;

		/* HDMI specific information */
		...
	};
Quoted 5 lines

Or yet another would be to create struct drm_hdmi_info as a separate structure and provide a helper which will extract the necessary info from the EDID. Drivers could then store that in driver-private data whereas struct drm_display_info could be reduced to the generic bits that it used to have.

I think nested drm_hdmi_info within drm_display_info sounds like a fine idea. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel