From patchwork Fri Mar 1 12:20:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10835069 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 2FE9018EC for ; Fri, 1 Mar 2019 12:21:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F6FC2097A for ; Fri, 1 Mar 2019 12:21:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13FE12D931; Fri, 1 Mar 2019 12:21:12 +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 507482D964 for ; Fri, 1 Mar 2019 12:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbfCAMVK (ORCPT ); Fri, 1 Mar 2019 07:21:10 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:36640 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387704AbfCAMVK (ORCPT ); Fri, 1 Mar 2019 07:21:10 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190301122109euoutp0118dbe97f55174d14e89ca582b3bd4fe1~H1RHq_lIp1404314043euoutp01t; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190301122109euoutp0118dbe97f55174d14e89ca582b3bd4fe1~H1RHq_lIp1404314043euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1551442869; bh=uZvrClUPHfriRADK0ELl4qfX0XMk6sY0DwYeawi6/rs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=fO2cKl26uc1OI+K8MX9pkI7zGstsFy0fCJDiMttt307dy4tjj19fZBg9frrVdbjzo VvSN/bALWc3RKskYgwFd3xju7OgLNQ9POPmAjOt3+i7lSdAYvk935mmR6XLdAwEQ/n IqXTqduybiJ8ODL0/idDfIJHvJLD2DpHTLg7pODs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190301122108eucas1p1f0cc09d67e36b17ddc700f539c0ec437~H1RHBmf8t2751727517eucas1p1p; Fri, 1 Mar 2019 12:21:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id D1.5E.04441.4B3297C5; Fri, 1 Mar 2019 12:21:08 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122108eucas1p2b52e33f1799eefb8ac68d7c4063bb2b9~H1RGc4fHR1653116531eucas1p2k; Fri, 1 Mar 2019 12:21:08 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-56-5c7923b4f5c5 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A5.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 06/23] drm/exynos/decon7: embed exynos_drm_crtc directly into context Date: Fri, 01 Mar 2019 13:20:38 +0100 Message-id: <20190301122055.7135-7-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+NgFprAIsWRmVeSWpSXmKPExsWy7djPc7pblCtjDBavUre4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ymg5e5GtYI5pxZcnz9gbGH9odzFyckgImEjMuf6VsYuRi0NIYAWjxM+FM6Gcz4wSjRt2M8FU vb/+lg0isYxR4vK//cwQzn9GiXtt/1lBqtgENCX+br7JBmKLCChLrNrXzg5SxCxwiVHi9clu RpCEsEC4xJI/u9lBbBYBVYm1238wg9i8AuYSq78fY4VYJy+xesMBsDingIXEwZUQgyQE3rJK PPrymRGiyEXixbsPbBC2jERnx0GoW+slmmZeYYZo6GCUOLF4OVSRtcTh4xfBNjAL8ElM2jYd qIgDKM4r0dEmBFHiIdG3dQUrxGvdjBKf/hxmn8AosYCRYRWjeGppcW56arFhXmq5XnFibnFp Xrpecn7uJkZgPJ3+d/zTDsavl5IOMQpwMCrx8Ca8LI8RYk0sK67MPcQowcGsJMLLx1AZI8Sb klhZlVqUH19UmpNafIhRmoNFSZy3muFBtJBAemJJanZqakFqEUyWiYNTqoGxTG/zlov9mZM2 1i789L/s+1PThIfXRGzeJu8VXi7YyNvRdezzr9s7YhpNhXilBfedaeMsNIlfKiKt9yqqd+fD r4Ic7afdDn+az/1aZoETT9Qpi39Mmc46YmoTb3ApXuoRKvukrMB4WLm2ZO+HWQ62E1ZnnLLR +n/uOH9G89KTfOf79i8UtXVTYinOSDTUYi4qTgQAWt5OG6MCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xq7pblCtjDM4c5rO4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ymg5e5GtYI5pxZcnz9gbGH9odzFyckgImEi8v/6WrYuRi0NIYAmjxKYHz9khnEYmiVtTLrGC VLEJaEr83XyTDcQWEVCWWLWvHayIWeAKo0T7ty52kISwQLjE7MZFYA0sAqoSa7f/YAaxeQXM JVZ/P8YKsU5eYvWGA2BxTgELiYMrQQZxAG0zl9h0OmoCI88CRoZVjCKppcW56bnFhnrFibnF pXnpesn5uZsYgeGx7djPzTsYL20MPsQowMGoxMOb8LI8Rog1say4MvcQowQHs5IILx9DZYwQ b0piZVVqUX58UWlOavEhRmkOFiVx3vMGlVFCAumJJanZqakFqUUwWSYOTqkGRtsvMxkZXl3d +9mzTcCn/2jvW5bTE43j2wQ4imN6W7Z5H7I1LIt7+VirbnZJvr+L5X2xbQXKWvXLNx5Qa/lk FqJxe7cg45QyKYa/lo8qz6zPjs2sWjfl6dcjERevTy2X5K4S3dzxak7E0nOPXjTO2z9f7FGS 7nrPhTO+sgd3VkX0rPJ7/1WgQomlOCPRUIu5qDgRAALGdMILAgAA X-CMS-MailID: 20190301122108eucas1p2b52e33f1799eefb8ac68d7c4063bb2b9 CMS-TYPE: 201P X-CMS-RootMailID: 20190301122108eucas1p2b52e33f1799eefb8ac68d7c4063bb2b9 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/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);