From patchwork Mon Mar 25 07:13:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10868025 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 47BE614DE 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 2E84C29246 for ; Mon, 25 Mar 2019 07:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 233922924C; 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 7CC4B2924E for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729795AbfCYHOA (ORCPT ); Mon, 25 Mar 2019 03:14:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:41920 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729764AbfCYHN7 (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 20190325071358euoutp01d236daf5145d4e33fcf197f5ae30924b~PIjxA1gQV0709007090euoutp01n; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190325071358euoutp01d236daf5145d4e33fcf197f5ae30924b~PIjxA1gQV0709007090euoutp01n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553498038; bh=qblQ/KFXj3CxfTRN5t+Y0yeR0q3YL3Lrkf6PoemiOz4=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=hA8yx7t2zOcRtU2bZS27ymTQT0JAdKYxS86Ay4WDupK/xrBVguyCIEQrJZRvNQuP1 MFP/Orw+ATD9COPLZZDMc8Mkcj4RoZp+cqqukUKFyjUyGsh7Qnud7uoFIs8yzXc9LV ckl4L7KOK6Z9pJynxhDeEbcXEZtv7NphuwBfvnhk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071358eucas1p1d51a5aaac1cfba81c56da778e1d74d06~PIjwkBHAL2091720917eucas1p1T; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F0.6E.04298.5BF789C5; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071357eucas1p1d1def486ebc1697def8c4d670b7cd15c~PIjv2TcI13105231052eucas1p1o; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) X-AuditID: cbfec7f2-f13ff700000010ca-bc-5c987fb504bb Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8C.19.04140.5BF789C5; Mon, 25 Mar 2019 07:13:57 +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:57 +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 10/24] drm/exynos/mixer: embed exynos_drm_crtc directly into context Date: Mon, 25 Mar 2019 08:13:35 +0100 Message-id: <20190325071349.22600-11-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+NgFprJIsWRmVeSWpSXmKPExsWy7djPc7pb62fEGGw5Ymxxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyVn3bzlzQp18x4fUb5gbGOepdjJwcEgImEhNfHGHrYuTiEBJYwSjRtecp K4TzmVHi2bblTDBVL//dY4dILGOUeL/mLFTLf0aJpbc2gFWxCWhK/N18kw3EFhFQlli1rx2s g1ngN6PE9OXb2EESwgIJEsunPmEGsVkEVCUeTlvJCGLzClhKbDwLYUsIyEus3nAArIYTKP7/ 9CVmkEESAj9ZJX7NPw90IAeQ4yJxqiEEol5G4vLkbhYIu17i/ooWqPoORomtG3YyQySsJQ4f v8gKYjML8ElM2jadGWIOr0RHmxBEiYfErFsbod7sAQbG2l6mCYwSCxgZVjGKp5YW56anFhvm pZbrFSfmFpfmpesl5+duYgRG2Ol/xz/tYPx6KekQowAHoxIP74ud02OEWBPLiitzDzFKcDAr ifA+EZ0RI8SbklhZlVqUH19UmpNafIhRmoNFSZy3muFBtJBAemJJanZqakFqEUyWiYNTqoFx 1uZHYU+1JmWmHgvWX3t0edDC+Oludo4Mu7jFtex1bk15OkPrX7Got/XcVcKJ2w1jT6sxc4a6 Gpw1DT1c/cWpTkJb9pQow8I5LIqVy0JNEkN0z+gcY2ZnTRJ8cfCsdWb5ry83NzrHdodOeNh1 Riljz5+a4jqRti0y7x0ijx1kevHiGqt+vb4SS3FGoqEWc1FxIgCjCBVArAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4Vd2t9TNiDDZ/E7O4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZq75tZy7o06+Y8PoNcwPjHPUuRk4OCQETiZf/7rF3MXJxCAksYZT4susd K4TTyCTR13yVDaSKTUBT4u/mm2C2iICyxKp97WAdzAK/GSU+z/jKDJIQFkiQWD71CZjNIqAq 8XDaSkYQm1fAUmLjWQhbQkBeYvWGA2A1nEDx/6cvgdlCAhYSe5c1sk9g5FnAyLCKUSS1tDg3 PbfYSK84Mbe4NC9dLzk/dxMjMGi2Hfu5ZQdj17vgQ4wCHIxKPLwOe6bHCLEmlhVX5h5ilOBg VhLhfSI6I0aINyWxsiq1KD++qDQntfgQozQHi5I473mDyighgfTEktTs1NSC1CKYLBMHp1QD o7HRC+OCNLv86T0iR7dH5fFMbV19hs9DkSNO3vnuCbbFTnGTimVtZ8m3ndoa8uDao1kXr+g5 +28rOjRBOcqtSTSgmVdHg8ntE3e6xZrKyR/f8NV9nsrFVDV5yVu7LQ9VNO/OkWL+ckJ1ctGq 4I9v3xifeqr+3GL/M1Pho7LbjswS/u4ykblOW4mlOCPRUIu5qDgRADsWbr4WAgAA X-CMS-MailID: 20190325071357eucas1p1d1def486ebc1697def8c4d670b7cd15c CMS-TYPE: 201P X-CMS-RootMailID: 20190325071357eucas1p1d1def486ebc1697def8c4d670b7cd15c 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/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 1c82265acf0a..7fcefcbe68db 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -99,7 +99,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; @@ -117,6 +117,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; @@ -474,7 +476,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); @@ -732,7 +734,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) && !mixer_is_synced(ctx)) goto out; - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); } out: @@ -876,7 +878,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)) @@ -891,7 +893,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); @@ -905,7 +907,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) static void mixer_atomic_begin(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; @@ -918,7 +920,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); @@ -934,7 +936,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); @@ -949,7 +951,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; @@ -960,7 +962,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; @@ -989,7 +991,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)) @@ -1011,7 +1013,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, @@ -1037,7 +1039,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 { @@ -1139,7 +1141,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, @@ -1173,14 +1174,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;