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_clear_buffer(tbm_surface_h buffer)
271 tbm_surface_info_s info;
274 TDM_RETURN_IF_FAIL(buffer != NULL);
276 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
277 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
279 switch (info.format) {
280 case TBM_FORMAT_ARGB8888:
281 case TBM_FORMAT_XRGB8888:
282 memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
284 case TBM_FORMAT_YVU420:
285 case TBM_FORMAT_YUV420:
286 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
287 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
288 memset((char*)info.planes[2].ptr, 0x80, info.planes[2].stride * (info.height >> 1));
290 case TBM_FORMAT_NV12:
291 case TBM_FORMAT_NV21:
292 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
293 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
295 case TBM_FORMAT_YUYV: {
296 int *ibuf = (int*)info.planes[0].ptr;
297 int i, size = info.planes[0].stride * info.height / 4;
299 for (i = 0 ; i < size ; i++)
300 ibuf[i] = 0x10801080;
303 case TBM_FORMAT_UYVY: {
304 int *ibuf = (int*)info.planes[0].ptr;
305 int i, size = info.planes[0].stride * info.height / 4;
307 for (i = 0 ; i < size ; i++)
308 ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */
312 TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format));
316 tbm_surface_unmap(buffer);
320 tdm_helper_get_fd(const char *env)
323 int fd, newfd, flags, ret;
325 value = (const char*)getenv(env);
329 ret = sscanf(value, "%d", &fd);
331 TDM_ERR("sscanf failed: %m");
335 flags = fcntl(fd, F_GETFD);
337 TDM_ERR("fcntl failed: %m");
343 TDM_ERR("dup failed: %m");
347 TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
349 fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
355 tdm_helper_set_fd(const char *env, int fd)
360 snprintf(buf, sizeof(buf), "%d", fd);
362 ret = setenv(env, (const char*)buf, 1);
364 TDM_ERR("setenv failed: %m");
369 TDM_INFO("%s: fd(%d)", env, fd);
373 tdm_helper_dump_start(char *dumppath, int *count)
375 if (dumppath == NULL || count == NULL) {
376 TDM_DBG("tdm_helper_dump dumppath or count is null.");
382 TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath);
386 tdm_helper_dump_stop(void)
390 TDM_DBG("tdm_helper_dump stop.");
393 static pixman_format_code_t
394 _tdm_helper_pixman_format_get(tbm_format format)
397 case TBM_FORMAT_ARGB8888:
398 return PIXMAN_a8r8g8b8;
399 case TBM_FORMAT_XRGB8888:
400 return PIXMAN_x8r8g8b8;
409 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
410 int dx, int dy, int dw, int dh, int count)
412 pixman_image_t *src_img = NULL, *dst_img = NULL;
413 pixman_format_code_t src_format, dst_format;
414 pixman_transform_t t;
415 struct pixman_f_transform ft;
417 tbm_surface_info_s src_info = {0, };
418 tbm_surface_info_s dst_info = {0, };
420 double scale_x, scale_y;
422 TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
423 TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
425 if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
426 != TBM_SURFACE_ERROR_NONE) {
427 TDM_ERR("cannot mmap srcbuf\n");
428 return TDM_ERROR_OPERATION_FAILED;
431 if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
432 != TBM_SURFACE_ERROR_NONE) {
433 TDM_ERR("cannot mmap dstbuf\n");
434 tbm_surface_unmap(srcbuf);
435 return TDM_ERROR_OPERATION_FAILED;
437 TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert);
438 TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert);
441 src_format = _tdm_helper_pixman_format_get(src_info.format);
442 TDM_GOTO_IF_FAIL(src_format > 0, cant_convert);
444 width = src_info.planes[0].stride / 4;
445 stride = src_info.planes[0].stride;
446 src_img = pixman_image_create_bits(src_format, width, src_info.height,
447 (uint32_t*)src_info.planes[0].ptr, stride);
448 TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert);
451 dst_format = _tdm_helper_pixman_format_get(dst_info.format);
452 TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert);
454 width = dst_info.planes[0].stride / 4;
455 stride = dst_info.planes[0].stride;
456 dst_img = pixman_image_create_bits(dst_format, width, dst_info.height,
457 (uint32_t*)dst_info.planes[0].ptr, stride);
458 TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert);
460 pixman_f_transform_init_identity(&ft);
462 scale_x = (double)src_info.width / dw;
463 scale_y = (double)src_info.height / dh;
465 pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
466 pixman_f_transform_translate(&ft, NULL, 0, 0);
467 pixman_transform_from_pixman_f_transform(&t, &ft);
468 pixman_image_set_transform(src_img, &t);
475 pixman_image_composite(op, src_img, NULL, dst_img,
476 0, 0, 0, 0, dx, dy, dw, dh);
479 pixman_image_unref(src_img);
481 pixman_image_unref(dst_img);
483 tbm_surface_unmap(srcbuf);
484 tbm_surface_unmap(dstbuf);
486 return TDM_ERROR_NONE;
490 pixman_image_unref(src_img);
492 tbm_surface_unmap(srcbuf);
493 tbm_surface_unmap(dstbuf);
495 return TDM_ERROR_OPERATION_FAILED;
499 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
500 int x, int y, int w, int h,
501 tdm_helper_capture_handler func, void *data)
503 tbm_surface_h surface;
505 int i, count, first = 0;
507 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
508 TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
509 TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER);
510 TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER);
511 TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
512 TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
513 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
514 TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
516 err = tdm_output_get_layer_count(output, &count);
517 if (err != TDM_ERROR_NONE) {
518 TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
519 return TDM_ERROR_OPERATION_FAILED;
522 TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count);
523 return TDM_ERROR_BAD_MODULE;
526 for (i = count - 1; i >= 0; i--) {
527 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
529 surface = tdm_layer_get_displaying_buffer(layer, &err);
530 if (err != TDM_ERROR_NONE)
533 err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++);
534 if (err != TDM_ERROR_NONE)
535 TDM_DBG("convert fail %d-layer buffer\n", i);
537 TDM_DBG("convert success %d-layer buffer\n", i);
540 func(dst_buffer, data);
542 return TDM_ERROR_NONE;
546 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
548 tdm_private_display *private_display;
549 tdm_backend_module *module_data;
550 tdm_func_output *func_output;
551 tdm_func_layer *func_layer;
552 tdm_private_output *private_output = NULL;
553 tdm_private_layer *private_layer = NULL;
554 tdm_private_pp *private_pp = NULL;
555 tdm_private_capture *private_capture = NULL;
559 TDM_DBG_RETURN_IF_FAIL(dpy != NULL);
561 private_display = dpy;
562 func_output = &private_display->func_output;
563 func_layer = &private_display->func_layer;
564 _pthread_mutex_lock(&private_display->lock);
566 /* module information */
567 module_data = private_display->module_data;
568 TDM_SNPRINTF(reply, len, "[TDM backend information]\n");
569 TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name);
570 TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor);
571 TDM_SNPRINTF(reply, len, "version: %d.%d\n\n",
572 (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version),
573 (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version));
575 /* output information */
576 TDM_SNPRINTF(reply, len, "[Output information]\n");
577 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
578 TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n");
579 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
580 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
581 TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
582 private_output->index, private_output->caps.maker,
583 private_output->caps.model, private_output->caps.name,
584 tdm_conn_str(private_output->caps.type),
585 tdm_status_str(private_output->caps.status),
586 tdm_dpms_str(private_output->current_dpms_value),
587 private_output->caps.subpixel,
588 private_output->caps.preferred_align,
589 private_output->caps.min_w, private_output->caps.min_h,
590 private_output->caps.max_w, private_output->caps.max_h,
591 private_output->caps.mmWidth, private_output->caps.mmHeight);
593 TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
595 if (private_output->caps.mode_count > 0) {
596 const tdm_output_mode *current_mode = NULL;
598 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_mode, unlock);
599 ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode);
600 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
602 TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot\n");
603 for (i = 0; i < private_output->caps.mode_count; i++) {
604 char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
605 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d ",
607 private_output->caps.modes[i].name,
608 private_output->caps.modes[i].vrefresh,
609 private_output->caps.modes[i].hdisplay,
610 private_output->caps.modes[i].hsync_start,
611 private_output->caps.modes[i].hsync_end,
612 private_output->caps.modes[i].htotal,
613 private_output->caps.modes[i].vdisplay,
614 private_output->caps.modes[i].vsync_start,
615 private_output->caps.modes[i].vsync_end,
616 private_output->caps.modes[i].vtotal);
617 tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len);
618 TDM_SNPRINTF(reply, len, " ");
619 tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len);
620 TDM_SNPRINTF(reply, len, "\n");
624 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count);
625 if (private_output->caps.prop_count > 0) {
626 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
627 for (i = 0; i < private_output->caps.prop_count; i++) {
629 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock);
630 ret = func_output->output_get_property(private_output->output_backend,
631 private_output->caps.props[i].id,
633 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
634 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
635 private_output->caps.props[i].name,
636 private_output->caps.props[i].id,
641 TDM_SNPRINTF(reply, len, "\n");
643 /* layer information */
644 TDM_SNPRINTF(reply, len, "[Layer information]\n");
645 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
646 TDM_SNPRINTF(reply, len, "idx output zpos buf format size crop geometry transform\n");
647 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
648 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
649 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
650 if (!private_layer->usable) {
654 tbm_surface_info_s buf_info;
656 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock);
657 memset(&info, 0, sizeof info);
658 ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
659 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
661 format = tbm_surface_get_format(private_layer->showing_buffer);
662 tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
665 size.h = buf_info.planes[0].stride >> 2;
667 size.h = buf_info.planes[0].stride;
668 size.v = tbm_surface_get_height(private_layer->showing_buffer);
670 if (info.src_config.format)
671 format = (info.src_config.format)?:format;
673 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n",
674 private_layer->index,
675 private_output->index,
676 private_layer->caps.zpos,
677 private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
678 info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
679 info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
680 tdm_transform_str(info.transform));
682 TDM_SNPRINTF(reply, len, "%d %d %d -\n",
683 private_layer->index,
684 private_output->index,
685 private_layer->caps.zpos);
688 TDM_SNPRINTF(reply, len, "\tcaps\t: ");
689 tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len);
690 TDM_SNPRINTF(reply, len, "\n");
692 TDM_SNPRINTF(reply, len, "\tformats\t: ");
693 if (private_layer->caps.format_count > 0) {
694 const char *sep = "";
695 for (i = 0; i < private_layer->caps.format_count; i++) {
696 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i]));
699 TDM_SNPRINTF(reply, len, "\n");
702 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
703 if (private_layer->caps.prop_count > 0) {
704 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
705 for (i = 0; i < private_layer->caps.prop_count; i++) {
707 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_property, unlock);
708 ret = func_layer->layer_get_property(private_layer->layer_backend,
709 private_layer->caps.props[i].id,
711 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
712 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
713 private_layer->caps.props[i].name,
714 private_layer->caps.props[i].id,
720 TDM_SNPRINTF(reply, len, "\n");
722 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
723 const char *sep = "";
724 TDM_SNPRINTF(reply, len, "[PP information]\n");
725 TDM_SNPRINTF(reply, len, "caps\t: ");
726 tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len);
727 TDM_SNPRINTF(reply, len, "\n");
728 TDM_SNPRINTF(reply, len, "formats\t: ");
729 for (i = 0; i < private_display->caps_pp.format_count; i++) {
730 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i]));
733 TDM_SNPRINTF(reply, len, "\n");
734 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
735 private_display->caps_pp.min_w, private_display->caps_pp.min_h,
736 private_display->caps_pp.max_w, private_display->caps_pp.max_h,
737 private_display->caps_pp.preferred_align);
738 if (!LIST_IS_EMPTY(&private_display->pp_list)) {
739 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
740 TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n");
741 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
742 LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
743 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
744 FOURCC_STR(private_pp->info.src_config.format),
745 private_pp->info.src_config.size.h,
746 private_pp->info.src_config.size.v,
747 private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y,
748 private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h,
749 FOURCC_STR(private_pp->info.dst_config.format),
750 private_pp->info.dst_config.size.h,
751 private_pp->info.dst_config.size.v,
752 private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y,
753 private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h,
754 tdm_transform_str(private_pp->info.transform));
758 TDM_SNPRINTF(reply, len, "[No PP capability]\n");
760 TDM_SNPRINTF(reply, len, "\n");
762 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
763 const char *sep = "";
764 TDM_SNPRINTF(reply, len, "[Capture information]\n");
765 TDM_SNPRINTF(reply, len, "caps\t: ");
766 tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len);
767 TDM_SNPRINTF(reply, len, "\n");
768 TDM_SNPRINTF(reply, len, "formats\t: ");
769 for (i = 0; i < private_display->caps_capture.format_count; i++) {
770 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i]));
773 TDM_SNPRINTF(reply, len, "\n");
774 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
775 private_display->caps_capture.min_w, private_display->caps_capture.min_h,
776 private_display->caps_capture.max_w, private_display->caps_capture.max_h,
777 private_display->caps_capture.preferred_align);
778 if (!LIST_IS_EMPTY(&private_display->capture_list)) {
779 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
780 TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n");
781 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
782 LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
783 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
784 FOURCC_STR(private_capture->info.dst_config.format),
785 private_capture->info.dst_config.size.h,
786 private_capture->info.dst_config.size.v,
787 private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y,
788 private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h,
789 tdm_transform_str(private_capture->info.transform));
793 TDM_SNPRINTF(reply, len, "[No Capture capability]\n");
795 TDM_SNPRINTF(reply, len, "\n");
798 _pthread_mutex_unlock(&private_display->lock);