[PATCH 2/2] drm/panel-simple: allow LVDS format override

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink <j.zink@xxxxxxxxxxxxxx>
---
 drivers/gpu/drm/panel/panel-simple.c | 37 +++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index 065f378bba9d..7366ad13b3f1 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
+#include <drm/drm_of.h>
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
 	struct device_node *ddc;
 	int connector_type;
 	u32 bus_flags;
-	int err;
+	int err, ret;
 
 	panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
 	if (!panel)
@@ -605,6 +606,40 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
 			panel_simple_parse_panel_timing_node(dev, panel, &dt);
 	}
 
+
+	/* optional data-mapping property for overriding bus format */
+	ret = drm_of_lvds_get_data_mapping(dev->of_node);
+	if (ret == -EINVAL) {
+		dev_warn(dev, "Ignore invalid data-mapping property");
+	} else if (ret != -ENODEV) {
+		int bpc;
+
+		switch (ret) {
+		default:
+			WARN_ON(1);
+			fallthrough;
+		case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+			fallthrough;
+		case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+			bpc = 8;
+			break;
+		case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+			bpc = 6;
+		}
+
+		if (desc->bpc != bpc || desc->bus_format != ret) {
+			struct panel_desc *override_desc;
+
+			override_desc = devm_kmemdup(dev, desc, sizeof(*desc), GFP_KERNEL);
+			if (!override_desc)
+				return -ENOMEM;
+
+			override_desc->bus_format = ret;
+			override_desc->bpc = bpc;
+			panel->desc = override_desc;
+		}
+	}
+
 	connector_type = desc->connector_type;
 	/* Catch common mistakes for panels. */
 	switch (connector_type) {
-- 
2.39.2




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux