From patchwork Wed Mar 20 13:06:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861567 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 5963115AC for ; Wed, 20 Mar 2019 13:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34C7329858 for ; Wed, 20 Mar 2019 13:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32A5329BEB; Wed, 20 Mar 2019 13:07:19 +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 8D75D29858 for ; Wed, 20 Mar 2019 13:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727172AbfCTNHS (ORCPT ); Wed, 20 Mar 2019 09:07:18 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55158 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727359AbfCTNHR (ORCPT ); Wed, 20 Mar 2019 09:07:17 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130715euoutp015a1ad0b72396be23f9540134f3fd9c5f~NrJzGNRcj0192201922euoutp01e; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190320130715euoutp015a1ad0b72396be23f9540134f3fd9c5f~NrJzGNRcj0192201922euoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087235; bh=HLWtj5gpnxYOt1cQ0328ti+3eXRQqGE+sXdo+C8YpoQ=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=RXyNAqglBv7NRhvymLgtNhhtTxWfp9vE584q/tufc1zDB+mUdBagPKRztZj26KbLU sYD3EeSGjvMVgRSmSmnIlYcoxaf63WnIqn3rZ9P97Zn2l3owDYfcLbnjtxnVCmFk7D po0pMP0qRdZpZfUtR9/AQtHizigSnnMkETBAjCs0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130715eucas1p224b9cd46c91d1175a1b01c49ff497921~NrJytGNRw1038210382eucas1p2z; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E9.92.04806.30B329C5; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190320130714eucas1p1d3ab6fceec849f22bab69df1e46b972d~NrJyLi-6A2303723037eucas1p19; Wed, 20 Mar 2019 13:07:14 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-22-5c923b03cea3 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 98.DA.04128.20B329C5; Wed, 20 Mar 2019 13:07:14 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0POO004P71RZN460@eusync1.samsung.com>; Wed, 20 Mar 2019 13:07:14 +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 v2 RESEND 07/24] drm/exynos/fimd: embed exynos_drm_crtc directly into context Date: Wed, 20 Mar 2019 14:06:50 +0100 Message-id: <20190320130707.25161-8-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20190320130707.25161-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsWy7djPc7rM1pNiDB5s4LW4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZj+beZSv4ZF0xZd5l5gbGM4ZdjJwcEgImEt8XnmXvYuTiEBJYwSjx8PQJ JgjnM6PEsXfNbDBV374+ZYNILGOUuHb3OpTzn1Fi+drZTCBVbAKaEn833wTrEBFQlli1rx1s LrPAb0aJ6cu3sYMkhAXiJXYuucwMYrMIqErcnLyMtYuRg4NXwELi3qNUiG3yEqs3HAAr4RSw lHg45z/YHAmBv6wSq1q6GSGKXCROL7vADmHLSFye3M0CYddL3F/RwgzR0MEosXXDTmaIhLXE 4eMXWUFsZgE+iUnbpjODLJYQ4JXoaBOCKPGQuLXsLdT/PYwSi47+ZJnAKLGAkWEVo3hqaXFu emqxcV5quV5xYm5xaV66XnJ+7iZGYISd/nf86w7GfX+SDjEKcDAq8fBeeD4hRog1say4MvcQ owQHs5IIb4TSpBgh3pTEyqrUovz4otKc1OJDjNIcLErivNUMD6KFBNITS1KzU1MLUotgskwc nFINjPcmSwiu45x//I9o1u2ZLbsbdn6aEqeWJRmlZHHlstEXGc0PoiqKcVJZ6XNbClUjL6X9 9s9dzeJlmz1la0rPp/ktQvVlXRynW6feW3mfPfWrWNutaZ8jZ6WyOdzXWvElcOXLwuJ7rVdc BAtPGpze2vfYSej8NnYVow1Ja5ZfYu2ZLdMaafZ2rRJLcUaioRZzUXEiAN7S3S2sAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42I5/e/4ZV0m60kxBms26lvcWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MR3PvshV8sq6YMu8ycwPjGcMuRk4OCQETiW9fn7J1MXJxCAksYZToefgQ ymlkkuhZcZ8dpIpNQFPi7+abbCC2iICyxKp97ewgRcwCvxklPs/4ygySEBaIl9i55DKYzSKg KnFz8jLWLkYODl4BC4l7j1IhtslLrN5wAKyEU8BS4uGc/2DzhYBKFp+4yziBkWcBI8MqRpHU 0uLc9NxiI73ixNzi0rx0veT83E2MwJDZduznlh2MXe+CDzEKcDAq8fBWPJ0QI8SaWFZcmXuI UYKDWUmEN0JpUowQb0piZVVqUX58UWlOavEhRmkOFiVx3vMGlVFCAumJJanZqakFqUUwWSYO TqkGxhw+ZamEZY4uLG6JyTfm/5vpwHr82dPw57sSNn3qmHtcdO11zqj9OicC93wVeKFxqT5n x2pZS56FeX/OJ6SsX25oW/Sa95B9kuN+TiX3L9rRml9f2p2484x/k7Xi106d//4iYcpWLULv eEI2h0xi3WFdI28t+MDFZuHKHbsOXOmMMRbKDXtgpcRSnJFoqMVcVJwIAGOTfpEVAgAA X-CMS-MailID: 20190320130714eucas1p1d3ab6fceec849f22bab69df1e46b972d CMS-TYPE: 201P X-CMS-RootMailID: 20190320130714eucas1p1d3ab6fceec849f22bab69df1e46b972d References: <20190320130707.25161-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);