From patchwork Wed Mar 20 13:06:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861559 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 8AEB517EF for ; Wed, 20 Mar 2019 13:07:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7106E28BF1 for ; Wed, 20 Mar 2019 13:07:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E4E629BE1; Wed, 20 Mar 2019 13:07:18 +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 D77F528BF1 for ; Wed, 20 Mar 2019 13:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbfCTNHR (ORCPT ); Wed, 20 Mar 2019 09:07:17 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:58196 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbfCTNHR (ORCPT ); Wed, 20 Mar 2019 09:07:17 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130715euoutp0295dfc442b5b36604f1f6d2106e26abbd~NrJyv44wk1589215892euoutp02j; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190320130715euoutp0295dfc442b5b36604f1f6d2106e26abbd~NrJyv44wk1589215892euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087235; bh=uZvrClUPHfriRADK0ELl4qfX0XMk6sY0DwYeawi6/rs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=lvwIMTCWhfwWU+a8ICQL902fA8rwGRabJD7GHiFomt+AhJ+dgDdUieLzjmtUh0CJW zWVYxMCNpixiRiDMip73u8vjUJcGCiL0wDkdBpRCNRAJGB43E9Dz+dVg6sKQkR6uy5 Q8kGxLdJ7zTDH7nhF64eGdF8CNg0KB1W7bThH5+I= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190320130715eucas1p1a36d4449ac57191e764fe9eb3e556462~NrJyXwx2x2311723117eucas1p1x; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 19.92.04806.20B329C5; Wed, 20 Mar 2019 13:07:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130714eucas1p2e4f96fe67486283560c7b6a8627b769c~NrJxy-h7C1665716657eucas1p2L; Wed, 20 Mar 2019 13:07:14 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-20-5c923b0243b3 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 93.AF.04284.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 06/24] drm/exynos/decon7: embed exynos_drm_crtc directly into context Date: Wed, 20 Mar 2019 14:06:49 +0100 Message-id: <20190320130707.25161-7-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+NgFprJIsWRmVeSWpSXmKPExsWy7djP87pM1pNiDD4+M7W4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZLWcvshXMMa348uQZewPjD+0uRk4OCQETia0fbzN1MXJxCAmsYJS4enka G4TzmVFiy7a57DBV+3r/s0AkljFK3Nx6jh3C+c8osXztbCaQKjYBTYm/m2+ygdgiAsoSq/a1 gxUxC/xmlJi+fBvYKGGBRIml0xeC2SwCqhIL3v4Bsjk4eAUsJP5/SYfYJi+xesMBZhCbU8BS 4uGc/2BzJAT+sko8PnObGaLIRWLeq+uMELaMRGfHQSYIu17i/ooWZoiGDkaJrRt2QjVYSxw+ fpEVxGYW4JOYtG06M8hiCQFeiY42IYgSD4lLi/YwQ3zWwyhx4vBclgmMEgsYGVYxiqeWFuem pxYb56WW6xUn5haX5qXrJefnbmIERtjpf8e/7mDc9yfpEKMAB6MSD++F5xNihFgTy4orcw8x SnAwK4nwRihNihHiTUmsrEotyo8vKs1JLT7EKM3BoiTOW83wIFpIID2xJDU7NbUgtQgmy8TB KdXAqMnRlZp19Pppyed2/2fZs4bK5T9db3Nke2dL24nbz4Oj6ud95Tvb5yCW3fpVj1OM+8KC F1viux/sjUgPqGXrWqwvof/8d7Aww14r0yczORQKf11YPEtmv5RcuFt57euNLt3F79V0dVrv Giw9k+G54kXnwa55VnYn3nFZFN4MFTb1XBLa8Oy7EktxRqKhFnNRcSIAoZEe46wCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkluLIzCtJLcpLzFFi42I5/e/4ZV0m60kxBvuXiVncWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MlrMX2QrmmFZ8efKMvYHxh3YXIyeHhICJxL7e/ywgtpDAEkaJ811RXYxc QHYjk0TPivvsIAk2AU2Jv5tvsoHYIgLKEqv2tbODFDEL/GaU+DzjKzNIQlggUWLp9IVgDSwC qhIL3v4Bsjk4eAUsJP5/SYdYJi+xesMBsHJOAUuJh3P+s0MstpBYfOIu4wRGngWMDKsYRVJL i3PTc4sN9YoTc4tL89L1kvNzNzECA2bbsZ+bdzBe2hh8iFGAg1GJh7fi6YQYIdbEsuLK3EOM EhzMSiK8EUqTYoR4UxIrq1KL8uOLSnNSiw8xSnOwKInznjeojBISSE8sSc1OTS1ILYLJMnFw SjUwVmpIPPi44abLkY2tM+669B2Z33/h08T48t7sgs9Rx+fP+j7RtspFMYL76M2Od7ENjZOO WX2Z/tG/9ZDQZyaJrV1sYj5vbX6erJ7jcryMn3fB1mf+JU3Sh5ueamh9rFS4d6Lnle3nw17J s9eI71jhGtd0zb7ut9/TSxnBL3yUFYo8rv7zXxiZocRSnJFoqMVcVJwIAMfEbN0UAgAA X-CMS-MailID: 20190320130714eucas1p2e4f96fe67486283560c7b6a8627b769c CMS-TYPE: 201P X-CMS-RootMailID: 20190320130714eucas1p2e4f96fe67486283560c7b6a8627b769c 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/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);