From patchwork Tue Jul 19 18:58:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 9238159 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 B22D9600CB for ; Tue, 19 Jul 2016 19:01:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F3C226A4D for ; Tue, 19 Jul 2016 19:01:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 941FB26E81; Tue, 19 Jul 2016 19:01:15 +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 1376A26A4D for ; Tue, 19 Jul 2016 19:01:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7409F6E6DF; Tue, 19 Jul 2016 19:01:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 321A66E024 for ; Tue, 19 Jul 2016 18:59:37 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id o80so3820745wme.0 for ; Tue, 19 Jul 2016 11:59:37 -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=wwomj/nt3Y2/zeg2mVbuXjZYGL+AJ02ho1qidhA3LZY=; b=fN6VaMCYUN87qomafiNTRVf8A8zNL3+yRCAoJmNFukJ73jxy2y/wpaJMbV2kAwAKfI ClN17T2lM4d+z3cIGOlJpx7lBZb+RfTzcGZnOMDWmEMcVyLQ4A6hTyPRLARnh1wukIPq z/bsMOLy9p6rmxaL6dkZpj77Up0P/Dls/NzyBLPQZnlQiYap+CsLn/4rI8ho93jysbh8 G4441laeypmGk+B7LMmCAev9+A1+EqkxOYXPIyzBimlu/wnM97xxouw9glL3X+gkYqRH YS0qW4UOIN+HiidyTX+0Mwx1qHrL8ft0mnpwaRpU6+bf6oDE33zC74JWq2TxlgmOcRqo xm2Q== 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=wwomj/nt3Y2/zeg2mVbuXjZYGL+AJ02ho1qidhA3LZY=; b=LPyD/LE0xTnUYjKJF/yzDTkMVeuI/SigpdZEe9UdUA+YJcuLwbIrN6jN+hdjJkRah0 oWXO9uT030kzyhHZhOkHG30E0RU52/S8aWHb2jmkT3hp4VKmIF111E4zS124eVeQfOjO OXV3mItcmQvZ69PvNS3wFkcHldn/EG19sbrKf2q4dVGPWXzzAWfjnWHHncFSTlXv1kLl Hysd+F0py07k4eF/RB8t4VXYuwju+bwoBet4vis+xJh2+paKhhAMRRkODCuzVJI13ecX +Sow9mY3g72RI6PBViQ3llR96gdVC8xUMCEol1MpgDn/7OHx2tAxvLhSKL2uA+kd+CVw Q+FA== X-Gm-Message-State: ALyK8tI3wp83NDGpqWovT3XHHqJykieMoX6C7bMsHTGHDxX3LFXg8VcgIlSWeA82yRdelQ== X-Received: by 10.28.103.6 with SMTP id b6mr6462124wmc.89.1468954774362; Tue, 19 Jul 2016 11:59:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 11:59:33 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/vc4: Fix handling of interlaced video modes. Date: Tue, 19 Jul 2016 20:58:58 +0200 Message-Id: <1468954741-30993-3-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 We must not apply CRTC_INTERLACE_HALVE_V to interlaced modes during mode enumeration, as drm_helper_probe_single_connector_modes does, so wrap it and reset the effect of CRTC_INTERLACE_HALVE_V on affected interlaced modes. Also mode_fixup interlaced modes passed in from user space. This fixes the vblank timestamping constants and entries in the mode->crtc_xxx fields needed for precise vblank timestamping. Signed-off-by: Mario Kleiner Cc: Eric Anholt --- drivers/gpu/drm/vc4/vc4_crtc.c | 18 ++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index 8fc2b73..a479d3d 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -532,6 +532,23 @@ static void vc4_crtc_enable(struct drm_crtc *crtc) CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN); } +static bool vc4_crtc_mode_fixup(struct drm_crtc *crtc, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + /* + * Interlaced video modes got CRTC_INTERLACE_HALVE_V applied when + * coming from user space. We don't want this, as it screws up + * vblank timestamping, so fix it up. + */ + drm_mode_set_crtcinfo(adjusted_mode, 0); + + DRM_DEBUG_KMS("[CRTC:%d] adjusted_mode :\n", crtc->base.id); + drm_mode_debug_printmodeline(adjusted_mode); + + return true; +} + static int vc4_crtc_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { @@ -819,6 +836,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = { .mode_set_nofb = vc4_crtc_mode_set_nofb, .disable = vc4_crtc_disable, .enable = vc4_crtc_enable, + .mode_fixup = vc4_crtc_mode_fixup, .atomic_check = vc4_crtc_atomic_check, .atomic_flush = vc4_crtc_atomic_flush, }; diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 4452f36..68ad106 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -208,10 +208,35 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) return ret; } +/* + * drm_helper_probe_single_connector_modes() applies drm_mode_set_crtcinfo to + * all modes with flag CRTC_INTERLACE_HALVE_V. We don't want this, as it + * screws up vblank timestamping for interlaced modes, so fix it up. + */ +static int vc4_hdmi_connector_probe_modes(struct drm_connector *connector, + uint32_t maxX, uint32_t maxY) +{ + struct drm_display_mode *mode; + int count; + + count = drm_helper_probe_single_connector_modes(connector, maxX, maxY); + if (count == 0) + return 0; + + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed adapted modes :\n", + connector->base.id, connector->name); + list_for_each_entry(mode, &connector->modes, head) { + drm_mode_set_crtcinfo(mode, 0); + drm_mode_debug_printmodeline(mode); + } + + return count; +} + static const struct drm_connector_funcs vc4_hdmi_connector_funcs = { .dpms = drm_atomic_helper_connector_dpms, .detect = vc4_hdmi_connector_detect, - .fill_modes = drm_helper_probe_single_connector_modes, + .fill_modes = vc4_hdmi_connector_probe_modes, .destroy = vc4_hdmi_connector_destroy, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, @@ -246,7 +271,7 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev, connector->polled = (DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT); - connector->interlace_allowed = 0; + connector->interlace_allowed = 1; connector->doublescan_allowed = 0; drm_mode_connector_attach_encoder(connector, encoder);