From patchwork Mon Mar 25 07:13:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10868031 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 2A21514DE for ; Mon, 25 Mar 2019 07:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 138D82924B for ; Mon, 25 Mar 2019 07:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 084802924E; Mon, 25 Mar 2019 07:14:02 +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 C310B29255 for ; Mon, 25 Mar 2019 07:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729765AbfCYHOA (ORCPT ); Mon, 25 Mar 2019 03:14:00 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:59674 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729792AbfCYHOA (ORCPT ); Mon, 25 Mar 2019 03:14:00 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190325071358euoutp02d5cbfb9b1cbe3e0640ba529b0c81fdd1~PIjxTTwjT0730507305euoutp02H; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190325071358euoutp02d5cbfb9b1cbe3e0640ba529b0c81fdd1~PIjxTTwjT0730507305euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553498038; bh=Zx2XHvFYWorS20Vhy6iLAPZJeMHhraLAeZL9/r6Pzvk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=GyRcK06yHjXB0sNJO/hRW0waMPQz8ZaK9o/X7cLUrGtbA5JjpZRA0n5XYYuPgtQCc PTOuSrOwHQnIZn3OchkDd5++YfAoZI9p62cGItjW4v4caqVOuZn3t+a71imChgxZ6P DC17T8xsByzOfJAJvsOIpktGmMAt+IpAbT79DPCU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071358eucas1p15dfad79afcbfcc03ae9e5bd4e521aae3~PIjw9O5UZ2364523645eucas1p1N; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 0D.4E.04377.6BF789C5; Mon, 25 Mar 2019 07:13:58 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190325071357eucas1p107f56a7c71d033687e02d8eab03c8635~PIjwNmlkp1834618346eucas1p1d; Mon, 25 Mar 2019 07:13:57 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-d4-5c987fb615de Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 53.69.04146.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 11/24] drm/exynos/vidi: embed exynos_drm_crtc directly into context Date: Mon, 25 Mar 2019 08:13:36 +0100 Message-id: <20190325071349.22600-12-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+NgFprJIsWRmVeSWpSXmKPExsWy7djPc7rb6mfEGKw7L2Rxa905VouNM9az Wlz5+p7NYtL9CSwW589vYLeYcX4fk8XaI3fZHdg9Nq3qZPO4332cyaNvyypGj8+b5AJYorhs UlJzMstSi/TtErgyFl99xlgwT65i39x9TA2MfZJdjJwcEgImEp2z5rF2MXJxCAmsYJT4ceoq lPOZUeLuh/esMFXXL79lh0gsY5Q4uXUKC4Tzn1Fi6a0NTCBVbAKaEn8332QDsUUElCVW7WsH 62AW+M0oMX35NiCHg0NYIF7i9csUkBoWAVWJ89fmg23gFbCUODnvOhPENnmJ1RsOMIPYnEDx /6cvMYPMkRBoZJOYe+8tVJGLxKM3d6DOk5Ho7DgIFa+XuL+iBaqhg1Fi64adzBAJa4nDxy+C NTAL8ElM2jadGeQgCQFeiY42IYgSD4kPq/dDfdbDKLH60QGmCYwSCxgZVjGKp5YW56anFhvl pZbrFSfmFpfmpesl5+duYgRG2Ol/x7/sYNz1J+kQowAHoxIPr8Oe6TFCrIllxZW5hxglOJiV RHifiM6IEeJNSaysSi3Kjy8qzUktPsQozcGiJM5bzfAgWkggPbEkNTs1tSC1CCbLxMEp1cCY uCM+6oe6yv75cqf/dt+t4shPC5VrfNe4OUdbdVrblqOPy/6In1zleOCzrQ770qp1waXz74nc kcyYfPa37qxzDzUYT/GZGx3pytT70ON2k09TeceXuc/8ZpSpK33osCsSrGp/ZpMSULDShj04 RWAH44IHi485tzgmauXYicd/cfvcmJDmZ63EUpyRaKjFXFScCACeM5oHrAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42I5/e/4Vd2t9TNiDGas1Le4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZi68+YyyYJ1exb+4+pgbGPskuRk4OCQETieuX37J3MXJxCAksYZTY8P0Y lNPIJNHXfJUNpIpNQFPi7+abYLaIgLLEqn3tYEXMAr8ZJT7P+MrcxcjBISwQL/H6ZQpIDYuA qsT5a/NZQWxeAUuJk/OuM0Fsk5dYveEAM4jNCRT/f/oSmC0kYCGxd1kj+wRGngWMDKsYRVJL i3PTc4sN9YoTc4tL89L1kvNzNzECQ2bbsZ+bdzBe2hh8iFGAg1GJh9dhz/QYIdbEsuLK3EOM EhzMSiK8T0RnxAjxpiRWVqUW5ccXleakFh9ilOZgURLnPW9QGSUkkJ5YkpqdmlqQWgSTZeLg lGpg5HsmvWn9imNsbyoeJwben7Hf4+ezE+s+bjh0ed77R6x3V9uWN/6yrOm3LLzG8JjjyvEp G64qzv82I7iKuYzrc8+Vn78rf8hu9BX7VKF862q3Q+AllcmFDks3TfjqVL/u4RXO+eYv54te 8WRdLC2WbCHSflotPetxRp7T19O9jDan1fafyi7ZdFOJpTgj0VCLuag4EQCe5dowFQIAAA== X-CMS-MailID: 20190325071357eucas1p107f56a7c71d033687e02d8eab03c8635 CMS-TYPE: 201P X-CMS-RootMailID: 20190325071357eucas1p107f56a7c71d033687e02d8eab03c8635 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_drm_vidi.c | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index b61ae3415b8c..377aae5f7631 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -41,7 +41,7 @@ struct vidi_context { struct drm_encoder encoder; struct platform_device *pdev; struct drm_device *drm_dev; - struct exynos_drm_crtc *crtc; + struct exynos_drm_crtc crtc; struct drm_connector connector; struct exynos_drm_plane planes[WINDOWS_NR]; struct edid *raw_edid; @@ -57,6 +57,8 @@ static inline struct vidi_context *encoder_to_vidi(struct drm_encoder *e) return container_of(e, struct vidi_context, encoder); } +#define to_vidi(ptr) container_of(ptr, struct vidi_context, ptr) + static const char fake_edid_info[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78, @@ -96,7 +98,7 @@ static const enum drm_plane_type vidi_win_types[WINDOWS_NR] = { static int vidi_enable_vblank(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = crtc->ctx; + struct vidi_context *ctx = to_vidi(crtc); if (ctx->suspended) return -EPERM; @@ -115,7 +117,7 @@ static void vidi_update_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { struct drm_plane_state *state = plane->base.state; - struct vidi_context *ctx = crtc->ctx; + struct vidi_context *ctx = to_vidi(crtc); dma_addr_t addr; if (ctx->suspended) @@ -127,7 +129,7 @@ static void vidi_update_plane(struct exynos_drm_crtc *crtc, static void vidi_enable(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = crtc->ctx; + struct vidi_context *ctx = to_vidi(crtc); mutex_lock(&ctx->lock); @@ -140,7 +142,7 @@ static void vidi_enable(struct exynos_drm_crtc *crtc) static void vidi_disable(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = crtc->ctx; + struct vidi_context *ctx = to_vidi(crtc); drm_crtc_vblank_off(&crtc->base); @@ -164,7 +166,7 @@ static void vidi_fake_vblank_timer(struct timer_list *t) { struct vidi_context *ctx = from_timer(ctx, t, timer); - if (drm_crtc_handle_vblank(&ctx->crtc->base)) + if (drm_crtc_handle_vblank(&ctx->crtc.base)) mod_timer(&ctx->timer, jiffies + msecs_to_jiffies(VIDI_REFRESH_TIME) - 1); } @@ -377,7 +379,6 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) struct vidi_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; struct drm_encoder *encoder = &ctx->encoder; - struct exynos_drm_plane *exynos_plane; unsigned int i; int ret; @@ -390,13 +391,14 @@ static int vidi_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_VIDI, &vidi_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) { + ctx->crtc.type = EXYNOS_DISPLAY_TYPE_VIDI; + ctx->crtc.ops = &vidi_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) { DRM_ERROR("failed to create crtc.\n"); - return PTR_ERR(ctx->crtc); + return ret; } + ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base; drm_encoder_init(drm_dev, encoder, &exynos_vidi_encoder_funcs, DRM_MODE_ENCODER_TMDS, NULL);