blob: 42c17cb5fa9343b7380a2268bae3d80c74253ede [file] [log] [blame]
Zach Reiznerd847a7e2016-04-28 16:48:32 -07001/*
2 * Copyright 2015 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7#include <ctype.h>
Zach Reiznerfa0547a2016-05-11 18:43:40 -07008#include <getopt.h>
9#include <math.h>
Zach Reiznerd847a7e2016-04-28 16:48:32 -070010
11#include "bs_drm.h"
12
Zach Reiznerfa0547a2016-05-11 18:43:40 -070013#define MAX_TEST_PLANES 4
14
15static int64_t ns_since(struct timespec *since)
16{
17 struct timespec now;
18 clock_gettime(CLOCK_MONOTONIC, &now);
19
20 return (int64_t)(now.tv_sec - since->tv_sec) * 1000000000 + (int64_t)now.tv_nsec -
21 (int64_t)since->tv_nsec;
22}
Zach Reiznerd847a7e2016-04-28 16:48:32 -070023
24static drmModeModeInfoPtr find_best_mode(int mode_count, drmModeModeInfoPtr modes)
25{
26 if (mode_count <= 0 || modes == NULL)
27 return NULL;
28
29 for (int m = 0; m < mode_count; m++)
30 if (modes[m].type & DRM_MODE_TYPE_PREFERRED)
31 return &modes[m];
32
33 return &modes[0];
34}
35
36static bool is_format_supported(uint32_t format_count, uint32_t *formats, uint32_t format)
37{
38 for (uint32_t i = 0; i < format_count; i++)
39 if (formats[i] == format)
40 return true;
41 return false;
42}
43
Zach Reiznerfa0547a2016-05-11 18:43:40 -070044static bool find_overlay_planes(int fd, uint32_t crtc_id, size_t plane_count, uint32_t *formats,
45 uint32_t *plane_ids)
Zach Reiznerd847a7e2016-04-28 16:48:32 -070046{
47 drmModeRes *res = drmModeGetResources(fd);
48 if (res == NULL) {
49 bs_debug_error("failed to get drm resources");
Zach Reiznerfa0547a2016-05-11 18:43:40 -070050 return false;
Zach Reiznerd847a7e2016-04-28 16:48:32 -070051 }
52
53 uint32_t crtc_mask = 0;
54 for (int crtc_index = 0; crtc_index < res->count_crtcs; crtc_index++) {
55 if (res->crtcs[crtc_index] == crtc_id) {
56 crtc_mask = (1 << crtc_index);
57 break;
58 }
59 }
60 if (crtc_mask == 0) {
61 bs_debug_error("invalid crtc id %u", crtc_id);
62 drmModeFreeResources(res);
Zach Reiznerfa0547a2016-05-11 18:43:40 -070063 return false;
Zach Reiznerd847a7e2016-04-28 16:48:32 -070064 }
65
66 drmModePlaneRes *plane_res = drmModeGetPlaneResources(fd);
67 if (plane_res == NULL) {
68 bs_debug_error("failed to get plane resources");
69 drmModeFreeResources(res);
Zach Reiznerfa0547a2016-05-11 18:43:40 -070070 return false;
Zach Reiznerd847a7e2016-04-28 16:48:32 -070071 }
72
Zach Reiznerfa0547a2016-05-11 18:43:40 -070073 for (size_t out_index = 0; out_index < plane_count; out_index++)
74 plane_ids[out_index] = 0;
75
76 size_t remaining_out = plane_count;
77 for (uint32_t plane_index = 0; remaining_out > 0 && plane_index < plane_res->count_planes;
Zach Reiznerd847a7e2016-04-28 16:48:32 -070078 plane_index++) {
79 drmModePlane *plane = drmModeGetPlane(fd, plane_res->planes[plane_index]);
80 if (plane == NULL) {
81 bs_debug_error("failed to get plane id %u", plane_res->planes[plane_index]);
82 continue;
83 }
84
Zach Reiznerfa0547a2016-05-11 18:43:40 -070085 size_t out_index;
86 for (out_index = 0; out_index < plane_count; out_index++) {
87 if (plane_ids[out_index] == 0 &&
88 is_format_supported(plane->count_formats, plane->formats,
89 formats[out_index]))
90 break;
91 }
92
93 if ((plane->possible_crtcs & crtc_mask) == 0 || out_index == plane_count) {
Zach Reiznerd847a7e2016-04-28 16:48:32 -070094 drmModeFreePlane(plane);
95 continue;
96 }
97
98 drmModeObjectPropertiesPtr props =
99 drmModeObjectGetProperties(fd, plane->plane_id, DRM_MODE_OBJECT_PLANE);
100 for (uint32_t prop_index = 0; prop_index < props->count_props; ++prop_index) {
101 drmModePropertyPtr prop = drmModeGetProperty(fd, props->props[prop_index]);
102 if (strcmp(prop->name, "type")) {
103 drmModeFreeProperty(prop);
104 continue;
105 }
106
107 uint64_t desired_value = 0;
108 bool has_value = false;
109 for (int enum_index = 0; enum_index < prop->count_enums; enum_index++) {
110 struct drm_mode_property_enum *penum = &prop->enums[enum_index];
111 if (!strcmp(penum->name, "Overlay")) {
112 desired_value = penum->value;
113 has_value = true;
114 break;
115 }
116 }
117 drmModeFreeProperty(prop);
118
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700119 if (has_value && desired_value == props->prop_values[prop_index]) {
120 plane_ids[out_index] = plane->plane_id;
121 remaining_out--;
122 }
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700123
124 break;
125 }
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700126
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700127 drmModeFreeObjectProperties(props);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700128 drmModeFreePlane(plane);
129 }
130
131 drmModeFreePlaneResources(plane_res);
132 drmModeFreeResources(res);
133
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700134 return remaining_out == 0;
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700135}
136
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700137struct test_plane {
Gurchetan Singh61208942017-01-27 13:31:19 -0800138 const struct bs_draw_format *format;
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700139
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700140 bool has_bo_size;
141 uint32_t bo_w;
142 uint32_t bo_h;
143
144 bool has_dst_position;
145 int32_t dst_x;
146 int32_t dst_y;
147
148 int32_t dst_center_x;
149 int32_t dst_center_y;
150
151 int32_t dst_vx;
152 int32_t dst_vy;
153
154 bool has_dst_size;
155 uint32_t dst_w;
156 uint32_t dst_h;
157
158 uint32_t dst_min_w;
159 uint32_t dst_max_w;
160 uint32_t dst_min_h;
161 uint32_t dst_max_h;
162
163 bool has_dst_scale;
164 uint32_t dst_downscale_factor;
165 uint32_t dst_upscale_factor;
166
167 int32_t src_x;
168 int32_t src_y;
169
170 int32_t src_vx;
171 int32_t src_vy;
172
173 bool has_src_size;
174 uint32_t src_w;
175 uint32_t src_h;
176
177 struct gbm_bo *bo;
178 uint32_t fb_id;
179};
180
181static bool update_test_plane(int step, int32_t max_x, int32_t max_y, struct test_plane *tp)
182{
183 bool needs_set = (step == 0);
184 if (tp->has_dst_scale) {
185 float scale_factor = (sinf(step / 120.0f) / 2.0f + 0.5f);
186 scale_factor = powf(scale_factor, 4);
187 tp->dst_w = tp->dst_min_w + scale_factor * (tp->dst_max_w - tp->dst_min_w);
188 tp->dst_h = tp->dst_min_h + scale_factor * (tp->dst_max_h - tp->dst_min_h);
189 needs_set = true;
190 }
191
192 if (tp->dst_vx != 0) {
193 tp->dst_center_x += tp->dst_vx;
194 if (tp->dst_center_x > max_x || tp->dst_center_x < 0) {
195 tp->dst_vx = -tp->dst_vx;
196 tp->dst_x += tp->dst_vx * 2;
197 }
198 needs_set = true;
199 }
200 tp->dst_x = tp->dst_center_x - tp->dst_w / 2;
201
202 if (tp->dst_vy != 0) {
203 tp->dst_center_y += tp->dst_vy;
204 if (tp->dst_center_y > max_y || tp->dst_center_y < 0) {
205 tp->dst_vy = -tp->dst_vy;
206 tp->dst_y += tp->dst_vy * 2;
207 }
208 needs_set = true;
209 }
210 tp->dst_y = tp->dst_center_y - tp->dst_h / 2;
211
212 if (tp->src_vx != 0) {
213 tp->src_x += tp->src_vx;
214 if (tp->src_x + tp->src_w > gbm_bo_get_width(tp->bo) || tp->src_x < 0) {
215 tp->src_vx = -tp->src_vx;
216 tp->src_x += tp->src_vx * 2;
217 }
218 needs_set = true;
219 }
220
221 if (tp->src_vy != 0) {
222 tp->src_y += tp->src_vy;
223 if (tp->src_y + tp->src_h > gbm_bo_get_height(tp->bo) || tp->src_y < 0) {
224 tp->src_vy = -tp->src_vy;
225 tp->src_y += tp->src_vy * 2;
226 }
227 needs_set = true;
228 }
229
230 return needs_set;
231}
232
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700233static bool parse_size(const char *str, uint32_t *w, uint32_t *h)
234{
235 if (sscanf(str, "%ux%u", w, h) == 2)
236 return true;
237
238 printf("unrecognized size format \"%s\"\n", str);
239
240 return false;
241}
242
243static bool parse_scale(const char *str, uint32_t *down, uint32_t *up)
244{
245 if (sscanf(str, "%u/%u", down, up) == 2)
246 return true;
247
248 printf("unrecognized scale format \"%s\"\n", str);
249
250 return false;
251}
252
253static bool parse_rect(const char *str, int32_t *x, int32_t *y, uint32_t *w, uint32_t *h,
254 bool *has_position, bool *has_size)
255{
256 if (sscanf(str, "%d,%d,%u,%u", x, y, w, h) == 4) {
257 if (has_position)
258 *has_position = true;
259 if (has_size)
260 *has_size = true;
261 return true;
262 }
263
264 if (sscanf(str, "%d,%d", x, y) == 2) {
265 if (has_position)
266 *has_position = true;
267 if (has_size)
268 *has_size = false;
269 return true;
270 }
271
272 if (sscanf(str, "%ux%u", w, h) == 2) {
273 if (has_position)
274 *has_position = false;
275 if (has_size)
276 *has_size = true;
277 return true;
278 }
279
280 printf("unrecognized rectangle format \"%s\"\n", str);
281
282 return false;
283}
284
285static const struct option longopts[] = {
286 { "plane", no_argument, NULL, 'p' },
287 { "format", required_argument, NULL, 'f' },
288 { "size", required_argument, NULL, 'z' },
289 { "scale", required_argument, NULL, 'c' },
290 { "translate", no_argument, NULL, 't' },
291 { "src", required_argument, NULL, 's' },
292 { "dst", required_argument, NULL, 'd' },
293 { "help", no_argument, NULL, 'h' },
294 { 0, 0, 0, 0 },
295};
296
297static void print_help(const char *argv0)
298{
299 // clang-format off
300 printf("usage: %s [OPTIONS]\n", argv0);
301 printf(" -p, --plane indicates that subsequent parameters are for a new plane\n");
302 printf(" -f, --format FOURCC format of source buffer (defaults to NV12)\n");
303 printf(" -z, --size WIDTHxHEIGHT size of the source buffer (defaults to screen size)\n");
304 printf(" -c, --scale DOWN/UP scale plane over time between (1/DOWN)x and UPx\n");
305 printf(" -t, --translate translate plane over time\n");
306 printf(" -s, --src RECT source rectangle (defaults to full buffer)\n");
307 printf(" -d, --dst RECT destination rectangle (defaults to buffer size centered in screen)\n");
308 printf(" -h, --help show help\n");
309 printf("\n");
310 printf("The format of RECT arguments is X,Y or X,Y,WIDTH,HEIGHT or WIDTHxHEIGHT.\n");
311 printf("To test more than one plane, separate plane arguments with -p. For example:\n");
312 printf(" %s --format NV12 --size 400x400 -p --format XR24 --size 100x100 --translate\n", argv0);
313 printf("\n");
314 // clang-format on
315}
316
317int main(int argc, char **argv)
318{
319 int ret = 0;
320 bool help_flag = false;
321 size_t test_planes_count = 1;
322 struct test_plane test_planes[MAX_TEST_PLANES] = { { 0 } };
323 uint32_t test_planes_formats[MAX_TEST_PLANES] = { 0 };
324 uint32_t test_planes_ids[MAX_TEST_PLANES] = { 0 };
325
326 int c;
327 while ((c = getopt_long(argc, argv, "pf:z:c:ts:d:h", longopts, NULL)) != -1) {
328 struct test_plane *current_plane = &test_planes[test_planes_count - 1];
329 switch (c) {
330 case 'p':
331 test_planes_count++;
332 if (test_planes_count > MAX_TEST_PLANES) {
333 printf("only %d planes are allowed\n", MAX_TEST_PLANES);
334 return 1;
335 }
336 break;
337 case 'f':
Dongseong Hwang20c494c2016-04-27 11:26:19 +0300338 if (!bs_parse_draw_format(optarg, &current_plane->format))
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700339 return 1;
340 break;
341 case 'z':
342 if (!parse_size(optarg, &current_plane->bo_w, &current_plane->bo_h))
343 return 1;
344 current_plane->has_bo_size = true;
345 break;
346 case 'c':
347 if (!parse_scale(optarg, &current_plane->dst_downscale_factor,
348 &current_plane->dst_upscale_factor))
349 return 1;
350 current_plane->has_dst_scale = true;
351 break;
352 case 't':
353 current_plane->dst_vx = 7;
354 current_plane->dst_vy = 7;
355 break;
356 case 's':
357 if (!parse_rect(optarg, &current_plane->src_x,
358 &current_plane->src_y, &current_plane->src_w,
359 &current_plane->src_h, NULL,
360 &current_plane->has_src_size))
361 return 1;
362 break;
363 case 'd':
364 if (!parse_rect(optarg, &current_plane->dst_x,
365 &current_plane->dst_y, &current_plane->dst_w,
366 &current_plane->dst_h,
367 &current_plane->has_dst_position,
368 &current_plane->has_dst_size))
369 return 1;
370 break;
371 case '?':
372 ret = 1;
373 case 'h':
374 help_flag = true;
375 break;
376 }
377 }
378
379 if (help_flag)
380 print_help(argv[0]);
381
382 if (ret)
383 return ret;
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700384
385 drmModeConnector *connector;
386 struct bs_drm_pipe pipe = { 0 };
387 struct bs_drm_pipe_plumber *plumber = bs_drm_pipe_plumber_new();
388 bs_drm_pipe_plumber_connector_ranks(plumber, bs_drm_connectors_internal_rank);
389 bs_drm_pipe_plumber_connector_ptr(plumber, &connector);
390 if (!bs_drm_pipe_plumber_make(plumber, &pipe)) {
391 bs_debug_error("failed to make pipe");
392 return 1;
393 }
394 bs_drm_pipe_plumber_destroy(&plumber);
395
396 drmModeModeInfo *mode_ptr = find_best_mode(connector->count_modes, connector->modes);
397 if (!mode_ptr) {
398 bs_debug_error("failed to find preferred mode");
399 return 1;
400 }
401 drmModeModeInfo mode = *mode_ptr;
402 drmModeFreeConnector(connector);
403 printf("Using mode %s\n", mode.name);
404
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700405 printf("Using CRTC:%u ENCODER:%u CONNECTOR:%u\n", pipe.crtc_id, pipe.encoder_id,
406 pipe.connector_id);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700407
408 struct gbm_device *gbm = gbm_create_device(pipe.fd);
409 if (!gbm) {
410 bs_debug_error("failed to create gbm");
411 return 1;
412 }
413
414 struct gbm_bo *bg_bo = gbm_bo_create(gbm, mode.hdisplay, mode.vdisplay, GBM_FORMAT_XRGB8888,
415 GBM_BO_USE_SCANOUT | GBM_BO_USE_LINEAR);
416 if (!bg_bo) {
417 bs_debug_error("failed to create background buffer ojbect");
418 return 1;
419 }
420
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700421 struct bs_mapper *mapper = bs_mapper_dma_buf_new();
422 if (mapper == NULL) {
423 bs_debug_error("failed to create mapper object");
424 return 1;
425 }
426
427 void *map_data;
428 void *bo_ptr = bs_mapper_map(mapper, bg_bo, 0, &map_data);
429 if (bo_ptr == MAP_FAILED) {
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700430 bs_debug_error("failed to mmap background buffer object");
431 return 1;
432 }
433 memset(bo_ptr, 0xff, gbm_bo_get_height(bg_bo) * gbm_bo_get_stride(bg_bo));
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700434 bs_mapper_unmap(mapper, bg_bo, map_data);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700435
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700436 uint32_t crtc_fb_id = bs_drm_fb_create_gbm(bg_bo);
437 if (!crtc_fb_id) {
438 bs_debug_error("failed to create frame buffer for buffer object");
439 return 1;
440 }
441
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700442 for (size_t test_plane_index = 0; test_plane_index < test_planes_count;
443 test_plane_index++) {
444 struct test_plane *tp = &test_planes[test_plane_index];
445
446 if (!tp->format)
Gurchetan Singh61208942017-01-27 13:31:19 -0800447 tp->format = bs_get_draw_format(GBM_FORMAT_NV12);
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700448
Gurchetan Singh61208942017-01-27 13:31:19 -0800449 test_planes_formats[test_plane_index] = bs_get_pixel_format(tp->format);
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700450
451 if (!tp->has_bo_size) {
452 tp->bo_w = mode.hdisplay;
453 tp->bo_h = mode.vdisplay;
454 }
455
456 if (!tp->has_src_size) {
457 tp->src_w = tp->bo_w;
458 tp->src_h = tp->bo_h;
459 }
460
461 if (!tp->has_dst_size) {
462 tp->dst_w = tp->bo_w;
463 tp->dst_h = tp->bo_h;
464 }
465
466 if (tp->has_dst_position) {
467 tp->dst_center_x = tp->dst_x + mode.hdisplay / 2;
468 tp->dst_center_y = tp->dst_y + mode.vdisplay / 2;
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700469 } else {
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700470 tp->dst_center_x = mode.hdisplay / 2;
471 tp->dst_center_y = mode.vdisplay / 2;
472 tp->dst_x = tp->dst_center_x - tp->dst_w / 2;
473 tp->dst_y = tp->dst_center_y - tp->dst_h / 2;
474 }
475
476 if (tp->has_dst_scale) {
477 tp->dst_min_w = tp->dst_w / tp->dst_downscale_factor;
478 tp->dst_max_w = tp->dst_w * tp->dst_upscale_factor;
479 tp->dst_min_h = tp->dst_h / tp->dst_downscale_factor;
480 tp->dst_max_h = tp->dst_h * tp->dst_upscale_factor;
481 }
482
Gurchetan Singh61208942017-01-27 13:31:19 -0800483 printf("Creating buffer %ux%u %s\n", tp->bo_w, tp->bo_h,
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700484 bs_get_format_name(tp->format));
Gurchetan Singh61208942017-01-27 13:31:19 -0800485 tp->bo = gbm_bo_create(gbm, tp->bo_w, tp->bo_h, bs_get_pixel_format(tp->format),
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700486 GBM_BO_USE_SCANOUT | GBM_BO_USE_LINEAR);
487 if (!tp->bo) {
488 bs_debug_error("failed to create buffer object");
489 return 1;
490 }
491
492 tp->fb_id = bs_drm_fb_create_gbm(tp->bo);
493 if (!tp->fb_id) {
494 bs_debug_error("failed to create plane frame buffer for buffer object");
495 return 1;
496 }
497
Dongseong Hwang20c494c2016-04-27 11:26:19 +0300498 if (!bs_draw_stripe(mapper, tp->bo, tp->format)) {
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700499 bs_debug_error("failed to draw pattern to buffer object");
500 return 1;
501 }
502 }
503
504 if (!find_overlay_planes(pipe.fd, pipe.crtc_id, test_planes_count, test_planes_formats,
505 test_planes_ids)) {
506 bs_debug_error("failed to find overlay planes for given formats");
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700507 return 1;
508 }
509
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700510 ret = drmModeSetCrtc(pipe.fd, pipe.crtc_id, crtc_fb_id, 0, 0, &pipe.connector_id, 1, &mode);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700511 if (ret < 0) {
512 bs_debug_error("Could not set mode on CRTC %d %s", pipe.crtc_id, strerror(errno));
513 return 1;
514 }
515
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700516 struct timespec start;
517 clock_gettime(CLOCK_MONOTONIC, &start);
518 const int64_t ten_seconds_in_ns = 10000000000;
519 for (int i = 0; ns_since(&start) < ten_seconds_in_ns; i++) {
520 for (size_t test_plane_index = 0; test_plane_index < test_planes_count;
521 test_plane_index++) {
522 struct test_plane *current_plane = &test_planes[test_plane_index];
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700523
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700524 bool needs_set =
525 update_test_plane(i, mode.hdisplay, mode.vdisplay, current_plane);
526 if (!needs_set)
527 continue;
528
529 ret = drmModeSetPlane(
530 pipe.fd, test_planes_ids[test_plane_index], pipe.crtc_id,
531 current_plane->fb_id, 0 /* flags */, current_plane->dst_x,
532 current_plane->dst_y, current_plane->dst_w, current_plane->dst_h,
533 current_plane->src_x << 16, current_plane->src_y << 16,
534 current_plane->src_w << 16, current_plane->src_h << 16);
535
536 if (ret) {
537 bs_debug_error(
538 "failed to set plane "
539 "%d:\ndst[x,y,w,h]=%d,%d,%u,%u\nsrc[x,y,w,h]=%d,%d,%u,%u",
540 ret, current_plane->dst_x, current_plane->dst_y,
541 current_plane->dst_w, current_plane->dst_h,
542 current_plane->src_x, current_plane->src_y,
543 current_plane->src_w, current_plane->src_h);
544 return 1;
545 }
546 }
547
548 usleep(1000000 / 60);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700549 }
550
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700551 ret = drmModeSetCrtc(pipe.fd, pipe.crtc_id, 0, 0, 0, NULL, 0, NULL);
552 if (ret < 0) {
553 bs_debug_error("Could not disable CRTC %d %s", pipe.crtc_id, strerror(errno));
554 return 1;
555 }
556
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700557 bs_mapper_destroy(mapper);
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700558 for (size_t test_plane_index = 0; test_plane_index < test_planes_count;
559 test_plane_index++) {
560 struct test_plane *current_plane = &test_planes[test_plane_index];
561 drmModeRmFB(pipe.fd, current_plane->fb_id);
562 gbm_bo_destroy(current_plane->bo);
563 }
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700564 drmModeRmFB(pipe.fd, crtc_fb_id);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700565 gbm_bo_destroy(bg_bo);
566 gbm_device_destroy(gbm);
567 close(pipe.fd);
568
569 return 0;
570}