blob: 5b190a0d03cb60659f2d60d36c45e1aab5740ba2 [file] [log] [blame]
Sonika Jindale3611392014-06-18 14:27:27 +05301/*
Damien Lespiau9cf7e8d2014-07-08 12:08:20 +01002 * Copyright © 2013,2014 Intel Corporation
Sonika Jindale3611392014-06-18 14:27:27 +05303 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
Thomas Wood804e11f2015-08-17 17:57:43 +010025#include "igt.h"
Damien Lespiau92b29b12014-07-08 12:49:03 +010026#include <math.h>
Sonika Jindale3611392014-06-18 14:27:27 +053027
Vivek Kasireddy938b9302015-11-04 16:10:15 -080028#define MAX_FENCES 32
Sonika Jindale3611392014-06-18 14:27:27 +053029
Sonika Jindale3611392014-06-18 14:27:27 +053030typedef struct {
31 int gfx_fd;
32 igt_display_t display;
Sonika Jindale3611392014-06-18 14:27:27 +053033 struct igt_fb fb;
Maarten Lankhorstca239862017-06-06 12:16:43 +020034 struct igt_fb fb_reference;
Joseph Garveyd242cd82017-11-22 15:05:55 -080035 struct igt_fb fb_unrotated;
Tvrtko Ursulind9011062015-04-22 16:46:43 +010036 struct igt_fb fb_modeset;
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +010037 struct igt_fb fb_flip;
Damien Lespiau19743a12014-07-08 12:59:03 +010038 igt_crc_t ref_crc;
Tvrtko Ursulinaf415862017-09-11 18:14:57 +010039 igt_crc_t flip_crc;
Sonika Jindale3611392014-06-18 14:27:27 +053040 igt_pipe_crc_t *pipe_crc;
Sonika Jindale1ce5ea2015-04-22 16:44:05 +053041 igt_rotation_t rotation;
42 int pos_x;
43 int pos_y;
Tvrtko Ursulindbf64682015-04-22 16:46:48 +010044 uint32_t override_fmt;
45 uint64_t override_tiling;
Tvrtko Ursulinaf415862017-09-11 18:14:57 +010046 bool flips;
Joseph Garveyd242cd82017-11-22 15:05:55 -080047 int devid;
Sonika Jindale3611392014-06-18 14:27:27 +053048} data_t;
49
Joseph Garveyd242cd82017-11-22 15:05:55 -080050typedef struct {
51 float r;
52 float g;
53 float b;
54} rgb_color_t;
55
56static void set_color(rgb_color_t *color, float r, float g, float b)
57{
58 color->r = r;
59 color->g = g;
60 color->b = b;
61}
62
63static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
64 rgb_color_t *bl, igt_rotation_t rotation)
65{
66 rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
67
68 if (rotation & IGT_REFLECT_X) {
69 igt_swap(*tl, *tr);
70 igt_swap(*bl, *br);
71 }
72
73 if (rotation & IGT_ROTATION_90) {
74 bl_tmp = *bl;
75 br_tmp = *br;
76 tl_tmp = *tl;
77 tr_tmp = *tr;
78 *tl = tr_tmp;
79 *bl = tl_tmp;
80 *tr = br_tmp;
81 *br = bl_tmp;
82 } else if (rotation & IGT_ROTATION_180) {
83 igt_swap(*tl, *br);
84 igt_swap(*tr, *bl);
85 } else if (rotation & IGT_ROTATION_270) {
86 bl_tmp = *bl;
87 br_tmp = *br;
88 tl_tmp = *tl;
89 tr_tmp = *tr;
90 *tl = bl_tmp;
91 *bl = br_tmp;
92 *tr = tl_tmp;
93 *br = tr_tmp;
94 }
95}
96
97#define RGB_COLOR(color) \
98 color.r, color.g, color.b
99
Damien Lespiau92b29b12014-07-08 12:49:03 +0100100static void
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200101paint_squares(data_t *data, igt_rotation_t rotation,
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +0100102 struct igt_fb *fb, float o)
Damien Lespiau92b29b12014-07-08 12:49:03 +0100103{
104 cairo_t *cr;
Maarten Lankhorstca239862017-06-06 12:16:43 +0200105 unsigned int w = fb->width;
106 unsigned int h = fb->height;
Joseph Garveyd242cd82017-11-22 15:05:55 -0800107 rgb_color_t tl, tr, bl, br;
Damien Lespiau92b29b12014-07-08 12:49:03 +0100108
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +0100109 cr = igt_get_cairo_ctx(data->gfx_fd, fb);
Damien Lespiau92b29b12014-07-08 12:49:03 +0100110
Joseph Garveyd242cd82017-11-22 15:05:55 -0800111 set_color(&tl, o, 0.0f, 0.0f);
112 set_color(&tr, 0.0f, o, 0.0f);
113 set_color(&br, o, o, o);
114 set_color(&bl, 0.0f, 0.0f, o);
Tvrtko Ursulinb769a7c2015-04-22 16:46:46 +0100115
Joseph Garveyd242cd82017-11-22 15:05:55 -0800116 rotate_colors(&tl, &tr, &br, &bl, rotation);
117
118 igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
119 igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
120 igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
121 igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
Tvrtko Ursulinb769a7c2015-04-22 16:46:46 +0100122
Maarten Lankhorstbe2f6fc2018-02-01 12:48:45 +0100123 igt_put_cairo_ctx(data->gfx_fd, fb, cr);
Damien Lespiau92b29b12014-07-08 12:49:03 +0100124}
125
Daniel Vetter57259d72014-11-24 16:08:32 +0100126static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
Maarten Lankhorstca239862017-06-06 12:16:43 +0200127 igt_plane_t *plane, enum igt_commit_style commit)
Sonika Jindale3611392014-06-18 14:27:27 +0530128{
129 drmModeModeInfo *mode;
Tvrtko Ursulinb769a7c2015-04-22 16:46:46 +0100130 unsigned int w, h;
Maarten Lankhorstca239862017-06-06 12:16:43 +0200131 uint64_t tiling = data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE;
132 uint32_t pixel_format = data->override_fmt ?: DRM_FORMAT_XRGB8888;
133 igt_display_t *display = &data->display;
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200134 igt_plane_t *primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
Sonika Jindale3611392014-06-18 14:27:27 +0530135
Damien Lespiau8facccf2014-07-08 18:28:53 +0100136 igt_output_set_pipe(output, pipe);
Maarten Lankhorst44023a22017-01-31 13:31:57 +0100137 igt_plane_set_rotation(plane, IGT_ROTATION_0);
Sonika Jindale3611392014-06-18 14:27:27 +0530138
139 /* create the pipe_crc object for this pipe */
Damien Lespiau2eaa50f2014-07-08 18:56:15 +0100140 igt_pipe_crc_free(data->pipe_crc);
Chris Wilson83884e92017-03-21 17:16:03 +0000141 data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
Sonika Jindale3611392014-06-18 14:27:27 +0530142
Damien Lespiau19743a12014-07-08 12:59:03 +0100143 mode = igt_output_get_mode(output);
Sonika Jindale3611392014-06-18 14:27:27 +0530144
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530145 w = mode->hdisplay;
146 h = mode->vdisplay;
147
Maarten Lankhorstca239862017-06-06 12:16:43 +0200148 igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb_modeset);
149
150 /*
151 * With igt_display_commit2 and COMMIT_UNIVERSAL, we call just the
152 * setplane without a modeset. So, to be able to call
153 * igt_display_commit and ultimately setcrtc to do the first modeset,
154 * we create an fb covering the crtc and call commit
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200155 *
156 * It's also a good idea to set a primary fb on the primary plane
157 * regardless, to force a underrun when watermarks are allocated
158 * incorrectly for other planes.
Maarten Lankhorstca239862017-06-06 12:16:43 +0200159 */
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200160 igt_plane_set_fb(primary, &data->fb_modeset);
Maarten Lankhorstca239862017-06-06 12:16:43 +0200161
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200162 if (commit < COMMIT_ATOMIC) {
Maarten Lankhorst5e42c622017-09-21 14:30:09 +0200163 igt_plane_clear_prop_changed(primary, IGT_PLANE_ROTATION);
Maarten Lankhorstca239862017-06-06 12:16:43 +0200164 igt_display_commit(display);
165
166 if (plane->type == DRM_PLANE_TYPE_PRIMARY)
Maarten Lankhorst5e42c622017-09-21 14:30:09 +0200167 igt_plane_set_prop_changed(primary, IGT_PLANE_ROTATION);
Maarten Lankhorstca239862017-06-06 12:16:43 +0200168 }
169
170 igt_plane_set_fb(plane, NULL);
171
172 igt_display_commit2(display, commit);
173}
174
175static void remove_fbs(data_t *data)
176{
177 if (!data->fb.fb_id)
178 return;
179
180 igt_remove_fb(data->gfx_fd, &data->fb);
181 igt_remove_fb(data->gfx_fd, &data->fb_reference);
Joseph Garveyd242cd82017-11-22 15:05:55 -0800182 igt_remove_fb(data->gfx_fd, &data->fb_unrotated);
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200183
Maarten Lankhorstca239862017-06-06 12:16:43 +0200184 if (data->fb_flip.fb_id)
185 igt_remove_fb(data->gfx_fd, &data->fb_flip);
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200186
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200187 data->fb_flip.fb_id = data->fb.fb_id = 0;
Maarten Lankhorstca239862017-06-06 12:16:43 +0200188}
189
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200190enum rectangle_type {
Maarten Lankhorsta6458242017-06-12 10:56:01 +0200191 rectangle,
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200192 square,
193 portrait,
194 landscape,
195 num_rectangle_types /* must be last */
196};
197
Maarten Lankhorstca239862017-06-06 12:16:43 +0200198static void prepare_fbs(data_t *data, igt_output_t *output,
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200199 igt_plane_t *plane, enum rectangle_type rect)
Maarten Lankhorstca239862017-06-06 12:16:43 +0200200{
201 drmModeModeInfo *mode;
202 igt_display_t *display = &data->display;
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200203 unsigned int w, h, ref_w, ref_h, min_w, min_h;
Maarten Lankhorstca239862017-06-06 12:16:43 +0200204 uint64_t tiling = data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE;
205 uint32_t pixel_format = data->override_fmt ?: DRM_FORMAT_XRGB8888;
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100206 const float flip_opacity = 0.75;
Maarten Lankhorstca239862017-06-06 12:16:43 +0200207
208 if (data->fb.fb_id) {
209 igt_plane_set_fb(plane, NULL);
210 igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
211
212 remove_fbs(data);
213 }
214
215 igt_plane_set_rotation(plane, IGT_ROTATION_0);
216
217 mode = igt_output_get_mode(output);
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200218 if (plane->type != DRM_PLANE_TYPE_CURSOR) {
219 w = mode->hdisplay;
220 h = mode->vdisplay;
221
222 min_w = 256;
223 min_h = 256;
224 } else {
225 pixel_format = data->override_fmt ?: DRM_FORMAT_ARGB8888;
226
227 w = h = 256;
228 min_w = min_h = 64;
229 }
230
231 switch (rect) {
Maarten Lankhorsta6458242017-06-12 10:56:01 +0200232 case rectangle:
233 break;
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200234 case square:
235 w = h = min(h, w);
236 break;
237 case portrait:
238 w = min_w;
239 break;
240 case landscape:
241 h = min_h;
242 break;
243 case num_rectangle_types:
244 igt_assert(0);
245 }
246
247 ref_w = w;
248 ref_h = h;
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530249
250 /*
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530251 * For 90/270, we will use create smaller fb so that the rotated
252 * frame can fit in
253 */
Joseph Garveyd242cd82017-11-22 15:05:55 -0800254 if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270)) {
Maarten Lankhorstca239862017-06-06 12:16:43 +0200255 tiling = data->override_tiling ?: LOCAL_I915_FORMAT_MOD_Y_TILED;
256
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200257 igt_swap(w, h);
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530258 }
259
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100260 /*
261 * Create a reference software rotated flip framebuffer.
262 */
263 if (data->flips) {
264 igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format, tiling,
265 &data->fb_flip);
266 paint_squares(data, data->rotation, &data->fb_flip,
267 flip_opacity);
268 igt_plane_set_fb(plane, &data->fb_flip);
269 if (plane->type != DRM_PLANE_TYPE_CURSOR)
270 igt_plane_set_position(plane, data->pos_x, data->pos_y);
271 igt_display_commit2(display,
272 display->is_atomic ?
273 COMMIT_ATOMIC : COMMIT_UNIVERSAL);
274 igt_pipe_crc_collect_crc(data->pipe_crc, &data->flip_crc);
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +0100275 }
276
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100277 /*
278 * Create a reference CRC for a software-rotated fb.
279 */
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200280 igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format,
281 data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE, &data->fb_reference);
282 paint_squares(data, data->rotation, &data->fb_reference, 1.0);
Maarten Lankhorstca239862017-06-06 12:16:43 +0200283
284 igt_plane_set_fb(plane, &data->fb_reference);
285 if (plane->type != DRM_PLANE_TYPE_CURSOR)
286 igt_plane_set_position(plane, data->pos_x, data->pos_y);
287 igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
288
Damien Lespiau19743a12014-07-08 12:59:03 +0100289 igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
Sonika Jindale3611392014-06-18 14:27:27 +0530290
Damien Lespiau282f5602014-07-10 17:44:28 +0100291 /*
Joseph Garveyd242cd82017-11-22 15:05:55 -0800292 * Prepare the non-rotated reference fb.
293 */
294 igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format, tiling, &data->fb_unrotated);
295 paint_squares(data, IGT_ROTATION_0, &data->fb_unrotated, 1.0);
296 igt_plane_set_fb(plane, &data->fb_unrotated);
297 igt_plane_set_rotation(plane, IGT_ROTATION_0);
298 if (plane->type != DRM_PLANE_TYPE_CURSOR)
299 igt_plane_set_position(plane, data->pos_x, data->pos_y);
300 igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
301
302 /*
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100303 * Prepare the plane with an non-rotated fb let the hw rotate it.
Damien Lespiau282f5602014-07-10 17:44:28 +0100304 */
Joseph Garveyd242cd82017-11-22 15:05:55 -0800305 igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb);
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200306 paint_squares(data, IGT_ROTATION_0, &data->fb, 1.0);
Tvrtko Ursulinb769a7c2015-04-22 16:46:46 +0100307 igt_plane_set_fb(plane, &data->fb);
Maarten Lankhorstca239862017-06-06 12:16:43 +0200308
309 if (plane->type != DRM_PLANE_TYPE_CURSOR)
310 igt_plane_set_position(plane, data->pos_x, data->pos_y);
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100311
312 /*
313 * Prepare the non-rotated flip fb.
314 */
315 if (data->flips) {
316 igt_remove_fb(data->gfx_fd, &data->fb_flip);
317 igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling,
318 &data->fb_flip);
319 paint_squares(data, IGT_ROTATION_0, &data->fb_flip,
320 flip_opacity);
321 }
322
Sonika Jindale3611392014-06-18 14:27:27 +0530323}
324
Damien Lespiau05f90b02014-07-08 18:51:25 +0100325static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
Sonika Jindale3611392014-06-18 14:27:27 +0530326{
327 igt_display_t *display = &data->display;
Sonika Jindale3611392014-06-18 14:27:27 +0530328
329 igt_pipe_crc_free(data->pipe_crc);
330 data->pipe_crc = NULL;
331
Maarten Lankhorstca239862017-06-06 12:16:43 +0200332 remove_fbs(data);
Damien Lespiau1a754392014-07-09 14:00:59 +0100333
Maarten Lankhorst9d809cd2017-06-06 17:12:20 +0200334 igt_remove_fb(data->gfx_fd, &data->fb_modeset);
335
Damien Lespiau1a754392014-07-09 14:00:59 +0100336 /* XXX: see the note in prepare_crtc() */
Robert Foss3e04c512017-01-10 20:18:41 -0500337 if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
Damien Lespiau1a754392014-07-09 14:00:59 +0100338 igt_plane_t *primary;
339
Robert Foss3e04c512017-01-10 20:18:41 -0500340 primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
Damien Lespiau1a754392014-07-09 14:00:59 +0100341 igt_plane_set_fb(primary, NULL);
342 }
343
Damien Lespiau05f90b02014-07-08 18:51:25 +0100344 igt_plane_set_fb(plane, NULL);
Maarten Lankhorst44023a22017-01-31 13:31:57 +0100345 igt_plane_set_rotation(plane, IGT_ROTATION_0);
346
347 igt_display_commit2(display, COMMIT_UNIVERSAL);
348
Sonika Jindale3611392014-06-18 14:27:27 +0530349 igt_output_set_pipe(output, PIPE_ANY);
Damien Lespiaueb81a922014-07-08 18:20:51 +0100350
Sonika Jindale3611392014-06-18 14:27:27 +0530351 igt_display_commit(display);
352}
353
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +0100354static void wait_for_pageflip(int fd)
355{
Daniel Stoned7db79d2017-04-07 14:15:26 +0100356 drmEventContext evctx = { .version = 2 };
Maarten Lankhorst3c1362f2016-01-05 15:19:13 +0100357 struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
Tvrtko Ursulin061a38f2015-10-07 12:18:52 +0100358 fd_set fds;
359 int ret;
360
361 /* Wait for pageflip completion, then consume event on fd */
362 FD_ZERO(&fds);
363 FD_SET(fd, &fds);
364 do {
365 ret = select(fd + 1, &fds, NULL, NULL, &timeout);
366 } while (ret < 0 && errno == EINTR);
367 igt_assert_eq(ret, 1);
368 igt_assert(drmHandleEvent(fd, &evctx) == 0);
369}
370
Joseph Garveyd242cd82017-11-22 15:05:55 -0800371static void __test_plane_rotation(data_t *data, int plane_type, bool test_bad_format)
Sonika Jindale3611392014-06-18 14:27:27 +0530372{
373 igt_display_t *display = &data->display;
374 igt_output_t *output;
Damien Lespiauaef475b2014-07-08 18:43:44 +0100375 enum pipe pipe;
Sonika Jindale3611392014-06-18 14:27:27 +0530376 int valid_tests = 0;
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100377 igt_crc_t crc_output;
Damien Lespiauc4564e02014-07-08 19:24:24 +0100378 enum igt_commit_style commit = COMMIT_LEGACY;
Tvrtko Ursulindbf64682015-04-22 16:46:48 +0100379 int ret;
Damien Lespiau13e979c2014-07-08 18:13:47 +0100380
Maarten Lankhorst5f680642017-09-21 08:36:33 +0200381 if (data->flips && plane_type != DRM_PLANE_TYPE_PRIMARY)
382 igt_require(data->display.is_atomic);
383
Robert Foss3e04c512017-01-10 20:18:41 -0500384 if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR)
Damien Lespiauc4564e02014-07-08 19:24:24 +0100385 commit = COMMIT_UNIVERSAL;
Lyude80baeb02016-12-07 19:02:04 -0500386
Robert Foss3e04c512017-01-10 20:18:41 -0500387 if (plane_type == DRM_PLANE_TYPE_CURSOR)
Lyude80baeb02016-12-07 19:02:04 -0500388 igt_require(display->has_cursor_plane);
Sonika Jindale3611392014-06-18 14:27:27 +0530389
pvishwak8b8d7aa2016-04-11 11:24:56 +0530390 if (data->display.is_atomic)
391 commit = COMMIT_ATOMIC;
392
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100393 for_each_pipe_with_valid_output(display, pipe, output) {
394 igt_plane_t *plane;
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200395 int i;
Damien Lespiau05f90b02014-07-08 18:51:25 +0100396
Joseph Garveyd242cd82017-11-22 15:05:55 -0800397 if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
398 continue;
399
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100400 igt_output_set_pipe(output, pipe);
Damien Lespiau05f90b02014-07-08 18:51:25 +0100401
Robert Foss3e04c512017-01-10 20:18:41 -0500402 plane = igt_output_get_plane_type(output, plane_type);
Maarten Lankhorst2f7519a2017-10-04 16:29:51 +0200403 igt_require(igt_plane_has_prop(plane, IGT_PLANE_ROTATION));
Damien Lespiau05f90b02014-07-08 18:51:25 +0100404
Maarten Lankhorstca239862017-06-06 12:16:43 +0200405 prepare_crtc(data, output, pipe, plane, commit);
406
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200407 for (i = 0; i < num_rectangle_types; i++) {
408 /* Unsupported on i915 */
409 if (plane_type == DRM_PLANE_TYPE_CURSOR &&
410 i != square)
411 continue;
Daniel Vetter57259d72014-11-24 16:08:32 +0100412
Maarten Lankhorsta6458242017-06-12 10:56:01 +0200413 /* Only support partial covering primary plane on gen9+ */
414 if (plane_type == DRM_PLANE_TYPE_PRIMARY &&
415 i != rectangle && intel_gen(intel_get_drm_devid(data->gfx_fd)) < 9)
416 continue;
417
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200418 igt_debug("Testing case %i on pipe %s\n", i, kmstest_pipe_name(pipe));
419 prepare_fbs(data, output, plane, i);
Sonika Jindale3611392014-06-18 14:27:27 +0530420
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200421 igt_plane_set_rotation(plane, data->rotation);
Joseph Garveyd242cd82017-11-22 15:05:55 -0800422 if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270))
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200423 igt_plane_set_size(plane, data->fb.height, data->fb.width);
424
425 ret = igt_display_try_commit2(display, commit);
Joseph Garveyd242cd82017-11-22 15:05:55 -0800426 if (test_bad_format && (data->override_fmt || data->override_tiling)) {
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200427 igt_assert_eq(ret, -EINVAL);
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100428 continue;
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200429 }
430
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100431 /* Verify commit was ok. */
432 igt_assert_eq(ret, 0);
433
434 /* Check CRC */
435 igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
436 igt_assert_crc_equal(&data->ref_crc, &crc_output);
437
438 /*
439 * If flips are requested flip to a different fb and
440 * check CRC against that one as well.
441 */
442 if (data->flips) {
Maarten Lankhorst5f680642017-09-21 08:36:33 +0200443 igt_plane_set_fb(plane, &data->fb_flip);
444 if (data->rotation == IGT_ROTATION_90 || data->rotation == IGT_ROTATION_270)
445 igt_plane_set_size(plane, data->fb.height, data->fb.width);
446
447 if (plane_type != DRM_PLANE_TYPE_PRIMARY) {
448 igt_display_commit_atomic(display, DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_NONBLOCK, NULL);
449 } else {
450 ret = drmModePageFlip(data->gfx_fd,
451 output->config.crtc->crtc_id,
452 data->fb_flip.fb_id,
453 DRM_MODE_PAGE_FLIP_EVENT,
454 NULL);
455 igt_assert_eq(ret, 0);
456 }
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200457 wait_for_pageflip(data->gfx_fd);
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100458 igt_pipe_crc_collect_crc(data->pipe_crc,
459 &crc_output);
460 igt_assert_crc_equal(&data->flip_crc,
461 &crc_output);
Maarten Lankhorsta7fe05b2017-06-06 16:41:12 +0200462 }
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100463 }
464
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100465 valid_tests++;
466 cleanup_crtc(data, output, plane);
Sonika Jindale3611392014-06-18 14:27:27 +0530467 }
468 igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
469}
470
Joseph Garveyd242cd82017-11-22 15:05:55 -0800471static inline void test_bad_plane_rotation(data_t *data, int plane_type)
472{
473 __test_plane_rotation(data, plane_type, true);
474}
475
476static inline void test_plane_rotation(data_t *data, int plane_type)
477{
478 __test_plane_rotation(data, plane_type, false);
479}
480
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100481static void test_plane_rotation_ytiled_obj(data_t *data,
482 igt_output_t *output,
Robert Foss3e04c512017-01-10 20:18:41 -0500483 int plane_type)
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700484{
485 igt_display_t *display = &data->display;
486 uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
487 uint32_t format = DRM_FORMAT_XRGB8888;
488 int bpp = igt_drm_format_to_bpp(format);
489 enum igt_commit_style commit = COMMIT_LEGACY;
490 int fd = data->gfx_fd;
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700491 igt_plane_t *plane;
492 drmModeModeInfo *mode;
493 unsigned int stride, size, w, h;
494 uint32_t gem_handle;
495 int ret;
496
Robert Foss3e04c512017-01-10 20:18:41 -0500497 plane = igt_output_get_plane_type(output, plane_type);
Maarten Lankhorst2f7519a2017-10-04 16:29:51 +0200498 igt_require(igt_plane_has_prop(plane, IGT_PLANE_ROTATION));
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700499
Robert Foss3e04c512017-01-10 20:18:41 -0500500 if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR)
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700501 commit = COMMIT_UNIVERSAL;
Lyude80baeb02016-12-07 19:02:04 -0500502
Robert Foss3e04c512017-01-10 20:18:41 -0500503 if (plane_type == DRM_PLANE_TYPE_CURSOR)
Lyude80baeb02016-12-07 19:02:04 -0500504 igt_require(display->has_cursor_plane);
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700505
pvishwak8b8d7aa2016-04-11 11:24:56 +0530506 if (data->display.is_atomic)
507 commit = COMMIT_ATOMIC;
508
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700509 mode = igt_output_get_mode(output);
510 w = mode->hdisplay;
511 h = mode->vdisplay;
512
513 for (stride = 512; stride < (w * bpp / 8); stride *= 2)
514 ;
515 for (size = 1024*1024; size < stride * h; size *= 2)
516 ;
517
518 gem_handle = gem_create(fd, size);
519 ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride);
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100520 igt_assert_eq(ret, 0);
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700521
522 do_or_die(__kms_addfb(fd, gem_handle, w, h, stride,
523 format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS,
524 &data->fb.fb_id));
525 data->fb.width = w;
526 data->fb.height = h;
527 data->fb.gem_handle = gem_handle;
528
529 igt_plane_set_fb(plane, NULL);
530 igt_display_commit(display);
531
532 igt_plane_set_rotation(plane, data->rotation);
533 igt_plane_set_fb(plane, &data->fb);
Maarten Lankhorst44023a22017-01-31 13:31:57 +0100534 igt_plane_set_size(plane, h, w);
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700535
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700536 ret = igt_display_try_commit2(display, commit);
537
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100538 igt_output_set_pipe(output, PIPE_NONE);
539
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700540 kmstest_restore_vt_mode();
541 igt_remove_fb(fd, &data->fb);
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100542 igt_assert_eq(ret, 0);
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700543}
544
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100545static void test_plane_rotation_exhaust_fences(data_t *data,
546 igt_output_t *output,
Robert Foss3e04c512017-01-10 20:18:41 -0500547 int plane_type)
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800548{
549 igt_display_t *display = &data->display;
550 uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
551 uint32_t format = DRM_FORMAT_XRGB8888;
552 int bpp = igt_drm_format_to_bpp(format);
553 enum igt_commit_style commit = COMMIT_LEGACY;
554 int fd = data->gfx_fd;
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800555 igt_plane_t *plane;
556 drmModeModeInfo *mode;
557 data_t data2[MAX_FENCES+1] = {};
558 unsigned int stride, size, w, h;
559 uint32_t gem_handle;
560 uint64_t total_aperture_size, total_fbs_size;
561 int i, ret;
562
Robert Foss3e04c512017-01-10 20:18:41 -0500563 plane = igt_output_get_plane_type(output, plane_type);
Maarten Lankhorst2f7519a2017-10-04 16:29:51 +0200564 igt_require(igt_plane_has_prop(plane, IGT_PLANE_ROTATION));
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800565
Robert Foss3e04c512017-01-10 20:18:41 -0500566 if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR)
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800567 commit = COMMIT_UNIVERSAL;
Lyude80baeb02016-12-07 19:02:04 -0500568
Robert Foss3e04c512017-01-10 20:18:41 -0500569 if (plane_type == DRM_PLANE_TYPE_CURSOR)
Lyude80baeb02016-12-07 19:02:04 -0500570 igt_require(display->has_cursor_plane);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800571
pvishwak8b8d7aa2016-04-11 11:24:56 +0530572 if (data->display.is_atomic)
573 commit = COMMIT_ATOMIC;
574
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800575 mode = igt_output_get_mode(output);
576 w = mode->hdisplay;
577 h = mode->vdisplay;
578
579 for (stride = 512; stride < (w * bpp / 8); stride *= 2)
580 ;
581 for (size = 1024*1024; size < stride * h; size *= 2)
582 ;
583
584 /*
585 * Make sure there is atleast 90% of the available GTT space left
586 * for creating (MAX_FENCES+1) framebuffers.
587 */
588 total_fbs_size = size * (MAX_FENCES + 1);
Chris Wilson16038902016-02-18 10:35:10 +0000589 total_aperture_size = gem_available_aperture_size(fd);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800590 igt_require(total_fbs_size < total_aperture_size * 0.9);
591
592 igt_plane_set_fb(plane, NULL);
593 igt_display_commit(display);
594
595 for (i = 0; i < MAX_FENCES + 1; i++) {
596 gem_handle = gem_create(fd, size);
597 ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride);
598 if (ret) {
599 igt_warn("failed to set tiling\n");
600 goto err_alloc;
601 }
602
603 ret = (__kms_addfb(fd, gem_handle, w, h, stride,
604 format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS,
605 &data2[i].fb.fb_id));
606 if (ret) {
607 igt_warn("failed to create framebuffer\n");
608 goto err_alloc;
609 }
610
611 data2[i].fb.width = w;
612 data2[i].fb.height = h;
613 data2[i].fb.gem_handle = gem_handle;
614
615 igt_plane_set_fb(plane, &data2[i].fb);
616 igt_plane_set_rotation(plane, IGT_ROTATION_0);
617
618 ret = igt_display_try_commit2(display, commit);
619 if (ret) {
620 igt_warn("failed to commit unrotated fb\n");
621 goto err_commit;
622 }
623
624 igt_plane_set_rotation(plane, IGT_ROTATION_90);
Maarten Lankhorst44023a22017-01-31 13:31:57 +0100625 igt_plane_set_size(plane, h, w);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800626
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100627 igt_display_commit2(display, commit);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800628 if (ret) {
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100629 igt_warn("failed to commit hardware rotated fb: %i\n", ret);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800630 goto err_commit;
631 }
632 }
633
634err_alloc:
635 if (ret)
636 gem_close(fd, gem_handle);
637
638 i--;
639err_commit:
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100640 igt_plane_set_fb(plane, NULL);
641 igt_plane_set_rotation(plane, IGT_ROTATION_0);
642
643 if (commit < COMMIT_ATOMIC)
644 igt_display_commit2(display, commit);
645
646 igt_output_set_pipe(output, PIPE_NONE);
647 igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
648
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800649 for (; i >= 0; i--)
650 igt_remove_fb(fd, &data2[i].fb);
651
652 kmstest_restore_vt_mode();
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100653 igt_assert_eq(ret, 0);
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800654}
655
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100656static const char *plane_test_str(unsigned plane)
657{
658 switch (plane) {
659 case DRM_PLANE_TYPE_PRIMARY:
660 return "primary";
661 case DRM_PLANE_TYPE_OVERLAY:
662 return "sprite";
663 case DRM_PLANE_TYPE_CURSOR:
664 return "cursor";
665 default:
666 igt_assert(0);
667 }
668}
669
670static const char *rot_test_str(igt_rotation_t rot)
671{
672 switch (rot) {
Joseph Garveyd242cd82017-11-22 15:05:55 -0800673 case IGT_ROTATION_0:
674 return "0";
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100675 case IGT_ROTATION_90:
676 return "90";
677 case IGT_ROTATION_180:
678 return "180";
679 case IGT_ROTATION_270:
680 return "270";
681 default:
682 igt_assert(0);
683 }
684}
685
Joseph Garveyd242cd82017-11-22 15:05:55 -0800686static const char *tiling_test_str(uint64_t tiling)
687{
688 switch (tiling) {
689 case LOCAL_I915_FORMAT_MOD_X_TILED:
690 return "x-tiled";
691 case LOCAL_I915_FORMAT_MOD_Y_TILED:
692 return "y-tiled";
693 case LOCAL_I915_FORMAT_MOD_Yf_TILED:
694 return "yf-tiled";
695 default:
696 igt_assert(0);
697 }
698}
699
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100700static const char *flip_test_str(unsigned flips)
701{
702 if (flips)
703 return "-flip";
704 else
705 return "";
706}
707
Sonika Jindale3611392014-06-18 14:27:27 +0530708igt_main
709{
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100710 struct rot_subtest {
711 unsigned plane;
712 igt_rotation_t rot;
Joseph Garveyd242cd82017-11-22 15:05:55 -0800713 bool flips;
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100714 } *subtest, subtests[] = {
715 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_90, 0 },
716 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_180, 0 },
717 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_270, 0 },
718 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_90, 1 },
719 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_180, 1 },
720 { DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_270, 1 },
721 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_90, 0 },
722 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_180, 0 },
723 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_270, 0 },
724 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_90, 1 },
725 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_180, 1 },
726 { DRM_PLANE_TYPE_OVERLAY, IGT_ROTATION_270, 1 },
727 { DRM_PLANE_TYPE_CURSOR, IGT_ROTATION_180, 0 },
728 { 0, 0, 0}
729 };
Joseph Garveyd242cd82017-11-22 15:05:55 -0800730
731 struct reflect_x {
732 uint64_t tiling;
733 igt_rotation_t rot;
734 bool flips;
735 } *reflect_x, reflect_x_subtests[] = {
736 { LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 0 },
737 { LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 0 },
738 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 0 },
739 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 0 },
740 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 0 },
741 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 0 },
742 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 0 },
743 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 0 },
744 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 0 },
745 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 0 },
746 { LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 1 },
747 { LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 1 },
748 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 1 },
749 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 1 },
750 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 1 },
751 { LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 1 },
752 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 1 },
753 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 1 },
754 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 1 },
755 { LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 1 },
756 { 0, 0, 0 }
757 };
758
Sonika Jindale3611392014-06-18 14:27:27 +0530759 data_t data = {};
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530760 int gen = 0;
Sonika Jindale3611392014-06-18 14:27:27 +0530761
762 igt_skip_on_simulation();
763
764 igt_fixture {
Micah Fedkec81d2932015-07-22 21:54:02 +0000765 data.gfx_fd = drm_open_driver_master(DRIVER_INTEL);
Joseph Garveyd242cd82017-11-22 15:05:55 -0800766 data.devid = intel_get_drm_devid(data.gfx_fd);
767 gen = intel_gen(data.devid);
Sonika Jindale3611392014-06-18 14:27:27 +0530768
Daniel Vetter33f08842014-08-12 11:23:09 +0200769 kmstest_set_vt_graphics_mode();
Sonika Jindale3611392014-06-18 14:27:27 +0530770
Chris Wilson83884e92017-03-21 17:16:03 +0000771 igt_require_pipe_crc(data.gfx_fd);
Sonika Jindale3611392014-06-18 14:27:27 +0530772
773 igt_display_init(&data.display, data.gfx_fd);
774 }
Sonika Jindale3611392014-06-18 14:27:27 +0530775
Tvrtko Ursulinaf415862017-09-11 18:14:57 +0100776 for (subtest = subtests; subtest->rot; subtest++) {
777 igt_subtest_f("%s-rotation-%s%s",
778 plane_test_str(subtest->plane),
779 rot_test_str(subtest->rot),
780 flip_test_str(subtest->flips)) {
781 igt_require(!(subtest->rot &
782 (IGT_ROTATION_90 | IGT_ROTATION_270)) ||
783 gen >= 9);
784 data.rotation = subtest->rot;
785 data.flips = subtest->flips;
786 test_plane_rotation(&data, subtest->plane);
787 }
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530788 }
789
790 igt_subtest_f("sprite-rotation-90-pos-100-0") {
791 igt_require(gen >= 9);
792 data.rotation = IGT_ROTATION_90;
793 data.pos_x = 100,
794 data.pos_y = 0;
Robert Foss3e04c512017-01-10 20:18:41 -0500795 test_plane_rotation(&data, DRM_PLANE_TYPE_OVERLAY);
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530796 }
797
Tvrtko Ursulindbf64682015-04-22 16:46:48 +0100798 igt_subtest_f("bad-pixel-format") {
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530799 igt_require(gen >= 9);
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530800 data.pos_x = 0,
801 data.pos_y = 0;
Tvrtko Ursulindbf64682015-04-22 16:46:48 +0100802 data.rotation = IGT_ROTATION_90;
803 data.override_fmt = DRM_FORMAT_RGB565;
Joseph Garveyd242cd82017-11-22 15:05:55 -0800804 test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
Tvrtko Ursulindbf64682015-04-22 16:46:48 +0100805 }
806
807 igt_subtest_f("bad-tiling") {
808 igt_require(gen >= 9);
809 data.override_fmt = 0;
810 data.rotation = IGT_ROTATION_90;
811 data.override_tiling = LOCAL_DRM_FORMAT_MOD_NONE;
Joseph Garveyd242cd82017-11-22 15:05:55 -0800812 test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
Sonika Jindale1ce5ea2015-04-22 16:44:05 +0530813 }
Sonika Jindal47246982014-10-23 08:48:50 -0700814
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700815 igt_subtest_f("primary-rotation-90-Y-tiled") {
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100816 enum pipe pipe;
817 igt_output_t *output;
818 int valid_tests = 0;
819
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700820 igt_require(gen >= 9);
821 data.rotation = IGT_ROTATION_90;
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100822
823 for_each_pipe_with_valid_output(&data.display, pipe, output) {
824 igt_output_set_pipe(output, pipe);
825
Robert Foss3e04c512017-01-10 20:18:41 -0500826 test_plane_rotation_ytiled_obj(&data, output, DRM_PLANE_TYPE_PRIMARY);
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100827
828 valid_tests++;
829 break;
830 }
831
832 igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
Vivek Kasireddyfe548fa2015-10-22 18:34:03 -0700833 }
834
Joseph Garveyd242cd82017-11-22 15:05:55 -0800835 for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
836 igt_subtest_f("primary-%s-reflect-x-%s%s",
837 tiling_test_str(reflect_x->tiling),
838 rot_test_str(reflect_x->rot),
839 flip_test_str(reflect_x->flips)) {
840 igt_require(gen >= 10 ||
841 (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
842 && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));
843 data.rotation = (IGT_REFLECT_X | reflect_x->rot);
844 data.override_tiling = reflect_x->tiling;
845 data.flips = reflect_x->flips;
846 test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
847 }
848 }
849
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800850 igt_subtest_f("exhaust-fences") {
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100851 enum pipe pipe;
852 igt_output_t *output;
853 int valid_tests = 0;
854
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800855 igt_require(gen >= 9);
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100856
857 for_each_pipe_with_valid_output(&data.display, pipe, output) {
858 igt_output_set_pipe(output, pipe);
859
Robert Foss3e04c512017-01-10 20:18:41 -0500860 test_plane_rotation_exhaust_fences(&data, output, DRM_PLANE_TYPE_PRIMARY);
Maarten Lankhorsteeffa252017-01-05 14:13:34 +0100861
862 valid_tests++;
863 break;
864 }
865
866 igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
Vivek Kasireddy938b9302015-11-04 16:10:15 -0800867 }
868
Sonika Jindale3611392014-06-18 14:27:27 +0530869 igt_fixture {
870 igt_display_fini(&data.display);
871 }
872}