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 #define TDM_UT_BACKEND_TEST_CNT 20
37 TDMBackendBasic::TDMBackendBasic()
45 for (int b = 0; b < 3; b++)
49 void TDMBackendBasic::SetUp(void)
53 TDMBackendEnv::SetUp();
55 dpy = tdm_display_init(&ret);
56 ASSERT_EQ(ret, TDM_ERROR_NONE);
59 ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
60 ASSERT_GE(output_count, 0);
62 if (output_count > 0) {
63 outputs = (tdm_output**)calloc(output_count, sizeof(tdm_output*));
64 ASSERT_NE(outputs, NULL);
66 for (int o = 0; o < output_count; o++) {
68 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
69 ASSERT_EQ(ret, TDM_ERROR_NONE);
70 ASSERT_NE(output, NULL);
75 for (int o = 0; o < output_count; o++) {
76 int old_layer_count = layer_count, count = TDM_UT_INVALID_VALUE;
79 if (tc_tdm_output_is_hwc_enable(outputs[o]))
82 ASSERT_EQ(tdm_output_get_layer_count(outputs[o], &count), TDM_ERROR_NONE);
86 layers = (tdm_layer**)realloc(layers, layer_count * sizeof(tdm_layer*));
87 ASSERT_NE(layers, NULL);
89 for (int l = 0; l < count; l++) {
90 tdm_layer *layer = tdm_output_get_layer(outputs[o], l, &ret);
91 ASSERT_NE(layer, NULL);
92 ASSERT_EQ(ret, TDM_ERROR_NONE);
93 layers[old_layer_count + l] = layer;
98 void TDMBackendBasic::TearDown(void)
100 tdm_display_deinit(dpy);
113 ASSERT_EQ(tbm_bufmgr_debug_get_ref_count(), 0);
115 TDMBackendEnv::TearDown();
118 void TDMBackendBasic::DestroyBuffers(void)
120 for (int b = 0; b < 3; b++) {
122 tbm_surface_destroy(buffers[b]);
128 tc_tdm_backend_getchar(void)
133 if (ch == '\n' || ch == '\r')
138 while (c != '\n' && c != EOF)
144 TEST_P(TDMBackendBasic, VerifyOutputObject)
147 int output_count = 0;
149 ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
150 TDM_UT_ASSERT_TRUE(output_count > 0, "output count(%d) should be greater than 0. Check display_get_outputs().");
152 for (int o = 0; o < output_count; o++) {
153 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
154 ASSERT_EQ(ret, TDM_ERROR_NONE);
155 TDM_UT_ASSERT_TRUE(output != NULL, "no output. (output: %d). Check display_get_outputs().", o);
159 TEST_P(TDMBackendBasic, VerifyLayerObject)
162 int output_count = 0;
164 ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
166 for (int o = 0; o < output_count; o++) {
167 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
168 ASSERT_EQ(ret, TDM_ERROR_NONE);
171 ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
172 TDM_UT_ASSERT_TRUE(layer_count > 0,
173 "layer count(%d) should be greater than 0. (output: %d). Check output_get_layers().",
176 for (int l = 0; l < layer_count; l++) {
177 tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
178 TDM_UT_ASSERT_TRUE(layer != NULL, "no layer. (output: %d, layer: %d). Check output_get_layers().", o, l);
183 TEST_P(TDMBackendBasic, VerifyOutputGetProperty)
186 int output_count = 0;
188 ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
190 for (int o = 0; o < output_count; o++) {
191 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
192 ASSERT_EQ(ret, TDM_ERROR_NONE);
194 const tdm_prop *props = NULL;
196 ASSERT_EQ(tdm_output_get_available_properties(output, &props, &prop_count), TDM_ERROR_NONE);
199 TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d). Check output_get_capability(), tdm_caps_output.", o);
201 for (int p = 0; p < prop_count; p++) {
203 value.s32 = TDM_UT_INVALID_VALUE;
204 ASSERT_EQ(tdm_output_get_property(output, props[p].id, &value), TDM_ERROR_NONE);
205 TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
206 "Getting a prop failed. (output: %d, prop_id: %d). Check output_get_property().",
212 TEST_P(TDMBackendBasic, VerifyLayerGetProperty)
215 int output_count = 0;
217 ASSERT_EQ(tdm_display_get_output_count(dpy, &output_count), TDM_ERROR_NONE);
219 for (int o = 0; o < output_count; o++) {
220 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
221 ASSERT_EQ(ret, TDM_ERROR_NONE);
224 ASSERT_EQ(tdm_output_get_layer_count(output, &layer_count), TDM_ERROR_NONE);
226 for (int l = 0; l < layer_count; l++) {
227 tdm_layer *layer = tdm_output_get_layer(output, l, &ret);
228 ASSERT_EQ(ret, TDM_ERROR_NONE);
230 const tdm_prop *props = NULL;
232 ASSERT_EQ(tdm_layer_get_available_properties(layer, &props, &prop_count), TDM_ERROR_NONE);
235 TDM_UT_ASSERT_TRUE(props != NULL, "no props. (output: %d, layer: %d). Check output_get_capability(), tdm_caps_output.", o, l);
237 for (int p = 0; p < prop_count; p++) {
239 value.s32 = TDM_UT_INVALID_VALUE;
240 ASSERT_EQ(tdm_layer_get_property(layer, props[p].id, &value), TDM_ERROR_NONE);
241 TDM_UT_ASSERT_TRUE(value.s32 != TDM_UT_INVALID_VALUE,
242 "Getting a prop failed. (output: %d, layer: %d, prop_id: %d). Check output_get_property().",
249 TEST_P(TDMBackendBasic, VerifyOutputSetMode)
251 for (int o = 0; o < output_count; o++) {
252 const tdm_output_mode *got_mode = NULL;
253 const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
254 const tdm_output_mode *set_mode = NULL;
255 const tdm_output_mode *best = NULL;
256 int count = TDM_UT_INVALID_VALUE;
258 if (!tc_tdm_output_is_connected(outputs[o]))
261 ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
262 TDM_UT_ASSERT_TRUE(count > 0, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
263 TDM_UT_ASSERT_TRUE(modes != NULL, "mode's count should be greater than 0. Check output_get_capability(), tdm_caps_output.");
265 for (int i = 0; i < count; i++) {
268 if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
269 set_mode = &modes[i];
271 if (!set_mode && best)
273 ASSERT_NE(set_mode, NULL);
275 ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
276 ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
277 TDM_UT_ASSERT_TRUE(set_mode == got_mode, "The mode which is set and got are different. Check output_set_mode(), output_get_mode()");
281 TEST_P(TDMBackendBasic, VerifyOutputSetDpms)
283 for (int o = 0; o < output_count; o++) {
284 const tdm_output_mode *got_mode = NULL;
285 const tdm_output_mode *modes = (const tdm_output_mode *)TDM_UT_INVALID_VALUE;
286 const tdm_output_mode *set_mode = NULL;
287 const tdm_output_mode *best = NULL;
288 int count = TDM_UT_INVALID_VALUE;
289 tdm_output_dpms got_dpms = TDM_OUTPUT_DPMS_OFF;
290 tdm_output_dpms set_dpms = TDM_OUTPUT_DPMS_ON;
292 if (!tc_tdm_output_is_connected(outputs[o]))
295 ASSERT_EQ(tdm_output_get_available_modes(outputs[o], &modes, &count), TDM_ERROR_NONE);
297 ASSERT_NE(modes, NULL);
299 for (int i = 0; i < count; i++) {
302 if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
303 set_mode = &modes[i];
305 if (!set_mode && best)
308 ASSERT_NE(set_mode, NULL);
309 ASSERT_EQ(tdm_output_set_mode(outputs[o], set_mode), TDM_ERROR_NONE);
310 ASSERT_EQ(tdm_output_get_mode(outputs[o], &got_mode), TDM_ERROR_NONE);
311 ASSERT_EQ(set_mode, got_mode);
313 ASSERT_EQ(tdm_output_set_dpms(outputs[o], set_dpms), TDM_ERROR_NONE);
314 ASSERT_EQ(tdm_output_get_dpms(outputs[o], &got_dpms), TDM_ERROR_NONE);
315 TDM_UT_ASSERT_TRUE(set_dpms == got_dpms, "The dpms value which is set and got are different. Check output_set_dpms(), output_get_dpms()");
319 TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrame)
321 for (int o = 0; o < output_count; o++) {
324 if (!tc_tdm_output_is_connected(outputs[o]))
327 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
328 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
330 layer = tc_tdm_output_get_primary_layer(outputs[o]);
331 ASSERT_NE(layer, NULL);
334 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
335 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
338 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
340 TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
342 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
343 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
348 TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowManyFrames)
350 for (int o = 0; o < output_count; o++) {
354 if (!tc_tdm_output_is_connected(outputs[o]))
357 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
358 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
360 layer = tc_tdm_output_get_primary_layer(outputs[o]);
361 ASSERT_NE(layer, NULL);
364 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 3, true), true);
366 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
367 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
368 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
369 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
370 usleep(40000); /* 40 ms */
372 if (next_buffer == 3)
378 TDM_UT_ASK_YNR("* Successed to display many frames to a primary layer? (output: %d)", o);
380 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
381 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
386 _tc_tdm_backend_output_commit_cb(tdm_output *output, unsigned int sequence,
387 unsigned int tv_sec, unsigned int tv_usec,
390 bool *done = (bool*)user_data;
395 TEST_P(TDMBackendBasic, VerifyPrimaryLayerShowOneFrameWithCommitHandler)
397 for (int o = 0; o < output_count; o++) {
400 if (!tc_tdm_output_is_connected(outputs[o]))
403 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
404 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
406 layer = tc_tdm_output_get_primary_layer(outputs[o]);
407 ASSERT_NE(layer, NULL);
410 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
411 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
415 TDM_UT_ASSERT_TRUE(tdm_output_commit(outputs[o], 0, _tc_tdm_backend_output_commit_cb, &done) == TDM_ERROR_NONE,
416 "Check output_commit(), output_set_commit_handler()");
418 TDM_UT_ASSERT_TRUE(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
419 "Check display_get_fd(), display_handle_events()");
421 TDM_UT_ASK_YNR("* Successed to display a frame to a primary layer? (output: %d)", o);
423 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
424 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
428 TEST_P(TDMBackendBasic, VerifyOverlayLayersShowOneFrame)
430 for (int o = 0; o < output_count; o++) {
433 if (!tc_tdm_output_is_connected(outputs[o]))
436 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
437 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
439 layer = tc_tdm_output_get_primary_layer(outputs[o]);
440 ASSERT_NE(layer, NULL);
442 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
443 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
446 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
447 usleep(40000); /* 40 ms */
450 for (int l = 0; l < layer_count; l++) {
453 if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
455 ASSERT_EQ(ret, TDM_ERROR_NONE);
456 if (tc_tdm_layer_is_primary_layer(layers[l]))
458 if (tc_tdm_layer_is_cursor_layer(layers[l]))
460 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true);
461 ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[0]), true);
465 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
467 TDM_UT_ASK_YNR("* Successed to display frames to all overlay layers? (output: %d)", o);
469 for (int l = 0; l < layer_count; l++)
470 ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
471 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
475 TEST_P(TDMBackendBasic, VerifyOverlayLayersShowManyFrames)
477 for (int o = 0; o < output_count; o++) {
480 if (!tc_tdm_output_is_connected(outputs[o]))
483 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
484 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
486 layer = tc_tdm_output_get_primary_layer(outputs[o]);
487 ASSERT_NE(layer, NULL);
489 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, false), true);
490 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
493 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
494 usleep(40000); /* 40 ms */
496 for (int l = 0; l < layer_count; l++) {
500 if (tdm_layer_get_output(layers[l], &ret) != outputs[o])
502 ASSERT_EQ(ret, TDM_ERROR_NONE);
503 if (tc_tdm_layer_is_primary_layer(layers[l]))
505 if (tc_tdm_layer_is_cursor_layer(layers[l]))
509 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 3, true), true);
511 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
512 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
513 ASSERT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[next_buffer]), true);
514 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
515 usleep(40000); /* 40 ms */
517 if (next_buffer == 3)
523 TDM_UT_ASK_YNR("* Successed to display many frames to a layer? (output: %d, layer: %d)", o, l);
525 ASSERT_EQ(tdm_layer_unset_buffer(layers[l]), TDM_ERROR_NONE);
526 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
527 usleep(40000); /* 40 ms */
532 TEST_P(TDMBackendBasic, DISABLED_VerifyCursorLayer)
537 _tc_tdm_backend_output_done_cb(tdm_output *output, unsigned int sequence,
538 unsigned int tv_sec, unsigned int tv_usec,
541 bool *done = (bool*)user_data;
546 TEST_P(TDMBackendBasic, VerifyOutputWaitVblank)
548 for (int o = 0; o < output_count; o++) {
551 if (!tc_tdm_output_is_connected(outputs[o]))
554 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
555 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
557 layer = tc_tdm_output_get_primary_layer(outputs[o]);
558 ASSERT_NE(layer, NULL);
560 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
561 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
564 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
567 for (int t = 1; t < 10; t++) {
568 double start, end, interval;
571 interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
574 start = tdm_helper_get_time();
575 TDM_UT_ASSERT_TRUE(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done) == TDM_ERROR_NONE,
576 "Check output_wait_vblank(), output_set_vblank_handler()");
578 TDM_UT_ASSERT_TRUE(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE,
579 "Check display_get_fd(), display_handle_events()");
580 end = tdm_helper_get_time();
582 /* "+ interval" consider the delay of socket communication between kernel and platform */
583 TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
584 "The vblank event should happen after %d vsync intervals(%d ms).\n"
585 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
586 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
587 TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
588 "The vblank event should happen after %d vsync intervals(%d ms).\n"
589 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
590 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
596 TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval)
598 for (int o = 0; o < output_count; o++) {
601 if (!tc_tdm_output_is_connected(outputs[o]))
604 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
605 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
607 layer = tc_tdm_output_get_primary_layer(outputs[o]);
608 ASSERT_NE(layer, NULL);
610 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
611 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
614 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
617 for (int t = 1; t < 10; t++) {
618 double start, end, interval;
621 interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
624 start = tdm_helper_get_time();
625 ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done), TDM_ERROR_NONE);
627 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
628 end = tdm_helper_get_time();
630 /* "+ interval" consider the delay of socket communication between kernel and platform */
631 TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
632 "The vblank event should happen after %d vsync intervals(%d ms).\n"
633 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
634 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
635 TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
636 "The vblank event should happen after %d vsync intervals(%d ms).\n"
637 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
638 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
643 TEST_P(TDMBackendBasic, VerifyOutputWaitVblankFewTimesInOneVblank)
645 for (int o = 0; o < output_count; o++) {
648 if (!tc_tdm_output_is_connected(outputs[o]))
651 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
652 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
654 layer = tc_tdm_output_get_primary_layer(outputs[o]);
655 ASSERT_NE(layer, NULL);
657 ASSERT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true);
658 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true);
661 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
664 for (int t = 1; t < 10; t++) {
665 double start, end, interval;
666 bool done1, done2, done3;
668 interval = tc_tdm_output_get_vblank_interval_time(outputs[o]);
670 done1 = done2 = done3 = false;
671 ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done1), TDM_ERROR_NONE);
672 ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done2), TDM_ERROR_NONE);
673 ASSERT_EQ(tdm_output_wait_vblank(outputs[o], t, 0, _tc_tdm_backend_output_done_cb, &done3), TDM_ERROR_NONE);
674 start = tdm_helper_get_time();
675 while (!done1 || !done2 || !done3)
676 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
677 end = tdm_helper_get_time();
679 /* "+ interval" consider the delay of socket communication between kernel and platform */
680 TDM_UT_ASSERT_TRUE((end - start) > (interval * (t - 1)),
681 "The vblank event should happen after %d vsync intervals(%d ms).\n"
682 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
683 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
684 TDM_UT_ASSERT_TRUE((end - start) < (interval * t + interval),
685 "The vblank event should happen after %d vsync intervals(%d ms).\n"
686 "\t But it happened at %d ms. Check output_wait_vblank(), output_set_vblank_handler()",
687 t, (int)(t * interval * 1000), (int)((end - start) * 1000));
692 TEST_P(TDMBackendBasic, VerifyPPObject)
697 if (!tc_tdm_display_has_pp_capability(dpy)) {
698 TDM_UT_INFO("PP not supported");
702 pp = tdm_display_create_pp(dpy, &ret);
703 TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "can't create a PP object. Check display_create_pp()");
704 TDM_UT_ASSERT_TRUE(pp != NULL, "can't create a PP object. Check display_create_pp()");
709 TEST_P(TDMBackendBasic, VerifyPPCapabilities)
711 tdm_pp_capability capabilities = (tdm_pp_capability)0;
713 if (!tc_tdm_display_has_pp_capability(dpy)) {
714 TDM_UT_INFO("PP not supported");
718 TDM_UT_ASSERT_TRUE(tdm_display_get_pp_capabilities(dpy, &capabilities) == TDM_ERROR_NONE,
719 "Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
720 TDM_UT_ASSERT_TRUE(capabilities != (tdm_pp_capability)0,
721 "PP has no capability. Check display_get_pp_capability(), tdm_caps_pp, tdm_pp_capability.");
724 TEST_P(TDMBackendBasic, VerifyPPAvaiableSize)
726 if (!tc_tdm_display_has_pp_capability(dpy)) {
727 TDM_UT_INFO("PP not supported");
735 int preferred_align = 0;
736 ASSERT_EQ(tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
741 ASSERT_NE(preferred_align, 0);
744 TEST_P(TDMBackendBasic, VerifyPPAvaiableFormats)
746 if (!tc_tdm_display_has_pp_capability(dpy)) {
747 TDM_UT_INFO("PP not supported");
751 const tbm_format *formats = NULL;
752 int format_count = 0;
753 TDM_UT_ASSERT_TRUE(tdm_display_get_pp_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
754 "Check display_get_pp_capability(), tdm_caps_pp");
755 TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_pp_capability(), tdm_caps_pp.");
756 TDM_UT_ASSERT_TRUE(format_count > 0, "Format count should be greater than 0. Check display_get_pp_capability(), tdm_caps_pp.");
759 TEST_P(TDMBackendBasic, VerifyCaptureObject)
761 if (!tc_tdm_display_has_capture_capability(dpy)) {
762 TDM_UT_INFO("Capture not supported.");
766 for (int o = 0; o < output_count; o++) {
767 tdm_capture *capture;
770 unsigned int has_capability = 0;
771 ASSERT_EQ(tdm_output_has_capture_capability(outputs[o], &has_capability), TDM_ERROR_NONE);
772 if (!has_capability) {
773 TDM_UT_INFO("Capture not supported. (output: %d)", o);
777 if (!tc_tdm_output_is_connected(outputs[o]))
780 capture = tdm_output_create_capture(outputs[o], &ret);
781 TDM_UT_ASSERT_TRUE(ret == TDM_ERROR_NONE, "Can't create a capture object. Check output_create_capture().");
782 TDM_UT_ASSERT_TRUE(capture != NULL, "Can't create a capture object. Check output_create_capture().");
784 tdm_capture_destroy(capture);
788 TEST_P(TDMBackendBasic, VerifyCaptureAvaiableSize)
790 if (!tc_tdm_display_has_capture_capability(dpy)) {
791 TDM_UT_INFO("Capture not supported.");
799 int preferred_align = 0;
800 ASSERT_EQ(tdm_display_get_capture_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align), TDM_ERROR_NONE);
805 ASSERT_NE(preferred_align, 0);
808 TEST_P(TDMBackendBasic, VerifyCaptureAvaiableFormats)
810 if (!tc_tdm_display_has_capture_capability(dpy)) {
811 TDM_UT_INFO("Capture not supported.");
815 const tbm_format *formats = NULL;
816 int format_count = 0;
817 TDM_UT_ASSERT_TRUE(tdm_display_get_capture_available_formats(dpy, &formats, &format_count) == TDM_ERROR_NONE,
818 "Check display_get_capture_capability(), tdm_caps_capture.");
819 TDM_UT_ASSERT_TRUE(formats != NULL, "Should have a format table. Check display_get_capture_capability(), tdm_caps_capture.");
820 TDM_UT_ASSERT_TRUE(format_count > 0, "The format count should be greater than 0. Check display_get_capture_capability(), tdm_caps_capture.");
823 #ifdef TDM_UT_TEST_WITH_PARAMS
824 INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
826 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
828 INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams,
830 Values(TDM_DEFAULT_MODULE));
833 TEST_P(TDMBackendDisplay, VerifyPirmaryLayerFormat)
835 for (int o = 0; o < output_count; o++) {
840 const tbm_format *formats;
841 int format_count = 0;
842 const tdm_output_mode *mode = NULL;
843 unsigned int flags = 0;
845 if (!tc_tdm_output_is_connected(outputs[o]))
848 layer = tc_tdm_output_get_primary_layer(outputs[o]);
849 ASSERT_NE(layer, NULL);
851 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
852 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
854 for (int f = 0; f < format_count; f++) {
855 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
856 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
857 ASSERT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE);
858 ASSERT_NE(mode, NULL);
861 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
862 ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
864 /* set buffer & commit for 60 times */
865 for (int t = 0; t < 60; t++) {
866 tbm_surface_h displaying_buffer;
867 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
869 ASSERT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
871 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
872 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
873 ASSERT_EQ(ret, TDM_ERROR_NONE);
874 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
876 if (next_buffer == 3)
882 TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a primary layer? (output: %d)", FOURCC_STR(formats[f]), o);
887 TEST_P(TDMBackendDisplay, VerifyOverlayLayerFormat)
889 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
891 for (int l = 0; l < layer_count; l++) {
897 const tbm_format *formats;
898 int format_count = 0;
899 const tdm_output_mode *mode = NULL;
900 unsigned int flags = 0;
901 unsigned int pipe = 0;
905 output = tdm_layer_get_output(layer, &ret);
906 ASSERT_EQ(ret, TDM_ERROR_NONE);
908 if (!tc_tdm_output_is_connected(output))
910 if (tc_tdm_layer_is_primary_layer(layer))
912 if (tc_tdm_layer_is_cursor_layer(layer))
915 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
917 TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
919 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
920 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
921 ASSERT_NE(mode, NULL);
923 ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
925 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
927 for (int f = 0; f < format_count; f++) {
929 TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
930 ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
932 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
933 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
934 tbm_surface_h displaying_buffer;
935 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
937 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
939 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
940 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
941 ASSERT_EQ(ret, TDM_ERROR_NONE);
942 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
944 if (next_buffer == 3)
948 TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a layer? (output: %d, layer: %d)", FOURCC_STR(formats[f]), pipe, l);
953 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
957 TEST_P(TDMBackendDisplay, VerifyOverlayLayerSize)
959 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
961 for (int l = 0; l < layer_count; l++) {
967 const tbm_format *formats;
968 int format_count = 0;
969 const tdm_output_mode *mode = NULL;
970 unsigned int flags = 0;
971 unsigned int pipe = 0;
975 output = tdm_layer_get_output(layer, &ret);
976 ASSERT_EQ(ret, TDM_ERROR_NONE);
978 if (!tc_tdm_output_is_connected(output))
980 if (tc_tdm_layer_is_primary_layer(layer))
982 if (tc_tdm_layer_is_cursor_layer(layer))
985 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
987 TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
989 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
990 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
991 ASSERT_NE(mode, NULL);
993 ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
995 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
997 for (int f = 0; f < format_count; f++) {
998 int diffw = mode->hdisplay / (format_count + 2);
999 int diffh = mode->vdisplay / (format_count + 2);
1000 int w = mode->hdisplay - diffw * (f + 1);
1001 int h = mode->vdisplay - diffh * (f + 1);
1003 TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
1004 ASSERT_EQ(tc_tdm_buffer_create(w, h, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
1006 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
1007 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
1008 tbm_surface_h displaying_buffer;
1009 ASSERT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true);
1011 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
1013 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1014 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
1015 ASSERT_EQ(ret, TDM_ERROR_NONE);
1016 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
1018 if (next_buffer == 3)
1024 TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' small size(%dx%d) frames to a layer? (output: %d, layer: %d)",
1025 FOURCC_STR(formats[f]), w, h, pipe, l);
1028 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1032 TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale)
1034 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
1036 for (int l = 0; l < layer_count; l++) {
1040 int next_buffer = 0;
1042 const tbm_format *formats;
1043 int format_count = 0;
1044 const tdm_output_mode *mode = NULL;
1045 unsigned int flags = 0;
1046 unsigned int pipe = 0;
1050 output = tdm_layer_get_output(layer, &ret);
1051 ASSERT_EQ(ret, TDM_ERROR_NONE);
1053 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
1055 if (!tc_tdm_output_is_connected(output))
1057 if (tc_tdm_layer_is_primary_layer(layer))
1059 if (tc_tdm_layer_is_cursor_layer(layer))
1061 if (!tc_tdm_layer_support_scale(layer)) {
1062 TDM_UT_INFO("no scale capability. (output: %d, layer: %d)", pipe, l);
1066 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
1067 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
1068 ASSERT_NE(mode, NULL);
1070 ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
1072 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
1074 for (int f = 0; f < format_count; f++) {
1076 TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f]));
1077 ASSERT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
1079 tdm_info_layer info;
1080 memset(&info, 0, sizeof info);
1081 info.src_config.size.h = TDM_UT_BUFFER_SIZE;
1082 info.src_config.size.v = TDM_UT_BUFFER_SIZE;
1083 info.src_config.pos.x = 0;
1084 info.src_config.pos.y = 0;
1085 info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
1086 info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
1087 info.src_config.format = formats[f];
1090 info.dst_pos.w = mode->hdisplay;
1091 info.dst_pos.h = mode->vdisplay;
1092 info.transform = TDM_TRANSFORM_NORMAL;
1093 ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
1095 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
1096 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
1097 tbm_surface_h displaying_buffer;
1098 ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
1100 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
1102 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1103 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
1104 ASSERT_EQ(ret, TDM_ERROR_NONE);
1105 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
1107 if (next_buffer == 3)
1113 TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' small size(%dx%d) frames to fullsreen? (output: %d, layer: %d)",
1114 FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
1117 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1121 TEST_P(TDMBackendDisplay, VerifyOverlayLayerMovePosition)
1123 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
1125 for (int l = 0; l < layer_count; l++) {
1129 int next_buffer = 0;
1131 const tbm_format *formats;
1132 int format_count = 0;
1133 const tdm_output_mode *mode = NULL;
1134 unsigned int flags = 0;
1135 unsigned int pipe = 0;
1139 output = tdm_layer_get_output(layer, &ret);
1140 ASSERT_EQ(ret, TDM_ERROR_NONE);
1142 if (!tc_tdm_output_is_connected(output))
1144 if (tc_tdm_layer_is_primary_layer(layer))
1146 if (tc_tdm_layer_is_cursor_layer(layer))
1149 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
1151 TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
1153 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
1154 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
1155 ASSERT_NE(mode, NULL);
1157 ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
1159 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
1161 for (int f = 0; f < format_count; f++) {
1163 TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
1164 ASSERT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
1166 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
1167 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
1168 tbm_surface_h displaying_buffer;
1170 tdm_info_layer info;
1171 memset(&info, 0, sizeof info);
1172 info.src_config.size.h = TDM_UT_BUFFER_SIZE;
1173 info.src_config.size.v = TDM_UT_BUFFER_SIZE;
1174 info.src_config.pos.x = 0;
1175 info.src_config.pos.y = 0;
1176 info.src_config.pos.w = TDM_UT_BUFFER_SIZE;
1177 info.src_config.pos.h = TDM_UT_BUFFER_SIZE;
1178 info.src_config.format = formats[f];
1179 info.dst_pos.x = ((mode->hdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
1180 info.dst_pos.y = ((mode->vdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t;
1181 info.dst_pos.w = TDM_UT_BUFFER_SIZE;
1182 info.dst_pos.h = TDM_UT_BUFFER_SIZE;
1183 info.transform = TDM_TRANSFORM_NORMAL;
1184 ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
1186 ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
1188 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
1190 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1191 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
1192 ASSERT_EQ(ret, TDM_ERROR_NONE);
1193 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
1195 if (next_buffer == 3)
1201 TDM_UT_ASK_YNR("* Successed to move '%c%c%c%c' small size(%dx%d) frames on screen? (output: %d, layer: %d)",
1202 FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l);
1205 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1209 TEST_P(TDMBackendDisplay, VerifyOverlayLayerCrop)
1211 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, false), true);
1213 for (int l = 0; l < layer_count; l++) {
1217 int next_buffer = 0;
1219 const tbm_format *formats;
1220 int format_count = 0;
1221 const tdm_output_mode *mode = NULL;
1222 unsigned int flags = 0;
1223 unsigned int pipe = 0;
1227 output = tdm_layer_get_output(layer, &ret);
1228 ASSERT_EQ(ret, TDM_ERROR_NONE);
1230 ASSERT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE);
1232 if (!tc_tdm_output_is_connected(output))
1234 if (tc_tdm_layer_is_primary_layer(layer))
1236 if (tc_tdm_layer_is_cursor_layer(layer))
1238 if (tc_tdm_layer_support_no_crop(layer)) {
1239 TDM_UT_INFO("no crop capability. (output: %d, layer: %d)", pipe, l);
1243 TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l);
1245 ASSERT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE);
1246 ASSERT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE);
1247 ASSERT_NE(mode, NULL);
1249 ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
1251 ASSERT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE);
1253 for (int f = 0; f < format_count; f++) {
1255 TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f]));
1256 ASSERT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true);
1258 tdm_info_layer info;
1259 memset(&info, 0, sizeof info);
1260 info.src_config.size.h = mode->hdisplay;
1261 info.src_config.size.v = mode->vdisplay;
1262 info.src_config.pos.x = mode->hdisplay / 2;
1263 info.src_config.pos.y = mode->vdisplay / 2;
1264 info.src_config.pos.w = info.src_config.size.h / 2;
1265 info.src_config.pos.h = info.src_config.size.v / 2;
1266 info.src_config.format = formats[f];
1267 info.dst_pos.x = info.src_config.pos.x;
1268 info.dst_pos.y = info.src_config.pos.y;
1269 info.dst_pos.w = info.src_config.pos.w;
1270 info.dst_pos.h = info.src_config.pos.h;
1271 info.transform = TDM_TRANSFORM_NORMAL;
1272 ASSERT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE);
1274 /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */
1275 for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) {
1276 tbm_surface_h displaying_buffer;
1277 ASSERT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE);
1279 ASSERT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE);
1281 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1282 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
1283 ASSERT_EQ(ret, TDM_ERROR_NONE);
1284 ASSERT_EQ(displaying_buffer, buffers[next_buffer]);
1286 if (next_buffer == 3)
1292 TDM_UT_ASK_YNR("* Successed to crop '%c%c%c%c' frames and display it? (output: %d, layer: %d)",
1293 FOURCC_STR(formats[f]), pipe, l);
1296 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1300 /* should be debugged int emulator kernel */
1301 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOnToOff)
1303 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
1305 for (int o = 0; o < output_count; o++) {
1306 if (!tc_tdm_output_is_connected(outputs[o]))
1309 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
1313 /* should be debugged int emulator kernel */
1314 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsFromOffToOn)
1316 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
1318 for (int o = 0; o < output_count; o++) {
1319 if (!tc_tdm_output_is_connected(outputs[o]))
1322 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
1323 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
1327 /* should be debugged int emulator kernel */
1328 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOnBeforeSet)
1330 for (int o = 0; o < output_count; o++) {
1331 if (!tc_tdm_output_is_connected(outputs[o]))
1334 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
1335 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE);
1339 /* should be debugged int emulator kernel */
1340 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffBeforeSet)
1342 for (int o = 0; o < output_count; o++) {
1343 if (!tc_tdm_output_is_connected(outputs[o]))
1346 ASSERT_EQ(tc_tdm_output_mode_setting(outputs[o]), true);
1347 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
1351 /* should be debugged int emulator kernel */
1352 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithoutCommit)
1354 for (int o = 0; o < output_count; o++) {
1355 if (!tc_tdm_output_is_connected(outputs[o]))
1358 ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
1360 tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
1361 ASSERT_NE(layer, NULL);
1363 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1365 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
1369 /* should be debugged int emulator kernel */
1370 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsToOffAfterUnsetWithCommit)
1372 for (int o = 0; o < output_count; o++) {
1373 if (!tc_tdm_output_is_connected(outputs[o]))
1376 ASSERT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true);
1378 tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
1379 ASSERT_NE(layer, NULL);
1381 ASSERT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE);
1382 ASSERT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE);
1384 ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE);
1388 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputSetDpmsAsync)
1392 TEST_P(TDMBackendDisplay, VerifyLayerGetInfo)
1394 ASSERT_EQ(tc_tdm_output_prepare_all_output(dpy, outputs, output_count, true), true);
1396 for (int o = 0; o < output_count; o++) {
1397 if (!tc_tdm_output_is_connected(outputs[o]))
1400 tbm_surface_h displaying_buffer;
1402 tdm_info_layer info, temp;
1403 tdm_layer *layer = tc_tdm_output_get_primary_layer(outputs[o]);
1404 ASSERT_NE(layer, NULL);
1406 displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret);
1407 ASSERT_NE(displaying_buffer, NULL);
1408 ASSERT_EQ(ret, TDM_ERROR_NONE);
1409 ASSERT_EQ(tc_tdm_layer_fill_info(layer, displaying_buffer, NULL, &info), true);
1410 ASSERT_EQ(tdm_layer_get_info(layer, &temp), TDM_ERROR_NONE);
1411 ASSERT_EQ(memcmp(&info, &temp, sizeof info), 0);
1415 TEST_P(TDMBackendDisplay, DISABLED_VerifyOutputWaitVblankBeforeDpmsOff) /* TODO */
1419 TEST_P(TDMBackendDisplay, DISABLED_VerifyLayerSetVideoPos)
1423 #ifdef TDM_UT_TEST_WITH_PARAMS
1424 INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
1426 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
1428 INSTANTIATE_TEST_CASE_P(TDMBackendDisplayParams,
1430 Values(TDM_DEFAULT_MODULE));