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"};
57 char *tdm_debug_dump_dir;
60 tdm_helper_get_time(void)
64 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
65 return (double)tp.tv_sec + ((double)tp.tv_nsec) / 1000000000.0;
71 _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
72 int size2, void *data3, int size3)
75 FILE *fp = fopen(file, "w+");
76 TDM_RETURN_IF_FAIL(fp != NULL);
78 blocks = (unsigned int *)data1;
79 fwrite(blocks, 1, size1, fp);
82 blocks = (unsigned int *)data2;
83 fwrite(blocks, 1, size2, fp);
87 blocks = (unsigned int *)data3;
88 fwrite(blocks, 1, size3, fp);
95 _tdm_helper_dump_png(const char *file, const void *data, int width,
98 FILE *fp = fopen(file, "wb");
99 TDM_RETURN_IF_FAIL(fp != NULL);
101 png_structp pPngStruct =
102 png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
108 png_infop pPngInfo = png_create_info_struct(pPngStruct);
110 png_destroy_write_struct(&pPngStruct, NULL);
115 png_init_io(pPngStruct, fp);
116 png_set_IHDR(pPngStruct,
123 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
125 png_set_bgr(pPngStruct);
126 png_write_info(pPngStruct, pPngInfo);
128 const int pixel_size = 4; // RGBA
129 png_bytep *row_pointers =
130 png_malloc(pPngStruct, height * sizeof(png_byte *));
132 unsigned int *blocks = (unsigned int *)data;
136 for (; y < height; ++y) {
138 png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size);
139 row_pointers[y] = (png_bytep)row;
140 for (x = 0; x < width; ++x) {
141 unsigned int curBlock = blocks[y * width + x];
142 row[x * pixel_size] = (curBlock & 0xFF);
143 row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
144 row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
145 row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
149 png_write_image(pPngStruct, row_pointers);
150 png_write_end(pPngStruct, pPngInfo);
152 for (y = 0; y < height; y++)
153 png_free(pPngStruct, row_pointers[y]);
154 png_free(pPngStruct, row_pointers);
156 png_destroy_write_struct(&pPngStruct, &pPngInfo);
162 tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
164 char *fullpath = NULL;
166 struct tm *t, *buf = NULL;
170 buf = calloc(1, sizeof(struct tm));
171 TDM_GOTO_IF_FAIL(buf != NULL, failed_make);
173 fullpath = calloc(1, TDM_PATH_LEN * sizeof(char));
174 TDM_GOTO_IF_FAIL(fullpath != NULL, failed_make);
176 t = localtime_r(&timer, buf);
177 TDM_GOTO_IF_FAIL(t != NULL, failed_make);
179 snprintf(fullpath, TDM_PATH_LEN, "%s/dump_%04d%02d%02d.%02d%02d%02d", path,
180 t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
182 if ((mkdir(fullpath, 0755)) < 0) {
183 TDM_ERR("mkdir '%s' fail\n", fullpath);
184 TDM_SNPRINTF(reply, len, "mkdir '%s' fail\n", fullpath);
200 tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
202 tbm_surface_info_s info;
204 char file[TDM_PATH_LEN];
207 TDM_RETURN_IF_FAIL(buffer != NULL);
208 TDM_RETURN_IF_FAIL(dir != NULL);
209 TDM_RETURN_IF_FAIL(str != NULL);
211 ret = tbm_surface_get_info(buffer, &info);
212 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
214 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
216 bw = info.planes[0].stride >> 2;
219 bw = info.planes[0].stride;
222 snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%s.%s",
223 dir, FOURCC_STR(info.format), bw, info.height, str, ext);
225 tdm_helper_dump_buffer(buffer, file);
229 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
231 tbm_surface_info_s info;
235 TDM_RETURN_IF_FAIL(buffer != NULL);
236 TDM_RETURN_IF_FAIL(file != NULL);
238 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
239 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
241 len = strnlen(file, 1024);
242 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
247 if (strncmp(file + (len - 3), ext, 3)) {
248 TDM_ERR("can't dump to '%s' file", file + (len - 3));
249 tbm_surface_unmap(buffer);
253 switch (info.format) {
254 case TBM_FORMAT_ARGB8888:
255 case TBM_FORMAT_XRGB8888:
256 _tdm_helper_dump_png(file, info.planes[0].ptr,
257 info.planes[0].stride >> 2, info.height);
259 case TBM_FORMAT_YVU420:
260 case TBM_FORMAT_YUV420:
261 _tdm_helper_dump_raw(file,
263 info.planes[0].stride * info.height,
265 info.planes[1].stride * (info.height >> 1),
267 info.planes[2].stride * (info.height >> 1));
269 case TBM_FORMAT_NV12:
270 case TBM_FORMAT_NV21:
271 _tdm_helper_dump_raw(file,
273 info.planes[0].stride * info.height,
275 info.planes[1].stride * (info.height >> 1), NULL,
278 case TBM_FORMAT_YUYV:
279 case TBM_FORMAT_UYVY:
280 _tdm_helper_dump_raw(file,
282 info.planes[0].stride * info.height, NULL, 0,
286 TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
287 tbm_surface_unmap(buffer);
291 tbm_surface_unmap(buffer);
293 TDM_INFO("dump %s", file);
297 tdm_helper_clear_buffer(tbm_surface_h buffer)
299 tbm_surface_info_s info;
302 TDM_RETURN_IF_FAIL(buffer != NULL);
304 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
305 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
307 switch (info.format) {
308 case TBM_FORMAT_ARGB8888:
309 case TBM_FORMAT_XRGB8888:
310 memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
312 case TBM_FORMAT_YVU420:
313 case TBM_FORMAT_YUV420:
314 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
315 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
316 memset((char*)info.planes[2].ptr, 0x80, info.planes[2].stride * (info.height >> 1));
318 case TBM_FORMAT_NV12:
319 case TBM_FORMAT_NV21:
320 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
321 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
323 case TBM_FORMAT_YUYV: {
324 int *ibuf = (int*)info.planes[0].ptr;
325 int i, size = info.planes[0].stride * info.height / 4;
327 for (i = 0 ; i < size ; i++)
328 ibuf[i] = 0x10801080;
331 case TBM_FORMAT_UYVY: {
332 int *ibuf = (int*)info.planes[0].ptr;
333 int i, size = info.planes[0].stride * info.height / 4;
335 for (i = 0 ; i < size ; i++)
336 ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */
340 TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format));
344 tbm_surface_unmap(buffer);
348 tdm_helper_get_fd(const char *env)
351 int fd, newfd, flags, ret;
353 value = (const char*)getenv(env);
357 ret = sscanf(value, "%d", &fd);
359 TDM_ERR("sscanf failed: %m");
363 flags = fcntl(fd, F_GETFD);
365 TDM_ERR("fcntl failed: %m");
371 TDM_ERR("dup failed: %m");
375 TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
377 fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
383 tdm_helper_set_fd(const char *env, int fd)
388 snprintf(buf, sizeof(buf), "%d", fd);
390 ret = setenv(env, (const char*)buf, 1);
392 TDM_ERR("setenv failed: %m");
397 TDM_INFO("%s: fd(%d)", env, fd);
401 tdm_helper_dump_start(char *dumppath, int *count)
403 if (dumppath == NULL || count == NULL) {
404 TDM_DBG("tdm_helper_dump dumppath or count is null.");
410 TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath);
414 tdm_helper_dump_stop(void)
418 TDM_DBG("tdm_helper_dump stop.");
421 static pixman_format_code_t
422 _tdm_helper_pixman_format_get(tbm_format format)
425 case TBM_FORMAT_ARGB8888:
426 return PIXMAN_a8r8g8b8;
427 case TBM_FORMAT_XRGB8888:
428 return PIXMAN_x8r8g8b8;
437 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
438 int dx, int dy, int dw, int dh, int count)
440 pixman_image_t *src_img = NULL, *dst_img = NULL;
441 pixman_format_code_t src_format, dst_format;
442 pixman_transform_t t;
443 struct pixman_f_transform ft;
445 tbm_surface_info_s src_info = {0, };
446 tbm_surface_info_s dst_info = {0, };
448 double scale_x, scale_y;
450 TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
451 TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
453 if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
454 != TBM_SURFACE_ERROR_NONE) {
455 TDM_ERR("cannot mmap srcbuf\n");
456 return TDM_ERROR_OPERATION_FAILED;
459 if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
460 != TBM_SURFACE_ERROR_NONE) {
461 TDM_ERR("cannot mmap dstbuf\n");
462 tbm_surface_unmap(srcbuf);
463 return TDM_ERROR_OPERATION_FAILED;
465 TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert);
466 TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert);
469 src_format = _tdm_helper_pixman_format_get(src_info.format);
470 TDM_GOTO_IF_FAIL(src_format > 0, cant_convert);
472 width = src_info.planes[0].stride / 4;
473 stride = src_info.planes[0].stride;
474 src_img = pixman_image_create_bits(src_format, width, src_info.height,
475 (uint32_t*)src_info.planes[0].ptr, stride);
476 TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert);
479 dst_format = _tdm_helper_pixman_format_get(dst_info.format);
480 TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert);
482 width = dst_info.planes[0].stride / 4;
483 stride = dst_info.planes[0].stride;
484 dst_img = pixman_image_create_bits(dst_format, width, dst_info.height,
485 (uint32_t*)dst_info.planes[0].ptr, stride);
486 TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert);
488 pixman_f_transform_init_identity(&ft);
490 scale_x = (double)src_info.width / dw;
491 scale_y = (double)src_info.height / dh;
493 pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
494 pixman_f_transform_translate(&ft, NULL, 0, 0);
495 pixman_transform_from_pixman_f_transform(&t, &ft);
496 pixman_image_set_transform(src_img, &t);
503 pixman_image_composite(op, src_img, NULL, dst_img,
504 0, 0, 0, 0, dx, dy, dw, dh);
507 pixman_image_unref(src_img);
509 pixman_image_unref(dst_img);
511 tbm_surface_unmap(srcbuf);
512 tbm_surface_unmap(dstbuf);
514 return TDM_ERROR_NONE;
518 pixman_image_unref(src_img);
520 tbm_surface_unmap(srcbuf);
521 tbm_surface_unmap(dstbuf);
523 return TDM_ERROR_OPERATION_FAILED;
527 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
528 int x, int y, int w, int h,
529 tdm_helper_capture_handler func, void *data)
531 tbm_surface_h surface;
533 int i, count, first = 0;
535 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
536 TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
537 TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER);
538 TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER);
539 TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
540 TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
541 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
542 TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
544 err = tdm_output_get_layer_count(output, &count);
545 if (err != TDM_ERROR_NONE) {
546 TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
547 return TDM_ERROR_OPERATION_FAILED;
550 TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count);
551 return TDM_ERROR_BAD_MODULE;
554 for (i = count - 1; i >= 0; i--) {
555 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
557 surface = tdm_layer_get_displaying_buffer(layer, &err);
558 if (err != TDM_ERROR_NONE)
561 err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++);
562 if (err != TDM_ERROR_NONE)
563 TDM_DBG("convert fail %d-layer buffer\n", i);
565 TDM_DBG("convert success %d-layer buffer\n", i);
568 func(dst_buffer, data);
570 return TDM_ERROR_NONE;
574 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
576 tdm_private_display *private_display;
577 tdm_backend_module *module_data;
578 tdm_func_output *func_output;
579 tdm_func_layer *func_layer;
580 tdm_private_output *private_output = NULL;
581 tdm_private_layer *private_layer = NULL;
582 tdm_private_pp *private_pp = NULL;
583 tdm_private_capture *private_capture = NULL;
587 TDM_DBG_RETURN_IF_FAIL(dpy != NULL);
589 private_display = dpy;
590 func_output = &private_display->func_output;
591 func_layer = &private_display->func_layer;
592 _pthread_mutex_lock(&private_display->lock);
594 /* module information */
595 module_data = private_display->module_data;
596 TDM_SNPRINTF(reply, len, "[TDM backend information]\n");
597 TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name);
598 TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor);
599 TDM_SNPRINTF(reply, len, "version: %d.%d\n\n",
600 (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version),
601 (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version));
603 /* output information */
604 TDM_SNPRINTF(reply, len, "[Output information]\n");
605 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
606 TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n");
607 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
608 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
609 TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
610 private_output->index, private_output->caps.maker,
611 private_output->caps.model, private_output->caps.name,
612 tdm_conn_str(private_output->caps.type),
613 tdm_status_str(private_output->caps.status),
614 tdm_dpms_str(private_output->current_dpms_value),
615 private_output->caps.subpixel,
616 TDM_FRONT_VALUE(private_output->caps.preferred_align),
617 TDM_FRONT_VALUE(private_output->caps.min_w),
618 TDM_FRONT_VALUE(private_output->caps.min_h),
619 TDM_FRONT_VALUE(private_output->caps.max_w),
620 TDM_FRONT_VALUE(private_output->caps.max_h),
621 private_output->caps.mmWidth, private_output->caps.mmHeight);
623 TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
625 if (private_output->caps.mode_count > 0) {
626 const tdm_output_mode *current_mode = NULL;
628 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_mode, unlock);
629 ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode);
630 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
632 TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) clk hdisp hss hse htot vdisp vss vse vtot vscan\n");
633 for (i = 0; i < private_output->caps.mode_count; i++) {
634 char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
635 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d %d %d ",
637 private_output->caps.modes[i].name,
638 private_output->caps.modes[i].vrefresh,
639 private_output->caps.modes[i].clock,
640 private_output->caps.modes[i].hdisplay,
641 private_output->caps.modes[i].hsync_start,
642 private_output->caps.modes[i].hsync_end,
643 private_output->caps.modes[i].htotal,
644 private_output->caps.modes[i].vdisplay,
645 private_output->caps.modes[i].vsync_start,
646 private_output->caps.modes[i].vsync_end,
647 private_output->caps.modes[i].vtotal,
648 private_output->caps.modes[i].vscan);
649 tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len);
650 TDM_SNPRINTF(reply, len, " ");
651 tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len);
652 TDM_SNPRINTF(reply, len, "\n");
656 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count);
657 if (private_output->caps.prop_count > 0) {
658 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
659 for (i = 0; i < private_output->caps.prop_count; i++) {
661 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock);
662 ret = func_output->output_get_property(private_output->output_backend,
663 private_output->caps.props[i].id,
665 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
666 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
667 private_output->caps.props[i].name,
668 private_output->caps.props[i].id,
673 TDM_SNPRINTF(reply, len, "\n");
675 /* layer information */
676 TDM_SNPRINTF(reply, len, "[Layer information]\n");
677 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
678 TDM_SNPRINTF(reply, len, "idx output zpos buf format size crop geometry transform\n");
679 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
680 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
681 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
682 if (!private_layer->usable) {
686 tbm_surface_info_s buf_info;
688 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock);
689 memset(&info, 0, sizeof info);
690 ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
691 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
693 format = tbm_surface_get_format(private_layer->showing_buffer);
694 tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
697 size.h = buf_info.planes[0].stride >> 2;
699 size.h = buf_info.planes[0].stride;
700 size.v = tbm_surface_get_height(private_layer->showing_buffer);
702 if (info.src_config.format)
703 format = (info.src_config.format)?:format;
705 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n",
706 private_layer->index,
707 private_output->index,
708 private_layer->caps.zpos,
709 private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
710 info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
711 info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
712 tdm_transform_str(info.transform));
714 TDM_SNPRINTF(reply, len, "%d %d %d -\n",
715 private_layer->index,
716 private_output->index,
717 private_layer->caps.zpos);
720 TDM_SNPRINTF(reply, len, "\tcaps\t: ");
721 tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len);
722 TDM_SNPRINTF(reply, len, "\n");
724 TDM_SNPRINTF(reply, len, "\tformats\t: ");
725 if (private_layer->caps.format_count > 0) {
726 const char *sep = "";
727 for (i = 0; i < private_layer->caps.format_count; i++) {
728 if (private_layer->caps.formats[i] == 0)
730 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i]));
733 TDM_SNPRINTF(reply, len, "\n");
736 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
737 if (private_layer->caps.prop_count > 0) {
738 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
739 for (i = 0; i < private_layer->caps.prop_count; i++) {
741 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_property, unlock);
742 ret = func_layer->layer_get_property(private_layer->layer_backend,
743 private_layer->caps.props[i].id,
745 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
746 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
747 private_layer->caps.props[i].name,
748 private_layer->caps.props[i].id,
754 TDM_SNPRINTF(reply, len, "\n");
756 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
757 const char *sep = "";
758 TDM_SNPRINTF(reply, len, "[PP information]\n");
759 TDM_SNPRINTF(reply, len, "caps\t: ");
760 tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len);
761 TDM_SNPRINTF(reply, len, "\n");
762 TDM_SNPRINTF(reply, len, "formats\t: ");
763 for (i = 0; i < private_display->caps_pp.format_count; i++) {
764 if (private_display->caps_pp.formats[i] == 0)
766 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i]));
769 TDM_SNPRINTF(reply, len, "\n");
770 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
771 TDM_FRONT_VALUE(private_display->caps_pp.min_w),
772 TDM_FRONT_VALUE(private_display->caps_pp.min_h),
773 TDM_FRONT_VALUE(private_display->caps_pp.max_w),
774 TDM_FRONT_VALUE(private_display->caps_pp.max_h),
775 TDM_FRONT_VALUE(private_display->caps_pp.preferred_align));
776 if (!LIST_IS_EMPTY(&private_display->pp_list)) {
777 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
778 TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n");
779 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
780 LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
781 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",
782 FOURCC_STR(private_pp->info.src_config.format),
783 private_pp->info.src_config.size.h,
784 private_pp->info.src_config.size.v,
785 private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y,
786 private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h,
787 FOURCC_STR(private_pp->info.dst_config.format),
788 private_pp->info.dst_config.size.h,
789 private_pp->info.dst_config.size.v,
790 private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y,
791 private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h,
792 tdm_transform_str(private_pp->info.transform));
796 TDM_SNPRINTF(reply, len, "[No PP capability]\n");
798 TDM_SNPRINTF(reply, len, "\n");
800 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
801 const char *sep = "";
802 TDM_SNPRINTF(reply, len, "[Capture information]\n");
803 TDM_SNPRINTF(reply, len, "caps\t: ");
804 tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len);
805 TDM_SNPRINTF(reply, len, "\n");
806 TDM_SNPRINTF(reply, len, "formats\t: ");
807 for (i = 0; i < private_display->caps_capture.format_count; i++) {
808 if (private_display->caps_capture.formats[i] == 0)
810 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i]));
813 TDM_SNPRINTF(reply, len, "\n");
814 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
815 TDM_FRONT_VALUE(private_display->caps_capture.min_w),
816 TDM_FRONT_VALUE(private_display->caps_capture.min_h),
817 TDM_FRONT_VALUE(private_display->caps_capture.max_w),
818 TDM_FRONT_VALUE(private_display->caps_capture.max_h),
819 TDM_FRONT_VALUE(private_display->caps_capture.preferred_align));
820 if (!LIST_IS_EMPTY(&private_display->capture_list)) {
821 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
822 TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n");
823 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
824 LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
825 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
826 FOURCC_STR(private_capture->info.dst_config.format),
827 private_capture->info.dst_config.size.h,
828 private_capture->info.dst_config.size.v,
829 private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y,
830 private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h,
831 tdm_transform_str(private_capture->info.transform));
835 TDM_SNPRINTF(reply, len, "[No Capture capability]\n");
837 TDM_SNPRINTF(reply, len, "\n");
840 _pthread_mutex_unlock(&private_display->lock);