From patchwork Wed Mar 20 13:06:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861575 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 4E48015AC for ; Wed, 20 Mar 2019 13:07:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32A3228B7B for ; Wed, 20 Mar 2019 13:07:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 265912996A; Wed, 20 Mar 2019 13:07:20 +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 197F429BE7 for ; Wed, 20 Mar 2019 13:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfCTNHS (ORCPT ); Wed, 20 Mar 2019 09:07:18 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55167 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbfCTNHS (ORCPT ); Wed, 20 Mar 2019 09:07:18 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130716euoutp01ccbd8743dedf289b9fc234cca2a52c46~NrJz3s77a0130601306euoutp01H; Wed, 20 Mar 2019 13:07:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190320130716euoutp01ccbd8743dedf289b9fc234cca2a52c46~NrJz3s77a0130601306euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087236; bh=Zx2XHvFYWorS20Vhy6iLAPZJeMHhraLAeZL9/r6Pzvk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=J9DpfMl1v+UHZktpOan7Gef2DMFBxAH2JO7Qp2Xl5kXgkuE6o862IEHyaOKgKBbqC 48TAz1cmU++rIWbIrGzAlE2PSi+w9u28saeIbqhSVQQJtsJfTgLdtMTNXPLFvVm3dH tPGZHVC21JW2c6QLKZhsCcYQTnqgFHaPC0pDkn/M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190320130716eucas1p129f2447d2c2d57359a9236d9261605c0~NrJzglogp2304123041eucas1p10; Wed, 20 Mar 2019 13:07:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 0A.35.04441.40B329C5; Wed, 20 Mar 2019 13:07:16 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130715eucas1p2ab0449e8b243fcfa2d63524363eb8544~NrJy4tCef1665716657eucas1p2M; Wed, 20 Mar 2019 13:07:15 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-a8-5c923b04f6c9 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 26.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 09/24] drm/exynos/vidi: embed exynos_drm_crtc directly into context Date: Wed, 20 Mar 2019 14:06:52 +0100 Message-id: <20190320130707.25161-10-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+NgFprBIsWRmVeSWpSXmKPExsWy7djPc7os1pNiDE58YLa4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZi68+YyyYJ1exb+4+pgbGPskuRk4OCQETiYfnHrJ1MXJxCAmsYJQ43b6b ESQhJPCZUeLe7yiYojd9DUwQRcsYJdoudTBDOP8ZJWb86GADqWIT0JT4u/kmmC0ioCyxal87 O0gRs8BvRonpy7exgySEBeIlTq19wtLFyMHBIqAqse+uPEiYV8BSYtL5P2wQ2+QlVm84wAxi cwLFH875DzZHQuAvq8TtjxMYIYpcJJ717meHsGUkOjsOMkHY9RL3V7QwQzR0MEps3bCTGSJh LXH4+EVWEJtZgE9i0rbpzCBHSAjwSnS0CUGUeEi0vHkJ9WYPo8SC55PYJgApRoZVjOKppcW5 6anFhnmp5XrFibnFpXnpesn5uZsYgfF1+t/xTzsYv15KOsQowMGoxMPb8GZCjBBrYllxZe4h RgkOZiUR3gilSTFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeasZHkQLCaQnlqRmp6YWpBbBZJk4 OKUaGNVuaE4zt154KKLJ9Ej9DuNCKTPlWWtm3njbttd+X9PTN7/1vge4eV25MefgwqjJPuIS lhoxr6IfBh/afFqFZ9GbSRfvyAU53m03bbxzZHXtNZdrd3anJS43EjRseeQ7b97MpI+x+Zov lyoY8Z+1SQrpZLxwh/3qvtjPO9kcMvavNCxLaf4TxKjEUpyRaKjFXFScCACBaPgwqwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e/4ZV1m60kxBl39yha31p1jtdg4Yz2r xZWv79ksJt2fwGJx/vwGdosZ5/cxWaw9cpfdgd1j06pONo/73ceZPPq2rGL0+LxJLoAlissm JTUnsyy1SN8ugStj8dVnjAXz5Cr2zd3H1MDYJ9nFyMkhIWAi8aavgQnEFhJYwijxZnU+hN3I JDFjeTGIzSagKfF38002EFtEQFli1b529i5GLg5mgd+MEp9nfGUGSQgLxEucWvuEpYuRg4NF QFVi3115kDCvgKXEpPN/2CB2yUus3nAArJwTKP5wzn92iF0WEotP3GWcwMizgJFhFaNIamlx bnpusaFecWJucWleul5yfu4mRmC4bDv2c/MOxksbgw8xCnAwKvHwVjydECPEmlhWXJl7iFGC g1lJhDdCaVKMEG9KYmVValF+fFFpTmrxIUZpDhYlcd7zBpVRQgLpiSWp2ampBalFMFkmDk6p BkZ+jraNZ/cyX50+sfHg0pr/+SU7/CZc03tl/ir+IGvm6nVfe4O2p660mxe4jfMM737ZZYXW Zmsf71L6EJp2ROLu8+6D9h1i9gnq/p/qPvAGqYplzF73buLstcEX+C8+eLnfZeE/gSe1MTwC T+4x7ZNdkS9T8Tzgwoo++ezwe5e51n/3Ur6zNWaVEktxRqKhFnNRcSIAGx3qyxMCAAA= X-CMS-MailID: 20190320130715eucas1p2ab0449e8b243fcfa2d63524363eb8544 CMS-TYPE: 201P X-CMS-RootMailID: 20190320130715eucas1p2ab0449e8b243fcfa2d63524363eb8544 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_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);