From patchwork Tue Aug 21 07:13:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yadav, Jyoti R" X-Patchwork-Id: 10571111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3814B139B for ; Tue, 21 Aug 2018 07:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2146C29A2D for ; Tue, 21 Aug 2018 07:14:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1412829CB8; Tue, 21 Aug 2018 07:14:55 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 1379129A2D for ; Tue, 21 Aug 2018 07:14:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA21F6E15C; Tue, 21 Aug 2018 07:14:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF72B6E15C; Tue, 21 Aug 2018 07:14:51 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 00:14:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,268,1531810800"; d="scan'208";a="77047717" Received: from vilango-desktop.iind.intel.com ([10.223.25.5]) by orsmga003.jf.intel.com with ESMTP; 21 Aug 2018 00:14:42 -0700 From: Yadav Jyoti To: igt-dev@lists.freedesktop.org Date: Tue, 21 Aug 2018 12:43:42 +0530 Message-Id: <1534835622-26658-1-git-send-email-jyoti.r.yadav@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH i-g-t] [intel-gfx] [igt-dev] tests/pm_backlight.c : Brightness test with DPMS and System suspend. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, vandita.kulkarni@intel.com, rodrigo.vivi@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Jyoti Yadav BIOS programs few of PWM related registers during initial boot. But during System suspend those registers are cleared. This test aims to check whether display programs those registers properly after system resume. Also checks brightness programming during DPMS ON/OFF cycle to check backlight programming is done properly from display side. Signed-off-by: Jyoti Yadav --- tests/pm_backlight.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/tests/pm_backlight.c b/tests/pm_backlight.c index bc1d417..72e23ea 100644 --- a/tests/pm_backlight.c +++ b/tests/pm_backlight.c @@ -90,6 +90,51 @@ static int backlight_write(int value, const char *fname) return 0; } +/* If we want to actually reach PC8+ states, we need to properly configure all + * the devices on the system to allow this. This function will try to setup the + * things we know we need, but won't scream in case anything fails: we don't + * know which devices are present on your machine, so we can't really expect + * anything, just try to help with the more common problems. */ +static void setup_non_graphics_runtime_pm(void) +{ + int fd, i; + char *file_name; + + /* Disk runtime PM policies. */ + file_name = malloc(PATH_MAX); + for (i = 0; ; i++) { + + snprintf(file_name, PATH_MAX, + "/sys/class/scsi_host/host%d/link_power_management_policy", + i); + + fd = open(file_name, O_WRONLY); + if (fd < 0) + break; + + igt_assert(write(fd, "min_power\n", 10) == 10); + close(fd); + } + free(file_name); +} +static void disable_all_screens_dpms(int drm_fd, drmModeResPtr res_ptr) +{ + int i; + for (i = 0; i < res_ptr->count_connectors; i++) { + drmModeConnectorPtr c = drmModeGetConnector(drm_fd, + res_ptr->connectors[i]); + kmstest_set_connector_dpms(drm_fd, c, DRM_MODE_DPMS_OFF); + } +} +static void enable_all_screens_dpms(int drm_fd, drmModeResPtr res_ptr) +{ + int i; + for (i = 0; i < res_ptr->count_connectors; i++) { + drmModeConnectorPtr c = drmModeGetConnector(drm_fd, + res_ptr->connectors[i]); + kmstest_set_connector_dpms(drm_fd, c, DRM_MODE_DPMS_ON); + } +} static void test_and_verify(int val) { @@ -145,9 +190,52 @@ static void test_fade(int max) } } + +static void test_fade_with_dpms(int max , int drm_fd, drmModeResPtr res_ptr) +{ + int i; + static const struct timespec ts = { .tv_sec = 0, .tv_nsec = FADESPEED*1000000 }; + bool has_runtime_pm; + has_runtime_pm = igt_setup_runtime_pm(); + igt_info("Runtime PM support: %d\n", has_runtime_pm); + igt_assert(has_runtime_pm); + disable_all_screens_dpms(drm_fd, res_ptr); + igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED)); + enable_all_screens_dpms(drm_fd, res_ptr); + igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_ACTIVE)); + /* Fade out, then in */ + for (i = max; i > 0; i -= max / FADESTEPS) { + test_and_verify(i); + nanosleep(&ts, NULL); + } + for (i = 0; i <= max; i += max / FADESTEPS) { + test_and_verify(i); + nanosleep(&ts, NULL); + } +} +static void test_fade_with_suspend(int max, int drm_fd, drmModeResPtr res_ptr ) +{ + int i; + static const struct timespec ts = { .tv_sec = 0, .tv_nsec = FADESPEED*1000000 }; + disable_all_screens_dpms(drm_fd, res_ptr); + igt_system_suspend_autoresume(); + igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED)); + + /* Fade out, then in */ + for (i = max; i > 0; i -= max / FADESTEPS) { + test_and_verify(i); + nanosleep(&ts, NULL); + } + for (i = 0; i <= max; i += max / FADESTEPS) { + test_and_verify(i); + nanosleep(&ts, NULL); + } +} + igt_main { - int max, old; + int drm_fd, max, old; + drmModeResPtr res; igt_skip_on_simulation(); @@ -155,6 +243,10 @@ igt_main /* Get the max value and skip the whole test if sysfs interface not available */ igt_skip_on(backlight_read(&old, "brightness")); igt_assert(backlight_read(&max, "max_brightness") > -1); + drm_fd = drm_open_any_master(); + res = drmModeGetResources(drm_fd); + igt_assert(res); + setup_non_graphics_runtime_pm(); } igt_subtest("basic-brightness") @@ -163,9 +255,14 @@ igt_main test_bad_brightness(max); igt_subtest("fade") test_fade(max); + igt_subtest("fade-with-dpms") + test_fade_with_dpms(max, drm_fd, res); + igt_subtest("fade-with-suspend") + test_fade_with_suspend(max, drm_fd, res); igt_fixture { /* Restore old brightness */ backlight_write(old, "brightness"); + drmClose(drm_fd); } }