From patchwork Fri Mar 1 12:20:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10835111 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 662BE922 for ; Fri, 1 Mar 2019 12:21:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5537B2097A for ; Fri, 1 Mar 2019 12:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E8E2D931; Fri, 1 Mar 2019 12:21:28 +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 BBE8C2097A for ; Fri, 1 Mar 2019 12:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388172AbfCAMVN (ORCPT ); Fri, 1 Mar 2019 07:21:13 -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 S2387704AbfCAMVN (ORCPT ); Fri, 1 Mar 2019 07:21:13 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190301122110euoutp0125e14e27d4f79c6a4351cdcf37df1b59~H1RIw3TV81452714527euoutp01S; Fri, 1 Mar 2019 12:21:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190301122110euoutp0125e14e27d4f79c6a4351cdcf37df1b59~H1RIw3TV81452714527euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1551442870; bh=Zx2XHvFYWorS20Vhy6iLAPZJeMHhraLAeZL9/r6Pzvk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=G/23kXcuJP8Wh6je5GZw/6XksnE4wDfp2RSv6jFDLZm8s1H0grBAmGCmjj1REdJ0h 9aBDwEOlWzhGLsmsWcc3XDzvWYOoRCOajVDIKKOb0qwAq5z2UI2wPcwMxY+bCHy6kf vDiJj8f5qTic4cm2AAF7YQlnEBXxt/EZDEd6Knu8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122110eucas1p2d07327b5d8c57b3dd401a3417bfbac60~H1RINGc5g1653516535eucas1p2Z; Fri, 1 Mar 2019 12:21:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E1.5B.04806.5B3297C5; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190301122109eucas1p22f304f014932064d4b02caa01b4583ac~H1RHgAEst1654016540eucas1p2S; Fri, 1 Mar 2019 12:21:09 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-84-5c7923b57398 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 56.6C.04128.5B3297C5; Fri, 1 Mar 2019 12:21:09 +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:09 +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 09/23] drm/exynos/vidi: embed exynos_drm_crtc directly into context Date: Fri, 01 Mar 2019 13:20:41 +0100 Message-id: <20190301122055.7135-10-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+NgFupnkeLIzCtJLcpLzFFi42LZduzned2typUxBr0rzCxurTvHarFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xld2DzuN99nMmjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4 MhZffcZYME+uYt/cfUwNjH2SXYycHBICJhJ/D65i6mLk4hASWMEo8fFVBxuE85lR4u3Ft0ww Va/OnmEBsYUEljFKfDiiDVH0n1Fiz8ZdYEVsApoSfzffZAOxRQSUJVbta2cHKWIWuMQo8fpk NyNIQlggVOLvy4dgRSwCqhId7YfZQWxeAQuJjv+tUNvkJVZvOMAMYnMCxQ+uhBgkIfCWVeLf rMNsEEUuEp/ufYJqkJG4PLmbBcKul2iaeYUZoqGDUeLE4uVQDdYSh49fZAWxmQX4JCZtmw5U xAEU55XoaBOCKPGQeHtsMivEa92MEktf7mGZwCixgJFhFaN4amlxbnpqsXFearlecWJucWle ul5yfu4mRmA0nf53/OsOxn1/kg4xCnAwKvHw7nhdHiPEmlhWXJl7iFGCg1lJhJePoTJGiDcl sbIqtSg/vqg0J7X4EKM0B4uSOG81w4NoIYH0xJLU7NTUgtQimCwTB6dUA+NVkdmmWe7HxBPk rdgu7zAV+Mh5eSvv7wN/K39cfvM5vp0rx+NeUrfjh9/XBA48uOiRXM6WGGAyI3/3xlqWSUmd 3PzFe6xvcunKlL46FuwYLv8iTujoqaa3v9SZHtr5tWXnzUt8sKzM3HKx5klJJsc4zgnhyu/+ 2IZcvN1/XmSHl4ntgV1ib5RYijMSDbWYi4oTAYmutVSiAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xq7pblStjDBb/E7a4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ylh89RljwTy5in1z9zE1MPZJdjFyckgImEi8OnuGpYuRi0NIYAmjxJe7W5kgnEYmiSlLVjKB VLEJaEr83XyTDcQWEVCWWLWvnR2kiFngCqNE+7cudpCEsECoxN+XD8GKWARUJTraD4PFeQUs JDr+tzJBrJOXWL3hADOIzQkUP7gSZBAH0DZziU2noyYw8ixgZFjFKJJaWpybnltspFecmFtc mpeul5yfu4kRGB7bjv3csoOx613wIUYBDkYlHt6El+UxQqyJZcWVuYcYJTiYlUR4+RgqY4R4 UxIrq1KL8uOLSnNSiw8xSnOwKInznjeojBISSE8sSc1OTS1ILYLJMnFwSjUw7gg7vPLxIe6s 5ZNPOBz03/Xknt+bDxv1Dc1DzRojS+JEao/bFd/275pc/vW0dsSatCdH2MxSu/wUXx4qOamZ HKP++3JV/P2cHqZ3nAXB9aLbI8z+nvy4+rCXa9VcPsF+BjW2Wvaijys4T0kwzNlr+2a+V4J0 q8gxyxtmV7jMfgh6asam9ucrsRRnJBpqMRcVJwIAcqiQxQsCAAA= X-CMS-MailID: 20190301122109eucas1p22f304f014932064d4b02caa01b4583ac CMS-TYPE: 201P X-CMS-RootMailID: 20190301122109eucas1p22f304f014932064d4b02caa01b4583ac 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/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);