2 * Copyright © 2014 Intel Corporation
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:
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
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
24 * Damien Lespiau <damien.lespiau@intel.com>
33 #include "igt_debugfs.h"
44 igt_display_t display;
45 igt_pipe_crc_t *pipe_crc;
48 static color_t green = { 0.0f, 1.0f, 0.0f };
51 * Common code across all tests, acting on data_t
53 static void test_init(data_t *data, enum pipe pipe)
55 data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
58 static void test_fini(data_t *data)
60 igt_pipe_crc_free(data->pipe_crc);
64 test_grab_crc(data_t *data, igt_output_t *output, color_t *fb_color,
65 igt_crc_t *crc /* out */)
68 drmModeModeInfo *mode;
71 primary = igt_output_get_plane(output, 0);
73 mode = igt_output_get_mode(output);
74 igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
77 fb_color->red, fb_color->green, fb_color->blue,
79 igt_plane_set_fb(primary, &fb);
81 igt_display_commit(&data->display);
83 igt_pipe_crc_collect_crc(data->pipe_crc, crc);
85 igt_plane_set_fb(primary, NULL);
86 igt_display_commit(&data->display);
88 igt_remove_fb(data->drm_fd, &fb);
92 * Plane position test.
93 * - We start by grabbing a reference CRC of a full green fb being scanned
94 * out on the primary plane
95 * - Then we scannout 2 planes:
96 * - the primary plane uses a green fb with a black rectangle
97 * - a plane, on top of the primary plane, with a green fb that is set-up
98 * to cover the black rectangle of the primary plane fb
99 * The resulting CRC should be identical to the reference CRC
104 igt_crc_t reference_crc;
108 * create a green fb with a black rectangle at (rect_x,rect_y) and of size
112 create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,
113 double rect_x, double rect_y,
114 double rect_w, double rect_h,
115 struct igt_fb *fb /* out */)
120 fb_id = igt_create_fb(data->drm_fd,
121 mode->hdisplay, mode->vdisplay,
127 cr = igt_get_cairo_ctx(data->drm_fd, fb);
128 igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
130 igt_paint_color(cr, rect_x, rect_y, rect_w, rect_h, 0.0, 0.0, 0.0);
131 igt_assert(cairo_status(cr) == 0);
136 TEST_POSITION_FULLY_COVERED = 1 << 0,
140 test_plane_position_with_output(data_t *data,
142 enum igt_plane plane,
143 igt_output_t *output,
146 test_position_t test = { .data = data };
147 igt_plane_t *primary, *sprite;
148 struct igt_fb primary_fb, sprite_fb;
149 drmModeModeInfo *mode;
152 igt_info("Testing connector %s using pipe %c plane %d\n",
153 igt_output_name(output), pipe_name(pipe), plane);
155 test_init(data, pipe);
157 test_grab_crc(data, output, &green, &test.reference_crc);
159 igt_output_set_pipe(output, pipe);
161 mode = igt_output_get_mode(output);
162 primary = igt_output_get_plane(output, 0);
163 sprite = igt_output_get_plane(output, plane);
165 create_fb_for_mode__position(data, mode, 100, 100, 64, 64,
167 igt_plane_set_fb(primary, &primary_fb);
169 igt_create_color_fb(data->drm_fd,
170 64, 64, /* width, height */
175 igt_plane_set_fb(sprite, &sprite_fb);
177 if (flags & TEST_POSITION_FULLY_COVERED)
178 igt_plane_set_position(sprite, 100, 100);
180 igt_plane_set_position(sprite, 132, 132);
182 igt_display_commit(&data->display);
184 igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
186 if (flags & TEST_POSITION_FULLY_COVERED)
187 igt_assert(igt_crc_equal(&test.reference_crc, &crc));
189 igt_assert(!igt_crc_equal(&test.reference_crc, &crc));
191 igt_plane_set_fb(primary, NULL);
192 igt_plane_set_fb(sprite, NULL);
194 /* reset the constraint on the pipe */
195 igt_output_set_pipe(output, PIPE_ANY);
201 test_plane_position(data_t *data, enum pipe pipe, enum igt_plane plane,
204 igt_output_t *output;
206 igt_skip_on(pipe >= data->display.n_pipes);
207 igt_skip_on(plane >= data->display.pipes[pipe].n_planes);
209 for_each_connected_output(&data->display, output)
210 test_plane_position_with_output(data, pipe, plane, output,
215 run_tests_for_pipe_plane(data_t *data, enum pipe pipe, enum igt_plane plane)
217 igt_subtest_f("plane-position-covered-pipe-%c-plane-%d",
218 pipe_name(pipe), plane)
219 test_plane_position(data, pipe, plane,
220 TEST_POSITION_FULLY_COVERED);
222 igt_subtest_f("plane-position-hole-pipe-%c-plane-%d",
223 pipe_name(pipe), plane)
224 test_plane_position(data, pipe, plane, 0);
228 run_tests_for_pipe(data_t *data, enum pipe pipe)
232 for (plane = 1; plane < IGT_MAX_PLANES; plane++)
233 run_tests_for_pipe_plane(data, pipe, plane);
241 igt_skip_on_simulation();
244 data.drm_fd = drm_open_any();
246 igt_set_vt_graphics_mode();
248 igt_require_pipe_crc();
249 igt_display_init(&data.display, data.drm_fd);
252 for (int pipe = 0; pipe < 3; pipe++)
253 run_tests_for_pipe(&data, pipe);
256 igt_display_fini(&data.display);