From: Sascha Hauer <s.hauer@pengutronix.de>
To: dri-devel@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
kernel@pengutronix.de, "Andy Yan" <andy.yan@rock-chips.com>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Michael Riesch" <michael.riesch@wolfvision.net>,
"Sandy Huang" <hjc@rock-chips.com>,
"Heiko Stübner" <heiko@sntech.de>,
"Peter Geis" <pgwipeout@gmail.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>
Subject: [PATCH v10 03/24] drm/rockchip: Add crtc_endpoint_id to rockchip_encoder
Date: Fri, 8 Apr 2022 13:22:17 +0200 [thread overview]
Message-ID: <20220408112238.1274817-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20220408112238.1274817-1-s.hauer@pengutronix.de>
The VOP2 has an interface mux which decides to which encoder(s) a CRTC
is routed to. The encoders and CRTCs are connected via of_graphs in the
device tree. When given an encoder the VOP2 driver needs to know to
which internal register setting this encoder matches. For this the VOP2
binding offers different endpoints, one for each possible encoder. The
endpoint ids of these endpoints are used as a key from an encoders
device tree description to the internal register setting.
This patch adds the key aka endpoint id to struct rockchip_encoder plus
a function to read the endpoint id starting from the encoders device
node.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Notes:
Changes since v6:
- new patch
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 33 +++++++++++++++++++++
drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 4 ++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 7efd12312354b..0dc09d92d92d6 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -244,6 +244,39 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
static int num_rockchip_sub_drivers;
+/*
+ * Get the endpoint id of the remote endpoint of the given encoder. This
+ * information is used by the VOP2 driver to identify the encoder.
+ *
+ * @rkencoder: The encoder to get the remote endpoint id from
+ * @np: The encoder device node
+ * @port: The number of the port leading to the VOP2
+ * @reg: The endpoint number leading to the VOP2
+ */
+int rockchip_drm_encoder_set_crtc_endpoint_id(struct rockchip_encoder *rkencoder,
+ struct device_node *np, int port, int reg)
+{
+ struct of_endpoint ep;
+ struct device_node *en, *ren;
+ int ret;
+
+ en = of_graph_get_endpoint_by_regs(np, port, reg);
+ if (!en)
+ return -ENOENT;
+
+ ren = of_graph_get_remote_endpoint(en);
+ if (!ren)
+ return -ENOENT;
+
+ ret = of_graph_parse_endpoint(ren, &ep);
+ if (ret)
+ return ret;
+
+ rkencoder->crtc_endpoint_id = ep.id;
+
+ return 0;
+}
+
/*
* Check if a vop endpoint is leading to a rockchip subdriver or bridge.
* Should be called from the component bind stage of the drivers
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 048ab277de653..a27ab928e1d2f 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -50,6 +50,7 @@ struct rockchip_drm_private {
};
struct rockchip_encoder {
+ int crtc_endpoint_id;
struct drm_encoder encoder;
};
@@ -60,7 +61,8 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
void rockchip_drm_dma_init_device(struct drm_device *drm_dev,
struct device *dev);
int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
-
+int rockchip_drm_encoder_set_crtc_endpoint_id(struct rockchip_encoder *rencoder,
+ struct device_node *np, int port, int reg);
int rockchip_drm_endpoint_is_subdriver(struct device_node *ep);
extern struct platform_driver cdn_dp_driver;
extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
--
2.30.2
next prev parent reply other threads:[~2022-04-08 11:23 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 11:22 [PATCH v10 00/24] drm/rockchip: RK356x VOP2 support Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 01/24] clk: rk3568: Mark hclk_vo as critical Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 02/24] drm/rockchip: Embed drm_encoder into rockchip_decoder Sascha Hauer
2022-04-08 11:22 ` Sascha Hauer [this message]
2022-04-08 11:22 ` [PATCH v10 04/24] drm/rockchip: dw_hdmi: rename vpll clock to reference clock Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 05/24] dt-bindings: display: rockchip: dw-hdmi: use "ref" as clock name Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 06/24] arm64: dts: rockchip: rk3399: rename HDMI ref clock to 'ref' Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 07/24] drm/rockchip: dw_hdmi: add rk3568 support Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 08/24] dt-bindings: display: rockchip: dw-hdmi: Add compatible for rk3568 HDMI Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 09/24] drm/rockchip: dw_hdmi: add regulator support Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 10/24] dt-bindings: display: rockchip: dw-hdmi: Add " Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 11/24] drm/rockchip: dw_hdmi: Use auto-generated tables Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 12/24] drm/rockchip: dw_hdmi: drop mode_valid hook Sascha Hauer
2022-04-10 11:31 ` Alex Bee
2022-04-11 7:53 ` Sascha Hauer
2022-04-11 17:00 ` Alex Bee
2022-04-14 8:13 ` Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 13/24] drm/rockchip: dw_hdmi: Set cur_ctr to 0 always Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 14/24] drm/rockchip: dw_hdmi: add default 594Mhz clk for 4K@60hz Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 15/24] dt-bindings: display: rockchip: dw-hdmi: Make unwedge pinctrl optional Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 16/24] arm64: dts: rockchip: rk356x: Add VOP2 nodes Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 17/24] arm64: dts: rockchip: rk356x: Add HDMI nodes Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 18/24] arm64: dts: rockchip: rk3568-evb: Enable VOP2 and hdmi Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 19/24] arm64: dts: rockchip: enable vop2 and hdmi tx on quartz64a Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 20/24] arm64: dts: rockchip: enable vop2 and hdmi tx on rock-3a Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 21/24] drm/rockchip: Make VOP driver optional Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 22/24] drm: rockchip: Add VOP2 driver Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 23/24] dt-bindings: display: rockchip: Add binding for VOP2 Sascha Hauer
2022-04-08 11:22 ` [PATCH v10 24/24] dt-bindings: display: rockchip: dw-hdmi: fix ports description Sascha Hauer
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=20220408112238.1274817-4-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=andy.yan@rock-chips.com \
--cc=benjamin.gaignard@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=michael.riesch@wolfvision.net \
--cc=pgwipeout@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).