1 /**************************************************************************
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
7 * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8 * JinYoung Jeon <jy0.jeon@samsung.com>,
9 * Taeheon Kim <th908.kim@samsung.com>,
10 * YoungJun Cho <yj44.cho@samsung.com>,
11 * SooChan Lim <sc1.lim@samsung.com>,
12 * Boram Park <sc1.lim@samsung.com>
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sub license, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 **************************************************************************/
42 #include <tbm_surface.h>
43 #include <tbm_surface_internal.h>
49 #include "tdm_private.h"
50 #include "tdm_helper.h"
54 static const char *file_exts[2] = {"png", "yuv"};
59 tdm_helper_get_time_in_millis(void)
63 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
64 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
70 tdm_helper_get_time_in_micros(void)
74 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
75 return (tp.tv_sec * 1000000) + (tp.tv_nsec / 1000L);
81 _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
82 int size2, void *data3, int size3)
85 FILE *fp = fopen(file, "w+");
86 TDM_RETURN_IF_FAIL(fp != NULL);
88 blocks = (unsigned int *)data1;
89 fwrite(blocks, 1, size1, fp);
92 blocks = (unsigned int *)data2;
93 fwrite(blocks, 1, size2, fp);
97 blocks = (unsigned int *)data3;
98 fwrite(blocks, 1, size3, fp);
105 _tdm_helper_dump_png(const char *file, const void *data, int width,
108 FILE *fp = fopen(file, "wb");
109 TDM_RETURN_IF_FAIL(fp != NULL);
111 png_structp pPngStruct =
112 png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
118 png_infop pPngInfo = png_create_info_struct(pPngStruct);
120 png_destroy_write_struct(&pPngStruct, NULL);
125 png_init_io(pPngStruct, fp);
126 png_set_IHDR(pPngStruct,
133 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
135 png_set_bgr(pPngStruct);
136 png_write_info(pPngStruct, pPngInfo);
138 const int pixel_size = 4; // RGBA
139 png_bytep *row_pointers =
140 png_malloc(pPngStruct, height * sizeof(png_byte *));
142 unsigned int *blocks = (unsigned int *)data;
146 for (; y < height; ++y) {
148 png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size);
149 row_pointers[y] = (png_bytep)row;
150 for (x = 0; x < width; ++x) {
151 unsigned int curBlock = blocks[y * width + x];
152 row[x * pixel_size] = (curBlock & 0xFF);
153 row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
154 row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
155 row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
159 png_write_image(pPngStruct, row_pointers);
160 png_write_end(pPngStruct, pPngInfo);
162 for (y = 0; y < height; y++)
163 png_free(pPngStruct, row_pointers[y]);
164 png_free(pPngStruct, row_pointers);
166 png_destroy_write_struct(&pPngStruct, &pPngInfo);
172 tdm_helper_dump_buffer_str(tbm_surface_h buffer, const char *str)
174 tbm_surface_info_s info;
175 const char *dir = "/tmp/dump-tdm";
177 char file[TDM_PATH_LEN];
180 TDM_RETURN_IF_FAIL(buffer != NULL);
181 TDM_RETURN_IF_FAIL(str != NULL);
183 ret = tbm_surface_get_info(buffer, &info);
184 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
186 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
188 bw = info.planes[0].stride >> 2;
191 bw = info.planes[0].stride;
194 snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%s.%s",
195 dir, FOURCC_STR(info.format), bw, info.height, str, ext);
197 tdm_helper_dump_buffer(buffer, file);
201 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
203 tbm_surface_info_s info;
207 TDM_RETURN_IF_FAIL(buffer != NULL);
208 TDM_RETURN_IF_FAIL(file != NULL);
210 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
211 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
213 len = strnlen(file, 1024);
214 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
219 if (strncmp(file + (len - 3), ext, 3)) {
220 TDM_ERR("can't dump to '%s' file", file + (len - 3));
221 tbm_surface_unmap(buffer);
225 switch (info.format) {
226 case TBM_FORMAT_ARGB8888:
227 case TBM_FORMAT_XRGB8888:
228 _tdm_helper_dump_png(file, info.planes[0].ptr,
229 info.planes[0].stride >> 2, info.height);
231 case TBM_FORMAT_YVU420:
232 case TBM_FORMAT_YUV420:
233 _tdm_helper_dump_raw(file,
235 info.planes[0].stride * info.height,
237 info.planes[1].stride * (info.height >> 1),
239 info.planes[2].stride * (info.height >> 1));
241 case TBM_FORMAT_NV12:
242 case TBM_FORMAT_NV21:
243 _tdm_helper_dump_raw(file,
245 info.planes[0].stride * info.height,
247 info.planes[1].stride * (info.height >> 1), NULL,
250 case TBM_FORMAT_YUYV:
251 case TBM_FORMAT_UYVY:
252 _tdm_helper_dump_raw(file,
254 info.planes[0].stride * info.height, NULL, 0,
258 TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
259 tbm_surface_unmap(buffer);
263 tbm_surface_unmap(buffer);
265 TDM_INFO("dump %s", file);
269 tdm_helper_get_fd(const char *env)
272 int fd, newfd, flags, ret;
274 value = (const char*)getenv(env);
278 ret = sscanf(value, "%d", &fd);
280 TDM_ERR("sscanf failed: %m");
284 flags = fcntl(fd, F_GETFD);
286 TDM_ERR("fcntl failed: %m");
292 TDM_ERR("dup failed: %m");
296 TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
298 fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
304 tdm_helper_set_fd(const char *env, int fd)
309 snprintf(buf, sizeof(buf), "%d", fd);
311 ret = setenv(env, (const char*)buf, 1);
313 TDM_ERR("setenv failed: %m");
318 TDM_INFO("%s: fd(%d)", env, fd);
322 tdm_helper_dump_start(char *dumppath, int *count)
324 if (dumppath == NULL || count == NULL) {
325 TDM_DBG("tdm_helper_dump dumppath or count is null.");
331 TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath);
335 tdm_helper_dump_stop(void)
339 TDM_DBG("tdm_helper_dump stop.");
342 static pixman_format_code_t
343 _tdm_helper_pixman_format_get(tbm_format format)
346 case TBM_FORMAT_ARGB8888:
347 return PIXMAN_a8r8g8b8;
348 case TBM_FORMAT_XRGB8888:
349 return PIXMAN_x8r8g8b8;
358 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
359 int dx, int dy, int dw, int dh, int count)
361 pixman_image_t *src_img = NULL, *dst_img = NULL;
362 pixman_format_code_t src_format, dst_format;
363 pixman_transform_t t;
364 struct pixman_f_transform ft;
366 tbm_surface_info_s src_info = {0, };
367 tbm_surface_info_s dst_info = {0, };
369 double scale_x, scale_y;
371 TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
372 TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
374 if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
375 != TBM_SURFACE_ERROR_NONE) {
376 TDM_ERR("cannot mmap srcbuf\n");
377 return TDM_ERROR_OPERATION_FAILED;
380 if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
381 != TBM_SURFACE_ERROR_NONE) {
382 TDM_ERR("cannot mmap dstbuf\n");
383 tbm_surface_unmap(srcbuf);
384 return TDM_ERROR_OPERATION_FAILED;
386 TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert);
387 TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert);
390 src_format = _tdm_helper_pixman_format_get(src_info.format);
391 TDM_GOTO_IF_FAIL(src_format > 0, cant_convert);
393 width = src_info.planes[0].stride / 4;
394 stride = src_info.planes[0].stride;
395 src_img = pixman_image_create_bits(src_format, width, src_info.height,
396 (uint32_t*)src_info.planes[0].ptr, stride);
397 TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert);
400 dst_format = _tdm_helper_pixman_format_get(dst_info.format);
401 TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert);
403 width = dst_info.planes[0].stride / 4;
404 stride = dst_info.planes[0].stride;
405 dst_img = pixman_image_create_bits(dst_format, width, dst_info.height,
406 (uint32_t*)dst_info.planes[0].ptr, stride);
407 TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert);
409 pixman_f_transform_init_identity(&ft);
411 scale_x = (double)src_info.width / dw;
412 scale_y = (double)src_info.height / dh;
414 pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
415 pixman_f_transform_translate(&ft, NULL, 0, 0);
416 pixman_transform_from_pixman_f_transform(&t, &ft);
417 pixman_image_set_transform(src_img, &t);
424 pixman_image_composite(op, src_img, NULL, dst_img,
425 0, 0, 0, 0, dx, dy, dw, dh);
428 pixman_image_unref(src_img);
430 pixman_image_unref(dst_img);
432 tbm_surface_unmap(srcbuf);
433 tbm_surface_unmap(dstbuf);
435 return TDM_ERROR_NONE;
439 pixman_image_unref(src_img);
441 tbm_surface_unmap(srcbuf);
442 tbm_surface_unmap(dstbuf);
444 return TDM_ERROR_OPERATION_FAILED;
448 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
449 int x, int y, int w, int h,
450 tdm_helper_capture_handler func, void *data)
452 tbm_surface_h surface;
454 int i, count, first = 0;
456 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
457 TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
458 TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER);
459 TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER);
460 TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
461 TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
462 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
463 TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
465 err = tdm_output_get_layer_count(output, &count);
466 if (err != TDM_ERROR_NONE) {
467 TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
468 return TDM_ERROR_OPERATION_FAILED;
471 TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count);
472 return TDM_ERROR_BAD_MODULE;
475 for (i = count - 1; i >= 0; i--) {
476 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
478 surface = tdm_layer_get_displaying_buffer(layer, &err);
479 if (err != TDM_ERROR_NONE)
482 err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++);
483 if (err != TDM_ERROR_NONE)
484 TDM_DBG("convert fail %d-layer buffer\n", i);
486 TDM_DBG("convert success %d-layer buffer\n", i);
489 func(dst_buffer, data);
491 return TDM_ERROR_NONE;
495 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
497 const char *name, *vendor;
502 const tdm_prop *props;
503 int min_w, min_h, max_w, max_h, preferred_align;
504 const tbm_format *formats;
505 tdm_display_capability display_caps;
507 ret = tdm_display_get_backend_info(dpy, &name, &vendor, &major, &minor);
508 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
510 TDM_SNPRINTF(reply, len, "TDM backend name: %s\n", name);
511 TDM_SNPRINTF(reply, len, "TDM backend vendor: %s\n", vendor);
512 TDM_SNPRINTF(reply, len, "TDM backend version: %d.%d\n\n", major, minor);
514 ret = tdm_display_get_output_count(dpy, &count);
515 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
517 TDM_SNPRINTF(reply, len, "[Output information]\n");
518 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------------------------------------\n");
519 TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpix prefer min max phy\n");
520 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------------------------------------\n");
522 for (i = 0; i < count; i++) {
523 /* idx maker model name type status dpms subpix prefer min max phy */
524 const char *maker, *model, *name;
525 tdm_output_type type;
526 tdm_output_conn_status status;
527 unsigned int subpixel;
528 unsigned int mmWidth, mmHeight;
529 tdm_output_dpms dpms;
530 const tdm_output_mode *mode, *modes;
533 output = tdm_display_get_output(dpy, i, &ret);
534 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
535 ret = tdm_output_get_model_info(output, &maker, &model, &name);
536 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
537 ret = tdm_output_get_output_type(output, &type);
538 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
539 ret = tdm_output_get_conn_status(output, &status);
540 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
541 ret = tdm_output_get_dpms(output, &dpms);
542 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
543 ret = tdm_output_get_subpixel(output, &subpixel);
544 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
545 ret = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align);
546 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
547 ret = tdm_output_get_physical_size(output, &mmWidth, &mmHeight);
548 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
550 TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
551 i, maker, model, name, tdm_conn_str(type), tdm_status_str(status),
552 tdm_dpms_str(dpms), subpixel, preferred_align,
553 min_w, min_h, max_w, max_h, mmWidth, mmHeight);
555 ret = tdm_output_get_mode(output, &mode);
556 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
558 ret = tdm_output_get_available_modes(output, &modes, &cnt);
559 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
561 TDM_SNPRINTF(reply, len, "\t%d modes:\n", cnt);
564 TDM_SNPRINTF(reply, len, "\t\tname refresh (Hz) hdisp hss hse htot vdisp vss vse vtot\n");
565 for (j = 0; j < cnt; j++) {
566 char *current = (mode == modes + j) ? "*" : " ";
567 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d ",
572 modes[j].hsync_start,
576 modes[j].vsync_start,
579 tdm_mode_flag_str(modes[j].flags, &reply, len);
580 TDM_SNPRINTF(reply, len, " ");
581 tdm_mode_type_str(modes[j].type, &reply, len);
582 TDM_SNPRINTF(reply, len, "\n");
586 ret = tdm_output_get_available_properties(output, &props, &cnt);
587 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
589 TDM_SNPRINTF(reply, len, "\t%d properties:\n", cnt);
591 TDM_SNPRINTF(reply, len, "\t\tname idx value\n");
592 for (j = 0; j < cnt; j++) {
594 ret = tdm_output_get_property(output, props[j].id, &value);
595 TDM_SNPRINTF(reply, len, "\t\t%s %d %d\n",
601 TDM_SNPRINTF(reply, len, "\n");
604 TDM_SNPRINTF(reply, len, "[Layer information]\n");
605 for (i = 0; i < count; i++) {
608 output = tdm_display_get_output(dpy, i, &ret);
609 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
611 ret = tdm_output_get_layer_count(output, &cnt);
612 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
615 TDM_SNPRINTF(reply, len, "-----------------------------------------------------\n");
616 TDM_SNPRINTF(reply, len, "idx output zpos buf info caps\n");
617 TDM_SNPRINTF(reply, len, "-----------------------------------------------------\n");
618 for (j = 0; j < cnt; j++) {
621 tdm_layer_capability layer_caps;
625 memset(&info, 0, sizeof info);
627 layer = tdm_output_get_layer(output, j, &ret);
628 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
629 ret = tdm_layer_get_capabilities(layer, &layer_caps);
630 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
631 ret = tdm_layer_get_zpos(layer, &zpos);
632 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
634 ret = tdm_layer_get_info(layer, &info);
635 buf = tdm_layer_get_displaying_buffer(layer, &ret);
637 if (info.src_config.format)
638 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d (%d,%d %dx%d) (%d,%d %dx%d) trans(%d) ",
640 FOURCC_STR(info.src_config.format), info.src_config.size.h, info.src_config.size.v,
641 info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
642 info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
645 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d (%d,%d %dx%d) (%d,%d %dx%d) trans(%d) ",
647 'N', 'O', 'N', 'E', info.src_config.size.h, info.src_config.size.v,
648 info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h,
649 info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h,
651 tdm_layer_caps_str(layer_caps, &reply, len);
652 TDM_SNPRINTF(reply, len, "\n");
654 ret = tdm_layer_get_available_properties(layer, &props, &c);
655 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
656 TDM_SNPRINTF(reply, len, "\t%d properties:\n", c);
658 TDM_SNPRINTF(reply, len, "\t\tname idx value\n");
659 for (k = 0; k < c; k++) {
661 ret = tdm_layer_get_property(layer, props[k].id, &value);
662 TDM_SNPRINTF(reply, len, "\t\t%s %d %d\n",
669 ret = tdm_layer_get_available_formats(layer, &formats, &c);
670 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
671 TDM_SNPRINTF(reply, len, "\tformats:");
672 for (k = 0; k < c; k++)
673 TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[k]));
674 TDM_SNPRINTF(reply, len, "\n");
679 TDM_SNPRINTF(reply, len, "\n");
681 ret = tdm_display_get_capabilities(dpy, &display_caps);
682 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
684 if (display_caps & TDM_DISPLAY_CAPABILITY_PP) {
685 tdm_pp_capability pp_caps;
687 ret = tdm_display_get_pp_capabilities(dpy, &pp_caps);
688 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
689 ret = tdm_display_get_pp_available_formats(dpy, &formats, &count);
690 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
691 ret = tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align);
692 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
694 TDM_SNPRINTF(reply, len, "[PP information]\n");
695 TDM_SNPRINTF(reply, len, "caps: ");
696 tdm_pp_caps_str(pp_caps, &reply, len);
697 TDM_SNPRINTF(reply, len, "\n");
698 TDM_SNPRINTF(reply, len, "formats: ");
699 for (i = 0; i < count; i++)
700 TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[i]));
701 TDM_SNPRINTF(reply, len, "\n");
702 TDM_SNPRINTF(reply, len, "size: min(%dx%d) max(%dx%d) preferred(%d)\n",
703 min_w, min_h, max_w, max_h, preferred_align);
706 if (display_caps & TDM_DISPLAY_CAPABILITY_CAPTURE) {
707 tdm_capture_capability capture_caps;
709 ret = tdm_display_get_capture_capabilities(dpy, &capture_caps);
710 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
711 ret = tdm_display_get_catpure_available_formats(dpy, &formats, &count);
712 TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
714 TDM_SNPRINTF(reply, len, "[Capture information]\n");
715 TDM_SNPRINTF(reply, len, "caps: ");
716 tdm_capture_caps_str(capture_caps, &reply, len);
717 TDM_SNPRINTF(reply, len, "\n");
718 TDM_SNPRINTF(reply, len, "formats: ");
719 for (i = 0; i < count; i++)
720 TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[i]));
721 TDM_SNPRINTF(reply, len, "\n");