[Intel-gfx] [PATCH 1/2] drm/edid: Add and export function to parse manufacturer id

José Roberto de Souza jose.souza at intel.com
Thu Nov 8 00:23:52 UTC 2018


This function will be helpful to drivers that wants to add its own
quirks to sinks.

Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 drivers/gpu/drm/drm_edid.c | 20 ++++++++++++++++----
 include/drm/drm_edid.h     |  1 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b506e3622b08..1a0ddf3d326b 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1755,6 +1755,21 @@ EXPORT_SYMBOL(drm_edid_duplicate);
 
 /*** EDID parsing ***/
 
+/**
+ * drm_edid_manufacturer_parse - parse the EDID manufacturer id to readable
+ * characters and set into manufacturer parameter.
+ * @edid: EDID to get the manufacturer
+ * @manufacturer: the char buffer to store the id
+ */
+void drm_edid_manufacturer_parse(const struct edid *edid, char manufacturer[3])
+{
+	manufacturer[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@';
+	manufacturer[1] = (((edid->mfg_id[0] & 0x3) << 3) |
+			  ((edid->mfg_id[1] & 0xe0) >> 5)) + '@';
+	manufacturer[2] = (edid->mfg_id[1] & 0x1f) + '@';
+}
+EXPORT_SYMBOL(drm_edid_manufacturer_parse);
+
 /**
  * edid_vendor - match a string against EDID's obfuscated vendor field
  * @edid: EDID to match
@@ -1766,10 +1781,7 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)
 {
 	char edid_vendor[3];
 
-	edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@';
-	edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) |
-			  ((edid->mfg_id[1] & 0xe0) >> 5)) + '@';
-	edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@';
+	drm_edid_manufacturer_parse(edid, edid_vendor);
 
 	return !strncmp(edid_vendor, vendor, 3);
 }
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index e3c404833115..e4f3f7f34d6a 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -466,6 +466,7 @@ struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
 				     struct i2c_adapter *adapter);
 struct edid *drm_edid_duplicate(const struct edid *edid);
 int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
+void drm_edid_manufacturer_parse(const struct edid *edid, char manufacturer[3]);
 
 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);
-- 
2.19.1



More information about the Intel-gfx mailing list