Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014 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 | |
Thomas Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 24 | #include "igt.h" |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 25 | #include <errno.h> |
| 26 | #include <stdbool.h> |
| 27 | #include <stdio.h> |
| 28 | #include <string.h> |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 29 | #include <fcntl.h> |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 30 | |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 31 | |
| 32 | typedef struct { |
| 33 | int drm_fd; |
| 34 | igt_display_t display; |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 35 | int gen; |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 36 | } data_t; |
| 37 | |
| 38 | typedef struct { |
| 39 | data_t *data; |
| 40 | igt_pipe_crc_t *pipe_crc; |
| 41 | igt_crc_t crc_1, crc_2, crc_3, crc_4, crc_5, crc_6, crc_7, crc_8, |
| 42 | crc_9, crc_10; |
| 43 | struct igt_fb red_fb, blue_fb, black_fb, yellow_fb; |
| 44 | drmModeModeInfo *mode; |
| 45 | } functional_test_t; |
| 46 | |
| 47 | typedef struct { |
| 48 | data_t *data; |
| 49 | drmModeResPtr moderes; |
| 50 | struct igt_fb blue_fb, oversized_fb, undersized_fb; |
| 51 | } sanity_test_t; |
| 52 | |
| 53 | typedef struct { |
| 54 | data_t *data; |
| 55 | struct igt_fb red_fb, blue_fb; |
| 56 | } pageflip_test_t; |
| 57 | |
Matt Roper | 1a593d2 | 2015-10-06 17:04:49 -0700 | [diff] [blame] | 58 | typedef struct { |
| 59 | data_t *data; |
| 60 | int x, y; |
| 61 | int w, h; |
| 62 | struct igt_fb biggreen_fb, smallred_fb, smallblue_fb; |
| 63 | } gen9_test_t; |
| 64 | |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 65 | static void |
| 66 | functional_test_init(functional_test_t *test, igt_output_t *output, enum pipe pipe) |
| 67 | { |
| 68 | data_t *data = test->data; |
| 69 | drmModeModeInfo *mode; |
| 70 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 71 | test->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 72 | |
| 73 | igt_output_set_pipe(output, pipe); |
| 74 | |
| 75 | mode = igt_output_get_mode(output); |
| 76 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 77 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 78 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 79 | 0.0, 0.0, 0.0, |
| 80 | &test->black_fb); |
| 81 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 82 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 83 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 84 | 0.0, 0.0, 1.0, |
| 85 | &test->blue_fb); |
| 86 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 87 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 88 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 89 | 1.0, 1.0, 0.0, |
| 90 | &test->yellow_fb); |
| 91 | igt_create_color_fb(data->drm_fd, 100, 100, |
| 92 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 93 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 94 | 1.0, 0.0, 0.0, |
| 95 | &test->red_fb); |
| 96 | |
| 97 | test->mode = mode; |
| 98 | } |
| 99 | |
| 100 | static void |
| 101 | functional_test_fini(functional_test_t *test, igt_output_t *output) |
| 102 | { |
| 103 | igt_pipe_crc_free(test->pipe_crc); |
| 104 | |
| 105 | igt_remove_fb(test->data->drm_fd, &test->black_fb); |
| 106 | igt_remove_fb(test->data->drm_fd, &test->blue_fb); |
| 107 | igt_remove_fb(test->data->drm_fd, &test->red_fb); |
| 108 | igt_remove_fb(test->data->drm_fd, &test->yellow_fb); |
| 109 | |
| 110 | igt_output_set_pipe(output, PIPE_ANY); |
| 111 | igt_display_commit2(&test->data->display, COMMIT_LEGACY); |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | * Universal plane functional testing. |
| 116 | * - Black primary plane via traditional interfaces, red sprite, grab CRC:1. |
| 117 | * - Blue primary plane via traditional interfaces, red sprite, grab CRC:2. |
| 118 | * - Yellow primary via traditional interfaces |
| 119 | * - Blue primary plane, red sprite via universal planes, grab CRC:3 and compare |
| 120 | * with CRC:2 (should be the same) |
| 121 | * - Disable primary plane, grab CRC:4 (should be same as CRC:1) |
| 122 | * - Reenable primary, grab CRC:5 (should be same as CRC:2 and CRC:3) |
| 123 | * - Yellow primary, no sprite |
| 124 | * - Disable CRTC |
| 125 | * - Program red sprite (while CRTC off) |
| 126 | * - Program blue primary (while CRTC off) |
| 127 | * - Enable CRTC, grab CRC:6 (should be same as CRC:2) |
| 128 | */ |
| 129 | static void |
| 130 | functional_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) |
| 131 | { |
| 132 | functional_test_t test = { .data = data }; |
| 133 | igt_display_t *display = &data->display; |
| 134 | igt_plane_t *primary, *sprite; |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 135 | int num_primary = 0, num_cursor = 0; |
| 136 | int i; |
| 137 | |
| 138 | igt_skip_on(pipe >= display->n_pipes); |
| 139 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 140 | igt_info("Testing connector %s using pipe %s\n", igt_output_name(output), |
| 141 | kmstest_pipe_name(pipe)); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 142 | |
| 143 | functional_test_init(&test, output, pipe); |
| 144 | |
| 145 | /* |
| 146 | * Make sure we have no more than one primary or cursor plane per crtc. |
| 147 | * If the kernel accidentally calls drm_plane_init() rather than |
| 148 | * drm_universal_plane_init(), the type enum can get interpreted as a |
| 149 | * boolean and show up in userspace as the wrong type. |
| 150 | */ |
| 151 | for (i = 0; i < display->pipes[pipe].n_planes; i++) |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 152 | if (display->pipes[pipe].planes[i].type == DRM_PLANE_TYPE_PRIMARY) |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 153 | num_primary++; |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 154 | else if (display->pipes[pipe].planes[i].type == DRM_PLANE_TYPE_CURSOR) |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 155 | num_cursor++; |
| 156 | |
Matt Roper | 07be8fe | 2015-03-05 15:01:00 -0800 | [diff] [blame] | 157 | igt_assert_eq(num_primary, 1); |
| 158 | igt_assert_lte(num_cursor, 1); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 159 | |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 160 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
| 161 | sprite = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 162 | if (!sprite) { |
| 163 | functional_test_fini(&test, output); |
| 164 | igt_skip("No sprite plane available\n"); |
| 165 | } |
| 166 | |
| 167 | igt_plane_set_position(sprite, 100, 100); |
| 168 | |
| 169 | /* Step 1: Legacy API's, black primary, red sprite (CRC 1) */ |
| 170 | igt_plane_set_fb(primary, &test.black_fb); |
| 171 | igt_plane_set_fb(sprite, &test.red_fb); |
| 172 | igt_display_commit2(display, COMMIT_LEGACY); |
| 173 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_1); |
| 174 | |
| 175 | /* Step 2: Legacy API', blue primary, red sprite (CRC 2) */ |
| 176 | igt_plane_set_fb(primary, &test.blue_fb); |
| 177 | igt_plane_set_fb(sprite, &test.red_fb); |
| 178 | igt_display_commit2(display, COMMIT_LEGACY); |
| 179 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_2); |
| 180 | |
| 181 | /* Step 3: Legacy API's, yellow primary (CRC 3) */ |
| 182 | igt_plane_set_fb(primary, &test.yellow_fb); |
| 183 | igt_display_commit2(display, COMMIT_LEGACY); |
| 184 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_3); |
| 185 | |
| 186 | /* Step 4: Universal API's, blue primary, red sprite (CRC 4) */ |
| 187 | igt_plane_set_fb(primary, &test.blue_fb); |
| 188 | igt_plane_set_fb(sprite, &test.red_fb); |
| 189 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 190 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_4); |
| 191 | |
| 192 | /* Step 5: Universal API's, disable primary plane (CRC 5) */ |
| 193 | igt_plane_set_fb(primary, NULL); |
| 194 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 195 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_5); |
| 196 | |
| 197 | /* Step 6: Universal API's, re-enable primary with blue (CRC 6) */ |
| 198 | igt_plane_set_fb(primary, &test.blue_fb); |
| 199 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 200 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_6); |
| 201 | |
| 202 | /* Step 7: Legacy API's, yellow primary, no sprite */ |
| 203 | igt_plane_set_fb(primary, &test.yellow_fb); |
| 204 | igt_plane_set_fb(sprite, NULL); |
| 205 | igt_display_commit2(display, COMMIT_LEGACY); |
| 206 | |
| 207 | /* Step 8: Disable CRTC */ |
| 208 | igt_plane_set_fb(primary, NULL); |
| 209 | igt_display_commit2(display, COMMIT_LEGACY); |
| 210 | |
| 211 | /* Step 9: Universal API's with crtc off: |
| 212 | * - red sprite |
| 213 | * - multiple primary fb's, ending in blue |
| 214 | */ |
| 215 | igt_plane_set_fb(sprite, &test.red_fb); |
| 216 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 217 | igt_plane_set_fb(primary, &test.yellow_fb); |
| 218 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 219 | igt_plane_set_fb(primary, &test.black_fb); |
| 220 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 221 | igt_plane_set_fb(primary, &test.blue_fb); |
| 222 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 223 | |
| 224 | /* Step 10: Enable crtc (fb = -1), take CRC (CRC 7) */ |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 225 | igt_assert(drmModeSetCrtc(data->drm_fd, output->config.crtc->crtc_id, -1, |
| 226 | 0, 0, &output->config.connector->connector_id, |
| 227 | 1, test.mode) == 0); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 228 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_7); |
| 229 | |
| 230 | /* Step 11: Disable primary plane */ |
| 231 | igt_plane_set_fb(primary, NULL); |
| 232 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 233 | |
| 234 | /* Step 12: Legacy modeset to yellow FB (CRC 8) */ |
| 235 | igt_plane_set_fb(primary, &test.yellow_fb); |
| 236 | igt_display_commit2(display, COMMIT_LEGACY); |
| 237 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_8); |
| 238 | |
| 239 | /* Step 13: Legacy API', blue primary, red sprite */ |
| 240 | igt_plane_set_fb(primary, &test.blue_fb); |
| 241 | igt_plane_set_fb(sprite, &test.red_fb); |
| 242 | igt_display_commit2(display, COMMIT_LEGACY); |
| 243 | |
| 244 | /* Step 14: Universal API, set primary completely offscreen (CRC 9) */ |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 245 | igt_assert(drmModeSetPlane(data->drm_fd, primary->drm_plane->plane_id, |
| 246 | output->config.crtc->crtc_id, |
| 247 | test.blue_fb.fb_id, 0, |
| 248 | 9000, 9000, |
| 249 | test.mode->hdisplay, |
| 250 | test.mode->vdisplay, |
| 251 | IGT_FIXED(0,0), IGT_FIXED(0,0), |
| 252 | IGT_FIXED(test.mode->hdisplay,0), |
| 253 | IGT_FIXED(test.mode->vdisplay,0)) == 0); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 254 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_9); |
| 255 | |
| 256 | /* |
| 257 | * Step 15: Explicitly disable primary after it's already been |
| 258 | * implicitly disabled (CRC 10). |
| 259 | */ |
| 260 | igt_plane_set_fb(primary, NULL); |
| 261 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 262 | igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_10); |
| 263 | |
| 264 | /* Step 16: Legacy API's, blue primary, red sprite */ |
| 265 | igt_plane_set_fb(primary, &test.blue_fb); |
| 266 | igt_plane_set_fb(sprite, &test.red_fb); |
| 267 | igt_display_commit2(display, COMMIT_LEGACY); |
| 268 | |
| 269 | /* Blue bg + red sprite should be same under both types of API's */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 270 | igt_assert_crc_equal(&test.crc_2, &test.crc_4); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 271 | |
| 272 | /* Disabling primary plane should be same as black primary */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 273 | igt_assert_crc_equal(&test.crc_1, &test.crc_5); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 274 | |
| 275 | /* Re-enabling primary should return to blue properly */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 276 | igt_assert_crc_equal(&test.crc_2, &test.crc_6); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 277 | |
| 278 | /* |
| 279 | * We should be able to setup plane FB's while CRTC is disabled and |
| 280 | * then have them pop up correctly when the CRTC is re-enabled. |
| 281 | */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 282 | igt_assert_crc_equal(&test.crc_2, &test.crc_7); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 283 | |
| 284 | /* |
| 285 | * We should be able to modeset with the primary plane off |
| 286 | * successfully |
| 287 | */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 288 | igt_assert_crc_equal(&test.crc_3, &test.crc_8); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 289 | |
| 290 | /* |
| 291 | * We should be able to move the primary plane completely offscreen |
| 292 | * and have it disable successfully. |
| 293 | */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 294 | igt_assert_crc_equal(&test.crc_5, &test.crc_9); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 295 | |
| 296 | /* |
| 297 | * We should be able to explicitly disable an already |
| 298 | * implicitly-disabled primary plane |
| 299 | */ |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 300 | igt_assert_crc_equal(&test.crc_5, &test.crc_10); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 301 | |
| 302 | igt_plane_set_fb(primary, NULL); |
| 303 | igt_plane_set_fb(sprite, NULL); |
| 304 | |
| 305 | functional_test_fini(&test, output); |
| 306 | } |
| 307 | |
| 308 | static void |
| 309 | sanity_test_init(sanity_test_t *test, igt_output_t *output, enum pipe pipe) |
| 310 | { |
| 311 | data_t *data = test->data; |
| 312 | drmModeModeInfo *mode; |
| 313 | |
| 314 | igt_output_set_pipe(output, pipe); |
| 315 | |
| 316 | mode = igt_output_get_mode(output); |
| 317 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 318 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 319 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 320 | 0.0, 0.0, 1.0, |
| 321 | &test->blue_fb); |
| 322 | igt_create_color_fb(data->drm_fd, |
| 323 | mode->hdisplay + 100, mode->vdisplay + 100, |
| 324 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 325 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 326 | 0.0, 0.0, 1.0, |
| 327 | &test->oversized_fb); |
| 328 | igt_create_color_fb(data->drm_fd, |
| 329 | mode->hdisplay - 100, mode->vdisplay - 100, |
| 330 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 331 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 332 | 0.0, 0.0, 1.0, |
| 333 | &test->undersized_fb); |
| 334 | |
| 335 | test->moderes = drmModeGetResources(data->drm_fd); |
| 336 | } |
| 337 | |
| 338 | static void |
| 339 | sanity_test_fini(sanity_test_t *test, igt_output_t *output) |
| 340 | { |
| 341 | drmModeFreeResources(test->moderes); |
| 342 | |
| 343 | igt_remove_fb(test->data->drm_fd, &test->oversized_fb); |
| 344 | igt_remove_fb(test->data->drm_fd, &test->undersized_fb); |
| 345 | igt_remove_fb(test->data->drm_fd, &test->blue_fb); |
| 346 | |
| 347 | igt_output_set_pipe(output, PIPE_ANY); |
| 348 | igt_display_commit2(&test->data->display, COMMIT_LEGACY); |
| 349 | } |
| 350 | |
| 351 | /* |
| 352 | * Universal plane sanity testing. |
| 353 | * - Primary doesn't cover CRTC |
| 354 | * - Primary plane tries to scale down |
| 355 | * - Primary plane tries to scale up |
| 356 | */ |
| 357 | static void |
| 358 | sanity_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) |
| 359 | { |
| 360 | sanity_test_t test = { .data = data }; |
| 361 | igt_plane_t *primary; |
| 362 | drmModeModeInfo *mode; |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 363 | int i; |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 364 | int expect; |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 365 | |
Matt Roper | 89201c5 | 2015-01-26 09:23:51 -0800 | [diff] [blame] | 366 | igt_skip_on(pipe >= data->display.n_pipes); |
| 367 | |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 368 | igt_output_set_pipe(output, pipe); |
| 369 | mode = igt_output_get_mode(output); |
| 370 | |
| 371 | sanity_test_init(&test, output, pipe); |
| 372 | |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 373 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 374 | |
| 375 | /* Use legacy API to set a mode with a blue FB */ |
| 376 | igt_plane_set_fb(primary, &test.blue_fb); |
| 377 | igt_display_commit2(&data->display, COMMIT_LEGACY); |
| 378 | |
| 379 | /* |
| 380 | * Try to use universal plane API to set primary plane that |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 381 | * doesn't cover CRTC (should fail on pre-gen9 and succeed on |
| 382 | * gen9+). |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 383 | */ |
| 384 | igt_plane_set_fb(primary, &test.undersized_fb); |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 385 | expect = (data->gen < 9) ? -EINVAL : 0; |
| 386 | igt_assert(igt_display_try_commit2(&data->display, COMMIT_UNIVERSAL) == expect); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 387 | |
| 388 | /* Same as above, but different plane positioning. */ |
| 389 | igt_plane_set_position(primary, 100, 100); |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 390 | igt_assert(igt_display_try_commit2(&data->display, COMMIT_UNIVERSAL) == expect); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 391 | |
| 392 | igt_plane_set_position(primary, 0, 0); |
| 393 | |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 394 | /* Try to use universal plane API to scale down (should fail on pre-gen9) */ |
| 395 | expect = (data->gen < 9) ? -ERANGE : 0; |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 396 | igt_assert(drmModeSetPlane(data->drm_fd, primary->drm_plane->plane_id, |
| 397 | output->config.crtc->crtc_id, |
| 398 | test.oversized_fb.fb_id, 0, |
| 399 | 0, 0, |
| 400 | mode->hdisplay + 100, |
| 401 | mode->vdisplay + 100, |
| 402 | IGT_FIXED(0,0), IGT_FIXED(0,0), |
| 403 | IGT_FIXED(mode->hdisplay,0), |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 404 | IGT_FIXED(mode->vdisplay,0)) == expect); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 405 | |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 406 | /* Try to use universal plane API to scale up (should fail on pre-gen9) */ |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 407 | igt_assert(drmModeSetPlane(data->drm_fd, primary->drm_plane->plane_id, |
| 408 | output->config.crtc->crtc_id, |
| 409 | test.oversized_fb.fb_id, 0, |
| 410 | 0, 0, |
| 411 | mode->hdisplay, |
| 412 | mode->vdisplay, |
| 413 | IGT_FIXED(0,0), IGT_FIXED(0,0), |
| 414 | IGT_FIXED(mode->hdisplay - 100,0), |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 415 | IGT_FIXED(mode->vdisplay - 100,0)) == expect); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 416 | |
| 417 | /* Find other crtcs and try to program our primary plane on them */ |
| 418 | for (i = 0; i < test.moderes->count_crtcs; i++) |
| 419 | if (test.moderes->crtcs[i] != output->config.crtc->crtc_id) { |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 420 | igt_assert(drmModeSetPlane(data->drm_fd, |
| 421 | primary->drm_plane->plane_id, |
| 422 | test.moderes->crtcs[i], |
| 423 | test.blue_fb.fb_id, 0, |
| 424 | 0, 0, |
| 425 | mode->hdisplay, |
| 426 | mode->vdisplay, |
| 427 | IGT_FIXED(0,0), IGT_FIXED(0,0), |
| 428 | IGT_FIXED(mode->hdisplay,0), |
| 429 | IGT_FIXED(mode->vdisplay,0)) == -EINVAL); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | igt_plane_set_fb(primary, NULL); |
| 433 | sanity_test_fini(&test, output); |
| 434 | } |
| 435 | |
| 436 | static void |
| 437 | pageflip_test_init(pageflip_test_t *test, igt_output_t *output, enum pipe pipe) |
| 438 | { |
| 439 | data_t *data = test->data; |
| 440 | drmModeModeInfo *mode; |
| 441 | |
| 442 | igt_output_set_pipe(output, pipe); |
| 443 | |
| 444 | mode = igt_output_get_mode(output); |
| 445 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 446 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 447 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 448 | 1.0, 0.0, 0.0, |
| 449 | &test->red_fb); |
| 450 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 451 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 452 | LOCAL_DRM_FORMAT_MOD_NONE, |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 453 | 0.0, 0.0, 1.0, |
| 454 | &test->blue_fb); |
| 455 | } |
| 456 | |
| 457 | static void |
| 458 | pageflip_test_fini(pageflip_test_t *test, igt_output_t *output) |
| 459 | { |
| 460 | igt_remove_fb(test->data->drm_fd, &test->red_fb); |
| 461 | igt_remove_fb(test->data->drm_fd, &test->blue_fb); |
| 462 | |
| 463 | igt_output_set_pipe(output, PIPE_ANY); |
| 464 | igt_display_commit2(&test->data->display, COMMIT_LEGACY); |
| 465 | } |
| 466 | |
| 467 | static void |
| 468 | pageflip_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) |
| 469 | { |
| 470 | pageflip_test_t test = { .data = data }; |
| 471 | igt_plane_t *primary; |
| 472 | struct timeval timeout = { .tv_sec = 0, .tv_usec = 500 }; |
Daniel Stone | d7db79d | 2017-04-07 14:15:26 +0100 | [diff] [blame] | 473 | drmEventContext evctx = { .version = 2 }; |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 474 | |
| 475 | fd_set fds; |
| 476 | int ret = 0; |
| 477 | |
Matt Roper | 89201c5 | 2015-01-26 09:23:51 -0800 | [diff] [blame] | 478 | igt_skip_on(pipe >= data->display.n_pipes); |
| 479 | |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 480 | igt_output_set_pipe(output, pipe); |
| 481 | |
| 482 | pageflip_test_init(&test, output, pipe); |
| 483 | |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 484 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 485 | |
| 486 | /* Use legacy API to set a mode with a blue FB */ |
| 487 | igt_plane_set_fb(primary, &test.blue_fb); |
| 488 | igt_display_commit2(&data->display, COMMIT_LEGACY); |
| 489 | |
| 490 | /* Disable the primary plane */ |
| 491 | igt_plane_set_fb(primary, NULL); |
| 492 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 493 | |
| 494 | /* |
| 495 | * Issue a pageflip to red FB |
| 496 | * |
| 497 | * Note that crtc->primary->fb = NULL causes flip to return EBUSY for |
| 498 | * historical reasons... |
| 499 | */ |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 500 | igt_assert(drmModePageFlip(data->drm_fd, output->config.crtc->crtc_id, |
| 501 | test.red_fb.fb_id, 0, NULL) == -EBUSY); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 502 | |
| 503 | /* Turn primary plane back on */ |
| 504 | igt_plane_set_fb(primary, &test.blue_fb); |
| 505 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 506 | |
| 507 | /* |
| 508 | * Issue a pageflip to red, then immediately try to disable the primary |
| 509 | * plane, hopefully before the pageflip has a chance to complete. The |
| 510 | * plane disable operation should wind up blocking while the pageflip |
| 511 | * completes, which we don't have a good way to specifically test for, |
| 512 | * but at least we can make sure that nothing blows up. |
| 513 | */ |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 514 | igt_assert(drmModePageFlip(data->drm_fd, output->config.crtc->crtc_id, |
| 515 | test.red_fb.fb_id, DRM_MODE_PAGE_FLIP_EVENT, |
| 516 | &test) == 0); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 517 | igt_plane_set_fb(primary, NULL); |
| 518 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 519 | |
| 520 | /* Wait for pageflip completion, then consume event on fd */ |
| 521 | FD_ZERO(&fds); |
| 522 | FD_SET(data->drm_fd, &fds); |
| 523 | do { |
| 524 | ret = select(data->drm_fd + 1, &fds, NULL, NULL, &timeout); |
| 525 | } while (ret < 0 && errno == EINTR); |
Matt Roper | 07be8fe | 2015-03-05 15:01:00 -0800 | [diff] [blame] | 526 | igt_assert_eq(ret, 1); |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 527 | igt_assert(drmHandleEvent(data->drm_fd, &evctx) == 0); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 528 | |
| 529 | igt_plane_set_fb(primary, NULL); |
| 530 | pageflip_test_fini(&test, output); |
| 531 | } |
| 532 | |
| 533 | static void |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 534 | cursor_leak_test_fini(data_t *data, |
| 535 | igt_output_t *output, |
| 536 | struct igt_fb *bg, |
| 537 | struct igt_fb *curs) |
| 538 | { |
| 539 | int i; |
| 540 | |
| 541 | igt_remove_fb(data->drm_fd, bg); |
| 542 | for (i = 0; i < 10; i++) |
| 543 | igt_remove_fb(data->drm_fd, &curs[i]); |
| 544 | |
| 545 | igt_output_set_pipe(output, PIPE_ANY); |
| 546 | } |
| 547 | |
| 548 | static int |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 549 | i915_gem_fb_count(data_t *data) |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 550 | { |
| 551 | char buf[1024]; |
| 552 | FILE *fp; |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 553 | int fd; |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 554 | int count = 0; |
| 555 | |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 556 | fd = igt_debugfs_open(data->drm_fd, "i915_gem_framebuffer", O_RDONLY); |
| 557 | fp = fdopen(fd, "r"); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 558 | igt_require(fp); |
| 559 | while (fgets(buf, sizeof(buf), fp) != NULL) |
| 560 | count++; |
| 561 | fclose(fp); |
Chris Wilson | e08ed8a | 2017-03-24 20:52:44 +0000 | [diff] [blame] | 562 | close(fd); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 563 | |
| 564 | return count; |
| 565 | } |
| 566 | |
| 567 | static void |
| 568 | cursor_leak_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) |
| 569 | { |
| 570 | igt_display_t *display = &data->display; |
| 571 | igt_plane_t *primary, *cursor; |
| 572 | drmModeModeInfo *mode; |
| 573 | struct igt_fb background_fb; |
| 574 | struct igt_fb cursor_fb[10]; |
| 575 | int i; |
| 576 | int r, g, b; |
| 577 | int count1, count2; |
| 578 | |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 579 | igt_skip_on(pipe >= display->n_pipes); |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 580 | igt_require(display->has_cursor_plane); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 581 | |
| 582 | igt_output_set_pipe(output, pipe); |
| 583 | mode = igt_output_get_mode(output); |
| 584 | |
| 585 | /* Count GEM framebuffers before creating our cursor FB's */ |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 586 | count1 = i915_gem_fb_count(data); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 587 | |
| 588 | /* Black background FB */ |
| 589 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 590 | DRM_FORMAT_XRGB8888, |
| 591 | false, |
| 592 | 0.0, 0.0, 0.0, |
| 593 | &background_fb); |
| 594 | |
| 595 | /* Random color cursors */ |
| 596 | for (i = 0; i < 10; i++) { |
| 597 | r = rand() % 0xFF; |
| 598 | g = rand() % 0xFF; |
| 599 | b = rand() % 0xFF; |
| 600 | igt_create_color_fb(data->drm_fd, 64, 64, |
| 601 | DRM_FORMAT_ARGB8888, |
| 602 | false, |
| 603 | (double)r / 0xFF, |
| 604 | (double)g / 0xFF, |
| 605 | (double)b / 0xFF, |
| 606 | &cursor_fb[i]); |
| 607 | } |
| 608 | |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 609 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
| 610 | cursor = igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 611 | if (!primary || !cursor) { |
| 612 | cursor_leak_test_fini(data, output, &background_fb, cursor_fb); |
| 613 | igt_skip("Primary and/or cursor are unavailable\n"); |
| 614 | } |
| 615 | |
| 616 | |
| 617 | igt_plane_set_fb(primary, &background_fb); |
| 618 | igt_display_commit2(display, COMMIT_LEGACY); |
| 619 | |
| 620 | igt_plane_set_position(cursor, 100, 100); |
| 621 | |
| 622 | /* |
| 623 | * Exercise both legacy and universal code paths. Note that legacy |
| 624 | * handling in the kernel redirects through universal codepaths |
| 625 | * internally, so that redirection is where we're most worried about |
| 626 | * leaking. |
| 627 | */ |
| 628 | for (i = 0; i < 10; i++) { |
| 629 | igt_plane_set_fb(cursor, &cursor_fb[i]); |
| 630 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 631 | } |
| 632 | for (i = 0; i < 10; i++) { |
| 633 | igt_plane_set_fb(cursor, &cursor_fb[i]); |
| 634 | igt_display_commit2(display, COMMIT_LEGACY); |
| 635 | } |
| 636 | |
| 637 | /* Release our framebuffer handles before we take a second count */ |
| 638 | igt_plane_set_fb(primary, NULL); |
| 639 | igt_plane_set_fb(cursor, NULL); |
| 640 | igt_display_commit2(display, COMMIT_LEGACY); |
| 641 | cursor_leak_test_fini(data, output, &background_fb, cursor_fb); |
| 642 | |
| 643 | /* We should be back to the same framebuffer count as when we started */ |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 644 | count2 = i915_gem_fb_count(data); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 645 | |
Daniel Vetter | e3f8eb5 | 2015-02-27 16:18:40 +0100 | [diff] [blame] | 646 | igt_assert_eq(count1, count2); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | static void |
Matt Roper | 1a593d2 | 2015-10-06 17:04:49 -0700 | [diff] [blame] | 650 | gen9_test_init(gen9_test_t *test, igt_output_t *output, enum pipe pipe) |
| 651 | { |
| 652 | data_t *data = test->data; |
| 653 | drmModeModeInfo *mode; |
| 654 | |
| 655 | igt_output_set_pipe(output, pipe); |
| 656 | |
| 657 | mode = igt_output_get_mode(output); |
| 658 | test->w = mode->hdisplay / 2; |
| 659 | test->h = mode->vdisplay / 2; |
| 660 | test->x = mode->hdisplay / 4; |
| 661 | test->y = mode->vdisplay / 4; |
| 662 | |
| 663 | /* Initial framebuffer of full CRTC size */ |
| 664 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 665 | DRM_FORMAT_XRGB8888, |
| 666 | LOCAL_DRM_FORMAT_MOD_NONE, |
| 667 | 0.0, 1.0, 0.0, |
| 668 | &test->biggreen_fb); |
| 669 | |
| 670 | /* Framebuffers that only cover a quarter of the CRTC size */ |
| 671 | igt_create_color_fb(data->drm_fd, test->w, test->h, |
| 672 | DRM_FORMAT_XRGB8888, |
| 673 | LOCAL_DRM_FORMAT_MOD_NONE, |
| 674 | 1.0, 0.0, 0.0, |
| 675 | &test->smallred_fb); |
| 676 | igt_create_color_fb(data->drm_fd, test->w, test->h, |
| 677 | DRM_FORMAT_XRGB8888, |
| 678 | LOCAL_DRM_FORMAT_MOD_NONE, |
| 679 | 0.0, 0.0, 1.0, |
| 680 | &test->smallblue_fb); |
| 681 | } |
| 682 | |
| 683 | static void |
| 684 | gen9_test_fini(gen9_test_t *test, igt_output_t *output) |
| 685 | { |
| 686 | igt_remove_fb(test->data->drm_fd, &test->biggreen_fb); |
| 687 | igt_remove_fb(test->data->drm_fd, &test->smallred_fb); |
| 688 | igt_remove_fb(test->data->drm_fd, &test->smallblue_fb); |
| 689 | |
| 690 | igt_output_set_pipe(output, PIPE_ANY); |
| 691 | igt_display_commit2(&test->data->display, COMMIT_LEGACY); |
| 692 | } |
| 693 | |
| 694 | /* |
| 695 | * Test features specific to gen9+ platforms (i.e., primary plane |
| 696 | * windowing) |
| 697 | */ |
| 698 | static void |
| 699 | gen9_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) |
| 700 | { |
| 701 | gen9_test_t test = { .data = data }; |
| 702 | igt_plane_t *primary; |
| 703 | |
| 704 | int ret = 0; |
| 705 | |
| 706 | igt_skip_on(data->gen < 9); |
| 707 | igt_skip_on(pipe >= data->display.n_pipes); |
| 708 | |
| 709 | igt_output_set_pipe(output, pipe); |
| 710 | |
| 711 | gen9_test_init(&test, output, pipe); |
| 712 | |
Robert Foss | 265a3a5 | 2017-01-10 20:19:46 -0500 | [diff] [blame] | 713 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Matt Roper | 1a593d2 | 2015-10-06 17:04:49 -0700 | [diff] [blame] | 714 | |
| 715 | /* Start with a full-screen primary plane */ |
| 716 | igt_plane_set_fb(primary, &test.biggreen_fb); |
| 717 | igt_display_commit2(&data->display, COMMIT_LEGACY); |
| 718 | |
| 719 | /* Set primary to windowed size/position */ |
| 720 | igt_plane_set_fb(primary, &test.smallblue_fb); |
| 721 | igt_plane_set_position(primary, test.x, test.y); |
| 722 | igt_plane_set_size(primary, test.w, test.h); |
| 723 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 724 | |
| 725 | /* |
| 726 | * SetPlane update to another framebuffer of the same size |
| 727 | * should succeed |
| 728 | */ |
| 729 | igt_plane_set_fb(primary, &test.smallred_fb); |
| 730 | igt_plane_set_position(primary, test.x, test.y); |
| 731 | igt_plane_set_size(primary, test.w, test.h); |
| 732 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 733 | |
| 734 | /* PageFlip should also succeed */ |
| 735 | ret = drmModePageFlip(data->drm_fd, output->config.crtc->crtc_id, |
| 736 | test.smallblue_fb.fb_id, 0, NULL); |
| 737 | igt_assert_eq(ret, 0); |
| 738 | |
| 739 | igt_plane_set_fb(primary, NULL); |
| 740 | igt_plane_set_position(primary, 0, 0); |
| 741 | gen9_test_fini(&test, output); |
| 742 | } |
| 743 | |
| 744 | static void |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 745 | run_tests_for_pipe(data_t *data, enum pipe pipe) |
| 746 | { |
| 747 | igt_output_t *output; |
| 748 | |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 749 | igt_fixture { |
| 750 | int valid_tests = 0; |
| 751 | |
| 752 | igt_skip_on(pipe >= data->display.n_pipes); |
| 753 | |
| 754 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
| 755 | valid_tests++; |
| 756 | |
| 757 | igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); |
| 758 | } |
| 759 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 760 | igt_subtest_f("universal-plane-pipe-%s-functional", |
| 761 | kmstest_pipe_name(pipe)) |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 762 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 763 | functional_test_pipe(data, pipe, output); |
| 764 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 765 | igt_subtest_f("universal-plane-pipe-%s-sanity", |
| 766 | kmstest_pipe_name(pipe)) |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 767 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 768 | sanity_test_pipe(data, pipe, output); |
| 769 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 770 | igt_subtest_f("disable-primary-vs-flip-pipe-%s", |
| 771 | kmstest_pipe_name(pipe)) |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 772 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 773 | pageflip_test_pipe(data, pipe, output); |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 774 | |
| 775 | igt_subtest_f("cursor-fb-leak-pipe-%s", |
| 776 | kmstest_pipe_name(pipe)) |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 777 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
Matt Roper | 59d8d66 | 2015-02-26 19:00:19 -0800 | [diff] [blame] | 778 | cursor_leak_test_pipe(data, pipe, output); |
Matt Roper | 1a593d2 | 2015-10-06 17:04:49 -0700 | [diff] [blame] | 779 | |
| 780 | igt_subtest_f("universal-plane-gen9-features-pipe-%s", |
| 781 | kmstest_pipe_name(pipe)) |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 782 | for_each_valid_output_on_pipe(&data->display, pipe, output) |
Matt Roper | 1a593d2 | 2015-10-06 17:04:49 -0700 | [diff] [blame] | 783 | gen9_test_pipe(data, pipe, output); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | static data_t data; |
| 787 | |
| 788 | igt_main |
| 789 | { |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 790 | igt_skip_on_simulation(); |
| 791 | |
| 792 | igt_fixture { |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 793 | data.drm_fd = drm_open_driver_master(DRIVER_INTEL); |
Matt Roper | b81f7db | 2015-07-01 15:45:21 -0700 | [diff] [blame] | 794 | data.gen = intel_gen(intel_get_drm_devid(data.drm_fd)); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 795 | |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 796 | kmstest_set_vt_graphics_mode(); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 797 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 798 | igt_require_pipe_crc(data.drm_fd); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 799 | igt_display_init(&data.display, data.drm_fd); |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 800 | } |
| 801 | |
Leo (Sunpeng) Li | df68217 | 2017-06-09 17:13:04 -0400 | [diff] [blame] | 802 | for (int pipe = 0; pipe < IGT_MAX_PIPES; pipe++) { |
Maarten Lankhorst | ef8cff6 | 2017-01-12 16:08:30 +0100 | [diff] [blame] | 803 | igt_subtest_group |
| 804 | run_tests_for_pipe(&data, pipe); |
| 805 | } |
Matt Roper | 075d9ea | 2014-06-30 16:44:28 -0700 | [diff] [blame] | 806 | |
| 807 | igt_fixture { |
| 808 | igt_display_fini(&data.display); |
| 809 | } |
| 810 | } |