2 * Copyright (c) 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Rodrigo Vivi <rodrigo.vivi@intel.com>
36 #define SLEEP_DURATION 5000 // in milliseconds
38 static int get_perf(const char *path)
44 file = fopen(path, "r");
47 ret = fscanf(file, "Sink_Support: %s\n", str);
48 igt_skip_on_f(ret == 0,
49 "i915_edp_psr_status format not supported by this test case\n");
50 igt_require(strcmp(str, "yes") == 0);
51 ret = fscanf(file, "Source_OK: %s\n", str);
54 igt_require(strcmp(str, "yes") == 0);
56 ret = fscanf(file, "Enabled: %s\n", str);
58 igt_assert(strcmp(str, "yes") == 0);
60 ret = fscanf(file, "Performance_Counter: %i", &perf);
71 int ret, perf1, perf2;
72 int device = drm_get_card();
75 igt_skip_on_simulation();
77 ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_edp_psr_status", device);
78 igt_assert(ret != -1);
80 perf1 = get_perf(path);
81 sleep(SLEEP_DURATION / 1000);
82 perf2 = get_perf(path);
84 igt_assert_f(perf1 != perf2,
85 "Unable to enter PSR state again\n");