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 000..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_XRGB,
+ 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, _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, _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, , 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, _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, , NULL);
+