[PATCH 3/5] drm/edid: add a ddc read block context

Jani Nikula jani.nikula at intel.com
Fri Dec 15 09:11:17 UTC 2023


Pass ddc address from higher up

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 drivers/gpu/drm/drm_edid.c | 39 ++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 1d6886ee3f82..d25fd4b1adb2 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2137,8 +2137,8 @@ static struct edid *edid_filter_invalid_blocks(struct edid *edid,
  *
  * Return: 0 on success or -1 on failure.
  */
-static int
-ddc_read_block(struct i2c_adapter *adapter, u16 addr, u8 *buf, unsigned int block, size_t len)
+static int ddc_read_block_addr(struct i2c_adapter *adapter, u16 addr,
+			       u8 *buf, unsigned int block, size_t len)
 {
 	unsigned char start = block * EDID_LENGTH;
 	unsigned char segment = block >> 1;
@@ -2188,9 +2188,16 @@ ddc_read_block(struct i2c_adapter *adapter, u16 addr, u8 *buf, unsigned int bloc
 	return ret == xfers ? 0 : -1;
 }
 
-static int ddc_read_block(void *context, u8 *buf, unsigned int block, size_t len)
+struct ddc_read_block_context {
+	struct i2c_adapter *adapter;
+	u16 addr;
+};
+
+static int ddc_read_block(void *_context, u8 *buf, unsigned int block, size_t len)
 {
-	return ddc_read_block_addr(context, DDC_ADDR, buf, block, len);
+	struct ddc_read_block_context *context = _context;
+
+	return ddc_read_block_addr(context->adapter, context->addr, buf, block, len);
 }
 
 static void connector_bad_edid(struct drm_connector *connector,
@@ -2615,9 +2622,13 @@ EXPORT_SYMBOL(drm_edid_free);
 bool
 drm_probe_ddc(struct i2c_adapter *adapter)
 {
+	struct ddc_read_block_context context = {
+		.adapter = adapter,
+		.addr = DDC_ADDR,
+	};
 	unsigned char out;
 
-	return ddc_read_block(adapter, &out, 0, 1) == 0;
+	return ddc_read_block(&context, &out, 0, 1) == 0;
 }
 EXPORT_SYMBOL(drm_probe_ddc);
 
@@ -2634,6 +2645,10 @@ EXPORT_SYMBOL(drm_probe_ddc);
 struct edid *drm_get_edid(struct drm_connector *connector,
 			  struct i2c_adapter *adapter)
 {
+	struct ddc_read_block_context context = {
+		.adapter = adapter,
+		.addr = DDC_ADDR,
+	};
 	struct edid *edid;
 
 	if (connector->force == DRM_FORCE_OFF)
@@ -2642,7 +2657,7 @@ struct edid *drm_get_edid(struct drm_connector *connector,
 	if (connector->force == DRM_FORCE_UNSPECIFIED && !drm_probe_ddc(adapter))
 		return NULL;
 
-	edid = _drm_do_get_edid(connector, ddc_read_block, adapter, NULL);
+	edid = _drm_do_get_edid(connector, ddc_read_block, &context, NULL);
 	drm_connector_update_edid_property(connector, edid);
 	return edid;
 }
@@ -2715,6 +2730,10 @@ EXPORT_SYMBOL(drm_edid_read_custom);
 const struct drm_edid *drm_edid_read_ddc(struct drm_connector *connector,
 					 struct i2c_adapter *adapter)
 {
+	struct ddc_read_block_context context = {
+		.adapter = adapter,
+		.addr = DDC_ADDR,
+	};
 	const struct drm_edid *drm_edid;
 
 	if (connector->force == DRM_FORCE_OFF)
@@ -2723,7 +2742,7 @@ const struct drm_edid *drm_edid_read_ddc(struct drm_connector *connector,
 	if (connector->force == DRM_FORCE_UNSPECIFIED && !drm_probe_ddc(adapter))
 		return NULL;
 
-	drm_edid = drm_edid_read_custom(connector, ddc_read_block, adapter);
+	drm_edid = drm_edid_read_custom(connector, ddc_read_block, &context);
 
 	/* Note: Do *not* call connector updates here. */
 
@@ -2800,6 +2819,10 @@ static u32 edid_extract_panel_id(const struct edid *edid)
 
 u32 drm_edid_get_panel_id(struct i2c_adapter *adapter)
 {
+	struct ddc_read_block_context context = {
+		.adapter = adapter,
+		.addr = DDC_ADDR,
+	};
 	enum edid_block_status status;
 	void *base_block;
 	u32 panel_id = 0;
@@ -2813,7 +2836,7 @@ u32 drm_edid_get_panel_id(struct i2c_adapter *adapter)
 	if (!base_block)
 		return 0;
 
-	status = edid_block_read(base_block, 0, ddc_read_block, adapter);
+	status = edid_block_read(base_block, 0, ddc_read_block, &context);
 
 	edid_block_status_print(status, base_block, 0);
 
-- 
2.39.2



More information about the Intel-gfx-trybot mailing list