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_in_millis(void)
64 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
65 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
71 tdm_helper_get_time_in_micros(void)
75 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
76 return (tp.tv_sec * 1000000) + (tp.tv_nsec / 1000L);
82 _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
83 int size2, void *data3, int size3)
86 FILE *fp = fopen(file, "w+");
87 TDM_RETURN_IF_FAIL(fp != NULL);
89 blocks = (unsigned int *)data1;
90 fwrite(blocks, 1, size1, fp);
93 blocks = (unsigned int *)data2;
94 fwrite(blocks, 1, size2, fp);
98 blocks = (unsigned int *)data3;
99 fwrite(blocks, 1, size3, fp);
106 _tdm_helper_dump_png(const char *file, const void *data, int width,
109 FILE *fp = fopen(file, "wb");
110 TDM_RETURN_IF_FAIL(fp != NULL);
112 png_structp pPngStruct =
113 png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
119 png_infop pPngInfo = png_create_info_struct(pPngStruct);
121 png_destroy_write_struct(&pPngStruct, NULL);
126 png_init_io(pPngStruct, fp);
127 png_set_IHDR(pPngStruct,
134 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
136 png_set_bgr(pPngStruct);
137 png_write_info(pPngStruct, pPngInfo);
139 const int pixel_size = 4; // RGBA
140 png_bytep *row_pointers =
141 png_malloc(pPngStruct, height * sizeof(png_byte *));
143 unsigned int *blocks = (unsigned int *)data;
147 for (; y < height; ++y) {
149 png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size);
150 row_pointers[y] = (png_bytep)row;
151 for (x = 0; x < width; ++x) {
152 unsigned int curBlock = blocks[y * width + x];
153 row[x * pixel_size] = (curBlock & 0xFF);
154 row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF;
155 row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF;
156 row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF;
160 png_write_image(pPngStruct, row_pointers);
161 png_write_end(pPngStruct, pPngInfo);
163 for (y = 0; y < height; y++)
164 png_free(pPngStruct, row_pointers[y]);
165 png_free(pPngStruct, row_pointers);
167 png_destroy_write_struct(&pPngStruct, &pPngInfo);
173 tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
175 char *fullpath = NULL;
177 struct tm *t, *buf = NULL;
181 buf = calloc(1, sizeof (struct tm));
182 TDM_GOTO_IF_FAIL(buf != NULL, failed_make);
184 fullpath = calloc(1, TDM_PATH_LEN * sizeof(char));
185 TDM_GOTO_IF_FAIL(fullpath != NULL, failed_make);
187 t = localtime_r(&timer, buf);
188 TDM_GOTO_IF_FAIL(t != NULL, failed_make);
190 snprintf(fullpath, TDM_PATH_LEN, "%s/dump_%04d%02d%02d.%02d%02d%02d", path,
191 t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
193 if ((mkdir(fullpath, 0755)) < 0) {
194 TDM_ERR("mkdir '%s' fail\n", fullpath);
195 TDM_SNPRINTF(reply, len, "mkdir '%s' fail\n", fullpath);
211 tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
213 tbm_surface_info_s info;
215 char file[TDM_PATH_LEN];
218 TDM_RETURN_IF_FAIL(buffer != NULL);
219 TDM_RETURN_IF_FAIL(str != NULL);
222 dir = tdm_helper_dump_make_directory(TDM_DUMP_DIR, NULL, NULL);
223 TDM_RETURN_IF_FAIL(dir != NULL);
226 ret = tbm_surface_get_info(buffer, &info);
227 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
229 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
231 bw = info.planes[0].stride >> 2;
234 bw = info.planes[0].stride;
237 snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%s.%s",
238 dir, FOURCC_STR(info.format), bw, info.height, str, ext);
240 tdm_helper_dump_buffer(buffer, file);
244 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
246 tbm_surface_info_s info;
250 TDM_RETURN_IF_FAIL(buffer != NULL);
251 TDM_RETURN_IF_FAIL(file != NULL);
253 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
254 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
256 len = strnlen(file, 1024);
257 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
262 if (strncmp(file + (len - 3), ext, 3)) {
263 TDM_ERR("can't dump to '%s' file", file + (len - 3));
264 tbm_surface_unmap(buffer);
268 switch (info.format) {
269 case TBM_FORMAT_ARGB8888:
270 case TBM_FORMAT_XRGB8888:
271 _tdm_helper_dump_png(file, info.planes[0].ptr,
272 info.planes[0].stride >> 2, info.height);
274 case TBM_FORMAT_YVU420:
275 case TBM_FORMAT_YUV420:
276 _tdm_helper_dump_raw(file,
278 info.planes[0].stride * info.height,
280 info.planes[1].stride * (info.height >> 1),
282 info.planes[2].stride * (info.height >> 1));
284 case TBM_FORMAT_NV12:
285 case TBM_FORMAT_NV21:
286 _tdm_helper_dump_raw(file,
288 info.planes[0].stride * info.height,
290 info.planes[1].stride * (info.height >> 1), NULL,
293 case TBM_FORMAT_YUYV:
294 case TBM_FORMAT_UYVY:
295 _tdm_helper_dump_raw(file,
297 info.planes[0].stride * info.height, NULL, 0,
301 TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
302 tbm_surface_unmap(buffer);
306 tbm_surface_unmap(buffer);
308 TDM_INFO("dump %s", file);
312 tdm_helper_clear_buffer(tbm_surface_h buffer)
314 tbm_surface_info_s info;
317 TDM_RETURN_IF_FAIL(buffer != NULL);
319 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
320 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
322 switch (info.format) {
323 case TBM_FORMAT_ARGB8888:
324 case TBM_FORMAT_XRGB8888:
325 memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
327 case TBM_FORMAT_YVU420:
328 case TBM_FORMAT_YUV420:
329 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
330 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
331 memset((char*)info.planes[2].ptr, 0x80, info.planes[2].stride * (info.height >> 1));
333 case TBM_FORMAT_NV12:
334 case TBM_FORMAT_NV21:
335 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
336 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
338 case TBM_FORMAT_YUYV: {
339 int *ibuf = (int*)info.planes[0].ptr;
340 int i, size = info.planes[0].stride * info.height / 4;
342 for (i = 0 ; i < size ; i++)
343 ibuf[i] = 0x10801080;
346 case TBM_FORMAT_UYVY: {
347 int *ibuf = (int*)info.planes[0].ptr;
348 int i, size = info.planes[0].stride * info.height / 4;
350 for (i = 0 ; i < size ; i++)
351 ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */
355 TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format));
359 tbm_surface_unmap(buffer);
363 tdm_helper_get_fd(const char *env)
366 int fd, newfd, flags, ret;
368 value = (const char*)getenv(env);
372 ret = sscanf(value, "%d", &fd);
374 TDM_ERR("sscanf failed: %m");
378 flags = fcntl(fd, F_GETFD);
380 TDM_ERR("fcntl failed: %m");
386 TDM_ERR("dup failed: %m");
390 TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
392 fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
398 tdm_helper_set_fd(const char *env, int fd)
403 snprintf(buf, sizeof(buf), "%d", fd);
405 ret = setenv(env, (const char*)buf, 1);
407 TDM_ERR("setenv failed: %m");
412 TDM_INFO("%s: fd(%d)", env, fd);
416 tdm_helper_dump_start(char *dumppath, int *count)
418 if (dumppath == NULL || count == NULL) {
419 TDM_DBG("tdm_helper_dump dumppath or count is null.");
425 TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath);
429 tdm_helper_dump_stop(void)
433 TDM_DBG("tdm_helper_dump stop.");
436 static pixman_format_code_t
437 _tdm_helper_pixman_format_get(tbm_format format)
440 case TBM_FORMAT_ARGB8888:
441 return PIXMAN_a8r8g8b8;
442 case TBM_FORMAT_XRGB8888:
443 return PIXMAN_x8r8g8b8;
452 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
453 int dx, int dy, int dw, int dh, int count)
455 pixman_image_t *src_img = NULL, *dst_img = NULL;
456 pixman_format_code_t src_format, dst_format;
457 pixman_transform_t t;
458 struct pixman_f_transform ft;
460 tbm_surface_info_s src_info = {0, };
461 tbm_surface_info_s dst_info = {0, };
463 double scale_x, scale_y;
465 TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
466 TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
468 if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
469 != TBM_SURFACE_ERROR_NONE) {
470 TDM_ERR("cannot mmap srcbuf\n");
471 return TDM_ERROR_OPERATION_FAILED;
474 if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
475 != TBM_SURFACE_ERROR_NONE) {
476 TDM_ERR("cannot mmap dstbuf\n");
477 tbm_surface_unmap(srcbuf);
478 return TDM_ERROR_OPERATION_FAILED;
480 TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert);
481 TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert);
484 src_format = _tdm_helper_pixman_format_get(src_info.format);
485 TDM_GOTO_IF_FAIL(src_format > 0, cant_convert);
487 width = src_info.planes[0].stride / 4;
488 stride = src_info.planes[0].stride;
489 src_img = pixman_image_create_bits(src_format, width, src_info.height,
490 (uint32_t*)src_info.planes[0].ptr, stride);
491 TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert);
494 dst_format = _tdm_helper_pixman_format_get(dst_info.format);
495 TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert);
497 width = dst_info.planes[0].stride / 4;
498 stride = dst_info.planes[0].stride;
499 dst_img = pixman_image_create_bits(dst_format, width, dst_info.height,
500 (uint32_t*)dst_info.planes[0].ptr, stride);
501 TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert);
503 pixman_f_transform_init_identity(&ft);
505 scale_x = (double)src_info.width / dw;
506 scale_y = (double)src_info.height / dh;
508 pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
509 pixman_f_transform_translate(&ft, NULL, 0, 0);
510 pixman_transform_from_pixman_f_transform(&t, &ft);
511 pixman_image_set_transform(src_img, &t);
518 pixman_image_composite(op, src_img, NULL, dst_img,
519 0, 0, 0, 0, dx, dy, dw, dh);
522 pixman_image_unref(src_img);
524 pixman_image_unref(dst_img);
526 tbm_surface_unmap(srcbuf);
527 tbm_surface_unmap(dstbuf);
529 return TDM_ERROR_NONE;
533 pixman_image_unref(src_img);
535 tbm_surface_unmap(srcbuf);
536 tbm_surface_unmap(dstbuf);
538 return TDM_ERROR_OPERATION_FAILED;
542 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
543 int x, int y, int w, int h,
544 tdm_helper_capture_handler func, void *data)
546 tbm_surface_h surface;
548 int i, count, first = 0;
550 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
551 TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
552 TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER);
553 TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER);
554 TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
555 TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
556 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
557 TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
559 err = tdm_output_get_layer_count(output, &count);
560 if (err != TDM_ERROR_NONE) {
561 TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
562 return TDM_ERROR_OPERATION_FAILED;
565 TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count);
566 return TDM_ERROR_BAD_MODULE;
569 for (i = count - 1; i >= 0; i--) {
570 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
572 surface = tdm_layer_get_displaying_buffer(layer, &err);
573 if (err != TDM_ERROR_NONE)
576 err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++);
577 if (err != TDM_ERROR_NONE)
578 TDM_DBG("convert fail %d-layer buffer\n", i);
580 TDM_DBG("convert success %d-layer buffer\n", i);
583 func(dst_buffer, data);
585 return TDM_ERROR_NONE;
589 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
591 tdm_private_display *private_display;
592 tdm_backend_module *module_data;
593 tdm_func_output *func_output;
594 tdm_func_layer *func_layer;
595 tdm_private_output *private_output = NULL;
596 tdm_private_layer *private_layer = NULL;
597 tdm_private_pp *private_pp = NULL;
598 tdm_private_capture *private_capture = NULL;
602 TDM_DBG_RETURN_IF_FAIL(dpy != NULL);
604 private_display = dpy;
605 func_output = &private_display->func_output;
606 func_layer = &private_display->func_layer;
607 _pthread_mutex_lock(&private_display->lock);
609 /* module information */
610 module_data = private_display->module_data;
611 TDM_SNPRINTF(reply, len, "[TDM backend information]\n");
612 TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name);
613 TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor);
614 TDM_SNPRINTF(reply, len, "version: %d.%d\n\n",
615 (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version),
616 (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version));
618 /* output information */
619 TDM_SNPRINTF(reply, len, "[Output information]\n");
620 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
621 TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n");
622 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
623 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
624 TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
625 private_output->index, private_output->caps.maker,
626 private_output->caps.model, private_output->caps.name,
627 tdm_conn_str(private_output->caps.type),
628 tdm_status_str(private_output->caps.status),
629 tdm_dpms_str(private_output->current_dpms_value),
630 private_output->caps.subpixel,
631 private_output->caps.preferred_align,
632 private_output->caps.min_w, private_output->caps.min_h,
633 private_output->caps.max_w, private_output->caps.max_h,
634 private_output->caps.mmWidth, private_output->caps.mmHeight);
636 TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
638 if (private_output->caps.mode_count > 0) {
639 const tdm_output_mode *current_mode = NULL;
641 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_mode, unlock);
642 ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode);
643 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
645 TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot\n");
646 for (i = 0; i < private_output->caps.mode_count; i++) {
647 char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
648 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d ",
650 private_output->caps.modes[i].name,
651 private_output->caps.modes[i].vrefresh,
652 private_output->caps.modes[i].hdisplay,
653 private_output->caps.modes[i].hsync_start,
654 private_output->caps.modes[i].hsync_end,
655 private_output->caps.modes[i].htotal,
656 private_output->caps.modes[i].vdisplay,
657 private_output->caps.modes[i].vsync_start,
658 private_output->caps.modes[i].vsync_end,
659 private_output->caps.modes[i].vtotal);
660 tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len);
661 TDM_SNPRINTF(reply, len, " ");
662 tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len);
663 TDM_SNPRINTF(reply, len, "\n");
667 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count);
668 if (private_output->caps.prop_count > 0) {
669 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
670 for (i = 0; i < private_output->caps.prop_count; i++) {
672 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock);
673 ret = func_output->output_get_property(private_output->output_backend,
674 private_output->caps.props[i].id,
676 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
677 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
678 private_output->caps.props[i].name,
679 private_output->caps.props[i].id,
684 TDM_SNPRINTF(reply, len, "\n");
686 /* layer information */
687 TDM_SNPRINTF(reply, len, "[Layer information]\n");
688 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
689 TDM_SNPRINTF(reply, len, "idx output zpos buf format size crop geometry transform\n");
690 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
691 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
692 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
693 if (!private_layer->usable) {
697 tbm_surface_info_s buf_info;
699 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock);
700 memset(&info, 0, sizeof info);
701 ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
702 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
704 format = tbm_surface_get_format(private_layer->showing_buffer);
705 tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
708 size.h = buf_info.planes[0].stride >> 2;
710 size.h = buf_info.planes[0].stride;
711 size.v = tbm_surface_get_height(private_layer->showing_buffer);
713 if (info.src_config.format)
714 format = (info.src_config.format)?:format;
716 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n",
717 private_layer->index,
718 private_output->index,
719 private_layer->caps.zpos,
720 private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
721 info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
722 info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
723 tdm_transform_str(info.transform));
725 TDM_SNPRINTF(reply, len, "%d %d %d -\n",
726 private_layer->index,
727 private_output->index,
728 private_layer->caps.zpos);
731 TDM_SNPRINTF(reply, len, "\tcaps\t: ");
732 tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len);
733 TDM_SNPRINTF(reply, len, "\n");
735 TDM_SNPRINTF(reply, len, "\tformats\t: ");
736 if (private_layer->caps.format_count > 0) {
737 const char *sep = "";
738 for (i = 0; i < private_layer->caps.format_count; i++) {
739 if (private_layer->caps.formats[i] == 0)
741 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i]));
744 TDM_SNPRINTF(reply, len, "\n");
747 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
748 if (private_layer->caps.prop_count > 0) {
749 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
750 for (i = 0; i < private_layer->caps.prop_count; i++) {
752 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_property, unlock);
753 ret = func_layer->layer_get_property(private_layer->layer_backend,
754 private_layer->caps.props[i].id,
756 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
757 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
758 private_layer->caps.props[i].name,
759 private_layer->caps.props[i].id,
765 TDM_SNPRINTF(reply, len, "\n");
767 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
768 const char *sep = "";
769 TDM_SNPRINTF(reply, len, "[PP information]\n");
770 TDM_SNPRINTF(reply, len, "caps\t: ");
771 tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len);
772 TDM_SNPRINTF(reply, len, "\n");
773 TDM_SNPRINTF(reply, len, "formats\t: ");
774 for (i = 0; i < private_display->caps_pp.format_count; i++) {
775 if (private_display->caps_pp.formats[i] == 0)
777 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i]));
780 TDM_SNPRINTF(reply, len, "\n");
781 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
782 private_display->caps_pp.min_w, private_display->caps_pp.min_h,
783 private_display->caps_pp.max_w, private_display->caps_pp.max_h,
784 private_display->caps_pp.preferred_align);
785 if (!LIST_IS_EMPTY(&private_display->pp_list)) {
786 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
787 TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n");
788 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
789 LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
790 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",
791 FOURCC_STR(private_pp->info.src_config.format),
792 private_pp->info.src_config.size.h,
793 private_pp->info.src_config.size.v,
794 private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y,
795 private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h,
796 FOURCC_STR(private_pp->info.dst_config.format),
797 private_pp->info.dst_config.size.h,
798 private_pp->info.dst_config.size.v,
799 private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y,
800 private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h,
801 tdm_transform_str(private_pp->info.transform));
805 TDM_SNPRINTF(reply, len, "[No PP capability]\n");
807 TDM_SNPRINTF(reply, len, "\n");
809 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
810 const char *sep = "";
811 TDM_SNPRINTF(reply, len, "[Capture information]\n");
812 TDM_SNPRINTF(reply, len, "caps\t: ");
813 tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len);
814 TDM_SNPRINTF(reply, len, "\n");
815 TDM_SNPRINTF(reply, len, "formats\t: ");
816 for (i = 0; i < private_display->caps_capture.format_count; i++) {
817 if (private_display->caps_capture.formats[i] == 0)
819 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i]));
822 TDM_SNPRINTF(reply, len, "\n");
823 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
824 private_display->caps_capture.min_w, private_display->caps_capture.min_h,
825 private_display->caps_capture.max_w, private_display->caps_capture.max_h,
826 private_display->caps_capture.preferred_align);
827 if (!LIST_IS_EMPTY(&private_display->capture_list)) {
828 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
829 TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n");
830 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
831 LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
832 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
833 FOURCC_STR(private_capture->info.dst_config.format),
834 private_capture->info.dst_config.size.h,
835 private_capture->info.dst_config.size.v,
836 private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y,
837 private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h,
838 tdm_transform_str(private_capture->info.transform));
842 TDM_SNPRINTF(reply, len, "[No Capture capability]\n");
844 TDM_SNPRINTF(reply, len, "\n");
847 _pthread_mutex_unlock(&private_display->lock);