blob: 06ccedfa147148bc48c3a04bfa7633510c76290e [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 }
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700229 return needs_set;
230}
231
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700232static bool parse_size(const char *str, uint32_t *w, uint32_t *h)
233{
234 if (sscanf(str, "%ux%u", w, h) == 2)
235 return true;
236
237 printf("unrecognized size format \"%s\"\n", str);
238
239 return false;
240}
241
242static bool parse_scale(const char *str, uint32_t *down, uint32_t *up)
243{
244 if (sscanf(str, "%u/%u", down, up) == 2)
245 return true;
246
247 printf("unrecognized scale format \"%s\"\n", str);
248
249 return false;
250}
251
252static bool parse_rect(const char *str, int32_t *x, int32_t *y, uint32_t *w, uint32_t *h,
253 bool *has_position, bool *has_size)
254{
255 if (sscanf(str, "%d,%d,%u,%u", x, y, w, h) == 4) {
256 if (has_position)
257 *has_position = true;
258 if (has_size)
259 *has_size = true;
260 return true;
261 }
262
263 if (sscanf(str, "%d,%d", x, y) == 2) {
264 if (has_position)
265 *has_position = true;
266 if (has_size)
267 *has_size = false;
268 return true;
269 }
270
271 if (sscanf(str, "%ux%u", w, h) == 2) {
272 if (has_position)
273 *has_position = false;
274 if (has_size)
275 *has_size = true;
276 return true;
277 }
278
279 printf("unrecognized rectangle format \"%s\"\n", str);
280
281 return false;
282}
283
284static const struct option longopts[] = {
285 { "plane", no_argument, NULL, 'p' },
286 { "format", required_argument, NULL, 'f' },
287 { "size", required_argument, NULL, 'z' },
288 { "scale", required_argument, NULL, 'c' },
289 { "translate", no_argument, NULL, 't' },
290 { "src", required_argument, NULL, 's' },
291 { "dst", required_argument, NULL, 'd' },
292 { "help", no_argument, NULL, 'h' },
293 { 0, 0, 0, 0 },
294};
295
296static void print_help(const char *argv0)
297{
298 // clang-format off
299 printf("usage: %s [OPTIONS]\n", argv0);
300 printf(" -p, --plane indicates that subsequent parameters are for a new plane\n");
301 printf(" -f, --format FOURCC format of source buffer (defaults to NV12)\n");
302 printf(" -z, --size WIDTHxHEIGHT size of the source buffer (defaults to screen size)\n");
303 printf(" -c, --scale DOWN/UP scale plane over time between (1/DOWN)x and UPx\n");
304 printf(" -t, --translate translate plane over time\n");
305 printf(" -s, --src RECT source rectangle (defaults to full buffer)\n");
306 printf(" -d, --dst RECT destination rectangle (defaults to buffer size centered in screen)\n");
307 printf(" -h, --help show help\n");
308 printf("\n");
309 printf("The format of RECT arguments is X,Y or X,Y,WIDTH,HEIGHT or WIDTHxHEIGHT.\n");
310 printf("To test more than one plane, separate plane arguments with -p. For example:\n");
311 printf(" %s --format NV12 --size 400x400 -p --format XR24 --size 100x100 --translate\n", argv0);
312 printf("\n");
313 // clang-format on
314}
315
316int main(int argc, char **argv)
317{
318 int ret = 0;
319 bool help_flag = false;
320 size_t test_planes_count = 1;
321 struct test_plane test_planes[MAX_TEST_PLANES] = { { 0 } };
322 uint32_t test_planes_formats[MAX_TEST_PLANES] = { 0 };
323 uint32_t test_planes_ids[MAX_TEST_PLANES] = { 0 };
324
325 int c;
326 while ((c = getopt_long(argc, argv, "pf:z:c:ts:d:h", longopts, NULL)) != -1) {
327 struct test_plane *current_plane = &test_planes[test_planes_count - 1];
328 switch (c) {
329 case 'p':
330 test_planes_count++;
331 if (test_planes_count > MAX_TEST_PLANES) {
332 printf("only %d planes are allowed\n", MAX_TEST_PLANES);
333 return 1;
334 }
335 break;
336 case 'f':
Dongseong Hwang20c494c2016-04-27 11:26:19 +0300337 if (!bs_parse_draw_format(optarg, &current_plane->format))
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700338 return 1;
339 break;
340 case 'z':
341 if (!parse_size(optarg, &current_plane->bo_w, &current_plane->bo_h))
342 return 1;
343 current_plane->has_bo_size = true;
344 break;
345 case 'c':
346 if (!parse_scale(optarg, &current_plane->dst_downscale_factor,
347 &current_plane->dst_upscale_factor))
348 return 1;
349 current_plane->has_dst_scale = true;
350 break;
351 case 't':
352 current_plane->dst_vx = 7;
353 current_plane->dst_vy = 7;
354 break;
355 case 's':
356 if (!parse_rect(optarg, &current_plane->src_x,
357 &current_plane->src_y, &current_plane->src_w,
358 &current_plane->src_h, NULL,
359 &current_plane->has_src_size))
360 return 1;
361 break;
362 case 'd':
363 if (!parse_rect(optarg, &current_plane->dst_x,
364 &current_plane->dst_y, &current_plane->dst_w,
365 &current_plane->dst_h,
366 &current_plane->has_dst_position,
367 &current_plane->has_dst_size))
368 return 1;
369 break;
370 case '?':
371 ret = 1;
372 case 'h':
373 help_flag = true;
374 break;
375 }
376 }
377
378 if (help_flag)
379 print_help(argv[0]);
380
381 if (ret)
382 return ret;
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700383
384 drmModeConnector *connector;
385 struct bs_drm_pipe pipe = { 0 };
386 struct bs_drm_pipe_plumber *plumber = bs_drm_pipe_plumber_new();
387 bs_drm_pipe_plumber_connector_ranks(plumber, bs_drm_connectors_internal_rank);
388 bs_drm_pipe_plumber_connector_ptr(plumber, &connector);
389 if (!bs_drm_pipe_plumber_make(plumber, &pipe)) {
390 bs_debug_error("failed to make pipe");
391 return 1;
392 }
393 bs_drm_pipe_plumber_destroy(&plumber);
394
395 drmModeModeInfo *mode_ptr = find_best_mode(connector->count_modes, connector->modes);
396 if (!mode_ptr) {
397 bs_debug_error("failed to find preferred mode");
398 return 1;
399 }
400 drmModeModeInfo mode = *mode_ptr;
401 drmModeFreeConnector(connector);
402 printf("Using mode %s\n", mode.name);
403
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700404 printf("Using CRTC:%u ENCODER:%u CONNECTOR:%u\n", pipe.crtc_id, pipe.encoder_id,
405 pipe.connector_id);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700406
407 struct gbm_device *gbm = gbm_create_device(pipe.fd);
408 if (!gbm) {
409 bs_debug_error("failed to create gbm");
410 return 1;
411 }
412
413 struct gbm_bo *bg_bo = gbm_bo_create(gbm, mode.hdisplay, mode.vdisplay, GBM_FORMAT_XRGB8888,
Gurchetan Singh18a05992017-11-08 15:43:57 -0800414 GBM_BO_USE_SCANOUT | GBM_BO_USE_SW_WRITE_RARELY);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700415 if (!bg_bo) {
416 bs_debug_error("failed to create background buffer ojbect");
417 return 1;
418 }
419
Shirish S70b14ff2017-06-09 10:57:28 +0530420 struct bs_mapper *mapper = bs_mapper_gem_new();
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700421 if (mapper == NULL) {
422 bs_debug_error("failed to create mapper object");
423 return 1;
424 }
425
426 void *map_data;
Satyajit Sahub7e47dd2018-05-07 12:35:50 +0530427 uint32_t stride;
428 void *bo_ptr = bs_mapper_map(mapper, bg_bo, 0, &map_data, &stride);
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700429 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 }
Satyajit Sahub7e47dd2018-05-07 12:35:50 +0530433 memset(bo_ptr, 0, gbm_bo_get_height(bg_bo) * stride);
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),
Gurchetan Singh18a05992017-11-08 15:43:57 -0800486 GBM_BO_USE_SCANOUT | GBM_BO_USE_SW_WRITE_RARELY);
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700487 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 }
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700547 usleep(1000000 / 60);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700548 }
549
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700550 ret = drmModeSetCrtc(pipe.fd, pipe.crtc_id, 0, 0, 0, NULL, 0, NULL);
551 if (ret < 0) {
552 bs_debug_error("Could not disable CRTC %d %s", pipe.crtc_id, strerror(errno));
553 return 1;
554 }
555
Dongseong Hwang9093afe2017-03-20 19:16:28 -0700556 bs_mapper_destroy(mapper);
Zach Reiznerfa0547a2016-05-11 18:43:40 -0700557 for (size_t test_plane_index = 0; test_plane_index < test_planes_count;
558 test_plane_index++) {
559 struct test_plane *current_plane = &test_planes[test_plane_index];
560 drmModeRmFB(pipe.fd, current_plane->fb_id);
561 gbm_bo_destroy(current_plane->bo);
562 }
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700563 drmModeRmFB(pipe.fd, crtc_fb_id);
Zach Reiznerd847a7e2016-04-28 16:48:32 -0700564 gbm_bo_destroy(bg_bo);
565 gbm_device_destroy(gbm);
566 close(pipe.fd);
567
568 return 0;
569}