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"
44 #define OUTPUT_FUNC_ENTRY() \
45 tdm_private_display *private_display; \
46 tdm_private_output *private_output; \
47 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
48 TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER); \
49 private_output = (tdm_private_output*)output; \
50 private_display = private_output->private_display
52 #define OUTPUT_FUNC_ENTRY_ERROR() \
53 tdm_private_display *private_display; \
54 tdm_private_output *private_output; \
55 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
56 TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER, NULL); \
57 private_output = (tdm_private_output*)output; \
58 private_display = private_output->private_display
61 _tdm_output_vblank_timeout_update(tdm_private_output *private_output, int ms_delay);
64 _tdm_output_vblank_timeout_cb(void *user_data)
66 tdm_private_output *private_output = user_data;
67 tdm_private_output_vblank_handler *v = NULL;
69 TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OPERATION_FAILED);
71 private_output->vblank_timeout_timer_expired++;
73 TDM_ERR("TDM output(%d) vblank TIMEOUT!! (%d time%s)",
75 private_output->vblank_timeout_timer_expired,
76 (private_output->vblank_timeout_timer_expired > 1) ? "s" : "");
78 LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
79 TDM_ERR("vblank_handler(%p) interval(%d) sync(%d) sent_to_frontend(%u) owner_tid(%d)",
80 v, v->interval, v->sync, v->sent_to_frontend, v->owner_tid);
83 return TDM_ERROR_NONE;
87 tdm_output_vblank_print_wait_information(tdm_private_output *private_output, void *user_data)
89 tdm_private_output_vblank_handler *v = NULL;
91 TDM_RETURN_IF_FAIL(private_output != NULL);
92 TDM_RETURN_IF_FAIL(user_data != NULL);
94 TDM_ERR("TDM output(%d) vblank user_data(%p) info!!", private_output->pipe, user_data);
96 LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
97 if (v->user_data != user_data)
99 TDM_ERR("vblank_handler(%p) interval(%d) sync(%d) sent_to_frontend(%u) owner_tid(%d)",
100 v, v->interval, v->sync, v->sent_to_frontend, v->owner_tid);
105 _tdm_output_vblank_timeout_update(tdm_private_output *private_output, int ms_delay)
109 if (!private_output->vblank_timeout_timer) {
110 private_output->vblank_timeout_timer =
111 tdm_event_loop_add_timer_handler(private_output->private_display,
112 _tdm_output_vblank_timeout_cb,
115 if (!private_output->vblank_timeout_timer) {
116 TDM_ERR("output(%d) couldn't add timer", private_output->pipe);
119 TDM_INFO("output(%d) create vblank timeout timer", private_output->pipe);
120 private_output->vblank_timeout_timer_expired = 0;
123 ret = tdm_event_loop_source_timer_update(private_output->vblank_timeout_timer, ms_delay);
124 if (ret != TDM_ERROR_NONE) {
125 TDM_ERR("output(%d) couldn't update timer", private_output->pipe);
130 static tdm_private_hwc_window *
131 _tdm_output_find_private_hwc_window(tdm_private_output *private_output,
132 tdm_hwc_window *hwc_window_backend)
134 tdm_private_hwc_window *private_hwc_window = NULL;
136 LIST_FOR_EACH_ENTRY(private_hwc_window, &private_output->hwc_window_list, link) {
137 if (private_hwc_window->hwc_window_backend == hwc_window_backend)
138 return private_hwc_window;
145 tdm_output_init(tdm_private_display *private_display)
147 tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_COMMIT, tdm_display_find_output_stamp);
148 tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_VBLANK, tdm_display_find_output_stamp);
149 tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_CHANGE, tdm_display_find_output_stamp);
151 return TDM_ERROR_NONE;
155 tdm_output_get_backend(tdm_output *output, tdm_error *error)
157 tdm_private_backend *private_backend;
159 OUTPUT_FUNC_ENTRY_ERROR();
161 _pthread_mutex_lock(&private_display->lock);
163 private_backend = private_output->private_backend;
166 *error = TDM_ERROR_NONE;
168 _pthread_mutex_unlock(&private_display->lock);
170 return private_backend;
174 tdm_output_get_model_info(tdm_output *output, const char **maker,
175 const char **model, const char **name)
179 _pthread_mutex_lock(&private_display->lock);
182 *maker = private_output->caps.maker;
184 *model = private_output->caps.model;
186 *name = private_output->caps.name;
188 _pthread_mutex_unlock(&private_display->lock);
194 tdm_output_get_capabilities(tdm_output *output, tdm_output_capability *capabilities)
198 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
200 _pthread_mutex_lock(&private_display->lock);
202 *capabilities = private_output->caps.capabilities;
204 _pthread_mutex_unlock(&private_display->lock);
210 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status)
214 TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
216 _pthread_mutex_lock(&private_display->lock);
218 *status = private_output->caps.status;
220 _pthread_mutex_unlock(&private_display->lock);
225 /* LCOV_EXCL_START */
227 _tdm_output_update(tdm_output *output_backend, void *user_data)
229 tdm_private_output *private_output = user_data;
232 TDM_RETURN_IF_FAIL(private_output);
234 ret = tdm_display_update_output(private_output->private_backend, output_backend, private_output->pipe);
235 TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
240 tdm_output_thread_cb_change(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
242 tdm_private_output *private_output = object;
243 tdm_thread_cb_output_change *output_change = (tdm_thread_cb_output_change *)cb_base;
244 tdm_private_output_change_handler *change_handler = user_data;
246 TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
248 assert(change_handler->owner_tid == syscall(SYS_gettid));
250 _pthread_mutex_unlock(&private_display->lock);
251 change_handler->func(private_output, output_change->type, output_change->value, change_handler->user_data);
252 _pthread_mutex_lock(&private_display->lock);
256 _tdm_output_call_thread_cb_change(tdm_private_output *private_output, tdm_output_change_type type, tdm_value value)
258 tdm_thread_cb_output_change output_change;
261 memset(&output_change, 0, sizeof output_change);
262 output_change.base.type = TDM_THREAD_CB_OUTPUT_CHANGE;
263 output_change.base.length = sizeof output_change;
264 output_change.base.object_stamp = private_output->stamp;
265 output_change.base.data = NULL;
266 output_change.base.sync = 1;
267 output_change.type = type;
268 output_change.value = value;
270 ret = tdm_thread_cb_call(private_output, &output_change.base);
271 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
273 return TDM_ERROR_NONE;
277 tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, void *user_data)
279 tdm_private_output *private_output = user_data;
283 TDM_INFO("output(%d) main %s", private_output->pipe, tdm_status_str(status));
285 _tdm_output_update(output_backend, user_data);
289 ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_CONNECTION, value);
290 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
294 tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
296 tdm_private_output *private_output = user_data;
300 TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(dpms));
302 private_output->current_dpms_value = dpms;
303 private_output->waiting_dpms_change = 0;
304 TDM_INFO("output(%d) dpms async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
308 ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
309 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
313 tdm_output_add_change_handler(tdm_output *output,
314 tdm_output_change_handler func,
317 tdm_private_output_change_handler *change_handler;
320 TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
322 _pthread_mutex_lock(&private_display->lock);
324 change_handler = calloc(1, sizeof(tdm_private_output_change_handler));
325 if (!change_handler) {
326 /* LCOV_EXCL_START */
327 TDM_ERR("failed: alloc memory");
328 _pthread_mutex_unlock(&private_display->lock);
329 return TDM_ERROR_OUT_OF_MEMORY;
333 ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
334 if (ret != TDM_ERROR_NONE) {
335 /* LCOV_EXCL_START */
336 TDM_ERR("tdm_thread_cb_add failed");
337 free(change_handler);
338 _pthread_mutex_unlock(&private_display->lock);
339 return TDM_ERROR_OPERATION_FAILED;
343 change_handler->private_output = private_output;
344 change_handler->func = func;
345 change_handler->user_data = user_data;
346 change_handler->owner_tid = syscall(SYS_gettid);
348 LIST_ADDTAIL(&change_handler->link, &private_output->change_handler_list);
350 _pthread_mutex_unlock(&private_display->lock);
356 tdm_output_remove_change_handler(tdm_output *output,
357 tdm_output_change_handler func,
360 tdm_private_display *private_display;
361 tdm_private_output *private_output;
362 tdm_private_output_change_handler *change_handler = NULL, *hh = NULL;
364 TDM_RETURN_IF_FAIL(tdm_output_is_valid(output));
365 TDM_RETURN_IF_FAIL(func != NULL);
367 private_output = (tdm_private_output*)output;
368 private_display = private_output->private_display;
370 _pthread_mutex_lock(&private_display->lock);
372 LIST_FOR_EACH_ENTRY_SAFE(change_handler, hh, &private_output->change_handler_list, link) {
373 if (change_handler->func != func || change_handler->user_data != user_data)
376 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
378 LIST_DEL(&change_handler->link);
379 free(change_handler);
381 _pthread_mutex_unlock(&private_display->lock);
386 _pthread_mutex_unlock(&private_display->lock);
390 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type)
394 TDM_RETURN_VAL_IF_FAIL(type != NULL, TDM_ERROR_INVALID_PARAMETER);
396 _pthread_mutex_lock(&private_display->lock);
398 *type = private_output->caps.type;
400 _pthread_mutex_unlock(&private_display->lock);
406 tdm_output_get_layer_count(tdm_output *output, int *count)
408 tdm_private_layer *private_layer = NULL;
412 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
414 _pthread_mutex_lock(&private_display->lock);
416 if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
417 TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
419 _pthread_mutex_unlock(&private_display->lock);
420 return TDM_ERROR_BAD_REQUEST;
424 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
427 _pthread_mutex_unlock(&private_display->lock);
428 return TDM_ERROR_NONE;
431 _pthread_mutex_unlock(&private_display->lock);
438 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error)
440 tdm_private_layer *private_layer = NULL;
442 OUTPUT_FUNC_ENTRY_ERROR();
444 _pthread_mutex_lock(&private_display->lock);
447 *error = TDM_ERROR_NONE;
449 if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
450 _pthread_mutex_unlock(&private_display->lock);
451 TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
453 *error = TDM_ERROR_BAD_REQUEST;
457 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
458 if (private_layer->index == index) {
459 _pthread_mutex_unlock(&private_display->lock);
460 return private_layer;
464 _pthread_mutex_unlock(&private_display->lock);
470 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
475 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
476 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
478 _pthread_mutex_lock(&private_display->lock);
480 *props = (const tdm_prop *)private_output->caps.props;
481 *count = private_output->caps.prop_count;
483 _pthread_mutex_unlock(&private_display->lock);
489 tdm_output_get_available_modes(tdm_output *output,
490 const tdm_output_mode **modes, int *count)
494 TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
495 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
497 _pthread_mutex_lock(&private_display->lock);
499 *modes = (const tdm_output_mode *)private_output->caps.modes;
500 *count = private_output->caps.mode_count;
502 _pthread_mutex_unlock(&private_display->lock);
508 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
509 int *max_w, int *max_h, int *preferred_align)
513 _pthread_mutex_lock(&private_display->lock);
516 *min_w = TDM_FRONT_VALUE(private_output->caps.min_w);
518 *min_h = TDM_FRONT_VALUE(private_output->caps.min_h);
520 *max_w = TDM_FRONT_VALUE(private_output->caps.max_w);
522 *max_h = TDM_FRONT_VALUE(private_output->caps.max_h);
524 *preferred_align = TDM_FRONT_VALUE(private_output->caps.preferred_align);
526 _pthread_mutex_unlock(&private_display->lock);
532 tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
533 int *max_w, int *max_h, int *preferred_align)
537 _pthread_mutex_lock(&private_display->lock);
539 if (!tdm_backend_check_module_abi(private_output->private_backend, 1, 5)) {
550 *preferred_align = -1;
552 _pthread_mutex_unlock(&private_display->lock);
554 return TDM_ERROR_BAD_REQUEST;
558 *min_w = TDM_FRONT_VALUE(private_output->caps.cursor_min_w);
560 *min_h = TDM_FRONT_VALUE(private_output->caps.cursor_min_h);
562 *max_w = TDM_FRONT_VALUE(private_output->caps.cursor_max_w);
564 *max_h = TDM_FRONT_VALUE(private_output->caps.cursor_max_h);
566 *preferred_align = TDM_FRONT_VALUE(private_output->caps.cursor_preferred_align);
568 _pthread_mutex_unlock(&private_display->lock);
574 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
575 unsigned int *mmHeight)
579 _pthread_mutex_lock(&private_display->lock);
582 *mmWidth = private_output->caps.mmWidth;
584 *mmHeight = private_output->caps.mmHeight;
586 _pthread_mutex_unlock(&private_display->lock);
592 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel)
595 TDM_RETURN_VAL_IF_FAIL(subpixel != NULL, TDM_ERROR_INVALID_PARAMETER);
597 _pthread_mutex_lock(&private_display->lock);
599 *subpixel = private_output->caps.subpixel;
601 _pthread_mutex_unlock(&private_display->lock);
607 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe)
610 TDM_RETURN_VAL_IF_FAIL(pipe != NULL, TDM_ERROR_INVALID_PARAMETER);
612 _pthread_mutex_lock(&private_display->lock);
614 *pipe = private_output->pipe;
616 _pthread_mutex_unlock(&private_display->lock);
622 tdm_output_get_primary_index(tdm_output *output, int *index)
624 tdm_private_layer *private_layer = NULL;
627 TDM_RETURN_VAL_IF_FAIL(index != NULL, TDM_ERROR_INVALID_PARAMETER);
629 _pthread_mutex_lock(&private_display->lock);
631 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
632 if (private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_PRIMARY) {
633 *index = private_layer->index;
638 _pthread_mutex_unlock(&private_display->lock);
644 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
646 tdm_private_backend *private_backend;
647 tdm_func_output *func_output;
650 _pthread_mutex_lock(&private_display->lock);
652 private_backend = private_output->private_backend;
653 func_output = &private_backend->func_output;
655 if (!func_output->output_set_property) {
656 /* LCOV_EXCL_START */
657 _pthread_mutex_unlock(&private_display->lock);
658 TDM_WRN("not implemented!!");
659 return TDM_ERROR_NOT_IMPLEMENTED;
663 ret = func_output->output_set_property(private_output->output_backend, id,
666 _pthread_mutex_unlock(&private_display->lock);
672 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
674 tdm_private_backend *private_backend;
675 tdm_func_output *func_output;
678 TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
680 _pthread_mutex_lock(&private_display->lock);
682 private_backend = private_output->private_backend;
683 func_output = &private_backend->func_output;
685 if (!func_output->output_get_property) {
686 /* LCOV_EXCL_START */
687 _pthread_mutex_unlock(&private_display->lock);
688 TDM_WRN("not implemented!!");
689 return TDM_ERROR_NOT_IMPLEMENTED;
693 ret = func_output->output_get_property(private_output->output_backend, id,
696 _pthread_mutex_unlock(&private_display->lock);
702 _tdm_output_thread_cb_vblank(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
704 tdm_thread_cb_output_vblank *output_vblank = (tdm_thread_cb_output_vblank *)cb_base;
705 tdm_private_output_vblank_handler *vblank_handler = output_vblank->base.data;
706 tdm_private_output_vblank_handler *v = NULL, *vv = NULL;
707 tdm_private_output *private_output = object;
708 struct list_head clone_list;
710 pid_t tid = syscall(SYS_gettid);
712 TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
714 assert(vblank_handler->owner_tid == tid);
716 vblank_handler->sent_to_frontend = 0;
718 _tdm_output_vblank_timeout_update(private_output, 0);
720 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
722 interval = vblank_handler->interval;
723 sync = vblank_handler->sync;
725 LIST_INITHEAD(&clone_list);
727 LIST_FOR_EACH_ENTRY_SAFE(v, vv, &private_output->vblank_handler_list, link) {
728 if (v->interval != interval || v->sync != sync || v->owner_tid != tid)
732 LIST_ADDTAIL(&v->link, &clone_list);
735 if (tdm_debug_module & TDM_DEBUG_COMMIT)
736 TDM_INFO("----------------------------------------- output(%d) got vblank", private_output->pipe);
738 _pthread_mutex_unlock(&private_display->lock);
739 LIST_FOR_EACH_ENTRY_SAFE(v, vv, &clone_list, link) {
740 if (tdm_debug_module & TDM_DEBUG_COMMIT)
741 TDM_INFO("handler(%p)", v);
746 v->func(v->private_output,
747 output_vblank->sequence,
748 output_vblank->tv_sec,
749 output_vblank->tv_usec,
754 _pthread_mutex_lock(&private_display->lock);
756 if (tdm_debug_module & TDM_DEBUG_COMMIT)
757 TDM_INFO("-----------------------------------------...");
761 _tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence,
762 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
764 tdm_private_output_vblank_handler *vblank_handler = user_data;
765 tdm_thread_cb_output_vblank output_vblank;
768 memset(&output_vblank, 0, sizeof output_vblank);
769 output_vblank.base.type = TDM_THREAD_CB_OUTPUT_VBLANK;
770 output_vblank.base.length = sizeof output_vblank;
771 output_vblank.base.object_stamp = vblank_handler->private_output->stamp;
772 output_vblank.base.data = vblank_handler;
773 output_vblank.base.sync = 0;
774 output_vblank.sequence = sequence;
775 output_vblank.tv_sec = tv_sec;
776 output_vblank.tv_usec = tv_usec;
778 vblank_handler->sent_to_frontend = 1;
780 ret = tdm_thread_cb_call(vblank_handler->private_output, &output_vblank.base);
781 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
785 _tdm_output_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
787 tdm_thread_cb_output_commit *output_commit = (tdm_thread_cb_output_commit *)cb_base;
788 tdm_private_output_commit_handler *output_commit_handler = output_commit->base.data;
789 tdm_private_output *private_output = object;
790 tdm_private_layer *private_layer = NULL;
792 TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
794 if (!output_commit_handler)
797 assert(output_commit_handler->owner_tid == syscall(SYS_gettid));
799 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
801 LIST_DEL(&output_commit_handler->link);
803 if (tdm_debug_module & TDM_DEBUG_COMMIT) {
804 TDM_INFO("----------------------------------------- output(%d) committed", private_output->pipe);
805 TDM_INFO("handler(%p)", output_commit_handler);
808 if (private_output->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
809 /* In case of layer commit, the below will be handled in the layer commit callback */
810 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
811 if (private_layer->committed_buffer)
812 tdm_layer_committed(private_layer, &private_layer->committed_buffer);
816 if (output_commit_handler->func) {
817 _pthread_mutex_unlock(&private_display->lock);
818 output_commit_handler->func(private_output,
819 output_commit->sequence,
820 output_commit->tv_sec,
821 output_commit->tv_usec,
822 output_commit_handler->user_data);
823 _pthread_mutex_lock(&private_display->lock);
826 free(output_commit_handler);
828 if (tdm_debug_module & TDM_DEBUG_COMMIT)
829 TDM_INFO("-----------------------------------------...");
833 _tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
834 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
836 tdm_private_output_commit_handler *output_commit_handler = user_data;
837 tdm_private_output *private_output;
838 tdm_thread_cb_output_commit output_commit;
841 if (output_commit_handler)
842 private_output = output_commit_handler->private_output;
844 private_output = tdm_display_find_private_output(tdm_display_get(), output_backend);
846 memset(&output_commit, 0, sizeof output_commit);
847 output_commit.base.type = TDM_THREAD_CB_OUTPUT_COMMIT;
848 output_commit.base.length = sizeof output_commit;
849 output_commit.base.object_stamp = private_output->stamp;
850 output_commit.base.data = output_commit_handler;
851 output_commit.base.sync = 0;
852 output_commit.sequence = sequence;
853 output_commit.tv_sec = tv_sec;
854 output_commit.tv_usec = tv_usec;
856 ret = tdm_thread_cb_call(private_output, &output_commit.base);
857 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
860 /* add_front: To distinguish between the user vblank handlers and the layer
861 * commit vblank handlers. The layer commit handlers will be called
862 * before calling the user vblank handlers.
865 _tdm_output_wait_vblank(tdm_private_output *private_output, int interval, int sync,
866 tdm_output_vblank_handler func, void *user_data,
867 unsigned int add_front)
869 tdm_private_backend *private_backend;
870 tdm_func_output *func_output;
871 tdm_private_output_vblank_handler *vblank_handler = NULL, *v = NULL;
872 unsigned int skip_request = 0;
873 pid_t tid = syscall(SYS_gettid);
874 tdm_error ret = TDM_ERROR_NONE;
876 private_backend = private_output->private_backend;
877 func_output = &private_backend->func_output;
879 /* interval SHOULD be at least 1 */
883 if (!func_output->output_wait_vblank) {
884 /* LCOV_EXCL_START */
885 TDM_WRN("not implemented!!");
886 return TDM_ERROR_NOT_IMPLEMENTED;
890 if (!private_output->regist_vblank_cb) {
891 private_output->regist_vblank_cb = 1;
892 ret = func_output->output_set_vblank_handler(private_output->output_backend,
893 _tdm_output_cb_vblank);
896 vblank_handler = calloc(1, sizeof(tdm_private_output_vblank_handler));
897 if (!vblank_handler) {
898 /* LCOV_EXCL_START */
899 TDM_ERR("failed: alloc memory");
900 return TDM_ERROR_OUT_OF_MEMORY;
904 if (tdm_debug_module & TDM_DEBUG_COMMIT)
905 TDM_INFO("output(%d) wait_vblank: handler(%p)", private_output->pipe, vblank_handler);
907 LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
908 if (v->interval == interval && v->sync == sync && v->owner_tid == tid) {
915 LIST_ADD(&vblank_handler->link, &private_output->vblank_handler_list);
917 LIST_ADDTAIL(&vblank_handler->link, &private_output->vblank_handler_list);
919 vblank_handler->private_output = private_output;
920 vblank_handler->interval = interval;
921 vblank_handler->sync = sync;
922 vblank_handler->func = func;
923 vblank_handler->user_data = user_data;
924 vblank_handler->owner_tid = tid;
926 /* If there is the previous request, we can skip to call output_wait_vblank() */
928 ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
929 if (ret != TDM_ERROR_NONE) {
930 TDM_ERR("tdm_thread_cb_add failed");
934 ret = func_output->output_wait_vblank(private_output->output_backend, interval,
935 sync, vblank_handler);
936 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
938 _tdm_output_vblank_timeout_update(private_output, 1000);
940 if (tdm_debug_module & TDM_DEBUG_COMMIT)
941 TDM_INFO("output(%d) backend wait_vblank", private_output->pipe);
947 /* LCOV_EXCL_START */
948 if (vblank_handler) {
949 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
950 LIST_DEL(&vblank_handler->link);
951 free(vblank_handler);
958 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
959 tdm_output_vblank_handler func, void *user_data)
963 _pthread_mutex_lock(&private_display->lock);
965 if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
966 TDM_WRN("output(%d) dpms: %s", private_output->pipe,
967 tdm_dpms_str(private_output->current_dpms_value));
968 _pthread_mutex_unlock(&private_display->lock);
969 return TDM_ERROR_DPMS_OFF;
972 ret = _tdm_output_wait_vblank(private_output, interval, sync, func, user_data, 0);
974 _pthread_mutex_unlock(&private_display->lock);
979 /* LCOV_EXCL_START */
981 tdm_output_wait_vblank_add_front(tdm_output *output, int interval, int sync,
982 tdm_output_vblank_handler func, void *user_data)
986 _pthread_mutex_lock(&private_display->lock);
988 if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
989 TDM_WRN("output(%d) dpms: %s", private_output->pipe,
990 tdm_dpms_str(private_output->current_dpms_value));
991 _pthread_mutex_unlock(&private_display->lock);
992 return TDM_ERROR_DPMS_OFF;
995 ret = _tdm_output_wait_vblank(private_output, interval, sync, func, user_data, 1);
997 _pthread_mutex_unlock(&private_display->lock);
1001 /* LCOV_EXCL_STOP */
1004 tdm_output_remove_vblank_handler_internal(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
1006 tdm_private_output *private_output = (tdm_private_output*)output;
1007 tdm_private_output_vblank_handler *v = NULL;
1009 TDM_RETURN_IF_FAIL(private_output != NULL);
1010 TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
1012 LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
1013 if (v->func == func && v->user_data == user_data) {
1014 /* only set func & user_data to NULL. It will be freed when an event occurs */
1016 v->user_data = NULL;
1023 tdm_output_remove_commit_handler_internal(tdm_output *output, tdm_output_commit_handler func, void *user_data)
1025 tdm_private_output *private_output = (tdm_private_output*)output;
1026 tdm_private_output_commit_handler *c = NULL;
1028 TDM_RETURN_IF_FAIL(private_output != NULL);
1029 TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
1031 LIST_FOR_EACH_ENTRY(c, &private_output->output_commit_handler_list, link) {
1032 if (c->func == func && c->user_data == user_data) {
1033 /* only set func & user_data to NULL. It will be freed when an event occurs */
1035 c->user_data = NULL;
1042 tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
1044 OUTPUT_FUNC_ENTRY();
1046 _pthread_mutex_lock(&private_display->lock);
1048 tdm_output_remove_vblank_handler_internal(output, func, user_data);
1050 _pthread_mutex_unlock(&private_display->lock);
1056 tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data)
1058 OUTPUT_FUNC_ENTRY();
1060 _pthread_mutex_lock(&private_display->lock);
1062 tdm_output_remove_commit_handler_internal(output, func, user_data);
1064 _pthread_mutex_unlock(&private_display->lock);
1070 tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data)
1072 tdm_private_output *private_output;
1073 tdm_private_backend *private_backend;
1074 tdm_func_output *func_output;
1075 tdm_private_output_commit_handler *output_commit_handler = NULL;
1076 tdm_private_layer *private_layer = NULL;
1077 tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_ON;
1078 tdm_error ret = TDM_ERROR_NONE;
1080 TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER);
1082 private_output = (tdm_private_output*)output;
1083 private_backend = private_output->private_backend;
1084 func_output = &private_backend->func_output;
1086 if (!func_output->output_commit) {
1087 /* LCOV_EXCL_START */
1088 TDM_WRN("not implemented!!");
1089 return TDM_ERROR_NOT_IMPLEMENTED;
1090 /* LCOV_EXCL_STOP */
1093 ret = tdm_output_get_dpms_internal(output, &dpms_value);
1094 TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
1096 if (!TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms_value)) {
1098 if (!private_output->regist_commit_cb) {
1099 private_output->regist_commit_cb = 1;
1100 ret = func_output->output_set_commit_handler(private_output->output_backend, _tdm_output_cb_commit);
1101 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
1104 output_commit_handler = calloc(1, sizeof(tdm_private_output_commit_handler));
1105 if (!output_commit_handler) {
1106 /* LCOV_EXCL_START */
1107 TDM_ERR("failed: alloc memory");
1108 return TDM_ERROR_OUT_OF_MEMORY;
1109 /* LCOV_EXCL_STOP */
1112 ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
1113 if (ret != TDM_ERROR_NONE) {
1114 TDM_ERR("tdm_thread_cb_add failed");
1115 free(output_commit_handler);
1119 LIST_ADDTAIL(&output_commit_handler->link, &private_output->output_commit_handler_list);
1120 output_commit_handler->private_output = private_output;
1121 output_commit_handler->func = func;
1122 output_commit_handler->user_data = user_data;
1123 output_commit_handler->owner_tid = syscall(SYS_gettid);
1126 ret = func_output->output_commit(private_output->output_backend, sync,
1127 output_commit_handler);
1128 TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
1130 if (tdm_debug_module & TDM_DEBUG_COMMIT)
1131 TDM_INFO("output(%d) backend commit: handle(%p) func(%p) user_data(%p)",
1132 private_output->pipe, output_commit_handler, func, user_data);
1135 /* Even if DPMS is off, committed_buffer should be changed because it will be referred
1136 * for tdm_layer_committed() function.
1138 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
1139 if (!private_layer->waiting_buffer)
1142 private_layer->committed_buffer = private_layer->waiting_buffer;
1143 private_layer->waiting_buffer = NULL;
1144 if (tdm_debug_module & TDM_DEBUG_BUFFER)
1145 TDM_INFO("layer(%p) waiting_buffer(%p) committed_buffer(%p)",
1146 private_layer, private_layer->waiting_buffer,
1147 private_layer->committed_buffer->buffer);
1150 if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms_value)) {
1151 TDM_WRN("dpms %s. Directly call commit handler instead of commit.", tdm_dpms_str(dpms_value));
1153 func(output, 0, 0, 0, user_data);
1159 /* LCOV_EXCL_START */
1160 if (output_commit_handler) {
1161 tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
1162 LIST_DEL(&output_commit_handler->link);
1163 free(output_commit_handler);
1166 /* LCOV_EXCL_STOP */
1170 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
1173 tdm_private_layer *private_layer = NULL;
1175 OUTPUT_FUNC_ENTRY();
1177 _pthread_mutex_lock(&private_display->lock);
1179 if (private_output->commit_type == TDM_COMMIT_TYPE_NONE)
1180 private_output->commit_type = TDM_COMMIT_TYPE_OUTPUT;
1181 else if (private_output->commit_type == TDM_COMMIT_TYPE_LAYER) {
1182 TDM_ERR("Can't supported. Use tdm_layer_commit");
1183 _pthread_mutex_unlock(&private_display->lock);
1184 return TDM_ERROR_BAD_REQUEST;
1187 if (private_output->commit_per_vblank) {
1188 TDM_ERR("Use tdm_layer_commit");
1189 _pthread_mutex_unlock(&private_display->lock);
1190 return TDM_ERROR_BAD_REQUEST;
1193 if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
1194 TDM_ERR("output(%d) dpms: %s", private_output->pipe,
1195 tdm_dpms_str(private_output->current_dpms_value));
1196 _pthread_mutex_unlock(&private_display->lock);
1197 return TDM_ERROR_DPMS_OFF;
1200 if (tdm_debug_module & TDM_DEBUG_COMMIT)
1201 TDM_INFO("output(%d) commit", private_output->pipe);
1203 /* apply the pending data of all layers */
1204 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
1205 tdm_layer_commit_pending_data(private_layer);
1208 ret = tdm_output_commit_internal(output, sync, func, user_data);
1210 _pthread_mutex_unlock(&private_display->lock);
1216 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode)
1218 tdm_private_backend *private_backend;
1219 tdm_func_output *func_output;
1220 OUTPUT_FUNC_ENTRY();
1222 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
1224 _pthread_mutex_lock(&private_display->lock);
1226 private_backend = private_output->private_backend;
1227 func_output = &private_backend->func_output;
1229 if (!func_output->output_set_mode) {
1230 /* LCOV_EXCL_START */
1231 _pthread_mutex_unlock(&private_display->lock);
1232 TDM_WRN("not implemented!!");
1233 return TDM_ERROR_NOT_IMPLEMENTED;
1234 /* LCOV_EXCL_STOP */
1237 ret = func_output->output_set_mode(private_output->output_backend, mode);
1238 if (ret == TDM_ERROR_NONE) {
1239 private_output->current_mode = mode;
1240 private_output->need_set_target_info = 1;
1241 TDM_INFO("mode: %dx%d %dhz", mode->hdisplay, mode->vdisplay, mode->vrefresh);
1244 _pthread_mutex_unlock(&private_display->lock);
1250 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
1252 OUTPUT_FUNC_ENTRY();
1254 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
1256 _pthread_mutex_lock(&private_display->lock);
1258 *mode = private_output->current_mode;
1260 _pthread_mutex_unlock(&private_display->lock);
1266 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
1268 tdm_private_backend *private_backend;
1269 tdm_func_output *func_output;
1270 OUTPUT_FUNC_ENTRY();
1272 if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
1273 if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
1274 TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
1275 return TDM_ERROR_BAD_REQUEST;
1278 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
1279 TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
1280 private_output->pipe, tdm_dpms_str(dpms_value));
1281 return TDM_ERROR_BAD_REQUEST;
1285 _pthread_mutex_lock(&private_display->lock);
1287 if (private_output->waiting_dpms_change) {
1288 TDM_ERR("DPMS is not changed yet. Can't be changed twice");
1289 _pthread_mutex_unlock(&private_display->lock);
1290 return TDM_ERROR_BAD_REQUEST;
1293 private_backend = private_output->private_backend;
1294 func_output = &private_backend->func_output;
1296 TDM_INFO("output(%d) dpms '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
1298 if (func_output->output_set_dpms)
1299 ret = func_output->output_set_dpms(private_output->output_backend, dpms_value);
1301 /* LCOV_EXCL_START */
1302 ret = TDM_ERROR_NONE;
1303 TDM_WRN("not implemented!!");
1305 /* LCOV_EXCL_STOP */
1309 if (ret == TDM_ERROR_NONE) {
1310 if (private_output->current_dpms_value != dpms_value) {
1312 private_output->current_dpms_value = dpms_value;
1313 value.u32 = dpms_value;
1314 _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
1315 TDM_INFO("output(%d) dpms '%s' done", private_output->pipe, tdm_dpms_str(dpms_value));
1318 tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
1320 /* update current_dpms_value forcely */
1321 tdm_output_get_dpms_internal(output, &temp);
1323 TDM_ERR("output(%d) set_dpms failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
1326 _pthread_mutex_unlock(&private_display->lock);
1331 /* LCOV_EXCL_START */
1333 tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value)
1335 tdm_private_backend *private_backend;
1336 tdm_func_output *func_output;
1337 OUTPUT_FUNC_ENTRY();
1339 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_ASYNC_DPMS)) {
1340 TDM_ERR("output doesn't support the asynchronous DPMS control!");
1341 return TDM_ERROR_BAD_REQUEST;
1344 if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
1345 if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
1346 TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
1347 return TDM_ERROR_BAD_REQUEST;
1350 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
1351 TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
1352 private_output->pipe, tdm_dpms_str(dpms_value));
1353 return TDM_ERROR_BAD_REQUEST;
1357 _pthread_mutex_lock(&private_display->lock);
1359 if (private_output->waiting_dpms_change) {
1360 TDM_ERR("DPMS is not changed yet. Can't be changed twice");
1361 _pthread_mutex_unlock(&private_display->lock);
1362 return TDM_ERROR_BAD_REQUEST;
1365 private_backend = private_output->private_backend;
1366 func_output = &private_backend->func_output;
1367 if (!func_output->output_set_dpms_handler) {
1368 TDM_WRN("not implemented: output_set_dpms_handler");
1369 _pthread_mutex_unlock(&private_display->lock);
1370 return TDM_ERROR_NOT_IMPLEMENTED;
1373 if (!func_output->output_set_dpms_async) {
1374 TDM_WRN("not implemented: output_set_dpms_async");
1375 _pthread_mutex_unlock(&private_display->lock);
1376 return TDM_ERROR_NOT_IMPLEMENTED;
1379 if (!private_output->regist_dpms_cb) {
1380 private_output->regist_dpms_cb = 1;
1381 ret = func_output->output_set_dpms_handler(private_output->output_backend,
1382 tdm_output_cb_dpms, private_output);
1383 if (ret != TDM_ERROR_NONE) {
1384 _pthread_mutex_unlock(&private_display->lock);
1385 TDM_ERR("Can't set the dpms handler!!");
1390 TDM_INFO("output(%d) dpms async '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
1392 ret = func_output->output_set_dpms_async(private_output->output_backend, dpms_value);
1394 if (ret == TDM_ERROR_NONE) {
1395 private_output->waiting_dpms_change = 1;
1396 TDM_INFO("output(%d) dpms async '%s' waiting", private_output->pipe, tdm_dpms_str(dpms_value));
1398 tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
1400 /* update current_dpms_value forcely */
1401 tdm_output_get_dpms_internal(output, &temp);
1403 TDM_ERR("output(%d) set_dpms_async failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
1406 _pthread_mutex_unlock(&private_display->lock);
1410 /* LCOV_EXCL_STOP */
1413 tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value)
1415 tdm_private_output *private_output;
1416 tdm_private_backend *private_backend;
1417 tdm_func_output *func_output;
1418 tdm_error ret = TDM_ERROR_NONE;
1420 TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER);
1422 private_output = (tdm_private_output*)output;
1424 /* TODO: this is ugly. But before calling backend's output_get_dpms(), we have
1425 * to check if all backends's DPMS operation has no problem. In future, we'd
1426 * better use new env instead of using commit_per_vblank variable to distinguish
1427 * whether we use the stored value or backend's output_get_dpms.
1429 if (!private_output->commit_per_vblank) {
1430 *dpms_value = private_output->current_dpms_value;
1431 return TDM_ERROR_NONE;
1434 private_backend = private_output->private_backend;
1435 func_output = &private_backend->func_output;
1437 if (!func_output->output_get_dpms) {
1438 /* LCOV_EXCL_START */
1439 *dpms_value = private_output->current_dpms_value;
1440 TDM_WRN("not implemented!!");
1441 return TDM_ERROR_NONE;
1442 /* LCOV_EXCL_STOP */
1445 ret = func_output->output_get_dpms(private_output->output_backend, dpms_value);
1446 if (ret != TDM_ERROR_NONE) {
1447 /* LCOV_EXCL_START */
1448 TDM_ERR("output_get_dpms failed");
1449 *dpms_value = TDM_OUTPUT_DPMS_OFF;
1450 /* LCOV_EXCL_STOP */
1453 /* checking with backend's value */
1454 if (*dpms_value != private_output->current_dpms_value) {
1456 TDM_ERR("output(%d) dpms changed suddenly: %s -> %s",
1457 private_output->pipe, private_output->current_dpms_value,
1458 tdm_dpms_str(*dpms_value));
1459 private_output->current_dpms_value = *dpms_value;
1460 value.u32 = *dpms_value;
1461 _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
1468 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
1470 OUTPUT_FUNC_ENTRY();
1472 TDM_RETURN_VAL_IF_FAIL(dpms_value != NULL, TDM_ERROR_INVALID_PARAMETER);
1474 _pthread_mutex_lock(&private_display->lock);
1476 ret = tdm_output_get_dpms_internal(output, dpms_value);
1478 _pthread_mutex_unlock(&private_display->lock);
1483 EXTERN tdm_capture *
1484 tdm_output_create_capture(tdm_output *output, tdm_error *error)
1486 tdm_capture *capture = NULL;
1488 OUTPUT_FUNC_ENTRY_ERROR();
1490 _pthread_mutex_lock(&private_display->lock);
1492 capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error);
1494 _pthread_mutex_unlock(&private_display->lock);
1499 EXTERN tdm_hwc_window *
1500 tdm_output_hwc_create_window(tdm_output *output, tdm_error *error)
1502 tdm_hwc_window *hwc_window = NULL;
1504 OUTPUT_FUNC_ENTRY_ERROR();
1506 _pthread_mutex_lock(&private_display->lock);
1508 if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
1509 hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 0, error);
1511 /* LCOV_EXCL_START */
1512 TDM_ERR("output(%p) not support HWC", private_output);
1514 *error = TDM_ERROR_BAD_REQUEST;
1515 /* LCOV_EXCL_STOP */
1518 _pthread_mutex_unlock(&private_display->lock);
1523 EXTERN tdm_hwc_window *
1524 tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error)
1526 tdm_hwc_window *hwc_window = NULL;
1528 OUTPUT_FUNC_ENTRY_ERROR();
1530 _pthread_mutex_lock(&private_display->lock);
1532 if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
1533 hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 1, error);
1535 /* LCOV_EXCL_START */
1536 TDM_ERR("output(%p) not support HWC", private_output);
1538 *error = TDM_ERROR_BAD_REQUEST;
1539 /* LCOV_EXCL_STOP */
1542 _pthread_mutex_unlock(&private_display->lock);
1548 tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window)
1550 OUTPUT_FUNC_ENTRY();
1552 TDM_RETURN_VAL_IF_FAIL(hwc_window != NULL, TDM_ERROR_INVALID_PARAMETER);
1554 _pthread_mutex_lock(&private_display->lock);
1556 ret = tdm_hwc_window_destroy_internal(hwc_window);
1558 _pthread_mutex_unlock(&private_display->lock);
1564 tdm_output_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds,
1565 uint32_t num_wnds, uint32_t *num_types)
1567 tdm_private_backend *private_backend;
1568 tdm_func_output *func_output = NULL;
1569 tdm_private_hwc_window **composited_wnds_frontend = NULL;
1570 tdm_hwc_window **composited_wnds_backend = NULL;
1573 OUTPUT_FUNC_ENTRY();
1575 TDM_RETURN_VAL_IF_FAIL(num_types != NULL, TDM_ERROR_INVALID_PARAMETER);
1577 _pthread_mutex_lock(&private_display->lock);
1579 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1580 TDM_ERR("output(%p) not support HWC", private_output);
1581 _pthread_mutex_unlock(&private_display->lock);
1582 return TDM_ERROR_BAD_REQUEST;
1585 private_backend = private_output->private_backend;
1586 func_output = &private_backend->func_output;
1588 if (!func_output->output_hwc_validate) {
1589 /* LCOV_EXCL_START */
1590 _pthread_mutex_unlock(&private_display->lock);
1591 TDM_WRN("not implemented!!");
1592 return TDM_ERROR_NOT_IMPLEMENTED;
1593 /* LCOV_EXCL_STOP */
1596 if (num_wnds == 0) {
1597 ret = func_output->output_hwc_validate(private_output->output_backend, NULL, 0, num_types);
1599 _pthread_mutex_unlock(&private_display->lock);
1604 composited_wnds_backend = calloc(num_wnds, sizeof(tdm_hwc_window *));
1605 if (!composited_wnds_backend) {
1606 /* LCOV_EXCL_START */
1607 _pthread_mutex_unlock(&private_display->lock);
1608 return TDM_ERROR_OUT_OF_MEMORY;
1609 /* LCOV_EXCL_STOP */
1612 composited_wnds_frontend = (tdm_private_hwc_window **)composited_wnds;
1614 for (i = 0; i < num_wnds; i++)
1615 composited_wnds_backend[i] = composited_wnds_frontend[i]->hwc_window_backend;
1617 ret = func_output->output_hwc_validate(private_output->output_backend, composited_wnds_backend, num_wnds, num_types);
1619 free(composited_wnds_backend);
1621 _pthread_mutex_unlock(&private_display->lock);
1627 tdm_output_hwc_set_need_validate_handler(tdm_output *output,
1628 tdm_output_need_validate_handler hndl)
1630 OUTPUT_FUNC_ENTRY();
1632 TDM_RETURN_VAL_IF_FAIL(hndl != NULL, TDM_ERROR_INVALID_PARAMETER);
1634 _pthread_mutex_lock(&private_display->lock);
1636 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1637 TDM_ERR("output(%p) not support HWC", private_output);
1638 _pthread_mutex_unlock(&private_display->lock);
1639 return TDM_ERROR_BAD_REQUEST;
1642 /* there's no reason to allow this */
1643 if (private_output->need_validate.hndl) {
1645 _pthread_mutex_unlock(&private_display->lock);
1646 return TDM_ERROR_OPERATION_FAILED;
1649 private_output->need_validate.hndl = hndl;
1651 _pthread_mutex_unlock(&private_display->lock);
1657 tdm_output_hwc_get_changed_composition_types(tdm_output *output,
1658 uint32_t *num_elements,
1659 tdm_hwc_window **hwc_window,
1660 tdm_hwc_window_composition *composition_types)
1662 tdm_private_backend *private_backend;
1663 tdm_func_output *func_output = NULL;
1664 tdm_private_hwc_window * private_hwc_window = NULL;
1667 OUTPUT_FUNC_ENTRY();
1669 TDM_RETURN_VAL_IF_FAIL(num_elements != NULL, TDM_ERROR_INVALID_PARAMETER);
1671 _pthread_mutex_lock(&private_display->lock);
1673 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1674 TDM_ERR("output(%p) not support HWC", private_output);
1675 _pthread_mutex_unlock(&private_display->lock);
1676 return TDM_ERROR_BAD_REQUEST;
1679 private_backend = private_output->private_backend;
1680 func_output = &private_backend->func_output;
1682 if (!func_output->output_hwc_get_changed_composition_types) {
1683 /* LCOV_EXCL_START */
1684 _pthread_mutex_unlock(&private_display->lock);
1685 TDM_WRN("not implemented!!");
1686 return TDM_ERROR_NOT_IMPLEMENTED;
1687 /* LCOV_EXCL_STOP */
1690 ret = func_output->output_hwc_get_changed_composition_types(private_output->output_backend,
1691 num_elements, hwc_window, composition_types);
1692 if (ret != TDM_ERROR_NONE) {
1693 /* LCOV_EXCL_START */
1694 _pthread_mutex_unlock(&private_display->lock);
1696 /* LCOV_EXCL_STOP */
1699 if (hwc_window == NULL || composition_types == NULL) {
1700 _pthread_mutex_unlock(&private_display->lock);
1701 return TDM_ERROR_NONE;
1704 for (i = 0; i < *num_elements; i++) {
1706 private_hwc_window = _tdm_output_find_private_hwc_window(private_output, hwc_window[i]);
1708 if (private_hwc_window == NULL) {
1709 /* LCOV_EXCL_START */
1710 TDM_ERR("failed! This should never happen!");
1711 func_output->output_hwc_destroy_window(private_output->output_backend, hwc_window[i]);
1713 _pthread_mutex_unlock(&private_display->lock);
1714 return TDM_ERROR_OPERATION_FAILED;
1715 /* LCOV_EXCL_STOP */
1718 hwc_window[i] = (tdm_hwc_window*)private_hwc_window;
1721 _pthread_mutex_unlock(&private_display->lock);
1727 tdm_output_hwc_accept_changes(tdm_output *output)
1729 tdm_private_backend *private_backend;
1730 tdm_func_output *func_output = NULL;
1732 OUTPUT_FUNC_ENTRY();
1734 _pthread_mutex_lock(&private_display->lock);
1736 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1737 TDM_ERR("output(%p) not support HWC", private_output);
1738 _pthread_mutex_unlock(&private_display->lock);
1739 return TDM_ERROR_BAD_REQUEST;
1742 private_backend = private_output->private_backend;
1743 func_output = &private_backend->func_output;
1745 if (!func_output->output_hwc_validate) {
1746 /* LCOV_EXCL_START */
1747 _pthread_mutex_unlock(&private_display->lock);
1748 TDM_WRN("not implemented!!");
1749 return TDM_ERROR_NOT_IMPLEMENTED;
1750 /* LCOV_EXCL_STOP */
1753 ret = func_output->output_hwc_accept_changes(private_output->output_backend);
1755 _pthread_mutex_unlock(&private_display->lock);
1761 tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error)
1763 tdm_private_backend *private_backend;
1764 tdm_func_output *func_output = NULL;
1765 tbm_surface_queue_h queue = NULL;
1767 OUTPUT_FUNC_ENTRY_ERROR();
1769 _pthread_mutex_lock(&private_display->lock);
1771 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1772 TDM_ERR("output(%p) not support HWC", private_output);
1774 *error = TDM_ERROR_BAD_REQUEST;
1775 _pthread_mutex_unlock(&private_display->lock);
1779 private_backend = private_output->private_backend;
1780 func_output = &private_backend->func_output;
1782 if (!func_output->output_hwc_get_target_buffer_queue) {
1783 /* LCOV_EXCL_START */
1784 _pthread_mutex_unlock(&private_display->lock);
1785 TDM_WRN("not implemented!!");
1787 /* LCOV_EXCL_STOP */
1790 queue = func_output->output_hwc_get_target_buffer_queue(private_output->output_backend, error);
1792 _pthread_mutex_unlock(&private_display->lock);
1798 tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer, tdm_hwc_region damage)
1800 tdm_private_backend *private_backend;
1801 tdm_func_output *func_output = NULL;
1803 OUTPUT_FUNC_ENTRY();
1805 _pthread_mutex_lock(&private_display->lock);
1807 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1808 TDM_ERR("output(%p) not support HWC", private_output);
1809 _pthread_mutex_unlock(&private_display->lock);
1810 return TDM_ERROR_BAD_REQUEST;
1813 if (tdm_debug_dump & TDM_DUMP_FLAG_WINDOW) {
1814 /* LCOV_EXCL_START */
1815 char str[TDM_PATH_LEN];
1817 snprintf(str, TDM_PATH_LEN, "target_window_%d_%03d",
1818 private_output->index, i++);
1819 tdm_helper_dump_buffer_str(target_buffer, tdm_debug_dump_dir, str);
1820 /* LCOV_EXCL_STOP */
1823 private_backend = private_output->private_backend;
1824 func_output = &private_backend->func_output;
1826 if (!func_output->output_hwc_set_client_target_buffer) {
1827 /* LCOV_EXCL_START */
1828 _pthread_mutex_unlock(&private_display->lock);
1829 TDM_WRN("not implemented!!");
1830 return TDM_ERROR_NOT_IMPLEMENTED;
1831 /* LCOV_EXCL_STOP */
1834 ret = func_output->output_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, damage);
1836 _pthread_mutex_unlock(&private_display->lock);
1842 tdm_output_hwc_unset_client_target_buffer(tdm_output *output)
1844 tdm_private_backend *private_backend;
1845 tdm_func_output *func_output = NULL;
1847 OUTPUT_FUNC_ENTRY();
1849 _pthread_mutex_lock(&private_display->lock);
1851 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1852 TDM_ERR("output(%p) not support HWC", private_output);
1853 _pthread_mutex_unlock(&private_display->lock);
1854 return TDM_ERROR_BAD_REQUEST;
1857 private_backend = private_output->private_backend;
1858 func_output = &private_backend->func_output;
1860 if (!func_output->output_hwc_unset_client_target_buffer) {
1861 /* LCOV_EXCL_START */
1862 _pthread_mutex_unlock(&private_display->lock);
1863 TDM_ERR("not implemented!!");
1864 return TDM_ERROR_NOT_IMPLEMENTED;
1865 /* LCOV_EXCL_STOP */
1868 ret = func_output->output_hwc_unset_client_target_buffer(private_output->output_backend);
1870 _pthread_mutex_unlock(&private_display->lock);
1876 _tdm_output_hwc_layer_commit_handler(tdm_layer *layer, unsigned int sequence,
1877 unsigned int tv_sec, unsigned int tv_usec,
1880 tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler = (tdm_private_output_hwc_target_buffer_commit_handler *)user_data;
1881 tdm_output_hwc_target_buffer_commit_handler func = output_hwc_target_buffer_commit_handler->func;
1882 tdm_output *output = (tdm_output *)output_hwc_target_buffer_commit_handler->private_output;
1883 void *data = output_hwc_target_buffer_commit_handler->user_data;
1885 func(output, sequence, tv_sec, tv_usec, data);
1887 free(output_hwc_target_buffer_commit_handler);
1891 tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_target_buffer_commit_handler func, void *user_data)
1893 tdm_private_backend *private_backend;
1894 tdm_func_output *func_output;
1895 tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler;
1896 tdm_layer *layer = NULL;
1897 tdm_private_layer *private_layer;
1898 const tdm_output_mode *mode;
1899 tbm_surface_h buffer;
1901 OUTPUT_FUNC_ENTRY();
1903 _pthread_mutex_lock(&private_display->lock);
1905 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
1906 TDM_ERR("output(%p) not support HWC", private_output);
1907 _pthread_mutex_unlock(&private_display->lock);
1908 return TDM_ERROR_BAD_REQUEST;
1911 private_backend = private_output->private_backend;
1912 func_output = &private_backend->func_output;
1914 if (!func_output->output_hwc_get_client_target_buffer_layer) {
1915 /* LCOV_EXCL_START */
1916 _pthread_mutex_unlock(&private_display->lock);
1917 TDM_ERR("not implemented!!");
1918 return TDM_ERROR_NOT_IMPLEMENTED;
1919 /* LCOV_EXCL_STOP */
1922 layer = func_output->output_hwc_get_client_target_buffer_layer(private_output->output_backend,
1925 /* LCOV_EXCL_START */
1926 _pthread_mutex_unlock(&private_display->lock);
1927 TDM_ERR("no assigned layer!!");
1928 return TDM_ERROR_INVALID_PARAMETER;
1929 /* LCOV_EXCL_STOP */
1932 private_layer = (tdm_private_layer*)layer;
1934 if (!func_output->output_hwc_get_client_target_buffer) {
1935 /* LCOV_EXCL_START */
1936 _pthread_mutex_unlock(&private_display->lock);
1937 TDM_ERR("not implemented!!");
1938 return TDM_ERROR_NOT_IMPLEMENTED;
1939 /* LCOV_EXCL_STOP */
1942 buffer = func_output->output_hwc_get_client_target_buffer(private_output->output_backend,
1945 ret = tdm_layer_set_buffer_internal(private_layer, buffer);
1947 ret = tdm_layer_unset_buffer_internal(private_layer);
1948 if (ret != TDM_ERROR_NONE) {
1949 /* LCOV_EXCL_START */
1950 TDM_ERR("failed: layer set info(window)");
1951 /* LCOV_EXCL_STOP */
1955 if (private_output->need_set_target_info) {
1956 mode = private_output->current_mode;
1957 private_output->target_buffer_info.src_config.size.h = mode->hdisplay;
1958 private_output->target_buffer_info.src_config.size.v = mode->vdisplay;
1959 private_output->target_buffer_info.src_config.pos.x = 0;
1960 private_output->target_buffer_info.src_config.pos.y = 0;
1961 private_output->target_buffer_info.src_config.pos.w = mode->hdisplay;
1962 private_output->target_buffer_info.src_config.pos.h = mode->vdisplay;
1963 private_output->target_buffer_info.dst_pos.x = 0;
1964 private_output->target_buffer_info.dst_pos.y = 0;
1965 private_output->target_buffer_info.dst_pos.w = mode->hdisplay;
1966 private_output->target_buffer_info.dst_pos.h = mode->vdisplay;
1967 private_output->target_buffer_info.transform = TDM_TRANSFORM_NORMAL;
1969 ret = tdm_layer_set_info_internal(private_layer, &private_output->target_buffer_info);
1970 if (ret != TDM_ERROR_NONE) {
1971 /* LCOV_EXCL_START */
1972 TDM_ERR("failed: layer set info(window)");
1973 /* LCOV_EXCL_STOP */
1977 private_output->need_set_target_info = 0;
1980 output_hwc_target_buffer_commit_handler = calloc(1, sizeof(tdm_private_output_hwc_target_buffer_commit_handler));
1981 if (!output_hwc_target_buffer_commit_handler) {
1982 /* LCOV_EXCL_START */
1983 TDM_ERR("failed: alloc memory");
1984 return TDM_ERROR_OUT_OF_MEMORY;
1985 /* LCOV_EXCL_STOP */
1988 output_hwc_target_buffer_commit_handler->private_output = private_output;
1989 output_hwc_target_buffer_commit_handler->func = func;
1990 output_hwc_target_buffer_commit_handler->user_data = user_data;
1992 ret = tdm_layer_commit_internal(private_layer, _tdm_output_hwc_layer_commit_handler, user_data);
1993 if (ret != TDM_ERROR_NONE) {
1994 /* LCOV_EXCL_START */
1995 TDM_ERR("failed: commit layer(target buffer)");
1996 free(output_hwc_target_buffer_commit_handler);
1997 /* LCOV_EXCL_STOP */
2001 _pthread_mutex_unlock(&private_display->lock);
2007 tdm_output_hwc_get_video_supported_formats(tdm_output *output, const tbm_format **formats,
2010 tdm_private_backend *private_backend;
2011 tdm_func_output *func_output;
2012 OUTPUT_FUNC_ENTRY();
2014 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
2015 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
2017 _pthread_mutex_lock(&private_display->lock);
2019 private_backend = private_output->private_backend;
2020 func_output = &private_backend->func_output;
2022 if (!func_output->output_hwc_get_video_supported_formats) {
2023 /* LCOV_EXCL_START */
2024 _pthread_mutex_unlock(&private_display->lock);
2025 TDM_WRN("not implemented!!");
2026 return TDM_ERROR_NOT_IMPLEMENTED;
2027 /* LCOV_EXCL_STOP */
2030 ret = func_output->output_hwc_get_video_supported_formats(
2031 private_output->output_backend, formats, count);
2033 _pthread_mutex_unlock(&private_display->lock);
2039 _is_hwc_output_still_existed(tdm_private_output *private_output)
2041 tdm_private_backend *private_backend = private_output->private_backend;
2042 tdm_private_output *o = NULL;
2044 LIST_FOR_EACH_ENTRY(o, &private_backend->output_list, link) {
2045 if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
2048 if (o == private_output)
2058 /* gets called on behalf of the ecore-main-loop thread */
2060 tdm_output_need_validate_handler_thread(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
2062 tdm_private_output *private_output = object;
2064 TDM_RETURN_IF_FAIL(private_output != NULL);
2066 _pthread_mutex_lock(&private_display->lock);
2068 /* as we get 'private_output' within an event, an output this 'private_output'
2069 * points to can be destroyed already */
2070 if (!_is_hwc_output_still_existed(private_output)) {
2071 _pthread_mutex_unlock(&private_display->lock);
2075 _pthread_mutex_unlock(&private_display->lock);
2077 TDM_INFO("tdm-backend asks for revalidation for the output:%p.", private_output);
2079 if (private_output->need_validate.hndl)
2080 private_output->need_validate.hndl((tdm_output*)private_output);
2083 /* gets called on behalf of the tdm-thread */
2085 _need_validate_handler(int fd, tdm_event_loop_mask mask, void *user_data)
2087 tdm_thread_cb_need_validate ev;
2088 tdm_private_output *private_output;
2092 private_output = (tdm_private_output *)user_data;
2094 if (read(private_output->need_validate.event_fd, &value, sizeof(value)) < 0) {
2095 TDM_ERR("error while trying to read from a need_validate.event_fd fd.");
2096 return TDM_ERROR_OPERATION_FAILED;
2099 memset(&ev, 0, sizeof ev);
2100 ev.base.type = TDM_THREAD_CB_NEED_VALIDATE;
2101 ev.base.length = sizeof ev;
2102 ev.base.object_stamp = private_output->stamp;
2103 ev.base.data = NULL;
2106 ret = tdm_thread_cb_call(private_output, &ev.base);
2107 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
2109 TDM_INFO("tdm-thread: get a 'need to revalidate' event for the ouptut:%p.", private_output);
2111 /* who cares about this? */
2112 return TDM_ERROR_NONE;
2116 tdm_output_need_validate_event_init(tdm_output *output)
2120 OUTPUT_FUNC_ENTRY();
2122 TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
2124 if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
2125 TDM_ERR("output(%p) not support HWC", private_output);
2126 return TDM_ERROR_BAD_REQUEST;
2129 /* build in eventfd fds into event_loop listened & handled by the tdm-thread */
2131 TDM_WARNING_IF_FAIL(fd >= 0);
2133 private_output->need_validate.event_source = tdm_event_loop_add_fd_handler(private_display,
2134 fd, TDM_EVENT_LOOP_READABLE, _need_validate_handler, private_output, &ret);
2135 TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
2137 private_output->need_validate.event_fd = fd;
2139 TDM_INFO("register an output:%p for the revalidation, event_fd:%d.", private_output, fd);
2145 tdm_output_choose_commit_per_vblank_mode(tdm_private_output *private_output, int mode)
2147 if (!private_output)
2148 return TDM_ERROR_INVALID_PARAMETER;
2150 if (mode < 0 || mode > 2)
2151 return TDM_ERROR_INVALID_PARAMETER;
2153 private_output->commit_per_vblank = mode;
2155 if (private_output->commit_per_vblank == 0)
2156 TDM_INFO("commit per vblank: disable");
2157 else if (private_output->commit_per_vblank == 1)
2158 TDM_INFO("commit per vblank: enable (1 layer)");
2159 else if (private_output->commit_per_vblank == 2)
2160 TDM_INFO("commit per vblank: enable (previous commit)");
2162 return TDM_ERROR_NONE;