dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Abhinav Kumar <quic_abhinavk@quicinc.com>
To: <dri-devel@lists.freedesktop.org>
Cc: hamohammed.sa@gmail.com, suraj.kandpal@intel.com,
	emma@anholt.net, rodrigosiqueiramelo@gmail.com,
	jani.nikula@intel.com, liviu.dudau@arm.com,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	swboyd@chromium.org, melissa.srw@gmail.com,
	nganji@codeaurora.org, seanpaul@chromium.org,
	laurent.pinchart@ideasonboard.com, dmitry.baryshkov@linaro.org,
	james.qian.wang@arm.com, quic_aravindh@quicinc.com,
	mihail.atanassov@arm.com, freedreno@lists.freedesktop.org
Subject: [PATCH v7 4/4] drm/vc4: change vc4 driver to use drm_writeback_connector_init_with_encoder()
Date: Fri, 8 Apr 2022 17:53:55 -0700	[thread overview]
Message-ID: <1649465635-20542-5-git-send-email-quic_abhinavk@quicinc.com> (raw)
In-Reply-To: <1649465635-20542-1-git-send-email-quic_abhinavk@quicinc.com>

vc4 driver currently embeds the drm_encoder into struct vc4_txp
and later on uses container_of to retrieve the vc4_txp from
the drm_encoder.

Make vc4 driver use the new API so that the embedded encoder model
can be retained in the driver and there is no change in
functionality.

changes in v7:
	- remove the drm core changes to previous patch in the series

Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
 drivers/gpu/drm/vc4/vc4_txp.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_txp.c b/drivers/gpu/drm/vc4/vc4_txp.c
index 7e063a9..0d461df 100644
--- a/drivers/gpu/drm/vc4/vc4_txp.c
+++ b/drivers/gpu/drm/vc4/vc4_txp.c
@@ -151,6 +151,8 @@ struct vc4_txp {
 
 	struct platform_device *pdev;
 
+	struct drm_encoder drm_enc;
+
 	struct drm_writeback_connector connector;
 
 	void __iomem *regs;
@@ -159,7 +161,7 @@ struct vc4_txp {
 
 static inline struct vc4_txp *encoder_to_vc4_txp(struct drm_encoder *encoder)
 {
-	return container_of(encoder, struct vc4_txp, connector.internal_encoder);
+	return container_of(encoder, struct vc4_txp, drm_enc);
 }
 
 static inline struct vc4_txp *connector_to_vc4_txp(struct drm_connector *conn)
@@ -368,6 +370,10 @@ static const struct drm_encoder_helper_funcs vc4_txp_encoder_helper_funcs = {
 	.disable = vc4_txp_encoder_disable,
 };
 
+static const struct drm_encoder_funcs vc4_txp_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static int vc4_txp_enable_vblank(struct drm_crtc *crtc)
 {
 	return 0;
@@ -467,6 +473,7 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
 	struct vc4_txp *txp;
 	struct drm_crtc *crtc;
 	struct drm_encoder *encoder;
+	struct drm_writeback_connector *wb_conn;
 	int ret, irq;
 
 	irq = platform_get_irq(pdev, 0);
@@ -492,16 +499,25 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
 	txp->regset.regs = txp_regs;
 	txp->regset.nregs = ARRAY_SIZE(txp_regs);
 
-	drm_connector_helper_add(&txp->connector.base,
-				 &vc4_txp_connector_helper_funcs);
-	ret = drm_writeback_connector_init(drm, &txp->connector,
-					   &vc4_txp_connector_funcs,
-					   &vc4_txp_encoder_helper_funcs,
-					   drm_fmts, ARRAY_SIZE(drm_fmts),
-					   0);
+	wb_conn = &txp->connector;
+
+	drm_encoder_helper_add(&txp->drm_enc, &vc4_txp_encoder_helper_funcs);
+
+	ret = drm_encoder_init(drm, &txp->drm_enc, &vc4_txp_encoder_funcs,
+			DRM_MODE_ENCODER_VIRTUAL, NULL);
 	if (ret)
 		return ret;
 
+	drm_connector_helper_add(&wb_conn->base, &vc4_txp_connector_helper_funcs);
+
+	ret = drm_writeback_connector_init_with_encoder(drm, wb_conn, &txp->drm_enc,
+			&vc4_txp_connector_funcs, drm_fmts, ARRAY_SIZE(drm_fmts));
+
+	if (ret) {
+		drm_encoder_cleanup(&txp->drm_enc);
+		return ret;
+	}
+
 	ret = vc4_crtc_init(drm, vc4_crtc,
 			    &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs);
 	if (ret)
-- 
2.7.4


  parent reply	other threads:[~2022-04-09  0:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09  0:53 [PATCH v7 0/4] Allow drm_writeback_connector to accept pointer to drm_encoder Abhinav Kumar
2022-04-09  0:53 ` [PATCH v7 1/4] drm: allow passing possible_crtcs to drm_writeback_connector_init() Abhinav Kumar
2022-04-09  0:59   ` Dmitry Baryshkov
2022-04-09  0:53 ` [PATCH v7 2/4] drm: introduce drm_writeback_connector_init_with_encoder() API Abhinav Kumar
2022-04-09  1:01   ` Dmitry Baryshkov
2022-04-09  0:53 ` [PATCH v7 3/4] drm: allow real encoder to be passed for drm_writeback_connector Abhinav Kumar
2022-04-09  1:05   ` Dmitry Baryshkov
2022-04-21 10:47   ` Liviu Dudau
2022-04-09  0:53 ` Abhinav Kumar [this message]
2022-04-20  1:54   ` [PATCH v7 4/4] drm/vc4: change vc4 driver to use drm_writeback_connector_init_with_encoder() Abhinav Kumar

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=1649465635-20542-5-git-send-email-quic_abhinavk@quicinc.com \
    --to=quic_abhinavk@quicinc.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=freedreno@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=james.qian.wang@arm.com \
    --cc=jani.nikula@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=liviu.dudau@arm.com \
    --cc=melissa.srw@gmail.com \
    --cc=mihail.atanassov@arm.com \
    --cc=nganji@codeaurora.org \
    --cc=quic_aravindh@quicinc.com \
    --cc=rodrigosiqueiramelo@gmail.com \
    --cc=seanpaul@chromium.org \
    --cc=suraj.kandpal@intel.com \
    --cc=swboyd@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;
as well as URLs for NNTP newsgroup(s).