From: philippe.cornu@st.com (Philippe CORNU)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/5] drm/stm: ltdc: Add bridge support
Date: Fri, 19 May 2017 17:20:14 +0200 [thread overview]
Message-ID: <1495207218-11372-2-git-send-email-philippe.cornu@st.com> (raw)
In-Reply-To: <1495207218-11372-1-git-send-email-philippe.cornu@st.com>
Add the bridge support, used by DSI host and HDMI/LVDS bridges.
Signed-off-by: Philippe CORNU <philippe.cornu@st.com>
---
drivers/gpu/drm/stm/ltdc.c | 74 ++++++++++++++++++++++++++++++++++------------
drivers/gpu/drm/stm/ltdc.h | 1 +
2 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 7b2d63b..809e420 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -858,6 +858,43 @@ static struct drm_encoder *ltdc_rgb_encoder_create(struct drm_device *ddev)
return encoder;
}
+static const struct drm_encoder_funcs bridge_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
+struct drm_encoder *bridge_encoder_create(struct drm_device *ddev,
+ struct drm_bridge *bridge)
+{
+ struct drm_encoder *encoder;
+ int ret;
+
+ encoder = devm_kzalloc(ddev->dev, sizeof(*encoder), GFP_KERNEL);
+ if (!encoder)
+ return NULL;
+
+ encoder->possible_crtcs = CRTC_MASK;
+ encoder->possible_clones = 0; /* No cloning support */
+
+ drm_encoder_init(ddev, encoder, &bridge_encoder_funcs,
+ DRM_MODE_ENCODER_TMDS, NULL);
+
+ drm_encoder_helper_add(encoder, NULL);
+
+ /* Link drm_bridge to encoder */
+ bridge->encoder = encoder;
+ encoder->bridge = bridge;
+
+ ret = drm_bridge_attach(encoder, bridge, NULL);
+ if (ret) {
+ drm_encoder_cleanup(encoder);
+ return NULL;
+ }
+
+ DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id);
+
+ return encoder;
+}
+
/*
* DRM_CONNECTOR
*/
@@ -967,12 +1004,13 @@ static int ltdc_get_caps(struct drm_device *ddev)
return 0;
}
-static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
+static int ltdc_parse_dt(struct drm_device *ddev)
{
+ struct ltdc_device *ldev = ddev->dev_private;
struct device *dev = ddev->dev;
struct device_node *np = dev->of_node;
- struct device_node *entity, *port = NULL;
- struct drm_panel *panel = NULL;
+ struct device_node *entity;
+ int ret;
DRM_DEBUG_DRIVER("\n");
@@ -985,21 +1023,13 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
if (!of_device_is_available(entity))
continue;
- port = of_graph_get_remote_port_parent(entity);
- if (port) {
- panel = of_drm_find_panel(port);
- of_node_put(port);
- if (panel) {
- DRM_DEBUG_DRIVER("remote panel %s\n",
- port->full_name);
- } else {
- DRM_DEBUG_DRIVER("panel missing\n");
- of_node_put(entity);
- }
- }
+ ret = drm_of_find_panel_or_bridge(np, 0, 0,
+ &ldev->panel, &ldev->bridge);
+ if (ret)
+ return ret;
}
- return panel;
+ return 0;
}
int ltdc_load(struct drm_device *ddev)
@@ -1017,9 +1047,9 @@ int ltdc_load(struct drm_device *ddev)
DRM_DEBUG_DRIVER("\n");
- ldev->panel = ltdc_get_panel(ddev);
- if (!ldev->panel)
- return -EPROBE_DEFER;
+ ret = ltdc_parse_dt(ddev);
+ if (ret)
+ return ret;
rstc = of_reset_control_get(np, NULL);
@@ -1077,6 +1107,12 @@ int ltdc_load(struct drm_device *ddev)
DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version);
+ if (ldev->bridge) {
+ encoder = bridge_encoder_create(ddev, ldev->bridge);
+ if (!encoder)
+ return -EINVAL;
+ }
+
if (ldev->panel) {
encoder = ltdc_rgb_encoder_create(ddev);
if (!encoder) {
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index 5427ef4..0083cad 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -25,6 +25,7 @@ struct ltdc_device {
void __iomem *regs;
struct clk *pixel_clk; /* lcd pixel clock */
struct drm_panel *panel;
+ struct drm_bridge *bridge;
struct spinlock lock; /* protecting irq status register */
struct ltdc_caps caps;
u32 clut[256]; /* color look up table */
--
1.9.1
next prev parent reply other threads:[~2017-05-19 15:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 15:20 [PATCH v2 0/5] STM32 DSI HOST Philippe CORNU
2017-05-19 15:20 ` Philippe CORNU [this message]
2017-05-19 19:33 ` [PATCH v2 1/5] drm/stm: ltdc: Add bridge support Eric Anholt
2017-05-23 2:11 ` Andrzej Hajda
2017-05-19 15:20 ` [PATCH v2 2/5] dt-bindings: display: Add Synopsys DW MIPI DSI DRM bridge driver Philippe CORNU
2017-05-23 15:14 ` Rob Herring
2017-05-19 15:20 ` [PATCH v2 3/5] drm/bridge/synopsys: Add MIPI DSI host controller bridge Philippe CORNU
2017-05-19 15:33 ` Neil Armstrong
2017-05-19 16:16 ` Philippe CORNU
2017-05-25 11:23 ` Archit Taneja
2017-06-02 15:08 ` Philippe CORNU
2017-05-19 15:20 ` [PATCH v2 4/5] dt-bindings: display: Add STM32 DSI host driver Philippe CORNU
2017-05-23 15:17 ` Rob Herring
2017-05-19 15:20 ` [PATCH v2 5/5] drm/stm: " Philippe CORNU
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=1495207218-11372-2-git-send-email-philippe.cornu@st.com \
--to=philippe.cornu@st.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).