From patchwork Mon Mar 25 07:13:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10868029 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 CD24318E8 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 B5A892924B for ; Mon, 25 Mar 2019 07:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA3222924E; 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 5C4682924B for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729761AbfCYHN7 (ORCPT ); Mon, 25 Mar 2019 03:13:59 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:41924 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729786AbfCYHN7 (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 20190325071357euoutp0142fe182c0422444885267a03c813c0a7~PIjwQMp8o0752607526euoutp01M; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190325071357euoutp0142fe182c0422444885267a03c813c0a7~PIjwQMp8o0752607526euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553498037; bh=4GagIZ6u+HzP7LKOOqaJeqOA7ziodwQif9IXyvp30QE=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=fNjcfagug1zTmr8Cvm8fyjTRZD1ZdEtAFImy1CQUbT1EITOV/fswQ2OltnRTRNifC 5md1swHnvIu+WYThIud9RhXKkGbCY7Domd5+qOCFFcEH1jhoGqKaGoknaOA/1hHFAj RtIoYKDlTMqqWSmdz1Gur3cKADrhVXe5i9ts1O4M= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190325071357eucas1p2ee8099b17a7796c978c1a6b4a61dd085~PIjve6mRm3045430454eucas1p20; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 29.4E.04325.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 20190325071356eucas1p111ff1323f9ef55582b6983ce91a0e58a~PIjuuvOkY2091320913eucas1p1L; Mon, 25 Mar 2019 07:13:56 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-92-5c987fb4be48 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6B.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 07/24] drm/exynos/decon5433: embed exynos_drm_crtc directly into context Date: Mon, 25 Mar 2019 08:13:32 +0100 Message-id: <20190325071349.22600-8-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+NgFprJIsWRmVeSWpSXmKPExsWy7djP87pb6mfEGGxfpGdxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyPv98xF7wzqxiyszvzA2Mu3W7GDk5JARMJA5PesbcxcjFISSwglGi5+91 VgjnM6NE77N2Jpiq7QvXM0EkljFK9P86ygjh/GeUmNK1DqyKTUBT4u/mm2wgtoiAssSqfe3s IEXMAr8ZJaYv38YOkhAWSJH4+noaK4jNIqAqcejiOjCbV8BCouvGWXaIdfISqzccYAaxOQUs Jf6fvgR2oITAX1aJ28cOQN3kIvH4yVeoBhmJy5O7WSDseon7K1qgGjoYJbZu2MkMkbCWOHz8 Itg2ZgE+iUnbpgPFOYDivBIdbUIQJR4S3XNPg80UEuhhlNg1K2sCo8QCRoZVjOKppcW56anF xnmp5XrFibnFpXnpesn5uZsYgRF2+t/xrzsY9/1JOsQowMGoxMP7Yuf0GCHWxLLiytxDjBIc zEoivE9EZ8QI8aYkVlalFuXHF5XmpBYfYpTmYFES561meBAtJJCeWJKanZpakFoEk2Xi4JRq YLRa88R2bbI6q4bY6mtrnb2e6l6Q3b5f6F5EZ9eirLfVU1ySX/YFvY47Kd6ZNtfstsiPCI9T waL+f3/rsv16N2N/z0yBt7b3cpblv/hzuOtX8zRrN8t3l7Wu80xRTtvtkr3zWcylTaqz8tyE 10mJFYoU3mt40/bubAtXz8Qraf+3zJ4nUaTQn6zEUpyRaKjFXFScCABqv1DHrAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4Vd0t9TNiDBb0cFncWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6Mzz8fsRe8M6uYMvM7cwPjbt0uRk4OCQETie0L1zN1MXJxCAksYZRYureH EcJpZJI4df0lM0gVm4CmxN/NN9lAbBEBZYlV+9rZQYqYBX4zSnye8RWsSFggReLr62msIDaL gKrEoYvrwGxeAQuJrhtn2SHWyUus3nAArJ5TwFLi/+lLYLYQUM3eZY3sExh5FjAyrGIUSS0t zk3PLTbSK07MLS7NS9dLzs/dxAgMmm3Hfm7Zwdj1LvgQowAHoxIPr8Oe6TFCrIllxZW5hxgl OJiVRHifiM6IEeJNSaysSi3Kjy8qzUktPsQozcGiJM573qAySkggPbEkNTs1tSC1CCbLxMEp 1cAYorpqY8cJw9T7234cnebN31lWqSKaUm/XLnkjufKIbczqearMnf+bva79XlYx+VPcBRcb HmYV5dxnHiy99yQV3L1kTqm+cTCusvfYGfr28hQFveTCt4dMC3hLefLPd+k4Ly15HzpvRvIR fjsx/8SJmjXllS/fNaw7YLNlwUdZyVDeCRtNbimxFGckGmoxFxUnAgBkeI4GFgIAAA== X-CMS-MailID: 20190325071356eucas1p111ff1323f9ef55582b6983ce91a0e58a CMS-TYPE: 201P X-CMS-RootMailID: 20190325071356eucas1p111ff1323f9ef55582b6983ce91a0e58a 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/exynos5433_drm_decon.c | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index ae0f475eb633..0d409f453923 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -54,7 +54,7 @@ static const char * const decon_clks_name[] = { 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]; void __iomem *addr; struct regmap *sysreg; @@ -69,6 +69,8 @@ struct decon_context { u32 frame_id; }; +#define to_decon(ptr) container_of(ptr, struct decon_context, ptr) + static const uint32_t decon_formats[] = { DRM_FORMAT_XRGB1555, DRM_FORMAT_RGB565, @@ -90,7 +92,7 @@ static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask, 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; val = VIDINTCON0_INTEN; @@ -110,7 +112,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); if (!(ctx->out_type & I80_HW_TRG)) disable_irq_nosync(ctx->te_irq); @@ -143,7 +145,7 @@ static u32 decon_get_frame_count(struct decon_context *ctx, bool end) switch (status & (VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE)) { case VIDCON1_VSTATUS_VS: - if (!(ctx->crtc->i80_mode)) + if (!(ctx->crtc.i80_mode)) --frm; break; case VIDCON1_VSTATUS_BP: @@ -163,7 +165,7 @@ static u32 decon_get_frame_count(struct decon_context *ctx, bool end) static void decon_setup_trigger(struct decon_context *ctx) { - if (!ctx->crtc->i80_mode && !(ctx->out_type & I80_HW_TRG)) + if (!ctx->crtc.i80_mode && !(ctx->out_type & I80_HW_TRG)) return; if (!(ctx->out_type & I80_HW_TRG)) { @@ -183,7 +185,7 @@ static void decon_setup_trigger(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 *m = &crtc->base.mode; bool interlaced = false; u32 val; @@ -377,7 +379,7 @@ static void decon_shadow_protect(struct decon_context *ctx, bool protect) static void decon_atomic_begin(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); decon_shadow_protect(ctx, true); } @@ -391,7 +393,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; unsigned int win = state->base.normalized_zpos + ctx->first_win; unsigned int cpp = fb->format->cpp[0]; @@ -445,7 +447,7 @@ static void decon_update_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); unsigned long flags; int win = hweight32(crtc->base.state->plane_mask) + ctx->first_win; @@ -502,7 +504,7 @@ static void decon_swreset(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); pm_runtime_get_sync(ctx->dev); @@ -510,12 +512,12 @@ static void decon_enable(struct exynos_drm_crtc *crtc) decon_swreset(ctx); - decon_commit(ctx->crtc); + decon_commit(&ctx->crtc); } 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->out_type & I80_HW_TRG)) @@ -548,7 +550,7 @@ static irqreturn_t decon_te_irq_handler(int irq, void *dev_id) static void decon_clear_channels(struct exynos_drm_crtc *crtc) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); int win, i, ret; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -577,7 +579,7 @@ static void decon_clear_channels(struct exynos_drm_crtc *crtc) static enum drm_mode_status decon_mode_valid(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode) { - struct decon_context *ctx = crtc->ctx; + struct decon_context *ctx = to_decon(crtc); ctx->irq = crtc->i80_mode ? ctx->irq_lcd_sys : ctx->irq_vsync; @@ -605,8 +607,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; - enum exynos_drm_output_type out_type; unsigned int i; int ret; @@ -624,15 +624,15 @@ static int decon_bind(struct device *dev, struct device *master, void *data) return ret; } - exynos_plane = &ctx->planes[PRIMARY_WIN]; - out_type = (ctx->out_type & IFTYPE_HDMI) ? EXYNOS_DISPLAY_TYPE_HDMI - : EXYNOS_DISPLAY_TYPE_LCD; - ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, - out_type, &decon_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) - return PTR_ERR(ctx->crtc); + ctx->crtc.type = (ctx->out_type & IFTYPE_HDMI) + ? EXYNOS_DISPLAY_TYPE_HDMI : EXYNOS_DISPLAY_TYPE_LCD; + ctx->crtc.ops = &decon_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) + return ret; + ctx->crtc.base.primary = &ctx->planes[PRIMARY_WIN].base; - decon_clear_channels(ctx->crtc); + decon_clear_channels(&ctx->crtc); return exynos_drm_register_dma(drm_dev, dev); } @@ -641,7 +641,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data) { struct decon_context *ctx = dev_get_drvdata(dev); - decon_disable(ctx->crtc); + decon_disable(&ctx->crtc); /* detach this sub driver from iommu mapping if supported. */ exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev); @@ -663,7 +663,7 @@ static void decon_handle_vblank(struct decon_context *ctx) if (frm != ctx->frame_id) { /* handle only if incremented, take care of wrap-around */ if ((s32)(frm - ctx->frame_id) > 0) - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); ctx->frame_id = frm; }