From patchwork Wed Dec 7 11:42:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marta Lofstedt X-Patchwork-Id: 9464353 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 B3D9F60236 for ; Wed, 7 Dec 2016 11:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90CF828422 for ; Wed, 7 Dec 2016 11:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81C992849D; Wed, 7 Dec 2016 11:39:48 +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 E6A0628422 for ; Wed, 7 Dec 2016 11:39:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E89376E55E; Wed, 7 Dec 2016 11:39:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AA9B6E55D for ; Wed, 7 Dec 2016 11:39:46 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 07 Dec 2016 03:39:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="795255007" Received: from mlofsted-desk.fi.intel.com ([10.237.72.104]) by FMSMGA003.fm.intel.com with ESMTP; 07 Dec 2016 03:39:44 -0800 From: Marta Lofstedt To: intel-gfx@lists.freedesktop.org Date: Wed, 7 Dec 2016 13:42:59 +0200 Message-Id: <20161207114259.24706-1-marta.lofstedt@intel.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH RFC i-g-t] igt: Add a dpms property test 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 This testcase will set the dpms drm property to DRM_MODE_DPMS_ON and DPMS_MODE_OFF and check that the property values was updated and that the new state corresponds to the crtc active property. Signed-off-by: Marta Lofstedt --- tests/Makefile.sources | 1 + tests/drm_dpms.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 tests/drm_dpms.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 04dd2d5..6d6e3db 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -14,6 +14,7 @@ VC4_TESTS_M = \ TESTS_progs_M = \ core_get_client_auth \ drm_mm \ + drm_dpms \ drv_getparams_basic \ drv_selftest \ drv_suspend \ diff --git a/tests/drm_dpms.c b/tests/drm_dpms.c new file mode 100644 index 0000000..0175e7b --- /dev/null +++ b/tests/drm_dpms.c @@ -0,0 +1,168 @@ +/* + * Copyright © 2016 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" + +static void prepare_pipe(igt_display_t *display, enum pipe pipe, + igt_output_t *output, struct igt_fb *fb) +{ + drmModeModeInfo *mode = igt_output_get_mode(output); + + igt_create_pattern_fb(display->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + LOCAL_DRM_FORMAT_MOD_NONE, + fb); + + igt_output_set_pipe(output, pipe); + + igt_plane_set_fb(igt_output_get_plane(output, IGT_PLANE_PRIMARY), fb); + + igt_display_commit2(display, + display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); +} + +static void cleanup_pipe(igt_display_t *display, enum pipe pipe, + igt_output_t *output, struct igt_fb *fb) +{ + igt_plane_t *plane; + + for_each_plane_on_pipe(display, pipe, plane) + igt_plane_set_fb(plane, NULL); + + igt_output_set_pipe(output, PIPE_NONE); + + igt_display_commit2(display, + display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); + + igt_remove_fb(display->drm_fd, fb); +} + +static void test_dpms(igt_display_t *display, drmModeConnector *connector, + int crtc_id) +{ + uint64_t dpms_state, active; + + kmstest_get_property(display->drm_fd, connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "DPMS", + NULL, &dpms_state, NULL); + + if (dpms_state == DRM_MODE_DPMS_OFF) { + kmstest_set_connector_dpms(display->drm_fd, connector, + DRM_MODE_DPMS_ON); + kmstest_get_property(display->drm_fd, connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "DPMS", + NULL, &dpms_state, NULL); + igt_assert_eq(dpms_state, DRM_MODE_DPMS_ON); + kmstest_get_property(display->drm_fd, crtc_id, + DRM_MODE_OBJECT_CRTC, "ACTIVE", + NULL, &active, NULL); + igt_assert(active); + } else { + kmstest_set_connector_dpms(display->drm_fd, connector, + DRM_MODE_DPMS_OFF); + kmstest_get_property(display->drm_fd, connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "DPMS", + NULL, &dpms_state, NULL); + igt_assert_eq(dpms_state, DRM_MODE_DPMS_OFF); + kmstest_get_property(display->drm_fd, crtc_id, + DRM_MODE_OBJECT_CRTC, "ACTIVE", + NULL, &active, NULL); + igt_assert(!active); + } +} + +static void run_dpms_test(igt_display_t *display, enum pipe pipe, + igt_output_t *output) +{ + struct igt_fb fb; + bool found; + uint64_t original_dpms_state; + drmModeConnector *connector = output->config.connector; + uint64_t active; + int crtc_id = display->pipes[pipe].crtc_id; + + if (pipe != PIPE_NONE) + prepare_pipe(display, pipe, output, &fb); + + igt_info("Testing dpms properties on output %s (pipe: %s)\n", + output->name, kmstest_pipe_name(pipe)); + + found = kmstest_get_property(display->drm_fd, connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "DPMS", + NULL, &original_dpms_state, NULL); + if (found) { + test_dpms(display, connector, crtc_id); + test_dpms(display, connector, crtc_id); + kmstest_set_connector_dpms(display->drm_fd, connector, + original_dpms_state); + } + + if (pipe != PIPE_NONE) + cleanup_pipe(display, pipe, output, &fb); +} + +static void dpms_property(igt_display_t *display) +{ + enum pipe pipe; + igt_output_t *output; + + for_each_connected_output(display, output) { + bool found = false; + + for_each_pipe(display, pipe) { + if (!igt_pipe_connector_valid(pipe, output)) + continue; + + found = true; + run_dpms_test(display, pipe, output); + break; + } + + igt_assert_f(found, + "Connected output should have at least 1 valid crtc\n"); + } +} + +igt_main +{ + igt_display_t display; + + igt_skip_on_simulation(); + + igt_fixture { + display.drm_fd = drm_open_driver_master(DRIVER_ANY); + + kmstest_set_vt_graphics_mode(); + + igt_display_init(&display, display.drm_fd); + } + + igt_subtest("dpms_property") + dpms_property(&display); + + igt_fixture { + igt_display_fini(&display); + } +}