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 EXPECT_EQ(tdm_display_get_pp_capabilities(dpy, &capabilities), TDM_ERROR_NONE);
112 EXPECT_GT(capabilities, 0);
113 EXPECT_EQ(tdm_display_get_pp_available_formats(dpy, &formats, &format_count), TDM_ERROR_NONE);
114 EXPECT_NE(formats, NULL);
115 EXPECT_GT(format_count, 0);
116 EXPECT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
117 EXPECT_TRUE(min_w == -1 || min_w > 0);
118 EXPECT_TRUE(min_h == -1 || min_h > 0);
119 EXPECT_TRUE(max_w == -1 || max_w > 0);
120 EXPECT_TRUE(max_h == -1 || max_h > 0);
121 EXPECT_TRUE(preferred_align == -1 || preferred_align > 0);
122 EXPECT_EQ(tdm_display_get_pp_preferred_align_vertical(dpy, &preferred_align_vertical), TDM_ERROR_NONE);
123 EXPECT_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 EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
131 EXPECT_EQ(tc_tdm_output_prepare(dpy, output, false), true);
132 EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
133 EXPECT_NE(mode, NULL);
138 void TDMBackendPP::TearDown(void)
145 EXPECT_EQ(tc_tdm_output_unset(dpy, output), true);
147 TDMBackendDisplay::TearDown();
150 bool TDMBackendPP::PreparePP(void)
153 pp = tdm_display_create_pp(dpy, &ret);
154 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
155 TDM_UT_RETURN_FALSE_IF_FAIL(pp != NULL);
159 void TDMBackendPP::DestroyPP(void)
167 bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t)
169 int src_flags = 0, dst_flags = 0;
171 sw = TDM_UT_SIZE_ALIGN(sw, preferred_align);
172 dw = TDM_UT_SIZE_ALIGN(dw, preferred_align);
173 if (preferred_align_vertical > 0) {
174 sh = TDM_UT_SIZE_ALIGN(sh, preferred_align_vertical);
175 dh = TDM_UT_SIZE_ALIGN(dh, preferred_align_vertical);
178 if (capabilities & TDM_PP_CAPABILITY_SCANOUT)
179 src_flags = dst_flags |= TBM_BO_SCANOUT;
182 tdm_layer_capability capabilities;
183 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_capabilities(dst_layer, &capabilities) == TDM_ERROR_NONE);
184 if (capabilities & TDM_LAYER_CAPABILITY_SCANOUT)
185 dst_flags |= TBM_BO_SCANOUT;
188 if (tc_tdm_output_is_hwc_enable(output))
189 dst_flags |= TBM_BO_SCANOUT;
191 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(sw, sh, sf, src_flags, true, 3, srcbuf) == true);
192 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_buffer_create(dw, dh, df, dst_flags, false, 3, dstbuf) == true);
193 TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_pp_fill_info(srcbuf[0], dstbuf[0], t, &info) == true);
194 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_info(pp, &info) == TDM_ERROR_NONE);
199 bool TDMBackendPP::FindLayerUnderPrimary(void)
203 int primary_zpos, zpos;
205 if (tc_tdm_output_is_hwc_enable(output)) {
206 pp_formats = (tbm_format *)calloc(1, sizeof(tbm_format) * 2);
207 TDM_UT_RETURN_FALSE_IF_FAIL(pp_formats != NULL);
208 pp_formats[0] = TBM_FORMAT_NV12;
209 pp_formats[1] = TBM_FORMAT_YUV420;
210 dst_formats = pp_formats;
211 dst_format_count = 2;
212 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
213 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
218 tdm_layer *primary = tc_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++) {
225 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
226 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
227 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_is_usable(temp, &usable) == TDM_ERROR_NONE);
228 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
229 if (zpos < primary_zpos && usable) {
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);
243 bool TDMBackendPP::FindLayerOverPrimary(void)
247 int primary_zpos, zpos;
249 if (tc_tdm_output_is_hwc_enable(output)) {
250 pp_formats = (tbm_format *)calloc(1, sizeof(tbm_format) * 2);
251 TDM_UT_RETURN_FALSE_IF_FAIL(pp_formats != NULL);
252 pp_formats[0] = TBM_FORMAT_ARGB8888;
253 pp_formats[1] = TBM_FORMAT_XRGB8888;
254 dst_formats = formats;
255 dst_format_count = 2;
256 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
257 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
262 tdm_layer *primary = tc_tdm_output_get_primary_layer(output);
263 TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL);
264 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(output, &count) == TDM_ERROR_NONE);
265 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE);
267 for (int l = 0; l < count; l++) {
268 tdm_layer *temp = tdm_output_get_layer(output, l, &ret);
269 TDM_UT_RETURN_FALSE_IF_FAIL(temp != NULL);
270 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(temp, &zpos) == TDM_ERROR_NONE);
271 if (zpos > primary_zpos) {
274 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(dst_layer, &dst_formats, &dst_format_count) == TDM_ERROR_NONE);
275 TDM_UT_RETURN_FALSE_IF_FAIL(dst_formats != NULL);
276 TDM_UT_RETURN_FALSE_IF_FAIL(dst_format_count > 0);
277 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(dst_layer, &dst_layer_index) == TDM_ERROR_NONE);
287 _tc_tdm_backend_pp_output_commit_cb(tdm_output *output, unsigned int sequence,
288 unsigned int tv_sec, unsigned int tv_usec,
291 bool *done = (bool *)user_data;
296 void TDMBackendPP::ShowBuffer(int b)
298 EXPECT_NE(output, NULL);
299 if (tc_tdm_output_is_hwc_enable(output))
302 EXPECT_NE(dst_layer, NULL);
306 EXPECT_EQ(tc_tdm_layer_set_buffer(dst_layer, dstbuf[b]), true);
307 EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_pp_output_commit_cb, &done), TDM_ERROR_NONE);
309 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
313 void TDMBackendPP::HideLayer(void)
315 EXPECT_NE(output, NULL);
316 if (tc_tdm_output_is_hwc_enable(output))
319 EXPECT_NE(dst_layer, NULL);
321 tdm_layer_unset_buffer(dst_layer);
322 tdm_output_commit(output, 0, NULL, NULL);
325 void TDMBackendPP::DumpBuffer(int b, char *test)
329 snprintf(filename, sizeof filename, "%s_%s_src_%d", typeid(*this).name(), test, b);
331 snprintf(filename, sizeof filename, "%s_src_%d", typeid(*this).name(), b);
332 tdm_helper_dump_buffer_str(srcbuf[b], NULL, filename);
334 snprintf(filename, sizeof filename, "%s_%s_dst_%d", typeid(*this).name(), test, b);
336 snprintf(filename, sizeof filename, "%s_dst_%d", typeid(*this).name(), b);
337 tdm_helper_dump_buffer_str(dstbuf[b], NULL, filename);
340 void TDMBackendPP::DestroyBuffers(void)
342 for (int b = 0; b < 3; b++) {
344 tbm_surface_destroy(srcbuf[b]);
346 tbm_surface_destroy(dstbuf[b]);
347 srcbuf[b] = dstbuf[b] = NULL;
352 tc_tdm_pp_fill_info(tbm_surface_h srcbuf, tbm_surface_h dstbuf, tdm_transform transform, tdm_info_pp *info)
356 memset(info, 0, sizeof *info);
358 bw = bh = TDM_UT_INVALID_VALUE;
359 tdm_helper_get_buffer_full_size(srcbuf, &bw, &bh);
360 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
361 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(srcbuf));
362 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
363 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(srcbuf));
364 info->src_config.size.h = bw;
365 info->src_config.size.v = bh;
366 info->src_config.pos.x = 0;
367 info->src_config.pos.y = 0;
368 info->src_config.pos.w = tbm_surface_get_width(srcbuf);
369 info->src_config.pos.h = tbm_surface_get_height(srcbuf);
370 info->src_config.format = tbm_surface_get_format(srcbuf);
372 bw = bh = TDM_UT_INVALID_VALUE;
373 tdm_helper_get_buffer_full_size(dstbuf, &bw, &bh);
374 TDM_UT_RETURN_FALSE_IF_FAIL(bw != TDM_UT_INVALID_VALUE);
375 TDM_UT_RETURN_FALSE_IF_FAIL(bw >= tbm_surface_get_width(dstbuf));
376 TDM_UT_RETURN_FALSE_IF_FAIL(bh != TDM_UT_INVALID_VALUE);
377 TDM_UT_RETURN_FALSE_IF_FAIL(bh >= tbm_surface_get_height(dstbuf));
378 info->dst_config.size.h = bw;
379 info->dst_config.size.v = bh;
380 info->dst_config.pos.x = 0;
381 info->dst_config.pos.y = 0;
382 info->dst_config.pos.w = tbm_surface_get_width(dstbuf);
383 info->dst_config.pos.h = tbm_surface_get_height(dstbuf);
384 info->dst_config.format = tbm_surface_get_format(dstbuf);
386 info->transform = transform;
390 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)",
391 info->src_config.size.h, info->src_config.size.v,
392 info->src_config.pos.x, info->src_config.pos.y, info->src_config.pos.w, info->src_config.pos.h,
393 FOURCC_STR(info->src_config.format),
394 info->dst_config.size.h, info->dst_config.size.v,
395 info->dst_config.pos.x, info->dst_config.pos.y, info->dst_config.pos.w, info->dst_config.pos.h,
396 FOURCC_STR(info->dst_config.format),
397 tdm_transform_str(transform), info->sync, info->flags);
402 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullObject)
404 const tbm_format *formats = (const tbm_format *)TDM_UT_INVALID_VALUE;
405 int count = TDM_UT_INVALID_VALUE;
406 if (tc_tdm_display_has_pp_capability(dpy))
407 EXPECT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
409 EXPECT_EQ(tdm_display_get_pp_available_formats(NULL, &formats, &count), TDM_ERROR_INVALID_PARAMETER);
410 EXPECT_EQ(formats, (const tbm_format *)TDM_UT_INVALID_VALUE);
411 EXPECT_EQ(count, TDM_UT_INVALID_VALUE);
414 TEST_P(TDMBackendPP, PPDispalyGetAvaiableFormatsNullOther)
416 if (tc_tdm_display_has_pp_capability(dpy)) {
417 EXPECT_EQ(PreparePP(), true);
418 EXPECT_EQ(tdm_display_get_pp_available_formats(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
422 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullObject)
424 int min_w = TDM_UT_INVALID_VALUE;
425 int min_h = TDM_UT_INVALID_VALUE;
426 int max_w = TDM_UT_INVALID_VALUE;
427 int max_h = TDM_UT_INVALID_VALUE;
428 int preferred_align = TDM_UT_INVALID_VALUE;
429 if (tc_tdm_display_has_pp_capability(dpy))
430 EXPECT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
432 EXPECT_EQ(tdm_display_get_pp_available_size(NULL, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_INVALID_PARAMETER);
433 EXPECT_EQ(min_w, TDM_UT_INVALID_VALUE);
434 EXPECT_EQ(min_h, TDM_UT_INVALID_VALUE);
435 EXPECT_EQ(max_w, TDM_UT_INVALID_VALUE);
436 EXPECT_EQ(max_h, TDM_UT_INVALID_VALUE);
437 EXPECT_EQ(preferred_align, TDM_UT_INVALID_VALUE);
440 TEST_P(TDMBackendPP, PPDispalyGetAvaiableSizeNullOther)
442 if (tc_tdm_display_has_pp_capability(dpy)) {
443 EXPECT_EQ(PreparePP(), true);
444 EXPECT_EQ(tdm_display_get_pp_available_size(dpy, NULL, NULL, NULL, NULL, NULL), TDM_ERROR_NONE);
448 TEST_P(TDMBackendPP, PPDispalyGetPreferredAlignVerticalNullObject)
450 if (tc_tdm_display_has_pp_capability(dpy)) {
451 EXPECT_EQ(PreparePP(), true);
452 EXPECT_EQ(tdm_display_get_pp_preferred_align_vertical(NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
456 TEST_P(TDMBackendPP, PPDestroy)
458 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
460 EXPECT_EQ(PreparePP(), true);
465 TEST_P(TDMBackendPP, PPDestroyNullObject)
467 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
469 tdm_pp_destroy(NULL);
472 TEST_P(TDMBackendPP, PPSetInfo)
474 /* tested in PPNoScaleNoTransformNoCSC */
477 TEST_P(TDMBackendPP, PPSetInfoNullObject)
479 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
482 memset(&info, 0, sizeof info);
483 EXPECT_EQ(tdm_pp_set_info(NULL, &info), TDM_ERROR_INVALID_PARAMETER);
486 TEST_P(TDMBackendPP, PPSetInfoNullOther)
488 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
490 EXPECT_EQ(PreparePP(), true);
491 EXPECT_EQ(tdm_pp_set_info(pp, NULL), TDM_ERROR_INVALID_PARAMETER);
495 _tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
497 bool *done = (bool*)user_data;
502 TEST_P(TDMBackendPP, PPSetDoneHandler)
504 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
506 EXPECT_EQ(PreparePP(), true);
507 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_NONE);
510 TEST_P(TDMBackendPP, PPSetDoneHandlerNullObject)
512 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
514 EXPECT_EQ(tdm_pp_set_done_handler(NULL, _tc_tdm_pp_done_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
517 TEST_P(TDMBackendPP, PPSetDoneHandlerNullOther)
519 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
521 EXPECT_EQ(PreparePP(), true);
522 EXPECT_EQ(tdm_pp_set_done_handler(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
525 TEST_P(TDMBackendPP, PPAttach)
527 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
529 EXPECT_EQ(PreparePP(), true);
531 for (int f = 0; f < format_count; f++) {
532 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
533 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
534 TDM_TRANSFORM_NORMAL), true);
536 for (int b = 0; b < 3; b++)
537 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
543 TEST_P(TDMBackendPP, PPAttachNullObject)
545 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
547 tbm_surface_h srcbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
548 tbm_surface_h dstbuf = (tbm_surface_h)TDM_UT_BUFFER_SIZE;
550 EXPECT_EQ(tdm_pp_attach(NULL, srcbuf, dstbuf), TDM_ERROR_INVALID_PARAMETER);
553 TEST_P(TDMBackendPP, PPAttachNullOther)
555 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
557 EXPECT_EQ(PreparePP(), true);
559 EXPECT_EQ(tdm_pp_attach(pp, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
562 TEST_P(TDMBackendPP, PPCommit)
564 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
566 EXPECT_EQ(PreparePP(), true);
568 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
571 TEST_P(TDMBackendPP, PPCommitNullOBject)
573 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
575 EXPECT_EQ(tdm_pp_commit(NULL), TDM_ERROR_INVALID_PARAMETER);
578 TEST_P(TDMBackendPP, PPConvertUnderlay)
580 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
582 FindLayerUnderPrimary();
584 if (!tc_tdm_output_is_hwc_enable(output))
585 EXPECT_NE(dst_layer, NULL);
587 for (int f = 0; f < dst_format_count; f++) {
590 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
592 EXPECT_EQ(PreparePP(), true);
594 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
595 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
596 TDM_TRANSFORM_NORMAL), true);
598 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
601 for (int b = 0; b < 3; b++) {
604 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
605 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
608 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
612 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
618 TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)",
619 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
624 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
630 TEST_P(TDMBackendPP, PPConvertOverlay)
632 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
634 FindLayerOverPrimary();
636 if (!tc_tdm_output_is_hwc_enable(output))
637 TDM_UT_SKIP_FLAG(dst_layer != NULL);
639 for (int f = 0; f < dst_format_count; f++) {
642 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
644 EXPECT_EQ(PreparePP(), true);
646 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
647 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
648 TDM_TRANSFORM_NORMAL), true);
650 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
653 for (int b = 0; b < 3; b++) {
656 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
657 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
660 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
664 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
670 TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)",
671 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
676 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
682 TEST_P(TDMBackendPP, PPConvertScale)
684 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
686 FindLayerUnderPrimary();
688 if (!tc_tdm_output_is_hwc_enable(output))
689 EXPECT_NE(dst_layer, NULL);
691 for (int f = 0; f < dst_format_count; f++) {
694 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
696 EXPECT_EQ(PreparePP(), true);
698 EXPECT_EQ(PrepareBuffers(640, 480, dst_formats[f],
699 mode->hdisplay, mode->vdisplay, dst_formats[f],
700 TDM_TRANSFORM_NORMAL), true);
702 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
705 for (int b = 0; b < 3; b++) {
708 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
709 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
712 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
716 snprintf(temp, sizeof temp, "f%d_b%d", f, b);
722 TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)",
723 FOURCC_STR(dst_formats[f]), pipe, dst_layer_index);
728 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
734 TEST_P(TDMBackendPP, PPConvertTransform)
736 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
737 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_TRANSFORM_ROTATION));
739 FindLayerUnderPrimary();
741 if (!tc_tdm_output_is_hwc_enable(output))
742 EXPECT_NE(dst_layer, NULL);
744 for (int f = 0; f < dst_format_count; f++) {
745 for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) {
748 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f]));
750 EXPECT_EQ(PreparePP(), true);
752 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
753 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f],
754 (tdm_transform)t), true);
756 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
759 for (int b = 0; b < 3; b++) {
762 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
763 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
766 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
770 snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t);
776 TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)",
777 FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index);
783 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
789 TEST_P(TDMBackendPP, PPConvertCSC)
791 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
792 TDM_UT_SKIP_FLAG(!(capabilities & TDM_PP_CAPABILITY_NO_CSC));
794 FindLayerUnderPrimary();
796 if (!tc_tdm_output_is_hwc_enable(output))
797 EXPECT_NE(dst_layer, NULL);
799 for (int df = 0; df < dst_format_count; df++) {
800 for (int sf = 0; sf < format_count; sf++) {
803 TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)",
804 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]));
806 EXPECT_EQ(PreparePP(), true);
808 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf],
809 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df],
810 TDM_TRANSFORM_NORMAL), true);
812 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE);
815 for (int b = 0; b < 3; b++) {
818 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
819 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
822 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
826 snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b);
832 TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)",
833 FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index);
839 if (tc_tdm_output_is_hwc_enable(output) && pp_formats) {
848 _tc_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
850 int *done = (int*)user_data;
855 /* some backend doens't implement correctly for attaching */
856 TEST_P(TDMBackendPP, DISABLED_PPAttachFewTimesInOneCommit)
858 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
860 EXPECT_EQ(PreparePP(), true);
865 snprintf(temp, sizeof temp, "%c%c%c%c", FOURCC_STR(formats[f]));
867 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
868 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
869 TDM_TRANSFORM_NORMAL), true);
871 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, &done), TDM_ERROR_NONE);
872 for (int b = 0; b < 3; b++)
873 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
875 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
878 EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
880 for (int b = 0; b < 3; b++)
886 TEST_P(TDMBackendPP, PPDestroyWithoutCommit)
888 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
890 EXPECT_EQ(PreparePP(), true);
894 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
895 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
896 TDM_TRANSFORM_NORMAL), true);
898 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
899 for (int b = 0; b < 3; b++)
900 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
908 TEST_P(TDMBackendPP, PPDestroyBeforeDone)
910 TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy));
912 EXPECT_EQ(PreparePP(), true);
916 EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
917 TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f],
918 TDM_TRANSFORM_NORMAL), true);
920 EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb2, NULL), TDM_ERROR_NONE);
921 for (int b = 0; b < 3; b++)
922 EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE);
924 EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE);
932 #ifdef TDM_UT_TEST_WITH_PARAMS
933 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
935 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
937 INSTANTIATE_TEST_CASE_P(TDMBackendPPParams,
939 Values(TDM_DEFAULT_MODULE));