From patchwork Wed Mar 20 13:07:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10861595 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 1D26417EF for ; Wed, 20 Mar 2019 13:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02E5B28B92 for ; Wed, 20 Mar 2019 13:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB7092838B; Wed, 20 Mar 2019 13:07:24 +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 C8B2B28B92 for ; Wed, 20 Mar 2019 13:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727307AbfCTNHX (ORCPT ); Wed, 20 Mar 2019 09:07:23 -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 S1727415AbfCTNHX (ORCPT ); Wed, 20 Mar 2019 09:07:23 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190320130721euoutp017a83345795bd45b0fbd7926d0a038b90~NrJ4jMY9u0192201922euoutp01i; Wed, 20 Mar 2019 13:07:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190320130721euoutp017a83345795bd45b0fbd7926d0a038b90~NrJ4jMY9u0192201922euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553087241; bh=3XLHoKB/gX6jbQYLpF9D12Y31faiwvzTIy/3lMIsTZA=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=W0kX5MDx/HJN3Kqt0MWnYcsSwRI1sWCFipi4FLyuOG8OAqmDMggfXd30WqfzhcPSH mMldlHxQHyzECr3puHd/MT+r0XqQE7lBVGUASd2QDs6JjRnSt7u5DVviMNVKd0aMgT QC9I6HCZYGZrzdTFJkp19sayXeMsNt79XHU9ZjDw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190320130721eucas1p2c29a9a04be9465f823568b22ca750192~NrJ4MEOEu0212202122eucas1p2k; Wed, 20 Mar 2019 13:07:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FE.35.04441.80B329C5; Wed, 20 Mar 2019 13:07:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190320130720eucas1p1f2b27e5d340a50dc710155b37e7b173b~NrJ3ljATu2302523025eucas1p1E; Wed, 20 Mar 2019 13:07:20 +0000 (GMT) X-AuditID: cbfec7f2-5c9ff70000001159-bb-5c923b08d1af Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FE.DA.04128.80B329C5; Wed, 20 Mar 2019 13:07:20 +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:20 +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 21/24] drm/exynos/decon5433: add local path support Date: Wed, 20 Mar 2019 14:07:04 +0100 Message-id: <20190320130707.25161-22-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+NgFprFIsWRmVeSWpSXmKPExsWy7djP87oc1pNiDN4vsLG4te4cq8XGGetZ La58fc9mMen+BBaL8+c3sFvMOL+PyWLtkbvsDuwem1Z1snnc7z7O5NG3ZRWjx+dNcgEsUVw2 Kak5mWWpRfp2CVwZf3dMYS2YZFzx91EfWwPjBq0uRk4OCQETicbjl5m6GLk4hARWMEo8vL6O EcL5zCjxfPF2Fpiq9Q3foKqWMUq8mD6LDcL5zyix/+47NpAqNgFNib+bb4LZIgLKEqv2tbOD FDEL/GaUmL58GztIQljAX+JEUw9YEYuAqsS3WY/AVvAKWEpMnfmKDWKdvMTqDQeYQWxOoPjD Of/BBkkINLJJbH5/ixmiyEXi2+tmJghbRuLy5G6oW+sl7q9oYYZo6GCU2LphJ1SDtcTh4xdZ QWxmAT6JSdumA8U5gOK8Eh1tQhAlHhIr/0+Heq2HUWLj+2PsExglFjAyrGIUTy0tzk1PLTbM Sy3XK07MLS7NS9dLzs/dxAiMsdP/jn/awfj1UtIhRgEORiUe3oY3E2KEWBPLiitzDzFKcDAr ifBGKE2KEeJNSaysSi3Kjy8qzUktPsQozcGiJM5bzfAgWkggPbEkNTs1tSC1CCbLxMEp1cC4 Mkro2TumylDTjylK7l2dH1lFj3a2zviziLfh+ndvCyepCe9iNjx3033a+SZMpfZx94mPvud1 H8ob+j27OsvziM+/s6ouTbEiQUHPFp6/PlE3Zhlv1LRlPi1BSWs0okNurHl87fvcn++Vt0wK 6Tjyh0/L8/ADg8P5nHzpu123bl+X3PiAw61YiaU4I9FQi7moOBEAwTxVWK0CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4ZV0O60kxBltmaVjcWneO1WLjjPWs Fle+vmezmHR/AovF+fMb2C1mnN/HZLH2yF12B3aPTas62Tzudx9n8ujbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MvzumsBZMMq74+6iPrYFxg1YXIyeHhICJxPqGb0xdjFwcQgJLGCUm7l3M COE0Mkn8XbqIBaSKTUBT4u/mm2wgtoiAssSqfe3sIEXMAr8ZJT7P+MoMkhAW8JVYvryVFcRm EVCV+DbrEVgzr4ClxNSZr9gg1slLrN5wAKyeEyj+cM5/dhBbSMBCYvGJu4wTGHkWMDKsYhRJ LS3OTc8tNtIrTswtLs1L10vOz93ECAyabcd+btnB2PUu+BCjAAejEg9vxdMJMUKsiWXFlbmH GCU4mJVEeCOUJsUI8aYkVlalFuXHF5XmpBYfYpTmYFES5z1vUBklJJCeWJKanZpakFoEk2Xi 4JRqYLRte7J88S6Rm1/Omh4+MfNTidxmsdUXnH7ffiUXG2sV/kDnkdFtSznpC3kvZGff+7h/ WSFfsvYp7xthqpP9EwXX3+pdWmRmu8CnNMyO48vsoElnjUWdl2wRndWY9DFo2vz7EY+E3l0t 27nIz0lqoufa5OJjL5YufuO46ULv7/NqVUmRn1qcMhiUWIozEg21mIuKEwFY3WtLFgIAAA== X-CMS-MailID: 20190320130720eucas1p1f2b27e5d340a50dc710155b37e7b173b CMS-TYPE: 201P X-CMS-RootMailID: 20190320130720eucas1p1f2b27e5d340a50dc710155b37e7b173b 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 GSCALERs in Exynos5433 have local path to DECON and DECON_TV. They can be used as extra planes with support for non-RGB formats and scaling. To enable it on DECON update_plane and disable_plane callback should be modified. Moreover DSD mux should be set accordingly, and finally atomic_check callback should be used to limit the number of active planes. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 80 +++++++++++++++---- drivers/gpu/drm/exynos/regs-decon5433.h | 6 ++ 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 958972e3ee1e..b0332763594e 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -26,6 +26,10 @@ #include "exynos_drm_fb.h" #include "regs-decon5433.h" +#define DSD_CFG 0x1000 +#define DSD_CFG_GSCL_MODE(gsc, decon, wb) (((wb) << 1) | decon) << (3 + ((gsc) << 1)) +#define DSD_CFG_GSCL_MODE_MASK(gsc) DSD_CFG_GSCL_MODE(gsc, 1, 1) + #define DSD_CFG_MUX 0x1004 #define DSD_CFG_MUX_TE_UNMASK_GLOBAL BIT(13) @@ -47,6 +51,7 @@ static const char * const decon_clks_name[] = { "pclk_smmu_decon1x", "sclk_decon_vclk", "sclk_decon_eclk", + "dsd" }; struct decon_context { @@ -370,11 +375,40 @@ static void decon_shadow_protect(struct decon_context *ctx, bool protect) protect ? ~0 : 0); } +static int decon_atomic_check(struct exynos_drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct decon_context *ctx = to_decon(crtc); + + if (hweight32(state->plane_mask) > WINDOWS_NR - ctx->first_win) + return -EINVAL; + return 0; +} + +static void decon_set_gscl_mode(struct decon_context *ctx) +{ + u32 plane_mask = ctx->crtc.base.state->plane_mask; + struct drm_plane *bplane; + u32 mask = 0, val = 0; + bool decon_id = ctx->out_type & IFTYPE_HDMI; + + drm_for_each_plane_mask(bplane, ctx->drm_dev, plane_mask) { + struct exynos_drm_plane *plane = to_exynos_plane(bplane); + + if (!(plane->capabilities & EXYNOS_DRM_PLANE_CAP_GSCALER)) + continue; + mask |= DSD_CFG_GSCL_MODE_MASK(plane->index); + val |= DSD_CFG_GSCL_MODE(plane->index, decon_id, 0); + } + regmap_update_bits(ctx->sysreg, DSD_CFG, mask, val); +} + static void decon_atomic_begin(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = to_decon(crtc); decon_shadow_protect(ctx, true); + decon_set_gscl_mode(ctx); } #define BIT_VAL(x, e, s) (((x) & ((1 << ((e) - (s) + 1)) - 1)) << (s)) @@ -394,6 +428,9 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0); u32 val; + if (plane->ops && plane->ops->update_plane) + plane->ops->update_plane(plane); + if (crtc->base.mode.flags & DRM_MODE_FLAG_INTERLACE) { val = COORDINATE_X(state->crtc.x) | COORDINATE_Y(state->crtc.y / 2); @@ -419,25 +456,38 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, VIDOSD_Wx_ALPHA_B_F(0x0); writel(val, ctx->addr + DECON_VIDOSDxD(win)); - writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win)); - - val = dma_addr + pitch * state->src.h; - writel(val, ctx->addr + DECON_VIDW0xADD1B0(win)); - - if (!(ctx->out_type & IFTYPE_HDMI)) - val = BIT_VAL(pitch - state->crtc.w * cpp, 27, 14) - | BIT_VAL(state->crtc.w * cpp, 13, 0); - else - val = BIT_VAL(pitch - state->crtc.w * cpp, 29, 15) - | BIT_VAL(state->crtc.w * cpp, 14, 0); - writel(val, ctx->addr + DECON_VIDW0xADD2(win)); - decon_win_set_pixfmt(ctx, plane); + if (plane->capabilities & EXYNOS_DRM_PLANE_CAP_GSCALER) { + writel(UPDATE_SCHEME_OTF_PER_FRAME, + ctx->addr + DECON_UPDATE_SCHEME); + decon_set_bits(ctx, DECON_WINCONx(win), + WINCONx_ENLOCAL_F | WINCONx_LOCALSEL_MASK, + WINCONx_ENLOCAL_F | WINCONx_LOCALSEL_F(plane->index)); + } else { + writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win)); + val = dma_addr + pitch * state->src.h; + writel(val, ctx->addr + DECON_VIDW0xADD1B0(win)); + if (!(ctx->out_type & IFTYPE_HDMI)) + val = BIT_VAL(pitch - state->crtc.w * cpp, 27, 14) + | BIT_VAL(state->crtc.w * cpp, 13, 0); + else + val = BIT_VAL(pitch - state->crtc.w * cpp, 29, 15) + | BIT_VAL(state->crtc.w * cpp, 14, 0); + writel(val, ctx->addr + DECON_VIDW0xADD2(win)); + } + /* 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) +{ + if (plane->ops && plane->ops->disable_plane) + plane->ops->disable_plane(plane); +} + static void decon_atomic_flush(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = to_decon(crtc); @@ -448,7 +498,7 @@ static void decon_atomic_flush(struct exynos_drm_crtc *crtc) 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); + writel(0, ctx->addr + DECON_WINCONx(win)); } spin_lock_irqsave(&ctx->vblank_lock, flags); @@ -590,8 +640,10 @@ static const struct exynos_drm_crtc_ops decon_crtc_ops = { .disable = decon_disable, .enable_vblank = decon_enable_vblank, .disable_vblank = decon_disable_vblank, + .atomic_check = decon_atomic_check, .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, }; diff --git a/drivers/gpu/drm/exynos/regs-decon5433.h b/drivers/gpu/drm/exynos/regs-decon5433.h index 63db6974bf14..21a1c0bdd10a 100644 --- a/drivers/gpu/drm/exynos/regs-decon5433.h +++ b/drivers/gpu/drm/exynos/regs-decon5433.h @@ -98,6 +98,9 @@ #define VIDOUT_COMMAND_IF (0x2 << 20) /* WINCONx */ +#define WINCONx_LOCALSEL_F(n) ((n) << 21) +#define WINCONx_LOCALSEL_MASK (0x3 << 21) +#define WINCONx_ENLOCAL_F (0x1 << 20) #define WINCONx_HAWSWP_F (1 << 16) #define WINCONx_WSWP_F (1 << 15) #define WINCONx_BURSTLEN_MASK (0x3 << 10) @@ -184,6 +187,9 @@ #define VIDTCON2_LINEVAL(x) (((x) & 0xfff) << 16) #define VIDTCON2_HOZVAL(x) ((x) & 0xfff) +/* DECON_UPDATE_SCHEME */ +#define UPDATE_SCHEME_OTF_PER_FRAME (1 << 31) + /* TRIGCON */ #define TRIGCON_TRIGEN_PER_F (1 << 31) #define TRIGCON_TRIGEN_F (1 << 30)