Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [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 | * Authors: |
| 24 | * Damien Lespiau <damien.lespiau@intel.com> |
| 25 | */ |
| 26 | |
Thomas Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 27 | #include "igt.h" |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 28 | #include <errno.h> |
| 29 | #include <stdbool.h> |
| 30 | #include <stdio.h> |
| 31 | #include <string.h> |
| 32 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 33 | |
| 34 | typedef struct { |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 35 | float red; |
| 36 | float green; |
| 37 | float blue; |
| 38 | } color_t; |
| 39 | |
| 40 | typedef struct { |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 41 | int drm_fd; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 42 | igt_display_t display; |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 43 | igt_pipe_crc_t *pipe_crc; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 44 | } data_t; |
| 45 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 46 | static color_t red = { 1.0f, 0.0f, 0.0f }; |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 47 | static color_t green = { 0.0f, 1.0f, 0.0f }; |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 48 | static color_t blue = { 0.0f, 0.0f, 1.0f }; |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Common code across all tests, acting on data_t |
| 52 | */ |
| 53 | static void test_init(data_t *data, enum pipe pipe) |
| 54 | { |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 55 | data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static void test_fini(data_t *data) |
| 59 | { |
| 60 | igt_pipe_crc_free(data->pipe_crc); |
| 61 | } |
| 62 | |
| 63 | static void |
Damien Lespiau | c5b9615 | 2014-07-09 11:05:06 +0100 | [diff] [blame] | 64 | test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe, |
| 65 | color_t *fb_color, igt_crc_t *crc /* out */) |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 66 | { |
| 67 | struct igt_fb fb; |
| 68 | drmModeModeInfo *mode; |
| 69 | igt_plane_t *primary; |
Damien Lespiau | 8d60b82 | 2014-07-07 14:41:15 +0100 | [diff] [blame] | 70 | char *crc_str; |
Feceoru, Gabriel | 8adb5a0 | 2016-02-26 14:59:03 +0200 | [diff] [blame] | 71 | int ret; |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 72 | |
Damien Lespiau | c5b9615 | 2014-07-09 11:05:06 +0100 | [diff] [blame] | 73 | igt_output_set_pipe(output, pipe); |
| 74 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 75 | primary = igt_output_get_plane(output, 0); |
| 76 | |
| 77 | mode = igt_output_get_mode(output); |
| 78 | igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 79 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 80 | LOCAL_DRM_FORMAT_MOD_NONE, |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 81 | fb_color->red, fb_color->green, fb_color->blue, |
| 82 | &fb); |
| 83 | igt_plane_set_fb(primary, &fb); |
| 84 | |
Feceoru, Gabriel | 8adb5a0 | 2016-02-26 14:59:03 +0200 | [diff] [blame] | 85 | ret = igt_display_try_commit2(&data->display, COMMIT_LEGACY); |
| 86 | igt_skip_on(ret != 0); |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 87 | |
| 88 | igt_pipe_crc_collect_crc(data->pipe_crc, crc); |
| 89 | |
| 90 | igt_plane_set_fb(primary, NULL); |
| 91 | igt_display_commit(&data->display); |
| 92 | |
| 93 | igt_remove_fb(data->drm_fd, &fb); |
Damien Lespiau | 8d60b82 | 2014-07-07 14:41:15 +0100 | [diff] [blame] | 94 | |
| 95 | crc_str = igt_crc_to_string(crc); |
| 96 | igt_debug("CRC for a (%.02f,%.02f,%.02f) fb: %s\n", fb_color->red, |
| 97 | fb_color->green, fb_color->blue, crc_str); |
| 98 | free(crc_str); |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 101 | /* |
| 102 | * Plane position test. |
| 103 | * - We start by grabbing a reference CRC of a full green fb being scanned |
| 104 | * out on the primary plane |
| 105 | * - Then we scannout 2 planes: |
| 106 | * - the primary plane uses a green fb with a black rectangle |
| 107 | * - a plane, on top of the primary plane, with a green fb that is set-up |
| 108 | * to cover the black rectangle of the primary plane fb |
| 109 | * The resulting CRC should be identical to the reference CRC |
| 110 | */ |
| 111 | |
| 112 | typedef struct { |
| 113 | data_t *data; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 114 | igt_crc_t reference_crc; |
| 115 | } test_position_t; |
| 116 | |
| 117 | /* |
| 118 | * create a green fb with a black rectangle at (rect_x,rect_y) and of size |
| 119 | * (rect_w,rect_h) |
| 120 | */ |
| 121 | static void |
| 122 | create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode, |
| 123 | double rect_x, double rect_y, |
| 124 | double rect_w, double rect_h, |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 125 | struct igt_fb *fb /* out */) |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 126 | { |
| 127 | unsigned int fb_id; |
| 128 | cairo_t *cr; |
| 129 | |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 130 | fb_id = igt_create_fb(data->drm_fd, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 131 | mode->hdisplay, mode->vdisplay, |
Daniel Vetter | 7018216 | 2014-03-23 16:36:40 +0100 | [diff] [blame] | 132 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 133 | LOCAL_DRM_FORMAT_MOD_NONE, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 134 | fb); |
| 135 | igt_assert(fb_id); |
| 136 | |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 137 | cr = igt_get_cairo_ctx(data->drm_fd, fb); |
| 138 | igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 139 | 0.0, 1.0, 0.0); |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 140 | igt_paint_color(cr, rect_x, rect_y, rect_w, rect_h, 0.0, 0.0, 0.0); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 141 | igt_assert(cairo_status(cr) == 0); |
| 142 | cairo_destroy(cr); |
| 143 | } |
| 144 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 145 | enum { |
| 146 | TEST_POSITION_FULLY_COVERED = 1 << 0, |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 147 | TEST_DPMS = 1 << 1, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static void |
| 151 | test_plane_position_with_output(data_t *data, |
| 152 | enum pipe pipe, |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 153 | int plane, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 154 | igt_output_t *output, |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 155 | igt_crc_t *reference_crc, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 156 | unsigned int flags) |
| 157 | { |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 158 | igt_plane_t *primary, *sprite; |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 159 | struct igt_fb primary_fb, sprite_fb; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 160 | drmModeModeInfo *mode; |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 161 | igt_crc_t crc, crc2; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 162 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 163 | igt_info("Testing connector %s using pipe %s plane %d\n", |
| 164 | igt_output_name(output), kmstest_pipe_name(pipe), plane); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 165 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 166 | igt_output_set_pipe(output, pipe); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 167 | |
| 168 | mode = igt_output_get_mode(output); |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 169 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Damien Lespiau | 2043e6b | 2014-02-11 17:45:48 +0000 | [diff] [blame] | 170 | sprite = igt_output_get_plane(output, plane); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 171 | |
| 172 | create_fb_for_mode__position(data, mode, 100, 100, 64, 64, |
| 173 | &primary_fb); |
| 174 | igt_plane_set_fb(primary, &primary_fb); |
| 175 | |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 176 | igt_create_color_fb(data->drm_fd, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 177 | 64, 64, /* width, height */ |
| 178 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 179 | LOCAL_DRM_FORMAT_MOD_NONE, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 180 | 0.0, 1.0, 0.0, |
| 181 | &sprite_fb); |
| 182 | igt_plane_set_fb(sprite, &sprite_fb); |
| 183 | |
| 184 | if (flags & TEST_POSITION_FULLY_COVERED) |
| 185 | igt_plane_set_position(sprite, 100, 100); |
| 186 | else |
| 187 | igt_plane_set_position(sprite, 132, 132); |
| 188 | |
| 189 | igt_display_commit(&data->display); |
| 190 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 191 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 192 | |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 193 | if (flags & TEST_DPMS) { |
| 194 | kmstest_set_connector_dpms(data->drm_fd, |
| 195 | output->config.connector, |
| 196 | DRM_MODE_DPMS_OFF); |
| 197 | kmstest_set_connector_dpms(data->drm_fd, |
| 198 | output->config.connector, |
| 199 | DRM_MODE_DPMS_ON); |
| 200 | } |
| 201 | |
| 202 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc2); |
| 203 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 204 | if (flags & TEST_POSITION_FULLY_COVERED) |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 205 | igt_assert_crc_equal(reference_crc, &crc); |
Daniel Vetter | 92709f0 | 2017-09-05 14:36:16 +0200 | [diff] [blame] | 206 | else { |
Daniel Vetter | 562bbe1 | 2015-02-27 22:04:18 +0100 | [diff] [blame] | 207 | ;/* FIXME: missing reference CRCs */ |
Daniel Vetter | 92709f0 | 2017-09-05 14:36:16 +0200 | [diff] [blame] | 208 | } |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 209 | |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 210 | igt_assert_crc_equal(&crc, &crc2); |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 211 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 212 | igt_plane_set_fb(primary, NULL); |
| 213 | igt_plane_set_fb(sprite, NULL); |
| 214 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 215 | /* reset the constraint on the pipe */ |
| 216 | igt_output_set_pipe(output, PIPE_ANY); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | static void |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 220 | test_plane_position(data_t *data, enum pipe pipe, unsigned int flags) |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 221 | { |
| 222 | igt_output_t *output; |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 223 | int connected_outs = 0; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 224 | |
Maarten Lankhorst | c79e6d8 | 2017-01-16 11:35:43 +0100 | [diff] [blame] | 225 | for_each_valid_output_on_pipe(&data->display, pipe, output) { |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 226 | int n_planes = data->display.pipes[pipe].n_planes; |
| 227 | igt_crc_t reference_crc; |
| 228 | |
| 229 | test_init(data, pipe); |
| 230 | |
| 231 | test_grab_crc(data, output, pipe, &green, &reference_crc); |
| 232 | |
| 233 | for (int plane = 1; plane < n_planes; plane++) |
| 234 | test_plane_position_with_output(data, pipe, plane, |
| 235 | output, &reference_crc, |
| 236 | flags); |
| 237 | |
| 238 | test_fini(data); |
| 239 | |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 240 | connected_outs++; |
| 241 | } |
| 242 | |
| 243 | igt_skip_on(connected_outs == 0); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 246 | /* |
| 247 | * Plane panning test. |
| 248 | * - We start by grabbing reference CRCs of a full red and a full blue fb |
| 249 | * being scanned out on the primary plane |
| 250 | * - Then we create a big fb, sized (2 * hdisplay, 2 * vdisplay) and: |
| 251 | * - fill the top left quarter with red |
| 252 | * - fill the bottom right quarter with blue |
| 253 | * - The TEST_PANNING_TOP_LEFT test makes sure that with panning at (0, 0) |
| 254 | * we do get the same CRC than the full red fb. |
| 255 | * - The TEST_PANNING_BOTTOM_RIGHT test makes sure that with panning at |
| 256 | * (vdisplay, hdisplay) we do get the same CRC than the full blue fb. |
| 257 | */ |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 258 | static void |
| 259 | create_fb_for_mode__panning(data_t *data, drmModeModeInfo *mode, |
| 260 | struct igt_fb *fb /* out */) |
| 261 | { |
| 262 | unsigned int fb_id; |
| 263 | cairo_t *cr; |
| 264 | |
| 265 | fb_id = igt_create_fb(data->drm_fd, |
| 266 | mode->hdisplay * 2, mode->vdisplay * 2, |
| 267 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 268 | LOCAL_DRM_FORMAT_MOD_NONE, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 269 | fb); |
| 270 | igt_assert(fb_id); |
| 271 | |
| 272 | cr = igt_get_cairo_ctx(data->drm_fd, fb); |
| 273 | |
| 274 | igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, |
| 275 | 1.0, 0.0, 0.0); |
| 276 | |
| 277 | igt_paint_color(cr, |
| 278 | mode->hdisplay, mode->vdisplay, |
| 279 | mode->hdisplay, mode->vdisplay, |
| 280 | 0.0, 0.0, 1.0); |
| 281 | |
| 282 | igt_assert(cairo_status(cr) == 0); |
| 283 | cairo_destroy(cr); |
| 284 | } |
| 285 | |
| 286 | enum { |
| 287 | TEST_PANNING_TOP_LEFT = 1 << 0, |
| 288 | TEST_PANNING_BOTTOM_RIGHT = 1 << 1, |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 289 | TEST_SUSPEND_RESUME = 1 << 2, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | static void |
| 293 | test_plane_panning_with_output(data_t *data, |
| 294 | enum pipe pipe, |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 295 | int plane, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 296 | igt_output_t *output, |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 297 | igt_crc_t *red_crc, igt_crc_t *blue_crc, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 298 | unsigned int flags) |
| 299 | { |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 300 | igt_plane_t *primary; |
| 301 | struct igt_fb primary_fb; |
| 302 | drmModeModeInfo *mode; |
| 303 | igt_crc_t crc; |
| 304 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 305 | igt_info("Testing connector %s using pipe %s plane %d\n", |
| 306 | igt_output_name(output), kmstest_pipe_name(pipe), plane); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 307 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 308 | igt_output_set_pipe(output, pipe); |
| 309 | |
| 310 | mode = igt_output_get_mode(output); |
| 311 | primary = igt_output_get_plane(output, 0); |
| 312 | |
| 313 | create_fb_for_mode__panning(data, mode, &primary_fb); |
| 314 | igt_plane_set_fb(primary, &primary_fb); |
| 315 | |
| 316 | if (flags & TEST_PANNING_TOP_LEFT) |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 317 | igt_fb_set_position(&primary_fb, primary, 0, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 318 | else |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 319 | igt_fb_set_position(&primary_fb, primary, mode->hdisplay, mode->vdisplay); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 320 | |
| 321 | igt_display_commit(&data->display); |
| 322 | |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 323 | if (flags & TEST_SUSPEND_RESUME) |
Imre Deak | 022e6f8 | 2016-09-30 17:28:53 +0300 | [diff] [blame] | 324 | igt_system_suspend_autoresume(SUSPEND_STATE_MEM, |
| 325 | SUSPEND_TEST_NONE); |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 326 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 327 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc); |
| 328 | |
| 329 | if (flags & TEST_PANNING_TOP_LEFT) |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 330 | igt_assert_crc_equal(red_crc, &crc); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 331 | else |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 332 | igt_assert_crc_equal(blue_crc, &crc); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 333 | |
| 334 | igt_plane_set_fb(primary, NULL); |
| 335 | |
| 336 | /* reset states to neutral values, assumed by other tests */ |
| 337 | igt_output_set_pipe(output, PIPE_ANY); |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 338 | igt_fb_set_position(&primary_fb, primary, 0, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | static void |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 342 | test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags) |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 343 | { |
| 344 | igt_output_t *output; |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 345 | int connected_outs = 0; |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 346 | |
Maarten Lankhorst | c79e6d8 | 2017-01-16 11:35:43 +0100 | [diff] [blame] | 347 | for_each_valid_output_on_pipe(&data->display, pipe, output) { |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 348 | int n_planes = data->display.pipes[pipe].n_planes; |
| 349 | igt_crc_t red_crc; |
| 350 | igt_crc_t blue_crc; |
| 351 | |
| 352 | test_init(data, pipe); |
| 353 | |
| 354 | test_grab_crc(data, output, pipe, &red, &red_crc); |
| 355 | test_grab_crc(data, output, pipe, &blue, &blue_crc); |
| 356 | |
| 357 | for (int plane = 1; plane < n_planes; plane++) |
| 358 | test_plane_panning_with_output(data, pipe, plane, |
| 359 | output, |
| 360 | &red_crc, &blue_crc, |
| 361 | flags); |
| 362 | |
| 363 | test_fini(data); |
| 364 | |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 365 | connected_outs++; |
| 366 | } |
| 367 | |
| 368 | igt_skip_on(connected_outs == 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 369 | } |
| 370 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 371 | static void |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 372 | run_tests_for_pipe_plane(data_t *data, enum pipe pipe) |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 373 | { |
Leo (Sunpeng) Li | 597cae9 | 2017-06-09 17:08:53 -0400 | [diff] [blame] | 374 | igt_fixture { |
| 375 | igt_skip_on(pipe >= data->display.n_pipes); |
| 376 | igt_require(data->display.pipes[pipe].n_planes > 0); |
| 377 | } |
| 378 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 379 | igt_subtest_f("plane-position-covered-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 380 | kmstest_pipe_name(pipe)) |
| 381 | test_plane_position(data, pipe, TEST_POSITION_FULLY_COVERED); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 382 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 383 | igt_subtest_f("plane-position-hole-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 384 | kmstest_pipe_name(pipe)) |
| 385 | test_plane_position(data, pipe, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 386 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 387 | igt_subtest_f("plane-position-hole-dpms-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 388 | kmstest_pipe_name(pipe)) |
| 389 | test_plane_position(data, pipe, TEST_DPMS); |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 390 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 391 | igt_subtest_f("plane-panning-top-left-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 392 | kmstest_pipe_name(pipe)) |
| 393 | test_plane_panning(data, pipe, TEST_PANNING_TOP_LEFT); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 394 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 395 | igt_subtest_f("plane-panning-bottom-right-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 396 | kmstest_pipe_name(pipe)) |
| 397 | test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 398 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 399 | igt_subtest_f("plane-panning-bottom-right-suspend-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame^] | 400 | kmstest_pipe_name(pipe)) |
| 401 | test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT | |
| 402 | TEST_SUSPEND_RESUME); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 403 | } |
| 404 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 405 | |
| 406 | static data_t data; |
| 407 | |
| 408 | igt_main |
| 409 | { |
Daniel Vetter | 229d7d2 | 2017-08-14 11:32:05 +0200 | [diff] [blame] | 410 | enum pipe pipe; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 411 | |
| 412 | igt_skip_on_simulation(); |
| 413 | |
| 414 | igt_fixture { |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 415 | data.drm_fd = drm_open_driver_master(DRIVER_INTEL); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 416 | |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 417 | kmstest_set_vt_graphics_mode(); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 418 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 419 | igt_require_pipe_crc(data.drm_fd); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 420 | igt_display_init(&data.display, data.drm_fd); |
| 421 | } |
| 422 | |
Daniel Vetter | 229d7d2 | 2017-08-14 11:32:05 +0200 | [diff] [blame] | 423 | for_each_pipe_static(pipe) |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 424 | run_tests_for_pipe_plane(&data, pipe); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 425 | |
| 426 | igt_fixture { |
| 427 | igt_display_fini(&data.display); |
| 428 | } |
| 429 | } |