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(dir != NULL);
220 TDM_RETURN_IF_FAIL(str != NULL);
222 ret = tbm_surface_get_info(buffer, &info);
223 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
225 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
227 bw = info.planes[0].stride >> 2;
230 bw = info.planes[0].stride;
233 snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%s.%s",
234 dir, FOURCC_STR(info.format), bw, info.height, str, ext);
236 tdm_helper_dump_buffer(buffer, file);
240 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
242 tbm_surface_info_s info;
246 TDM_RETURN_IF_FAIL(buffer != NULL);
247 TDM_RETURN_IF_FAIL(file != NULL);
249 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
250 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
252 len = strnlen(file, 1024);
253 if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
258 if (strncmp(file + (len - 3), ext, 3)) {
259 TDM_ERR("can't dump to '%s' file", file + (len - 3));
260 tbm_surface_unmap(buffer);
264 switch (info.format) {
265 case TBM_FORMAT_ARGB8888:
266 case TBM_FORMAT_XRGB8888:
267 _tdm_helper_dump_png(file, info.planes[0].ptr,
268 info.planes[0].stride >> 2, info.height);
270 case TBM_FORMAT_YVU420:
271 case TBM_FORMAT_YUV420:
272 _tdm_helper_dump_raw(file,
274 info.planes[0].stride * info.height,
276 info.planes[1].stride * (info.height >> 1),
278 info.planes[2].stride * (info.height >> 1));
280 case TBM_FORMAT_NV12:
281 case TBM_FORMAT_NV21:
282 _tdm_helper_dump_raw(file,
284 info.planes[0].stride * info.height,
286 info.planes[1].stride * (info.height >> 1), NULL,
289 case TBM_FORMAT_YUYV:
290 case TBM_FORMAT_UYVY:
291 _tdm_helper_dump_raw(file,
293 info.planes[0].stride * info.height, NULL, 0,
297 TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
298 tbm_surface_unmap(buffer);
302 tbm_surface_unmap(buffer);
304 TDM_INFO("dump %s", file);
308 tdm_helper_clear_buffer(tbm_surface_h buffer)
310 tbm_surface_info_s info;
313 TDM_RETURN_IF_FAIL(buffer != NULL);
315 ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
316 TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
318 switch (info.format) {
319 case TBM_FORMAT_ARGB8888:
320 case TBM_FORMAT_XRGB8888:
321 memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height);
323 case TBM_FORMAT_YVU420:
324 case TBM_FORMAT_YUV420:
325 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
326 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
327 memset((char*)info.planes[2].ptr, 0x80, info.planes[2].stride * (info.height >> 1));
329 case TBM_FORMAT_NV12:
330 case TBM_FORMAT_NV21:
331 memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height);
332 memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1));
334 case TBM_FORMAT_YUYV: {
335 int *ibuf = (int*)info.planes[0].ptr;
336 int i, size = info.planes[0].stride * info.height / 4;
338 for (i = 0 ; i < size ; i++)
339 ibuf[i] = 0x10801080;
342 case TBM_FORMAT_UYVY: {
343 int *ibuf = (int*)info.planes[0].ptr;
344 int i, size = info.planes[0].stride * info.height / 4;
346 for (i = 0 ; i < size ; i++)
347 ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */
351 TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format));
355 tbm_surface_unmap(buffer);
359 tdm_helper_get_fd(const char *env)
362 int fd, newfd, flags, ret;
364 value = (const char*)getenv(env);
368 ret = sscanf(value, "%d", &fd);
370 TDM_ERR("sscanf failed: %m");
374 flags = fcntl(fd, F_GETFD);
376 TDM_ERR("fcntl failed: %m");
382 TDM_ERR("dup failed: %m");
386 TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
388 fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
394 tdm_helper_set_fd(const char *env, int fd)
399 snprintf(buf, sizeof(buf), "%d", fd);
401 ret = setenv(env, (const char*)buf, 1);
403 TDM_ERR("setenv failed: %m");
408 TDM_INFO("%s: fd(%d)", env, fd);
412 tdm_helper_dump_start(char *dumppath, int *count)
414 if (dumppath == NULL || count == NULL) {
415 TDM_DBG("tdm_helper_dump dumppath or count is null.");
421 TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath);
425 tdm_helper_dump_stop(void)
429 TDM_DBG("tdm_helper_dump stop.");
432 static pixman_format_code_t
433 _tdm_helper_pixman_format_get(tbm_format format)
436 case TBM_FORMAT_ARGB8888:
437 return PIXMAN_a8r8g8b8;
438 case TBM_FORMAT_XRGB8888:
439 return PIXMAN_x8r8g8b8;
448 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
449 int dx, int dy, int dw, int dh, int count)
451 pixman_image_t *src_img = NULL, *dst_img = NULL;
452 pixman_format_code_t src_format, dst_format;
453 pixman_transform_t t;
454 struct pixman_f_transform ft;
456 tbm_surface_info_s src_info = {0, };
457 tbm_surface_info_s dst_info = {0, };
459 double scale_x, scale_y;
461 TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
462 TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
464 if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
465 != TBM_SURFACE_ERROR_NONE) {
466 TDM_ERR("cannot mmap srcbuf\n");
467 return TDM_ERROR_OPERATION_FAILED;
470 if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
471 != TBM_SURFACE_ERROR_NONE) {
472 TDM_ERR("cannot mmap dstbuf\n");
473 tbm_surface_unmap(srcbuf);
474 return TDM_ERROR_OPERATION_FAILED;
476 TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert);
477 TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert);
480 src_format = _tdm_helper_pixman_format_get(src_info.format);
481 TDM_GOTO_IF_FAIL(src_format > 0, cant_convert);
483 width = src_info.planes[0].stride / 4;
484 stride = src_info.planes[0].stride;
485 src_img = pixman_image_create_bits(src_format, width, src_info.height,
486 (uint32_t*)src_info.planes[0].ptr, stride);
487 TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert);
490 dst_format = _tdm_helper_pixman_format_get(dst_info.format);
491 TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert);
493 width = dst_info.planes[0].stride / 4;
494 stride = dst_info.planes[0].stride;
495 dst_img = pixman_image_create_bits(dst_format, width, dst_info.height,
496 (uint32_t*)dst_info.planes[0].ptr, stride);
497 TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert);
499 pixman_f_transform_init_identity(&ft);
501 scale_x = (double)src_info.width / dw;
502 scale_y = (double)src_info.height / dh;
504 pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
505 pixman_f_transform_translate(&ft, NULL, 0, 0);
506 pixman_transform_from_pixman_f_transform(&t, &ft);
507 pixman_image_set_transform(src_img, &t);
514 pixman_image_composite(op, src_img, NULL, dst_img,
515 0, 0, 0, 0, dx, dy, dw, dh);
518 pixman_image_unref(src_img);
520 pixman_image_unref(dst_img);
522 tbm_surface_unmap(srcbuf);
523 tbm_surface_unmap(dstbuf);
525 return TDM_ERROR_NONE;
529 pixman_image_unref(src_img);
531 tbm_surface_unmap(srcbuf);
532 tbm_surface_unmap(dstbuf);
534 return TDM_ERROR_OPERATION_FAILED;
538 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
539 int x, int y, int w, int h,
540 tdm_helper_capture_handler func, void *data)
542 tbm_surface_h surface;
544 int i, count, first = 0;
546 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
547 TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
548 TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER);
549 TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER);
550 TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
551 TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
552 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
553 TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
555 err = tdm_output_get_layer_count(output, &count);
556 if (err != TDM_ERROR_NONE) {
557 TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err);
558 return TDM_ERROR_OPERATION_FAILED;
561 TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count);
562 return TDM_ERROR_BAD_MODULE;
565 for (i = count - 1; i >= 0; i--) {
566 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
568 surface = tdm_layer_get_displaying_buffer(layer, &err);
569 if (err != TDM_ERROR_NONE)
572 err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++);
573 if (err != TDM_ERROR_NONE)
574 TDM_DBG("convert fail %d-layer buffer\n", i);
576 TDM_DBG("convert success %d-layer buffer\n", i);
579 func(dst_buffer, data);
581 return TDM_ERROR_NONE;
585 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
587 tdm_private_display *private_display;
588 tdm_backend_module *module_data;
589 tdm_func_output *func_output;
590 tdm_func_layer *func_layer;
591 tdm_private_output *private_output = NULL;
592 tdm_private_layer *private_layer = NULL;
593 tdm_private_pp *private_pp = NULL;
594 tdm_private_capture *private_capture = NULL;
598 TDM_DBG_RETURN_IF_FAIL(dpy != NULL);
600 private_display = dpy;
601 func_output = &private_display->func_output;
602 func_layer = &private_display->func_layer;
603 _pthread_mutex_lock(&private_display->lock);
605 /* module information */
606 module_data = private_display->module_data;
607 TDM_SNPRINTF(reply, len, "[TDM backend information]\n");
608 TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name);
609 TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor);
610 TDM_SNPRINTF(reply, len, "version: %d.%d\n\n",
611 (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version),
612 (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version));
614 /* output information */
615 TDM_SNPRINTF(reply, len, "[Output information]\n");
616 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
617 TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n");
618 TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
619 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
620 TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
621 private_output->index, private_output->caps.maker,
622 private_output->caps.model, private_output->caps.name,
623 tdm_conn_str(private_output->caps.type),
624 tdm_status_str(private_output->caps.status),
625 tdm_dpms_str(private_output->current_dpms_value),
626 private_output->caps.subpixel,
627 private_output->caps.preferred_align,
628 private_output->caps.min_w, private_output->caps.min_h,
629 private_output->caps.max_w, private_output->caps.max_h,
630 private_output->caps.mmWidth, private_output->caps.mmHeight);
632 TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
634 if (private_output->caps.mode_count > 0) {
635 const tdm_output_mode *current_mode = NULL;
637 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_mode, unlock);
638 ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode);
639 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
641 TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) clk hdisp hss hse htot vdisp vss vse vtot vscan\n");
642 for (i = 0; i < private_output->caps.mode_count; i++) {
643 char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
644 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d %d %d ",
646 private_output->caps.modes[i].name,
647 private_output->caps.modes[i].vrefresh,
648 private_output->caps.modes[i].clock,
649 private_output->caps.modes[i].hdisplay,
650 private_output->caps.modes[i].hsync_start,
651 private_output->caps.modes[i].hsync_end,
652 private_output->caps.modes[i].htotal,
653 private_output->caps.modes[i].vdisplay,
654 private_output->caps.modes[i].vsync_start,
655 private_output->caps.modes[i].vsync_end,
656 private_output->caps.modes[i].vtotal,
657 private_output->caps.modes[i].vscan);
658 tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len);
659 TDM_SNPRINTF(reply, len, " ");
660 tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len);
661 TDM_SNPRINTF(reply, len, "\n");
665 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count);
666 if (private_output->caps.prop_count > 0) {
667 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
668 for (i = 0; i < private_output->caps.prop_count; i++) {
670 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock);
671 ret = func_output->output_get_property(private_output->output_backend,
672 private_output->caps.props[i].id,
674 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
675 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
676 private_output->caps.props[i].name,
677 private_output->caps.props[i].id,
682 TDM_SNPRINTF(reply, len, "\n");
684 /* layer information */
685 TDM_SNPRINTF(reply, len, "[Layer information]\n");
686 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
687 TDM_SNPRINTF(reply, len, "idx output zpos buf format size crop geometry transform\n");
688 TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
689 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
690 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
691 if (!private_layer->usable) {
695 tbm_surface_info_s buf_info;
697 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock);
698 memset(&info, 0, sizeof info);
699 ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
700 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
702 format = tbm_surface_get_format(private_layer->showing_buffer);
703 tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
706 size.h = buf_info.planes[0].stride >> 2;
708 size.h = buf_info.planes[0].stride;
709 size.v = tbm_surface_get_height(private_layer->showing_buffer);
711 if (info.src_config.format)
712 format = (info.src_config.format)?:format;
714 TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n",
715 private_layer->index,
716 private_output->index,
717 private_layer->caps.zpos,
718 private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
719 info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
720 info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
721 tdm_transform_str(info.transform));
723 TDM_SNPRINTF(reply, len, "%d %d %d -\n",
724 private_layer->index,
725 private_output->index,
726 private_layer->caps.zpos);
729 TDM_SNPRINTF(reply, len, "\tcaps\t: ");
730 tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len);
731 TDM_SNPRINTF(reply, len, "\n");
733 TDM_SNPRINTF(reply, len, "\tformats\t: ");
734 if (private_layer->caps.format_count > 0) {
735 const char *sep = "";
736 for (i = 0; i < private_layer->caps.format_count; i++) {
737 if (private_layer->caps.formats[i] == 0)
739 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i]));
742 TDM_SNPRINTF(reply, len, "\n");
745 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
746 if (private_layer->caps.prop_count > 0) {
747 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
748 for (i = 0; i < private_layer->caps.prop_count; i++) {
750 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_property, unlock);
751 ret = func_layer->layer_get_property(private_layer->layer_backend,
752 private_layer->caps.props[i].id,
754 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
755 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
756 private_layer->caps.props[i].name,
757 private_layer->caps.props[i].id,
763 TDM_SNPRINTF(reply, len, "\n");
765 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
766 const char *sep = "";
767 TDM_SNPRINTF(reply, len, "[PP information]\n");
768 TDM_SNPRINTF(reply, len, "caps\t: ");
769 tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len);
770 TDM_SNPRINTF(reply, len, "\n");
771 TDM_SNPRINTF(reply, len, "formats\t: ");
772 for (i = 0; i < private_display->caps_pp.format_count; i++) {
773 if (private_display->caps_pp.formats[i] == 0)
775 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i]));
778 TDM_SNPRINTF(reply, len, "\n");
779 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
780 private_display->caps_pp.min_w, private_display->caps_pp.min_h,
781 private_display->caps_pp.max_w, private_display->caps_pp.max_h,
782 private_display->caps_pp.preferred_align);
783 if (!LIST_IS_EMPTY(&private_display->pp_list)) {
784 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
785 TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n");
786 TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
787 LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
788 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",
789 FOURCC_STR(private_pp->info.src_config.format),
790 private_pp->info.src_config.size.h,
791 private_pp->info.src_config.size.v,
792 private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y,
793 private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h,
794 FOURCC_STR(private_pp->info.dst_config.format),
795 private_pp->info.dst_config.size.h,
796 private_pp->info.dst_config.size.v,
797 private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y,
798 private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h,
799 tdm_transform_str(private_pp->info.transform));
803 TDM_SNPRINTF(reply, len, "[No PP capability]\n");
805 TDM_SNPRINTF(reply, len, "\n");
807 if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
808 const char *sep = "";
809 TDM_SNPRINTF(reply, len, "[Capture information]\n");
810 TDM_SNPRINTF(reply, len, "caps\t: ");
811 tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len);
812 TDM_SNPRINTF(reply, len, "\n");
813 TDM_SNPRINTF(reply, len, "formats\t: ");
814 for (i = 0; i < private_display->caps_capture.format_count; i++) {
815 if (private_display->caps_capture.formats[i] == 0)
817 TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i]));
820 TDM_SNPRINTF(reply, len, "\n");
821 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
822 private_display->caps_capture.min_w, private_display->caps_capture.min_h,
823 private_display->caps_capture.max_w, private_display->caps_capture.max_h,
824 private_display->caps_capture.preferred_align);
825 if (!LIST_IS_EMPTY(&private_display->capture_list)) {
826 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
827 TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n");
828 TDM_SNPRINTF(reply, len, "-----------------------------------\n");
829 LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
830 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
831 FOURCC_STR(private_capture->info.dst_config.format),
832 private_capture->info.dst_config.size.h,
833 private_capture->info.dst_config.size.v,
834 private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y,
835 private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h,
836 tdm_transform_str(private_capture->info.transform));
840 TDM_SNPRINTF(reply, len, "[No Capture capability]\n");
842 TDM_SNPRINTF(reply, len, "\n");
845 _pthread_mutex_unlock(&private_display->lock);