From patchwork Tue Jul 19 18:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 9238151 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 773A9600CB for ; Tue, 19 Jul 2016 19:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6348226A4D for ; Tue, 19 Jul 2016 19:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5555B26E81; Tue, 19 Jul 2016 19:00:03 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1725626A4D for ; Tue, 19 Jul 2016 19:00:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 059AF6E22B; Tue, 19 Jul 2016 18:59:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE6556E114 for ; Tue, 19 Jul 2016 18:59:41 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id x83so3792798wma.3 for ; Tue, 19 Jul 2016 11:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vGjGpDUMN4oJpMNMEAH46Jd7ZyLIId4VL1mi9kqeeHY=; b=j3XpDh9ryzBvzNLPJYdSuqD0c/rEH/c8OMBu7v7W80SJWlvhoyLVhnkOdU0V0pEFqk s49VF4Vv0ft+0YzhwFIBTH6xrMYx45/SjG7Z35XxCjZKToHKx24kkAdHVqJy10YYAr7S oMBorPpKIPkM0iL+p4lqBCHOVSo1aB0X+hoajZWw9uI5dU+lbvVEjcmp313kTwL7xJG3 kz/GThcJ9KbSLDjMhnOzCWb/X2YR62VrG2h08IJDDh0FixGwnXDgb21sd1MZseJCusI3 XRRm9ra7O2TMMbpGMKpZGVfU00H4YLq2BfTgNAeaYBL+2b93+e+5ViQxB1NpiveC4CkO yKJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vGjGpDUMN4oJpMNMEAH46Jd7ZyLIId4VL1mi9kqeeHY=; b=dO/q8w9kgWS6IhWQCcSUP7r3/sbIRjwgXfeiSDt+XjxqVu+1tlTRuLE44OSFyqM78b Ci6Wc1UO4asTWoydGMPqUbS9+QM/Jkntir5sc85uK55BGW3BKJ8l85JGZ2dy5ZteAeE9 6jTvB5GkvsMP5WDOqPdleRi8FulIgAsnOQdNIMMfrSrHLyyxLyXuTZayfYiv6UfvY+wa spSRlf4cEDVSe9ZUqIaGhqn7ESr7EL52K7p6NQiflCtRFbjR0DLKwMs1K6bWK9ex956p 5RObKgH4ijycByja2lVLOhoB5moFlIaqr3kah6qC8X1LNzc4f+h72exFonrEssRsaQ14 onFg== X-Gm-Message-State: ALyK8tKIoF0tfnsuabvqOtiQVFwx/fk8co6+06/sKu/usdu9U5pM9a2nHVov9kTaca6nIQ== X-Received: by 10.28.176.7 with SMTP id z7mr5930606wme.17.1468954779006; Tue, 19 Jul 2016 11:59:39 -0700 (PDT) Received: from twisty.fritz.box (x4d02e19a.dyn.telefonica.de. [77.2.225.154]) by smtp.gmail.com with ESMTPSA id i8sm7755380wmg.21.2016.07.19.11.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 11:59:38 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm/vc4: Enable precise vblank timestamping for interlaced modes. Date: Tue, 19 Jul 2016 20:59:00 +0200 Message-Id: <1468954741-30993-5-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1468954741-30993-1-git-send-email-mario.kleiner.de@gmail.com> References: <1468954741-30993-1-git-send-email-mario.kleiner.de@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On top of the interlaced video mode fix and with some additional adjustments, this now works well. It has almost the same accuracy as on regular progressive scan modes. Signed-off-by: Mario Kleiner Cc: Eric Anholt --- drivers/gpu/drm/vc4/vc4_crtc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index 2bfa247..7ffdad5 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -163,14 +163,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, int vblank_lines; int ret = 0; - /* - * XXX Doesn't work well in interlaced mode yet, partially due - * to problems in vc4 kms or drm core interlaced mode handling, - * so disable for now in interlaced mode. - */ - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - return ret; - /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */ /* Get optional system timestamp before query. */ @@ -191,10 +183,15 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, /* Vertical position of hvs composed scanline. */ *vpos = VC4_GET_FIELD(val, SCALER_DISPSTATX_LINE); + *hpos = 0; + + if (mode->flags & DRM_MODE_FLAG_INTERLACE) { + *vpos /= 2; - /* No hpos info available. */ - if (hpos) - *hpos = 0; + /* Use hpos to correct for field offset in interlaced mode. */ + if (VC4_GET_FIELD(val, SCALER_DISPSTATX_FRAME_COUNT) % 2) + *hpos += mode->crtc_htotal / 2; + } /* This is the offset we need for translating hvs -> pv scanout pos. */ fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay; @@ -217,8 +214,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, * position of the PV. */ *vpos -= fifo_lines + 1; - if (mode->flags & DRM_MODE_FLAG_INTERLACE) - *vpos /= 2; ret |= DRM_SCANOUTPOS_ACCURATE; return ret;