Skip to contentSkip to conversation

drm/probe-helper: convert drm_connector_helper_get_modes_from_ddc() to struct drm_edid

PATCH In review Jani Nikula 2 participants 4 messages Nov 14, 2023 – Jan 5, 2024

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

PATCH 1/1 drm/probe-helper: convert drm_connector_helper_get_modes_from_ddc() to struct drm_edid

Going forward, the struct drm_edid based functions drm_edid_read(), drm_edid_connector_update() and drm_edid_connector_add_modes() are the preferred ways of retrieving the EDID and updating the connector.

Cc Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/drm_probe_helper.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_probe_helper.c +8 -9
index 3f479483d7d8..309d88f13648 100644
@@ -1116,21 +1116,20 @@ EXPORT_SYMBOL(drm_crtc_helper_mode_valid_fixed);
  */
 int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
 {
-	struct edid *edid;
-	int count = 0;
+	const struct drm_edid *drm_edid;
+	int count;
 
 	if (!connector->ddc)
 		return 0;
 
-	edid = drm_get_edid(connector, connector->ddc);
+	drm_edid = drm_edid_read(connector);
+
+	/* clears property if EDID is NULL */
+	drm_edid_connector_update(connector, drm_edid);
 
-	// clears property if EDID is NULL
-	drm_connector_update_edid_property(connector, edid);
+	count = drm_edid_connector_add_modes(connector);
 
-	if (edid) {
-		count = drm_add_edid_modes(connector, edid);
-		kfree(edid);
-	}
+	drm_edid_free(drm_edid);
 
 	return count;
 }
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi

Am 14.11.23 um 11:58 schrieb Jani Nikula:

Quoted 6 lines

Going forward, the struct drm_edid based functions drm_edid_read(), drm_edid_connector_update() and drm_edid_connector_add_modes() are the preferred ways of retrieving the EDID and updating the connector.

Cc Thomas Zimmermann <[email protected]>

If I'm not mistaken, the correct pattern is to read the EDID block in the detect callback and only parse it for modes in get_modes. If so, you might also inline this helper into its only caller in mgag200. I'll later split it up into detect and get_modes.

Best regards
Thomas

Quoted 38 lines
---
  drivers/gpu/drm/drm_probe_helper.c | 17 ++++++++---------
  1 file changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_probe_helper.c +8 -9
index 3f479483d7d8..309d88f13648 100644
@@ -1116,21 +1116,20 @@ EXPORT_SYMBOL(drm_crtc_helper_mode_valid_fixed);
   */
  int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
  {
-	struct edid *edid;
-	int count = 0;
+	const struct drm_edid *drm_edid;
+	int count;
 
  	if (!connector->ddc)
  		return 0;
 
-	edid = drm_get_edid(connector, connector->ddc);
+	drm_edid = drm_edid_read(connector);
+
+	/* clears property if EDID is NULL */
+	drm_edid_connector_update(connector, drm_edid);
 
-	// clears property if EDID is NULL
-	drm_connector_update_edid_property(connector, edid);
+	count = drm_edid_connector_add_modes(connector);
 
-	if (edid) {
-		count = drm_add_edid_modes(connector, edid);
-		kfree(edid);
-	}
+	drm_edid_free(drm_edid);
 
  	return count;
  }
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#2 lore raw
Quoted 10 lines · Thomas Zimmermann

Hi

Am 14.11.23 um 11:58 schrieb Jani Nikula:

Quoted 6 lines

Going forward, the struct drm_edid based functions drm_edid_read(), drm_edid_connector_update() and drm_edid_connector_add_modes() are the preferred ways of retrieving the EDID and updating the connector.

Cc Thomas Zimmermann <[email protected]>
Quoted 6 lines

If I'm not mistaken, the correct pattern is to read the EDID block in the detect callback and only parse it for modes in get_modes. If so, you might also inline this helper into its only caller in mgag200. I'll later split it up into detect and get_modes.

That's what we do in i915 anyway.

drm_edid_read() and drm_edid_connector_update() in ->detect and ->force, and drm_edid_connector_add_modes() in ->get_modes.

BR,
Jani.

Quoted 42 lines

Best regards
Thomas

Quoted 38 lines
---
  drivers/gpu/drm/drm_probe_helper.c | 17 ++++++++---------
  1 file changed, 8 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_probe_helper.c +8 -9
index 3f479483d7d8..309d88f13648 100644
@@ -1116,21 +1116,20 @@ EXPORT_SYMBOL(drm_crtc_helper_mode_valid_fixed);
   */
  int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
  {
-	struct edid *edid;
-	int count = 0;
+	const struct drm_edid *drm_edid;
+	int count;
 
  	if (!connector->ddc)
  		return 0;
 
-	edid = drm_get_edid(connector, connector->ddc);
+	drm_edid = drm_edid_read(connector);
+
+	/* clears property if EDID is NULL */
+	drm_edid_connector_update(connector, drm_edid);
 
-	// clears property if EDID is NULL
-	drm_connector_update_edid_property(connector, edid);
+	count = drm_edid_connector_add_modes(connector);
 
-	if (edid) {
-		count = drm_add_edid_modes(connector, edid);
-		kfree(edid);
-	}
+	drm_edid_free(drm_edid);
 
  	return count;
  }
Signature · 1 line
Jani Nikula, Intel
#3 lore raw
In reply to Thomas Zimmermann
Quoted 4 lines · Thomas Zimmermann

If I'm not mistaken, the correct pattern is to read the EDID block in the detect callback and only parse it for modes in get_modes. If so, you might also inline this helper into its only caller in mgag200. I'll later split it up into detect and get_modes.

Never merged this, so I sent your suggested alternative instead [1].

BR,
Jani.

[1] https://patchwork.freedesktop.org/series/128269/

Signature · 1 line
Jani Nikula, Intel