From patchwork Wed Mar 20 13:06:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861563 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 DBF2B18EC 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 C1177299B6 for ; Wed, 20 Mar 2019 13:07:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B589229BD8; 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 2CDD129BE7 for ; Wed, 20 Mar 2019 13:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbfCTNHR (ORCPT ); Wed, 20 Mar 2019 09:07:17 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55162 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbfCTNHR (ORCPT ); Wed, 20 Mar 2019 09:07:17 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130716euoutp011d234c4aefe6ff2704d9f7e16af47f05~NrJzbkQXd0192801928euoutp01c; Wed, 20 Mar 2019 13:07:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190320130716euoutp011d234c4aefe6ff2704d9f7e16af47f05~NrJzbkQXd0192801928euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087236; bh=bQCAlj48koAMC69VP17ExVvUrMe7ZRRaujUvGSzX0JI=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=Iyj57Dncrkw4VksGJ42ozuXnwcqy8iEJXVVvPTlaDlllxSdni3EHFH710yDGrpflG 9y/MhmTwQUIKZOlS5NyBJ0L3us4QbgJndX17UND6wNrxr+M6nA9Y32HgzSxQLPg8KB GXKd+G1pZlrZeu04q5ffOvMlKOP0mjD4p/pke494= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130715eucas1p2e361abd74eb658b02c4b519deab9566e~NrJzFBmQJ1665816658eucas1p2R; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 69.35.04441.30B329C5; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130715eucas1p250b6b902360896cd36bff8536b6292bf~NrJyixDPu0312903129eucas1p2e; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-a6-5c923b03c9f2 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B4.AF.04284.30B329C5; Wed, 20 Mar 2019 13:07:15 +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:15 +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 08/24] drm/exynos/mixer: embed exynos_drm_crtc directly into context Date: Wed, 20 Mar 2019 14:06:51 +0100 Message-id: <20190320130707.25161-9-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+NgFprOIsWRmVeSWpSXmKPExsWy7djPc7rM1pNiDHrblC1urTvHarFxxnpW iytf37NZTLo/gcXi/PkN7BYzzu9jslh75C67A7vHplWdbB73u48zefRtWcXo8XmTXABLFJdN SmpOZllqkb5dAlfG5nttjAXN+hXdh7+yNTBOVe9i5OSQEDCRmH3gL1sXIxeHkMAKRonHv9+x gSSEBD4zSuxqd4Epur1yGiNE0TJGiYdX5zBDOP8ZJWb86ADrYBPQlPi7+SaYLSKgLLFqXzs7 SBGzwG9GienLt7GDJIQFEiT2LuxhAbFZBFQlrkxqZupi5ODgFbCQWPxIA2KbvMTqDQeYQWxO AUuJh3P+g82REGhkk/jT+JoRoshFovfLUTYIW0ais+MgE4RdL3F/RQszREMHo8TWDTuZIRLW EoePX2QFsZkF+CQmbZvODLJYQoBXoqNNCML0kFi6iBPisR5GiUdnu5gmMEosYGRYxSieWlqc m55abJiXWq5XnJhbXJqXrpecn7uJERhdp/8d/7SD8eulpEOMAhyMSjy8DW8mxAixJpYVV+Ye YpTgYFYS4Y1QmhQjxJuSWFmVWpQfX1Sak1p8iFGag0VJnLea4UG0kEB6YklqdmpqQWoRTJaJ g1OqgXHZkbcLdbzOV/fPfivwx/N8rFmZ3apExZb/3JMfts9tfaeXUbC//N8C/8A792cEbu7v le2tvWB6X6ma+6bXQrflUwLO2b1svH/wwvwvpuUlmvlnWF9fnb24aFn2DeEVLQV3PHfd0rp9 x8Ccg4Wf1/Xrn4sc7/VeZXz+L3ru3gKxuaJhXsvKtKOUWIozEg21mIuKEwFf9iX1qgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkluLIzCtJLcpLzFFi42I5/e/4ZV1m60kxBl9vcVncWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MzffaGAua9Su6D39la2Ccqt7FyMkhIWAicXvlNMYuRi4OIYEljBIPLnax giSEBBqZJGYsLwax2QQ0Jf5uvskGYosIKEus2tfODtLALPCbUeLzjK/MIAlhgQSJvQt7WEBs FgFViSuTmpm6GDk4eAUsJBY/0oBYJi+xesMBsHJOAUuJh3P+s0PsAio5cZdxAiPPAkaGVYwi qaXFuem5xYZ6xYm5xaV56XrJ+bmbGIEBs+3Yz807GC9tDD7EKMDBqMTDW/F0QowQa2JZcWXu IUYJDmYlEd4IpUkxQrwpiZVVqUX58UWlOanFhxilOViUxHnPG1RGCQmkJ5akZqemFqQWwWSZ ODilGhjLy3d5vKg2Wer0x2Jjqsa+BZ2aJ9WZJ0ybJN961jfuvdbjo+I1Cqs1dzsmOcRYSmg1 TXzndvq70LHljzO2PfgXzLW7fi/HrkdmnRYuF6eyay2bvzK30pj/eXzF7KTSzTeVGLbU//ou ETCjkv/1loW8IbclWXSvTxBW/bf27yI2LbGW2XM/B85QYinOSDTUYi4qTgQA3o3iDBQCAAA= X-CMS-MailID: 20190320130715eucas1p250b6b902360896cd36bff8536b6292bf CMS-TYPE: 201P X-CMS-RootMailID: 20190320130715eucas1p250b6b902360896cd36bff8536b6292bf 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/exynos_mixer.c | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 750f682e9c31..946d62ae83e3 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -98,7 +98,7 @@ struct mixer_context { struct platform_device *pdev; struct device *dev; struct drm_device *drm_dev; - struct exynos_drm_crtc *crtc; + struct exynos_drm_crtc crtc; struct exynos_drm_plane planes[MIXER_WIN_NR]; unsigned long flags; @@ -116,6 +116,8 @@ struct mixer_context { int scan_value; }; +#define to_mixer(ptr) container_of(ptr, struct mixer_context, ptr) + struct mixer_drv_data { enum mixer_version_id version; bool is_vp_enabled; @@ -426,7 +428,7 @@ static void mixer_stop(struct mixer_context *ctx) static void mixer_commit(struct mixer_context *ctx) { - struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode; + struct drm_display_mode *mode = &ctx->crtc.base.state->adjusted_mode; mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay); mixer_cfg_rgb_fmt(ctx, mode); @@ -712,7 +714,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) goto out; } - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); } out: @@ -856,7 +858,7 @@ static void mixer_ctx_remove(struct mixer_context *mixer_ctx) static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); __set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) @@ -871,7 +873,7 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); __clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); @@ -885,7 +887,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) return; @@ -896,7 +898,7 @@ static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) static void mixer_update_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); DRM_DEBUG_KMS("win: %d\n", plane->index); @@ -912,7 +914,7 @@ static void mixer_update_plane(struct exynos_drm_crtc *crtc, static void mixer_disable_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); unsigned long flags; DRM_DEBUG_KMS("win: %d\n", plane->index); @@ -927,7 +929,7 @@ static void mixer_disable_plane(struct exynos_drm_crtc *crtc, static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) return; @@ -938,7 +940,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) static void mixer_enable(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); if (test_bit(MXR_BIT_POWERED, &ctx->flags)) return; @@ -967,7 +969,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) static void mixer_disable(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); int i; if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) @@ -989,7 +991,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc) static int mixer_mode_valid(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); u32 w = mode->hdisplay, h = mode->vdisplay; DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d\n", w, h, @@ -1015,7 +1017,7 @@ static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); int width = mode->hdisplay, height = mode->vdisplay, i; struct { @@ -1117,7 +1119,6 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) { struct mixer_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct exynos_drm_plane *exynos_plane; unsigned int i; int ret; static enum drm_plane_type types[] = { DRM_PLANE_TYPE_PRIMARY, @@ -1151,14 +1152,14 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) return ret; } - exynos_plane = &ctx->planes[DEFAULT_WIN]; - ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, - EXYNOS_DISPLAY_TYPE_HDMI, &mixer_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) { + ctx->crtc.type = EXYNOS_DISPLAY_TYPE_HDMI; + ctx->crtc.ops = &mixer_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) { mixer_ctx_remove(ctx); - ret = PTR_ERR(ctx->crtc); goto free_ctx; } + ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base; return 0;