From: Liu Ying <victor.liu@nxp.com>
To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
andrzej.hajda@intel.com, neil.armstrong@linaro.org,
rfoss@kernel.org, Laurent.pinchart@ideasonboard.com,
jonas@kwiboo.se, jernej.skrabec@gmail.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch
Subject: [PATCH 2/5] drm/of: Add drm_of_dpi_get_color_coding()
Date: Tue, 4 Mar 2025 18:15:27 +0800 [thread overview]
Message-ID: <20250304101530.969920-3-victor.liu@nxp.com> (raw)
In-Reply-To: <20250304101530.969920-1-victor.liu@nxp.com>
Add helper function drm_of_dpi_get_color_coding() to get media bus format
value from MIPI DPI color coding string.
Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
drivers/gpu/drm/drm_of.c | 43 ++++++++++++++++++++++++++++++++++++++++
include/drm/drm_of.h | 7 +++++++
2 files changed, 50 insertions(+)
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index d0183dea7703..6e2e19275b99 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -285,6 +285,49 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
}
EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
+/**
+ * drm_of_dpi_get_color_coding - Get DPI color coding
+ * @endpoint: DT endpoint node of the DPI source or sink
+ *
+ * Convert DT "dpi-color-coding" property string value into media bus format
+ * value.
+ *
+ * Return:
+ * * MEDIA_BUS_FMT_RGB565_1X16 - dpi-color-coding is "16bit-configuration1"
+ * * MEDIA_BUS_FMT_RGB565_1X24_CPADHI - dpi-color-coding is
+ * "16bit-configuration2"
+ * * MEDIA_BUS_FMT_RGB666_1X18 - dpi-color-coding is "18bit-configuration1"
+ * * MEDIA_BUS_FMT_BGR666_1X24_CPADHI - dpi-color-coding is
+ * "18bit-configuration2"
+ * * MEDIA_BUS_FMT_RGB888_1X24 - dpi-color-coding is "24bit"
+ * * -EINVAL - the "dpi-color-coding" property is unsupported
+ * * -ENODEV - the "dpi-color-coding" property is missing
+ */
+int drm_of_dpi_get_color_coding(const struct device_node *endpoint)
+{
+ const char *coding;
+ int ret;
+
+ ret = of_property_read_string(endpoint, "dpi-color-coding", &coding);
+ if (ret < 0)
+ return -ENODEV;
+
+ /* TODO: Add 16bit-configuration3 support. */
+ if (!strcmp(coding, "16bit-configuration1"))
+ return MEDIA_BUS_FMT_RGB565_1X16;
+ if (!strcmp(coding, "16bit-configuration2"))
+ return MEDIA_BUS_FMT_RGB565_1X24_CPADHI;
+ if (!strcmp(coding, "18bit-configuration1"))
+ return MEDIA_BUS_FMT_RGB666_1X18;
+ if (!strcmp(coding, "18bit-configuration2"))
+ return MEDIA_BUS_FMT_BGR666_1X24_CPADHI;
+ if (!strcmp(coding, "24bit"))
+ return MEDIA_BUS_FMT_RGB888_1X24;
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(drm_of_dpi_get_color_coding);
+
enum drm_of_lvds_pixels {
DRM_OF_LVDS_EVEN = BIT(0),
DRM_OF_LVDS_ODD = BIT(1),
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index 7f0256dae3f1..0a827f3b3a55 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -50,6 +50,7 @@ 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_dpi_get_color_coding(const struct device_node *endpoint);
int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
const struct device_node *port2);
int drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1,
@@ -104,6 +105,12 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
return -EINVAL;
}
+static inline int
+drm_of_dpi_get_color_coding(const struct device_node *endpoint)
+{
+ return -EINVAL;
+}
+
static inline int
drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
const struct device_node *port2)
--
2.34.1
next prev parent reply other threads:[~2025-03-04 10:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 10:15 [PATCH 0/5] drm/bridge: simple-bridge: Add DPI color encoder support Liu Ying
2025-03-04 10:15 ` [PATCH 1/5] dt-bindings: display: Document DPI color codings Liu Ying
2025-03-04 10:33 ` Maxime Ripard
2025-03-05 7:51 ` Krzysztof Kozlowski
2025-03-05 8:26 ` Maxime Ripard
2025-03-05 12:16 ` Krzysztof Kozlowski
2025-03-06 7:13 ` Liu Ying
2025-03-04 10:15 ` Liu Ying [this message]
2025-03-04 10:15 ` [PATCH 3/5] dt-bindings: display: simple-bridge: Document DPI color encoder Liu Ying
2025-03-04 10:38 ` Maxime Ripard
2025-03-06 5:49 ` Liu Ying
2025-03-04 11:27 ` Rob Herring (Arm)
2025-03-04 15:23 ` Rob Herring
2025-03-05 9:35 ` Alexander Stein
2025-03-05 16:38 ` Rob Herring
2025-03-06 7:02 ` Liu Ying
2025-03-06 11:35 ` Maxime Ripard
2025-03-06 20:34 ` Rob Herring
2025-03-07 3:25 ` Liu Ying
2025-03-10 9:53 ` Maxime Ripard
2025-03-11 2:29 ` Liu Ying
2025-03-11 7:44 ` Maxime Ripard
2025-03-07 3:10 ` Liu Ying
2025-03-10 9:44 ` Maxime Ripard
2025-03-11 2:38 ` Liu Ying
2025-03-11 7:52 ` Maxime Ripard
2025-03-04 10:15 ` [PATCH 4/5] drm/bridge: simple-bridge: Add DPI color encoder support Liu Ying
2025-03-04 10:40 ` Maxime Ripard
2025-03-06 5:57 ` Liu Ying
2025-03-04 10:15 ` [PATCH 5/5] drm/bridge: simple-bridge: Add next panel support Liu Ying
2025-03-04 10:41 ` Maxime Ripard
2025-03-06 6:17 ` Liu Ying
2025-03-04 15:00 ` [PATCH 0/5] drm/bridge: simple-bridge: Add DPI color encoder support Alexander Stein
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=20250304101530.969920-3-victor.liu@nxp.com \
--to=victor.liu@nxp.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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).