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"
38 igt_debugfs_t debugfs;
39 igt_display_t display;
43 * Plane position test.
44 * - We start by grabbing a reference CRC of a full green fb being scanned
45 * out on the primary plane
46 * - Then we scannout 2 planes:
47 * - the primary plane uses a green fb with a black rectangle
48 * - a plane, on top of the primary plane, with a green fb that is set-up
49 * to cover the black rectangle of the primary plane fb
50 * The resulting CRC should be identical to the reference CRC
55 igt_pipe_crc_t *pipe_crc;
56 igt_crc_t reference_crc;
60 * create a green fb with a black rectangle at (rect_x,rect_y) and of size
64 create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,
65 double rect_x, double rect_y,
66 double rect_w, double rect_h,
67 struct kmstest_fb *fb /* out */)
72 fb_id = kmstest_create_fb(data->drm_fd,
73 mode->hdisplay, mode->vdisplay,
74 32 /* bpp */, 24 /* depth */,
79 cr = kmstest_get_cairo_ctx(data->drm_fd, fb);
80 kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
82 kmstest_paint_color(cr, rect_x, rect_y, rect_w, rect_h, 0.0, 0.0, 0.0);
83 igt_assert(cairo_status(cr) == 0);
88 test_position_init(test_position_t *test, igt_output_t *output, enum pipe pipe)
90 data_t *data = test->data;
91 struct kmstest_fb green_fb;
92 drmModeModeInfo *mode;
95 test->pipe_crc = igt_pipe_crc_new(&data->debugfs, data->drm_fd,
96 pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
98 igt_output_set_pipe(output, pipe);
99 primary = igt_output_get_plane(output, 0);
101 mode = igt_output_get_mode(output);
102 kmstest_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
107 igt_plane_set_fb(primary, &green_fb);
109 igt_display_commit(&data->display);
111 igt_pipe_crc_collect_crc(test->pipe_crc, &test->reference_crc);
113 igt_plane_set_fb(primary, NULL);
114 igt_display_commit(&data->display);
116 kmstest_remove_fb(data->drm_fd, &green_fb);
120 test_position_fini(test_position_t *test, igt_output_t *output)
122 igt_pipe_crc_free(test->pipe_crc);
124 igt_output_set_pipe(output, PIPE_ANY);
125 igt_display_commit(&test->data->display);
129 TEST_POSITION_FULLY_COVERED = 1 << 0,
133 test_plane_position_with_output(data_t *data,
135 enum igt_plane plane,
136 igt_output_t *output,
139 test_position_t test = { .data = data };
140 igt_plane_t *primary, *sprite;
141 struct kmstest_fb primary_fb, sprite_fb;
142 drmModeModeInfo *mode;
145 fprintf(stdout, "Testing connector %s using pipe %c plane %d\n",
146 igt_output_name(output), pipe_name(pipe), plane);
148 test_position_init(&test, output, pipe);
150 mode = igt_output_get_mode(output);
151 primary = igt_output_get_plane(output, 0);
152 sprite = igt_output_get_plane(output, plane);
154 create_fb_for_mode__position(data, mode, 100, 100, 64, 64,
156 igt_plane_set_fb(primary, &primary_fb);
158 kmstest_create_color_fb(data->drm_fd,
159 64, 64, /* width, height */
164 igt_plane_set_fb(sprite, &sprite_fb);
166 if (flags & TEST_POSITION_FULLY_COVERED)
167 igt_plane_set_position(sprite, 100, 100);
169 igt_plane_set_position(sprite, 132, 132);
171 igt_display_commit(&data->display);
173 igt_pipe_crc_collect_crc(test.pipe_crc, &crc);
175 if (flags & TEST_POSITION_FULLY_COVERED)
176 igt_assert(igt_crc_equal(&test.reference_crc, &crc));
178 igt_assert(!igt_crc_equal(&test.reference_crc, &crc));
180 igt_plane_set_fb(primary, NULL);
181 igt_plane_set_fb(sprite, NULL);
183 test_position_fini(&test, output);
187 test_plane_position(data_t *data, enum pipe pipe, enum igt_plane plane,
190 igt_output_t *output;
192 igt_skip_on(pipe >= data->display.n_pipes);
193 igt_skip_on(plane >= data->display.pipes[pipe].n_planes);
195 for_each_connected_output(&data->display, output)
196 test_plane_position_with_output(data, pipe, plane, output,
201 run_tests_for_pipe_plane(data_t *data, enum pipe pipe, enum igt_plane plane)
203 igt_subtest_f("plane-position-covered-pipe-%c-plane-%d",
204 pipe_name(pipe), plane)
205 test_plane_position(data, pipe, plane,
206 TEST_POSITION_FULLY_COVERED);
208 igt_subtest_f("plane-position-hole-pipe-%c-plane-%d",
209 pipe_name(pipe), plane)
210 test_plane_position(data, pipe, plane, 0);
214 run_tests_for_pipe(data_t *data, enum pipe pipe)
218 for (plane = 1; plane < IGT_MAX_PLANES; plane++)
219 run_tests_for_pipe_plane(data, pipe, plane);
227 igt_skip_on_simulation();
230 data.drm_fd = drm_open_any();
232 igt_set_vt_graphics_mode();
234 igt_debugfs_init(&data.debugfs);
235 igt_pipe_crc_check(&data.debugfs);
236 igt_display_init(&data.display, data.drm_fd);
239 for (int pipe = 0; pipe < 3; pipe++)
240 run_tests_for_pipe(&data, pipe);
243 igt_display_fini(&data.display);