[PATCH v2 1/3] drm_edid: Support getting EDID through ddc without connector

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some panels are interested in the EDID during early probe when connector
is still unknown.

Add a function drm_get_edid_no_connector() to get edid without connector.
No functional change for existing usage.

Signed-off-by: Hsin-Yi Wang <hsinyi@xxxxxxxxxxxx>
---
v1->v2:
add a function to return the entire edid without updating connector.
---
 drivers/gpu/drm/drm_edid.c | 45 ++++++++++++++++++++++++++++----------
 include/drm/drm_edid.h     |  1 +
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 1ad94473e400..15b97c8ed993 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2364,7 +2364,7 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
 	struct edid *edid, *new;
 	size_t alloc_size = EDID_LENGTH;
 
-	override = drm_edid_override_get(connector);
+	override = connector ? drm_edid_override_get(connector) : false;
 	if (override) {
 		alloc_size = override->size;
 		edid = kmemdup(override->edid, alloc_size, GFP_KERNEL);
@@ -2385,18 +2385,20 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
 	if (status == EDID_BLOCK_READ_FAIL)
 		goto fail;
 
-	/* FIXME: Clarify what a corrupt EDID actually means. */
-	if (status == EDID_BLOCK_OK || status == EDID_BLOCK_VERSION)
-		connector->edid_corrupt = false;
-	else
-		connector->edid_corrupt = true;
+	if (connector) {
+		/* FIXME: Clarify what a corrupt EDID actually means. */
+		if (status == EDID_BLOCK_OK || status == EDID_BLOCK_VERSION)
+			connector->edid_corrupt = false;
+		else
+			connector->edid_corrupt = true;
 
-	if (!edid_block_status_valid(status, edid_block_tag(edid))) {
-		if (status == EDID_BLOCK_ZERO)
-			connector->null_edid_counter++;
+		if (!edid_block_status_valid(status, edid_block_tag(edid))) {
+			if (status == EDID_BLOCK_ZERO)
+				connector->null_edid_counter++;
 
-		connector_bad_edid(connector, edid, 1);
-		goto fail;
+			connector_bad_edid(connector, edid, 1);
+			goto fail;
+		}
 	}
 
 	if (!edid_extension_block_count(edid))
@@ -2444,7 +2446,8 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
 	}
 
 	if (invalid_blocks) {
-		connector_bad_edid(connector, edid, num_blocks);
+		if (connector)
+			connector_bad_edid(connector, edid, num_blocks);
 
 		edid = edid_filter_invalid_blocks(edid, &alloc_size);
 	}
@@ -2637,6 +2640,24 @@ struct edid *drm_get_edid(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_get_edid);
 
+/**
+ * drm_get_edid_no_connector - get EDID data without updating connector status
+ * @adapter: I2C adapter to use for DDC
+ *
+ * Similar to drm_edid_read_ddc(), but not checking any connector status. Use
+ * this function to get EDID when connector is still unknown.
+ *
+ * Return: Pointer to valid EDID or NULL if we couldn't find any.
+ */
+struct edid *drm_get_edid_no_connector(struct i2c_adapter *adapter)
+{
+	if (!drm_probe_ddc(adapter))
+		return NULL;
+
+	return _drm_do_get_edid(NULL, drm_do_probe_ddc_edid, adapter, NULL);
+}
+EXPORT_SYMBOL(drm_get_edid_no_connector);
+
 /**
  * drm_edid_read_custom - Read EDID data using given EDID block read function
  * @connector: Connector to use
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 70ae6c290bdc..80c9e32ff80e 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -565,6 +565,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
 	void *data);
 struct edid *drm_get_edid(struct drm_connector *connector,
 			  struct i2c_adapter *adapter);
+struct edid *drm_get_edid_no_connector(struct i2c_adapter *adapter);
 u32 drm_edid_get_panel_id(struct i2c_adapter *adapter);
 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
 				     struct i2c_adapter *adapter);
-- 
2.44.0.rc1.240.g4c46232300-goog




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux