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" |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 26 | #include <errno.h> |
| 27 | #include <stdbool.h> |
| 28 | #include <stdio.h> |
| 29 | #include <string.h> |
| 30 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 31 | #include "intel_bufmgr.h" |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 32 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 33 | bool running_with_psr_disabled; |
| 34 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 35 | #define CRC_BLACK "000000000000" |
| 36 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 37 | enum planes { |
| 38 | PRIMARY, |
| 39 | SPRITE, |
| 40 | CURSOR, |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 41 | }; |
| 42 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 43 | enum operations { |
| 44 | PAGE_FLIP, |
| 45 | MMAP_GTT, |
| 46 | MMAP_GTT_WAITING, |
| 47 | MMAP_CPU, |
| 48 | BLT, |
| 49 | RENDER, |
| 50 | PLANE_MOVE, |
| 51 | PLANE_ONOFF, |
| 52 | }; |
| 53 | |
| 54 | static const char *op_str(enum operations op) |
| 55 | { |
| 56 | static const char * const name[] = { |
| 57 | [PAGE_FLIP] = "page_flip", |
| 58 | [MMAP_GTT] = "mmap_gtt", |
| 59 | [MMAP_GTT_WAITING] = "mmap_gtt_waiting", |
| 60 | [MMAP_CPU] = "mmap_cpu", |
| 61 | [BLT] = "blt", |
| 62 | [RENDER] = "render", |
| 63 | [PLANE_MOVE] = "plane_move", |
| 64 | [PLANE_ONOFF] = "plane_onoff", |
| 65 | }; |
| 66 | |
| 67 | return name[op]; |
| 68 | } |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 69 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 70 | typedef struct { |
| 71 | int drm_fd; |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 72 | enum planes test_plane; |
| 73 | enum operations op; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 74 | uint32_t devid; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 75 | uint32_t crtc_id; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 76 | igt_display_t display; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 77 | drm_intel_bufmgr *bufmgr; |
| 78 | struct igt_fb fb_green, fb_white; |
| 79 | igt_plane_t *primary, *sprite, *cursor; |
Rodrigo Vivi | 00992f7 | 2014-12-05 20:01:41 -0500 | [diff] [blame] | 80 | int mod_size; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 81 | int mod_stride; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 82 | drmModeModeInfo *mode; |
| 83 | igt_output_t *output; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 84 | } data_t; |
| 85 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 86 | static void create_cursor_fb(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 87 | { |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 88 | cairo_t *cr; |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 89 | uint32_t fb_id; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 90 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 91 | fb_id = igt_create_fb(data->drm_fd, 64, 64, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 92 | DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE, |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 93 | &data->fb_white); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 94 | igt_assert(fb_id); |
| 95 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 96 | cr = igt_get_cairo_ctx(data->drm_fd, &data->fb_white); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 97 | igt_paint_color_alpha(cr, 0, 0, 64, 64, 1.0, 1.0, 1.0, 1.0); |
| 98 | igt_assert(cairo_status(cr) == 0); |
| 99 | } |
| 100 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 101 | |
| 102 | static void setup_output(data_t *data) |
| 103 | { |
| 104 | igt_display_t *display = &data->display; |
| 105 | igt_output_t *output; |
| 106 | |
| 107 | for_each_connected_output(display, output) { |
| 108 | drmModeConnectorPtr c = output->config.connector; |
| 109 | |
| 110 | if (c->connector_type != DRM_MODE_CONNECTOR_eDP || |
| 111 | c->connection != DRM_MODE_CONNECTED) |
| 112 | continue; |
| 113 | |
| 114 | igt_output_set_pipe(output, PIPE_ANY); |
| 115 | data->crtc_id = output->config.crtc->crtc_id; |
| 116 | data->output = output; |
| 117 | data->mode = igt_output_get_mode(output); |
| 118 | |
| 119 | return; |
| 120 | } |
| 121 | } |
| 122 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 123 | static void display_init(data_t *data) |
| 124 | { |
| 125 | igt_display_init(&data->display, data->drm_fd); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 126 | setup_output(data); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static void display_fini(data_t *data) |
| 130 | { |
| 131 | igt_display_fini(&data->display); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | static void fill_blt(data_t *data, uint32_t handle, unsigned char color) |
| 135 | { |
| 136 | drm_intel_bo *dst = gem_handle_to_libdrm_bo(data->bufmgr, |
| 137 | data->drm_fd, |
| 138 | "", handle); |
| 139 | struct intel_batchbuffer *batch; |
| 140 | |
| 141 | batch = intel_batchbuffer_alloc(data->bufmgr, data->devid); |
| 142 | igt_assert(batch); |
| 143 | |
Chris Wilson | 10552b5 | 2014-08-30 11:44:51 +0100 | [diff] [blame] | 144 | COLOR_BLIT_COPY_BATCH_START(0); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 145 | OUT_BATCH((1 << 24) | (0xf0 << 16) | 0); |
Rodrigo Vivi | 1447d83 | 2014-09-03 18:18:15 -0400 | [diff] [blame] | 146 | OUT_BATCH(0); |
Rodrigo Vivi | 3cb2124 | 2014-12-05 19:43:34 -0500 | [diff] [blame] | 147 | OUT_BATCH(0xfff << 16 | 0xfff); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 148 | OUT_RELOC(dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); |
| 149 | OUT_BATCH(color); |
| 150 | ADVANCE_BATCH(); |
| 151 | |
| 152 | intel_batchbuffer_flush(batch); |
| 153 | intel_batchbuffer_free(batch); |
| 154 | |
| 155 | gem_bo_busy(data->drm_fd, handle); |
| 156 | } |
| 157 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 158 | static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo, |
| 159 | int size, int stride) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 160 | { |
| 161 | buf->bo = bo; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 162 | buf->stride = stride; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 163 | buf->tiling = I915_TILING_X; |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 164 | buf->size = size; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 165 | } |
| 166 | |
Rodrigo Vivi | fb004a6 | 2014-09-03 17:53:35 -0400 | [diff] [blame] | 167 | 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] | 168 | { |
| 169 | drm_intel_bo *src, *dst; |
| 170 | struct intel_batchbuffer *batch; |
| 171 | struct igt_buf src_buf, dst_buf; |
| 172 | const uint8_t buf[4] = { color, color, color, color }; |
| 173 | igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(data->devid); |
| 174 | |
| 175 | igt_skip_on(!rendercopy); |
| 176 | |
| 177 | dst = gem_handle_to_libdrm_bo(data->bufmgr, data->drm_fd, "", handle); |
| 178 | igt_assert(dst); |
| 179 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 180 | src = drm_intel_bo_alloc(data->bufmgr, "", data->mod_size, 4096); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 181 | igt_assert(src); |
| 182 | |
| 183 | gem_write(data->drm_fd, src->handle, 0, buf, 4); |
| 184 | |
Rodrigo Vivi | 36ecc31 | 2015-04-14 18:04:01 -0700 | [diff] [blame] | 185 | scratch_buf_init(&src_buf, src, data->mod_size, data->mod_stride); |
| 186 | scratch_buf_init(&dst_buf, dst, data->mod_size, data->mod_stride); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 187 | |
| 188 | batch = intel_batchbuffer_alloc(data->bufmgr, data->devid); |
| 189 | igt_assert(batch); |
| 190 | |
Rodrigo Vivi | fb004a6 | 2014-09-03 17:53:35 -0400 | [diff] [blame] | 191 | rendercopy(batch, NULL, |
Rodrigo Vivi | f20690d | 2014-12-05 19:45:37 -0500 | [diff] [blame] | 192 | &src_buf, 0, 0, 0xff, 0xff, |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 193 | &dst_buf, 0, 0); |
| 194 | |
| 195 | intel_batchbuffer_free(batch); |
| 196 | |
| 197 | gem_bo_busy(data->drm_fd, handle); |
| 198 | } |
| 199 | |
Paulo Zanoni | 75b286e | 2015-06-02 12:03:45 -0300 | [diff] [blame] | 200 | static bool psr_possible(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 201 | { |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 202 | char buf[512]; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 203 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 204 | igt_debugfs_read("i915_edp_psr_status", buf); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 205 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 206 | return running_with_psr_disabled || |
| 207 | strstr(buf, "Sink_Support: yes\n"); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 208 | } |
| 209 | |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 210 | static bool psr_active(data_t *data) |
| 211 | { |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 212 | char buf[512]; |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 213 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 214 | igt_debugfs_read("i915_edp_psr_status", buf); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 215 | |
Rodrigo Vivi | 05ac611 | 2016-01-08 07:40:45 -0800 | [diff] [blame^] | 216 | return running_with_psr_disabled || |
| 217 | strstr(buf, "HW Enabled & Active bit: yes\n"); |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Rodrigo Vivi | fd9ef1b | 2015-03-13 12:28:07 -0400 | [diff] [blame] | 220 | static bool wait_psr_entry(data_t *data) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 221 | { |
Rodrigo Vivi | 4a004d9 | 2015-12-07 01:26:17 -0800 | [diff] [blame] | 222 | int timeout = 5; |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 223 | while (timeout--) { |
Rodrigo Vivi | e90847f | 2014-08-22 09:37:08 -0700 | [diff] [blame] | 224 | if (psr_active(data)) |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 225 | return true; |
| 226 | sleep(1); |
| 227 | } |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | static void get_sink_crc(data_t *data, char *crc) { |
| 232 | int ret; |
| 233 | FILE *file; |
| 234 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 235 | if (igt_interactive_debug) |
| 236 | return; |
| 237 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 238 | file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r"); |
| 239 | igt_require(file); |
| 240 | |
| 241 | ret = fscanf(file, "%s\n", crc); |
Rodrigo Vivi | ae9c685 | 2014-12-09 20:44:11 -0500 | [diff] [blame] | 242 | igt_require_f(ret > 0, "Sink CRC is unreliable on this machine. Try manual debug with --interactive-debug=no-crc\n"); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 243 | |
| 244 | fclose(file); |
Rodrigo Vivi | 1ab0445 | 2014-08-29 17:58:31 -0400 | [diff] [blame] | 245 | |
| 246 | igt_debug("%s\n", crc); |
| 247 | igt_debug_wait_for_keypress("crc"); |
| 248 | |
| 249 | /* The important value was already taken. |
| 250 | * Now give a time for human eyes |
| 251 | */ |
| 252 | usleep(300000); |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 253 | |
| 254 | /* Black screen is always invalid */ |
| 255 | igt_assert(strcmp(crc, CRC_BLACK) != 0); |
| 256 | } |
| 257 | |
| 258 | static bool is_green(char *crc) |
| 259 | { |
| 260 | char color_mask[5] = "FFFF\0"; |
| 261 | char rs[5], gs[5], bs[5]; |
| 262 | unsigned int rh, gh, bh, mask; |
| 263 | int ret; |
| 264 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 265 | if (igt_interactive_debug) |
| 266 | return false; |
| 267 | |
Rodrigo Vivi | 25aa69d | 2014-09-09 13:10:51 -0400 | [diff] [blame] | 268 | sscanf(color_mask, "%4x", &mask); |
| 269 | |
| 270 | memcpy(rs, &crc[0], 4); |
| 271 | rs[4] = '\0'; |
| 272 | ret = sscanf(rs, "%4x", &rh); |
| 273 | igt_require(ret > 0); |
| 274 | |
| 275 | memcpy(gs, &crc[4], 4); |
| 276 | gs[4] = '\0'; |
| 277 | ret = sscanf(gs, "%4x", &gh); |
| 278 | igt_require(ret > 0); |
| 279 | |
| 280 | memcpy(bs, &crc[8], 4); |
| 281 | bs[4] = '\0'; |
| 282 | ret = sscanf(bs, "%4x", &bh); |
| 283 | igt_require(ret > 0); |
| 284 | |
| 285 | return ((rh & mask) == 0 && |
| 286 | (gh & mask) != 0 && |
| 287 | (bh & mask) == 0); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 288 | } |
| 289 | |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 290 | static void assert_or_manual(bool condition, const char *expected) |
| 291 | { |
Rodrigo Vivi | ae9c685 | 2014-12-09 20:44:11 -0500 | [diff] [blame] | 292 | igt_debug_manual_check("no-crc", expected); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 293 | igt_assert(igt_interactive_debug || condition); |
| 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) { |
| 316 | case PRIMARY: default: test_plane = data->primary; break; |
| 317 | case SPRITE: test_plane = data->sprite; break; |
| 318 | case 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); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 326 | if (data->test_plane == PRIMARY) |
| 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); |
Rodrigo Vivi | e1ac044 | 2014-12-05 20:03:43 -0500 | [diff] [blame] | 358 | if (data->test_plane == PRIMARY) |
| 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); |
| 409 | if (data->test_plane == SPRITE) |
| 410 | igt_plane_set_fb(data->sprite, NULL); |
| 411 | if (data->test_plane == CURSOR) |
| 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 | |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 431 | data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY); |
| 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) { |
| 442 | case SPRITE: |
| 443 | data->sprite = igt_output_get_plane(data->output, |
| 444 | IGT_PLANE_2); |
| 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; |
| 451 | case 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; |
| 459 | case CURSOR: |
| 460 | data->cursor = igt_output_get_plane(data->output, |
| 461 | IGT_PLANE_CURSOR); |
| 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 | |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 536 | for (op = PAGE_FLIP; op <= RENDER; op++) { |
| 537 | igt_subtest_f("primary_%s", op_str(op)) { |
| 538 | data.test_plane = PRIMARY; |
| 539 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 540 | setup_test_plane(&data); |
| 541 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 542 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 543 | test_cleanup(&data); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 547 | for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) { |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 548 | igt_subtest_f("sprite_%s", op_str(op)) { |
| 549 | data.test_plane = SPRITE; |
| 550 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 551 | setup_test_plane(&data); |
| 552 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 553 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 554 | test_cleanup(&data); |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 555 | } |
| 556 | } |
| 557 | |
Rodrigo Vivi | d4e6a51 | 2014-08-29 19:12:54 -0400 | [diff] [blame] | 558 | for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) { |
Rodrigo Vivi | 99efdc0 | 2014-09-09 17:58:45 -0400 | [diff] [blame] | 559 | igt_subtest_f("cursor_%s", op_str(op)) { |
| 560 | data.test_plane = CURSOR; |
| 561 | data.op = op; |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 562 | setup_test_plane(&data); |
| 563 | igt_assert(wait_psr_entry(&data)); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 564 | run_test(&data); |
Rodrigo Vivi | 782d5e7 | 2015-03-13 12:10:20 -0400 | [diff] [blame] | 565 | test_cleanup(&data); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 566 | } |
| 567 | } |
| 568 | |
Rodrigo Vivi | c352475 | 2015-03-13 12:11:54 -0400 | [diff] [blame] | 569 | igt_subtest_f("dpms_off_psr_active") { |
| 570 | data.test_plane = PRIMARY; |
| 571 | data.op = RENDER; |
| 572 | setup_test_plane(&data); |
| 573 | igt_assert(wait_psr_entry(&data)); |
| 574 | |
| 575 | dpms_off_on(data); |
| 576 | |
| 577 | run_test(&data); |
| 578 | test_cleanup(&data); |
| 579 | } |
| 580 | |
| 581 | igt_subtest_f("dpms_off_psr_exit") { |
| 582 | data.test_plane = SPRITE; |
| 583 | data.op = PLANE_ONOFF; |
| 584 | setup_test_plane(&data); |
| 585 | |
| 586 | dpms_off_on(data); |
| 587 | |
| 588 | igt_assert(wait_psr_entry(&data)); |
| 589 | run_test(&data); |
| 590 | test_cleanup(&data); |
| 591 | } |
| 592 | |
Rodrigo Vivi | 7bd31d0 | 2015-11-03 10:02:14 -0800 | [diff] [blame] | 593 | igt_subtest_f("suspend_psr_active") { |
| 594 | data.test_plane = PRIMARY; |
| 595 | data.op = PAGE_FLIP; |
| 596 | setup_test_plane(&data); |
| 597 | igt_assert(wait_psr_entry(&data)); |
| 598 | |
| 599 | igt_system_suspend_autoresume(); |
| 600 | |
| 601 | run_test(&data); |
| 602 | test_cleanup(&data); |
| 603 | } |
| 604 | |
| 605 | igt_subtest_f("suspend_psr_exit") { |
| 606 | data.test_plane = CURSOR; |
| 607 | data.op = PLANE_ONOFF; |
| 608 | setup_test_plane(&data); |
| 609 | |
| 610 | igt_system_suspend_autoresume(); |
| 611 | |
| 612 | igt_assert(wait_psr_entry(&data)); |
| 613 | run_test(&data); |
| 614 | test_cleanup(&data); |
| 615 | } |
| 616 | |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 617 | igt_fixture { |
| 618 | drm_intel_bufmgr_destroy(data.bufmgr); |
| 619 | display_fini(&data); |
| 620 | } |
Daniel Vetter | 3205a91 | 2014-09-23 15:15:51 +0200 | [diff] [blame] | 621 | |
| 622 | igt_exit(); |
Rodrigo Vivi | 27d37a1 | 2014-03-19 22:43:51 -0300 | [diff] [blame] | 623 | } |