From patchwork Fri Mar 1 12:20:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10835075 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 37B8217E9 for ; Fri, 1 Mar 2019 12:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261DA2097A for ; Fri, 1 Mar 2019 12:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A4BB2D900; Fri, 1 Mar 2019 12:21:13 +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 78CD42D931 for ; Fri, 1 Mar 2019 12:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388052AbfCAMVM (ORCPT ); Fri, 1 Mar 2019 07:21:12 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39153 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387692AbfCAMVL (ORCPT ); Fri, 1 Mar 2019 07:21:11 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190301122109euoutp02e900fddab2f20a33f69dce7c9d23c7d6~H1RH7zVmY2156121561euoutp02v; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190301122109euoutp02e900fddab2f20a33f69dce7c9d23c7d6~H1RH7zVmY2156121561euoutp02v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1551442869; bh=HLWtj5gpnxYOt1cQ0328ti+3eXRQqGE+sXdo+C8YpoQ=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=D6kyMJekvSJ23bb/leNzVW6/hn7tjjidkDgj6r3WHKKEi7XAMUeAXg/RAcmhC/5ol R//xoxfZCS40/1+0CFSXh42xC0+4OZpmEUpsBuazuuSew4lpbTBvnbyesu1SFIENmn 8Mo1kyt/O3PWs+fqv8SmfqX1nn2nwk2F7YeU3lmU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122109eucas1p25d8e6f31843f788a3dc6f84f26913676~H1RHfPsE72978429784eucas1p2o; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D0.5B.04806.5B3297C5; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122108eucas1p25f8fcb147e5dd0be0d877c55effa7e7e~H1RG0vEFg2069220692eucas1p24; Fri, 1 Mar 2019 12:21:08 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-80-5c7923b5fc31 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 16.23.04284.4B3297C5; Fri, 1 Mar 2019 12:21:08 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PNO007ENSZ56Z20@eusync3.samsung.com>; Fri, 01 Mar 2019 12:21:08 +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 Subject: [PATCH 07/23] drm/exynos/fimd: embed exynos_drm_crtc directly into context Date: Fri, 01 Mar 2019 13:20:39 +0100 Message-id: <20190301122055.7135-8-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20190301122055.7135-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42LZduzned2typUxBntfcVjcWneO1WLjjPWs Fle+vmezmHR/AovFjPP7mCzWHrnL7sDmcb/7OJNH35ZVjB6fN8kFMEdx2aSk5mSWpRbp2yVw ZTyae5et4JN1xZR5l5kbGM8YdjFyckgImEh8mTCJsYuRi0NIYAWjxL2Ve1kgnM+MEsdbLrHA VL05MJEJxBYSWMYosfKnA0TRf6COtv+sIAk2AU2Jv5tvsoHYIgLKEqv2tbODFDELXGKUeH2y mxEkISwQKvH2XjuYzSKgKtHXPR9sKq+AucTy/2uhtslLrN5wgBnE5hSwkDi4EmKQhMBXVokZ E45AFblIXPr6ggnClpHo7DgIZddLNM28wgzR0MEocWLxcjaIhLXE4eMXwU5lFuCTmLRtOlAR B1CcV6KjTQiixEPi7ryH7BCvdTNK7Hy7l2kCo8QCRoZVjOKppcW56anFxnmp5XrFibnFpXnp esn5uZsYgdF0+t/xrzsY9/1JOsQowMGoxMO743V5jBBrYllxZe4hRgkOZiURXj6Gyhgh3pTE yqrUovz4otKc1OJDjNIcLErivNUMD6KFBNITS1KzU1MLUotgskwcnFINjDzmrfGh665NcHte ZdT3b3ZSxIOFU4ujXC0Uvdv36Xi0P3xZblKtFX5MY4bamQeaW9lOJ0RtutP7mnXBb9ODLAHJ 79wfbmNQKiv/ueQX2wp//W1fvqXcbYoXunO75th2KYW4bY8OHY7o33UnoOY4z4Ptvw/rttXs +tRywjzqr9vWabPET9aE/1BiKc5INNRiLipOBABUU5LmogIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xq7pblCtjDM4eULG4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yng09y5bwSfriinzLjM3MJ4x7GLk5JAQMJF4c2AiUxcjF4eQwBJGiYOzrrBAOI1MEremXGIF qWIT0JT4u/kmG4gtIqAssWpfOztIEbPAFUaJ9m9d7CAJYYFQibf32hlBbBYBVYm+7vlMIDav gLnE8v9rWSDWyUus3nCAGcTmFLCQOLgSZBAH0DZziU2noyYw8ixgZFjFKJJaWpybnltsqFec mFtcmpeul5yfu4kRGB7bjv3cvIPx0sbgQ4wCHIxKPLwJL8tjhFgTy4orcw8xSnAwK4nw8jFU xgjxpiRWVqUW5ccXleakFh9ilOZgURLnPW9QGSUkkJ5YkpqdmlqQWgSTZeLglGpgLOzf9SXk wMaId9cjuUpXneY6/7GFY4f36TO3M7ssv+oE2HWeXNdwZnJNo0V+ZGStxJd50UKHviSd+ntY PzT1QIvov6emqq7fZiu8Njy+7mqP600eges3KqSktySsXpqSEPjpp1jfk2t6y12PrNu5hm3f zfeTni7bzhpW2l79S4Lr690/53b17FdiKc5INNRiLipOBAANxwUwCwIAAA== X-CMS-MailID: 20190301122108eucas1p25f8fcb147e5dd0be0d877c55effa7e7e CMS-TYPE: 201P X-CMS-RootMailID: 20190301122108eucas1p25f8fcb147e5dd0be0d877c55effa7e7e References: <20190301122055.7135-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);