From patchwork Wed Mar 20 13:06:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861577 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 7F0CF1575 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 64C642838B for ; Wed, 20 Mar 2019 13:07:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62F1F29BDC; 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 A339129BD8 for ; Wed, 20 Mar 2019 13:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbfCTNHT (ORCPT ); Wed, 20 Mar 2019 09:07:19 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:58196 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727625AbfCTNHT (ORCPT ); Wed, 20 Mar 2019 09:07:19 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130717euoutp022e7a463f02dd3b22a6ec47b3b844c463~NrJ1Ag8mp1589215892euoutp02l; Wed, 20 Mar 2019 13:07:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190320130717euoutp022e7a463f02dd3b22a6ec47b3b844c463~NrJ1Ag8mp1589215892euoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087237; bh=PgbKR/w9TRKewd4GHl+53PaABxvCvoMv24+YVVR5Zf8=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=dRxi3Hcyxwb5D0R2/UB8TFCHZRU7YHHRhUctwFjUTzGEsifa/Q+1+DSTroJOmO3PH Ad1latgSrJBmdU21R0qrTnZV6wc+TS04jh1jXLs/oV1vdxsqQwvztKXykyqpltch1F KFSYkycdTMhzXsppamWI8SLsDZnDu7T8An6a8Eyc= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130717eucas1p227fc4e1a5deedc250ec1daff4fd04e23~NrJ0on8NI1479814798eucas1p2R; Wed, 20 Mar 2019 13:07:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2C.35.04441.50B329C5; Wed, 20 Mar 2019 13:07:17 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190320130716eucas1p121bc6480ad28d1c0c79c195ae943ee55~NrJ0C6qVg2302623026eucas1p19; Wed, 20 Mar 2019 13:07:16 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-ae-5c923b05b7fd Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E9.DA.04128.40B329C5; Wed, 20 Mar 2019 13:07:16 +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:16 +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 12/24] drm/exynos: unify plane type assignment Date: Wed, 20 Mar 2019 14:06:55 +0100 Message-id: <20190320130707.25161-13-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+NgFprJIsWRmVeSWpSXmKPExsWy7djP87qs1pNiDFa+47e4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZL7YnF+ywq/g/6wBLA+Nd4y5GTg4JAROJ22d2snUxcnEICaxglHjYuI0Z wvnMKDFl7jQmmKr+CTdZIRLLGCXerp/MBOH8Z5SY9vsxWBWbgKbE38032UBsEQFliVX72tlB ipgFfjNKTF++jR0kISzgIdH37j0LiM0ioCpx92QrI4jNK2ApMfX9b3aIdfISqzccYAaxOYHi D+f8BxskIfCTVWLenMNQN7lI/Pr5jhnClpG4PLmbBcKul7i/ooUZoqGDUWLrhp1QRdYSh49f ZAWxmQX4JCZtmw4U5wCK80p0tAlBlHhIbLnyBRoaPYwSf1vbmCYwSixgZFjFKJ5aWpybnlps mJdarlecmFtcmpeul5yfu4kRGGGn/x3/tIPx66WkQ4wCHIxKPLwNbybECLEmlhVX5h5ilOBg VhLhjVCaFCPEm5JYWZValB9fVJqTWnyIUZqDRUmct5rhQbSQQHpiSWp2ampBahFMlomDU6qB Ua5v+3IF+ZlpIjxXy7UNjPbJzPikte+yw03jSAXOl6sXrbez3icd97nz47eUJE3JhMUPBQ+r z+Z5Haq1M861nPHpi68hx4L7WB+KH/eobj899ccV8VlX8nd5H2u5a/j7oUOXgeq5kNxdyf+m nsoXZO8/bHdtC5v3ZC9uzWfzJ70td+vntNvzX4mlOCPRUIu5qDgRAIKkk+2sAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e/4ZV0W60kxBlc36FvcWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MF9uTC3bYVfyfdYClgfGucRcjJ4eEgIlE/4SbrCC2kMASRolnizUh7EYm iU/vFUFsNgFNib+bb7KB2CICyhKr9rWzdzFycTAL/GaU+DzjKzNIQljAQ6Lv3XsWEJtFQFXi 7slWRhCbV8BSYur73+wQy+QlVm84AFbPCRR/OOc/O8QyC4nFJ+4yTmDkWcDIsIpRJLW0ODc9 t9hIrzgxt7g0L10vOT93EyMwXLYd+7llB2PXu+BDjAIcjEo8vBVPJ8QIsSaWFVfmHmKU4GBW EuGNUJoUI8SbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJanZqakFqEUyWiYNTqoHx WKV1/bOzp0O32sUL3JW8Hcdw8KDJM8mwFf+3vfmwbNuE48LrspZOmiOS47jN30FeOcV8Drvz 0wenP5wu4izkMYz4ra+kmT/5UUjudO0b6lpFOv9+TO95dOzJGYYuhoiCM7882R8/PZr4v1a5 faam9duF1wVDqkNmNUx5Hi15N+DFpwItsU0sSizFGYmGWsxFxYkAXJHprRMCAAA= X-CMS-MailID: 20190320130716eucas1p121bc6480ad28d1c0c79c195ae943ee55 CMS-TYPE: 201P X-CMS-RootMailID: 20190320130716eucas1p121bc6480ad28d1c0c79c195ae943ee55 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 all Exynos CRTCs uses the first plane as primary plane and the last one as cursor plane we can drop custom assignments per CRTC and replace it with common code. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 7 +------ drivers/gpu/drm/exynos/exynos7_drm_decon.c | 7 +------ drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 10 +--------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 19 +++++++++++++------ drivers/gpu/drm/exynos/exynos_drm_vidi.c | 8 +------- drivers/gpu/drm/exynos/exynos_mixer.c | 6 ++---- 7 files changed, 20 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 0d409f453923..663446ca2d09 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -78,11 +78,6 @@ static const uint32_t decon_formats[] = { DRM_FORMAT_ARGB8888, }; -static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { - [PRIMARY_WIN] = DRM_PLANE_TYPE_PRIMARY, - [CURSON_WIN] = DRM_PLANE_TYPE_CURSOR, -}; - static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask, u32 val) { @@ -619,7 +614,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data) | EXYNOS_DRM_PLANE_CAP_PIX_BLEND; ret = exynos_plane_init(drm_dev, &ctx->planes[i], decon_formats, ARRAY_SIZE(decon_formats), - decon_win_types[i]); + WINDOWS_NR - ctx->first_win); if (ret) return ret; } diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 22659f2da755..b6ad2faed159 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -78,11 +78,6 @@ static const uint32_t decon_formats[] = { DRM_FORMAT_BGRA8888, }; -static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { - DRM_PLANE_TYPE_PRIMARY, - DRM_PLANE_TYPE_CURSOR, -}; - static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = to_decon(crtc); @@ -628,7 +623,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data) for (i = 0; i < WINDOWS_NR; i++) { ctx->planes[i].index = i; ret = exynos_plane_init(drm_dev, &ctx->planes[i], decon_formats, - ARRAY_SIZE(decon_formats), decon_win_types[i]); + ARRAY_SIZE(decon_formats), WINDOWS_NR); if (ret) return ret; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 82af112be03d..23b27b82de6e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -97,7 +97,7 @@ struct exynos_drm_plane { int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane, const uint32_t *pixel_formats, int num_pixel_formats, - enum drm_plane_type type); + int win_count); /* * Exynos drm crtc ops diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 8ea1cfd51736..b3c11bca5aed 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -212,14 +212,6 @@ static const struct of_device_id fimd_driver_dt_match[] = { }; MODULE_DEVICE_TABLE(of, fimd_driver_dt_match); -static const enum drm_plane_type fimd_win_types[WINDOWS_NR] = { - DRM_PLANE_TYPE_PRIMARY, - DRM_PLANE_TYPE_OVERLAY, - DRM_PLANE_TYPE_OVERLAY, - DRM_PLANE_TYPE_OVERLAY, - DRM_PLANE_TYPE_CURSOR, -}; - static const uint32_t fimd_formats[] = { DRM_FORMAT_C8, DRM_FORMAT_XRGB1555, @@ -1049,7 +1041,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) | EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND; ret = exynos_plane_init(drm_dev, &ctx->planes[i], fimd_formats, - ARRAY_SIZE(fimd_formats), fimd_win_types[i]); + ARRAY_SIZE(fimd_formats), WINDOWS_NR); if (ret) return ret; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index e1aa504539fa..5f8f56b69369 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -291,9 +291,18 @@ static void exynos_plane_attach_zpos_property(struct drm_plane *plane, drm_plane_create_zpos_property(plane, zpos, 0, MAX_PLANE - 1); } +static inline enum drm_plane_type exynos_plane_type(int index, int count) +{ + if (count && !index) + return DRM_PLANE_TYPE_PRIMARY; + if (index == count - 1) + return DRM_PLANE_TYPE_CURSOR; + return DRM_PLANE_TYPE_OVERLAY; +} + int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane, const uint32_t *pixel_formats, int num_pixel_formats, - enum drm_plane_type type) + int win_count) { int err; unsigned int supported_modes = BIT(DRM_MODE_BLEND_PIXEL_NONE) | @@ -302,11 +311,9 @@ int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane, struct drm_plane *bplane = &plane->base; err = drm_universal_plane_init(dev, bplane, - 1 << dev->mode_config.num_crtc, - &exynos_plane_funcs, - pixel_formats, - num_pixel_formats, - NULL, type, NULL); + 1 << dev->mode_config.num_crtc, + &exynos_plane_funcs, pixel_formats, num_pixel_formats,NULL, + exynos_plane_type(plane->index, win_count), NULL); if (err) { DRM_ERROR("failed to initialize plane\n"); return err; diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 2579462aec70..eb1fd3a2cdf3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -85,12 +85,6 @@ static const uint32_t formats[] = { DRM_FORMAT_NV12, }; -static const enum drm_plane_type vidi_win_types[WINDOWS_NR] = { - DRM_PLANE_TYPE_PRIMARY, - DRM_PLANE_TYPE_OVERLAY, - DRM_PLANE_TYPE_CURSOR, -}; - static int vidi_enable_vblank(struct exynos_drm_crtc *crtc) { struct vidi_context *ctx = to_vidi(crtc); @@ -381,7 +375,7 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) for (i = 0; i < WINDOWS_NR; i++) { ret = exynos_plane_init(drm_dev, &ctx->planes[i], formats, - ARRAY_SIZE(formats), vidi_win_types[i]); + ARRAY_SIZE(formats), WINDOWS_NR); if (ret) return ret; } diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 946d62ae83e3..d0dcbbfc67e5 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -1121,8 +1121,6 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) struct drm_device *drm_dev = data; unsigned int i; int ret; - static enum drm_plane_type types[] = { DRM_PLANE_TYPE_PRIMARY, - DRM_PLANE_TYPE_CURSOR, DRM_PLANE_TYPE_OVERLAY }; ret = mixer_initialize(ctx, drm_dev); if (ret) @@ -1135,7 +1133,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) EXYNOS_DRM_PLANE_CAP_PIX_BLEND | EXYNOS_DRM_PLANE_CAP_WIN_BLEND; ret = exynos_plane_init(drm_dev, &ctx->planes[i], mixer_formats, - ARRAY_SIZE(mixer_formats), types[i]); + ARRAY_SIZE(mixer_formats), VP_DEFAULT_WIN); if (ret) return ret; } @@ -1147,7 +1145,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) EXYNOS_DRM_PLANE_CAP_TILE | EXYNOS_DRM_PLANE_CAP_WIN_BLEND; ret = exynos_plane_init(drm_dev, &ctx->planes[i], vp_formats, - ARRAY_SIZE(vp_formats), types[i]); + ARRAY_SIZE(vp_formats), VP_DEFAULT_WIN); if (ret) return ret; }