From patchwork Mon Mar 25 07:13:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10868023 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 CD06417EE for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B26E22924C for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4C4F29254; Mon, 25 Mar 2019 07:14:00 +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 0E7752924C for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729794AbfCYHN7 (ORCPT ); Mon, 25 Mar 2019 03:13:59 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:59663 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729761AbfCYHN7 (ORCPT ); Mon, 25 Mar 2019 03:13:59 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190325071357euoutp029465c3f1b9ea1bbe3dc6a0dd889aadad~PIjwGtIRT0730507305euoutp02G; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190325071357euoutp029465c3f1b9ea1bbe3dc6a0dd889aadad~PIjwGtIRT0730507305euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553498037; bh=uZvrClUPHfriRADK0ELl4qfX0XMk6sY0DwYeawi6/rs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=X3yUvG8IP87B2HN8J5nuvDK0JSWZnc0wl3VaIRR6K/Gf/xq12eIDf33+6/0TRcC1R M2vU7yVG1j1osCdTCqqo0wOSZxVc6fV3JpuW3gTi6Bye9FXWgQoazDvzDSTZbiYQ9t nAfD4+rmyw1ZUKuVJAz5TXO/BguO9Um4N4343Oik= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071357eucas1p1c494c53e9048062f3ee4edeb639a2f4b~PIjvsoAdE1834618346eucas1p1b; 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 9F.5E.04298.4BF789C5; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071356eucas1p17598af50b99cecd3f04bd5bd7b665468~PIjvGkPVN0855608556eucas1p1u; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) X-AuditID: cbfec7f2-f2dff700000010ca-b6-5c987fb407a3 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0C.19.04140.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 08/24] drm/exynos/decon7: embed exynos_drm_crtc directly into context Date: Mon, 25 Mar 2019 08:13:33 +0100 Message-id: <20190325071349.22600-9-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+NgFprKIsWRmVeSWpSXmKPExsWy7djP87pb6mfEGMydZ2Nxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyWs5eZCuYY1rx5ckz9gbGH9pdjBwcEgImEnPuR3UxcnEICaxglJh4+zIz hPOZUWL2m15WmKLbK1Ug4ssYJS7du8IE4fxnlJjStQ7I4eRgE9CU+Lv5JhuILSKgLLFqXzs7 SBGzwG9GienLt7GDTBIWSJToPqMEYrIIqEo03uIBKecVsJD4vvQBM4gtISAvsXrDATCbU8BS 4v/pS2AHSQj8ZZWYdewDI0SRi8S9lVtZIWwZicuTu1kg7HqJ+ytaoBo6GCW2btgJNdVa4vDx i2ANzAJ8EpO2TWeG+IxXoqNNCKLEQ2LPg3lgvwgJ9ACDojtqAqPEAkaGVYziqaXFuempxYZ5 qeV6xYm5xaV56XrJ+bmbGIGRdfrf8U87GL9eSjrEKMDBqMTD+2Ln9Bgh1sSy4srcQ4wSHMxK IrxPRGfECPGmJFZWpRblxxeV5qQWH2KU5mBREuetZngQLSSQnliSmp2aWpBaBJNl4uCUamCM U14lb/9O/7HAlg/zJOrKFPVDDu3WOBjlnsW9Je+Z8AydkgW1f3alNrvIK6cKvVOsnprTomlS u+qcn3xy+Y+baY3Xji/bPGPWXQ8fVf1zrSq2Ew69td0SVSiikqH48PHU7ZvyVH4t2xZ38Otb ZpvXdifb1zX+2+491ynCa5O8zKXXM9U3G7grsRRnJBpqMRcVJwIARxwwM6gCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPJMWRmVeSWpSXmKPExsVy+t/xq7pb6mfEGFw7qWRxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyWs5eZCuYY1rx5ckz9gbGH9pdjBwcEgImErdXqnQxcnIICSxhlJg3KbSL kQvIbmSSOHX9JTNIgk1AU+Lv5ptsILaIgLLEqn3t7CBFzAK/GSU+z/jKDDJIWCBRovuMEojJ IqAq0XiLB6ScV8BC4vvSB2BjJATkJVZvOABmcwpYSvw/fYkZYq+FxN5ljewTGHkWMDKsYhRJ LS3OTc8tNtIrTswtLs1L10vOz93ECAyWbcd+btnB2PUu+BCjAAejEg+vw57pMUKsiWXFlbmH GCU4mJVEeJ+IzogR4k1JrKxKLcqPLyrNSS0+xCjNwaIkznveoDJKSCA9sSQ1OzW1ILUIJsvE wSnVwLj5L1P+W7bLSUtWHHxdIiHwOmZ10087/9OrHtYp8v6656re0Cik4lgt4u2/22TFHKnO bTxv1PW4bmpN3FTrd1Ikyalk79ypyToLZq6LzPd742L25HlAptf86rb6hVMTNSabNl5Lv268 PVx6Qx7LTKX2IxIpG9Z/T9v8L6dnZVLtKXFV9lw9byWW4oxEQy3mouJEAKd1Zs8SAgAA X-CMS-MailID: 20190325071356eucas1p17598af50b99cecd3f04bd5bd7b665468 CMS-TYPE: 201P X-CMS-RootMailID: 20190325071356eucas1p17598af50b99cecd3f04bd5bd7b665468 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/exynos7_drm_decon.c | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 6d462f057531..22659f2da755 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -42,7 +42,7 @@ struct decon_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 *pclk; struct clk *aclk; @@ -58,6 +58,8 @@ struct decon_context { struct drm_encoder *encoder; }; +#define to_decon(ptr) container_of(ptr, struct decon_context, ptr) + static const struct of_device_id decon_driver_dt_match[] = { {.compatible = "samsung,exynos7-decon"}, {}, @@ -83,7 +85,7 @@ static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); if (ctx->suspended) return; @@ -102,7 +104,7 @@ static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc) static void decon_clear_channels(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); unsigned int win, ch_enabled = 0; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -120,7 +122,7 @@ static void decon_clear_channels(struct exynos_drm_crtc *crtc) /* Wait for vsync, as disable channel takes effect at next vsync */ if (ch_enabled) - decon_wait_for_vblank(ctx->crtc); + decon_wait_for_vblank(&ctx->crtc); } static int decon_ctx_initialize(struct decon_context *ctx, @@ -128,7 +130,7 @@ static int decon_ctx_initialize(struct decon_context *ctx, { ctx->drm_dev = drm_dev; - decon_clear_channels(ctx->crtc); + decon_clear_channels(&ctx->crtc); return exynos_drm_register_dma(drm_dev, ctx->dev); } @@ -153,7 +155,7 @@ static u32 decon_calc_clkdiv(struct decon_context *ctx, static void decon_commit(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); struct drm_display_mode *mode = &crtc->base.state->adjusted_mode; u32 val, clkdiv; @@ -218,7 +220,7 @@ static void decon_commit(struct exynos_drm_crtc *crtc) static int decon_enable_vblank(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); u32 val; if (ctx->suspended) @@ -243,7 +245,7 @@ static int decon_enable_vblank(struct exynos_drm_crtc *crtc) static void decon_disable_vblank(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); u32 val; if (ctx->suspended) @@ -368,7 +370,7 @@ static void decon_shadow_protect_win(struct decon_context *ctx, static void decon_atomic_begin(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); int i; if (ctx->suspended) @@ -383,7 +385,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, { struct exynos_drm_plane_state *state = to_exynos_plane_state(plane->base.state); - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); struct drm_framebuffer *fb = state->base.fb; int padding; unsigned long val, alpha; @@ -479,7 +481,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, static void decon_disable_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); unsigned int win = plane->index; u32 val; @@ -501,7 +503,7 @@ static void decon_disable_plane(struct exynos_drm_crtc *crtc, static void decon_atomic_flush(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); int i; if (ctx->suspended) @@ -531,7 +533,7 @@ static void decon_init(struct decon_context *ctx) static void decon_enable(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); if (!ctx->suspended) return; @@ -542,16 +544,16 @@ static void decon_enable(struct exynos_drm_crtc *crtc) /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) - decon_enable_vblank(ctx->crtc); + decon_enable_vblank(&ctx->crtc); - decon_commit(ctx->crtc); + decon_commit(&ctx->crtc); ctx->suspended = false; } static void decon_disable(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); int i; if (ctx->suspended) @@ -598,7 +600,7 @@ static irqreturn_t decon_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); /* set wait vsync event to zero and wake up queue. */ if (atomic_read(&ctx->wait_vsync_event)) { @@ -614,7 +616,6 @@ static int decon_bind(struct device *dev, struct device *master, void *data) { struct decon_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct exynos_drm_plane *exynos_plane; unsigned int i; int ret; @@ -632,13 +633,14 @@ static int decon_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, &decon_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) { + ctx->crtc.type = EXYNOS_DISPLAY_TYPE_LCD; + ctx->crtc.ops = &decon_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) { decon_ctx_remove(ctx); - return PTR_ERR(ctx->crtc); + return ret; } + ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base; if (ctx->encoder) exynos_dpi_bind(drm_dev, ctx->encoder); @@ -652,7 +654,7 @@ static void decon_unbind(struct device *dev, struct device *master, { struct decon_context *ctx = dev_get_drvdata(dev); - decon_disable(ctx->crtc); + decon_disable(&ctx->crtc); if (ctx->encoder) exynos_dpi_remove(ctx->encoder);