blob: 54bcffc16f4f5f0abcf0174aec8bd4320b961897 [file] [log] [blame]
Damien Lespiau0d5de662014-02-06 21:20:35 +00001/*
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 Wood804e11f2015-08-17 17:57:43 +010027#include "igt.h"
Damien Lespiau0d5de662014-02-06 21:20:35 +000028#include <errno.h>
29#include <stdbool.h>
30#include <stdio.h>
31#include <string.h>
32
Damien Lespiau0d5de662014-02-06 21:20:35 +000033
34typedef struct {
Damien Lespiaude538cf2014-07-07 13:30:41 +010035 float red;
36 float green;
37 float blue;
38} color_t;
39
40typedef struct {
Damien Lespiau0d5de662014-02-06 21:20:35 +000041 int drm_fd;
Damien Lespiau0d5de662014-02-06 21:20:35 +000042 igt_display_t display;
Damien Lespiaude538cf2014-07-07 13:30:41 +010043 igt_pipe_crc_t *pipe_crc;
Damien Lespiau0d5de662014-02-06 21:20:35 +000044} data_t;
45
Yi Sunb5333b42014-05-23 08:28:47 +080046static color_t red = { 1.0f, 0.0f, 0.0f };
Damien Lespiaude538cf2014-07-07 13:30:41 +010047static color_t green = { 0.0f, 1.0f, 0.0f };
Yi Sunb5333b42014-05-23 08:28:47 +080048static color_t blue = { 0.0f, 0.0f, 1.0f };
Damien Lespiaude538cf2014-07-07 13:30:41 +010049
50/*
51 * Common code across all tests, acting on data_t
52 */
53static void test_init(data_t *data, enum pipe pipe)
54{
Chris Wilson83884e92017-03-21 17:16:03 +000055 data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
Damien Lespiaude538cf2014-07-07 13:30:41 +010056}
57
58static void test_fini(data_t *data)
59{
60 igt_pipe_crc_free(data->pipe_crc);
61}
62
63static void
Damien Lespiauc5b96152014-07-09 11:05:06 +010064test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
65 color_t *fb_color, igt_crc_t *crc /* out */)
Damien Lespiaude538cf2014-07-07 13:30:41 +010066{
67 struct igt_fb fb;
68 drmModeModeInfo *mode;
69 igt_plane_t *primary;
Damien Lespiau8d60b822014-07-07 14:41:15 +010070 char *crc_str;
Feceoru, Gabriel8adb5a02016-02-26 14:59:03 +020071 int ret;
Damien Lespiaude538cf2014-07-07 13:30:41 +010072
Damien Lespiauc5b96152014-07-09 11:05:06 +010073 igt_output_set_pipe(output, pipe);
74
Damien Lespiaude538cf2014-07-07 13:30:41 +010075 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 Ursuline36091d2015-03-03 14:11:01 +000080 LOCAL_DRM_FORMAT_MOD_NONE,
Damien Lespiaude538cf2014-07-07 13:30:41 +010081 fb_color->red, fb_color->green, fb_color->blue,
82 &fb);
83 igt_plane_set_fb(primary, &fb);
84
Feceoru, Gabriel8adb5a02016-02-26 14:59:03 +020085 ret = igt_display_try_commit2(&data->display, COMMIT_LEGACY);
86 igt_skip_on(ret != 0);
Damien Lespiaude538cf2014-07-07 13:30:41 +010087
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 Lespiau8d60b822014-07-07 14:41:15 +010094
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 Lespiaude538cf2014-07-07 13:30:41 +010099}
100
Damien Lespiau0d5de662014-02-06 21:20:35 +0000101/*
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
112typedef struct {
113 data_t *data;
Damien Lespiau0d5de662014-02-06 21:20:35 +0000114 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 */
121static void
122create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,
123 double rect_x, double rect_y,
124 double rect_w, double rect_h,
Daniel Vetter9aea7ae2014-03-26 09:18:11 +0100125 struct igt_fb *fb /* out */)
Damien Lespiau0d5de662014-02-06 21:20:35 +0000126{
127 unsigned int fb_id;
128 cairo_t *cr;
129
Daniel Vetter9aea7ae2014-03-26 09:18:11 +0100130 fb_id = igt_create_fb(data->drm_fd,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000131 mode->hdisplay, mode->vdisplay,
Daniel Vetter70182162014-03-23 16:36:40 +0100132 DRM_FORMAT_XRGB8888,
Tvrtko Ursuline36091d2015-03-03 14:11:01 +0000133 LOCAL_DRM_FORMAT_MOD_NONE,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000134 fb);
135 igt_assert(fb_id);
136
Daniel Vetter9aea7ae2014-03-26 09:18:11 +0100137 cr = igt_get_cairo_ctx(data->drm_fd, fb);
138 igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000139 0.0, 1.0, 0.0);
Daniel Vetter9aea7ae2014-03-26 09:18:11 +0100140 igt_paint_color(cr, rect_x, rect_y, rect_w, rect_h, 0.0, 0.0, 0.0);
Maarten Lankhorstbe2f6fc2018-02-01 12:48:45 +0100141 igt_put_cairo_ctx(data->drm_fd, fb, cr);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000142}
143
Damien Lespiau0d5de662014-02-06 21:20:35 +0000144enum {
145 TEST_POSITION_FULLY_COVERED = 1 << 0,
Matt Roper14a3d882015-03-04 10:50:53 -0800146 TEST_DPMS = 1 << 1,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000147};
148
149static void
150test_plane_position_with_output(data_t *data,
151 enum pipe pipe,
Robert Fossee350e72017-01-10 20:06:49 -0500152 int plane,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000153 igt_output_t *output,
Imre Deak006e6ce2017-11-21 21:52:53 +0200154 igt_crc_t *reference_crc,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000155 unsigned int flags)
156{
Damien Lespiau0d5de662014-02-06 21:20:35 +0000157 igt_plane_t *primary, *sprite;
Daniel Vetter9aea7ae2014-03-26 09:18:11 +0100158 struct igt_fb primary_fb, sprite_fb;
Damien Lespiau0d5de662014-02-06 21:20:35 +0000159 drmModeModeInfo *mode;
Matt Roper14a3d882015-03-04 10:50:53 -0800160 igt_crc_t crc, crc2;
Damien Lespiau0d5de662014-02-06 21:20:35 +0000161
Daniel Vetterdd8fba42014-08-12 11:00:37 +0200162 igt_info("Testing connector %s using pipe %s plane %d\n",
163 igt_output_name(output), kmstest_pipe_name(pipe), plane);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000164
Damien Lespiaude538cf2014-07-07 13:30:41 +0100165 igt_output_set_pipe(output, pipe);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000166
167 mode = igt_output_get_mode(output);
Robert Fossee350e72017-01-10 20:06:49 -0500168 primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
Damien Lespiau2043e6b2014-02-11 17:45:48 +0000169 sprite = igt_output_get_plane(output, plane);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000170
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 Vetter9aea7ae2014-03-26 09:18:11 +0100175 igt_create_color_fb(data->drm_fd,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000176 64, 64, /* width, height */
177 DRM_FORMAT_XRGB8888,
Tvrtko Ursuline36091d2015-03-03 14:11:01 +0000178 LOCAL_DRM_FORMAT_MOD_NONE,
Damien Lespiau0d5de662014-02-06 21:20:35 +0000179 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 Lespiaude538cf2014-07-07 13:30:41 +0100190 igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000191
Matt Roper14a3d882015-03-04 10:50:53 -0800192 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 Lespiau0d5de662014-02-06 21:20:35 +0000203 if (flags & TEST_POSITION_FULLY_COVERED)
Imre Deak006e6ce2017-11-21 21:52:53 +0200204 igt_assert_crc_equal(reference_crc, &crc);
Daniel Vetter92709f02017-09-05 14:36:16 +0200205 else {
Daniel Vetter562bbe12015-02-27 22:04:18 +0100206 ;/* FIXME: missing reference CRCs */
Daniel Vetter92709f02017-09-05 14:36:16 +0200207 }
Damien Lespiau0d5de662014-02-06 21:20:35 +0000208
Daniel Vettere588f6d2015-02-27 20:37:29 +0100209 igt_assert_crc_equal(&crc, &crc2);
Matt Roper14a3d882015-03-04 10:50:53 -0800210
Damien Lespiau0d5de662014-02-06 21:20:35 +0000211 igt_plane_set_fb(primary, NULL);
212 igt_plane_set_fb(sprite, NULL);
213
Damien Lespiaude538cf2014-07-07 13:30:41 +0100214 /* reset the constraint on the pipe */
215 igt_output_set_pipe(output, PIPE_ANY);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000216}
217
218static void
Imre Deak006e6ce2017-11-21 21:52:53 +0200219test_plane_position(data_t *data, enum pipe pipe, unsigned int flags)
Damien Lespiau0d5de662014-02-06 21:20:35 +0000220{
221 igt_output_t *output;
Feceoru, Gabriel11a2b0d2016-02-19 14:34:51 +0200222 int connected_outs = 0;
Damien Lespiau0d5de662014-02-06 21:20:35 +0000223
Maarten Lankhorstc79e6d82017-01-16 11:35:43 +0100224 for_each_valid_output_on_pipe(&data->display, pipe, output) {
Imre Deak006e6ce2017-11-21 21:52:53 +0200225 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, Gabriel11a2b0d2016-02-19 14:34:51 +0200239 connected_outs++;
240 }
241
242 igt_skip_on(connected_outs == 0);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000243}
244
Yi Sunb5333b42014-05-23 08:28:47 +0800245/*
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 Sunb5333b42014-05-23 08:28:47 +0800257static void
258create_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 Ursuline36091d2015-03-03 14:11:01 +0000267 LOCAL_DRM_FORMAT_MOD_NONE,
Yi Sunb5333b42014-05-23 08:28:47 +0800268 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 Lankhorstbe2f6fc2018-02-01 12:48:45 +0100281 igt_put_cairo_ctx(data->drm_fd, fb, cr);
Yi Sunb5333b42014-05-23 08:28:47 +0800282}
283
284enum {
285 TEST_PANNING_TOP_LEFT = 1 << 0,
286 TEST_PANNING_BOTTOM_RIGHT = 1 << 1,
Ander Conselvan de Oliveiraeeff3902015-01-19 15:43:57 +0200287 TEST_SUSPEND_RESUME = 1 << 2,
Yi Sunb5333b42014-05-23 08:28:47 +0800288};
289
290static void
291test_plane_panning_with_output(data_t *data,
292 enum pipe pipe,
Robert Fossee350e72017-01-10 20:06:49 -0500293 int plane,
Yi Sunb5333b42014-05-23 08:28:47 +0800294 igt_output_t *output,
Imre Deakb5c0ca62017-11-21 21:52:54 +0200295 igt_crc_t *red_crc, igt_crc_t *blue_crc,
Yi Sunb5333b42014-05-23 08:28:47 +0800296 unsigned int flags)
297{
Yi Sunb5333b42014-05-23 08:28:47 +0800298 igt_plane_t *primary;
299 struct igt_fb primary_fb;
300 drmModeModeInfo *mode;
301 igt_crc_t crc;
302
Daniel Vetterdd8fba42014-08-12 11:00:37 +0200303 igt_info("Testing connector %s using pipe %s plane %d\n",
304 igt_output_name(output), kmstest_pipe_name(pipe), plane);
Yi Sunb5333b42014-05-23 08:28:47 +0800305
Yi Sunb5333b42014-05-23 08:28:47 +0800306 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 Lankhorst0e29ce32016-06-30 11:32:10 +0200315 igt_fb_set_position(&primary_fb, primary, 0, 0);
Yi Sunb5333b42014-05-23 08:28:47 +0800316 else
Maarten Lankhorst0e29ce32016-06-30 11:32:10 +0200317 igt_fb_set_position(&primary_fb, primary, mode->hdisplay, mode->vdisplay);
Yi Sunb5333b42014-05-23 08:28:47 +0800318
319 igt_display_commit(&data->display);
320
Ander Conselvan de Oliveiraeeff3902015-01-19 15:43:57 +0200321 if (flags & TEST_SUSPEND_RESUME)
Imre Deak022e6f82016-09-30 17:28:53 +0300322 igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
323 SUSPEND_TEST_NONE);
Ander Conselvan de Oliveiraeeff3902015-01-19 15:43:57 +0200324
Yi Sunb5333b42014-05-23 08:28:47 +0800325 igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
326
327 if (flags & TEST_PANNING_TOP_LEFT)
Imre Deakb5c0ca62017-11-21 21:52:54 +0200328 igt_assert_crc_equal(red_crc, &crc);
Yi Sunb5333b42014-05-23 08:28:47 +0800329 else
Imre Deakb5c0ca62017-11-21 21:52:54 +0200330 igt_assert_crc_equal(blue_crc, &crc);
Yi Sunb5333b42014-05-23 08:28:47 +0800331
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 Lankhorst0e29ce32016-06-30 11:32:10 +0200336 igt_fb_set_position(&primary_fb, primary, 0, 0);
Yi Sunb5333b42014-05-23 08:28:47 +0800337}
338
339static void
Imre Deakb5c0ca62017-11-21 21:52:54 +0200340test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)
Yi Sunb5333b42014-05-23 08:28:47 +0800341{
342 igt_output_t *output;
Feceoru, Gabriel11a2b0d2016-02-19 14:34:51 +0200343 int connected_outs = 0;
Yi Sunb5333b42014-05-23 08:28:47 +0800344
Maarten Lankhorstc79e6d82017-01-16 11:35:43 +0100345 for_each_valid_output_on_pipe(&data->display, pipe, output) {
Imre Deakb5c0ca62017-11-21 21:52:54 +0200346 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, Gabriel11a2b0d2016-02-19 14:34:51 +0200363 connected_outs++;
364 }
365
366 igt_skip_on(connected_outs == 0);
Yi Sunb5333b42014-05-23 08:28:47 +0800367}
368
Mahesh Kumar84a30802017-12-13 15:20:49 +0530369static 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
383static 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 Lankhorstbe2f6fc2018-02-01 12:48:45 +0100437 igt_put_cairo_ctx(data->drm_fd, &fb, cr);
Mahesh Kumar84a30802017-12-13 15:20:49 +0530438
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
450static void
451test_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 Lespiau0d5de662014-02-06 21:20:35 +0000467static void
Robert Fossee350e72017-01-10 20:06:49 -0500468run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
Damien Lespiau0d5de662014-02-06 21:20:35 +0000469{
Leo (Sunpeng) Li597cae92017-06-09 17:08:53 -0400470 igt_fixture {
471 igt_skip_on(pipe >= data->display.n_pipes);
472 igt_require(data->display.pipes[pipe].n_planes > 0);
473 }
474
Mahesh Kumar84a30802017-12-13 15:20:49 +0530475 igt_subtest_f("pixel-format-pipe-%s-planes",
476 kmstest_pipe_name(pipe))
477 test_pixel_formats(data, pipe);
478
Robert Fossee350e72017-01-10 20:06:49 -0500479 igt_subtest_f("plane-position-covered-pipe-%s-planes",
Imre Deak006e6ce2017-11-21 21:52:53 +0200480 kmstest_pipe_name(pipe))
481 test_plane_position(data, pipe, TEST_POSITION_FULLY_COVERED);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000482
Robert Fossee350e72017-01-10 20:06:49 -0500483 igt_subtest_f("plane-position-hole-pipe-%s-planes",
Imre Deak006e6ce2017-11-21 21:52:53 +0200484 kmstest_pipe_name(pipe))
485 test_plane_position(data, pipe, 0);
Yi Sunb5333b42014-05-23 08:28:47 +0800486
Robert Fossee350e72017-01-10 20:06:49 -0500487 igt_subtest_f("plane-position-hole-dpms-pipe-%s-planes",
Imre Deak006e6ce2017-11-21 21:52:53 +0200488 kmstest_pipe_name(pipe))
489 test_plane_position(data, pipe, TEST_DPMS);
Matt Roper14a3d882015-03-04 10:50:53 -0800490
Robert Fossee350e72017-01-10 20:06:49 -0500491 igt_subtest_f("plane-panning-top-left-pipe-%s-planes",
Imre Deakb5c0ca62017-11-21 21:52:54 +0200492 kmstest_pipe_name(pipe))
493 test_plane_panning(data, pipe, TEST_PANNING_TOP_LEFT);
Yi Sunb5333b42014-05-23 08:28:47 +0800494
Robert Fossee350e72017-01-10 20:06:49 -0500495 igt_subtest_f("plane-panning-bottom-right-pipe-%s-planes",
Imre Deakb5c0ca62017-11-21 21:52:54 +0200496 kmstest_pipe_name(pipe))
497 test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT);
Yi Sunb5333b42014-05-23 08:28:47 +0800498
Robert Fossee350e72017-01-10 20:06:49 -0500499 igt_subtest_f("plane-panning-bottom-right-suspend-pipe-%s-planes",
Imre Deakb5c0ca62017-11-21 21:52:54 +0200500 kmstest_pipe_name(pipe))
501 test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT |
502 TEST_SUSPEND_RESUME);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000503}
504
Damien Lespiau0d5de662014-02-06 21:20:35 +0000505
506static data_t data;
507
508igt_main
509{
Daniel Vetter229d7d22017-08-14 11:32:05 +0200510 enum pipe pipe;
Damien Lespiau0d5de662014-02-06 21:20:35 +0000511
512 igt_skip_on_simulation();
513
514 igt_fixture {
Micah Fedkec81d2932015-07-22 21:54:02 +0000515 data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000516
Daniel Vetter33f08842014-08-12 11:23:09 +0200517 kmstest_set_vt_graphics_mode();
Damien Lespiau0d5de662014-02-06 21:20:35 +0000518
Chris Wilson83884e92017-03-21 17:16:03 +0000519 igt_require_pipe_crc(data.drm_fd);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000520 igt_display_init(&data.display, data.drm_fd);
521 }
522
Daniel Vetter229d7d22017-08-14 11:32:05 +0200523 for_each_pipe_static(pipe)
Robert Fossee350e72017-01-10 20:06:49 -0500524 run_tests_for_pipe_plane(&data, pipe);
Damien Lespiau0d5de662014-02-06 21:20:35 +0000525
526 igt_fixture {
527 igt_display_fini(&data.display);
528 }
529}