Skip to contentSkip to conversation

drm: Add drm.edid_quirk_param module parameter

PATCH In review Keith Packard 2 participants 2 messages Aug 9, 2018 – Aug 15, 2018

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

PATCH 1/1 drm: Add drm.edid_quirk_param module parameter

This parameter allows the set of EDID quirks to be changed at runtime. The syntax is

vendor/product/quirks,vendor/product/quirks,...

where vendor is the three-letter EDID vendor value, product is the EDID product id which may be prefixed with 0x to for hex instead of decimal values and quirks is the replacement quirks value from the list in drm_edid.c.

---
 drivers/gpu/drm/drm_edid.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_edid.c +22 -0
index 5dc742b27ca0..63b4587faddd 100644
@@ -98,6 +98,12 @@ struct detailed_mode_closure {
 #define LEVEL_GTF2	2
 #define LEVEL_CVT	3
 
+#define EDID_QUIRK_PARAM_LEN	256
+static char edid_quirk_param[EDID_QUIRK_PARAM_LEN];
+module_param_string(edid_quirk_param, edid_quirk_param, sizeof(edid_quirk_param), 0644);
+MODULE_PARM_DESC(edid_quirk_param, "Extra EDID quirks, "
+		 "format is 'vendor/product/quirks;...' ");
+
 static const struct edid_quirk {
 	char vendor[4];
 	int product_id;
@@ -1774,8 +1780,24 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)
 static u32 edid_get_quirks(const struct edid *edid)
 {
 	const struct edid_quirk *quirk;
+	const char *q;
 	int i;
 
+	for (q = edid_quirk_param; q && *q; q = strchr(q, ',')) {
+		char 	vendor[4];
+		int	product_id;
+		int	quirks;
+
+		while (*q == ',')
+			q++;
+
+		if (sscanf(q, "%3s/%i/%i", vendor, &product_id, &quirks) == 3) {
+			if (edid_vendor(edid, vendor) &&
+			    (EDID_PRODUCT_ID(edid) == product_id))
+				return quirks;
+		}
+	}
+
 	for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) {
 		quirk = &edid_quirk_list[i];
 
Signature · 6 lines
2.18.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 9 lines · Keith Packard

This parameter allows the set of EDID quirks to be changed at runtime. The syntax is

vendor/product/quirks,vendor/product/quirks,...

where vendor is the three-letter EDID vendor value, product is the EDID product id which may be prefixed with 0x to for hex instead of decimal values and quirks is the replacement quirks value from the list in drm_edid.c.

Why?

I guess if we want to manage quirks from userspace, we should work to provide an interface udev can use.

BR,
Jani.

Quoted 47 lines
---
 drivers/gpu/drm/drm_edid.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/drm_edid.c +22 -0
index 5dc742b27ca0..63b4587faddd 100644
@@ -98,6 +98,12 @@ struct detailed_mode_closure {
 #define LEVEL_GTF2	2
 #define LEVEL_CVT	3
 
+#define EDID_QUIRK_PARAM_LEN	256
+static char edid_quirk_param[EDID_QUIRK_PARAM_LEN];
+module_param_string(edid_quirk_param, edid_quirk_param, sizeof(edid_quirk_param), 0644);
+MODULE_PARM_DESC(edid_quirk_param, "Extra EDID quirks, "
+		 "format is 'vendor/product/quirks;...' ");
+
 static const struct edid_quirk {
 	char vendor[4];
 	int product_id;
@@ -1774,8 +1780,24 @@ static bool edid_vendor(const struct edid *edid, const char *vendor)
 static u32 edid_get_quirks(const struct edid *edid)
 {
 	const struct edid_quirk *quirk;
+	const char *q;
 	int i;
 
+	for (q = edid_quirk_param; q && *q; q = strchr(q, ',')) {
+		char 	vendor[4];
+		int	product_id;
+		int	quirks;
+
+		while (*q == ',')
+			q++;
+
+		if (sscanf(q, "%3s/%i/%i", vendor, &product_id, &quirks) == 3) {
+			if (edid_vendor(edid, vendor) &&
+			    (EDID_PRODUCT_ID(edid) == product_id))
+				return quirks;
+		}
+	}
+
 	for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) {
 		quirk = &edid_quirk_list[i];
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center