1 /**************************************************************************
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
7 * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8 * JinYoung Jeon <jy0.jeon@samsung.com>,
9 * Taeheon Kim <th908.kim@samsung.com>,
10 * YoungJun Cho <yj44.cho@samsung.com>,
11 * SooChan Lim <sc1.lim@samsung.com>,
12 * Boram Park <sc1.lim@samsung.com>
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sub license, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 **************************************************************************/
40 #include "tdm_private.h"
42 pthread_mutex_t tdm_mutex_check_lock = PTHREAD_MUTEX_INITIALIZER;
44 const char *tdm_mutex_lock_func;
45 int tdm_mutex_lock_line;
46 const char *tdm_mutex_unlock_func;
47 int tdm_mutex_unlock_line;
50 static tdm_private_layer *
51 _tdm_display_find_private_layer(tdm_private_output *private_output,
52 tdm_layer *layer_backend)
54 tdm_private_layer *private_layer = NULL;
56 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
57 if (private_layer->layer_backend == layer_backend)
64 INTERN tdm_private_output *
65 tdm_display_find_private_output(tdm_private_display *private_display, tdm_output *output_backend)
67 tdm_private_backend *private_backend = NULL;
68 tdm_private_output *private_output = NULL;
70 LIST_FOR_EACH_ENTRY(private_backend, &private_display->backend_list, link) {
71 LIST_FOR_EACH_ENTRY(private_output, &private_backend->output_list, link) {
72 if (private_output->output_backend == output_backend)
73 return private_output;
81 tdm_display_find_output_stamp(tdm_private_display *private_display, double stamp)
83 tdm_private_backend *private_backend = NULL;
84 tdm_private_output *private_output = NULL;
86 LIST_FOR_EACH_ENTRY(private_backend, &private_display->backend_list, link) {
87 LIST_FOR_EACH_ENTRY(private_output, &private_backend->output_list, link) {
88 if (private_output->stamp == stamp)
89 return private_output;
97 _tdm_display_destroy_caps_pp(tdm_caps_pp *caps_pp)
100 free(caps_pp->formats);
102 memset(caps_pp, 0, sizeof(tdm_caps_pp));
106 _tdm_display_destroy_caps_capture(tdm_caps_capture *caps_capture)
108 if (caps_capture->formats)
109 free(caps_capture->formats);
111 memset(caps_capture, 0, sizeof(tdm_caps_capture));
115 _tdm_display_destroy_caps_layer(tdm_caps_layer *caps_layer)
117 if (caps_layer->formats)
118 free(caps_layer->formats);
120 if (caps_layer->props)
121 free(caps_layer->props);
123 memset(caps_layer, 0, sizeof(tdm_caps_layer));
127 _tdm_display_destroy_caps_output(tdm_caps_output *caps_output)
129 if (caps_output->modes)
130 free(caps_output->modes);
132 if (caps_output->props)
133 free(caps_output->props);
135 memset(caps_output, 0, sizeof(tdm_caps_output));
139 _tdm_display_destroy_private_layer(tdm_private_layer *private_layer)
141 tdm_private_capture *c = NULL, *cc = NULL;
143 tdm_layer_unset_buffer_internal(private_layer);
145 LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_layer->capture_list, link)
146 tdm_capture_destroy_internal(c);
148 _tdm_display_destroy_caps_layer(&private_layer->caps);
150 /* when destroying layer, someone could check if layer is valid. So delete
151 * the layer's link at last.
153 LIST_DEL(&private_layer->link);
159 _tdm_display_destroy_private_output(tdm_private_output *private_output)
161 tdm_private_display *private_display = private_output->private_display;
162 tdm_private_layer *l = NULL, *ll = NULL;
163 tdm_private_hwc_window *hw = NULL, *hww = NULL;
164 tdm_private_capture *c = NULL, *cc = NULL;
165 tdm_private_output_vblank_handler *v = NULL, *vv = NULL;
166 tdm_private_output_commit_handler *om = NULL, *omm = NULL;
167 tdm_private_layer_commit_handler *lm = NULL, *lmm = NULL;
168 tdm_private_output_change_handler *h = NULL, *hh = NULL;
170 free(private_output->layers_ptr);
172 if (private_output->vblank_timeout_timer)
173 tdm_event_loop_source_remove(private_output->vblank_timeout_timer);
175 LIST_FOR_EACH_ENTRY_SAFE(v, vv, &private_output->vblank_handler_list, link) {
180 LIST_FOR_EACH_ENTRY_SAFE(om, omm, &private_output->output_commit_handler_list, link) {
185 LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &private_output->layer_commit_handler_list, link) {
190 LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &private_output->pending_commit_handler_list, link) {
195 LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list, link) {
197 tdm_thread_cb_remove(h->private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, h);
201 if (private_output->vblank) {
202 /* tdm_vblank APIs is for server. it should be called in unlock status*/
203 _pthread_mutex_unlock(&private_display->lock);
204 tdm_vblank_destroy(private_output->vblank);
205 _pthread_mutex_lock(&private_display->lock);
208 if (private_output->ttrace_vblank) {
209 /* tdm_vblank APIs is for server. it should be called in unlock status*/
210 _pthread_mutex_unlock(&private_display->lock);
211 tdm_vblank_destroy(private_output->ttrace_vblank);
212 _pthread_mutex_lock(&private_display->lock);
215 LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_output->capture_list, link)
216 tdm_capture_destroy_internal(c);
218 LIST_FOR_EACH_ENTRY_SAFE(hw, hww, &private_output->hwc_window_list, link)
219 tdm_hwc_window_destroy_internal(hw);
221 LIST_FOR_EACH_ENTRY_SAFE(l, ll, &private_output->layer_list, link)
222 _tdm_display_destroy_private_layer(l);
224 _tdm_display_destroy_caps_output(&private_output->caps);
226 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_NEED_VALIDATE, NULL,
227 tdm_output_need_validate_handler_thread, NULL);
228 tdm_event_loop_source_remove(private_output->need_validate.event_source);
229 close(private_output->need_validate.event_fd);
231 /* when destroying output, vblank objects are also destroyed. vblank checks
232 * if output object is valid. So delete the output's link at last.
234 LIST_DEL(&private_output->link);
236 private_output->stamp = 0;
237 free(private_output);
241 _tdm_display_destroy_private_display(tdm_private_display *private_display)
243 tdm_private_backend *private_backend = NULL, *bb = NULL;
244 tdm_private_output *o = NULL, *oo = NULL;
245 tdm_private_pp *p = NULL, *pp = NULL;
247 LIST_FOR_EACH_ENTRY_SAFE(private_backend, bb, &private_display->backend_list, link) {
248 LIST_FOR_EACH_ENTRY_SAFE(p, pp, &private_backend->pp_list, link) {
249 tdm_pp_destroy_internal(p);
252 LIST_FOR_EACH_ENTRY_SAFE(o, oo, &private_backend->output_list, link) {
253 _tdm_display_destroy_private_output(o);
256 _tdm_display_destroy_caps_pp(&private_backend->caps_pp);
257 _tdm_display_destroy_caps_capture(&private_backend->caps_capture);
259 private_backend->capabilities = 0;
260 private_backend->caps_display.max_layer_count = 0;
262 if (private_backend->outputs) {
263 free(private_backend->outputs);
264 private_backend->outputs = NULL;
270 _tdm_display_update_caps_pp(tdm_private_backend *private_backend, tdm_caps_pp *caps)
272 tdm_func_display *func_display;
275 func_display = &private_backend->func_display;
277 if (!func_display->display_get_pp_capability) {
278 TDM_ERR("backend(%s) no display_get_pp_capability()", private_backend->module_data->name);
279 return TDM_ERROR_BAD_MODULE;
282 ret = func_display->display_get_pp_capability(private_backend->bdata, caps);
283 if (ret != TDM_ERROR_NONE) {
284 TDM_ERR("backend(%s) display_get_pp_capability() failed", private_backend->module_data->name);
285 return TDM_ERROR_BAD_MODULE;
288 return TDM_ERROR_NONE;
292 _tdm_display_update_caps_capture(tdm_private_backend *private_backend, tdm_caps_capture *caps)
294 tdm_func_display *func_display;
297 func_display = &private_backend->func_display;
299 if (!func_display->display_get_capture_capability) {
300 TDM_ERR("backend(%s) no display_get_capture_capability()", private_backend->module_data->name);
301 return TDM_ERROR_BAD_MODULE;
304 ret = func_display->display_get_capture_capability(private_backend->bdata, caps);
305 if (ret != TDM_ERROR_NONE) {
306 TDM_ERR("backend(%s) display_get_capture_capability() failed", private_backend->module_data->name);
307 return TDM_ERROR_BAD_MODULE;
310 return TDM_ERROR_NONE;
314 _tdm_display_update_caps_layer(tdm_private_backend *private_backend,
315 tdm_layer *layer_backend, tdm_caps_layer *caps)
317 tdm_func_layer *func_layer = &private_backend->func_layer;
320 if (!func_layer->layer_get_capability) {
321 TDM_ERR("backend(%s) no layer_get_capability()", private_backend->module_data->name);
322 return TDM_ERROR_BAD_MODULE;
325 ret = func_layer->layer_get_capability(layer_backend, caps);
326 if (ret != TDM_ERROR_NONE) {
327 TDM_ERR("backend(%s) layer_get_capability() failed", private_backend->module_data->name);
328 return TDM_ERROR_BAD_MODULE;
331 return TDM_ERROR_NONE;
335 _tdm_display_update_caps_output(tdm_private_backend *private_backend, int pipe,
336 tdm_output *output_backend, tdm_caps_output *caps)
338 tdm_func_output *func_output = &private_backend->func_output;
339 char temp[TDM_NAME_LEN];
343 if (!func_output->output_get_capability) {
344 TDM_ERR("backend(%s) no output_get_capability()", private_backend->module_data->name);
345 return TDM_ERROR_BAD_MODULE;
348 stamp = tdm_helper_get_time();
349 ret = func_output->output_get_capability(output_backend, caps);
350 TDM_DBG("backend(%s) backend output_get_capability() time: %.3f ms",
351 private_backend->module_data->name, (tdm_helper_get_time() - stamp) * 1000.0);
353 if (ret != TDM_ERROR_NONE) {
354 TDM_ERR("backend(%s) output_get_capability() failed", private_backend->module_data->name);
355 return TDM_ERROR_BAD_MODULE;
358 /* FIXME: Use model for tdm client to distinguish amoung outputs */
359 snprintf(temp, TDM_NAME_LEN, "%s-%d", caps->model, pipe);
360 snprintf(caps->model, TDM_NAME_LEN, "%s", temp);
362 return TDM_ERROR_NONE;
366 _tdm_display_update_layer(tdm_private_output *private_output,
367 tdm_layer *layer_backend, int index)
369 tdm_private_layer *private_layer;
372 private_layer = _tdm_display_find_private_layer(private_output, layer_backend);
373 if (!private_layer) {
374 private_layer = calloc(1, sizeof(tdm_private_layer));
375 TDM_RETURN_VAL_IF_FAIL(private_layer != NULL, TDM_ERROR_OUT_OF_MEMORY);
377 LIST_ADDTAIL(&private_layer->link, &private_output->layer_list);
378 private_layer->index = index;
379 private_layer->private_backend = private_output->private_backend;
380 private_layer->private_display = private_output->private_display;
381 private_layer->private_output = private_output;
382 private_layer->layer_backend = layer_backend;
384 LIST_INITHEAD(&private_layer->capture_list);
386 private_layer->usable = 1;
388 _tdm_display_destroy_caps_layer(&private_layer->caps);
390 ret = _tdm_display_update_caps_layer(private_layer->private_backend, layer_backend,
391 &private_layer->caps);
392 if (ret != TDM_ERROR_NONE)
395 return TDM_ERROR_NONE;
397 _tdm_display_destroy_private_layer(private_layer);
402 tdm_display_update_output(tdm_private_backend *private_backend,
403 tdm_output *output_backend, int pipe)
405 tdm_func_output *func_output = &private_backend->func_output;
406 tdm_private_output *private_output = NULL;
407 tdm_layer **layers = NULL;
408 int layer_count = 0, i;
411 private_output = tdm_display_find_private_output(private_backend->private_display, output_backend);
412 if (!private_output) {
413 private_output = calloc(1, sizeof(tdm_private_output));
414 TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OUT_OF_MEMORY);
416 private_output->stamp = tdm_helper_get_time();
417 while (tdm_display_find_output_stamp(private_backend->private_display, private_output->stamp))
418 private_output->stamp++;
420 LIST_ADDTAIL(&private_output->link, &private_backend->output_list);
422 private_output->private_backend = private_backend;
423 private_output->private_display = private_backend->private_display;
424 private_output->current_dpms_value = TDM_OUTPUT_DPMS_OFF;
425 private_output->output_backend = output_backend;
426 private_output->pipe = pipe;
427 private_output->index = pipe;
429 LIST_INITHEAD(&private_output->layer_list);
430 LIST_INITHEAD(&private_output->hwc_window_list);
431 LIST_INITHEAD(&private_output->capture_list);
432 LIST_INITHEAD(&private_output->vblank_handler_list);
433 LIST_INITHEAD(&private_output->output_commit_handler_list);
434 LIST_INITHEAD(&private_output->layer_commit_handler_list);
435 LIST_INITHEAD(&private_output->pending_commit_handler_list);
436 LIST_INITHEAD(&private_output->change_handler_list);
438 if (func_output->output_set_status_handler) {
439 func_output->output_set_status_handler(private_output->output_backend,
440 tdm_output_cb_status,
442 private_output->regist_change_cb = 1;
445 ret = _tdm_display_update_caps_output(private_backend, pipe, output_backend,
446 &private_output->caps);
447 if (ret != TDM_ERROR_NONE)
450 tdm_caps_output new_caps;
452 ret = _tdm_display_update_caps_output(private_backend, pipe, output_backend,
454 if (ret != TDM_ERROR_NONE)
457 /* FIXME: This is very ugly. need to fix after the TDM ABI is changed. */
458 if (private_output->caps.status != new_caps.status) {
459 _tdm_display_destroy_caps_output(&private_output->caps);
460 private_output->caps = new_caps;
461 private_output->current_mode = NULL;
463 tdm_output_mode *old_modes = private_output->caps.modes;
464 unsigned int old_mode_count = private_output->caps.mode_count;
466 free(new_caps.modes);
467 new_caps.modes = old_modes;
468 new_caps.mode_count = old_mode_count;
469 if (private_output->caps.props)
470 free(private_output->caps.props);
471 private_output->caps = new_caps;
475 layers = func_output->output_get_layers(output_backend, &layer_count, &ret);
476 if (ret != TDM_ERROR_NONE)
479 for (i = 0; i < layer_count; i++) {
480 ret = _tdm_display_update_layer(private_output, layers[i], i);
481 if (ret != TDM_ERROR_NONE)
487 return TDM_ERROR_NONE;
489 _tdm_display_destroy_private_output(private_output);
495 _tdm_display_set_main_first(tdm_output **outputs, int index)
497 tdm_output *output_tmp = NULL;
502 output_tmp = outputs[0];
503 outputs[0] = outputs[index];
504 outputs[index] = output_tmp;
510 _tdm_display_get_ordered_outputs(tdm_private_backend *private_backend, int *count)
512 tdm_func_display *func_display = &private_backend->func_display;
513 tdm_output **outputs = NULL;
514 tdm_output **new_outputs = NULL;
515 tdm_output *output_dsi = NULL;
516 tdm_output *output_lvds = NULL;
517 tdm_output *output_hdmia = NULL;
518 tdm_output *output_hdmib = NULL;
519 int i, output_count = 0, output_connected_count = 0;
520 int index_dsi = 0, index_lvds = 0, index_hdmia = 0, index_hdmib = 0;
523 /* don't change list order if not init time */
524 if (private_backend->outputs) {
525 TDM_ERR("can't change output order");
526 return private_backend->outputs;
529 outputs = func_display->display_get_outputs(private_backend->bdata, &output_count, &ret);
530 if (ret != TDM_ERROR_NONE)
531 goto failed_get_outputs;
533 *count = output_count;
535 if (output_count == 0)
536 goto failed_get_outputs;
537 else if (output_count == 1) {
538 private_backend->outputs = outputs;
542 /* count connected outputs */
543 for (i = 0; i < output_count; i++) {
544 tdm_func_output *func_output = &private_backend->func_output;
545 tdm_caps_output caps;
546 memset(&caps, 0, sizeof(tdm_caps_output));
548 if (!func_output->output_get_capability) {
549 TDM_ERR("no output_get_capability()");
550 goto failed_get_outputs;
553 ret = func_output->output_get_capability(outputs[i], &caps);
554 if (ret != TDM_ERROR_NONE) {
555 TDM_ERR("output_get_capability() failed");
556 goto failed_get_outputs;
559 if (caps.status == TDM_OUTPUT_CONN_STATUS_CONNECTED) {
560 output_connected_count++;
563 case TDM_OUTPUT_TYPE_DSI:
564 output_dsi = outputs[i];
567 case TDM_OUTPUT_TYPE_LVDS:
568 output_lvds = outputs[i];
571 case TDM_OUTPUT_TYPE_HDMIA:
572 output_hdmia = outputs[i];
575 case TDM_OUTPUT_TYPE_HDMIB:
576 output_hdmib = outputs[i];
584 _tdm_display_destroy_caps_output(&caps);
587 /* ordering : main output is first */
588 /* If there is no connected output, lvds or dsi cannot be main display. (cannot connect after booting)
589 * But hdmi is possible, so set hdmi to main display.
590 * If connected only one output, it is main output.
591 * If connected outputs over 2, has priority like below.
592 * (dsi > lvds > hdmi > else)
594 if (output_connected_count == 0) {
595 /* hdmi > dsi > lvds > else */
596 if (output_hdmia != NULL)
597 new_outputs = _tdm_display_set_main_first(outputs, index_hdmia);
598 else if (output_hdmib != NULL)
599 new_outputs = _tdm_display_set_main_first(outputs, index_hdmib);
600 else if (output_dsi != NULL)
601 new_outputs = _tdm_display_set_main_first(outputs, index_dsi);
602 else if (output_lvds != NULL)
603 new_outputs = _tdm_display_set_main_first(outputs, index_lvds);
605 new_outputs = outputs;
606 } else { /* (output_connected_count > 1) */
607 /* dsi > lvds > hdmi > else */
608 if (output_dsi != NULL)
609 new_outputs = _tdm_display_set_main_first(outputs, index_dsi);
610 else if (output_lvds != NULL)
611 new_outputs = _tdm_display_set_main_first(outputs, index_lvds);
612 else if (output_hdmia != NULL)
613 new_outputs = _tdm_display_set_main_first(outputs, index_hdmia);
614 else if (output_hdmib != NULL)
615 new_outputs = _tdm_display_set_main_first(outputs, index_hdmib);
617 new_outputs = outputs;
620 private_backend->outputs = new_outputs;
631 _tdm_display_update(tdm_private_display *private_display)
633 tdm_private_backend *private_backend = NULL;
634 tdm_error ret = TDM_ERROR_NONE;
637 if (private_display->pp_backend) {
638 ret = _tdm_display_update_caps_pp(private_display->pp_backend,
639 &private_display->pp_backend->caps_pp);
640 if (ret != TDM_ERROR_NONE)
644 if (private_display->capture_backend) {
645 ret = _tdm_display_update_caps_capture(private_display->capture_backend,
646 &private_display->capture_backend->caps_capture);
647 if (ret != TDM_ERROR_NONE)
651 LIST_FOR_EACH_ENTRY(private_backend, &private_display->backend_list, link) {
652 tdm_output **outputs;
653 int output_count = 0, i;
655 outputs = _tdm_display_get_ordered_outputs(private_backend, &output_count);
659 for (i = 0; i < output_count; i++) {
660 ret = tdm_display_update_output(private_backend, outputs[i], index++);
661 if (ret != TDM_ERROR_NONE)
666 return TDM_ERROR_NONE;
669 _tdm_display_destroy_private_display(private_display);
675 tdm_display_update(tdm_display *dpy)
677 TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER);
678 TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER);
680 TDM_DEPRECATED(NULL);
682 return TDM_ERROR_NONE;
685 int tdm_debug_module;
687 int tdm_ttrace_module;
688 int tdm_ttrace_output;
690 static tdm_private_display *g_private_display;
691 static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
693 /* LCOV_EXCL_START */
695 _tdm_display_check_module(tdm_backend_module *module)
699 TDM_INFO("TDM ABI version : %d.%d",
700 TDM_MAJOR_VERSION, TDM_MINOR_VERSION);
703 TDM_ERR("TDM backend doesn't have name");
704 return TDM_ERROR_BAD_MODULE;
707 if (!module->vendor) {
708 TDM_ERR("TDM backend doesn't have vendor");
709 return TDM_ERROR_BAD_MODULE;
712 major = TDM_BACKEND_GET_ABI_MAJOR(module->abi_version);
713 minor = TDM_BACKEND_GET_ABI_MINOR(module->abi_version);
715 TDM_INFO("TDM module name: %s", module->name);
716 TDM_INFO("'%s' vendor: %s", module->name, module->vendor);
717 TDM_INFO("'%s' version: %d.%d", module->name, major, minor);
719 if (major != TDM_MAJOR_VERSION) {
720 TDM_ERR("'%s' major version mismatch, %d != %d",
721 module->name, major, TDM_MAJOR_VERSION);
722 return TDM_ERROR_BAD_MODULE;
725 if (minor > TDM_MINOR_VERSION) {
726 TDM_ERR("'%s' minor version(%d) is newer than %d",
727 module->name, minor, TDM_MINOR_VERSION);
728 return TDM_ERROR_BAD_MODULE;
732 TDM_ERR("'%s' doesn't have init function", module->name);
733 return TDM_ERROR_BAD_MODULE;
736 if (!module->deinit) {
737 TDM_ERR("'%s' doesn't have deinit function", module->name);
738 return TDM_ERROR_BAD_MODULE;
741 return TDM_ERROR_NONE;
745 _tdm_display_check_backend_functions(tdm_private_backend *private_backend)
747 tdm_func_display *func_display = &private_backend->func_display;
748 tdm_func_output *func_output = &private_backend->func_output;
749 tdm_func_layer *func_layer = &private_backend->func_layer;
752 /* below functions should be implemented in backend side */
754 TDM_RETURN_VAL_IF_FAIL(func_display != NULL, TDM_ERROR_BAD_MODULE);
755 TDM_RETURN_VAL_IF_FAIL(func_display->display_get_outputs, TDM_ERROR_BAD_MODULE);
756 TDM_RETURN_VAL_IF_FAIL(func_output->output_get_capability, TDM_ERROR_BAD_MODULE);
757 TDM_RETURN_VAL_IF_FAIL(func_output->output_get_layers, TDM_ERROR_BAD_MODULE);
758 TDM_RETURN_VAL_IF_FAIL(func_layer->layer_get_capability, TDM_ERROR_BAD_MODULE);
760 ret = func_display->display_get_capability(private_backend->bdata, &private_backend->caps_display);
761 if (ret != TDM_ERROR_NONE) {
762 TDM_ERR("display_get_capability() failed");
763 return TDM_ERROR_BAD_MODULE;
766 if (private_backend->capabilities & TDM_DISPLAY_CAPABILITY_PP) {
767 tdm_func_pp *func_pp = &private_backend->func_pp;
768 TDM_RETURN_VAL_IF_FAIL(func_display->display_get_pp_capability, TDM_ERROR_BAD_MODULE);
769 TDM_RETURN_VAL_IF_FAIL(func_display->display_create_pp, TDM_ERROR_BAD_MODULE);
770 TDM_RETURN_VAL_IF_FAIL(func_pp->pp_destroy, TDM_ERROR_BAD_MODULE);
771 TDM_RETURN_VAL_IF_FAIL(func_pp->pp_commit, TDM_ERROR_BAD_MODULE);
772 TDM_RETURN_VAL_IF_FAIL(func_pp->pp_set_done_handler, TDM_ERROR_BAD_MODULE);
775 if (private_backend->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
776 tdm_func_capture *func_capture = &private_backend->func_capture;
777 TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capture_capability, TDM_ERROR_BAD_MODULE);
778 if (private_backend->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT)
779 TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE);
780 if (private_backend->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_LAYER)
781 TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE);
782 TDM_RETURN_VAL_IF_FAIL(func_capture->capture_destroy, TDM_ERROR_BAD_MODULE);
783 TDM_RETURN_VAL_IF_FAIL(func_capture->capture_commit, TDM_ERROR_BAD_MODULE);
784 TDM_RETURN_VAL_IF_FAIL(func_capture->capture_set_done_handler, TDM_ERROR_BAD_MODULE);
787 return TDM_ERROR_NONE;
791 _tdm_display_load_module_with_file(tdm_private_display *private_display,
794 char path[TDM_PATH_LEN] = {0,};
796 tdm_backend_module *module_data;
797 tdm_backend_data *bdata = NULL;
798 tdm_private_backend *private_backend = NULL;
803 size = snprintf(path, sizeof(path), TDM_MODULE_PATH "/%s", file);
804 if (size >= (int)sizeof(path)) {
805 TDM_WRN("too long: %s/%s", TDM_MODULE_PATH, file);
806 return TDM_ERROR_BAD_MODULE;
809 private_backend = calloc(1, sizeof *private_backend);
810 if (!private_backend) {
811 TDM_ERR("alloc failed: %m");
812 ret = TDM_ERROR_OUT_OF_MEMORY;
816 private_backend->private_display = private_display;
818 stamp = tdm_helper_get_time();
820 TDM_TRACE_BEGIN("TDM_Load_Backend");
821 module = dlopen(path, RTLD_LAZY);
823 TDM_ERR("failed to load module: %s(%s)", dlerror(), file);
825 ret = TDM_ERROR_BAD_MODULE;
829 private_backend->module = module;
831 module_data = dlsym(module, "tdm_backend_module_data");
833 TDM_ERR("'%s' doesn't have data object", file);
834 ret = TDM_ERROR_BAD_MODULE;
840 private_backend->module_data = module_data;
842 TDM_DBG("dlopen, dlsym time: %.3f ms", (tdm_helper_get_time() - stamp) * 1000.0);
844 /* check if version, init() and deinit() are valid or not */
845 ret = _tdm_display_check_module(module_data);
846 if (ret != TDM_ERROR_NONE) {
847 TDM_ERR("backend(%s) load failed: check module error", module_data->name);
851 private_display->current_backend = private_backend;
853 /* We don't care if backend_data is NULL or not. It's up to backend. */
854 TDM_TRACE_BEGIN("TDM_Init_Backend");
855 stamp = tdm_helper_get_time();
856 bdata = module_data->init((tdm_display *)private_display, &ret);
857 TDM_DBG("backend init() time: %.3f ms", (tdm_helper_get_time() - stamp) * 1000.0);
860 private_display->current_backend = NULL;
862 private_backend->bdata = bdata;
864 if (ret != TDM_ERROR_NONE) {
865 TDM_ERR("backend(%s) load failed: init error", module_data->name);
869 ret = _tdm_display_check_backend_functions(private_backend);
870 if (ret != TDM_ERROR_NONE) {
871 TDM_ERR("backend(%s) load failed: check functions error", module_data->name);
875 LIST_INITHEAD(&private_backend->output_list);
876 LIST_INITHEAD(&private_backend->pp_list);
877 LIST_INITHEAD(&private_backend->capture_list);
879 LIST_ADDTAIL(&private_backend->link, &private_display->backend_list);
881 TDM_INFO("Success to load '%s' module", module_data->name);
883 return TDM_ERROR_NONE;
886 module_data->deinit(bdata);
889 free(private_backend);
894 _tdm_display_load_modules(tdm_private_display *private_display)
896 const char *module_names;
898 char temp[TDM_PATH_LEN];
902 LIST_INITHEAD(&private_display->backend_list);
904 module_names = tdm_config_get_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, TDM_DEFAULT_MODULE);
906 snprintf(temp, TDM_PATH_LEN, "%s", module_names);
908 arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
910 TDM_INFO("loading a %s backend", arg);
911 ret = _tdm_display_load_module_with_file(private_display, arg);
912 if (ret == TDM_ERROR_NONE)
913 TDM_INFO("%s backend loading success", arg);
915 TDM_INFO("%s backend loading failed", arg);
916 arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
919 /* load bufmgr priv from dummy lib */
920 if (LIST_IS_EMPTY(&private_display->backend_list)) {
921 TDM_WRN("No backend. loading a %s backend", TDM_DUMMY_MODULE);
922 ret = _tdm_display_load_module_with_file(private_display, TDM_DUMMY_MODULE);
923 if (ret == TDM_ERROR_NONE)
924 TDM_INFO("%s backend loading success", TDM_DUMMY_MODULE);
926 TDM_INFO("%s backend loading failed", TDM_DUMMY_MODULE);
933 _tdm_display_unload_modules(tdm_private_display *private_display)
935 tdm_private_backend *private_backend = NULL, *bb = NULL;
937 LIST_FOR_EACH_ENTRY_SAFE(private_backend, bb, &private_display->backend_list, link) {
938 LIST_DEL(&private_backend->link);
940 if (private_backend->module_data)
941 private_backend->module_data->deinit(private_backend->bdata);
942 if (private_backend->module)
943 dlclose(private_backend->module);
945 free(private_backend);
951 tdm_display_init(tdm_error *error)
953 tdm_private_display *private_display = NULL;
956 double stamp1, stamp2, start;
959 pthread_mutex_lock(&gLock);
961 if (g_private_display) {
962 g_private_display->init_count++;
963 pthread_mutex_unlock(&gLock);
965 *error = TDM_ERROR_NONE;
966 return g_private_display;
969 start = stamp1 = tdm_helper_get_time();
971 stamp2 = tdm_helper_get_time();
972 TDM_INFO("config init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
975 private_display = calloc(1, sizeof(tdm_private_display));
976 if (!private_display) {
977 /* LCOV_EXCL_START */
978 ret = TDM_ERROR_OUT_OF_MEMORY;
979 TDM_ERR("'private_display != NULL' failed");
984 private_display->stamp = tdm_helper_get_time();
986 str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_MODULE, NULL);
988 tdm_display_enable_debug_module(str);
990 str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_DUMP, NULL);
992 tdm_display_enable_dump(private_display, str, NULL, NULL);
994 if (pthread_mutex_init(&private_display->lock, NULL)) {
995 /* LCOV_EXCL_START */
996 ret = TDM_ERROR_OPERATION_FAILED;
997 TDM_ERR("mutex init failed: %m");
998 goto failed_mutex_init;
1002 _pthread_mutex_lock(&private_display->lock);
1004 stamp2 = tdm_helper_get_time();
1005 TDM_DBG("prepare init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
1008 ret = tdm_event_loop_init(private_display);
1009 if (ret != TDM_ERROR_NONE)
1012 stamp2 = tdm_helper_get_time();
1013 TDM_INFO("event loop init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
1016 ret = tdm_vblank_init(private_display);
1017 if (ret != TDM_ERROR_NONE)
1020 ret = tdm_output_init(private_display);
1021 if (ret != TDM_ERROR_NONE)
1024 ret = tdm_pp_init(private_display);
1025 if (ret != TDM_ERROR_NONE)
1028 ret = tdm_capture_init(private_display);
1029 if (ret != TDM_ERROR_NONE)
1032 ret = _tdm_display_load_modules(private_display);
1033 if (ret != TDM_ERROR_NONE)
1036 stamp2 = tdm_helper_get_time();
1037 TDM_INFO("loading backend time: %.3f ms", (stamp2 - stamp1) * 1000.0);
1041 int tdm_drm_fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
1042 if (tdm_drm_fd >= 0) {
1043 private_display->bufmgr = tbm_bufmgr_init(tdm_drm_fd);
1045 if (!private_display->bufmgr) {
1046 TDM_ERR("tbm_bufmgr_init failed");
1049 TDM_INFO("tbm_bufmgr_init successed");
1052 stamp2 = tdm_helper_get_time();
1053 TDM_DBG("initializing bufmgr time: %.3f ms", (stamp2 - stamp1) * 1000.0);
1058 TDM_TRACE_BEGIN("TDM_Update_Display");
1059 ret = _tdm_display_update(private_display);
1061 if (ret != TDM_ERROR_NONE)
1064 stamp2 = tdm_helper_get_time();
1065 TDM_DBG("updating display time: %.3f ms", (stamp2 - stamp1) * 1000.0);
1068 tdm_event_loop_create_backend_source(private_display);
1070 private_display->init_count = 1;
1071 g_private_display = private_display;
1073 tdm_private_backend *b = NULL;
1074 tdm_private_output *o = NULL;
1075 LIST_FOR_EACH_ENTRY(b, &private_display->backend_list, link) {
1076 LIST_FOR_EACH_ENTRY(o, &b->output_list, link) {
1077 if (o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
1078 tdm_output_need_validate_event_init(o);
1082 /* the COMMIT_PER_VBLANK functionality is ability of an output to support
1083 * several operational modes (commit_per_vblank modes) related to tdm_commit;
1084 * this functionality can be turned off which means a default mode */
1085 mode = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0);
1087 tdm_private_backend *b = NULL;
1088 tdm_private_output *o = NULL;
1090 /* outputs which support hwc capability can work only
1091 * if commit_per_vblank mode is '0' (default mode) */
1092 LIST_FOR_EACH_ENTRY(b, &private_display->backend_list, link) {
1093 LIST_FOR_EACH_ENTRY(o, &b->output_list, link) {
1094 if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
1095 tdm_output_choose_commit_per_vblank_mode(o, mode);
1101 *error = TDM_ERROR_NONE;
1103 _pthread_mutex_unlock(&private_display->lock);
1104 pthread_mutex_unlock(&gLock);
1106 TDM_INFO("init time: %.3f ms", (tdm_helper_get_time() - start) * 1000.0);
1108 return (tdm_display *)private_display;
1110 /* LCOV_EXCL_START */
1112 _tdm_display_unload_modules(private_display);
1114 tdm_event_loop_stop(private_display);
1115 tdm_event_loop_deinit(private_display);
1117 tdm_vblank_deinit(private_display);
1119 _pthread_mutex_unlock(&private_display->lock);
1120 pthread_mutex_destroy(&private_display->lock);
1122 free(private_display);
1126 pthread_mutex_unlock(&gLock);
1128 /* LCOV_EXCL_STOP */
1132 tdm_display_deinit(tdm_display *dpy)
1134 tdm_private_display *private_display = dpy;
1136 if (!private_display)
1139 TDM_RETURN_IF_FAIL(tdm_display_is_valid(dpy));
1141 pthread_mutex_lock(&gLock);
1143 private_display->init_count--;
1144 if (private_display->init_count > 0) {
1145 pthread_mutex_unlock(&gLock);
1149 /* dont move the position of lock/unlock. all resource should be protected
1150 * during destroying. after tdm_event_loop_deinit, we don't worry about thread
1151 * things because it's finalized.
1153 _pthread_mutex_lock(&private_display->lock);
1154 tdm_event_loop_stop(private_display);
1155 tdm_event_loop_deinit(private_display);
1156 _pthread_mutex_unlock(&private_display->lock);
1158 /* when private_output is destroyed, all vblank resources of client and server
1159 * are destroyed. Then we can call tdm_vblank_deinit. After destroying display,
1160 * we can unload backend modulues.
1162 _tdm_display_destroy_private_display(private_display);
1163 _tdm_display_unload_modules(private_display);
1165 tdm_vblank_deinit(private_display);
1168 if (private_display->bufmgr)
1169 tbm_bufmgr_deinit(private_display->bufmgr);
1172 tbm_drm_helper_unset_tbm_master_fd();
1174 pthread_mutex_destroy(&private_display->lock);
1175 free(private_display);
1176 g_private_display = NULL;
1178 if (tdm_debug_dump_dir) {
1179 free(tdm_debug_dump_dir);
1180 tdm_debug_dump_dir = NULL;
1183 tdm_config_deinit();
1185 pthread_mutex_unlock(&gLock);
1190 INTERN tdm_private_display *
1191 tdm_display_get(void)
1193 return g_private_display;
1197 tdm_display_is_valid(tdm_display *dpy)
1199 if (dpy != NULL && dpy == g_private_display)
1205 tdm_output_is_valid(tdm_output *output)
1207 tdm_private_backend *b = NULL;
1208 tdm_private_output *o = NULL;
1210 if (!output || !g_private_display)
1213 LIST_FOR_EACH_ENTRY(b, &g_private_display->backend_list, link) {
1214 LIST_FOR_EACH_ENTRY(o, &b->output_list, link)
1222 /* LCOV_EXCL_START */
1224 tdm_backend_check_module_abi(tdm_private_backend *private_backend, int abimaj, int abimin)
1226 tdm_backend_module *module = private_backend->module_data;
1228 if (TDM_BACKEND_GET_ABI_MAJOR(module->abi_version) < abimaj)
1231 if (TDM_BACKEND_GET_ABI_MINOR(module->abi_version) < abimin)
1238 tdm_display_enable_debug_module(const char*modules)
1240 char temp[TDM_PATH_LEN];
1244 snprintf(temp, TDM_PATH_LEN, "%s", modules);
1246 tdm_debug_module = 0;
1248 arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
1250 if (!strncmp(arg, "none", 4)) {
1251 tdm_debug_module = 0;
1252 return TDM_ERROR_NONE;
1254 if (!strncmp(arg, "all", 3)) {
1255 tdm_debug_module = 0xFFFFFFFF;
1256 return TDM_ERROR_NONE;
1258 if (!strncmp(arg, "buffer", 6))
1259 tdm_debug_module |= TDM_DEBUG_BUFFER;
1260 else if (!strncmp(arg, "event", 5))
1261 tdm_debug_module |= TDM_DEBUG_EVENT;
1262 else if (!strncmp(arg, "thread", 6))
1263 tdm_debug_module |= TDM_DEBUG_THREAD;
1264 else if (!strncmp(arg, "mutex", 5))
1265 tdm_debug_module |= TDM_DEBUG_MUTEX;
1266 else if (!strncmp(arg, "vblank", 6))
1267 tdm_debug_module |= TDM_DEBUG_VBLANK;
1268 else if (!strncmp(arg, "commit", 6))
1269 tdm_debug_module |= TDM_DEBUG_COMMIT;
1271 arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
1274 TDM_INFO("module debugging... '%s'", modules);
1276 return TDM_ERROR_NONE;
1280 tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_str, char *reply, int *len)
1282 char temp[TDM_PATH_LEN] = {0,}, temp2[TDM_PATH_LEN] = {0,};
1283 char *path = NULL, *path2;
1287 snprintf(temp2, TDM_PATH_LEN, "%s", dump_str);
1288 path2 = strtostr(temp, TDM_PATH_LEN, temp2, "@");
1289 if (!path2 || path2[0] == '\0')
1290 path2 = TDM_DUMP_DIR;
1296 snprintf(temp, sizeof(temp), "%s", dump_str);
1297 arg = strtok_r(temp, ",", &end);
1298 TDM_GOTO_IF_FAIL(arg != NULL, done);
1300 if (!strncmp(arg, "none", 4)) {
1302 TDM_SNPRINTF(reply, len, "path: %s\n", (tdm_debug_dump_dir) ? : "unknown");
1303 if (tdm_debug_dump_dir) {
1304 free(tdm_debug_dump_dir);
1305 tdm_debug_dump_dir = NULL;
1310 path = tdm_helper_dump_make_directory(path2, reply, len);
1311 TDM_GOTO_IF_FAIL(path != NULL, done);
1313 if (!strncmp(arg, "current", 7)) {
1314 tdm_private_backend *b = NULL;
1315 tdm_private_output *o = NULL;
1317 if (!private_display) {
1318 TDM_WRN("no private_display");
1322 LIST_FOR_EACH_ENTRY(b, &private_display->backend_list, link) {
1323 LIST_FOR_EACH_ENTRY(o, &b->output_list, link) {
1324 tdm_private_layer *l = NULL;
1325 LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
1326 char str[TDM_PATH_LEN];
1327 if (l->usable || l->caps.capabilities & TDM_LAYER_CAPABILITY_VIDEO)
1329 if (!l->showing_buffer)
1331 snprintf(str, TDM_PATH_LEN, "layer_%d_%d", o->index, l->index);
1332 tdm_helper_dump_buffer_str(l->showing_buffer->buffer, path, str);
1337 TDM_SNPRINTF(reply, len, "path: %s\n", path);
1341 TDM_SNPRINTF(reply, len, "dump: %s\n", arg);
1344 if (!strncmp(arg, "all", 3)) {
1345 tdm_debug_dump = 0xFFFFFFFF;
1347 } else if (!strncmp(arg, "layer", 5)) {
1348 tdm_debug_dump |= TDM_DUMP_FLAG_LAYER;
1349 } else if (!strncmp(arg, "pp", 2)) {
1350 tdm_debug_dump |= TDM_DUMP_FLAG_PP;
1351 } else if (!strncmp(arg, "capture", 7)) {
1352 tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
1353 } else if (!strncmp(arg, "window", 6)) {
1354 tdm_debug_dump |= TDM_DUMP_FLAG_WINDOW;
1358 arg = strtok_r(NULL, ",", &end);
1361 if (tdm_debug_dump_dir)
1362 free(tdm_debug_dump_dir);
1364 tdm_debug_dump_dir = strndup(path, TDM_PATH_LEN);
1366 TDM_INFO("dump... '%s'", dump_str);
1372 return TDM_ERROR_NONE;
1376 _tdm_display_ttrace_vblank_cb(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1377 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
1379 tdm_error ret = TDM_ERROR_NONE;
1381 TDM_TRACE_MARK("VSYNC");
1383 ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
1384 TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
1388 tdm_display_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable)
1390 tdm_private_display *private_display = dpy;
1391 tdm_private_backend *private_backend = NULL;
1392 tdm_private_output *private_output = NULL;
1393 const tdm_output_mode *mode = NULL;
1394 tdm_vblank *vblank = NULL;
1395 tdm_error ret = TDM_ERROR_NONE;
1398 LIST_FOR_EACH_ENTRY(private_backend, &private_display->backend_list, link) {
1399 LIST_FOR_EACH_ENTRY(private_output, &private_backend->output_list, link) {
1400 if (private_output->ttrace_vblank)
1401 tdm_vblank_destroy(private_output->ttrace_vblank);
1402 private_output->ttrace_vblank = NULL;
1405 return TDM_ERROR_NONE;
1408 private_output = output;
1409 TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER);
1411 if (private_output->ttrace_vblank)
1412 return TDM_ERROR_NONE;
1414 vblank = tdm_vblank_create(private_display, output, &ret);
1415 TDM_RETURN_VAL_IF_FAIL(vblank != NULL, ret);
1417 ret = tdm_output_get_mode(output, &mode);
1418 TDM_GOTO_IF_FAIL(mode != NULL, enable_fail);
1420 ret = tdm_vblank_set_fps(vblank, mode->vrefresh);
1421 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
1423 ret = tdm_vblank_set_enable_fake(vblank, 1);
1424 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
1426 ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
1427 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
1429 private_output->ttrace_vblank = vblank;
1431 return TDM_ERROR_NONE;
1435 tdm_vblank_destroy(vblank);
1441 tdm_display_enable_ttrace(tdm_private_display *private_display, const char *ttrace, int output_id, char *reply, int *len)
1443 char temp[TDM_PATH_LEN];
1448 tdm_output_type type;
1450 snprintf(temp, TDM_PATH_LEN, "%s", ttrace);
1452 tdm_ttrace_output = output_id;
1453 tdm_ttrace_module = 0;
1455 output = tdm_display_get_output(private_display, output_id, &ret);
1457 TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id);
1461 ret = tdm_output_get_output_type(output, &type);
1462 if (ret != TDM_ERROR_NONE) {
1463 TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id);
1467 arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
1469 if (!strncmp(arg, "none", 4))
1470 tdm_ttrace_module = 0;
1471 else if (!strncmp(arg, "all", 3))
1472 tdm_ttrace_module = 0xFFFFFFFF;
1473 else if (!strncmp(arg, "vsync", 5))
1474 tdm_ttrace_module |= TDM_TTRACE_VSYNC;
1475 else if (!strncmp(arg, "client_vblank", 13))
1476 tdm_ttrace_module |= TDM_TTRACE_CLIENT_VBLANK;
1477 else if (!strncmp(arg, "server_vblank", 13))
1478 tdm_ttrace_module |= TDM_TTRACE_SERVER_VBLANK;
1479 else if (!strncmp(arg, "vblank", 6))
1480 tdm_ttrace_module |= TDM_TTRACE_VBLANK;
1481 else if (!strncmp(arg, "layer", 5))
1482 tdm_ttrace_module |= TDM_TTRACE_LAYER;
1483 else if (!strncmp(arg, "pp", 2))
1484 tdm_ttrace_module |= TDM_TTRACE_PP;
1485 else if (!strncmp(arg, "capture", 7))
1486 tdm_ttrace_module |= TDM_TTRACE_CAPTURE;
1488 tdm_ttrace_module = 0;
1489 tdm_display_enable_ttrace_vblank(private_display, NULL, 0);
1490 tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0);
1491 TDM_SNPRINTF(reply, len, "unknown option: '%s'\n", arg);
1492 return TDM_ERROR_NONE;
1495 arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
1498 TDM_SNPRINTF(reply, len, "ttrace debugging... '%s' %x\n", ttrace, tdm_ttrace_module);
1500 if (tdm_ttrace_module & TDM_TTRACE_VSYNC)
1501 tdm_display_enable_ttrace_vblank(private_display, output, 1);
1503 tdm_display_enable_ttrace_vblank(private_display, NULL, 0);
1505 if (tdm_ttrace_module & TDM_TTRACE_CLIENT_VBLANK)
1506 tdm_server_enable_ttrace_client_vblank(private_display, output, 1);
1508 tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0);
1510 return TDM_ERROR_NONE;
1514 tdm_display_enable_fps(tdm_private_display *private_display, int enable)
1516 private_display->print_fps = enable;
1518 TDM_INFO("print fps: %s", (enable) ? "enable" : "disable");
1520 return TDM_ERROR_NONE;
1522 /* LCOV_EXCL_STOP */