From patchwork Mon Mar 25 07:13:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10868027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A46018B7 for ; Mon, 25 Mar 2019 07:14:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6036C29246 for ; Mon, 25 Mar 2019 07:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541452924C; Mon, 25 Mar 2019 07:14:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D36429250 for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbfCYHOA (ORCPT ); Mon, 25 Mar 2019 03:14:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:41930 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729765AbfCYHN7 (ORCPT ); Mon, 25 Mar 2019 03:13:59 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190325071358euoutp013ed5334e1ae463362651de28f2837c75~PIjwecRPw0750607506euoutp01V; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190325071358euoutp013ed5334e1ae463362651de28f2837c75~PIjwecRPw0750607506euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553498038; bh=HLWtj5gpnxYOt1cQ0328ti+3eXRQqGE+sXdo+C8YpoQ=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=qo/RPynOUuU0Zw+0oi1XyYIPSPFboUtIGrQQgtNdr21VYdYZLtCmlTSpTy1WPfrhU m+M4vw8jvkpsA+KGGDhDcbPlV0JcnMfDXuvg/oFCOhnvzeNz4elMzs7Yqcuiv5q9qe nJ+6KBK/5TERkhSUzu9tNyeFy7F8b8I7B57gcSzk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190325071357eucas1p216d8dc1c054d756626e91276ca891501~PIjwG4NBk0650606506eucas1p2M; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 70.6E.04298.5BF789C5; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071356eucas1p169112fff9a6b5914c93b162a267348f1~PIjvd7F4i1607116071eucas1p1k; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) X-AuditID: cbfec7f2-3615e9c0000010ca-bb-5c987fb5b017 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B2.69.04146.4BF789C5; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.51.74]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0POW003QHUR43P00@eusync3.samsung.com>; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) From: Andrzej Hajda To: Inki Dae Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, Krzysztof Kozlowski Subject: [PATCH v3 RESEND 09/24] drm/exynos/fimd: embed exynos_drm_crtc directly into context Date: Mon, 25 Mar 2019 08:13:34 +0100 Message-id: <20190325071349.22600-10-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20190325071349.22600-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRmVeSWpSXmKPExsWy7djP87pb62fEGGyZIGFxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyHs29y1bwybpiyrzLzA2MZwy7GDk5JARMJL5dPcDexcjFISSwglHi/NNO VgjnM6PEn7ZrbDBV7f+2MUIkljFKHPt1HarqP6PElK51TCBVbAKaEn833wTrEBFQlli1rx1s LrPAb0aJ6cu3sYMkhAXiJTY8OscMYrMIqEpMWtYJFucVsJT4d2c91Dp5idUbDoDVcALF/5++ xAwySELgL6vE6/9rWSGKXCTWTvrNDGHLSHR2HGSCsOsl7q9ogWroYJTYumEnVJG1xOHjF8Ga mQX4JCZtmw4U5wCK80p0tAlBlHhI3Nn/hhnitR5GibkblrBPYJRYwMiwilE8tbQ4Nz212DAv tVyvODG3uDQvXS85P3cTIzDGTv87/mkH49dLSYcYBTgYlXh4X+ycHiPEmlhWXJl7iFGCg1lJ hPeJ6IwYId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzVDA+ihQTSE0tSs1NTC1KLYLJMHJxSDYzN OpvfTAuUMM6+VnuxYuauL/f8A5MUP+pxT5u7tO6RuAwX44J4TSELRgWV9V/uq9ivf2TtoJGu emZO16KyY28uFCg+Mgx9GKt85nO/reyFaxGlKRZavLt7dp5jN+E5kL6hRurGxn+b1Z7Gp3W2 dR2cn5G8dop1G7PTGt+fD97NMCi1ufF6UZASS3FGoqEWc1FxIgDKVdDcrQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4Vd0t9TNiDD6fsLa4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZj+beZSv4ZF0xZd5l5gbGM4ZdjJwcEgImEu3/tjF2MXJxCAksYZS4MXMD M4TTyCRx6vpLZpAqNgFNib+bb7KB2CICyhKr9rWzgxQxC/xmlPg84ytYkbBAvMSGR+fAbBYB VYlJyzrZQWxeAUuJf3fWs0Gsk5dYveEAWA0nUPz/6UtgtpCAhcTeZY3sExh5FjAyrGIUSS0t zk3PLTbUK07MLS7NS9dLzs/dxAgMmm3Hfm7ewXhpY/AhRgEORiUeXoc902OEWBPLiitzDzFK cDArifA+EZ0RI8SbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJanZqakFqEUyWiYNT qoExNM9tvg73ymbpvJmx74Xvhi7L5VRrXB0m7rtneteVH1I8n0v26oX828BXqCk0fb+t/F1+ 002/tzue0PnI9XXTD6vrVVxT2Iyz/YJrutaFSxU/PfZlyqKYt87GazZ8NjIU8cnMNcmOdr60 SpuhTKXidsSxw8/t93i+8I5yqn4jPzl417mX7lpKLMUZiYZazEXFiQAPEenxFgIAAA== X-CMS-MailID: 20190325071356eucas1p169112fff9a6b5914c93b162a267348f1 CMS-TYPE: 201P X-CMS-RootMailID: 20190325071356eucas1p169112fff9a6b5914c93b162a267348f1 References: <20190325071349.22600-1-a.hajda@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since crtc maps 1:1 to the device there is no point in allocating it separately, another benefit is possibility of direct initialisation of its fields which is more readable and allows further expansion. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 60 ++++++++++++------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 2d34ca375ee1..8ea1cfd51736 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -169,7 +169,7 @@ static struct fimd_driver_data exynos5420_fimd_driver_data = { struct fimd_context { struct device *dev; struct drm_device *drm_dev; - struct exynos_drm_crtc *crtc; + struct exynos_drm_crtc crtc; struct exynos_drm_plane planes[WINDOWS_NR]; struct clk *bus_clk; struct clk *lcd_clk; @@ -193,6 +193,8 @@ struct fimd_context { struct exynos_drm_clk dp_clk; }; +#define to_fimd(ptr) container_of(ptr, struct fimd_context, ptr) + static const struct of_device_id fimd_driver_dt_match[] = { { .compatible = "samsung,s3c6400-fimd", .data = &s3c64xx_fimd_driver_data }, @@ -235,7 +237,7 @@ static inline void fimd_set_bits(struct fimd_context *ctx, u32 reg, u32 mask, static int fimd_enable_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); u32 val; if (ctx->suspended) @@ -267,7 +269,7 @@ static int fimd_enable_vblank(struct exynos_drm_crtc *crtc) static void fimd_disable_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); u32 val; if (ctx->suspended) @@ -291,7 +293,7 @@ static void fimd_disable_vblank(struct exynos_drm_crtc *crtc) static void fimd_wait_for_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); if (ctx->suspended) return; @@ -345,7 +347,7 @@ static void fimd_disable_win(struct fimd_context *ctx, int win) static void fimd_clear_channels(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); unsigned int win, ch_enabled = 0; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -370,9 +372,9 @@ static void fimd_clear_channels(struct exynos_drm_crtc *crtc) if (ch_enabled) { ctx->suspended = false; - fimd_enable_vblank(ctx->crtc); - fimd_wait_for_vblank(ctx->crtc); - fimd_disable_vblank(ctx->crtc); + fimd_enable_vblank(&ctx->crtc); + fimd_wait_for_vblank(&ctx->crtc); + fimd_disable_vblank(&ctx->crtc); ctx->suspended = true; } @@ -388,7 +390,7 @@ static int fimd_atomic_check(struct exynos_drm_crtc *crtc, struct drm_crtc_state *state) { struct drm_display_mode *mode = &state->adjusted_mode; - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); unsigned long ideal_clk, lcd_rate; u32 clkdiv; @@ -448,7 +450,7 @@ static void fimd_setup_trigger(struct fimd_context *ctx) static void fimd_commit(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); struct drm_display_mode *mode = &crtc->base.state->adjusted_mode; const struct fimd_driver_data *driver_data = ctx->driver_data; void *timing_base = ctx->regs + driver_data->timing_base; @@ -754,7 +756,7 @@ static void fimd_shadow_protect_win(struct fimd_context *ctx, static void fimd_atomic_begin(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); int i; if (ctx->suspended) @@ -766,7 +768,7 @@ static void fimd_atomic_begin(struct exynos_drm_crtc *crtc) static void fimd_atomic_flush(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); int i; if (ctx->suspended) @@ -789,7 +791,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc, { struct exynos_drm_plane_state *state = to_exynos_plane_state(plane->base.state); - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); struct drm_framebuffer *fb = state->base.fb; dma_addr_t dma_addr; unsigned long val, size, offset; @@ -878,7 +880,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc, static void fimd_enable(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); if (!ctx->suspended) return; @@ -889,14 +891,14 @@ static void fimd_enable(struct exynos_drm_crtc *crtc) /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) - fimd_enable_vblank(ctx->crtc); + fimd_enable_vblank(&ctx->crtc); - fimd_commit(ctx->crtc); + fimd_commit(&ctx->crtc); } static void fimd_disable(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); int i; if (ctx->suspended) @@ -951,7 +953,7 @@ static void fimd_trigger(struct device *dev) static void fimd_te_handler(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = crtc->ctx; + struct fimd_context *ctx = to_fimd(crtc); u32 trg_type = ctx->driver_data->trg_type; /* Checks the crtc is detached already from encoder */ @@ -976,7 +978,7 @@ static void fimd_te_handler(struct exynos_drm_crtc *crtc) } if (test_bit(0, &ctx->irq_flags)) - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); } static void fimd_dp_clock_enable(struct exynos_drm_clk *clk, bool enable) @@ -1015,7 +1017,7 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id) goto out; if (!ctx->i80_if) - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); if (ctx->i80_if) { /* Exits triggering mode */ @@ -1036,7 +1038,6 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) { struct fimd_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct exynos_drm_plane *exynos_plane; unsigned int i; int ret; @@ -1053,22 +1054,23 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) return ret; } - exynos_plane = &ctx->planes[DEFAULT_WIN]; - ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, - EXYNOS_DISPLAY_TYPE_LCD, &fimd_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) - return PTR_ERR(ctx->crtc); + ctx->crtc.type = EXYNOS_DISPLAY_TYPE_LCD; + ctx->crtc.ops = &fimd_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) + return ret; + ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base; if (ctx->driver_data->has_dp_clk) { ctx->dp_clk.enable = fimd_dp_clock_enable; - ctx->crtc->pipe_clk = &ctx->dp_clk; + ctx->crtc.pipe_clk = &ctx->dp_clk; } if (ctx->encoder) exynos_dpi_bind(drm_dev, ctx->encoder); if (is_drm_iommu_supported(drm_dev)) - fimd_clear_channels(ctx->crtc); + fimd_clear_channels(&ctx->crtc); return exynos_drm_register_dma(drm_dev, dev); } @@ -1078,7 +1080,7 @@ static void fimd_unbind(struct device *dev, struct device *master, { struct fimd_context *ctx = dev_get_drvdata(dev); - fimd_disable(ctx->crtc); + fimd_disable(&ctx->crtc); exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);