remove unused helper function
[platform/core/uifw/libtdm.git] / src / tdm_helper.c
1 /**************************************************************************
2  *
3  * libtdm
4  *
5  * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6  *
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>
13  *
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:
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  *
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.
33  *
34 **************************************************************************/
35
36 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40 #include <png.h>
41 #include <string.h>
42 #include <tbm_surface.h>
43 #include <tbm_surface_internal.h>
44 #include <string.h>
45 #include <time.h>
46 #include <pixman.h>
47
48 #include "tdm.h"
49 #include "tdm_private.h"
50 #include "tdm_helper.h"
51
52 #define PNG_DEPTH 8
53
54 static const char *file_exts[2] = {"png", "yuv"};
55
56 int tdm_dump_enable;
57 char *tdm_debug_dump_dir;
58
59 EXTERN double
60 tdm_helper_get_time(void)
61 {
62         struct timespec tp;
63
64         if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
65                 return (double)tp.tv_sec + ((double)tp.tv_nsec) / 1000000000.0;
66
67         return 0;
68 }
69
70 static void
71 _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
72                                          int size2, void *data3, int size3)
73 {
74         unsigned int *blocks;
75         FILE *fp = fopen(file, "w+");
76         TDM_RETURN_IF_FAIL(fp != NULL);
77
78         blocks = (unsigned int *)data1;
79         fwrite(blocks, 1, size1, fp);
80
81         if (size2 > 0) {
82                 blocks = (unsigned int *)data2;
83                 fwrite(blocks, 1, size2, fp);
84         }
85
86         if (size3 > 0) {
87                 blocks = (unsigned int *)data3;
88                 fwrite(blocks, 1, size3, fp);
89         }
90
91         fclose(fp);
92 }
93
94 static void
95 _tdm_helper_dump_png(const char *file, const void *data, int width,
96                                          int height)
97 {
98         FILE *fp = fopen(file, "wb");
99         TDM_RETURN_IF_FAIL(fp != NULL);
100
101         png_structp pPngStruct =
102                 png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
103         if (!pPngStruct) {
104                 fclose(fp);
105                 return;
106         }
107
108         png_infop pPngInfo = png_create_info_struct(pPngStruct);
109         if (!pPngInfo) {
110                 png_destroy_write_struct(&pPngStruct, NULL);
111                 fclose(fp);
112                 return;
113         }
114
115         png_init_io(pPngStruct, fp);
116         png_set_IHDR(pPngStruct,
117                                  pPngInfo,
118                                  width,
119                                  height,
120                                  PNG_DEPTH,
121                                  PNG_COLOR_TYPE_RGBA,
122                                  PNG_INTERLACE_NONE,
123                                  PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
124
125         png_set_bgr(pPngStruct);
126         png_write_info(pPngStruct, pPngInfo);
127
128         const int pixel_size = 4;       // RGBA
129         png_bytep *row_pointers =
130                 png_malloc(pPngStruct, height * sizeof(png_byte *));
131
132         unsigned int *blocks = (unsigned int *)data;
133         int y = 0;
134         int x = 0;
135
136         for (; y < height; ++y) {
137                 png_bytep row =
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;
146                 }
147         }
148
149         png_write_image(pPngStruct, row_pointers);
150         png_write_end(pPngStruct, pPngInfo);
151
152         for (y = 0; y < height; y++)
153                 png_free(pPngStruct, row_pointers[y]);
154         png_free(pPngStruct, row_pointers);
155
156         png_destroy_write_struct(&pPngStruct, &pPngInfo);
157
158         fclose(fp);
159 }
160
161 INTERN char *
162 tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
163 {
164         char *fullpath = NULL;
165         time_t timer;
166         struct tm *t, *buf = NULL;
167
168         timer = time(NULL);
169
170         buf = calloc(1, sizeof(struct tm));
171         TDM_GOTO_IF_FAIL(buf != NULL, failed_make);
172
173         fullpath = calloc(1, TDM_PATH_LEN * sizeof(char));
174         TDM_GOTO_IF_FAIL(fullpath != NULL, failed_make);
175
176         t = localtime_r(&timer, buf);
177         TDM_GOTO_IF_FAIL(t != NULL, failed_make);
178
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);
181
182         if ((mkdir(fullpath, 0755)) < 0) {
183                 TDM_ERR("mkdir '%s' fail\n", fullpath);
184                 TDM_SNPRINTF(reply, len, "mkdir '%s' fail\n", fullpath);
185                 goto failed_make;
186         }
187
188         free(buf);
189
190         return fullpath;
191 failed_make:
192         if (fullpath)
193                 free(fullpath);
194         if (buf)
195                 free(buf);
196         return NULL;
197 }
198
199 INTERN void
200 tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
201 {
202         tbm_surface_info_s info;
203         const char *ext;
204         char file[TDM_PATH_LEN];
205         int ret, bw;
206
207         TDM_RETURN_IF_FAIL(buffer != NULL);
208         TDM_RETURN_IF_FAIL(dir != NULL);
209         TDM_RETURN_IF_FAIL(str != NULL);
210
211         ret = tbm_surface_get_info(buffer, &info);
212         TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
213
214         if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) {
215                 ext = file_exts[0];
216                 bw = info.planes[0].stride >> 2;
217         } else {
218                 ext = file_exts[1];
219                 bw = info.planes[0].stride;
220         }
221
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);
224
225         tdm_helper_dump_buffer(buffer, file);
226 }
227
228 EXTERN void
229 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
230 {
231         tbm_surface_info_s info;
232         int len, ret;
233         const char *ext;
234
235         TDM_RETURN_IF_FAIL(buffer != NULL);
236         TDM_RETURN_IF_FAIL(file != NULL);
237
238         ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
239         TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
240
241         len = strnlen(file, 1024);
242         if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
243                 ext = file_exts[0];
244         else
245                 ext = file_exts[1];
246
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);
250                 return;
251         }
252
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);
258                 break;
259         case TBM_FORMAT_YVU420:
260         case TBM_FORMAT_YUV420:
261                 _tdm_helper_dump_raw(file,
262                                                          info.planes[0].ptr,
263                                                          info.planes[0].stride * info.height,
264                                                          info.planes[1].ptr,
265                                                          info.planes[1].stride * (info.height >> 1),
266                                                          info.planes[2].ptr,
267                                                          info.planes[2].stride * (info.height >> 1));
268                 break;
269         case TBM_FORMAT_NV12:
270         case TBM_FORMAT_NV21:
271                 _tdm_helper_dump_raw(file,
272                                                          info.planes[0].ptr,
273                                                          info.planes[0].stride * info.height,
274                                                          info.planes[1].ptr,
275                                                          info.planes[1].stride * (info.height >> 1), NULL,
276                                                          0);
277                 break;
278         case TBM_FORMAT_YUYV:
279         case TBM_FORMAT_UYVY:
280                 _tdm_helper_dump_raw(file,
281                                                          info.planes[0].ptr,
282                                                          info.planes[0].stride * info.height, NULL, 0,
283                                                          NULL, 0);
284                 break;
285         default:
286                 TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
287                 tbm_surface_unmap(buffer);
288                 return;
289         }
290
291         tbm_surface_unmap(buffer);
292
293         TDM_INFO("dump %s", file);
294 }
295
296 EXTERN void
297 tdm_helper_clear_buffer(tbm_surface_h buffer)
298 {
299         tbm_surface_info_s info;
300         int ret;
301
302         TDM_RETURN_IF_FAIL(buffer != NULL);
303
304         ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
305         TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
306
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);
311                 break;
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));
317                 break;
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));
322                 break;
323         case TBM_FORMAT_YUYV: {
324                 int *ibuf = (int*)info.planes[0].ptr;
325                 int i, size = info.planes[0].stride * info.height / 4;
326
327                 for (i = 0 ; i < size ; i++)
328                         ibuf[i] = 0x10801080;
329         }
330         break;
331         case TBM_FORMAT_UYVY: {
332                 int *ibuf = (int*)info.planes[0].ptr;
333                 int i, size = info.planes[0].stride * info.height / 4;
334
335                 for (i = 0 ; i < size ; i++)
336                         ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */
337         }
338         break;
339         default:
340                 TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format));
341                 break;
342         }
343
344         tbm_surface_unmap(buffer);
345 }
346
347 EXTERN int
348 tdm_helper_get_fd(const char *env)
349 {
350         const char *value;
351         int fd, newfd, flags, ret;
352
353         value = (const char*)getenv(env);
354         if (!value)
355                 return -1;
356
357         ret = sscanf(value, "%d", &fd);
358         if (ret < 0) {
359                 TDM_ERR("sscanf failed: %m");
360                 return -1;
361         }
362
363         flags = fcntl(fd, F_GETFD);
364         if (flags == -1) {
365                 TDM_ERR("fcntl failed: %m");
366                 return -1;
367         }
368
369         newfd = dup(fd);
370         if (newfd < 0) {
371                 TDM_ERR("dup failed: %m");
372                 return -1;
373         }
374
375         TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
376
377         fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
378
379         return newfd;
380 }
381
382 EXTERN void
383 tdm_helper_set_fd(const char *env, int fd)
384 {
385         char buf[32];
386         int ret;
387
388         snprintf(buf, sizeof(buf), "%d", fd);
389
390         ret = setenv(env, (const char*)buf, 1);
391         if (ret) {
392                 TDM_ERR("setenv failed: %m");
393                 return;
394         }
395
396         if (fd >= 0)
397                 TDM_INFO("%s: fd(%d)", env, fd);
398 }
399
400 EXTERN void
401 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
402 {
403         tdm_private_display *private_display;
404         tdm_backend_module *module_data;
405         tdm_func_output *func_output;
406         tdm_func_layer *func_layer;
407         tdm_private_output *private_output = NULL;
408         tdm_private_layer *private_layer = NULL;
409         tdm_private_pp *private_pp = NULL;
410         tdm_private_capture *private_capture = NULL;
411         tdm_error ret;
412         int i;
413
414         TDM_DBG_RETURN_IF_FAIL(dpy != NULL);
415
416         private_display = dpy;
417         func_output = &private_display->func_output;
418         func_layer = &private_display->func_layer;
419         _pthread_mutex_lock(&private_display->lock);
420
421         /* module information */
422         module_data = private_display->module_data;
423         TDM_SNPRINTF(reply, len, "[TDM backend information]\n");
424         TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name);
425         TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor);
426         TDM_SNPRINTF(reply, len, "version: %d.%d\n\n",
427                                  (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version),
428                                  (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version));
429
430         /* output information */
431         TDM_SNPRINTF(reply, len, "[Output information]\n");
432         TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
433         TDM_SNPRINTF(reply, len, "idx   maker   model   name   type   status   dpms   subpixel   align_w   min   max   phy(mm)\n");
434         TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
435         LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
436                 TDM_SNPRINTF(reply, len, "%d   %s   %s   %s   %s   %s   %s   %d   %d   %dx%d   %dx%d   %dx%d\n",
437                                          private_output->index, private_output->caps.maker,
438                                          private_output->caps.model, private_output->caps.name,
439                                          tdm_conn_str(private_output->caps.type),
440                                          tdm_status_str(private_output->caps.status),
441                                          tdm_dpms_str(private_output->current_dpms_value),
442                                          private_output->caps.subpixel,
443                                          TDM_FRONT_VALUE(private_output->caps.preferred_align),
444                                          TDM_FRONT_VALUE(private_output->caps.min_w),
445                                          TDM_FRONT_VALUE(private_output->caps.min_h),
446                                          TDM_FRONT_VALUE(private_output->caps.max_w),
447                                          TDM_FRONT_VALUE(private_output->caps.max_h),
448                                          private_output->caps.mmWidth, private_output->caps.mmHeight);
449
450                 TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
451
452                 if (private_output->caps.mode_count > 0) {
453                         const tdm_output_mode *current_mode = NULL;
454
455                         TDM_DBG_GOTO_IF_FAIL(func_output->output_get_mode, unlock);
456                         ret = func_output->output_get_mode(private_output->output_backend, &current_mode);
457                         TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
458
459                         TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) clk hdisp hss hse htot vdisp vss vse vtot vscan\n");
460                         for (i = 0; i < private_output->caps.mode_count; i++) {
461                                 char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
462                                 TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d %d %d ",
463                                                          current,
464                                                          private_output->caps.modes[i].name,
465                                                          private_output->caps.modes[i].vrefresh,
466                                                          private_output->caps.modes[i].clock,
467                                                          private_output->caps.modes[i].hdisplay,
468                                                          private_output->caps.modes[i].hsync_start,
469                                                          private_output->caps.modes[i].hsync_end,
470                                                          private_output->caps.modes[i].htotal,
471                                                          private_output->caps.modes[i].vdisplay,
472                                                          private_output->caps.modes[i].vsync_start,
473                                                          private_output->caps.modes[i].vsync_end,
474                                                          private_output->caps.modes[i].vtotal,
475                                                          private_output->caps.modes[i].vscan);
476                                 tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len);
477                                 TDM_SNPRINTF(reply, len, " ");
478                                 tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len);
479                                 TDM_SNPRINTF(reply, len, "\n");
480                         }
481                 }
482
483                 TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count);
484                 if (private_output->caps.prop_count > 0) {
485                         TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
486                         for (i = 0; i < private_output->caps.prop_count; i++) {
487                                 tdm_value value;
488                                 TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock);
489                                 ret = func_output->output_get_property(private_output->output_backend,
490                                                                                                            private_output->caps.props[i].id,
491                                                                                                            &value);
492                                 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
493                                 TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
494                                                          private_output->caps.props[i].name,
495                                                          private_output->caps.props[i].id,
496                                                          value.u32);
497                         }
498                 }
499         }
500         TDM_SNPRINTF(reply, len, "\n");
501
502         /* layer information */
503         TDM_SNPRINTF(reply, len, "[Layer information]\n");
504         TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
505         TDM_SNPRINTF(reply, len, "idx   output   zpos   buf   format   size   crop   geometry   transform\n");
506         TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n");
507         LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
508                 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
509                         if (!private_layer->usable) {
510                                 tdm_info_layer info;
511                                 unsigned int format;
512                                 tdm_size size;
513                                 tbm_surface_info_s buf_info;
514
515                                 TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock);
516                                 memset(&info, 0, sizeof info);
517                                 ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
518                                 TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
519
520                                 format = tbm_surface_get_format(private_layer->showing_buffer);
521                                 tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
522
523                                 if (IS_RGB(format))
524                                         size.h = buf_info.planes[0].stride >> 2;
525                                 else
526                                         size.h = buf_info.planes[0].stride;
527                                 size.v = tbm_surface_get_height(private_layer->showing_buffer);
528
529                                 if (info.src_config.format)
530                                         format = (info.src_config.format)?:format;
531
532                                 TDM_SNPRINTF(reply, len, "%d   %d   %d   %p   %c%c%c%c   %dx%d   %dx%d+%d+%d   %dx%d+%d+%d   %s\n",
533                                                          private_layer->index,
534                                                          private_output->index,
535                                                          private_layer->caps.zpos,
536                                                          private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
537                                                          info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
538                                                          info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
539                                                          tdm_transform_str(info.transform));
540                         } else {
541                                 TDM_SNPRINTF(reply, len, "%d   %d   %d   -\n",
542                                                          private_layer->index,
543                                                          private_output->index,
544                                                          private_layer->caps.zpos);
545                         }
546
547                         TDM_SNPRINTF(reply, len, "\tcaps\t: ");
548                         tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len);
549                         TDM_SNPRINTF(reply, len, "\n");
550
551                         TDM_SNPRINTF(reply, len, "\tformats\t: ");
552                         if (private_layer->caps.format_count > 0) {
553                                 const char *sep = "";
554                                 for (i = 0; i < private_layer->caps.format_count; i++) {
555                                         if (private_layer->caps.formats[i] == 0)
556                                                 continue;
557                                         TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i]));
558                                         sep = ",";
559                                 }
560                                 TDM_SNPRINTF(reply, len, "\n");
561                         }
562
563                         TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
564                         if (private_layer->caps.prop_count > 0) {
565                                 TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
566                                 for (i = 0; i < private_layer->caps.prop_count; i++) {
567                                         tdm_value value;
568                                         TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_property, unlock);
569                                         ret = func_layer->layer_get_property(private_layer->layer_backend,
570                                                                                                                  private_layer->caps.props[i].id,
571                                                                                                                  &value);
572                                         TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
573                                         TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
574                                                                  private_layer->caps.props[i].name,
575                                                                  private_layer->caps.props[i].id,
576                                                                  value.u32);
577                                 }
578                         }
579                 }
580         }
581         TDM_SNPRINTF(reply, len, "\n");
582
583         if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
584                 const char *sep = "";
585                 TDM_SNPRINTF(reply, len, "[PP information]\n");
586                 TDM_SNPRINTF(reply, len, "caps\t: ");
587                 tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len);
588                 TDM_SNPRINTF(reply, len, "\n");
589                 TDM_SNPRINTF(reply, len, "formats\t: ");
590                 for (i = 0; i < private_display->caps_pp.format_count; i++) {
591                         if (private_display->caps_pp.formats[i] == 0)
592                                 continue;
593                         TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i]));
594                         sep = ",";
595                 }
596                 TDM_SNPRINTF(reply, len, "\n");
597                 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
598                                          TDM_FRONT_VALUE(private_display->caps_pp.min_w),
599                                          TDM_FRONT_VALUE(private_display->caps_pp.min_h),
600                                          TDM_FRONT_VALUE(private_display->caps_pp.max_w),
601                                          TDM_FRONT_VALUE(private_display->caps_pp.max_h),
602                                          TDM_FRONT_VALUE(private_display->caps_pp.preferred_align));
603                 if (!LIST_IS_EMPTY(&private_display->pp_list)) {
604                         TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
605                         TDM_SNPRINTF(reply, len, "src(format size crop)  |  dst(format size crop)  |  transform\n");
606                         TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
607                         LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
608                                 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",
609                                                          FOURCC_STR(private_pp->info.src_config.format),
610                                                          private_pp->info.src_config.size.h,
611                                                          private_pp->info.src_config.size.v,
612                                                          private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y,
613                                                          private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h,
614                                                          FOURCC_STR(private_pp->info.dst_config.format),
615                                                          private_pp->info.dst_config.size.h,
616                                                          private_pp->info.dst_config.size.v,
617                                                          private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y,
618                                                          private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h,
619                                                          tdm_transform_str(private_pp->info.transform));
620                         }
621                 }
622         } else {
623                 TDM_SNPRINTF(reply, len, "[No PP capability]\n");
624         }
625         TDM_SNPRINTF(reply, len, "\n");
626
627         if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
628                 const char *sep = "";
629                 TDM_SNPRINTF(reply, len, "[Capture information]\n");
630                 TDM_SNPRINTF(reply, len, "caps\t: ");
631                 tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len);
632                 TDM_SNPRINTF(reply, len, "\n");
633                 TDM_SNPRINTF(reply, len, "formats\t: ");
634                 for (i = 0; i < private_display->caps_capture.format_count; i++) {
635                         if (private_display->caps_capture.formats[i] == 0)
636                                 continue;
637                         TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i]));
638                         sep = ",";
639                 }
640                 TDM_SNPRINTF(reply, len, "\n");
641                 TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n",
642                                          TDM_FRONT_VALUE(private_display->caps_capture.min_w),
643                                          TDM_FRONT_VALUE(private_display->caps_capture.min_h),
644                                          TDM_FRONT_VALUE(private_display->caps_capture.max_w),
645                                          TDM_FRONT_VALUE(private_display->caps_capture.max_h),
646                                          TDM_FRONT_VALUE(private_display->caps_capture.preferred_align));
647                 if (!LIST_IS_EMPTY(&private_display->capture_list)) {
648                         TDM_SNPRINTF(reply, len, "-----------------------------------\n");
649                         TDM_SNPRINTF(reply, len, "dst(format size crop)  |  transform\n");
650                         TDM_SNPRINTF(reply, len, "-----------------------------------\n");
651                         LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
652                                 TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
653                                                          FOURCC_STR(private_capture->info.dst_config.format),
654                                                          private_capture->info.dst_config.size.h,
655                                                          private_capture->info.dst_config.size.v,
656                                                          private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y,
657                                                          private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h,
658                                                          tdm_transform_str(private_capture->info.transform));
659                         }
660                 }
661         } else {
662                 TDM_SNPRINTF(reply, len, "[No Capture capability]\n");
663         }
664         TDM_SNPRINTF(reply, len, "\n");
665
666 unlock:
667         _pthread_mutex_unlock(&private_display->lock);
668 }