From patchwork Sat Apr 9 00:53:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhinav Kumar X-Patchwork-Id: 12807311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A539AC433F5 for ; Sat, 9 Apr 2022 00:54:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4410910F29E; Sat, 9 Apr 2022 00:54:19 +0000 (UTC) Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADA8910F29E; Sat, 9 Apr 2022 00:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649465657; x=1681001657; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Cnwv23K4B8XZHD2Nb0a3Tb5be/YO4uOT44lZEQnBpuo=; b=KBOTKjurtXxuxa6WeRCEbveLQ3yp0HK0/tEemskIBIu9XDFLOsxnnXyW 4pt3TUXW6oS5z9wl8XLh1dI3fYeni0PrszBjQiYmRRUA158utrj0KbgPE KNFYdyW4AvvBjKbRE7uz7O//kuZYS2w2N1OVaV7tYy4yRL0I8h99V5FF1 A=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 08 Apr 2022 17:54:17 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 17:54:16 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 8 Apr 2022 17:54:15 -0700 Received: from abhinavk-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 8 Apr 2022 17:54:15 -0700 From: Abhinav Kumar To: 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 Message-ID: <1649465635-20542-5-git-send-email-quic_abhinavk@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1649465635-20542-1-git-send-email-quic_abhinavk@quicinc.com> References: <1649465635-20542-1-git-send-email-quic_abhinavk@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 , 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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)