From: Johannes Zink <j.zink@pengutronix.de>
To: thierry.reding@gmail.com, sam@ravnborg.org, airlied@gmail.com,
daniel@ffwll.ch, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel@pengutronix.de
Cc: Johannes Zink <j.zink@pengutronix.de>
Subject: [PATCH 2/2] drm/panel-simple: allow LVDS format override
Date: Fri, 14 Apr 2023 18:11:16 +0200 [thread overview]
Message-ID: <20230414161116.3673911-3-j.zink@pengutronix.de> (raw)
In-Reply-To: <20230414161116.3673911-1-j.zink@pengutronix.de>
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@pengutronix.de>
---
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
next prev parent reply other threads:[~2023-04-14 16:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 16:11 [PATCH 0/2] Support non-default LVDS data mapping for simple Johannes Zink
2023-04-14 16:11 ` [PATCH 1/2] dt-bindings: display: simple: support non-default data-mapping Johannes Zink
2023-04-18 21:20 ` Rob Herring
2023-04-19 6:29 ` Johannes Zink
2023-05-04 7:35 ` Johannes Zink
2023-04-14 16:11 ` Johannes Zink [this message]
2023-04-17 4:46 ` [PATCH 2/2] drm/panel-simple: allow LVDS format override Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230414161116.3673911-3-j.zink@pengutronix.de \
--to=j.zink@pengutronix.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sam@ravnborg.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).