Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 Intel Corporation |
| 3 | * |
| 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: |
| 10 | * |
| 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 |
| 13 | * Software. |
| 14 | * |
| 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
| 24 | |
Thomas Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 25 | #include "igt.h" |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 26 | #include "igt_sysfs.h" |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 27 | #include <errno.h> |
| 28 | #include <stdbool.h> |
| 29 | #include <stdio.h> |
| 30 | #include <string.h> |
| 31 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 32 | #include "intel_bufmgr.h" |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 33 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 34 | bool running_with_psr_disabled; |
| 35 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 36 | #define CRC_BLACK "000000000000" |
| 37 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 38 | enum operations { |
| 39 | PAGE_FLIP, |
| 40 | MMAP_GTT, |
| 41 | MMAP_GTT_WAITING, |
| 42 | MMAP_CPU, |
| 43 | BLT, |
| 44 | RENDER, |
| 45 | PLANE_MOVE, |
| 46 | PLANE_ONOFF, |
| 47 | }; |
| 48 | |
| 49 | static const char *op_str(enum operations op) |
| 50 | { |
| 51 | static const char * const name[] = { |
| 52 | [PAGE_FLIP] = "page_flip", |
| 53 | [MMAP_GTT] = "mmap_gtt", |
| 54 | [MMAP_GTT_WAITING] = "mmap_gtt_waiting", |
| 55 | [MMAP_CPU] = "mmap_cpu", |
| 56 | [BLT] = "blt", |
| 57 | [RENDER] = "render", |
| 58 | [PLANE_MOVE] = "plane_move", |
| 59 | [PLANE_ONOFF] = "plane_onoff", |
| 60 | }; |
| 61 | |
| 62 | return name[op]; |
| 63 | } |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 64 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 65 | typedef struct { |
| 66 | int drm_fd; |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 67 | int test_plane; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 68 | enum operations op; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 69 | uint32_t devid; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 70 | uint32_t crtc_id; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 71 | igt_display_t display; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 72 | drm_intel_bufmgr *bufmgr; |
| 73 | struct igt_fb fb_green, fb_white; |
| 74 | igt_plane_t *primary, *sprite, *cursor; |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 75 | int mod_size; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 76 | int mod_stride; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 77 | drmModeModeInfo *mode; |
| 78 | igt_output_t *output; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 79 | } data_t; |
| 80 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 81 | static void create_cursor_fb(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 82 | { |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 83 | cairo_t *cr; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 84 | uint32_t fb_id; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 85 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 86 | fb_id = igt_create_fb(data->drm_fd, 64, 64, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 87 | DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE, |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 88 | &data->fb_white); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 89 | igt_assert(fb_id); |
| 90 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 91 | cr = igt_get_cairo_ctx(data->drm_fd, &data->fb_white); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 92 | igt_paint_color_alpha(cr, 0, 0, 64, 64, 1.0, 1.0, 1.0, 1.0); |
| 93 | igt_assert(cairo_status(cr) == 0); |
| 94 | } |
| 95 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 96 | |
| 97 | static void setup_output(data_t *data) |
| 98 | { |
| 99 | igt_display_t *display = &data->display; |
| 100 | igt_output_t *output; |
Maarten Lankhorst | cd88595 | 2016-06-30 07:41:44 +0200 | [diff] [blame] | 101 | enum pipe pipe; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 102 | |
Maarten Lankhorst | cd88595 | 2016-06-30 07:41:44 +0200 | [diff] [blame] | 103 | for_each_pipe_with_valid_output(display, pipe, output) { |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 104 | drmModeConnectorPtr c = output->config.connector; |
| 105 | |
Maarten Lankhorst | cd88595 | 2016-06-30 07:41:44 +0200 | [diff] [blame] | 106 | if (c->connector_type != DRM_MODE_CONNECTOR_eDP) |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 107 | continue; |
| 108 | |
Maarten Lankhorst | cd88595 | 2016-06-30 07:41:44 +0200 | [diff] [blame] | 109 | igt_output_set_pipe(output, pipe); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 110 | data->crtc_id = output->config.crtc->crtc_id; |
| 111 | data->output = output; |
| 112 | data->mode = igt_output_get_mode(output); |
| 113 | |
| 114 | return; |
| 115 | } |
| 116 | } |
| 117 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 118 | static void display_init(data_t *data) |
| 119 | { |
| 120 | igt_display_init(&data->display, data->drm_fd); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 121 | setup_output(data); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | static void display_fini(data_t *data) |
| 125 | { |
| 126 | igt_display_fini(&data->display); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static void fill_blt(data_t *data, uint32_t handle, unsigned char color) |
| 130 | { |
| 131 | drm_intel_bo *dst = gem_handle_to_libdrm_bo(data->bufmgr, |
| 132 | data->drm_fd, |
| 133 | "", handle); |
| 134 | struct intel_batchbuffer *batch; |
| 135 | |
| 136 | batch = intel_batchbuffer_alloc(data->bufmgr, data->devid); |
| 137 | igt_assert(batch); |
| 138 | |
Chris Wilson | 10552b5 | 2014-08-30 11:44:51 +0100 | [diff] [blame] | 139 | COLOR_BLIT_COPY_BATCH_START(0); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 140 | OUT_BATCH((1 << 24) | (0xf0 << 16) | 0); |
Rodrigo Vivi | 1447d83 | 2014-09-03 18:18:15 -0400 | [diff] [blame] | 141 | OUT_BATCH(0); |
Rodrigo Vivi | 3cb2124 | 2014-12-05 19:43:34 -0500 | [diff] [blame] | 142 | OUT_BATCH(0xfff << 16 | 0xfff); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 143 | OUT_RELOC(dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); |
| 144 | OUT_BATCH(color); |
| 145 | ADVANCE_BATCH(); |
| 146 | |
| 147 | intel_batchbuffer_flush(batch); |
| 148 | intel_batchbuffer_free(batch); |
| 149 | |
| 150 | gem_bo_busy(data->drm_fd, handle); |
| 151 | } |
| 152 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 153 | static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo, |
| 154 | int size, int stride) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 155 | { |
| 156 | buf->bo = bo; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 157 | buf->stride = stride; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 158 | buf->tiling = I915_TILING_X; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 159 | buf->size = size; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 160 | } |
| 161 | |
Rodrigo Vivi | fb004a6 | 2014-09-03 17:53:35 -0400 | [diff] [blame] | 162 | static void fill_render(data_t *data, uint32_t handle, unsigned char color) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 163 | { |
| 164 | drm_intel_bo *src, *dst; |
| 165 | struct intel_batchbuffer *batch; |
| 166 | struct igt_buf src_buf, dst_buf; |
| 167 | const uint8_t buf[4] = { color, color, color, color }; |
| 168 | igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(data->devid); |
| 169 | |
| 170 | igt_skip_on(!rendercopy); |
| 171 | |
| 172 | dst = gem_handle_to_libdrm_bo(data->bufmgr, data->drm_fd, "", handle); |
| 173 | igt_assert(dst); |
| 174 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 175 | src = drm_intel_bo_alloc(data->bufmgr, "", data->mod_size, 4096); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 176 | igt_assert(src); |
| 177 | |
| 178 | gem_write(data->drm_fd, src->handle, 0, buf, 4); |
| 179 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 180 | scratch_buf_init(&src_buf, src, data->mod_size, data->mod_stride); |
| 181 | scratch_buf_init(&dst_buf, dst, data->mod_size, data->mod_stride); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 182 | |
| 183 | batch = intel_batchbuffer_alloc(data->bufmgr, data->devid); |
| 184 | igt_assert(batch); |
| 185 | |
Rodrigo Vivi | fb004a6 | 2014-09-03 17:53:35 -0400 | [diff] [blame] | 186 | rendercopy(batch, NULL, |
Rodrigo Vivi | f20690d | 2014-12-05 19:45:37 -0500 | [diff] [blame] | 187 | &src_buf, 0, 0, 0xff, 0xff, |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 188 | &dst_buf, 0, 0); |
| 189 | |
| 190 | intel_batchbuffer_free(batch); |
| 191 | |
| 192 | gem_bo_busy(data->drm_fd, handle); |
| 193 | } |
| 194 | |
Paulo Zanoni | 75b286e | 2015-06-02 12:03:45 -0300 | [diff] [blame] | 195 | static bool psr_possible(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 196 | { |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame] | 197 | char buf[512]; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 198 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 199 | igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 200 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame] | 201 | return running_with_psr_disabled || |
| 202 | strstr(buf, "Sink_Support: yes\n"); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 203 | } |
| 204 | |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 205 | static bool psr_active(data_t *data) |
| 206 | { |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame] | 207 | char buf[512]; |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 208 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 209 | igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 210 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame] | 211 | return running_with_psr_disabled || |
| 212 | strstr(buf, "HW Enabled & Active bit: yes\n"); |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Rodrigo Vivi | fd9ef1b | 2015-03-13 12:28:07 -0400 | [diff] [blame] | 215 | static bool wait_psr_entry(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 216 | { |
Rodrigo Vivi | 4a004d9 | 2015-12-07 01:26:17 -0800 | [diff] [blame] | 217 | int timeout = 5; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 218 | while (timeout--) { |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 219 | if (psr_active(data)) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 220 | return true; |
| 221 | sleep(1); |
| 222 | } |
| 223 | return false; |
| 224 | } |
| 225 | |
| 226 | static void get_sink_crc(data_t *data, char *crc) { |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 227 | int dir; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 228 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 229 | if (igt_interactive_debug) |
| 230 | return; |
| 231 | |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 232 | dir = igt_debugfs_dir(data->drm_fd); |
| 233 | igt_require_f(igt_sysfs_scanf(dir, "i915_sink_crc_eDP1", "%s\n", crc), |
| 234 | "Sink CRC is unreliable on this machine. Try manual debug with --interactive-debug=no-crc\n"); |
| 235 | close(dir); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 236 | |
| 237 | igt_debug("%s\n", crc); |
| 238 | igt_debug_wait_for_keypress("crc"); |
| 239 | |
| 240 | /* The important value was already taken. |
| 241 | * Now give a time for human eyes |
| 242 | */ |
| 243 | usleep(300000); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 244 | |
| 245 | /* Black screen is always invalid */ |
| 246 | igt_assert(strcmp(crc, CRC_BLACK) != 0); |
| 247 | } |
| 248 | |
| 249 | static bool is_green(char *crc) |
| 250 | { |
| 251 | char color_mask[5] = "FFFF\0"; |
| 252 | char rs[5], gs[5], bs[5]; |
| 253 | unsigned int rh, gh, bh, mask; |
| 254 | int ret; |
| 255 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 256 | if (igt_interactive_debug) |
| 257 | return false; |
| 258 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 259 | sscanf(color_mask, "%4x", &mask); |
| 260 | |
| 261 | memcpy(rs, &crc[0], 4); |
| 262 | rs[4] = '\0'; |
| 263 | ret = sscanf(rs, "%4x", &rh); |
| 264 | igt_require(ret > 0); |
| 265 | |
| 266 | memcpy(gs, &crc[4], 4); |
| 267 | gs[4] = '\0'; |
| 268 | ret = sscanf(gs, "%4x", &gh); |
| 269 | igt_require(ret > 0); |
| 270 | |
| 271 | memcpy(bs, &crc[8], 4); |
| 272 | bs[4] = '\0'; |
| 273 | ret = sscanf(bs, "%4x", &bh); |
| 274 | igt_require(ret > 0); |
| 275 | |
| 276 | return ((rh & mask) == 0 && |
| 277 | (gh & mask) != 0 && |
| 278 | (bh & mask) == 0); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 279 | } |
| 280 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 281 | static void assert_or_manual(bool condition, const char *expected) |
| 282 | { |
Rodrigo Vivi | ae9c685 | 2014-12-09 20:44:11 -0500 | [diff] [blame] | 283 | igt_debug_manual_check("no-crc", expected); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 284 | igt_assert(igt_interactive_debug || condition); |
| 285 | } |
| 286 | |
Radhakrishna Sripada | 6dceb6f | 2017-09-15 17:00:08 -0700 | [diff] [blame^] | 287 | static bool drrs_disabled(data_t *data) |
| 288 | { |
| 289 | char buf[512]; |
| 290 | |
| 291 | igt_debugfs_read(data->drm_fd, "i915_drrs_status", buf); |
| 292 | |
| 293 | return strstr(buf, "DRRS Support: No\n"); |
| 294 | } |
| 295 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 296 | static void run_test(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 297 | { |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 298 | uint32_t handle = data->fb_white.gem_handle; |
| 299 | igt_plane_t *test_plane; |
| 300 | void *ptr; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 301 | char ref_crc[12]; |
| 302 | char crc[12]; |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 303 | const char *expected = ""; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 304 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 305 | /* Confirm that screen became Green */ |
| 306 | get_sink_crc(data, ref_crc); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 307 | assert_or_manual(is_green(ref_crc), "screen GREEN"); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 308 | |
| 309 | /* Confirm screen stays Green after PSR got active */ |
Rodrigo Vivi | fd9ef1b | 2015-03-13 12:28:07 -0400 | [diff] [blame] | 310 | igt_assert(wait_psr_entry(data)); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 311 | get_sink_crc(data, ref_crc); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 312 | assert_or_manual(is_green(ref_crc), "screen GREEN"); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 313 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 314 | /* Setting a secondary fb/plane */ |
| 315 | switch (data->test_plane) { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 316 | case DRM_PLANE_TYPE_PRIMARY: default: test_plane = data->primary; break; |
| 317 | case DRM_PLANE_TYPE_OVERLAY: test_plane = data->sprite; break; |
| 318 | case DRM_PLANE_TYPE_CURSOR: test_plane = data->cursor; break; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 319 | } |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 320 | igt_plane_set_fb(test_plane, &data->fb_white); |
| 321 | igt_display_commit(&data->display); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 322 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 323 | /* Confirm it is not Green anymore */ |
Rodrigo Vivi | fd9ef1b | 2015-03-13 12:28:07 -0400 | [diff] [blame] | 324 | igt_assert(wait_psr_entry(data)); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 325 | get_sink_crc(data, ref_crc); |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 326 | if (data->test_plane == DRM_PLANE_TYPE_PRIMARY) |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 327 | assert_or_manual(!is_green(ref_crc), "screen WHITE"); |
| 328 | else |
| 329 | assert_or_manual(!is_green(ref_crc), "GREEN background with WHITE box"); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 330 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 331 | switch (data->op) { |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 332 | case PAGE_FLIP: |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 333 | /* Only in use when testing primary plane */ |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 334 | igt_assert(drmModePageFlip(data->drm_fd, data->crtc_id, |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 335 | data->fb_green.fb_id, 0, NULL) == 0); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 336 | get_sink_crc(data, crc); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 337 | assert_or_manual(is_green(crc), "screen GREEN"); |
| 338 | expected = "still GREEN"; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 339 | break; |
| 340 | case MMAP_GTT: |
Ville Syrjälä | f52e7ec | 2015-10-09 19:11:39 +0300 | [diff] [blame] | 341 | ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size, |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 342 | PROT_WRITE); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 343 | gem_set_domain(data->drm_fd, handle, |
| 344 | I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 345 | memset(ptr, 0xcc, data->mod_size); |
| 346 | munmap(ptr, data->mod_size); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 347 | expected = "BLACK or TRANSPARENT mark on top of plane in test"; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 348 | break; |
| 349 | case MMAP_GTT_WAITING: |
Ville Syrjälä | f52e7ec | 2015-10-09 19:11:39 +0300 | [diff] [blame] | 350 | ptr = gem_mmap__gtt(data->drm_fd, handle, data->mod_size, |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 351 | PROT_WRITE); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 352 | gem_set_domain(data->drm_fd, handle, |
| 353 | I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); |
| 354 | |
| 355 | /* Printing white on white so the screen shouldn't change */ |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 356 | memset(ptr, 0xff, data->mod_size); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 357 | get_sink_crc(data, crc); |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 358 | if (data->test_plane == DRM_PLANE_TYPE_PRIMARY) |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 359 | assert_or_manual(strcmp(ref_crc, crc) == 0, "screen WHITE"); |
| 360 | else |
| 361 | assert_or_manual(strcmp(ref_crc, crc) == 0, |
| 362 | "GREEN background with WHITE box"); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 363 | |
Daniel Vetter | 8b556f7 | 2014-10-23 17:54:44 +0200 | [diff] [blame] | 364 | igt_info("Waiting 10s...\n"); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 365 | sleep(10); |
| 366 | |
| 367 | /* Now lets print black to change the screen */ |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 368 | memset(ptr, 0, data->mod_size); |
| 369 | munmap(ptr, data->mod_size); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 370 | expected = "BLACK or TRANSPARENT mark on top of plane in test"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 371 | break; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 372 | case MMAP_CPU: |
Ville Syrjälä | f52e7ec | 2015-10-09 19:11:39 +0300 | [diff] [blame] | 373 | ptr = gem_mmap__cpu(data->drm_fd, handle, 0, data->mod_size, |
| 374 | PROT_WRITE); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 375 | gem_set_domain(data->drm_fd, handle, |
| 376 | I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 377 | memset(ptr, 0, data->mod_size); |
| 378 | munmap(ptr, data->mod_size); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 379 | gem_sw_finish(data->drm_fd, handle); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 380 | expected = "BLACK or TRANSPARENT mark on top of plane in test"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 381 | break; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 382 | case BLT: |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 383 | fill_blt(data, handle, 0); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 384 | expected = "BLACK or TRANSPARENT mark on top of plane in test"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 385 | break; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 386 | case RENDER: |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 387 | fill_render(data, handle, 0); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 388 | expected = "BLACK or TRANSPARENT mark on top of plane in test"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 389 | break; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 390 | case PLANE_MOVE: |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 391 | /* Only in use when testing Sprite and Cursor */ |
Rodrigo Vivi | b7b2ecb | 2014-12-05 20:03:31 -0500 | [diff] [blame] | 392 | igt_plane_set_position(test_plane, 500, 500); |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 393 | igt_display_commit(&data->display); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 394 | expected = "White box moved to 500x500"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 395 | break; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 396 | case PLANE_ONOFF: |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 397 | /* Only in use when testing Sprite and Cursor */ |
| 398 | igt_plane_set_fb(test_plane, NULL); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 399 | igt_display_commit(&data->display); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 400 | expected = "screen GREEN"; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 401 | break; |
| 402 | } |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 403 | get_sink_crc(data, crc); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 404 | assert_or_manual(strcmp(ref_crc, crc) != 0, expected); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 405 | } |
| 406 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 407 | static void test_cleanup(data_t *data) { |
| 408 | igt_plane_set_fb(data->primary, NULL); |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 409 | if (data->test_plane == DRM_PLANE_TYPE_OVERLAY) |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 410 | igt_plane_set_fb(data->sprite, NULL); |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 411 | if (data->test_plane == DRM_PLANE_TYPE_CURSOR) |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 412 | igt_plane_set_fb(data->cursor, NULL); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 413 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 414 | igt_display_commit(&data->display); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 415 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 416 | igt_remove_fb(data->drm_fd, &data->fb_green); |
| 417 | igt_remove_fb(data->drm_fd, &data->fb_white); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 418 | } |
| 419 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 420 | static void setup_test_plane(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 421 | { |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 422 | uint32_t white_h, white_v; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 423 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 424 | igt_create_color_fb(data->drm_fd, |
| 425 | data->mode->hdisplay, data->mode->vdisplay, |
| 426 | DRM_FORMAT_XRGB8888, |
| 427 | LOCAL_I915_FORMAT_MOD_X_TILED, |
| 428 | 0.0, 1.0, 0.0, |
| 429 | &data->fb_green); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 430 | |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 431 | data->primary = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 432 | igt_plane_set_fb(data->primary, NULL); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 433 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 434 | white_h = data->mode->hdisplay; |
| 435 | white_v = data->mode->vdisplay; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 436 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 437 | /* Ignoring pitch and bpp to avoid changing full screen */ |
| 438 | data->mod_size = white_h * white_v; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 439 | data->mod_stride = white_h * 4; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 440 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 441 | switch (data->test_plane) { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 442 | case DRM_PLANE_TYPE_OVERLAY: |
| 443 | data->sprite = igt_output_get_plane_type(data->output, |
| 444 | DRM_PLANE_TYPE_OVERLAY); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 445 | igt_plane_set_fb(data->sprite, NULL); |
| 446 | /* To make it different for human eyes let's make |
| 447 | * sprite visible in only one quarter of the primary |
| 448 | */ |
| 449 | white_h = white_h/2; |
| 450 | white_v = white_v/2; |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 451 | case DRM_PLANE_TYPE_PRIMARY: |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 452 | igt_create_color_fb(data->drm_fd, |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 453 | white_h, white_v, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 454 | DRM_FORMAT_XRGB8888, |
| 455 | LOCAL_I915_FORMAT_MOD_X_TILED, |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 456 | 1.0, 1.0, 1.0, |
| 457 | &data->fb_white); |
| 458 | break; |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 459 | case DRM_PLANE_TYPE_CURSOR: |
| 460 | data->cursor = igt_output_get_plane_type(data->output, |
| 461 | DRM_PLANE_TYPE_CURSOR); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 462 | igt_plane_set_fb(data->cursor, NULL); |
| 463 | create_cursor_fb(data); |
| 464 | igt_plane_set_position(data->cursor, 0, 0); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 465 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 466 | /* Cursor is 64 x 64, ignoring pitch and bbp again */ |
| 467 | data->mod_size = 64 * 64; |
| 468 | break; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 469 | } |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 470 | |
| 471 | igt_display_commit(&data->display); |
| 472 | |
| 473 | igt_plane_set_fb(data->primary, &data->fb_green); |
| 474 | igt_display_commit(&data->display); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 475 | } |
| 476 | |
Rodrigo Vivi | c352475 | 2015-03-13 12:11:54 -0400 | [diff] [blame] | 477 | static void dpms_off_on(data_t data) |
| 478 | { |
| 479 | kmstest_set_connector_dpms(data.drm_fd, data.output->config.connector, |
| 480 | DRM_MODE_DPMS_OFF); |
| 481 | sleep(1); |
| 482 | kmstest_set_connector_dpms(data.drm_fd, data.output->config.connector, |
| 483 | DRM_MODE_DPMS_ON); |
| 484 | } |
| 485 | |
Damien Lespiau | fd6846c | 2015-05-14 14:19:01 +0100 | [diff] [blame] | 486 | static int opt_handler(int opt, int opt_index, void *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 487 | { |
Daniel Vetter | 3205a91 | 2014-09-23 15:15:51 +0200 | [diff] [blame] | 488 | switch (opt) { |
| 489 | case 'n': |
| 490 | running_with_psr_disabled = true; |
| 491 | break; |
| 492 | default: |
| 493 | igt_assert(0); |
| 494 | } |
| 495 | |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | int main(int argc, char *argv[]) |
| 500 | { |
| 501 | const char *help_str = |
| 502 | " --no-psr\tRun test without PSR to check the CRC test logic."; |
| 503 | static struct option long_options[] = { |
| 504 | {"no-psr", 0, 0, 'n'}, |
| 505 | { 0, 0, 0, 0 } |
| 506 | }; |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 507 | data_t data = {}; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 508 | enum operations op; |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 509 | |
Thomas Wood | 8fb1978 | 2015-02-18 16:19:59 +0000 | [diff] [blame] | 510 | igt_subtest_init_parse_opts(&argc, argv, "", long_options, |
Damien Lespiau | fd6846c | 2015-05-14 14:19:01 +0100 | [diff] [blame] | 511 | help_str, opt_handler, NULL); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 512 | igt_skip_on_simulation(); |
| 513 | |
| 514 | igt_fixture { |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 515 | data.drm_fd = drm_open_driver_master(DRIVER_INTEL); |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 516 | kmstest_set_vt_graphics_mode(); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 517 | data.devid = intel_get_drm_devid(data.drm_fd); |
| 518 | |
Rodrigo Vivi | 63980ba | 2015-11-03 09:37:56 -0800 | [diff] [blame] | 519 | igt_set_module_param_int("enable_psr", running_with_psr_disabled ? |
| 520 | 0 : 1); |
Paulo Zanoni | 75b286e | 2015-06-02 12:03:45 -0300 | [diff] [blame] | 521 | |
| 522 | igt_skip_on(!psr_possible(&data)); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 523 | |
| 524 | data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096); |
| 525 | igt_assert(data.bufmgr); |
| 526 | drm_intel_bufmgr_gem_enable_reuse(data.bufmgr); |
| 527 | |
| 528 | display_init(&data); |
| 529 | } |
| 530 | |
Rodrigo Vivi | 4aa1b99 | 2015-12-08 00:11:21 -0800 | [diff] [blame] | 531 | igt_subtest("psr_basic") { |
| 532 | setup_test_plane(&data); |
| 533 | igt_assert(wait_psr_entry(&data)); |
| 534 | } |
| 535 | |
Radhakrishna Sripada | 6dceb6f | 2017-09-15 17:00:08 -0700 | [diff] [blame^] | 536 | igt_subtest("psr_drrs") { |
| 537 | setup_test_plane(&data); |
| 538 | igt_assert(drrs_disabled(&data)); |
| 539 | } |
| 540 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 541 | for (op = PAGE_FLIP; op <= RENDER; op++) { |
| 542 | igt_subtest_f("primary_%s", op_str(op)) { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 543 | data.test_plane = DRM_PLANE_TYPE_PRIMARY; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 544 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 545 | setup_test_plane(&data); |
| 546 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 547 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 548 | test_cleanup(&data); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 552 | for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) { |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 553 | igt_subtest_f("sprite_%s", op_str(op)) { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 554 | data.test_plane = DRM_PLANE_TYPE_OVERLAY; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 555 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 556 | setup_test_plane(&data); |
| 557 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 558 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 559 | test_cleanup(&data); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 560 | } |
| 561 | } |
| 562 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 563 | for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) { |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 564 | igt_subtest_f("cursor_%s", op_str(op)) { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 565 | data.test_plane = DRM_PLANE_TYPE_CURSOR; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 566 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 567 | setup_test_plane(&data); |
| 568 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 569 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 570 | test_cleanup(&data); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 571 | } |
| 572 | } |
| 573 | |
Rodrigo Vivi | c352475 | 2015-03-13 12:11:54 -0400 | [diff] [blame] | 574 | igt_subtest_f("dpms_off_psr_active") { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 575 | data.test_plane = DRM_PLANE_TYPE_PRIMARY; |
Rodrigo Vivi | c352475 | 2015-03-13 12:11:54 -0400 | [diff] [blame] | 576 | data.op = RENDER; |
| 577 | setup_test_plane(&data); |
| 578 | igt_assert(wait_psr_entry(&data)); |
| 579 | |
| 580 | dpms_off_on(data); |
| 581 | |
| 582 | run_test(&data); |
| 583 | test_cleanup(&data); |
| 584 | } |
| 585 | |
| 586 | igt_subtest_f("dpms_off_psr_exit") { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 587 | data.test_plane = DRM_PLANE_TYPE_OVERLAY; |
Rodrigo Vivi | c352475 | 2015-03-13 12:11:54 -0400 | [diff] [blame] | 588 | data.op = PLANE_ONOFF; |
| 589 | setup_test_plane(&data); |
| 590 | |
| 591 | dpms_off_on(data); |
| 592 | |
| 593 | igt_assert(wait_psr_entry(&data)); |
| 594 | run_test(&data); |
| 595 | test_cleanup(&data); |
| 596 | } |
| 597 | |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 598 | igt_subtest_f("suspend_psr_active") { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 599 | data.test_plane = DRM_PLANE_TYPE_PRIMARY; |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 600 | data.op = PAGE_FLIP; |
| 601 | setup_test_plane(&data); |
| 602 | igt_assert(wait_psr_entry(&data)); |
| 603 | |
Imre Deak | 022e6f8 | 2016-09-30 17:28:53 +0300 | [diff] [blame] | 604 | igt_system_suspend_autoresume(SUSPEND_STATE_MEM, |
| 605 | SUSPEND_TEST_NONE); |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 606 | |
| 607 | run_test(&data); |
| 608 | test_cleanup(&data); |
| 609 | } |
| 610 | |
| 611 | igt_subtest_f("suspend_psr_exit") { |
Robert Foss | 934062c | 2017-01-10 20:16:23 -0500 | [diff] [blame] | 612 | data.test_plane = DRM_PLANE_TYPE_CURSOR; |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 613 | data.op = PLANE_ONOFF; |
| 614 | setup_test_plane(&data); |
| 615 | |
Imre Deak | 022e6f8 | 2016-09-30 17:28:53 +0300 | [diff] [blame] | 616 | igt_system_suspend_autoresume(SUSPEND_STATE_MEM, |
| 617 | SUSPEND_TEST_NONE); |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 618 | |
| 619 | igt_assert(wait_psr_entry(&data)); |
| 620 | run_test(&data); |
| 621 | test_cleanup(&data); |
| 622 | } |
| 623 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 624 | igt_fixture { |
| 625 | drm_intel_bufmgr_destroy(data.bufmgr); |
| 626 | display_fini(&data); |
| 627 | } |
Daniel Vetter | 3205a91 | 2014-09-23 15:15:51 +0200 | [diff] [blame] | 628 | |
| 629 | igt_exit(); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 630 | } |