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); |
Maarten Lankhorst | be2f6fc | 2018-02-01 12:48:45 +0100 | [diff] [blame^] | 141 | igt_put_cairo_ctx(data->drm_fd, fb, cr); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 144 | enum { |
| 145 | TEST_POSITION_FULLY_COVERED = 1 << 0, |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 146 | TEST_DPMS = 1 << 1, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | static void |
| 150 | test_plane_position_with_output(data_t *data, |
| 151 | enum pipe pipe, |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 152 | int plane, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 153 | igt_output_t *output, |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 154 | igt_crc_t *reference_crc, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 155 | unsigned int flags) |
| 156 | { |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 157 | igt_plane_t *primary, *sprite; |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 158 | struct igt_fb primary_fb, sprite_fb; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 159 | drmModeModeInfo *mode; |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 160 | igt_crc_t crc, crc2; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 161 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 162 | igt_info("Testing connector %s using pipe %s plane %d\n", |
| 163 | igt_output_name(output), kmstest_pipe_name(pipe), plane); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 164 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 165 | igt_output_set_pipe(output, pipe); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 166 | |
| 167 | mode = igt_output_get_mode(output); |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 168 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Damien Lespiau | 2043e6b | 2014-02-11 17:45:48 +0000 | [diff] [blame] | 169 | sprite = igt_output_get_plane(output, plane); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 170 | |
| 171 | create_fb_for_mode__position(data, mode, 100, 100, 64, 64, |
| 172 | &primary_fb); |
| 173 | igt_plane_set_fb(primary, &primary_fb); |
| 174 | |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 175 | igt_create_color_fb(data->drm_fd, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 176 | 64, 64, /* width, height */ |
| 177 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 178 | LOCAL_DRM_FORMAT_MOD_NONE, |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 179 | 0.0, 1.0, 0.0, |
| 180 | &sprite_fb); |
| 181 | igt_plane_set_fb(sprite, &sprite_fb); |
| 182 | |
| 183 | if (flags & TEST_POSITION_FULLY_COVERED) |
| 184 | igt_plane_set_position(sprite, 100, 100); |
| 185 | else |
| 186 | igt_plane_set_position(sprite, 132, 132); |
| 187 | |
| 188 | igt_display_commit(&data->display); |
| 189 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 190 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 191 | |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 192 | if (flags & TEST_DPMS) { |
| 193 | kmstest_set_connector_dpms(data->drm_fd, |
| 194 | output->config.connector, |
| 195 | DRM_MODE_DPMS_OFF); |
| 196 | kmstest_set_connector_dpms(data->drm_fd, |
| 197 | output->config.connector, |
| 198 | DRM_MODE_DPMS_ON); |
| 199 | } |
| 200 | |
| 201 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc2); |
| 202 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 203 | if (flags & TEST_POSITION_FULLY_COVERED) |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 204 | igt_assert_crc_equal(reference_crc, &crc); |
Daniel Vetter | 92709f0 | 2017-09-05 14:36:16 +0200 | [diff] [blame] | 205 | else { |
Daniel Vetter | 562bbe1 | 2015-02-27 22:04:18 +0100 | [diff] [blame] | 206 | ;/* FIXME: missing reference CRCs */ |
Daniel Vetter | 92709f0 | 2017-09-05 14:36:16 +0200 | [diff] [blame] | 207 | } |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 208 | |
Daniel Vetter | e588f6d | 2015-02-27 20:37:29 +0100 | [diff] [blame] | 209 | igt_assert_crc_equal(&crc, &crc2); |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 210 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 211 | igt_plane_set_fb(primary, NULL); |
| 212 | igt_plane_set_fb(sprite, NULL); |
| 213 | |
Damien Lespiau | de538cf | 2014-07-07 13:30:41 +0100 | [diff] [blame] | 214 | /* reset the constraint on the pipe */ |
| 215 | igt_output_set_pipe(output, PIPE_ANY); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | static void |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 219 | test_plane_position(data_t *data, enum pipe pipe, unsigned int flags) |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 220 | { |
| 221 | igt_output_t *output; |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 222 | int connected_outs = 0; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 223 | |
Maarten Lankhorst | c79e6d8 | 2017-01-16 11:35:43 +0100 | [diff] [blame] | 224 | for_each_valid_output_on_pipe(&data->display, pipe, output) { |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 225 | int n_planes = data->display.pipes[pipe].n_planes; |
| 226 | igt_crc_t reference_crc; |
| 227 | |
| 228 | test_init(data, pipe); |
| 229 | |
| 230 | test_grab_crc(data, output, pipe, &green, &reference_crc); |
| 231 | |
| 232 | for (int plane = 1; plane < n_planes; plane++) |
| 233 | test_plane_position_with_output(data, pipe, plane, |
| 234 | output, &reference_crc, |
| 235 | flags); |
| 236 | |
| 237 | test_fini(data); |
| 238 | |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 239 | connected_outs++; |
| 240 | } |
| 241 | |
| 242 | igt_skip_on(connected_outs == 0); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 245 | /* |
| 246 | * Plane panning test. |
| 247 | * - We start by grabbing reference CRCs of a full red and a full blue fb |
| 248 | * being scanned out on the primary plane |
| 249 | * - Then we create a big fb, sized (2 * hdisplay, 2 * vdisplay) and: |
| 250 | * - fill the top left quarter with red |
| 251 | * - fill the bottom right quarter with blue |
| 252 | * - The TEST_PANNING_TOP_LEFT test makes sure that with panning at (0, 0) |
| 253 | * we do get the same CRC than the full red fb. |
| 254 | * - The TEST_PANNING_BOTTOM_RIGHT test makes sure that with panning at |
| 255 | * (vdisplay, hdisplay) we do get the same CRC than the full blue fb. |
| 256 | */ |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 257 | static void |
| 258 | create_fb_for_mode__panning(data_t *data, drmModeModeInfo *mode, |
| 259 | struct igt_fb *fb /* out */) |
| 260 | { |
| 261 | unsigned int fb_id; |
| 262 | cairo_t *cr; |
| 263 | |
| 264 | fb_id = igt_create_fb(data->drm_fd, |
| 265 | mode->hdisplay * 2, mode->vdisplay * 2, |
| 266 | DRM_FORMAT_XRGB8888, |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 267 | LOCAL_DRM_FORMAT_MOD_NONE, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 268 | fb); |
| 269 | igt_assert(fb_id); |
| 270 | |
| 271 | cr = igt_get_cairo_ctx(data->drm_fd, fb); |
| 272 | |
| 273 | igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, |
| 274 | 1.0, 0.0, 0.0); |
| 275 | |
| 276 | igt_paint_color(cr, |
| 277 | mode->hdisplay, mode->vdisplay, |
| 278 | mode->hdisplay, mode->vdisplay, |
| 279 | 0.0, 0.0, 1.0); |
| 280 | |
Maarten Lankhorst | be2f6fc | 2018-02-01 12:48:45 +0100 | [diff] [blame^] | 281 | igt_put_cairo_ctx(data->drm_fd, fb, cr); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | enum { |
| 285 | TEST_PANNING_TOP_LEFT = 1 << 0, |
| 286 | TEST_PANNING_BOTTOM_RIGHT = 1 << 1, |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 287 | TEST_SUSPEND_RESUME = 1 << 2, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 288 | }; |
| 289 | |
| 290 | static void |
| 291 | test_plane_panning_with_output(data_t *data, |
| 292 | enum pipe pipe, |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 293 | int plane, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 294 | igt_output_t *output, |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 295 | igt_crc_t *red_crc, igt_crc_t *blue_crc, |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 296 | unsigned int flags) |
| 297 | { |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 298 | igt_plane_t *primary; |
| 299 | struct igt_fb primary_fb; |
| 300 | drmModeModeInfo *mode; |
| 301 | igt_crc_t crc; |
| 302 | |
Daniel Vetter | dd8fba4 | 2014-08-12 11:00:37 +0200 | [diff] [blame] | 303 | igt_info("Testing connector %s using pipe %s plane %d\n", |
| 304 | igt_output_name(output), kmstest_pipe_name(pipe), plane); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 305 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 306 | igt_output_set_pipe(output, pipe); |
| 307 | |
| 308 | mode = igt_output_get_mode(output); |
| 309 | primary = igt_output_get_plane(output, 0); |
| 310 | |
| 311 | create_fb_for_mode__panning(data, mode, &primary_fb); |
| 312 | igt_plane_set_fb(primary, &primary_fb); |
| 313 | |
| 314 | if (flags & TEST_PANNING_TOP_LEFT) |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 315 | igt_fb_set_position(&primary_fb, primary, 0, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 316 | else |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 317 | igt_fb_set_position(&primary_fb, primary, mode->hdisplay, mode->vdisplay); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 318 | |
| 319 | igt_display_commit(&data->display); |
| 320 | |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 321 | if (flags & TEST_SUSPEND_RESUME) |
Imre Deak | 022e6f8 | 2016-09-30 17:28:53 +0300 | [diff] [blame] | 322 | igt_system_suspend_autoresume(SUSPEND_STATE_MEM, |
| 323 | SUSPEND_TEST_NONE); |
Ander Conselvan de Oliveira | eeff390 | 2015-01-19 15:43:57 +0200 | [diff] [blame] | 324 | |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 325 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc); |
| 326 | |
| 327 | if (flags & TEST_PANNING_TOP_LEFT) |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 328 | igt_assert_crc_equal(red_crc, &crc); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 329 | else |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 330 | igt_assert_crc_equal(blue_crc, &crc); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 331 | |
| 332 | igt_plane_set_fb(primary, NULL); |
| 333 | |
| 334 | /* reset states to neutral values, assumed by other tests */ |
| 335 | igt_output_set_pipe(output, PIPE_ANY); |
Maarten Lankhorst | 0e29ce3 | 2016-06-30 11:32:10 +0200 | [diff] [blame] | 336 | igt_fb_set_position(&primary_fb, primary, 0, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | static void |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 340 | test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags) |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 341 | { |
| 342 | igt_output_t *output; |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 343 | int connected_outs = 0; |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 344 | |
Maarten Lankhorst | c79e6d8 | 2017-01-16 11:35:43 +0100 | [diff] [blame] | 345 | for_each_valid_output_on_pipe(&data->display, pipe, output) { |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 346 | int n_planes = data->display.pipes[pipe].n_planes; |
| 347 | igt_crc_t red_crc; |
| 348 | igt_crc_t blue_crc; |
| 349 | |
| 350 | test_init(data, pipe); |
| 351 | |
| 352 | test_grab_crc(data, output, pipe, &red, &red_crc); |
| 353 | test_grab_crc(data, output, pipe, &blue, &blue_crc); |
| 354 | |
| 355 | for (int plane = 1; plane < n_planes; plane++) |
| 356 | test_plane_panning_with_output(data, pipe, plane, |
| 357 | output, |
| 358 | &red_crc, &blue_crc, |
| 359 | flags); |
| 360 | |
| 361 | test_fini(data); |
| 362 | |
Feceoru, Gabriel | 11a2b0d | 2016-02-19 14:34:51 +0200 | [diff] [blame] | 363 | connected_outs++; |
| 364 | } |
| 365 | |
| 366 | igt_skip_on(connected_outs == 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 367 | } |
| 368 | |
Mahesh Kumar | 84a3080 | 2017-12-13 15:20:49 +0530 | [diff] [blame] | 369 | static bool can_draw(uint32_t drm_format) |
| 370 | { |
| 371 | const uint32_t *drm_formats; |
| 372 | int format_count, i; |
| 373 | |
| 374 | igt_get_all_cairo_formats(&drm_formats, &format_count); |
| 375 | |
| 376 | for (i = 0; i < format_count; i++) |
| 377 | if (drm_formats[i] == drm_format) |
| 378 | return true; |
| 379 | |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | static void test_format_plane(data_t *data, enum pipe pipe, |
| 384 | igt_output_t *output, igt_plane_t *plane) |
| 385 | { |
| 386 | igt_plane_t *primary; |
| 387 | struct igt_fb primary_fb, fb; |
| 388 | drmModeModeInfo *mode; |
| 389 | cairo_t *cr; |
| 390 | int i; |
| 391 | uint32_t format; |
| 392 | uint64_t width, height; |
| 393 | |
| 394 | mode = igt_output_get_mode(output); |
| 395 | if (plane->type != DRM_PLANE_TYPE_CURSOR) { |
| 396 | width = mode->hdisplay; |
| 397 | height = mode->vdisplay; |
| 398 | } else { |
| 399 | if (!plane->drm_plane) { |
| 400 | igt_debug("Only legacy cursor ioctl supported, skipping cursor plane\n"); |
| 401 | return; |
| 402 | } |
| 403 | do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width)); |
| 404 | do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_HEIGHT, &height)); |
| 405 | } |
| 406 | |
| 407 | igt_debug("Testing connector %s on %s plane %s.%u\n", |
| 408 | igt_output_name(output), kmstest_plane_type_name(plane->type), |
| 409 | kmstest_pipe_name(pipe), plane->index); |
| 410 | |
| 411 | igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, |
| 412 | DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, &primary_fb); |
| 413 | |
| 414 | igt_output_set_pipe(output, pipe); |
| 415 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
| 416 | igt_plane_set_fb(primary, &primary_fb); |
| 417 | |
| 418 | igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 419 | |
| 420 | for (i = 0; i < plane->drm_plane->count_formats; i++) { |
| 421 | format = plane->drm_plane->formats[i]; |
| 422 | |
| 423 | if (!can_draw(format)) |
| 424 | continue; |
| 425 | |
| 426 | igt_debug("Testing format 0x%x on %s.%u\n", |
| 427 | format, kmstest_pipe_name(pipe), plane->index); |
| 428 | |
| 429 | igt_create_fb(data->drm_fd, width, height, |
| 430 | format, LOCAL_DRM_FORMAT_MOD_NONE, &fb); |
| 431 | |
| 432 | cr = igt_get_cairo_ctx(data->drm_fd, &fb); |
| 433 | igt_paint_color(cr, 0, 0, width, height, |
| 434 | 0.0, 1.0, 0.0); |
| 435 | if (width >= 164 && height >= 164) |
| 436 | igt_paint_color(cr, 100, 100, 64, 64, 0.0, 0.0, 0.0); |
Maarten Lankhorst | be2f6fc | 2018-02-01 12:48:45 +0100 | [diff] [blame^] | 437 | igt_put_cairo_ctx(data->drm_fd, &fb, cr); |
Mahesh Kumar | 84a3080 | 2017-12-13 15:20:49 +0530 | [diff] [blame] | 438 | |
| 439 | igt_plane_set_fb(plane, &fb); |
| 440 | igt_display_commit2(&data->display, COMMIT_UNIVERSAL); |
| 441 | |
| 442 | igt_remove_fb(data->drm_fd, &fb); |
| 443 | } |
| 444 | |
| 445 | igt_plane_set_fb(primary, NULL); |
| 446 | igt_plane_set_fb(plane, NULL); |
| 447 | igt_remove_fb(data->drm_fd, &primary_fb); |
| 448 | } |
| 449 | |
| 450 | static void |
| 451 | test_pixel_formats(data_t *data, enum pipe pipe) |
| 452 | { |
| 453 | igt_output_t *output; |
| 454 | |
| 455 | igt_display_require_output_on_pipe(&data->display, pipe); |
| 456 | |
| 457 | for_each_valid_output_on_pipe(&data->display, pipe, output) { |
| 458 | igt_plane_t *plane; |
| 459 | |
| 460 | for_each_plane_on_pipe(&data->display, pipe, plane) |
| 461 | test_format_plane(data, pipe, output, plane); |
| 462 | |
| 463 | igt_output_set_pipe(output, PIPE_ANY); |
| 464 | } |
| 465 | } |
| 466 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 467 | static void |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 468 | run_tests_for_pipe_plane(data_t *data, enum pipe pipe) |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 469 | { |
Leo (Sunpeng) Li | 597cae9 | 2017-06-09 17:08:53 -0400 | [diff] [blame] | 470 | igt_fixture { |
| 471 | igt_skip_on(pipe >= data->display.n_pipes); |
| 472 | igt_require(data->display.pipes[pipe].n_planes > 0); |
| 473 | } |
| 474 | |
Mahesh Kumar | 84a3080 | 2017-12-13 15:20:49 +0530 | [diff] [blame] | 475 | igt_subtest_f("pixel-format-pipe-%s-planes", |
| 476 | kmstest_pipe_name(pipe)) |
| 477 | test_pixel_formats(data, pipe); |
| 478 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 479 | igt_subtest_f("plane-position-covered-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 480 | kmstest_pipe_name(pipe)) |
| 481 | test_plane_position(data, pipe, TEST_POSITION_FULLY_COVERED); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 482 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 483 | igt_subtest_f("plane-position-hole-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 484 | kmstest_pipe_name(pipe)) |
| 485 | test_plane_position(data, pipe, 0); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 486 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 487 | igt_subtest_f("plane-position-hole-dpms-pipe-%s-planes", |
Imre Deak | 006e6ce | 2017-11-21 21:52:53 +0200 | [diff] [blame] | 488 | kmstest_pipe_name(pipe)) |
| 489 | test_plane_position(data, pipe, TEST_DPMS); |
Matt Roper | 14a3d88 | 2015-03-04 10:50:53 -0800 | [diff] [blame] | 490 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 491 | igt_subtest_f("plane-panning-top-left-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 492 | kmstest_pipe_name(pipe)) |
| 493 | test_plane_panning(data, pipe, TEST_PANNING_TOP_LEFT); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 494 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 495 | igt_subtest_f("plane-panning-bottom-right-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 496 | kmstest_pipe_name(pipe)) |
| 497 | test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT); |
Yi Sun | b5333b4 | 2014-05-23 08:28:47 +0800 | [diff] [blame] | 498 | |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 499 | igt_subtest_f("plane-panning-bottom-right-suspend-pipe-%s-planes", |
Imre Deak | b5c0ca6 | 2017-11-21 21:52:54 +0200 | [diff] [blame] | 500 | kmstest_pipe_name(pipe)) |
| 501 | test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT | |
| 502 | TEST_SUSPEND_RESUME); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 503 | } |
| 504 | |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 505 | |
| 506 | static data_t data; |
| 507 | |
| 508 | igt_main |
| 509 | { |
Daniel Vetter | 229d7d2 | 2017-08-14 11:32:05 +0200 | [diff] [blame] | 510 | enum pipe pipe; |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 511 | |
| 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); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 516 | |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 517 | kmstest_set_vt_graphics_mode(); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 518 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 519 | igt_require_pipe_crc(data.drm_fd); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 520 | igt_display_init(&data.display, data.drm_fd); |
| 521 | } |
| 522 | |
Daniel Vetter | 229d7d2 | 2017-08-14 11:32:05 +0200 | [diff] [blame] | 523 | for_each_pipe_static(pipe) |
Robert Foss | ee350e7 | 2017-01-10 20:06:49 -0500 | [diff] [blame] | 524 | run_tests_for_pipe_plane(&data, pipe); |
Damien Lespiau | 0d5de66 | 2014-02-06 21:20:35 +0000 | [diff] [blame] | 525 | |
| 526 | igt_fixture { |
| 527 | igt_display_fini(&data.display); |
| 528 | } |
| 529 | } |