1 /**************************************************************************
3 * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
5 * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6 * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7 * Contact: Roman Marchenko <r.marchenko@samsung.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sub license, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice and this permission notice (including the
18 * next paragraph) shall be included in all copies or substantial portions
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 **************************************************************************/
35 class TDMBackendPP : public TDMBackendDisplay
39 tdm_pp_capability capabilities;
40 const tbm_format *formats;
47 int preferred_align_vertical;
49 tbm_surface_h srcbuf[3];
50 tbm_surface_h dstbuf[3];
56 const tdm_output_mode *mode;
59 const tbm_format *dst_formats;
60 tbm_format *pp_formats;
69 bool FindLayerUnderPrimary(void);
70 bool FindLayerOverPrimary(void);
72 bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
73 void ShowBuffer(int b);
75 void DumpBuffer(int b, char *test);
76 void DestroyBuffers(void);
80 TDMBackendPP::TDMBackendPP()
83 capabilities = (tdm_pp_capability)0;
86 min_w = min_h = max_w = max_h = preferred_align = preferred_align_vertical = -1;
88 for (int b = 0; b < 3; b++)
89 srcbuf[b] = dstbuf[b] = NULL;
90 memset(&info, 0, sizeof info);
104 void TDMBackendPP::SetUp(void)
106 TDMBackendDisplay::SetUp();
108 if (!tc_tdm_display_has_pp_capability(dpy))
111 ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
112 ASSERT_GT(capabilities, 0);
113 ASSERT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
114 ASSERT_NE(formats, NULL);
115 ASSERT_GT(format_count, 0);
116 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
117 ASSERT_TRUE(min_w == -1 || min_w > 0);
118 ASSERT_TRUE(min_h == -1 || min_h > 0);
119 ASSERT_TRUE(max_w == -1 || max_w > 0);
120 ASSERT_TRUE(max_h == -1 || max_h > 0);
121 ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
122 ASSERT_EQ(tdm_display_get_pp_preferred_align_vertical(dpy, &preferred_align_vertical), TDM_ERROR_NONE);
123 ASSERT_TRUE(preferred_align_vertical == -1 || preferred_align_vertical > 0);
125 for (int o = 0; o < output_count; o++) {
126 if (!tc_tdm_output_is_connected(outputs[o]))
130 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
131 ASSERT_EQ(tc_tdm_output_prepare(dpy, output, false), true);
132 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
133 ASSERT_NE(mode, NULL);
138 void TDMBackendPP::TearDown(void)
144 ASSERT_EQ(tc_tdm_output_unset(dpy, output), true);
146 TDMBackendDisplay::TearDown();
149 bool TDMBackendPP::PreparePP(void)
152 pp = tdm_display_create_pp(dpy, &ret);
153 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
154 TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
158 void TDMBackendPP::DestroyPP(void)
166 bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
168 int src_flags = 0, dst_flags = 0;
170 sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
171 dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
172 if (preferred_align_vertical > 0) {
173 sh = TDM_UT_SIZE_ALIGN(sh, preferred_align_vertical);
174 dh = TDM_UT_SIZE_ALIGN(dh, preferred_align_vertical);
177 if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
178 src_flags = dst_flags |= TBM_BO_SCANOUT;
181 tdm_layer_capability capabilities;
182 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
183 if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
184 dst_flags |= TBM_BO_SCANOUT;
187 if (tc_tdm_output_is_hwc_enable(output))
188 dst_flags |= TBM_BO_SCANOUT;
190 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
191 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
192 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
193 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
198 bool TDMBackendPP::FindLayerUnderPrimary(void)
202 int primary_zpos, zpos;
204 if (tc_tdm_output_is_hwc_enable(output)) {
205 pp_formats = (tbm_format *)calloc(1, sizeof(tbm_format) * 2);
206 TDM_UT_RETURN_FALSE_IF_FAIL(pp_formats != NULL);
207 pp_formats[0] = TBM_FORMAT_NV12;
208 pp_formats[1] = TBM_FORMAT_YUV420;
209 dst_formats = pp_formats;
210 dst_format_count = 2;
211 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
212 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
217 tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
218 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
219 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
220 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
222 for (int l = 0; l < count; l++) {
224 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
225 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
226 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
227 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
228 if (zpos < primary_zpos && usable) {
231 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
232 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
233 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
234 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
242 bool TDMBackendPP::FindLayerOverPrimary(void)
246 int primary_zpos, zpos;
248 if (tc_tdm_output_is_hwc_enable(output)) {
249 pp_formats = (tbm_format *)calloc(1, sizeof(tbm_format) * 2);
250 TDM_UT_RETURN_FALSE_IF_FAIL(pp_formats != NULL);
251 pp_formats[0] = TBM_FORMAT_ARGB8888;
252 pp_formats[1] = TBM_FORMAT_XRGB8888;
253 dst_formats = formats;
254 dst_format_count = 2;
255 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
256 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
261 tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
262 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
263 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
264 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
266 for (int l = 0; l < count; l++) {
267 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
268 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
269 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
270 if (zpos > primary_zpos) {
273 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
274 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
275 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
276 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
286 _tc_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
287 unsigned int tv_sec, unsigned int tv_usec,
290 bool *done = (bool *)user_data;
295 void TDMBackendPP::ShowBuffer(int b)
297 ASSERT_NE(output, NULL);
298 if (tc_tdm_output_is_hwc_enable(output))
301 ASSERT_NE(dst_layer, NULL);
305 ASSERT_EQ(tc_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
306 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
308 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
312 void TDMBackendPP::HideLayer(void)
314 ASSERT_NE(output, NULL);
315 if (tc_tdm_output_is_hwc_enable(output))
318 ASSERT_NE(dst_layer, NULL);
320 tdm_layer_unset_buffer(dst_layer);
321 tdm_output_commit(output, 0, NULL, NULL);
324 void TDMBackendPP::DumpBuffer(int b, char *test)
328 snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
330 snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
331 tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
333 snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
335 snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
336 tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
339 void TDMBackendPP::DestroyBuffers(void)
341 for (int b = 0; b < 3; b++) {
343 tbm_surface_destroy(srcbuf[b]);
345 tbm_surface_destroy(dstbuf[b]);
346 srcbuf[b] = dstbuf[b] = NULL;
351 tc_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
355 memset(info, 0, sizeof *info);
357 bw = bh = TDM_UT_INVALID_VALUE;
358 tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
359 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
360 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
361 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
362 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
363 info->src_config.size.h = bw;
364 info->src_config.size.v = bh;
365 info->src_config.pos.x = 0;
366 info->src_config.pos.y = 0;
367 info->src_config.pos.w = tbm_surface_get_width(srcbuf);
368 info->src_config.pos.h = tbm_surface_get_height(srcbuf);
369 info->src_config.format = tbm_surface_get_format(srcbuf);
371 bw = bh = TDM_UT_INVALID_VALUE;
372 tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
373 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
374 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
375 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
376 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
377 info->dst_config.size.h = bw;
378 info->dst_config.size.v = bh;
379 info->dst_config.pos.x = 0;
380 info->dst_config.pos.y = 0;
381 info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
382 info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
383 info->dst_config.format = tbm_surface_get_format(dstbuf);
385 info->transform = transform;
389 TDM_UT_INFO("src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_config(%dx%d: %d,%d %dx%d: %c%c%c%c) transform(%s) sync(%d) info->flags(%x)",
390 info->src_config.size.h, info->src_config.size.v,
391 info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
392 FOURCC_STR(info->src_config.format),
393 info->dst_config.size.h, info->dst_config.size.v,
394 info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
395 FOURCC_STR(info->dst_config.format),
396 tdm_transform_str(transform), info->sync, info->flags);
401 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
403 const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
404 int count = TDM_UT_INVALID_VALUE;
405 if (tc_tdm_display_has_pp_capability(dpy))
406 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
408 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
409 ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
410 ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
413 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
415 if (tc_tdm_display_has_pp_capability(dpy)) {
416 ASSERT_EQ(PreparePP(), true);
417 ASSERT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
421 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
423 int min_w = TDM_UT_INVALID_VALUE;
424 int min_h = TDM_UT_INVALID_VALUE;
425 int max_w = TDM_UT_INVALID_VALUE;
426 int max_h = TDM_UT_INVALID_VALUE;
427 int preferred_align = TDM_UT_INVALID_VALUE;
428 if (tc_tdm_display_has_pp_capability(dpy))
429 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
431 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
432 ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
433 ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
434 ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
435 ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
436 ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
439 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
441 if (tc_tdm_display_has_pp_capability(dpy)) {
442 ASSERT_EQ(PreparePP(), true);
443 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
447 TEST_P(TDMBackendPP, PPDispalyGetPreferredAlignVerticalNullObject)
449 if (tc_tdm_display_has_pp_capability(dpy)) {
450 ASSERT_EQ(PreparePP(), true);
451 ASSERT_EQ(tdm_display_get_pp_preferred_align_vertical(NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
455 TEST_P(TDMBackendPP, PPDestroy)
457 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
459 ASSERT_EQ(PreparePP(), true);
464 TEST_P(TDMBackendPP, PPDestroyNullObject)
466 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
468 tdm_pp_destroy(NULL);
471 TEST_P(TDMBackendPP, PPSetInfo)
473 /* tested in PPNoScaleNoTransformNoCSC */
476 TEST_P(TDMBackendPP, PPSetInfoNullObject)
478 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
481 memset(&info, 0, sizeof info);
482 ASSERT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
485 TEST_P(TDMBackendPP, PPSetInfoNullOther)
487 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
489 ASSERT_EQ(PreparePP(), true);
490 ASSERT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
494 _tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
496 bool *done = (bool*)user_data;
501 TEST_P(TDMBackendPP, PPSetDoneHandler)
503 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
505 ASSERT_EQ(PreparePP(), true);
506 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
509 TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
511 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
513 ASSERT_EQ(tdm_pp_set_done_handler(NULL, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
516 TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
518 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
520 ASSERT_EQ(PreparePP(), true);
521 ASSERT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
524 TEST_P(TDMBackendPP, PPAttach)
526 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
528 ASSERT_EQ(PreparePP(), true);
530 for (int f = 0; f < format_count; f++) {
531 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
532 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
533 TDM_TRANSFORM_NORMAL), true);
535 for (int b = 0; b < 3; b++)
536 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
542 TEST_P(TDMBackendPP, PPAttachNullObject)
544 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
546 tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
547 tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
549 ASSERT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
552 TEST_P(TDMBackendPP, PPAttachNullOther)
554 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
556 ASSERT_EQ(PreparePP(), true);
558 ASSERT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
561 TEST_P(TDMBackendPP, PPCommit)
563 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
565 ASSERT_EQ(PreparePP(), true);
567 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
570 TEST_P(TDMBackendPP, PPCommitNullOBject)
572 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
574 ASSERT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
577 TEST_P(TDMBackendPP, PPConvertUnderlay)
579 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
581 FindLayerUnderPrimary();
583 if (!tc_tdm_output_is_hwc_enable(output))
584 ASSERT_NE(dst_layer, NULL);
586 for (int f = 0; f < dst_format_count; f++) {
589 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
591 ASSERT_EQ(PreparePP(), true);
593 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
594 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
595 TDM_TRANSFORM_NORMAL), true);
597 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
600 for (int b = 0; b < 3; b++) {
603 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
604 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
607 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
611 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
617 TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
618 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
623 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
629 TEST_P(TDMBackendPP, PPConvertOverlay)
631 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
633 FindLayerOverPrimary();
635 if (!tc_tdm_output_is_hwc_enable(output))
636 TDM_UT_SKIP_FLAG(dst_layer != NULL);
638 for (int f = 0; f < dst_format_count; f++) {
641 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
643 ASSERT_EQ(PreparePP(), true);
645 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
646 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
647 TDM_TRANSFORM_NORMAL), true);
649 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
652 for (int b = 0; b < 3; b++) {
655 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
656 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
659 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
663 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
669 TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
670 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
675 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
681 TEST_P(TDMBackendPP, PPConvertScale)
683 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
685 FindLayerUnderPrimary();
687 if (!tc_tdm_output_is_hwc_enable(output))
688 ASSERT_NE(dst_layer, NULL);
690 for (int f = 0; f < dst_format_count; f++) {
693 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
695 ASSERT_EQ(PreparePP(), true);
697 ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f],
698 mode->hdisplay, mode->vdisplay, dst_formats[f],
699 TDM_TRANSFORM_NORMAL), true);
701 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
704 for (int b = 0; b < 3; b++) {
707 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
708 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
711 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
715 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
721 TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
722 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
727 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
733 TEST_P(TDMBackendPP, PPConvertTransform)
735 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
736 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_TRANSFORM_ROTATION));
738 FindLayerUnderPrimary();
740 if (!tc_tdm_output_is_hwc_enable(output))
741 ASSERT_NE(dst_layer, NULL);
743 for (int f = 0; f < dst_format_count; f++) {
744 for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
747 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
749 ASSERT_EQ(PreparePP(), true);
751 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
752 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
753 (tdm_transform)t), true);
755 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
758 for (int b = 0; b < 3; b++) {
761 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
762 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
765 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
769 snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
775 TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
776 FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
782 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
788 TEST_P(TDMBackendPP, PPConvertCSC)
790 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
791 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
793 FindLayerUnderPrimary();
795 if (!tc_tdm_output_is_hwc_enable(output))
796 ASSERT_NE(dst_layer, NULL);
798 for (int df = 0; df < dst_format_count; df++) {
799 for (int sf = 0; sf < format_count; sf++) {
802 TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
803 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
805 ASSERT_EQ(PreparePP(), true);
807 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
808 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
809 TDM_TRANSFORM_NORMAL), true);
811 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
814 for (int b = 0; b < 3; b++) {
817 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
818 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
821 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
825 snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
831 TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
832 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
838 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
847 _tc_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
849 int *done = (int*)user_data;
854 /* some backend doens't implement correctly for attaching */
855 TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
857 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
859 ASSERT_EQ(PreparePP(), true);
864 snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
866 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
867 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
868 TDM_TRANSFORM_NORMAL), true);
870 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
871 for (int b = 0; b < 3; b++)
872 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
874 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
877 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
879 for (int b = 0; b < 3; b++)
885 TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
887 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
889 ASSERT_EQ(PreparePP(), true);
893 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
894 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
895 TDM_TRANSFORM_NORMAL), true);
897 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
898 for (int b = 0; b < 3; b++)
899 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
907 TEST_P(TDMBackendPP, PPDestroyBeforeDone)
909 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
911 ASSERT_EQ(PreparePP(), true);
915 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
916 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
917 TDM_TRANSFORM_NORMAL), true);
919 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
920 for (int b = 0; b < 3; b++)
921 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
923 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
931 #ifdef TDM_UT_TEST_WITH_PARAMS
932 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
934 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
936 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
938 Values(TDM_DEFAULT_MODULE));