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;
48 tbm_surface_h srcbuf[3];
49 tbm_surface_h dstbuf[3];
55 const tdm_output_mode *mode;
58 const tbm_format *dst_formats;
67 bool FindLayerUnderPrimary(void);
68 bool FindLayerOverPrimary(void);
70 bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t);
71 void ShowBuffer(int b);
73 void DumpBuffer(int b, char *test);
74 void DestroyBuffers(void);
78 TDMBackendPP::TDMBackendPP()
81 capabilities = (tdm_pp_capability)0;
84 min_w = min_h = max_w = max_h = preferred_align = -1;
86 for (int b = 0; b < 3; b++)
87 srcbuf[b] = dstbuf[b] = NULL;
88 memset(&info, 0, sizeof info);
101 void TDMBackendPP::SetUp(void)
103 TDMBackendDisplay::SetUp();
105 if (!tc_tdm_display_has_pp_capability(dpy))
108 ASSERT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
109 ASSERT_GT(capabilities, 0);
110 ASSERT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
111 ASSERT_NE(formats, NULL);
112 ASSERT_GT(format_count, 0);
113 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
114 ASSERT_TRUE(min_w == -1 || min_w > 0);
115 ASSERT_TRUE(min_h == -1 || min_h > 0);
116 ASSERT_TRUE(max_w == -1 || max_w > 0);
117 ASSERT_TRUE(max_h == -1 || max_h > 0);
118 ASSERT_TRUE(preferred_align == -1 || preferred_align > 0);
120 for (int o = 0; o < output_count; o++) {
121 if (!tc_tdm_output_is_connected(outputs[o]))
125 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
126 ASSERT_EQ(tc_tdm_output_prepare(dpy, output, false), true);
127 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
128 ASSERT_NE(mode, NULL);
133 void TDMBackendPP::TearDown(void)
140 TDMBackendDisplay::TearDown();
143 bool TDMBackendPP::PreparePP(void)
146 pp = tdm_display_create_pp(dpy, &ret);
147 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
148 TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
152 void TDMBackendPP::DestroyPP(void)
160 bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
162 int src_flags = 0, dst_flags = 0;
164 sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
165 dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
167 if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
168 src_flags = dst_flags |= TBM_BO_SCANOUT;
171 tdm_layer_capability capabilities;
172 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
173 if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
174 dst_flags |= TBM_BO_SCANOUT;
177 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
178 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
179 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
180 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
185 bool TDMBackendPP::FindLayerUnderPrimary(void)
189 int primary_zpos, zpos;
190 tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
191 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
192 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
193 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
195 for (int l = 0; l < count; l++) {
197 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
198 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
199 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
200 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
201 if (zpos < primary_zpos && usable) {
204 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
205 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
206 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
207 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
215 bool TDMBackendPP::FindLayerOverPrimary(void)
219 int primary_zpos, zpos;
220 tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
221 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
222 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
223 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
225 for (int l = 0; l < count; l++) {
226 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
227 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
228 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
229 if (zpos > primary_zpos) {
232 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
233 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
234 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
235 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
245 _tc_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
246 unsigned int tv_sec, unsigned int tv_usec,
249 bool *done = (bool *)user_data;
254 void TDMBackendPP::ShowBuffer(int b)
256 ASSERT_NE(output, NULL);
257 ASSERT_NE(dst_layer, NULL);
261 ASSERT_EQ(tc_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
262 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
264 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
268 void TDMBackendPP::HideLayer(void)
270 ASSERT_NE(output, NULL);
271 ASSERT_NE(dst_layer, NULL);
273 tdm_layer_unset_buffer(dst_layer);
274 tdm_output_commit(output, 0, NULL, NULL);
277 void TDMBackendPP::DumpBuffer(int b, char *test)
281 snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
283 snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
284 tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
286 snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
288 snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
289 tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
292 void TDMBackendPP::DestroyBuffers(void)
294 for (int b = 0; b < 3; b++) {
296 tbm_surface_destroy(srcbuf[b]);
298 tbm_surface_destroy(dstbuf[b]);
299 srcbuf[b] = dstbuf[b] = NULL;
304 tc_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
308 memset(info, 0, sizeof *info);
310 bw = bh = TDM_UT_INVALID_VALUE;
311 tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
312 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
313 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
314 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
315 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
316 info->src_config.size.h = bw;
317 info->src_config.size.v = bh;
318 info->src_config.pos.x = 0;
319 info->src_config.pos.y = 0;
320 info->src_config.pos.w = tbm_surface_get_width(srcbuf);
321 info->src_config.pos.h = tbm_surface_get_height(srcbuf);
322 info->src_config.format = tbm_surface_get_format(srcbuf);
324 bw = bh = TDM_UT_INVALID_VALUE;
325 tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
326 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
327 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
328 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
329 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
330 info->dst_config.size.h = bw;
331 info->dst_config.size.v = bh;
332 info->dst_config.pos.x = 0;
333 info->dst_config.pos.y = 0;
334 info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
335 info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
336 info->dst_config.format = tbm_surface_get_format(dstbuf);
338 info->transform = transform;
342 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)",
343 info->src_config.size.h, info->src_config.size.v,
344 info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
345 FOURCC_STR(info->src_config.format),
346 info->dst_config.size.h, info->dst_config.size.v,
347 info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
348 FOURCC_STR(info->dst_config.format),
349 tdm_transform_str(transform), info->sync, info->flags);
354 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
356 const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
357 int count = TDM_UT_INVALID_VALUE;
358 if (tc_tdm_display_has_pp_capability(dpy))
359 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
361 ASSERT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
362 ASSERT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
363 ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
366 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
368 if (tc_tdm_display_has_pp_capability(dpy)) {
369 ASSERT_EQ(PreparePP(), true);
370 ASSERT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
374 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
376 int min_w = TDM_UT_INVALID_VALUE;
377 int min_h = TDM_UT_INVALID_VALUE;
378 int max_w = TDM_UT_INVALID_VALUE;
379 int max_h = TDM_UT_INVALID_VALUE;
380 int preferred_align = TDM_UT_INVALID_VALUE;
381 if (tc_tdm_display_has_pp_capability(dpy))
382 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
384 ASSERT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
385 ASSERT_EQ(min_w, TDM_UT_INVALID_VALUE);
386 ASSERT_EQ(min_h, TDM_UT_INVALID_VALUE);
387 ASSERT_EQ(max_w, TDM_UT_INVALID_VALUE);
388 ASSERT_EQ(max_h, TDM_UT_INVALID_VALUE);
389 ASSERT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
392 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
394 if (tc_tdm_display_has_pp_capability(dpy)) {
395 ASSERT_EQ(PreparePP(), true);
396 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
400 TEST_P(TDMBackendPP, PPDestroy)
402 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
404 ASSERT_EQ(PreparePP(), true);
409 TEST_P(TDMBackendPP, PPDestroyNullObject)
411 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
413 tdm_pp_destroy(NULL);
416 TEST_P(TDMBackendPP, PPSetInfo)
418 /* tested in PPNoScaleNoTransformNoCSC */
421 TEST_P(TDMBackendPP, PPSetInfoNullObject)
423 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
426 memset(&info, 0, sizeof info);
427 ASSERT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
430 TEST_P(TDMBackendPP, PPSetInfoNullOther)
432 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
434 ASSERT_EQ(PreparePP(), true);
435 ASSERT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
439 _tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
441 bool *done = (bool*)user_data;
446 TEST_P(TDMBackendPP, PPSetDoneHandler)
448 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
450 ASSERT_EQ(PreparePP(), true);
451 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
454 TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
456 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
458 ASSERT_EQ(tdm_pp_set_done_handler(NULL, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
461 TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
463 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
465 ASSERT_EQ(PreparePP(), true);
466 ASSERT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
469 TEST_P(TDMBackendPP, PPAttach)
471 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
473 ASSERT_EQ(PreparePP(), true);
475 for (int f = 0; f < format_count; f++) {
476 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
477 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
478 TDM_TRANSFORM_NORMAL), true);
480 for (int b = 0; b < 3; b++)
481 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
487 TEST_P(TDMBackendPP, PPAttachNullObject)
489 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
491 tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
492 tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
494 ASSERT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
497 TEST_P(TDMBackendPP, PPAttachNullOther)
499 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
501 ASSERT_EQ(PreparePP(), true);
503 ASSERT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
506 TEST_P(TDMBackendPP, PPCommit)
508 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
510 ASSERT_EQ(PreparePP(), true);
512 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
515 TEST_P(TDMBackendPP, PPCommitNullOBject)
517 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
519 ASSERT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
522 TEST_P(TDMBackendPP, PPConvertUnderlay)
524 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
526 FindLayerUnderPrimary();
528 ASSERT_NE(dst_layer, NULL);
530 for (int f = 0; f < dst_format_count; f++) {
533 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
535 ASSERT_EQ(PreparePP(), true);
537 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
538 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
539 TDM_TRANSFORM_NORMAL), true);
541 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
544 for (int b = 0; b < 3; b++) {
547 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
548 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
551 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
555 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
561 TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
562 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
569 TEST_P(TDMBackendPP, PPConvertOverlay)
571 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
573 FindLayerOverPrimary();
575 TDM_UT_SKIP_FLAG(dst_layer != NULL);
577 for (int f = 0; f < dst_format_count; f++) {
580 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
582 ASSERT_EQ(PreparePP(), true);
584 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
585 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
586 TDM_TRANSFORM_NORMAL), true);
588 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
591 for (int b = 0; b < 3; b++) {
594 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
595 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
598 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
602 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
608 TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
609 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
616 TEST_P(TDMBackendPP, PPConvertScale)
618 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
620 FindLayerUnderPrimary();
622 ASSERT_NE(dst_layer, NULL);
624 for (int f = 0; f < dst_format_count; f++) {
627 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
629 ASSERT_EQ(PreparePP(), true);
631 ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f],
632 mode->hdisplay, mode->vdisplay, dst_formats[f],
633 TDM_TRANSFORM_NORMAL), true);
635 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
638 for (int b = 0; b < 3; b++) {
641 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
642 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
645 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
649 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
655 TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
656 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
663 TEST_P(TDMBackendPP, PPConvertTransform)
665 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
667 FindLayerUnderPrimary();
669 ASSERT_NE(dst_layer, NULL);
671 for (int f = 0; f < dst_format_count; f++) {
672 for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
675 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
677 ASSERT_EQ(PreparePP(), true);
679 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
680 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
681 (tdm_transform)t), true);
683 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
686 for (int b = 0; b < 3; b++) {
689 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
690 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
693 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
697 snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
703 TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
704 FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
712 TEST_P(TDMBackendPP, PPConvertCSC)
714 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
715 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
717 FindLayerUnderPrimary();
719 ASSERT_NE(dst_layer, NULL);
721 for (int df = 0; df < dst_format_count; df++) {
722 for (int sf = 0; sf < format_count; sf++) {
725 TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
726 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
728 ASSERT_EQ(PreparePP(), true);
730 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
731 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
732 TDM_TRANSFORM_NORMAL), true);
734 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
737 for (int b = 0; b < 3; b++) {
740 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
741 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
744 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
748 snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
754 TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
755 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
766 _tc_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
768 int *done = (int*)user_data;
773 /* some backend doens't implement correctly for attaching */
774 TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
776 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
778 ASSERT_EQ(PreparePP(), true);
783 snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
785 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
786 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
787 TDM_TRANSFORM_NORMAL), true);
789 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
790 for (int b = 0; b < 3; b++)
791 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
793 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
796 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
798 for (int b = 0; b < 3; b++)
804 TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
806 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
808 ASSERT_EQ(PreparePP(), true);
812 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
813 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
814 TDM_TRANSFORM_NORMAL), true);
816 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
817 for (int b = 0; b < 3; b++)
818 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
826 TEST_P(TDMBackendPP, PPDestroyBeforeDone)
828 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
830 ASSERT_EQ(PreparePP(), true);
834 ASSERT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
835 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
836 TDM_TRANSFORM_NORMAL), true);
838 ASSERT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
839 for (int b = 0; b < 3; b++)
840 ASSERT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
842 ASSERT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
850 #ifdef TDM_UT_TEST_WITH_PARAMS
851 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
853 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
855 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
857 Values(TDM_DEFAULT_MODULE));