From patchwork Mon Feb 13 23:43:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: jim.bride@linux.intel.com X-Patchwork-Id: 9570883 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 4333C60572 for ; Mon, 13 Feb 2017 23:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3897627F85 for ; Mon, 13 Feb 2017 23:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D8FB28178; Mon, 13 Feb 2017 23:45:14 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A457127F85 for ; Mon, 13 Feb 2017 23:45:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA7EC6E58F; Mon, 13 Feb 2017 23:45:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D8466E58C for ; Mon, 13 Feb 2017 23:45:10 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 13 Feb 2017 15:45:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,158,1484035200"; d="scan'208";a="933496865" Received: from shiv.jf.intel.com ([10.7.198.83]) by orsmga003.jf.intel.com with ESMTP; 13 Feb 2017 15:45:09 -0800 From: Jim Bride To: intel-gfx@lists.freedesktop.org Date: Mon, 13 Feb 2017 15:43:25 -0800 Message-Id: <1487029408-28483-1-git-send-email-jim.bride@linux.intel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Paulo Zanoni , Rodrigo Vivi Subject: [Intel-gfx] [PATCH I-G-T 1/4] lib: Add PSR utility functions to igt library. 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Factor out some code that was replicated in three test utilities into some new IGT library functions so that we are checking PSR status in a consistent fashion across all of our PSR tests. Cc: Rodrigo Vivi Cc: Paulo Zanoni Signed-off-by: Jim Bride Reviewed-by: Rodrigo Vivi --- lib/Makefile.sources | 2 + lib/igt.h | 1 + lib/igt_psr.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_psr.h | 38 +++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 lib/igt_psr.c create mode 100644 lib/igt_psr.h diff --git a/lib/Makefile.sources b/lib/Makefile.sources index 6348487..0a8835b 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -83,6 +83,8 @@ lib_source_list = \ uwildmat/uwildmat.c \ igt_kmod.c \ igt_kmod.h \ + igt_psr.c \ + igt_psr.h \ $(NULL) if HAVE_CHAMELIUM diff --git a/lib/igt.h b/lib/igt.h index a97923e..7f52d6c 100644 --- a/lib/igt.h +++ b/lib/igt.h @@ -37,6 +37,7 @@ #include "igt_gt.h" #include "igt_kms.h" #include "igt_pm.h" +#include "igt_psr.h" #include "igt_stats.h" #include "igt_chamelium.h" #include "instdone.h" diff --git a/lib/igt_psr.c b/lib/igt_psr.c new file mode 100644 index 0000000..833a9d6 --- /dev/null +++ b/lib/igt_psr.c @@ -0,0 +1,147 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "igt.h" +#include +#include +#include +#include + +/** + * SECTION:igt_psr + * @short_description: Panel Self Refresh helpers + * @title: Panel Self Refresh + * @include: igt.h + * + * This library provides various helpers to enable Panel Self Refresh, + * as well as to check the state of PSR on the system (enabled vs. + * disabled, active vs. inactive) or to wait for PSR to be active + * or inactive. + */ + +/** + * igt_psr_possible: + * + * Returns true if both the source and sink support PSR. + */ +bool igt_psr_possible(void) +{ + char buf[512]; + + igt_debugfs_read("i915_edp_psr_status", buf); + + return strstr(buf, "Source_OK: yes\n") && + strstr(buf, "Sink_Support: yes\n"); +} + +/** + * igt_psr_active: + * + * Returns true if PSR is active on the panel. + */ +bool igt_psr_active(void) +{ + char buf[512]; + bool actret = false; + bool hwactret = false; + + igt_debugfs_read("i915_edp_psr_status", buf); + hwactret = (strstr(buf, "HW Enabled & Active bit: yes\n") != NULL); + actret = (strstr(buf, "Active: yes\n") != NULL); + igt_debug("hwactret: %s actret: %s\n", hwactret ? "true" : "false", + actret ? "true" : "false"); + return hwactret && actret; +} + +/** + * igt_psr_await_status: + * @active: A boolean that causes the function to wait for PSR to activate + * if set to true, or to wait for PSR to deactivate if false. + * + * Returns true if the requested condition is met. + */ +bool igt_psr_await_status(bool active) +{ + const int timeout = 5; + int count = 0; + while (count < timeout) { + if (igt_psr_active() == active) { + igt_debug("PSR %s after %d seconds.\n", + active ? "Active" : "Inactive", count); + return true; + } + count++; + sleep(1); + } + return false; +} + +/** + * igt_psr_enabled: + * + * Returns true if the PSR feature is enabled. + */ +bool igt_psr_enabled(void) +{ + char buf[256]; + + igt_debugfs_read("i915_edp_psr_status", buf); + return strstr(buf, "Enabled: yes\n"); +} + +/** + * igt_psr_print_status: + * + * Dumps the contents of i915_edp_psr_status from debugfs. + */ +void igt_psr_print_status(void) +{ + char buf[256]; + + igt_debugfs_read("i915_edp_psr_status", buf); + igt_info("PSR status:\n%s\n", buf); +} + +/** + * igt_psr_valid_connector: + * @connector: a drmModeConnector pointer to check + * + * Returns true if connector is an eDP connector. + */ +bool igt_psr_valid_connector(drmModeConnectorPtr connector) +{ + return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); +} + +/** + * igt_psr_sink_support: + * + * Returns true if the current eDP panel supports PSR. + */ +bool igt_psr_sink_support(void) +{ + char buf[256]; + + igt_debugfs_read("i915_edp_psr_status", buf); + return strstr(buf, "Sink_Support: yes\n"); +} diff --git a/lib/igt_psr.h b/lib/igt_psr.h new file mode 100644 index 0000000..9625e91 --- /dev/null +++ b/lib/igt_psr.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef IGT_PSR_H +#define IGT_PSR_H + +#define igt_psr_enable() igt_set_module_param_int("enable_psr", 1) +#define igt_psr_disable() igt_set_module_param_int("enable_psr", 0) + +bool igt_psr_possible(void); +bool igt_psr_active(void); +bool igt_psr_await_status(bool active); +bool igt_psr_enabled(void); +void igt_psr_print_status(void); +bool igt_psr_valid_connector(drmModeConnectorPtr connector); +bool igt_psr_sink_support(void); + +#endif /* IGT_PSR_H */