From patchwork Mon Dec 10 11:18:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10721101 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 EA19013BF for ; Mon, 10 Dec 2018 11:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80ED629612 for ; Mon, 10 Dec 2018 11:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7532D29622; Mon, 10 Dec 2018 11:18:42 +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 EB1382961E for ; Mon, 10 Dec 2018 11:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbeLJLSl (ORCPT ); Mon, 10 Dec 2018 06:18:41 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:34139 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbeLJLSl (ORCPT ); Mon, 10 Dec 2018 06:18:41 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181210111839euoutp02b11e0926efef7deb7605fddc2accc7a7~u9KbexxW32009220092euoutp02m; Mon, 10 Dec 2018 11:18:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181210111839euoutp02b11e0926efef7deb7605fddc2accc7a7~u9KbexxW32009220092euoutp02m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1544440719; bh=NWcEDFeDfBh0C0lPPqXBteQagmavbb8Cz4clnV2XEk4=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=npQcnVRsqLn6rgqroGRpbTHx7u8RoVn0nqYqnmuvaJc1zZ/9hEhZIh7bNEjvrozjf LgpcWBjNJo5csbW4oys4TsfPbXlgqWG/HVUNrnX7G42+G3j1cJUJOHzccZAifWkUZj YsBW76qshQjCBZ+lOvsxZx3WaVuqB58b8OBIyv/I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181210111839eucas1p292c4c9cafcdf31a948f72a28042c3b78~u9Ka3PvW31889518895eucas1p2U; Mon, 10 Dec 2018 11:18:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.C0.04441.E8B4E0C5; Mon, 10 Dec 2018 11:18:38 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181210111838eucas1p2b9e8a1bddd7c01528d23a546bf36fe9f~u9KaHOOXF1960019600eucas1p2M; Mon, 10 Dec 2018 11:18:38 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-b0-5c0e4b8efbc5 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AD.9E.04284.E8B4E0C5; Mon, 10 Dec 2018 11:18:38 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PJI001ZCQ31VQ20@eusync4.samsung.com>; Mon, 10 Dec 2018 11:18:38 +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 v2 1/3] drm/exynos/decon5433: add dynamic zpos support Date: Mon, 10 Dec 2018 12:18:32 +0100 Message-id: <20181210111834.17916-2-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181210111834.17916-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRmVeSWpSXmKPExsWy7djPc7p93nwxBj1LDS1urTvHarFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xld2DzuN99nMmjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4 MlrPbmUtmKha0Xx2P3MD4wL5LkZODgkBE4nHN7pYuxi5OIQEVjBKfJ41kxHC+cwocbPpIiNM 1ZfP29khEssYJZZfuMncxcgB5PxnlOjMAqlhE9CU+Lv5JhuILSKgLLFqXztYPbPAJUaJ1ye7 wQYJC7hJ/Ly0mBnEZhFQldjwbj6YzStgITHpYScLxDJ5idUbDoDN5xSwlGh5nAcyR0LgJavE qqeNbBA1LhJ/n9xihrCFJV4d38IOYctIdHYcZIKw6yWaZl5hhmjuYJQ4sXg5VLO1xOHjF1lB bGYBPolJ26aDLZMQ4JXoaBOCMD0kmj7kQ/zbwyixed9N5gmMkgsYGVYxiqeWFuempxYb5qWW 6xUn5haX5qXrJefnbmIExtfpf8c/7WD8einpEKMAB6MSD29AE2+MEGtiWXFl7iFGCQ5mJRFe 3TSgEG9KYmVValF+fFFpTmrxIUZpDhYlcd5qhgfRQgLpiSWp2ampBalFMFkmDk6pBkYeRt8t f/c7eXn9ZJ+46zfD1K766rIl//+XB85eeD/ENn2RxWGnR1a3PnXPOmJUnjlT6mmodOyxzC1F 5x0mpRlN9Daa71xdam7OY1+7jrH6u3elWLhgWcdyw7mSB1ozWgRfuZSuE1m0Nu7CjoLHFzYv k+66Xt/8sC+iqG9Ge9Ia00MHy3Xk2pRYijMSDbWYi4oTAbL0NMWrAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xa7p93nwxBt2r+S1urTvHarFxxnpW iytf37NZTLo/gcVixvl9TBZrj9xld2DzuN99nMmjb8sqRo/Pm+QCmKO4bFJSczLLUov07RK4 MlrPbmUtmKha0Xx2P3MD4wL5LkZODgkBE4kvn7ezdzFycQgJLGGUWHf5FSOE08gk8f3ILnaQ KjYBTYm/m2+ygdgiAsoSq/a1g3UwC1xhlGj/1gVWJCzgJvHz0mJmEJtFQFViw7v5YDavgIXE pIedLBDr5CVWbzgAFOfg4BSwlGh5nAdiCgGVTDuQO4GRZwEjwypGkdTS4tz03GJDveLE3OLS vHS95PzcTYzA4Nh27OfmHYyXNgYfYhTgYFTi4Q1o4o0RYk0sK67MPcQowcGsJMKrmwYU4k1J rKxKLcqPLyrNSS0+xCjNwaIkznveoDJKSCA9sSQ1OzW1ILUIJsvEwSnVwKj76Ng2bym2jzNq ZoqvfxeulSEcWexydfnfP9nahotLv6myvXo31dM8+YGBVbzSO4b8qPTOZrl817PFledfG576 //6bc1Iy217dbuH183zeWuofCjr1x/DQ59bwGWa5NskC4c1vTvw7OK/KUOvWrtkrTQ58qWFl OCrYtsp0RWtpQf8Vt3s6EkosxRmJhlrMRcWJAE0ukp8KAgAA X-CMS-MailID: 20181210111838eucas1p2b9e8a1bddd7c01528d23a546bf36fe9f X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181210111838eucas1p2b9e8a1bddd7c01528d23a546bf36fe9f References: <20181210111834.17916-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 DECON has fixed hardware window order. To implement dynamic zpos normalized_zpos of active plane has to be connected to window number, and remaining windows have to be disabled. v2: fixed pixel format setting Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 5b4e0e8b23bc..bdfec5f977e9 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -83,14 +83,6 @@ static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { [CURSON_WIN] = DRM_PLANE_TYPE_CURSOR, }; -static const unsigned int capabilities[WINDOWS_NR] = { - 0, - EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND, - EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND, - EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND, - EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND, -}; - static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask, u32 val) { @@ -314,12 +306,13 @@ static void decon_win_set_bldmod(struct decon_context *ctx, unsigned int win, } } -static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win, - struct drm_framebuffer *fb) +static void decon_win_set_pixfmt(struct decon_context *ctx, + struct exynos_drm_plane *plane) { - struct exynos_drm_plane plane = ctx->planes[win]; struct exynos_drm_plane_state *state = - to_exynos_plane_state(plane.base.state); + to_exynos_plane_state(plane->base.state); + unsigned int win = state->base.normalized_zpos + ctx->first_win; + struct drm_framebuffer *fb = state->base.fb; unsigned int alpha = state->base.alpha; unsigned int pixel_alpha; unsigned long val; @@ -402,7 +395,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, to_exynos_plane_state(plane->base.state); struct decon_context *ctx = crtc->ctx; struct drm_framebuffer *fb = state->base.fb; - unsigned int win = plane->index; + unsigned int win = state->base.normalized_zpos + ctx->first_win; unsigned int cpp = fb->format->cpp[0]; unsigned int pitch = fb->pitches[0]; dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0); @@ -446,25 +439,24 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, | BIT_VAL(state->crtc.w * cpp, 14, 0); writel(val, ctx->addr + DECON_VIDW0xADD2(win)); - decon_win_set_pixfmt(ctx, win, fb); + decon_win_set_pixfmt(ctx, plane); /* window enable */ decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0); } -static void decon_disable_plane(struct exynos_drm_crtc *crtc, - struct exynos_drm_plane *plane) -{ - struct decon_context *ctx = crtc->ctx; - unsigned int win = plane->index; - - decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, 0); -} - static void decon_atomic_flush(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = crtc->ctx; unsigned long flags; + int win = hweight32(crtc->base.state->plane_mask) + ctx->first_win; + + /* disable windows corresponding to disabled planes */ + for (; win < WINDOWS_NR; ++win) { + if (!readl(ctx->addr + DECON_WINCONx(win)) & WINCONx_ENWIN_F) + break; + decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, 0); + } spin_lock_irqsave(&ctx->vblank_lock, flags); @@ -538,7 +530,7 @@ static void decon_disable(struct exynos_drm_crtc *crtc) * a destroyed buffer later. */ for (i = ctx->first_win; i < WINDOWS_NR; i++) - decon_disable_plane(crtc, &ctx->planes[i]); + decon_set_bits(ctx, DECON_WINCONx(i), WINCONx_ENWIN_F, 0); decon_swreset(ctx); @@ -607,7 +599,6 @@ static const struct exynos_drm_crtc_ops decon_crtc_ops = { .disable_vblank = decon_disable_vblank, .atomic_begin = decon_atomic_begin, .update_plane = decon_update_plane, - .disable_plane = decon_disable_plane, .mode_valid = decon_mode_valid, .atomic_flush = decon_atomic_flush, }; @@ -628,7 +619,9 @@ static int decon_bind(struct device *dev, struct device *master, void *data) ctx->configs[win].num_pixel_formats = ARRAY_SIZE(decon_formats); ctx->configs[win].zpos = win - ctx->first_win; ctx->configs[win].type = decon_win_types[win]; - ctx->configs[win].capabilities = capabilities[win]; + ctx->configs[win].capabilities = EXYNOS_DRM_PLANE_CAP_ZPOS + | EXYNOS_DRM_PLANE_CAP_WIN_BLEND + | EXYNOS_DRM_PLANE_CAP_PIX_BLEND; ret = exynos_plane_init(drm_dev, &ctx->planes[win], win, &ctx->configs[win]);