drm/edid: api to register cea modes if no edid supported

Saurabh Sengar saurabh.singh at xilinx.com
Fri Jul 14 07:24:51 UTC 2017


Adding drm_add_modes_noedid_cea API for supporting cea modes
for drm devices which does not have panel framework or edid
support.
Protocols like SDI whic have minimal support in linux kernel can
benifit from this.

There is already a API drm_add_modes_noedid, but that supports only
dmt modes.

Signed-off-by: Saurabh Sengar <saurabhs at xilinx.com>
---
 drivers/gpu/drm/drm_edid.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  2 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index ec77bd3..08cfd9d 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4110,6 +4110,54 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 EXPORT_SYMBOL(drm_add_edid_modes);
 
 /**
+ * drm_add_modes_noedid_cea - add cea modes for the connectors without EDID
+ * @connector: connector we're probing
+ * @hdisplay: the horizontal display limit
+ * @vdisplay: the vertical display limit
+ *
+ * Add the cea modes to the connector's mode list. Only when the
+ * hdisplay/vdisplay is not beyond the given limit, it will be added.
+ *
+ * Return: The number of modes added or 0 if we couldn't find any.
+ */
+int drm_add_modes_noedid_cea(struct drm_connector *connector,
+			int hdisplay, int vdisplay)
+{
+	int i, count, num_modes = 0;
+	struct drm_display_mode *mode;
+	struct drm_device *dev = connector->dev;
+
+	count = ARRAY_SIZE(edid_cea_modes);
+	if (hdisplay < 0)
+		hdisplay = 0;
+	if (vdisplay < 0)
+		vdisplay = 0;
+
+	for (i = 0; i < count; i++) {
+		const struct drm_display_mode *ptr = &edid_cea_modes[i];
+		if (hdisplay && vdisplay) {
+			/*
+			 * Only when two are valid, they will be used to check
+			 * whether the mode should be added to the mode list of
+			 * the connector.
+			 */
+			if (ptr->hdisplay > hdisplay ||
+					ptr->vdisplay > vdisplay)
+				continue;
+		}
+		if (drm_mode_vrefresh(ptr) > 61)
+			continue;
+		mode = drm_mode_duplicate(dev, ptr);
+		if (mode) {
+			drm_mode_probed_add(connector, mode);
+			num_modes++;
+		}
+	}
+	return num_modes;
+}
+EXPORT_SYMBOL(drm_add_modes_noedid_cea);
+
+/**
  * drm_add_modes_noedid - add modes for the connectors without EDID
  * @connector: connector we're probing
  * @hdisplay: the horizontal display limit
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index c3a7d44..67f4c26 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -445,6 +445,8 @@ 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,
 			 int hdisplay, int vdisplay);
+int drm_add_modes_noedid_cea(struct drm_connector *connector,
+			 int hdisplay, int vdisplay);
 void drm_set_preferred_mode(struct drm_connector *connector,
 			    int hpref, int vpref);
 
-- 
2.1.1



More information about the dri-devel mailing list