From patchwork Thu Mar 2 08:35:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 9599719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6058260429 for ; Thu, 2 Mar 2017 08:48:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB7D28543 for ; Thu, 2 Mar 2017 08:48:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FDB228585; Thu, 2 Mar 2017 08:48:36 +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=-6.9 required=2.0 tests=BAYES_00,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 90E0028543 for ; Thu, 2 Mar 2017 08:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754237AbdCBIsf (ORCPT ); Thu, 2 Mar 2017 03:48:35 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:25834 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754019AbdCBIsd (ORCPT ); Thu, 2 Mar 2017 03:48:33 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OM600ACZIJI2Y60@mailout1.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 02 Mar 2017 08:35:42 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170302083541eucas1p281cc7b591c7aa3f86085f649fdf34c0a~oA7JsmWtS1533615336eucas1p26; Thu, 2 Mar 2017 08:35:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 67.05.09557.D59D7B85; Thu, 2 Mar 2017 08:35:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170302083541eucas1p13c1c1f247f06714e6cf4b5732b22dc49~oA7JFBopw2739327393eucas1p1Z; Thu, 2 Mar 2017 08:35:41 +0000 (GMT) X-AuditID: cbfec7f2-f790f6d000002555-f7-58b7d95dcfec Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 93.89.06687.8B9D7B85; Thu, 2 Mar 2017 08:37:12 +0000 (GMT) Received: from AMDC2768.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 <0OM6009FRIJGR510@eusync3.samsung.com>; Thu, 02 Mar 2017 08:35:40 +0000 (GMT) From: Andrzej Hajda To: Inki Dae , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski Subject: [PATCH] drm/exynos/decon5433: implement frame counter Date: Thu, 02 Mar 2017 09:35:36 +0100 Message-id: <1488443736-5287-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRmVeSWpSXmKPExsWy7djPc7qxN7dHGKyaL21xa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lbHy4jTGgtc6FVefnWFtYJyg2sX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mScwci9gZFjFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGHzbjv3cvIPx0sbg Q4wCHIxKPLwHmLZHCLEmlhVX5h5ilOBgVhLhlTwCFOJNSaysSi3Kjy8qzUktPsRoCrR7IrOU aHI+MDLySuINTQzNLQ2NjC0szI2MlMR5Sz5cCRcSSE8sSc1OTS1ILYLpY+LglGpgVKoX5Ipa vN3p/NJuD67jkyZwmTTc33gh/tBun0r7yotfzGp5Ty2ZL55sJcW+bWXJgfwlE5wsK1c7rzA1 mHyxR/bBpbuTs7I4rZdyqs+16+v5M3FFQceS8lbZVyar/V1VGn8lahdwr3cNlr7jfuWhzcxL D0y/L1D8ERDs8+ua4/RDn3mMtqrUKbEUZyQaajEXFScCADnfsihUAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170302083541eucas1p13c1c1f247f06714e6cf4b5732b22dc49 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRvsgrw=?= =?UTF-8?B?7ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRtTYW1z?= =?UTF-8?B?dW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170302083541eucas1p13c1c1f247f06714e6cf4b5732b22dc49 X-RootMTR: 20170302083541eucas1p13c1c1f247f06714e6cf4b5732b22dc49 References: 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 in Exynos5433 has frame counter, it can be used to implement get_vblank_counter callback. Signed-off-by: Andrzej Hajda --- Hi Inki, The patch is based on my last patches, maybe to make it clear I will resend all these patches in one patchset, what do you think? Regards Andrzej drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 76 ++++++++++++++++++--------- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 11 ++++ drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 4b596dc..4b5af67 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -123,6 +123,53 @@ static void decon_disable_vblank(struct exynos_drm_crtc *crtc) writel(0, ctx->addr + DECON_VIDINTCON0); } +/* return number of starts/ends of frame transmissions since reset */ +static u32 decon_get_frame_count(struct decon_context *ctx, bool end) +{ + u32 frm, pfrm, status, cnt; + + /* To get consistent result repeat read until frame id is stable. */ + frm = readl(ctx->addr + DECON_CRFMID); + cnt = 3; + do { + status = readl(ctx->addr + DECON_VIDCON1); + pfrm = frm; + frm = readl(ctx->addr + DECON_CRFMID); + } while (frm != pfrm && --cnt); + + /* CRFMID is incremented on BPORCH in case of I80 and on VSYNC in case + * of RGB, it should be taken into account. + */ + if (!frm) + return 0; + + switch (status & (VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE)) { + case VIDCON1_VSTATUS_VS: + if (!(ctx->out_type & IFTYPE_I80)) + --frm; + break; + case VIDCON1_VSTATUS_BP: + --frm; + break; + case VIDCON1_I80_ACTIVE: + case VIDCON1_VSTATUS_AC: + if (end) + --frm; + } + + return frm; +} + +static u32 decon_get_vblank_counter(struct exynos_drm_crtc *crtc) +{ + struct decon_context *ctx = crtc->ctx; + + if (test_bit(BIT_SUSPENDED, &ctx->flags)) + return 0; + + return decon_get_frame_count(ctx, false); +} + static void decon_setup_trigger(struct decon_context *ctx) { if (!(ctx->out_type & (IFTYPE_I80 | I80_HW_TRG))) @@ -518,6 +565,7 @@ static const struct exynos_drm_crtc_ops decon_crtc_ops = { .enable = decon_enable, .disable = decon_disable, .enable_vblank = decon_enable_vblank, + .get_vblank_counter = decon_get_vblank_counter, .disable_vblank = decon_disable_vblank, .atomic_begin = decon_atomic_begin, .update_plane = decon_update_plane, @@ -536,6 +584,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data) int ret; ctx->drm_dev = drm_dev; + drm_dev->max_vblank_count = 0xffffffff; for (win = ctx->first_win; win < WINDOWS_NR; win++) { int tmp = (win == ctx->first_win) ? 0 : win; @@ -581,34 +630,11 @@ static const struct component_ops decon_component_ops = { static void decon_handle_vblank(struct decon_context *ctx) { - u32 frm, pfrm, status, cnt; + u32 frm; spin_lock(&ctx->vblank_lock); - /* To get consistent result repeat read until frame id is stable. */ - frm = readl(ctx->addr + DECON_CRFMID); - cnt = 3; - do { - status = readl(ctx->addr + DECON_VIDCON1); - pfrm = frm; - frm = readl(ctx->addr + DECON_CRFMID); - } while (frm != pfrm && --cnt); - - status &= VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE; - - /* In case of delayed vblank CRFMID could be already incremented, - * it should be taken into account. - */ - if (frm > 0) - switch (status) { - case VIDCON1_VSTATUS_VS: - if (ctx->out_type & IFTYPE_I80) - break; - case VIDCON1_I80_ACTIVE: - case VIDCON1_VSTATUS_BP: - case VIDCON1_VSTATUS_AC: - --frm; - } + frm = decon_get_frame_count(ctx, true); if (frm != ctx->frame_id) { if (frm > ctx->frame_id) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 0c9a775..d72777f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -132,6 +132,16 @@ static void exynos_drm_crtc_disable_vblank(struct drm_crtc *crtc) exynos_crtc->ops->disable_vblank(exynos_crtc); } +static u32 exynos_drm_crtc_get_vblank_counter(struct drm_crtc *crtc) +{ + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); + + if (exynos_crtc->ops->get_vblank_counter) + return exynos_crtc->ops->get_vblank_counter(exynos_crtc); + + return 0; +} + static const struct drm_crtc_funcs exynos_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .page_flip = drm_atomic_helper_page_flip, @@ -141,6 +151,7 @@ static const struct drm_crtc_funcs exynos_crtc_funcs = { .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, .enable_vblank = exynos_drm_crtc_enable_vblank, .disable_vblank = exynos_drm_crtc_disable_vblank, + .get_vblank_counter = exynos_drm_crtc_get_vblank_counter, }; struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index e52f70a..527bf1d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -131,6 +131,7 @@ struct exynos_drm_crtc_ops { void (*disable)(struct exynos_drm_crtc *crtc); int (*enable_vblank)(struct exynos_drm_crtc *crtc); void (*disable_vblank)(struct exynos_drm_crtc *crtc); + u32 (*get_vblank_counter)(struct exynos_drm_crtc *crtc); int (*atomic_check)(struct exynos_drm_crtc *crtc, struct drm_crtc_state *state); void (*atomic_begin)(struct exynos_drm_crtc *crtc);