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 **************************************************************************/
33 class TDMBackendPP : public TDMBackendDisplay
37 tdm_pp_capability capabilities;
38 const tbm_format *formats;
46 tbm_surface_h srcbuf[3];
47 tbm_surface_h dstbuf[3];
53 const tdm_output_mode *mode;
56 const tbm_format *dst_formats;
65 bool FindLayerUnderPrimary(void);
66 bool FindLayerOverPrimary(void);
68 bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
69 void ShowBuffer(int b);
71 void DumpBuffer(int b, char *test);
72 void DestroyBuffers(void);
76 TDMBackendPP::TDMBackendPP()
79 capabilities = (tdm_pp_capability)0;
82 min_w = min_h = max_w = max_h = preferred_align = -1;
84 for (int b = 0; b < 3; b++)
85 srcbuf[b] = dstbuf[b] = NULL;
86 memset(&info, 0, sizeof info);
99 void TDMBackendPP::SetUp(void)
101 TDMBackendDisplay::SetUp();
103 if (!ut_tdm_display_has_pp_capability(dpy))
106 ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
107 ASSERT_GT(capabilities, 0);
108 ASSERT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
109 ASSERT_NE(formats, NULL);
110 ASSERT_GT(format_count, 0);
111 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
112 ASSERT_TRUE(min_w == -1 || min_w > 0);
113 ASSERT_TRUE(min_h == -1 || min_h > 0);
114 ASSERT_TRUE(max_w == -1 || max_w > 0);
115 ASSERT_TRUE(max_h == -1 || max_h > 0);
116 ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
118 for (int o = 0; o < output_count; o++) {
119 if (!ut_tdm_output_is_connected(outputs[o]))
123 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
124 ASSERT_EQ(ut_tdm_output_prepare(dpy, output, false), true);
125 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
126 ASSERT_NE(mode, NULL);
131 void TDMBackendPP::TearDown(void)
138 TDMBackendDisplay::TearDown();
141 bool TDMBackendPP::PreparePP(void)
144 pp = tdm_display_create_pp(dpy, &ret);
145 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
146 TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
150 void TDMBackendPP::DestroyPP(void)
158 bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
160 int src_flags = 0, dst_flags = 0;
162 sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
163 dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
165 if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
166 src_flags = dst_flags |= TBM_BO_SCANOUT;
169 tdm_layer_capability capabilities;
170 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
171 if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
172 dst_flags |= TBM_BO_SCANOUT;
175 TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
176 TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
177 TDM_UT_RETURN_FALSE_IF_FAIL(ut_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
178 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
183 bool TDMBackendPP::FindLayerUnderPrimary(void)
187 int primary_zpos, zpos;
188 tdm_layer *primary = ut_tdm_output_get_primary_layer(output);
189 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
190 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
191 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
193 for (int l = 0; l < count; l++) {
195 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
196 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
197 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
198 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
199 if (zpos < primary_zpos && usable) {
202 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
203 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
204 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
205 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
213 bool TDMBackendPP::FindLayerOverPrimary(void)
217 int primary_zpos, zpos;
218 tdm_layer *primary = ut_tdm_output_get_primary_layer(output);
219 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
220 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
221 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
223 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_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
227 if (zpos > primary_zpos) {
230 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
231 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
232 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
233 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
243 _ut_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
244 unsigned int tv_sec, unsigned int tv_usec,
247 bool *done = (bool *)user_data;
252 void TDMBackendPP::ShowBuffer(int b)
254 ASSERT_NE(output, NULL);
255 ASSERT_NE(dst_layer, NULL);
259 ASSERT_EQ(ut_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
260 ASSERT_EQ(tdm_output_commit(output, 0, _ut_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
262 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
266 void TDMBackendPP::HideLayer(void)
268 ASSERT_NE(output, NULL);
269 ASSERT_NE(dst_layer, NULL);
271 tdm_layer_unset_buffer(dst_layer);
272 tdm_output_commit(output, 0, NULL, NULL);
275 void TDMBackendPP::DumpBuffer(int b, char *test)
279 snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
281 snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
282 tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
284 snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
286 snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
287 tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
290 void TDMBackendPP::DestroyBuffers(void)
292 for (int b = 0; b < 3; b++) {
294 tbm_surface_destroy(srcbuf[b]);
296 tbm_surface_destroy(dstbuf[b]);
297 srcbuf[b] = dstbuf[b] = NULL;
302 ut_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
306 memset(info, 0, sizeof *info);
308 bw = bh = TDM_UT_INVALID_VALUE;
309 tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
310 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
311 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
312 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
313 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
314 info->src_config.size.h = bw;
315 info->src_config.size.v = bh;
316 info->src_config.pos.x = 0;
317 info->src_config.pos.y = 0;
318 info->src_config.pos.w = tbm_surface_get_width(srcbuf);
319 info->src_config.pos.h = tbm_surface_get_height(srcbuf);
320 info->src_config.format = tbm_surface_get_format(srcbuf);
322 bw = bh = TDM_UT_INVALID_VALUE;
323 tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
324 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
325 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
326 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
327 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
328 info->dst_config.size.h = bw;
329 info->dst_config.size.v = bh;
330 info->dst_config.pos.x = 0;
331 info->dst_config.pos.y = 0;
332 info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
333 info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
334 info->dst_config.format = tbm_surface_get_format(dstbuf);
336 info->transform = transform;
340 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)",
341 info->src_config.size.h, info->src_config.size.v,
342 info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
343 FOURCC_STR(info->src_config.format),
344 info->dst_config.size.h, info->dst_config.size.v,
345 info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
346 FOURCC_STR(info->dst_config.format),
347 tdm_transform_str(transform), info->sync, info->flags);
352 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
354 const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
355 int count = TDM_UT_INVALID_VALUE;
356 if (ut_tdm_display_has_pp_capability(dpy))
357 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
359 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
360 ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
361 ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
364 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
366 if (ut_tdm_display_has_pp_capability(dpy)) {
367 ASSERT_EQ(PreparePP(), true);
368 ASSERT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
372 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
374 int min_w = TDM_UT_INVALID_VALUE;
375 int min_h = TDM_UT_INVALID_VALUE;
376 int max_w = TDM_UT_INVALID_VALUE;
377 int max_h = TDM_UT_INVALID_VALUE;
378 int preferred_align = TDM_UT_INVALID_VALUE;
379 if (ut_tdm_display_has_pp_capability(dpy))
380 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
382 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
383 ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
384 ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
385 ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
386 ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
387 ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
390 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
392 if (ut_tdm_display_has_pp_capability(dpy)) {
393 ASSERT_EQ(PreparePP(), true);
394 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
398 TEST_P(TDMBackendPP, PPDestroy)
400 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
402 ASSERT_EQ(PreparePP(), true);
407 TEST_P(TDMBackendPP, PPDestroyNullObject)
409 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
411 tdm_pp_destroy(NULL);
414 TEST_P(TDMBackendPP, PPSetInfo)
416 /* tested in PPNoScaleNoTransformNoCSC */
419 TEST_P(TDMBackendPP, PPSetInfoNullObject)
421 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
424 memset(&info, 0, sizeof info);
425 ASSERT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
428 TEST_P(TDMBackendPP, PPSetInfoNullOther)
430 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
432 ASSERT_EQ(PreparePP(), true);
433 ASSERT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
437 _ut_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
439 bool *done = (bool*)user_data;
444 TEST_P(TDMBackendPP, PPSetDoneHandler)
446 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
448 ASSERT_EQ(PreparePP(), true);
449 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
452 TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
454 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
456 ASSERT_EQ(tdm_pp_set_done_handler(NULL, _ut_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
459 TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
461 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
463 ASSERT_EQ(PreparePP(), true);
464 ASSERT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
467 TEST_P(TDMBackendPP, PPAttach)
469 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
471 ASSERT_EQ(PreparePP(), true);
473 for (int f = 0; f < format_count; f++) {
474 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
475 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
476 TDM_TRANSFORM_NORMAL), true);
478 for (int b = 0; b < 3; b++)
479 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
485 TEST_P(TDMBackendPP, PPAttachNullObject)
487 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
489 tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
490 tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
492 ASSERT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
495 TEST_P(TDMBackendPP, PPAttachNullOther)
497 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
499 ASSERT_EQ(PreparePP(), true);
501 ASSERT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
504 TEST_P(TDMBackendPP, PPCommit)
506 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
508 ASSERT_EQ(PreparePP(), true);
510 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
513 TEST_P(TDMBackendPP, PPCommitNullOBject)
515 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
517 ASSERT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
520 TEST_P(TDMBackendPP, PPConvertUnderlay)
522 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
524 FindLayerUnderPrimary();
526 ASSERT_NE(dst_layer, NULL);
528 for (int f = 0; f < dst_format_count; f++) {
531 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
533 ASSERT_EQ(PreparePP(), true);
535 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
536 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
537 TDM_TRANSFORM_NORMAL), true);
539 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
542 for (int b = 0; b < 3; b++) {
545 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
546 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
549 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
553 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
559 TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
560 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
567 TEST_P(TDMBackendPP, PPConvertOverlay)
569 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
571 FindLayerOverPrimary();
573 TDM_UT_SKIP_FLAG(dst_layer != NULL);
575 for (int f = 0; f < dst_format_count; f++) {
578 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
580 ASSERT_EQ(PreparePP(), true);
582 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
583 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
584 TDM_TRANSFORM_NORMAL), true);
586 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
589 for (int b = 0; b < 3; b++) {
592 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
593 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
596 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
600 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
606 TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
607 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
614 TEST_P(TDMBackendPP, PPConvertScale)
616 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
618 FindLayerUnderPrimary();
620 ASSERT_NE(dst_layer, NULL);
622 for (int f = 0; f < dst_format_count; f++) {
625 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
627 ASSERT_EQ(PreparePP(), true);
629 ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f],
630 mode->hdisplay, mode->vdisplay, dst_formats[f],
631 TDM_TRANSFORM_NORMAL), true);
633 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
636 for (int b = 0; b < 3; b++) {
639 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
640 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
643 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
647 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
653 TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
654 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
661 TEST_P(TDMBackendPP, PPConvertTransform)
663 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
665 FindLayerUnderPrimary();
667 ASSERT_NE(dst_layer, NULL);
669 for (int f = 0; f < dst_format_count; f++) {
670 for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
673 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
675 ASSERT_EQ(PreparePP(), true);
677 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
678 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
679 (tdm_transform)t), true);
681 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
684 for (int b = 0; b < 3; b++) {
687 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
688 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
691 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
695 snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
701 TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
702 FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
710 TEST_P(TDMBackendPP, PPConvertCSC)
712 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
713 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
715 FindLayerUnderPrimary();
717 ASSERT_NE(dst_layer, NULL);
719 for (int df = 0; df < dst_format_count; df++) {
720 for (int sf = 0; sf < format_count; sf++) {
723 TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
724 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
726 ASSERT_EQ(PreparePP(), true);
728 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
729 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
730 TDM_TRANSFORM_NORMAL), true);
732 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
735 for (int b = 0; b < 3; b++) {
738 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
739 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
742 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
746 snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
752 TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
753 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
764 _ut_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
766 int *done = (int*)user_data;
771 /* some backend doens't implement correctly for attaching */
772 TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
774 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
776 ASSERT_EQ(PreparePP(), true);
781 snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
783 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
784 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
785 TDM_TRANSFORM_NORMAL), true);
787 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
788 for (int b = 0; b < 3; b++)
789 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
791 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
794 ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
796 for (int b = 0; b < 3; b++)
802 TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
804 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
806 ASSERT_EQ(PreparePP(), true);
810 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
811 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
812 TDM_TRANSFORM_NORMAL), true);
814 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
815 for (int b = 0; b < 3; b++)
816 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
824 TEST_P(TDMBackendPP, PPDestroyBeforeDone)
826 TDM_UT_SKIP_FLAG(ut_tdm_display_has_pp_capability(dpy));
828 ASSERT_EQ(PreparePP(), true);
832 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
833 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
834 TDM_TRANSFORM_NORMAL), true);
836 ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
837 for (int b = 0; b < 3; b++)
838 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
840 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
848 #ifdef TDM_UT_TEST_WITH_PARAMS
849 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
851 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
853 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
855 Values(TDM_DEFAULT_MODULE));