From: Peter Rosin <peda@axentia.se>
To: linux-kernel@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>, David Airlie <airlied@linux.ie>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Archit Taneja <architt@codeaurora.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Daniel Vetter <daniel.vetter@intel.com>,
Gustavo Padovan <gustavo@padovan.org>,
Sean Paul <seanpaul@chromium.org>,
Jacopo Mondi <jacopo@jmondi.org>,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/5] drm: of: add display bus-format parser
Date: Mon, 26 Mar 2018 23:24:45 +0200 [thread overview]
Message-ID: <20180326212447.7380-4-peda@axentia.se> (raw)
In-Reply-To: <20180326212447.7380-1-peda@axentia.se>
Add a common API to parse display bus format strings into fourcc codes.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
.../devicetree/bindings/display/bus-format.txt | 35 +++++++++++++
drivers/gpu/drm/drm_of.c | 59 ++++++++++++++++++++++
include/drm/drm_of.h | 9 ++++
3 files changed, 103 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/bus-format.txt
diff --git a/Documentation/devicetree/bindings/display/bus-format.txt b/Documentation/devicetree/bindings/display/bus-format.txt
new file mode 100644
index 000000000000..590e6c73f3dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bus-format.txt
@@ -0,0 +1,35 @@
+Bus formats in the display pipe
+===============================
+
+Various encoders in display controllers output the pixels in different
+formats. Circuits handling display connectors and hardwired panels also
+expect pixel input in various formats. We call these formats bus formats.
+
+Some bus formats are:
+
+Parallel
+--------
+
+rgb888
+ 8 parallel lines for red, green and blue respectively. There are
+ also lines for the pixel-clock, horizontal-sync, vertical-sync
+ and data-enable.
+
+rgb666
+ Same as rgb888, but with 6 lines per color.
+
+rgb565
+ Same as rgb888, but with 6 green lines and 5 red and blue lines.
+
+rgb444
+ Same as rgb888, but with 4 lines per color.
+
+
+LVDS
+----
+
+jeida-18
+jeida-24
+vesa-24
+ These are LVDS bus formats, see the data-mapping property in
+ panel/panel-lvds.txt for a description of these bus formats.
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 4c191c050e7d..5f65471225bb 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -262,3 +262,62 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
return ret;
}
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+
+/*
+ * drm_of_bus_formats - parse list of bus format strings into drm fourcc
+ * @np: device tree node containing bus format property
+ * @propname: name of bus format property
+ * @bus_formats: array of parsed fourcc codes
+ *
+ * On success, @bus_formats points to a location where the actual drm
+ * fourcc codes are.
+ * WARNING: The caller is responsible for freeing this memory with kfree.
+ *
+ * Returns the number of parsed bus format entries, or one of the standard
+ * error codes on failure.
+ */
+int drm_of_bus_formats(const struct device_node *np, const char *propname,
+ u32 **bus_formats)
+{
+ int num_bus_formats = of_property_count_strings(np, propname);
+ const char *fmt;
+ int ret;
+ int i;
+
+ if (num_bus_formats <= 0)
+ return num_bus_formats;
+
+ *bus_formats = kmalloc(num_bus_formats * sizeof(**bus_formats),
+ GFP_KERNEL);
+ if (!*bus_formats)
+ return -ENOMEM;
+
+ for (i = 0; i < num_bus_formats; ++i) {
+ ret = of_property_read_string_index(np, propname, i, &fmt);
+ if (ret < 0)
+ return ret;
+
+ if (!strcmp(fmt, "rgb444")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB444_1X12;
+ } else if (!strcmp(fmt, "rgb565")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB565_1X16;
+ } else if (!strcmp(fmt, "rgb666")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB666_1X18;
+ } else if (!strcmp(fmt, "rgb888")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB888_1X24;
+ } else if (!strcmp(fmt, "jeida-18")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
+ } else if (!strcmp(fmt, "jeida-24")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
+ } else if (!strcmp(fmt, "vesa-24")) {
+ *bus_formats[i] = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
+ } else {
+ kfree(*bus_formats);
+ *bus_formats = NULL;
+ return -EINVAL;
+ }
+ }
+
+ return num_bus_formats;
+}
+EXPORT_SYMBOL_GPL(drm_of_bus_formats);
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index b93c239afb60..ccacddc03a2e 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -33,6 +33,8 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
int port, int endpoint,
struct drm_panel **panel,
struct drm_bridge **bridge);
+int drm_of_bus_formats(const struct device_node *np, const char *propname,
+ u32 **bus_formats);
#else
static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
struct device_node *port)
@@ -69,6 +71,13 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
{
return -EINVAL;
}
+
+static inline int drm_of_bus_formats(const struct device_node *np,
+ const char *propname,
+ u32 **bus_formats)
+{
+ return -EINVAL;
+}
#endif
/*
--
2.11.0
next prev parent reply other threads:[~2018-03-26 21:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 21:24 [PATCH v2 0/5] allow override of bus format in bridges Peter Rosin
2018-03-26 21:24 ` [PATCH v2 1/5] dt-bindings: display: bridge: lvds-transmitter: add ti,ds90c185 Peter Rosin
2018-04-03 22:19 ` Laurent Pinchart
2018-03-26 21:24 ` [PATCH v2 2/5] drm: bridge: add API to query the expected input formats of bridges Peter Rosin
2018-03-27 9:47 ` jacopo mondi
2018-03-27 12:12 ` Peter Rosin
2018-03-27 13:02 ` jacopo mondi
2018-04-04 13:07 ` Laurent Pinchart
2018-04-04 14:40 ` Peter Rosin
2018-03-27 13:04 ` Peter Rosin
2018-03-26 21:24 ` Peter Rosin [this message]
2018-03-26 21:24 ` [PATCH v2 4/5] drm: bridge: lvds-encoder: allow specifying the input bus format Peter Rosin
2018-03-27 10:27 ` jacopo mondi
2018-03-27 12:56 ` Peter Rosin
2018-04-09 18:37 ` Rob Herring
2018-03-26 21:24 ` [PATCH v2 5/5] drm/atmel-hlcdc: take bridges into account when selecting output format Peter Rosin
2018-03-28 7:08 ` [PATCH v2 0/5] allow override of bus format in bridges Daniel Vetter
2018-04-03 22:28 ` Laurent Pinchart
2018-04-03 22:31 ` Laurent Pinchart
2018-04-04 6:34 ` Daniel Vetter
2018-04-04 9:07 ` Laurent Pinchart
2018-04-04 12:35 ` Peter Rosin
2018-04-09 7:04 ` Peter Rosin
2018-04-09 12:51 ` Laurent Pinchart
2018-04-09 13:29 ` Peter Rosin
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=20180326212447.7380-4-peda@axentia.se \
--to=peda@axentia.se \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=alexandre.belloni@bootlin.com \
--cc=architt@codeaurora.org \
--cc=boris.brezillon@free-electrons.com \
--cc=daniel.vetter@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=jacopo@jmondi.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nicolas.ferre@microchip.com \
--cc=robh+dt@kernel.org \
--cc=seanpaul@chromium.org \
/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
all inboxes | Powered by JetHome®