1*d83cc019SAndroid Build Coastguard Worker /*
2*d83cc019SAndroid Build Coastguard Worker * Copyright 2019 Advanced Micro Devices, Inc.
3*d83cc019SAndroid Build Coastguard Worker *
4*d83cc019SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
5*d83cc019SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
6*d83cc019SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
7*d83cc019SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*d83cc019SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
9*d83cc019SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
10*d83cc019SAndroid Build Coastguard Worker *
11*d83cc019SAndroid Build Coastguard Worker * The above copyright notice and this permission notice shall be included in
12*d83cc019SAndroid Build Coastguard Worker * all copies or substantial portions of the Software.
13*d83cc019SAndroid Build Coastguard Worker *
14*d83cc019SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*d83cc019SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*d83cc019SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*d83cc019SAndroid Build Coastguard Worker * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*d83cc019SAndroid Build Coastguard Worker * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*d83cc019SAndroid Build Coastguard Worker * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*d83cc019SAndroid Build Coastguard Worker * OTHER DEALINGS IN THE SOFTWARE.
21*d83cc019SAndroid Build Coastguard Worker */
22*d83cc019SAndroid Build Coastguard Worker
23*d83cc019SAndroid Build Coastguard Worker #include "igt.h"
24*d83cc019SAndroid Build Coastguard Worker
25*d83cc019SAndroid Build Coastguard Worker /*
26*d83cc019SAndroid Build Coastguard Worker * This file tests cursor interactions with primary and overlay planes.
27*d83cc019SAndroid Build Coastguard Worker *
28*d83cc019SAndroid Build Coastguard Worker * Some assumptions made:
29*d83cc019SAndroid Build Coastguard Worker * - Cursor planes can be placed on top of overlay planes
30*d83cc019SAndroid Build Coastguard Worker * - DRM index indicates z-ordering, higher index = higher z-order
31*d83cc019SAndroid Build Coastguard Worker */
32*d83cc019SAndroid Build Coastguard Worker
33*d83cc019SAndroid Build Coastguard Worker typedef struct {
34*d83cc019SAndroid Build Coastguard Worker int x;
35*d83cc019SAndroid Build Coastguard Worker int y;
36*d83cc019SAndroid Build Coastguard Worker } pos_t;
37*d83cc019SAndroid Build Coastguard Worker
38*d83cc019SAndroid Build Coastguard Worker typedef struct {
39*d83cc019SAndroid Build Coastguard Worker int x;
40*d83cc019SAndroid Build Coastguard Worker int y;
41*d83cc019SAndroid Build Coastguard Worker int w;
42*d83cc019SAndroid Build Coastguard Worker int h;
43*d83cc019SAndroid Build Coastguard Worker } rect_t;
44*d83cc019SAndroid Build Coastguard Worker
45*d83cc019SAndroid Build Coastguard Worker /* Common test data. */
46*d83cc019SAndroid Build Coastguard Worker typedef struct data {
47*d83cc019SAndroid Build Coastguard Worker igt_display_t display;
48*d83cc019SAndroid Build Coastguard Worker igt_plane_t *primary;
49*d83cc019SAndroid Build Coastguard Worker igt_plane_t *overlay;
50*d83cc019SAndroid Build Coastguard Worker igt_plane_t *cursor;
51*d83cc019SAndroid Build Coastguard Worker igt_output_t *output;
52*d83cc019SAndroid Build Coastguard Worker igt_pipe_t *pipe;
53*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_t *pipe_crc;
54*d83cc019SAndroid Build Coastguard Worker drmModeModeInfo *mode;
55*d83cc019SAndroid Build Coastguard Worker enum pipe pipe_id;
56*d83cc019SAndroid Build Coastguard Worker int drm_fd;
57*d83cc019SAndroid Build Coastguard Worker rect_t or;
58*d83cc019SAndroid Build Coastguard Worker } data_t;
59*d83cc019SAndroid Build Coastguard Worker
60*d83cc019SAndroid Build Coastguard Worker /* Common test setup. */
test_init(data_t * data,enum pipe pipe_id)61*d83cc019SAndroid Build Coastguard Worker static void test_init(data_t *data, enum pipe pipe_id)
62*d83cc019SAndroid Build Coastguard Worker {
63*d83cc019SAndroid Build Coastguard Worker igt_display_t *display = &data->display;
64*d83cc019SAndroid Build Coastguard Worker
65*d83cc019SAndroid Build Coastguard Worker data->pipe_id = pipe_id;
66*d83cc019SAndroid Build Coastguard Worker data->pipe = &data->display.pipes[data->pipe_id];
67*d83cc019SAndroid Build Coastguard Worker
68*d83cc019SAndroid Build Coastguard Worker igt_display_reset(display);
69*d83cc019SAndroid Build Coastguard Worker
70*d83cc019SAndroid Build Coastguard Worker data->output = igt_get_single_output_for_pipe(&data->display, pipe_id);
71*d83cc019SAndroid Build Coastguard Worker igt_require(data->output);
72*d83cc019SAndroid Build Coastguard Worker
73*d83cc019SAndroid Build Coastguard Worker data->mode = igt_output_get_mode(data->output);
74*d83cc019SAndroid Build Coastguard Worker
75*d83cc019SAndroid Build Coastguard Worker data->primary = igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
76*d83cc019SAndroid Build Coastguard Worker data->overlay = igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_OVERLAY);
77*d83cc019SAndroid Build Coastguard Worker data->cursor = igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_CURSOR);
78*d83cc019SAndroid Build Coastguard Worker
79*d83cc019SAndroid Build Coastguard Worker data->pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe_id,
80*d83cc019SAndroid Build Coastguard Worker INTEL_PIPE_CRC_SOURCE_AUTO);
81*d83cc019SAndroid Build Coastguard Worker
82*d83cc019SAndroid Build Coastguard Worker igt_output_set_pipe(data->output, data->pipe_id);
83*d83cc019SAndroid Build Coastguard Worker
84*d83cc019SAndroid Build Coastguard Worker /* Overlay rectangle for a rect in the center of the screen */
85*d83cc019SAndroid Build Coastguard Worker data->or.x = data->mode->hdisplay / 4;
86*d83cc019SAndroid Build Coastguard Worker data->or.y = data->mode->vdisplay / 4;
87*d83cc019SAndroid Build Coastguard Worker data->or.w = data->mode->hdisplay / 2;
88*d83cc019SAndroid Build Coastguard Worker data->or.h = data->mode->vdisplay / 2;
89*d83cc019SAndroid Build Coastguard Worker }
90*d83cc019SAndroid Build Coastguard Worker
91*d83cc019SAndroid Build Coastguard Worker /* Common test cleanup. */
test_fini(data_t * data)92*d83cc019SAndroid Build Coastguard Worker static void test_fini(data_t *data)
93*d83cc019SAndroid Build Coastguard Worker {
94*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_free(data->pipe_crc);
95*d83cc019SAndroid Build Coastguard Worker igt_display_reset(&data->display);
96*d83cc019SAndroid Build Coastguard Worker }
97*d83cc019SAndroid Build Coastguard Worker
98*d83cc019SAndroid Build Coastguard Worker /* Fills a FB with the solid color given. */
draw_color(igt_fb_t * fb,double r,double g,double b)99*d83cc019SAndroid Build Coastguard Worker static void draw_color(igt_fb_t *fb, double r, double g, double b)
100*d83cc019SAndroid Build Coastguard Worker {
101*d83cc019SAndroid Build Coastguard Worker cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
102*d83cc019SAndroid Build Coastguard Worker
103*d83cc019SAndroid Build Coastguard Worker cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
104*d83cc019SAndroid Build Coastguard Worker igt_paint_color(cr, 0, 0, fb->width, fb->height, r, g, b);
105*d83cc019SAndroid Build Coastguard Worker igt_put_cairo_ctx(fb->fd, fb, cr);
106*d83cc019SAndroid Build Coastguard Worker }
107*d83cc019SAndroid Build Coastguard Worker
108*d83cc019SAndroid Build Coastguard Worker /*
109*d83cc019SAndroid Build Coastguard Worker * Draws white and gray (if overlay FB is given) on the primary FB.
110*d83cc019SAndroid Build Coastguard Worker * Draws a magenta square where the cursor should be over top both planes.
111*d83cc019SAndroid Build Coastguard Worker * Takes this as the reference CRC.
112*d83cc019SAndroid Build Coastguard Worker *
113*d83cc019SAndroid Build Coastguard Worker * Draws white on the primary FB and gray on the overlay FB if given.
114*d83cc019SAndroid Build Coastguard Worker * Places the cursor where the magenta square should be with a magenta FB.
115*d83cc019SAndroid Build Coastguard Worker * Takes this as the test CRC and compares it to the reference.
116*d83cc019SAndroid Build Coastguard Worker */
test_cursor_pos(data_t * data,igt_fb_t * pfb,igt_fb_t * ofb,igt_fb_t * cfb,const rect_t * or,int x,int y)117*d83cc019SAndroid Build Coastguard Worker static void test_cursor_pos(data_t *data, igt_fb_t *pfb, igt_fb_t *ofb,
118*d83cc019SAndroid Build Coastguard Worker igt_fb_t *cfb, const rect_t *or, int x, int y)
119*d83cc019SAndroid Build Coastguard Worker {
120*d83cc019SAndroid Build Coastguard Worker igt_crc_t ref_crc, test_crc;
121*d83cc019SAndroid Build Coastguard Worker cairo_t *cr;
122*d83cc019SAndroid Build Coastguard Worker int cw = cfb->width;
123*d83cc019SAndroid Build Coastguard Worker int ch = cfb->height;
124*d83cc019SAndroid Build Coastguard Worker
125*d83cc019SAndroid Build Coastguard Worker cr = igt_get_cairo_ctx(pfb->fd, pfb);
126*d83cc019SAndroid Build Coastguard Worker igt_paint_color(cr, 0, 0, pfb->width, pfb->height, 1.0, 1.0, 1.0);
127*d83cc019SAndroid Build Coastguard Worker
128*d83cc019SAndroid Build Coastguard Worker if (ofb)
129*d83cc019SAndroid Build Coastguard Worker igt_paint_color(cr, or->x, or->y, or->w, or->h, 0.5, 0.5, 0.5);
130*d83cc019SAndroid Build Coastguard Worker
131*d83cc019SAndroid Build Coastguard Worker igt_paint_color(cr, x, y, cw, ch, 1.0, 0.0, 1.0);
132*d83cc019SAndroid Build Coastguard Worker igt_put_cairo_ctx(pfb->fd, pfb, cr);
133*d83cc019SAndroid Build Coastguard Worker
134*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->overlay, NULL);
135*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->cursor, NULL);
136*d83cc019SAndroid Build Coastguard Worker igt_display_commit_atomic(&data->display, 0, NULL);
137*d83cc019SAndroid Build Coastguard Worker
138*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_start(data->pipe_crc);
139*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &ref_crc);
140*d83cc019SAndroid Build Coastguard Worker
141*d83cc019SAndroid Build Coastguard Worker draw_color(pfb, 1.0, 1.0, 1.0);
142*d83cc019SAndroid Build Coastguard Worker
143*d83cc019SAndroid Build Coastguard Worker if (ofb) {
144*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->overlay, ofb);
145*d83cc019SAndroid Build Coastguard Worker igt_plane_set_position(data->overlay, or->x, or->y);
146*d83cc019SAndroid Build Coastguard Worker igt_plane_set_size(data->overlay, or->w, or->h);
147*d83cc019SAndroid Build Coastguard Worker igt_fb_set_size(ofb, data->overlay, or->w, or->h);
148*d83cc019SAndroid Build Coastguard Worker igt_fb_set_position(ofb, data->overlay,
149*d83cc019SAndroid Build Coastguard Worker (ofb->width - or->w) / 2,
150*d83cc019SAndroid Build Coastguard Worker (ofb->height - or->h) / 2);
151*d83cc019SAndroid Build Coastguard Worker }
152*d83cc019SAndroid Build Coastguard Worker
153*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->cursor, cfb);
154*d83cc019SAndroid Build Coastguard Worker igt_plane_set_position(data->cursor, x, y);
155*d83cc019SAndroid Build Coastguard Worker igt_display_commit_atomic(&data->display, 0, NULL);
156*d83cc019SAndroid Build Coastguard Worker
157*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &test_crc);
158*d83cc019SAndroid Build Coastguard Worker igt_pipe_crc_stop(data->pipe_crc);
159*d83cc019SAndroid Build Coastguard Worker
160*d83cc019SAndroid Build Coastguard Worker igt_assert_crc_equal(&ref_crc, &test_crc);
161*d83cc019SAndroid Build Coastguard Worker }
162*d83cc019SAndroid Build Coastguard Worker
163*d83cc019SAndroid Build Coastguard Worker /*
164*d83cc019SAndroid Build Coastguard Worker * Tests the cursor on a variety of positions on the screen.
165*d83cc019SAndroid Build Coastguard Worker * Specific edge cases that should be captured here are the negative edges
166*d83cc019SAndroid Build Coastguard Worker * of each plane and the centers.
167*d83cc019SAndroid Build Coastguard Worker */
test_cursor_spots(data_t * data,igt_fb_t * pfb,igt_fb_t * ofb,igt_fb_t * cfb,const rect_t * or,int size)168*d83cc019SAndroid Build Coastguard Worker static void test_cursor_spots(data_t *data, igt_fb_t *pfb, igt_fb_t *ofb,
169*d83cc019SAndroid Build Coastguard Worker igt_fb_t *cfb, const rect_t *or, int size)
170*d83cc019SAndroid Build Coastguard Worker {
171*d83cc019SAndroid Build Coastguard Worker int sw = data->mode->hdisplay;
172*d83cc019SAndroid Build Coastguard Worker int sh = data->mode->vdisplay;
173*d83cc019SAndroid Build Coastguard Worker int i;
174*d83cc019SAndroid Build Coastguard Worker const pos_t pos[] = {
175*d83cc019SAndroid Build Coastguard Worker /* Test diagonally from top left to bottom right. */
176*d83cc019SAndroid Build Coastguard Worker { -size / 3, -size / 3 },
177*d83cc019SAndroid Build Coastguard Worker { 0, 0 },
178*d83cc019SAndroid Build Coastguard Worker { or->x - size, or->y - size },
179*d83cc019SAndroid Build Coastguard Worker { or->x - size / 3, or->y - size / 3 },
180*d83cc019SAndroid Build Coastguard Worker { or->x, or->y },
181*d83cc019SAndroid Build Coastguard Worker { or->x + size, or->y + size },
182*d83cc019SAndroid Build Coastguard Worker { sw / 2, sh / 2 },
183*d83cc019SAndroid Build Coastguard Worker { or->x + or->w - size, or->y + or->h - size },
184*d83cc019SAndroid Build Coastguard Worker { or->x + or->w - size / 3, or->y + or->h - size / 3 },
185*d83cc019SAndroid Build Coastguard Worker { or->x + or->w + size, or->y + or->h + size },
186*d83cc019SAndroid Build Coastguard Worker { sw - size, sh - size },
187*d83cc019SAndroid Build Coastguard Worker { sw - size / 3, sh - size / 3 },
188*d83cc019SAndroid Build Coastguard Worker /* Test remaining corners. */
189*d83cc019SAndroid Build Coastguard Worker { sw - size, 0 },
190*d83cc019SAndroid Build Coastguard Worker { 0, sh - size },
191*d83cc019SAndroid Build Coastguard Worker { or->x + or->w - size, or->y },
192*d83cc019SAndroid Build Coastguard Worker { or->x, or->y + or->h - size }
193*d83cc019SAndroid Build Coastguard Worker };
194*d83cc019SAndroid Build Coastguard Worker
195*d83cc019SAndroid Build Coastguard Worker for (i = 0; i < ARRAY_SIZE(pos); ++i) {
196*d83cc019SAndroid Build Coastguard Worker test_cursor_pos(data, pfb, ofb, cfb, or, pos[i].x, pos[i].y);
197*d83cc019SAndroid Build Coastguard Worker }
198*d83cc019SAndroid Build Coastguard Worker }
199*d83cc019SAndroid Build Coastguard Worker
200*d83cc019SAndroid Build Coastguard Worker /*
201*d83cc019SAndroid Build Coastguard Worker * Tests atomic cursor positioning on a primary and overlay plane.
202*d83cc019SAndroid Build Coastguard Worker * Assumes the cursor can be placed on top of the overlay.
203*d83cc019SAndroid Build Coastguard Worker */
test_cursor_overlay(data_t * data,int size,enum pipe pipe_id)204*d83cc019SAndroid Build Coastguard Worker static void test_cursor_overlay(data_t *data, int size, enum pipe pipe_id)
205*d83cc019SAndroid Build Coastguard Worker {
206*d83cc019SAndroid Build Coastguard Worker igt_fb_t pfb, ofb, cfb;
207*d83cc019SAndroid Build Coastguard Worker int sw, sh;
208*d83cc019SAndroid Build Coastguard Worker
209*d83cc019SAndroid Build Coastguard Worker test_init(data, pipe_id);
210*d83cc019SAndroid Build Coastguard Worker igt_require(data->overlay);
211*d83cc019SAndroid Build Coastguard Worker
212*d83cc019SAndroid Build Coastguard Worker sw = data->mode->hdisplay;
213*d83cc019SAndroid Build Coastguard Worker sh = data->mode->vdisplay;
214*d83cc019SAndroid Build Coastguard Worker
215*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888, 0,
216*d83cc019SAndroid Build Coastguard Worker 1.0, 1.0, 1.0, &pfb);
217*d83cc019SAndroid Build Coastguard Worker
218*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, data->or.w, data->or.h,
219*d83cc019SAndroid Build Coastguard Worker DRM_FORMAT_XRGB8888, 0, 0.5, 0.5, 0.5, &ofb);
220*d83cc019SAndroid Build Coastguard Worker
221*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, size, size, DRM_FORMAT_ARGB8888, 0,
222*d83cc019SAndroid Build Coastguard Worker 1.0, 0.0, 1.0, &cfb);
223*d83cc019SAndroid Build Coastguard Worker
224*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->primary, &pfb);
225*d83cc019SAndroid Build Coastguard Worker igt_display_commit2(&data->display, COMMIT_ATOMIC);
226*d83cc019SAndroid Build Coastguard Worker
227*d83cc019SAndroid Build Coastguard Worker test_cursor_spots(data, &pfb, &ofb, &cfb, &data->or, size);
228*d83cc019SAndroid Build Coastguard Worker
229*d83cc019SAndroid Build Coastguard Worker test_fini(data);
230*d83cc019SAndroid Build Coastguard Worker
231*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &cfb);
232*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &ofb);
233*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &pfb);
234*d83cc019SAndroid Build Coastguard Worker }
235*d83cc019SAndroid Build Coastguard Worker
236*d83cc019SAndroid Build Coastguard Worker /* Tests atomic cursor positioning on a primary plane. */
test_cursor_primary(data_t * data,int size,enum pipe pipe_id)237*d83cc019SAndroid Build Coastguard Worker static void test_cursor_primary(data_t *data, int size, enum pipe pipe_id)
238*d83cc019SAndroid Build Coastguard Worker {
239*d83cc019SAndroid Build Coastguard Worker igt_fb_t pfb, cfb;
240*d83cc019SAndroid Build Coastguard Worker int sw, sh;
241*d83cc019SAndroid Build Coastguard Worker
242*d83cc019SAndroid Build Coastguard Worker test_init(data, pipe_id);
243*d83cc019SAndroid Build Coastguard Worker
244*d83cc019SAndroid Build Coastguard Worker sw = data->mode->hdisplay;
245*d83cc019SAndroid Build Coastguard Worker sh = data->mode->vdisplay;
246*d83cc019SAndroid Build Coastguard Worker
247*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888, 0,
248*d83cc019SAndroid Build Coastguard Worker 1.0, 1.0, 1.0, &pfb);
249*d83cc019SAndroid Build Coastguard Worker
250*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, size, size, DRM_FORMAT_ARGB8888, 0,
251*d83cc019SAndroid Build Coastguard Worker 1.0, 0.0, 1.0, &cfb);
252*d83cc019SAndroid Build Coastguard Worker
253*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->primary, &pfb);
254*d83cc019SAndroid Build Coastguard Worker igt_display_commit2(&data->display, COMMIT_ATOMIC);
255*d83cc019SAndroid Build Coastguard Worker
256*d83cc019SAndroid Build Coastguard Worker test_cursor_spots(data, &pfb, NULL, &cfb, &data->or, size);
257*d83cc019SAndroid Build Coastguard Worker
258*d83cc019SAndroid Build Coastguard Worker test_fini(data);
259*d83cc019SAndroid Build Coastguard Worker
260*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &cfb);
261*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &pfb);
262*d83cc019SAndroid Build Coastguard Worker }
263*d83cc019SAndroid Build Coastguard Worker
264*d83cc019SAndroid Build Coastguard Worker /*
265*d83cc019SAndroid Build Coastguard Worker * Tests atomic cursor positioning on a primary and overlay plane.
266*d83cc019SAndroid Build Coastguard Worker * The overlay's buffer is larger than the viewport actually used
267*d83cc019SAndroid Build Coastguard Worker * for display.
268*d83cc019SAndroid Build Coastguard Worker */
test_cursor_viewport(data_t * data,int size,enum pipe pipe_id)269*d83cc019SAndroid Build Coastguard Worker static void test_cursor_viewport(data_t *data, int size, enum pipe pipe_id)
270*d83cc019SAndroid Build Coastguard Worker {
271*d83cc019SAndroid Build Coastguard Worker igt_fb_t pfb, ofb, cfb;
272*d83cc019SAndroid Build Coastguard Worker int sw, sh;
273*d83cc019SAndroid Build Coastguard Worker int pad = 128;
274*d83cc019SAndroid Build Coastguard Worker
275*d83cc019SAndroid Build Coastguard Worker test_init(data, pipe_id);
276*d83cc019SAndroid Build Coastguard Worker igt_require(data->overlay);
277*d83cc019SAndroid Build Coastguard Worker
278*d83cc019SAndroid Build Coastguard Worker sw = data->mode->hdisplay;
279*d83cc019SAndroid Build Coastguard Worker sh = data->mode->vdisplay;
280*d83cc019SAndroid Build Coastguard Worker
281*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888, 0,
282*d83cc019SAndroid Build Coastguard Worker 1.0, 1.0, 1.0, &pfb);
283*d83cc019SAndroid Build Coastguard Worker
284*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, data->or.w + pad, data->or.h + pad,
285*d83cc019SAndroid Build Coastguard Worker DRM_FORMAT_XRGB8888, 0, 0.5, 0.5, 0.5, &ofb);
286*d83cc019SAndroid Build Coastguard Worker
287*d83cc019SAndroid Build Coastguard Worker igt_create_color_fb(data->drm_fd, size, size, DRM_FORMAT_ARGB8888, 0,
288*d83cc019SAndroid Build Coastguard Worker 1.0, 0.0, 1.0, &cfb);
289*d83cc019SAndroid Build Coastguard Worker
290*d83cc019SAndroid Build Coastguard Worker igt_plane_set_fb(data->primary, &pfb);
291*d83cc019SAndroid Build Coastguard Worker igt_display_commit2(&data->display, COMMIT_ATOMIC);
292*d83cc019SAndroid Build Coastguard Worker
293*d83cc019SAndroid Build Coastguard Worker test_cursor_spots(data, &pfb, &ofb, &cfb, &data->or, size);
294*d83cc019SAndroid Build Coastguard Worker
295*d83cc019SAndroid Build Coastguard Worker test_fini(data);
296*d83cc019SAndroid Build Coastguard Worker
297*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &cfb);
298*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &ofb);
299*d83cc019SAndroid Build Coastguard Worker igt_remove_fb(data->drm_fd, &pfb);
300*d83cc019SAndroid Build Coastguard Worker }
301*d83cc019SAndroid Build Coastguard Worker
302*d83cc019SAndroid Build Coastguard Worker igt_main
303*d83cc019SAndroid Build Coastguard Worker {
304*d83cc019SAndroid Build Coastguard Worker static const int cursor_sizes[] = { 64, 128, 256 };
305*d83cc019SAndroid Build Coastguard Worker data_t data = { 0 };
306*d83cc019SAndroid Build Coastguard Worker enum pipe pipe;
307*d83cc019SAndroid Build Coastguard Worker int i;
308*d83cc019SAndroid Build Coastguard Worker
309*d83cc019SAndroid Build Coastguard Worker igt_skip_on_simulation();
310*d83cc019SAndroid Build Coastguard Worker
311*d83cc019SAndroid Build Coastguard Worker igt_fixture {
312*d83cc019SAndroid Build Coastguard Worker data.drm_fd = drm_open_driver_master(DRIVER_ANY);
313*d83cc019SAndroid Build Coastguard Worker
314*d83cc019SAndroid Build Coastguard Worker kmstest_set_vt_graphics_mode();
315*d83cc019SAndroid Build Coastguard Worker
316*d83cc019SAndroid Build Coastguard Worker igt_display_require(&data.display, data.drm_fd);
317*d83cc019SAndroid Build Coastguard Worker igt_require(data.display.is_atomic);
318*d83cc019SAndroid Build Coastguard Worker igt_display_require_output(&data.display);
319*d83cc019SAndroid Build Coastguard Worker }
320*d83cc019SAndroid Build Coastguard Worker
321*d83cc019SAndroid Build Coastguard Worker for_each_pipe_static(pipe)
322*d83cc019SAndroid Build Coastguard Worker for (i = 0; i < ARRAY_SIZE(cursor_sizes); ++i) {
323*d83cc019SAndroid Build Coastguard Worker int size = cursor_sizes[i];
324*d83cc019SAndroid Build Coastguard Worker
325*d83cc019SAndroid Build Coastguard Worker igt_subtest_f("pipe-%s-overlay-size-%d",
326*d83cc019SAndroid Build Coastguard Worker kmstest_pipe_name(pipe), size)
327*d83cc019SAndroid Build Coastguard Worker test_cursor_overlay(&data, size, pipe);
328*d83cc019SAndroid Build Coastguard Worker
329*d83cc019SAndroid Build Coastguard Worker igt_subtest_f("pipe-%s-primary-size-%d",
330*d83cc019SAndroid Build Coastguard Worker kmstest_pipe_name(pipe), size)
331*d83cc019SAndroid Build Coastguard Worker test_cursor_primary(&data, size, pipe);
332*d83cc019SAndroid Build Coastguard Worker
333*d83cc019SAndroid Build Coastguard Worker igt_subtest_f("pipe-%s-viewport-size-%d",
334*d83cc019SAndroid Build Coastguard Worker kmstest_pipe_name(pipe), size)
335*d83cc019SAndroid Build Coastguard Worker test_cursor_viewport(&data, size, pipe);
336*d83cc019SAndroid Build Coastguard Worker }
337*d83cc019SAndroid Build Coastguard Worker
338*d83cc019SAndroid Build Coastguard Worker igt_fixture {
339*d83cc019SAndroid Build Coastguard Worker igt_display_fini(&data.display);
340*d83cc019SAndroid Build Coastguard Worker }
341*d83cc019SAndroid Build Coastguard Worker }
342