From patchwork Thu Jul 7 15:06:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 9219101 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 1B9F160B16 for ; Thu, 7 Jul 2016 15:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B64027BF8 for ; Thu, 7 Jul 2016 15:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F382D27F54; Thu, 7 Jul 2016 15:06:50 +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_SIGNED, 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 785F427E5A for ; Thu, 7 Jul 2016 15:06:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 413FA6E7FC; Thu, 7 Jul 2016 15:06:45 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@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 46AA56E7F7; Thu, 7 Jul 2016 15:06:42 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id a66so6129524wme.2; Thu, 07 Jul 2016 08:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q0mQHY+M7wnlaL/LWFJhnrhrmzY17ZIgoNqxtklJ2JQ=; b=dOYOgvEIlV8VklEnymOqwpke2dZcPXGNVKicXj7JpvkEIzy0Yq+axrjLtuSWt+Npqs k9uCunJmBG4ag438EDeHCqdncoKLOk+5X6Ubjb3/i9Cfm2yqazc2LAMGkCzLAsNkBsMj kkF5Ke4wkxu4zCTbFB8efFAujCmDAsAh4w2QdRVjgTGu5dGt/plzn+Vahb7HgrQ2uxfR YW8McgDdVEFZ3CEYwwa2h18Z4QyepxDddiHI7qZzgSSW3zrBxyJG5Ukc7o8qXkkreJ+v RfcmlL3C4I8ThtnbQEITO6f73QYv4GPNF+vYvzw23xP2AEjViXGni2G1rUYmfyWCjqW9 67Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Q0mQHY+M7wnlaL/LWFJhnrhrmzY17ZIgoNqxtklJ2JQ=; b=ij7CbtfcMWt2tB7bgEXaYnTSJJjJHGp5OvM4ZS67h4Wj0sWYjDRW8uE4lQnrelcj7m gV/kRDMkABr1syn7Xceyvl0YUw4syMJR0lYrxzIFowPwUi948LgHjhXCOVgvz/il0jvy UKH9/QwMVnAtP5GhS3bgcptywRsFlYxIVidBOrMK0pS5kM4zURY6m3xLCgGJDSiHqcP5 4iiGlmb1T1YiPwArkPw5hRQ4egoW0t0fLFSgqatYX9IkRAQ8K3Qz9/1TpuzZzESV2JGZ zub+1+YiFlP6YaGlFZ9avHUTwqiT4JASQMCPfUmVbxa5y6e1nI9/xCgtEGHRwmXsjcho JSig== X-Gm-Message-State: ALyK8tI0DHsDT4azKVgr3KPSVEbUvzuZKIgTPenuV7cyh2gJCPZXoYSzYSyXDaiWfkuRWg== X-Received: by 10.194.69.3 with SMTP id a3mr601322wju.61.1467904000513; Thu, 07 Jul 2016 08:06:40 -0700 (PDT) Received: from cizrna.lan ([109.72.12.120]) by smtp.gmail.com with ESMTPSA id kr4sm3019394wjc.27.2016.07.07.08.06.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 08:06:39 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Date: Thu, 7 Jul 2016 17:06:09 +0200 Message-Id: <1467903970-10590-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467903970-10590-1-git-send-email-tomeu.vizoso@collabora.com> References: <1467903970-10590-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Tomeu Vizoso , David Airlie , intel-gfx@lists.freedesktop.org, Thierry Reding , dri-devel@lists.freedesktop.org, Daniel Vetter , Emil Velikov Subject: [Intel-gfx] [PATCH v2 3/3] drm/i915: Use new CRC debugfs API X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The core provides now an ABI to userspace for generation of frame CRCs, so implement the ->set_crc_source() callback and reuse as much code as possible with the previous ABI implementation. v2: - Leave the legacy implementation in place as the ABI implementation in the core is incompatible with it. Signed-off-by: Tomeu Vizoso --- drivers/gpu/drm/i915/i915_irq.c | 57 ++++++++++++++++++++--------------- drivers/gpu/drm/i915/intel_display.c | 1 + drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_pipe_crc.c | 17 +++++++++++ 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index b77d808b71cd..1c5c6bdbb66c 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1492,41 +1492,48 @@ static void display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, { struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; struct intel_pipe_crc_entry *entry; + struct drm_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe); + struct drm_driver *driver = dev_priv->drm.driver; + uint32_t frame = driver->get_vblank_counter(&dev_priv->drm, pipe); int head, tail; - spin_lock(&pipe_crc->lock); + if (pipe_crc->opened) { + spin_lock(&pipe_crc->lock); - if (!pipe_crc->entries) { - spin_unlock(&pipe_crc->lock); - DRM_DEBUG_KMS("spurious interrupt\n"); - return; - } + if (!pipe_crc->entries) { + spin_unlock(&pipe_crc->lock); + DRM_DEBUG_KMS("spurious interrupt\n"); + return; + } - head = pipe_crc->head; - tail = pipe_crc->tail; + head = pipe_crc->head; + tail = pipe_crc->tail; - if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { - spin_unlock(&pipe_crc->lock); - DRM_ERROR("CRC buffer overflowing\n"); - return; - } + if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { + spin_unlock(&pipe_crc->lock); + DRM_ERROR("CRC buffer overflowing\n"); + return; + } - entry = &pipe_crc->entries[head]; + entry = &pipe_crc->entries[head]; - entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm, - pipe); - entry->crc[0] = crc0; - entry->crc[1] = crc1; - entry->crc[2] = crc2; - entry->crc[3] = crc3; - entry->crc[4] = crc4; + entry->frame = frame; + entry->crc[0] = crc0; + entry->crc[1] = crc1; + entry->crc[2] = crc2; + entry->crc[3] = crc3; + entry->crc[4] = crc4; - head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); - pipe_crc->head = head; + head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); + pipe_crc->head = head; - spin_unlock(&pipe_crc->lock); + spin_unlock(&pipe_crc->lock); - wake_up_interruptible(&pipe_crc->wq); + wake_up_interruptible(&pipe_crc->wq); + } else { + drm_crtc_add_crc_entry(crtc, frame, crc0, crc1, crc2, crc3, + crc4); + } } #else static inline void diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 111b350d1d7e..d91a2f779fb1 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -14019,6 +14019,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { .page_flip = intel_crtc_page_flip, .atomic_duplicate_state = intel_crtc_duplicate_state, .atomic_destroy_state = intel_crtc_destroy_state, + .set_crc_source = intel_crtc_set_crc_source, }; /** diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 5d06cb2425a1..4cd8689afe90 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1782,6 +1782,7 @@ void intel_color_load_luts(struct drm_crtc_state *crtc_state); /* intel_pipe_crc.c */ int intel_pipe_crc_create(struct drm_minor *minor); void intel_pipe_crc_cleanup(struct drm_minor *minor); +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name); extern const struct file_operations i915_display_crc_ctl_fops; #endif /* __INTEL_DRV_H__ */ diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c index 590e909bcf1b..51047ad37ffa 100644 --- a/drivers/gpu/drm/i915/intel_pipe_crc.c +++ b/drivers/gpu/drm/i915/intel_pipe_crc.c @@ -823,6 +823,11 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s) { int i; + if (!buf) { + *s = INTEL_PIPE_CRC_SOURCE_NONE; + return 0; + } + for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++) if (!strcmp(buf, pipe_crc_sources[i])) { *s = i; @@ -951,3 +956,15 @@ void intel_pipe_crc_cleanup(struct drm_minor *minor) drm_debugfs_remove_files(info_list, 1, minor); } } + +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name) +{ + enum intel_pipe_crc_source source; + + if (display_crc_ctl_parse_source(source_name, &source) < 0) { + DRM_DEBUG_DRIVER("unknown source %s\n", source_name); + return -EINVAL; + } + + return pipe_crc_set_source(crtc->dev, crtc->index, source); +}