* Taeheon Kim <th908.kim@samsung.com>,
* YoungJun Cho <yj44.cho@samsung.com>,
* SooChan Lim <sc1.lim@samsung.com>,
- * Boram Park <sc1.lim@samsung.com>
+ * Boram Park <boram1288.park@samsung.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
#include "config.h"
#endif
-#include "tdm.h"
-#include "tdm_backend.h"
#include "tdm_private.h"
-#include "tdm_helper.h"
#define COUNT_MAX 10
private_output = (tdm_private_output*)output; \
private_display = private_output->private_display
-EXTERN tdm_error
-tdm_output_get_model_info(tdm_output *output, const char **maker,
- const char **model, const char **name)
+static void
+_tdm_output_vblank_timeout_update(tdm_private_output *private_output, int ms_delay);
+
+static tdm_error
+_tdm_output_vblank_timeout_cb(void *user_data)
{
- OUTPUT_FUNC_ENTRY();
+ tdm_private_output *private_output = user_data;
+ tdm_private_output_vblank_handler *v = NULL;
- _pthread_mutex_lock(&private_display->lock);
+ TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OPERATION_FAILED);
- if (maker)
- *maker = private_output->caps.maker;
- if (model)
- *model = private_output->caps.model;
- if (name)
- *name = private_output->caps.name;
+ private_output->vblank_timeout_timer_expired++;
- _pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("TDM output(%d) vblank TIMEOUT!! (%d time%s)",
+ private_output->pipe,
+ private_output->vblank_timeout_timer_expired,
+ (private_output->vblank_timeout_timer_expired > 1) ? "s" : "");
- return ret;
+ LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
+ TDM_ERR("vblank_handler(%p) interval(%d) sync(%d) sent_to_frontend(%u) owner_tid(%d)",
+ v, v->interval, v->sync, v->sent_to_frontend, v->owner_tid);
+ }
+
+ return TDM_ERROR_NONE;
}
-EXTERN tdm_error
-tdm_output_get_capabilities(tdm_output *output, tdm_output_capability *capabilities)
+INTERN void
+tdm_output_vblank_print_wait_information(tdm_private_output *private_output, void *user_data)
{
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_private_output_vblank_handler *v = NULL;
- *capabilities = private_output->caps.capabilities;
+ TDM_RETURN_IF_FAIL(private_output != NULL);
+ TDM_RETURN_IF_FAIL(user_data != NULL);
- _pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("TDM output(%d) vblank user_data(%p) info!!", private_output->pipe, user_data);
- return ret;
+ LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
+ if (v->user_data != user_data)
+ continue;
+ TDM_ERR("vblank_handler(%p) interval(%d) sync(%d) sent_to_frontend(%u) owner_tid(%d)",
+ v, v->interval, v->sync, v->sent_to_frontend, v->owner_tid);
+ }
}
-EXTERN tdm_error
-tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status)
+static void
+_tdm_output_vblank_timeout_update(tdm_private_output *private_output, int ms_delay)
{
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
+ tdm_error ret;
- _pthread_mutex_lock(&private_display->lock);
+ if (!private_output->vblank_timeout_timer) {
+ private_output->vblank_timeout_timer =
+ tdm_event_loop_add_timer_handler(private_output->private_display,
+ _tdm_output_vblank_timeout_cb,
+ private_output,
+ &ret);
+ if (!private_output->vblank_timeout_timer) {
+ TDM_ERR("output(%d) couldn't add timer", private_output->pipe);
+ return;
+ }
+ TDM_INFO("output(%d) create vblank timeout timer", private_output->pipe);
+ private_output->vblank_timeout_timer_expired = 0;
+ }
- *status = private_output->caps.status;
+ ret = tdm_event_loop_source_timer_update(private_output->vblank_timeout_timer, ms_delay);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("output(%d) couldn't update timer", private_output->pipe);
+ return;
+ }
+}
- _pthread_mutex_unlock(&private_display->lock);
+INTERN tdm_error
+tdm_output_init(tdm_private_display *private_display)
+{
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_DESTROY, tdm_display_find_output_stamp);
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_COMMIT, tdm_display_find_output_stamp);
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_VBLANK, tdm_display_find_output_stamp);
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_STATUS, tdm_display_find_output_stamp);
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_DPMS, tdm_display_find_output_stamp);
+ tdm_thread_cb_set_find_func(TDM_THREAD_CB_VOUTPUT_COMMIT, tdm_display_find_private_voutput);
- return ret;
+ return TDM_ERROR_NONE;
}
-static void
-_tdm_output_update(tdm_output *output_backend, void *user_data)
+INTERN tdm_error
+tdm_output_call_thread_cb_destroy(tdm_private_output *private_output)
{
- tdm_private_display *private_display;
- tdm_private_output *private_output = user_data;
+ tdm_thread_cb_output_destroy output_destroy;
tdm_error ret;
- TDM_RETURN_IF_FAIL(private_output);
+ memset(&output_destroy, 0, sizeof output_destroy);
+ output_destroy.base.type = TDM_THREAD_CB_OUTPUT_DESTROY;
+ output_destroy.base.length = sizeof output_destroy;
+ output_destroy.base.object_stamp = private_output->stamp;
+ output_destroy.base.data = NULL;
+ output_destroy.base.sync = 1;
- private_display = private_output->private_display;
+ ret = tdm_thread_cb_call(private_output, &output_destroy.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
- ret = tdm_display_update_output(private_display, output_backend, private_output->pipe);
- TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ return TDM_ERROR_NONE;
}
+/* LCOV_EXCL_START */
INTERN void
-tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status,
- void *user_data)
+tdm_output_thread_cb_destroy(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
{
- tdm_private_display *private_display;
- tdm_private_output *private_output = user_data;
- tdm_value value;
+ tdm_private_output *private_output = object;
+ tdm_private_output_destroy_handler *destroy_handler = user_data;
TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
- TDM_RETURN_IF_FAIL(private_output);
-
- private_display = private_output->private_display;
-
- if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) {
- tdm_thread_cb_output_status output_status;
- tdm_error ret;
-
- _tdm_output_update(output_backend, user_data);
-
- output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS;
- output_status.base.length = sizeof output_status;
- output_status.output_stamp = private_output->stamp;
- output_status.status = status;
- output_status.user_data = user_data;
-
- value.u32 = status;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_sub,
- TDM_OUTPUT_CHANGE_CONNECTION,
- value, 0);
- ret = tdm_thread_send_cb(private_display->private_loop, &output_status.base);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+ assert(destroy_handler->owner_tid == syscall(SYS_gettid));
- return;
- }
-
- if (!tdm_thread_is_running())
- _tdm_output_update(output_backend, user_data);
-
- value.u32 = status;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_main,
- TDM_OUTPUT_CHANGE_CONNECTION,
- value, 0);
+ _pthread_mutex_unlock(&private_display->lock);
+ destroy_handler->func(private_output, destroy_handler->user_data);
+ _pthread_mutex_lock(&private_display->lock);
}
EXTERN tdm_error
-tdm_output_add_change_handler(tdm_output *output,
- tdm_output_change_handler func,
- void *user_data)
+tdm_output_add_destroy_handler(tdm_output *output,
+ tdm_output_destroy_handler func,
+ void *user_data)
{
- tdm_private_change_handler *change_handler;
+ tdm_private_output_destroy_handler *destroy_handler = NULL;
OUTPUT_FUNC_ENTRY();
TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
- pthread_mutex_lock(&private_display->lock);
+ _pthread_mutex_lock(&private_display->lock);
- change_handler = calloc(1, sizeof(tdm_private_change_handler));
- if (!change_handler) {
+ LIST_FOR_EACH_ENTRY(destroy_handler, &private_output->destroy_handler_list, link) {
+ if (destroy_handler->func == func && destroy_handler->user_data == user_data) {
+ TDM_ERR("can't add twice");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
+
+ destroy_handler = calloc(1, sizeof(tdm_private_output_destroy_handler));
+ if (!destroy_handler) {
TDM_ERR("failed: alloc memory");
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_OUT_OF_MEMORY;
}
- change_handler->private_output = private_output;
- change_handler->func = func;
- change_handler->user_data = user_data;
- change_handler->owner_tid = syscall(SYS_gettid);
+ ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_DESTROY, NULL, tdm_output_thread_cb_destroy, destroy_handler);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("tdm_thread_cb_add failed");
+ free(destroy_handler);
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OPERATION_FAILED;
+ }
- if (!tdm_thread_in_display_thread(change_handler->owner_tid))
- LIST_ADDTAIL(&change_handler->link, &private_output->change_handler_list_sub);
- else
- LIST_ADDTAIL(&change_handler->link, &private_output->change_handler_list_main);
+ destroy_handler->private_output = private_output;
+ destroy_handler->func = func;
+ destroy_handler->user_data = user_data;
+ destroy_handler->owner_tid = syscall(SYS_gettid);
+
+ LIST_ADDTAIL(&destroy_handler->link, &private_output->destroy_handler_list);
_pthread_mutex_unlock(&private_display->lock);
}
EXTERN void
-tdm_output_remove_change_handler(tdm_output *output,
- tdm_output_change_handler func,
- void *user_data)
+tdm_output_remove_destroy_handler(tdm_output *output,
+ tdm_output_destroy_handler func,
+ void *user_data)
{
tdm_private_display *private_display;
tdm_private_output *private_output;
- tdm_private_change_handler *h = NULL, *hh = NULL;
+ tdm_private_output_destroy_handler *destroy_handler = NULL, *hh = NULL;
TDM_RETURN_IF_FAIL(output != NULL);
TDM_RETURN_IF_FAIL(func != NULL);
_pthread_mutex_lock(&private_display->lock);
- LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list_main, link) {
- if (h->func != func || h->user_data != user_data)
+ LIST_FOR_EACH_ENTRY_SAFE(destroy_handler, hh, &private_output->destroy_handler_list, link) {
+ if (destroy_handler->func != func || destroy_handler->user_data != user_data)
continue;
- LIST_DEL(&h->link);
- free(h);
-
- _pthread_mutex_unlock(&private_display->lock);
-
- return;
- }
-
- LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list_sub, link) {
- if (h->func != func || h->user_data != user_data)
- continue;
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_DESTROY, NULL, tdm_output_thread_cb_destroy, destroy_handler);
- LIST_DEL(&h->link);
- free(h);
+ LIST_DEL(&destroy_handler->link);
+ free(destroy_handler);
_pthread_mutex_unlock(&private_display->lock);
_pthread_mutex_unlock(&private_display->lock);
}
+/* LCOV_EXCL_STOP */
-EXTERN tdm_error
-tdm_output_get_output_type(tdm_output *output, tdm_output_type *type)
+EXTERN tdm_module *
+tdm_output_get_backend_module(tdm_output *output, tdm_error *error)
{
- OUTPUT_FUNC_ENTRY();
+ tdm_private_module *private_module;
- TDM_RETURN_VAL_IF_FAIL(type != NULL, TDM_ERROR_INVALID_PARAMETER);
+ OUTPUT_FUNC_ENTRY_ERROR();
_pthread_mutex_lock(&private_display->lock);
- *type = private_output->caps.type;
+ private_module = private_output->private_module;
+
+ if (error)
+ *error = TDM_ERROR_NONE;
_pthread_mutex_unlock(&private_display->lock);
- return ret;
+ return private_module;
}
EXTERN tdm_error
-tdm_output_get_layer_count(tdm_output *output, int *count)
+tdm_output_get_model_info(tdm_output *output, const char **maker,
+ const char **model, const char **name)
{
- tdm_private_layer *private_layer = NULL;
-
OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
-
_pthread_mutex_lock(&private_display->lock);
- *count = 0;
- LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
- (*count)++;
- if (*count == 0) {
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
- }
+ if (maker)
+ *maker = private_output->caps.maker;
+ if (model)
+ *model = private_output->caps.model;
+ if (name)
+ *name = private_output->caps.name;
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-
-EXTERN tdm_layer *
-tdm_output_get_layer(tdm_output *output, int index, tdm_error *error)
+EXTERN tdm_error
+tdm_output_get_capabilities(tdm_output *output, tdm_output_capability *capabilities)
{
- tdm_private_layer *private_layer = NULL;
+ OUTPUT_FUNC_ENTRY();
- OUTPUT_FUNC_ENTRY_ERROR();
+ TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
- if (error)
- *error = TDM_ERROR_NONE;
-
- LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
- if (private_layer->index == index) {
- _pthread_mutex_unlock(&private_display->lock);
- return private_layer;
- }
- }
+ *capabilities = private_output->caps.capabilities;
_pthread_mutex_unlock(&private_display->lock);
- return NULL;
+ return ret;
}
EXTERN tdm_error
-tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
- int *count)
+tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status)
{
OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
- *props = (const tdm_prop *)private_output->caps.props;
- *count = private_output->caps.prop_count;
+ *status = private_output->caps.status;
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-EXTERN tdm_error
-tdm_output_get_available_modes(tdm_output *output,
- const tdm_output_mode **modes, int *count)
+INTERN void
+tdm_output_thread_cb_change(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
{
- OUTPUT_FUNC_ENTRY();
+ tdm_private_output *private_output = object;
+ tdm_private_output_change_handler *change_handler = user_data;
+ tdm_output_change_type type = TDM_OUTPUT_CHANGE_CONNECTION;
+ tdm_value value = {.u32 = 0 };
- TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
- _pthread_mutex_lock(&private_display->lock);
+ assert(change_handler->owner_tid == syscall(SYS_gettid));
- *modes = (const tdm_output_mode *)private_output->caps.modes;
- *count = private_output->caps.mode_count;
+ if (cb_base->type == TDM_THREAD_CB_OUTPUT_STATUS) {
+ tdm_thread_cb_output_status *output_status = (tdm_thread_cb_output_status *)cb_base;
+ type = TDM_OUTPUT_CHANGE_CONNECTION;
+ value.u32 = output_status->status;
+ } else if (cb_base->type == TDM_THREAD_CB_OUTPUT_DPMS) {
+ tdm_thread_cb_output_dpms *output_dpms = (tdm_thread_cb_output_dpms *)cb_base;
+ type = TDM_OUTPUT_CHANGE_DPMS;
+ value.u32 = output_dpms->dpms;
+ } else {
+ TDM_NEVER_GET_HERE();
+ return;
+ }
_pthread_mutex_unlock(&private_display->lock);
+ change_handler->func(private_output, type, value, change_handler->user_data);
+ _pthread_mutex_lock(&private_display->lock);
- return ret;
}
-EXTERN tdm_error
-tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
- int *max_w, int *max_h, int *preferred_align)
+static tdm_error
+_tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output_conn_status status)
{
- OUTPUT_FUNC_ENTRY();
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_thread_cb_output_status output_status;
+ pid_t caller_tid = syscall(SYS_gettid);
+ tdm_error ret;
- if (min_w)
- *min_w = TDM_FRONT_VALUE(private_output->caps.min_w);
- if (min_h)
- *min_h = TDM_FRONT_VALUE(private_output->caps.min_h);
- if (max_w)
- *max_w = TDM_FRONT_VALUE(private_output->caps.max_w);
- if (max_h)
- *max_h = TDM_FRONT_VALUE(private_output->caps.max_h);
- if (preferred_align)
- *preferred_align = TDM_FRONT_VALUE(private_output->caps.preferred_align);
+ memset(&output_status, 0, sizeof output_status);
+ output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS;
+ output_status.base.length = sizeof output_status;
+ output_status.base.object_stamp = private_output->stamp;
+ output_status.base.data = NULL;
+ if (tdm_thread_in_display_thread(caller_tid))
+ output_status.base.sync = 0;
+ else
+ output_status.base.sync = 1;
+ output_status.status = status;
- _pthread_mutex_unlock(&private_display->lock);
+ ret = tdm_thread_cb_call(private_output, &output_status.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
- return ret;
+ return TDM_ERROR_NONE;
}
-EXTERN tdm_error
-tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
- int *max_w, int *max_h, int *preferred_align)
+static tdm_error
+_tdm_output_call_thread_cb_dpms(tdm_private_output *private_output, tdm_output_dpms dpms)
{
- OUTPUT_FUNC_ENTRY();
+ tdm_thread_cb_output_dpms output_dpms;
+ tdm_error ret;
- _pthread_mutex_lock(&private_display->lock);
+ memset(&output_dpms, 0, sizeof output_dpms);
+ output_dpms.base.type = TDM_THREAD_CB_OUTPUT_DPMS;
+ output_dpms.base.length = sizeof output_dpms;
+ output_dpms.base.object_stamp = private_output->stamp;
+ output_dpms.base.data = NULL;
+ output_dpms.base.sync = 0;
+ output_dpms.dpms = dpms;
- if (!tdm_display_check_module_abi(private_display, 1, 5)) {
+ ret = tdm_thread_cb_call(private_output, &output_dpms.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
- if (min_w)
- *min_w = -1;
- if (min_h)
- *min_h = -1;
- if (max_w)
- *max_w = -1;
- if (max_h)
- *max_h = -1;
- if (preferred_align)
- *preferred_align = -1;
+ return TDM_ERROR_NONE;
+}
- _pthread_mutex_unlock(&private_display->lock);
+/* LCOV_EXCL_START */
+INTERN void
+tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, void *user_data)
+{
+ tdm_private_output *private_output = user_data;
+ tdm_error ret;
- return TDM_ERROR_BAD_MODULE;
- }
+ TDM_RETURN_IF_FAIL(private_output);
- if (min_w)
- *min_w = TDM_FRONT_VALUE(private_output->caps.cursor_min_w);
- if (min_h)
- *min_h = TDM_FRONT_VALUE(private_output->caps.cursor_min_h);
- if (max_w)
- *max_w = TDM_FRONT_VALUE(private_output->caps.cursor_max_w);
- if (max_h)
- *max_h = TDM_FRONT_VALUE(private_output->caps.cursor_max_h);
- if (preferred_align)
- *preferred_align = TDM_FRONT_VALUE(private_output->caps.cursor_preferred_align);
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status));
- _pthread_mutex_unlock(&private_display->lock);
+ if ((private_output->caps.status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED && status != TDM_OUTPUT_CONN_STATUS_DISCONNECTED) ||
+ (private_output->caps.status != TDM_OUTPUT_CONN_STATUS_DISCONNECTED && status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)) {
+ ret = tdm_display_update_output(private_output->private_module, output_backend);
+ TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ } else {
+ private_output->caps.status = status;
+ }
- return ret;
+ ret = _tdm_output_call_thread_cb_status(private_output, status);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
}
-EXTERN tdm_error
-tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
- unsigned int *mmHeight)
+INTERN void
+tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
{
- OUTPUT_FUNC_ENTRY();
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_private_output *private_output = user_data;
+ tdm_error ret;
- if (mmWidth)
- *mmWidth = private_output->caps.mmWidth;
- if (mmHeight)
- *mmHeight = private_output->caps.mmHeight;
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_dpms_str(dpms));
- _pthread_mutex_unlock(&private_display->lock);
+ private_output->current_dpms_value = dpms;
+ private_output->waiting_dpms_change = 0;
+ TDM_INFO("output(%d) DPMS async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
- return ret;
+ ret = _tdm_output_call_thread_cb_dpms(private_output, dpms);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
}
-EXTERN tdm_error
-tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel)
+INTERN void
+tdm_output_cb_status_hal_tdm(hal_tdm_output *output_backend, hal_tdm_output_conn_status status, void *user_data)
{
- OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(subpixel != NULL, TDM_ERROR_INVALID_PARAMETER);
-
+ tdm_private_output *private_output = user_data;
+ tdm_error ret;
+
+ TDM_RETURN_IF_FAIL(private_output);
+
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str((tdm_output_conn_status)status));
+
+ if ((private_output->caps.status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED && status != HAL_TDM_OUTPUT_CONN_STATUS_DISCONNECTED) ||
+ (private_output->caps.status != TDM_OUTPUT_CONN_STATUS_DISCONNECTED && status == HAL_TDM_OUTPUT_CONN_STATUS_DISCONNECTED)) {
+ ret = tdm_display_update_output(private_output->private_module, output_backend);
+ TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ } else {
+ private_output->caps.status = (tdm_output_conn_status)status;
+ }
+
+ ret = _tdm_output_call_thread_cb_status(private_output, (tdm_output_conn_status)status);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+INTERN void
+tdm_output_cb_dpms_hal_tdm(hal_tdm_output *output_backend, hal_tdm_output_dpms dpms, void *user_data)
+{
+ tdm_private_output *private_output = user_data;
+ tdm_error ret;
+
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_dpms_str((tdm_output_dpms)dpms));
+
+ private_output->current_dpms_value = (tdm_output_dpms)dpms;
+ private_output->waiting_dpms_change = 0;
+ TDM_INFO("output(%d) DPMS async '%s' done", private_output->pipe, tdm_dpms_str((tdm_output_dpms)dpms));
+
+ ret = _tdm_output_call_thread_cb_dpms(private_output, (tdm_output_dpms)dpms);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+/* LCOV_EXCL_STOP */
+
+EXTERN tdm_error
+tdm_output_add_change_handler(tdm_output *output,
+ tdm_output_change_handler func,
+ void *user_data)
+{
+ tdm_private_output_change_handler *change_handler = NULL;
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ LIST_FOR_EACH_ENTRY(change_handler, &private_output->change_handler_list, link) {
+ if (change_handler->func == func && change_handler->user_data == user_data) {
+ TDM_ERR("can't add twice");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
+
+ change_handler = calloc(1, sizeof(tdm_private_output_change_handler));
+ if (!change_handler) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("failed: alloc memory");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+
+ ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
+ if (ret != TDM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("tdm_thread_cb_add failed");
+ free(change_handler);
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
+ }
+
+ ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_STATUS, NULL, tdm_output_thread_cb_change, change_handler);
+ if (ret != TDM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("tdm_thread_cb_add failed");
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
+ free(change_handler);
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
+ }
+
+ change_handler->private_output = private_output;
+ change_handler->func = func;
+ change_handler->user_data = user_data;
+ change_handler->owner_tid = syscall(SYS_gettid);
+
+ LIST_ADDTAIL(&change_handler->link, &private_output->change_handler_list);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+/* LCOV_EXCL_START */
+EXTERN tdm_error
+tdm_output_add_mode_change_request_handler(tdm_output *output,
+ tdm_output_mode_change_request_handler func,
+ void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_output_mode_change_handler *mode_change_handler = NULL;
+
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_output = (tdm_private_output*)output;
+ private_display = private_output->private_display;
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ LIST_FOR_EACH_ENTRY(mode_change_handler, &private_output->mode_change_request_handler_list, link) {
+ if (mode_change_handler->func == func && mode_change_handler->user_data == user_data) {
+ TDM_ERR("can't add twice");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
+
+ mode_change_handler = calloc(1, sizeof(tdm_private_output_mode_change_handler));
+ if (!mode_change_handler) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("failed: alloc memory");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+
+ mode_change_handler->private_output = private_output;
+ mode_change_handler->func = func;
+ mode_change_handler->user_data = user_data;
+
+ LIST_ADDTAIL(&mode_change_handler->link, &private_output->mode_change_request_handler_list);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return TDM_ERROR_NONE;
+}
+
+EXTERN tdm_error
+tdm_output_remove_mode_change_request_handler(tdm_output *output,
+ tdm_output_mode_change_request_handler func,
+ void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_output_mode_change_handler *mode_change_handler = NULL, *hh = NULL;
+
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_output = (tdm_private_output*)output;
+ private_display = private_output->private_display;
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ LIST_FOR_EACH_ENTRY_SAFE(mode_change_handler, hh, &private_output->mode_change_request_handler_list, link) {
+ if (mode_change_handler->func != func || mode_change_handler->user_data != user_data)
+ continue;
+
+ LIST_DEL(&mode_change_handler->link);
+ free(mode_change_handler);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return TDM_ERROR_NONE;
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return TDM_ERROR_INVALID_PARAMETER;
+}
+/* LCOV_EXCL_STOP */
+
+EXTERN void
+tdm_output_remove_change_handler(tdm_output *output,
+ tdm_output_change_handler func,
+ void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_output_change_handler *change_handler = NULL, *hh = NULL;
+
+ TDM_RETURN_IF_FAIL(output != NULL);
+ TDM_RETURN_IF_FAIL(func != NULL);
+
+ private_output = (tdm_private_output*)output;
+ private_display = private_output->private_display;
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ LIST_FOR_EACH_ENTRY_SAFE(change_handler, hh, &private_output->change_handler_list, link) {
+ if (change_handler->func != func || change_handler->user_data != user_data)
+ continue;
+
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_STATUS, NULL, tdm_output_thread_cb_change, change_handler);
+
+ LIST_DEL(&change_handler->link);
+ free(change_handler);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return;
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+}
+
+EXTERN tdm_error
+tdm_output_get_output_type(tdm_output *output, tdm_output_type *type)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(type != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *type = private_output->caps.type;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_layer_count(tdm_output *output, int *count)
+{
+ tdm_private_layer *private_layer = NULL;
+
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
+ TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
+ *count = 0;
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ *count = 0;
+ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
+ (*count)++;
+ if (*count == 0) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NONE;
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+
+EXTERN tdm_layer *
+tdm_output_get_layer(tdm_output *output, int index, tdm_error *error)
+{
+ tdm_private_layer *private_layer = NULL;
+
+ OUTPUT_FUNC_ENTRY_ERROR();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (error)
+ *error = TDM_ERROR_NONE;
+
+ if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
+ if (error)
+ *error = TDM_ERROR_BAD_REQUEST;
+ return NULL;
+ }
+
+ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
+ if (private_layer->index == index) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return private_layer;
+ }
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return NULL;
+}
+
+EXTERN tdm_error
+tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
+ int *count)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *props = (const tdm_prop *)private_output->caps.props;
+ *count = private_output->caps.prop_count;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_available_modes(tdm_output *output,
+ const tdm_output_mode **modes, int *count)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *modes = (const tdm_output_mode *)private_output->caps.modes;
+ *count = private_output->caps.mode_count;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
+ int *max_w, int *max_h, int *preferred_align)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (min_w)
+ *min_w = TDM_FRONT_VALUE(private_output->caps.min_w);
+ if (min_h)
+ *min_h = TDM_FRONT_VALUE(private_output->caps.min_h);
+ if (max_w)
+ *max_w = TDM_FRONT_VALUE(private_output->caps.max_w);
+ if (max_h)
+ *max_h = TDM_FRONT_VALUE(private_output->caps.max_h);
+ if (preferred_align)
+ *preferred_align = TDM_FRONT_VALUE(private_output->caps.preferred_align);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
+ int *max_w, int *max_h, int *preferred_align)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (!tdm_module_check_abi(private_output->private_module, 1, 5)) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ if (min_w)
+ *min_w = TDM_FRONT_VALUE(private_output->caps.cursor_min_w);
+ if (min_h)
+ *min_h = TDM_FRONT_VALUE(private_output->caps.cursor_min_h);
+ if (max_w)
+ *max_w = TDM_FRONT_VALUE(private_output->caps.cursor_max_w);
+ if (max_h)
+ *max_h = TDM_FRONT_VALUE(private_output->caps.cursor_max_h);
+ if (preferred_align)
+ *preferred_align = TDM_FRONT_VALUE(private_output->caps.cursor_preferred_align);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
+ unsigned int *mmHeight)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (mmWidth)
+ *mmWidth = private_output->caps.mmWidth;
+ if (mmHeight)
+ *mmHeight = private_output->caps.mmHeight;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel)
+{
+ OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(subpixel != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *subpixel = private_output->caps.subpixel;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_pipe(tdm_output *output, unsigned int *pipe)
+{
+ OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(pipe != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *pipe = private_output->pipe;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_primary_index(tdm_output *output, int *index)
+{
+ tdm_private_layer *private_layer = NULL;
+
+ OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(index != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
+ if (private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_PRIMARY) {
+ *index = private_layer->index;
+ break;
+ }
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
+{
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ private_module = private_output->private_module;
+
+ if (private_module->use_hal_tdm) {
+ hal_tdm_value hvalue;
+ memcpy(&hvalue.ptr, &value.ptr, sizeof(hal_tdm_value));
+ ret = (tdm_error)hal_tdm_output_set_property(private_output->output_backend, id, hvalue);
+ } else {
+ func_output = &private_module->func_output;
+
+ if (!func_output->output_set_property) {
+ /* LCOV_EXCL_START */
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_WRN("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
+ }
+
+ ret = func_output->output_set_property(private_output->output_backend, id, value);
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN tdm_error
+tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
+{
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ private_module = private_output->private_module;
+
+ if (private_module->use_hal_tdm) {
+ hal_tdm_value hvalue;
+ ret = (tdm_error)hal_tdm_output_get_property(private_output->output_backend, id, &hvalue);
+ if (ret == TDM_ERROR_NONE)
+ memcpy(&value->ptr, &hvalue.ptr, sizeof(tdm_value));
+ } else {
+ func_output = &private_module->func_output;
+
+ if (!func_output->output_get_property) {
+ /* LCOV_EXCL_START */
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_WRN("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
+ }
+
+ ret = func_output->output_get_property(private_output->output_backend, id, value);
+ }
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+static void
+_tdm_output_thread_cb_vblank(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
+{
+ tdm_thread_cb_output_vblank *output_vblank = (tdm_thread_cb_output_vblank *)cb_base;
+ tdm_private_output_vblank_handler *vblank_handler = output_vblank->base.data;
+ tdm_private_output_vblank_handler *v = NULL, *vv = NULL;
+ tdm_private_output *private_output = object;
+ struct list_head clone_list;
+ int interval, sync;
+ pid_t tid = syscall(SYS_gettid);
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ assert(vblank_handler->owner_tid == tid);
+
+ vblank_handler->sent_to_frontend = 0;
+
+ _tdm_output_vblank_timeout_update(private_output, 0);
+
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
+
+ interval = vblank_handler->interval;
+ sync = vblank_handler->sync;
+
+ LIST_INITHEAD(&clone_list);
+
+ LIST_FOR_EACH_ENTRY_SAFE(v, vv, &private_output->vblank_handler_list, link) {
+ if (v->interval != interval || v->sync != sync || v->owner_tid != tid)
+ continue;
+
+ LIST_DEL(&v->link);
+ LIST_ADDTAIL(&v->link, &clone_list);
+ }
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("----------------------------------------- output(%d) got vblank", private_output->pipe);
+
+ _pthread_mutex_unlock(&private_display->lock);
+ LIST_FOR_EACH_ENTRY_SAFE(v, vv, &clone_list, link) {
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("handler(%p)", v);
+
+ LIST_DEL(&v->link);
+
+ if (v->func)
+ v->func(v->private_output,
+ output_vblank->sequence,
+ output_vblank->tv_sec,
+ output_vblank->tv_usec,
+ v->user_data);
+
+ free(v);
+ }
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("-----------------------------------------...");
+}
+
+static void
+_tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ tdm_private_output_vblank_handler *vblank_handler = user_data;
+ tdm_thread_cb_output_vblank output_vblank;
+ tdm_error ret;
+
+ memset(&output_vblank, 0, sizeof output_vblank);
+ output_vblank.base.type = TDM_THREAD_CB_OUTPUT_VBLANK;
+ output_vblank.base.length = sizeof output_vblank;
+ output_vblank.base.object_stamp = vblank_handler->private_output->stamp;
+ output_vblank.base.data = vblank_handler;
+ output_vblank.base.sync = 0;
+ output_vblank.sequence = sequence;
+ output_vblank.tv_sec = tv_sec;
+ output_vblank.tv_usec = tv_usec;
+
+ vblank_handler->sent_to_frontend = 1;
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) wait_vblank: handler(%p)", vblank_handler->private_output->pipe, vblank_handler);
+
+ ret = tdm_thread_cb_call(vblank_handler->private_output, &output_vblank.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
+_tdm_output_cb_vblank_hal_tdm(hal_tdm_output *output_backend, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ tdm_private_output_vblank_handler *vblank_handler = user_data;
+ tdm_thread_cb_output_vblank output_vblank;
+ tdm_error ret;
+
+ memset(&output_vblank, 0, sizeof output_vblank);
+ output_vblank.base.type = TDM_THREAD_CB_OUTPUT_VBLANK;
+ output_vblank.base.length = sizeof output_vblank;
+ output_vblank.base.object_stamp = vblank_handler->private_output->stamp;
+ output_vblank.base.data = vblank_handler;
+ output_vblank.base.sync = 0;
+ output_vblank.sequence = sequence;
+ output_vblank.tv_sec = tv_sec;
+ output_vblank.tv_usec = tv_usec;
+
+ vblank_handler->sent_to_frontend = 1;
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) wait_vblank: handler(%p)", vblank_handler->private_output->pipe, vblank_handler);
+
+ ret = tdm_thread_cb_call(vblank_handler->private_output, &output_vblank.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+/* LCOV_EXCL_START */
+static void
+_tdm_output_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
+{
+ tdm_thread_cb_output_commit *output_commit = (tdm_thread_cb_output_commit *)cb_base;
+ tdm_private_output_commit_handler *output_commit_handler = output_commit->base.data;
+ tdm_private_output *private_output = object;
+ tdm_private_layer *private_layer = NULL;
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ if (!output_commit_handler)
+ return;
+
+ assert(output_commit_handler->owner_tid == syscall(SYS_gettid));
+
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
+
+ LIST_DEL(&output_commit_handler->link);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT) {
+ TDM_INFO("----------------------------------------- output(%d) committed", private_output->pipe);
+ TDM_INFO("handler(%p)", output_commit_handler);
+ }
+
+ if (private_output->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
+ /* In case of layer commit, the below will be handled in the layer commit callback */
+ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
+ if (private_layer->committed_buffer)
+ tdm_layer_committed(private_layer, &private_layer->committed_buffer);
+ }
+ }
+
+ if (output_commit_handler->func) {
+ _pthread_mutex_unlock(&private_display->lock);
+ output_commit_handler->func(private_output,
+ output_commit->sequence,
+ output_commit->tv_sec,
+ output_commit->tv_usec,
+ output_commit_handler->user_data);
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
+ free(output_commit_handler);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("-----------------------------------------...");
+}
+
+static void
+_tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ tdm_private_output_commit_handler *output_commit_handler = user_data;
+ tdm_private_output *private_output;
+ tdm_thread_cb_output_commit output_commit;
+ tdm_error ret;
+
+ if (output_commit_handler)
+ private_output = output_commit_handler->private_output;
+ else
+ private_output = tdm_display_find_private_output(tdm_display_get(), output_backend);
+
+ memset(&output_commit, 0, sizeof output_commit);
+ output_commit.base.type = TDM_THREAD_CB_OUTPUT_COMMIT;
+ output_commit.base.length = sizeof output_commit;
+ output_commit.base.object_stamp = private_output->stamp;
+ output_commit.base.data = output_commit_handler;
+ output_commit.base.sync = 0;
+ output_commit.sequence = sequence;
+ output_commit.tv_sec = tv_sec;
+ output_commit.tv_usec = tv_usec;
+
+ ret = tdm_thread_cb_call(private_output, &output_commit.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
+_tdm_output_cb_commit_hal_tdm(hal_tdm_output *output_backend, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ tdm_private_output_commit_handler *output_commit_handler = user_data;
+ tdm_private_output *private_output;
+ tdm_thread_cb_output_commit output_commit;
+ tdm_error ret;
+
+ if (output_commit_handler)
+ private_output = output_commit_handler->private_output;
+ else
+ private_output = tdm_display_find_private_output(tdm_display_get(), (tdm_output *)output_backend);
+
+ memset(&output_commit, 0, sizeof output_commit);
+ output_commit.base.type = TDM_THREAD_CB_OUTPUT_COMMIT;
+ output_commit.base.length = sizeof output_commit;
+ output_commit.base.object_stamp = private_output->stamp;
+ output_commit.base.data = output_commit_handler;
+ output_commit.base.sync = 0;
+ output_commit.sequence = sequence;
+ output_commit.tv_sec = tv_sec;
+ output_commit.tv_usec = tv_usec;
+
+ ret = tdm_thread_cb_call(private_output, &output_commit.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+static void
+_tdm_voutput_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
+{
+ tdm_thread_cb_voutput_commit *voutput_commit = (tdm_thread_cb_voutput_commit *)cb_base;
+ tdm_private_voutput_commit_handler *voutput_commit_handler = voutput_commit->base.data;
+ tdm_private_voutput *private_voutput = object;
+ tdm_private_output *private_output = NULL;
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ if (!voutput_commit_handler)
+ return;
+
+ assert(voutput_commit_handler->owner_tid == syscall(SYS_gettid));
+
+ tdm_thread_cb_remove(private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL);
+
+ LIST_DEL(&voutput_commit_handler->link);
+
+ private_output = private_voutput->private_output;
+ if (tdm_debug_module & TDM_DEBUG_COMMIT) {
+ TDM_INFO("----------------------------------------- voutput(%d) committed", private_output->pipe);
+ TDM_INFO("handler(%p)", voutput_commit_handler);
+ }
+
+ if (voutput_commit_handler->func && private_voutput->set_voutput_commit != 0) {
+ _pthread_mutex_unlock(&private_display->lock);
+ voutput_commit_handler->func(private_voutput, voutput_commit_handler->user_data);
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
+ free(voutput_commit_handler);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("-----------------------------------------...");
+}
+
+static void
+_tdm_voutput_cb_commit(tdm_voutput *voutput_backend, unsigned int sequence,
+ unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ tdm_private_voutput_commit_handler *voutput_commit_handler = NULL;
+ tdm_private_module *private_module;
+ tdm_private_voutput *private_voutput = NULL, *v = NULL;
+ tdm_private_output *private_output;
+ tdm_thread_cb_voutput_commit voutput_commit;
+ tdm_error ret;
+
+ private_module = tdm_display_get()->virtual_module;
+
+ LIST_FOR_EACH_ENTRY(v, &private_module->voutput_list, link) {
+ if (v->voutput_backend == voutput_backend) {
+ private_voutput = v;
+ break;
+ }
+ }
+ if (!private_voutput) {
+ TDM_ERR("cannot find voutput");
+ return;
+ }
+
+ if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) == 0) return;
+
+ voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link);
+
+ private_output = private_voutput->private_output;
+
+ memset(&voutput_commit, 0, sizeof voutput_commit);
+ voutput_commit.base.type = TDM_THREAD_CB_VOUTPUT_COMMIT;
+ voutput_commit.base.length = sizeof voutput_commit;
+ voutput_commit.base.object_stamp = private_output->stamp;
+ voutput_commit.base.data = voutput_commit_handler;
+ voutput_commit.base.sync = 0;
+ voutput_commit.sequence = sequence;
+ voutput_commit.tv_sec = tv_sec;
+ voutput_commit.tv_usec = tv_usec;
+
+ ret = tdm_thread_cb_call(private_voutput, &voutput_commit.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+/* LCOV_EXCL_STOP */
+
+/* add_front: To distinguish between the user vblank handlers and the layer
+ * commit vblank handlers. The layer commit handlers will be called
+ * before calling the user vblank handlers.
+ */
+static tdm_error
+_tdm_output_wait_vblank(tdm_private_output *private_output, int interval, int sync,
+ tdm_output_vblank_handler func, void *user_data,
+ unsigned int add_front)
+{
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ tdm_private_output_vblank_handler *vblank_handler = NULL, *v = NULL;
+ unsigned int skip_request = 0;
+ pid_t tid = syscall(SYS_gettid);
+ tdm_error ret = TDM_ERROR_NONE;
+
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
+
+ /* interval SHOULD be at least 1 */
+ if (interval <= 0)
+ interval = 1;
+
+ if (private_module->use_hal_tdm) {
+ if (!private_output->regist_vblank_cb) {
+ private_output->regist_vblank_cb = 1;
+ ret = (tdm_error)hal_tdm_output_set_vblank_handler(private_output->output_backend, _tdm_output_cb_vblank_hal_tdm);
+ }
+ } else {
+ if (!func_output->output_wait_vblank) {
+ /* LCOV_EXCL_START */
+ TDM_WRN("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
+ }
+
+ if (!private_output->regist_vblank_cb) {
+ private_output->regist_vblank_cb = 1;
+ ret = func_output->output_set_vblank_handler(private_output->output_backend,
+ _tdm_output_cb_vblank);
+ }
+ }
+ vblank_handler = calloc(1, sizeof(tdm_private_output_vblank_handler));
+ if (!vblank_handler) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("failed: alloc memory");
+ return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) wait_vblank: handler(%p)", private_output->pipe, vblank_handler);
+
+ LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
+ if (v->interval == interval && v->sync == sync && v->owner_tid == tid) {
+ skip_request = 1;
+ break;
+ }
+ }
+
+ if (add_front)
+ LIST_ADD(&vblank_handler->link, &private_output->vblank_handler_list);
+ else
+ LIST_ADDTAIL(&vblank_handler->link, &private_output->vblank_handler_list);
+
+ vblank_handler->private_output = private_output;
+ vblank_handler->interval = interval;
+ vblank_handler->sync = sync;
+ vblank_handler->func = func;
+ vblank_handler->user_data = user_data;
+ vblank_handler->owner_tid = tid;
+
+ /* If there is the previous request, we can skip to call output_wait_vblank() */
+ if (!skip_request) {
+ ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("tdm_thread_cb_add failed");
+ goto wait_failed;
+ }
+ if (private_module->use_hal_tdm)
+ ret = (tdm_error)hal_tdm_output_wait_vblank(private_output->output_backend, interval,
+ sync, vblank_handler);
+ else
+ ret = func_output->output_wait_vblank(private_output->output_backend, interval,
+ sync, vblank_handler);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
+
+ _tdm_output_vblank_timeout_update(private_output, 1000);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) backend wait_vblank", private_output->pipe);
+ }
+
+ return ret;
+
+wait_failed:
+ /* LCOV_EXCL_START */
+ if (vblank_handler) {
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_VBLANK, vblank_handler, _tdm_output_thread_cb_vblank, NULL);
+ LIST_DEL(&vblank_handler->link);
+ free(vblank_handler);
+ }
+ return ret;
+ /* LCOV_EXCL_STOP */
+}
+
+EXTERN tdm_error
+tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
+ tdm_output_vblank_handler func, void *user_data)
+{
+ OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
+ TDM_WRN("output(%d) dpms: %s", private_output->pipe,
+ tdm_dpms_str(private_output->current_dpms_value));
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_DPMS_OFF;
+ }
+
+ if (private_output->waiting_dpms_change) {
+ TDM_WRN("output(%d) dpms is changing: %s", private_output->pipe,
+ tdm_dpms_str(private_output->current_dpms_value));
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_DPMS_OFF;
+ }
+
+ ret = _tdm_output_wait_vblank(private_output, interval, sync, func, user_data, 0);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+/* LCOV_EXCL_START */
+EXTERN tdm_error
+tdm_output_wait_vblank_add_front(tdm_output *output, int interval, int sync,
+ tdm_output_vblank_handler func, void *user_data)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
+ TDM_WRN("output(%d) dpms: %s", private_output->pipe,
+ tdm_dpms_str(private_output->current_dpms_value));
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_DPMS_OFF;
+ }
+
+ if (private_output->waiting_dpms_change) {
+ TDM_WRN("output(%d) dpms is changing: %s", private_output->pipe,
+ tdm_dpms_str(private_output->current_dpms_value));
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_DPMS_OFF;
+ }
+
+ ret = _tdm_output_wait_vblank(private_output, interval, sync, func, user_data, 1);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+/* LCOV_EXCL_STOP */
+
+INTERN void
+tdm_output_remove_vblank_handler_internal(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
+{
+ tdm_private_output *private_output = (tdm_private_output*)output;
+ tdm_private_output_vblank_handler *v = NULL;
+
+ TDM_RETURN_IF_FAIL(private_output != NULL);
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
+ if (v->func == func && v->user_data == user_data) {
+ /* only set func & user_data to NULL. It will be freed when an event occurs */
+ v->func = NULL;
+ v->user_data = NULL;
+ break;
+ }
+ }
+}
+
+/* LCOV_EXCL_START */
+INTERN void
+tdm_output_remove_commit_handler_internal(tdm_output *output, tdm_output_commit_handler func, void *user_data)
+{
+ tdm_private_output *private_output = (tdm_private_output*)output;
+ tdm_private_output_commit_handler *c = NULL;
+
+ TDM_RETURN_IF_FAIL(private_output != NULL);
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ LIST_FOR_EACH_ENTRY(c, &private_output->output_commit_handler_list, link) {
+ if (c->func == func && c->user_data == user_data) {
+ /* only set func & user_data to NULL. It will be freed when an event occurs */
+ c->func = NULL;
+ c->user_data = NULL;
+ break;
+ }
+ }
+}
+/* LCOV_EXCL_STOP */
+
+EXTERN tdm_error
+tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ tdm_output_remove_vblank_handler_internal(output, func, user_data);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+/* LCOV_EXCL_START */
+EXTERN tdm_error
+tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data)
+{
+ OUTPUT_FUNC_ENTRY();
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ tdm_output_remove_commit_handler_internal(output, func, user_data);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+INTERN void
+tdm_output_request_mode_set(tdm_output *output, unsigned int index)
+{
+ tdm_private_output *private_output = (tdm_private_output*)output;
+ tdm_private_output_mode_change_handler *mode_change_handler = NULL;
+
+ TDM_RETURN_IF_FAIL(private_output != NULL);
+
+ if (LIST_IS_EMPTY(&private_output->mode_change_request_handler_list))
+ return;
+
+ LIST_FOR_EACH_ENTRY(mode_change_handler, &private_output->mode_change_request_handler_list, link) {
+ mode_change_handler->func(mode_change_handler->private_output, index, mode_change_handler->user_data);
+ }
+}
+
+static void
+_voutput_commit_func(tdm_voutput *voutput, tbm_surface_h buffer)
+{
+ tdm_private_voutput *private_voutput = (tdm_private_voutput *)voutput;
+ tdm_error ret;
+
+ TDM_RETURN_IF_FAIL(voutput != NULL);
+ TDM_RETURN_IF_FAIL(buffer != NULL);
+
+ ret = tdm_voutput_attach_buffer(private_voutput, buffer);
+ TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ ret = tdm_voutput_commit_buffer(private_voutput);
+ TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ return;
+}
+
+INTERN tdm_error
+tdm_output_set_voutput_commit(tdm_voutput *voutput)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_voutput *private_voutput;
+ tdm_private_voutput_commit_handler *voutput_commit_handler = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
+
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_voutput = (tdm_private_voutput *)voutput;
+ private_display = private_voutput->private_display;
+ private_output = (tdm_private_output *)private_voutput->private_output;
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return ret;
+ }
+
+ if (!private_voutput->regist_commit_cb) {
+ private_voutput->regist_commit_cb = 1;
+ ret = tdm_voutput_set_commit_func(private_voutput, _tdm_voutput_cb_commit);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("failed: tdm_voutput_set_commit_func");
+ _pthread_mutex_unlock(&private_display->lock);
+ return ret;
+ }
+ }
+
+ voutput_commit_handler = calloc(1, sizeof(tdm_private_voutput_commit_handler));
+ if (!voutput_commit_handler) {
+ TDM_ERR("failed: alloc memory");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = tdm_thread_cb_add(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("tdm_thread_cb_add failed");
+ free(voutput_commit_handler);
+ _pthread_mutex_unlock(&private_display->lock);
+ return ret;
+ }
+
+ LIST_ADDTAIL(&voutput_commit_handler->link, &private_voutput->voutput_commit_handler_list);
+ voutput_commit_handler->private_voutput = private_voutput;
+ voutput_commit_handler->func = _voutput_commit_func;
+ voutput_commit_handler->owner_tid = syscall(SYS_gettid);
+
+ private_voutput->set_voutput_commit = 1;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+INTERN tdm_error
+tdm_output_unset_voutput_commit(tdm_voutput *voutput)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_voutput *private_voutput;
+ tdm_private_voutput_commit_handler *voutput_commit_handler = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
+
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_voutput = (tdm_private_voutput *)voutput;
+ private_display = private_voutput->private_display;
+ private_output = (tdm_private_output *)private_voutput->private_output;
+
_pthread_mutex_lock(&private_display->lock);
- *subpixel = private_output->caps.subpixel;
+ private_voutput->set_voutput_commit = 0;
+
+ if (private_voutput->regist_commit_cb) {
+ private_voutput->regist_commit_cb = 0;
+ ret = tdm_voutput_set_commit_func(private_voutput, NULL);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("failed: tdm_voutput_set_commit_func");
+ _pthread_mutex_unlock(&private_display->lock);
+ return ret;
+ }
+ }
+
+ if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) == 0) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NONE;
+ }
+
+ if (LIST_LENGTH(&private_output->output_commit_handler_list) != 0) {
+ //commiting. don't remove voutput commit thread here
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NONE;
+ }
+
+ if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) {
+ voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link);
+ } else {
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NONE;
+ }
+
+ tdm_thread_cb_remove(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return TDM_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+INTERN tdm_error
+tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_voutput *private_voutput;
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ tdm_private_output_commit_handler *output_commit_handler = NULL;
+ tdm_private_voutput_commit_handler *voutput_commit_handler = NULL;
+ tdm_private_layer *private_layer = NULL;
+ tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_ON;
+ tdm_error ret = TDM_ERROR_NONE;
+
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_output = (tdm_private_output*)output;
+ private_module = private_output->private_module;
+ private_display = private_module->private_display;
+ func_output = &private_module->func_output;
+
+ if (!private_module->use_hal_tdm) {
+ if (!func_output->output_commit) {
+ TDM_WRN("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
+ }
+
+ ret = tdm_output_get_dpms_internal(output, &dpms_value);
+ TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
+
+ if (!TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms_value)) {
+ if (!private_output->regist_commit_cb) {
+ private_output->regist_commit_cb = 1;
+ if (private_module->use_hal_tdm)
+ ret = (tdm_error)hal_tdm_output_set_commit_handler(private_output->output_backend, _tdm_output_cb_commit_hal_tdm);
+ else
+ ret = func_output->output_set_commit_handler(private_output->output_backend, _tdm_output_cb_commit);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
+ }
+
+ output_commit_handler = calloc(1, sizeof(tdm_private_output_commit_handler));
+ if (!output_commit_handler) {
+ TDM_ERR("failed: alloc memory");
+ return TDM_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (private_module == private_display->virtual_module) {
+ if (!private_output->private_voutput) {
+ TDM_ERR("virtual module but don't have voutput");
+ free(output_commit_handler);
+ return TDM_ERROR_BAD_MODULE;
+ }
+ }
+
+ ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("tdm_thread_cb_add failed");
+ free(output_commit_handler);
+ return ret;
+ }
+
+ LIST_ADDTAIL(&output_commit_handler->link, &private_output->output_commit_handler_list);
+ output_commit_handler->private_output = private_output;
+ output_commit_handler->func = func;
+ output_commit_handler->user_data = user_data;
+ output_commit_handler->owner_tid = syscall(SYS_gettid);
+
+ if (private_module == private_display->virtual_module) {
+ private_voutput = private_output->private_voutput;
+
+ /* voutput use only 1 layer */
+ private_layer = LIST_FIRST_ENTRY(&private_output->layer_list, tdm_private_layer, link);
+
+ if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) {
+ voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link);
+ voutput_commit_handler->user_data = private_layer->commiting_buffer;
+ }
+ }
+ if (private_module->use_hal_tdm)
+ ret = (tdm_error)hal_tdm_output_commit(private_output->output_backend, sync, output_commit_handler);
+ else
+ ret = func_output->output_commit(private_output->output_backend, sync, output_commit_handler);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) backend commit: handle(%p) func(%p) user_data(%p)",
+ private_output->pipe, output_commit_handler, func, user_data);
+ }
- _pthread_mutex_unlock(&private_display->lock);
+ /* Even if DPMS is off, committed_buffer should be changed because it will be referred
+ * for tdm_layer_committed() function.
+ */
+ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
+ if (!private_layer->waiting_buffer)
+ continue;
- return ret;
-}
+ if (private_layer->committed_buffer) {
+ tdm_layer_free_buffer(private_layer, private_layer->committed_buffer);
+ private_layer->committed_buffer = NULL;
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
+ TDM_INFO("layer(%p) waiting_buffer(%p) committed_buffer(%p)",
+ private_layer, private_layer->waiting_buffer->buffer,
+ private_layer->committed_buffer);
+ }
-EXTERN tdm_error
-tdm_output_get_pipe(tdm_output *output, unsigned int *pipe)
-{
- OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(pipe != NULL, TDM_ERROR_INVALID_PARAMETER);
+ private_layer->committed_buffer = private_layer->waiting_buffer;
+ private_layer->waiting_buffer = NULL;
+ private_layer->commiting_buffer = NULL;
+ if (tdm_debug_module & TDM_DEBUG_BUFFER)
+ TDM_INFO("layer(%p) waiting_buffer(%p) committed_buffer(%p)",
+ private_layer, private_layer->waiting_buffer,
+ private_layer->committed_buffer->buffer);
+ }
- _pthread_mutex_lock(&private_display->lock);
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms_value)) {
+ TDM_WRN("dpms %s. Directly call commit handler instead of commit.", tdm_dpms_str(dpms_value));
+ if (func) {
+ _pthread_mutex_unlock(&private_display->lock);
+ func(output, 0, 0, 0, user_data);
+ _pthread_mutex_lock(&private_display->lock);
+ }
+ }
- *pipe = private_output->pipe;
+ return ret;
- _pthread_mutex_unlock(&private_display->lock);
+commit_failed:
+ if (output_commit_handler) {
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
+ LIST_DEL(&output_commit_handler->link);
+ free(output_commit_handler);
+ }
return ret;
}
EXTERN tdm_error
-tdm_output_get_primary_index(tdm_output *output, int *index)
+tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
+ void *user_data)
{
tdm_private_layer *private_layer = NULL;
OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(index != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
+ if (private_output->commit_type == TDM_COMMIT_TYPE_NONE)
+ private_output->commit_type = TDM_COMMIT_TYPE_OUTPUT;
+ else if (private_output->commit_type == TDM_COMMIT_TYPE_LAYER) {
+ TDM_ERR("Can't supported. Use tdm_layer_commit");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ if (private_output->commit_per_vblank) {
+ TDM_ERR("Use tdm_layer_commit");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
+ TDM_ERR("output(%d) dpms: %s", private_output->pipe,
+ tdm_dpms_str(private_output->current_dpms_value));
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_DPMS_OFF;
+ }
+
+ if (tdm_debug_module & TDM_DEBUG_COMMIT)
+ TDM_INFO("output(%d) commit", private_output->pipe);
+
+ /* apply the pending data of all layers */
LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
- if (private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_PRIMARY) {
- *index = private_layer->index;
- break;
- }
+ tdm_layer_commit_pending_data(private_layer);
}
+ ret = tdm_output_commit_internal(output, sync, func, user_data);
+
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
-tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
+tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode)
{
+ tdm_private_module *private_module;
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
+
_pthread_mutex_lock(&private_display->lock);
- func_output = &private_display->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- if (!func_output->output_set_property) {
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- }
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_output_set_mode(private_output->output_backend, (const hal_tdm_output_mode *)mode);
+ } else {
+ if (!func_output->output_set_mode) {
+ /* LCOV_EXCL_START */
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_WRN("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
+ }
- ret = func_output->output_set_property(private_output->output_backend, id,
- value);
+ ret = func_output->output_set_mode(private_output->output_backend, mode);
+ }
+ if (ret == TDM_ERROR_NONE) {
+ private_output->current_mode = mode;
+ private_output->need_set_target_info = 1;
+ TDM_INFO("mode: %dx%d %dhz", mode->hdisplay, mode->vdisplay, mode->vrefresh);
+ }
_pthread_mutex_unlock(&private_display->lock);
}
EXTERN tdm_error
-tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
+tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
{
- tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
- func_output = &private_display->func_output;
-
- if (!func_output->output_get_property) {
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- }
-
- ret = func_output->output_get_property(private_output->output_backend, id,
- value);
+ *mode = private_output->current_mode;
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-INTERN void
-tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+EXTERN tdm_error
+tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
{
- tdm_private_vblank_handler *vblank_handler = user_data;
- tdm_private_vblank_handler *v = NULL, *vv = NULL;
- tdm_private_output *private_output;
- tdm_private_display *private_display;
- struct list_head clone_list;
- int interval, sync;
- pid_t tid = syscall(SYS_gettid);
-
- TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
- TDM_RETURN_IF_FAIL(vblank_handler);
-
- private_output = vblank_handler->private_output;
- private_display = private_output->private_display;
-
- if (vblank_handler->owner_tid != tid) {
- tdm_thread_cb_output_vblank output_vblank;
- tdm_error ret;
-
- output_vblank.base.type = TDM_THREAD_CB_OUTPUT_VBLANK;
- output_vblank.base.length = sizeof output_vblank;
- output_vblank.output_stamp = vblank_handler->private_output->stamp;
- output_vblank.sequence = sequence;
- output_vblank.tv_sec = tv_sec;
- output_vblank.tv_usec = tv_usec;
- output_vblank.user_data = user_data;
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ OUTPUT_FUNC_ENTRY();
- ret = tdm_thread_send_cb(private_display->private_loop, &output_vblank.base);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+ if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
+ if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
+ TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
+ return TDM_ERROR_BAD_REQUEST;
+ }
- return;
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
+ TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
+ private_output->pipe, tdm_dpms_str(dpms_value));
+ return TDM_ERROR_BAD_REQUEST;
+ }
}
- if (vblank_handler->owner_tid != tid)
- TDM_NEVER_GET_HERE();
+ _pthread_mutex_lock(&private_display->lock);
- interval = vblank_handler->interval;
- sync = vblank_handler->sync;
+ if (private_output->waiting_dpms_change) {
+ TDM_ERR("DPMS is not changed yet. Can't be changed twice");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
- LIST_INITHEAD(&clone_list);
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- LIST_FOR_EACH_ENTRY_SAFE(v, vv, &private_output->vblank_handler_list, link) {
- if (v->interval != interval || v->sync != sync || v->owner_tid != tid)
- continue;
+ TDM_INFO("output(%d) DPMS '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
- LIST_DEL(&v->link);
- LIST_ADDTAIL(&v->link, &clone_list);
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_output_set_dpms(private_output->output_backend, (hal_tdm_output_dpms)dpms_value);
+ } else {
+ if (func_output->output_set_dpms)
+ ret = func_output->output_set_dpms(private_output->output_backend, dpms_value);
+ else {
+ /* LCOV_EXCL_START */
+ ret = TDM_ERROR_NONE;
+ TDM_WRN("DPMS not implemented!!");
+ /* LCOV_EXCL_STOP */
+ }
}
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("----------------------------------------- output(%d) got vblank", private_output->pipe);
+ if (ret == TDM_ERROR_NONE) {
+ if (private_output->current_dpms_value != dpms_value) {
+ private_output->current_dpms_value = dpms_value;
+ _tdm_output_call_thread_cb_dpms(private_output, dpms_value);
+ }
+ TDM_INFO("output(%d) DPMS '%s' done", private_output->pipe, tdm_dpms_str(dpms_value));
+ } else {
+ tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
- _pthread_mutex_unlock(&private_display->lock);
- LIST_FOR_EACH_ENTRY_SAFE(v, vv, &clone_list, link) {
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("handler(%p)", v);
+ /* update current_dpms_value forcely */
+ tdm_output_get_dpms_internal(output, &temp);
- if (v->func)
- v->func(v->private_output, sequence, tv_sec, tv_usec, v->user_data);
- LIST_DEL(&v->link);
- free(v);
+ TDM_ERR("output(%d) set DPMS failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
}
- _pthread_mutex_lock(&private_display->lock);
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("-----------------------------------------...");
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
}
-INTERN void
-tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+/* LCOV_EXCL_START */
+EXTERN tdm_error
+tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value)
{
- tdm_private_output_commit_handler *output_commit_handler = user_data;
- tdm_private_display *private_display;
- tdm_private_output *private_output;
- tdm_private_layer *private_layer = NULL;
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ int sync = 0;
+ OUTPUT_FUNC_ENTRY();
- TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_ASYNC_DPMS)) {
+ TDM_ERR("output doesn't support the asynchronous DPMS control!");
+ return TDM_ERROR_BAD_REQUEST;
+ }
- if (!output_commit_handler)
- return;
+ if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
+ if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
+ TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
+ return TDM_ERROR_BAD_REQUEST;
+ }
- private_output = output_commit_handler->private_output;
- private_display = private_output->private_display;
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
+ TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
+ private_output->pipe, tdm_dpms_str(dpms_value));
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
- if (output_commit_handler->owner_tid != syscall(SYS_gettid)) {
- tdm_thread_cb_output_commit output_commit;
- tdm_error ret;
+ _pthread_mutex_lock(&private_display->lock);
- output_commit.base.type = TDM_THREAD_CB_OUTPUT_COMMIT;
- output_commit.base.length = sizeof output_commit;
- output_commit.output_stamp = private_output->stamp;
- output_commit.sequence = sequence;
- output_commit.tv_sec = tv_sec;
- output_commit.tv_usec = tv_usec;
- output_commit.user_data = user_data;
+ if (private_output->waiting_dpms_change) {
+ TDM_ERR("DPMS is not changed yet. Can't be changed twice");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
- ret = tdm_thread_send_cb(private_display->private_loop, &output_commit.base);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
+ if (!private_module->use_hal_tdm) {
+ if (!func_output->output_set_dpms_handler) {
+ TDM_WRN("not implemented DPMS: output_set_dpms_handler");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
- return;
+ if (!func_output->output_set_dpms_async) {
+ TDM_WRN("not implemented DPMS: output_set_dpms_async");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
}
- if (tdm_debug_module & TDM_DEBUG_COMMIT) {
- TDM_INFO("----------------------------------------- output(%d) committed", private_output->pipe);
- TDM_INFO("handler(%p)", output_commit_handler);
+ if (!private_output->regist_dpms_cb) {
+ private_output->regist_dpms_cb = 1;
+ if (private_module->use_hal_tdm)
+ ret = (tdm_error)hal_tdm_output_set_dpms_handler(private_output->output_backend,
+ tdm_output_cb_dpms_hal_tdm, private_output);
+ else
+ ret = func_output->output_set_dpms_handler(private_output->output_backend,
+ tdm_output_cb_dpms, private_output);
+ if (ret != TDM_ERROR_NONE) {
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("Can't set the DPMS handler!!");
+ return ret;
+ }
}
- if (private_display->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
- /* In case of layer commit, the below will be handled in the layer commit callback */
- LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
- if (private_layer->committed_buffer)
- tdm_layer_committed(private_layer, &private_layer->committed_buffer);
+ TDM_INFO("output(%d) DPMS async '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
+
+ if (private_module->use_hal_tdm)
+ ret = (tdm_error)hal_tdm_output_set_dpms_async(private_output->output_backend, (hal_tdm_output_dpms)dpms_value, &sync);
+ else
+ ret = func_output->output_set_dpms_async(private_output->output_backend, dpms_value, &sync);
+
+ if (ret == TDM_ERROR_NONE) {
+ if (sync) {
+ tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
+
+ tdm_output_get_dpms_internal(output, &temp);
+ TDM_INFO("output(%d) DPMS async '%s'(%s) done", private_output->pipe, tdm_dpms_str(dpms_value), tdm_dpms_str(temp));
+ } else {
+ private_output->waiting_dpms_change = 1;
+ TDM_INFO("output(%d) DPMS async '%s' waiting", private_output->pipe, tdm_dpms_str(dpms_value));
}
- }
+ } else {
+ tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
- if (output_commit_handler->func) {
- _pthread_mutex_unlock(&private_display->lock);
- output_commit_handler->func(private_output, sequence,
- tv_sec, tv_usec, output_commit_handler->user_data);
- _pthread_mutex_lock(&private_display->lock);
+ /* update current_dpms_value forcely */
+ tdm_output_get_dpms_internal(output, &temp);
+
+ TDM_ERR("output(%d) set DPMS async failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
}
- LIST_DEL(&output_commit_handler->link);
- free(output_commit_handler);
+ _pthread_mutex_unlock(&private_display->lock);
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("-----------------------------------------...");
+ return ret;
}
+/* LCOV_EXCL_STOP */
-/* add_front: To distinguish between the user vblank handlers and the layer
- * commit vblank handlers. The layer commit handlers will be called
- * before calling the user vblank handlers.
- */
-static tdm_error
-_tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
- tdm_output_vblank_handler func, void *user_data,
- unsigned int add_front)
+INTERN tdm_error
+tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value)
{
+ tdm_private_output *private_output;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
- tdm_private_vblank_handler *vblank_handler = NULL, *v = NULL;
- unsigned int skip_request = 0;
- pid_t tid = syscall(SYS_gettid);
-
- OUTPUT_FUNC_ENTRY();
+ tdm_error ret = TDM_ERROR_NONE;
- func_output = &private_display->func_output;
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
- /* interval SHOULD be at least 1 */
- if (interval <= 0)
- interval = 1;
-
- if (!func_output->output_wait_vblank) {
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- }
-
- if (!private_output->regist_vblank_cb) {
- private_output->regist_vblank_cb = 1;
- ret = func_output->output_set_vblank_handler(private_output->output_backend,
- tdm_output_cb_vblank);
- }
+ private_output = (tdm_private_output*)output;
- vblank_handler = calloc(1, sizeof(tdm_private_vblank_handler));
- if (!vblank_handler) {
- TDM_ERR("failed: alloc memory");
- return TDM_ERROR_OUT_OF_MEMORY;
+ /* TODO: this is ugly. But before calling backend's output_get_dpms(), we have
+ * to check if all backends's DPMS operation has no problem. In future, we'd
+ * better use new env instead of using commit_per_vblank variable to distinguish
+ * whether we use the stored value or backend's output_get_dpms.
+ */
+ if (!private_output->commit_per_vblank) {
+ *dpms_value = private_output->current_dpms_value;
+ return TDM_ERROR_NONE;
}
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("output(%d) wait_vblank: handler(%p)", private_output->pipe, vblank_handler);
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) {
- if (v->interval == interval && v->sync == sync && v->owner_tid == tid) {
- skip_request = 1;
- break;
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_output_get_dpms(private_output->output_backend, (hal_tdm_output_dpms *)dpms_value);
+ } else {
+ if (!func_output->output_get_dpms) {
+ /* LCOV_EXCL_START */
+ *dpms_value = private_output->current_dpms_value;
+ TDM_WRN("DPMS get not implemented!!");
+ return TDM_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
}
- }
- if (add_front)
- LIST_ADD(&vblank_handler->link, &private_output->vblank_handler_list);
- else
- LIST_ADDTAIL(&vblank_handler->link, &private_output->vblank_handler_list);
+ ret = func_output->output_get_dpms(private_output->output_backend, dpms_value);
+ }
+ if (ret != TDM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("output get DPMS failed");
+ *dpms_value = TDM_OUTPUT_DPMS_OFF;
+ /* LCOV_EXCL_STOP */
+ }
- vblank_handler->private_output = private_output;
- vblank_handler->interval = interval;
- vblank_handler->sync = sync;
- vblank_handler->func = func;
- vblank_handler->user_data = user_data;
- vblank_handler->owner_tid = tid;
+ /* checking with backend's value */
+ if (*dpms_value != private_output->current_dpms_value) {
+ TDM_ERR("output(%d) DPMS changed suddenly: %s -> %s",
+ private_output->pipe, tdm_dpms_str(private_output->current_dpms_value),
+ tdm_dpms_str(*dpms_value));
+ private_output->current_dpms_value = *dpms_value;
+ _tdm_output_call_thread_cb_dpms(private_output, *dpms_value);
+ }
- /* If there is the previous request, we can skip to call output_wait_vblank() */
- if (!skip_request) {
- ret = func_output->output_wait_vblank(private_output->output_backend, interval,
- sync, vblank_handler);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
+ return ret;
+}
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("output(%d) backend wait_vblank", private_output->pipe);
- }
+INTERN tdm_error
+tdm_output_get_dpms_changing(tdm_output *output, int *changing)
+{
+ tdm_private_output *private_output;
- return ret;
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(changing != NULL, TDM_ERROR_INVALID_PARAMETER);
-wait_failed:
- if (vblank_handler) {
- LIST_DEL(&vblank_handler->link);
- free(vblank_handler);
- }
- return ret;
+ private_output = (tdm_private_output*)output;
+
+ *changing = private_output->waiting_dpms_change;
+
+ return TDM_ERROR_NONE;
}
+
EXTERN tdm_error
-tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
- tdm_output_vblank_handler func, void *user_data)
+tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
{
OUTPUT_FUNC_ENTRY();
- _pthread_mutex_lock(&private_display->lock);
+ TDM_RETURN_VAL_IF_FAIL(dpms_value != NULL, TDM_ERROR_INVALID_PARAMETER);
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
- TDM_WRN("output(%d) dpms: %s", private_output->pipe,
- tdm_dpms_str(private_output->current_dpms_value));
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_DPMS_OFF;
- }
+ _pthread_mutex_lock(&private_display->lock);
- ret = _tdm_output_wait_vblank(output, interval, sync, func, user_data, 0);
+ ret = tdm_output_get_dpms_internal(output, dpms_value);
_pthread_mutex_unlock(&private_display->lock);
}
EXTERN tdm_error
-tdm_output_wait_vblank_add_front(tdm_output *output, int interval, int sync,
- tdm_output_vblank_handler func, void *user_data)
+tdm_output_has_capture_capability(tdm_output *output, unsigned int *has_capability)
{
+ tdm_private_module *private_module;
+
OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(has_capability != NULL, TDM_ERROR_INVALID_PARAMETER);
+
_pthread_mutex_lock(&private_display->lock);
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
- TDM_WRN("output(%d) dpms: %s", private_output->pipe,
- tdm_dpms_str(private_output->current_dpms_value));
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_DPMS_OFF;
- }
+ private_module = private_output->private_module;
- ret = _tdm_output_wait_vblank(output, interval, sync, func, user_data, 1);
+ if (!(private_module->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE))
+ *has_capability = 0;
+ else if (!(private_module->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT))
+ *has_capability = 0;
+ else
+ *has_capability = 1;
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-INTERN tdm_error
-tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data)
+EXTERN tdm_capture *
+tdm_output_create_capture(tdm_output *output, tdm_error *error)
{
- tdm_func_output *func_output;
- tdm_private_output_commit_handler *output_commit_handler = NULL;
- tdm_private_layer *private_layer = NULL;
- tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_ON;
-
- OUTPUT_FUNC_ENTRY();
-
- func_output = &private_display->func_output;
+ tdm_capture *capture = NULL;
- if (!func_output->output_commit) {
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- }
+ OUTPUT_FUNC_ENTRY_ERROR();
- if (!func_output->output_get_dpms) {
- dpms_value = private_output->current_dpms_value;
- } else {
- ret = func_output->output_get_dpms(private_output->output_backend, &dpms_value);
- if (ret != TDM_ERROR_NONE) {
- TDM_ERR("output_get_dpms failed");
- dpms_value = TDM_OUTPUT_DPMS_OFF;
- }
- }
+ _pthread_mutex_lock(&private_display->lock);
- if (dpms_value == TDM_OUTPUT_DPMS_ON) {
- if (func) {
- if (!private_output->regist_commit_cb) {
- private_output->regist_commit_cb = 1;
- ret = func_output->output_set_commit_handler(private_output->output_backend,
- tdm_output_cb_commit);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
- }
+ capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error);
- output_commit_handler = calloc(1, sizeof(tdm_private_output_commit_handler));
- if (!output_commit_handler) {
- TDM_ERR("failed: alloc memory");
- return TDM_ERROR_OUT_OF_MEMORY;
- }
+ _pthread_mutex_unlock(&private_display->lock);
- LIST_ADDTAIL(&output_commit_handler->link, &private_output->output_commit_handler_list);
- output_commit_handler->private_output = private_output;
- output_commit_handler->func = func;
- output_commit_handler->user_data = user_data;
- output_commit_handler->owner_tid = syscall(SYS_gettid);
- }
+ return capture;
+}
- ret = func_output->output_commit(private_output->output_backend, sync,
- output_commit_handler);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);
+EXTERN tdm_hwc *
+tdm_output_get_hwc(tdm_output *output, tdm_error *error)
+{
+ tdm_private_hwc *private_hwc = NULL;
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("output(%d) backend commit: handle(%p) func(%p) user_data(%p)",
- private_output->pipe, output_commit_handler, func, user_data);
- }
+ OUTPUT_FUNC_ENTRY_ERROR();
- LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
- if (!private_layer->waiting_buffer)
- continue;
+ _pthread_mutex_lock(&private_display->lock);
- private_layer->committed_buffer = private_layer->waiting_buffer;
- private_layer->waiting_buffer = NULL;
- if (tdm_debug_module & TDM_DEBUG_BUFFER)
- TDM_INFO("layer(%p) waiting_buffer(%p) committed_buffer(%p)",
- private_layer, private_layer->waiting_buffer,
- private_layer->committed_buffer->buffer);
+ private_hwc = private_output->private_hwc;
+ if (!private_hwc) {
+ if (error)
+ *error = TDM_ERROR_BAD_REQUEST;
+ _pthread_mutex_unlock(&private_display->lock);
+ return NULL;
}
- if (dpms_value != TDM_OUTPUT_DPMS_ON) {
- TDM_WRN("TDM_OUTPUT_DPMS_OFF. Directly call commit handler instead of commit.");
- if (func)
- func(output, 0, 0, 0, user_data);
- }
+ if (error)
+ *error = TDM_ERROR_NONE;
- return ret;
+ _pthread_mutex_unlock(&private_display->lock);
-commit_failed:
- if (output_commit_handler) {
- LIST_DEL(&output_commit_handler->link);
- free(output_commit_handler);
- }
- return ret;
+ return private_hwc;
}
EXTERN tdm_error
-tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
- void *user_data)
+tdm_output_set_mirror(tdm_output *output, tdm_output *src_output, tdm_transform transform)
{
+ /* LCOV_EXCL_START */
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
+ tdm_private_output *private_src_output;
+
OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(src_output != NULL, TDM_ERROR_INVALID_PARAMETER);
+
_pthread_mutex_lock(&private_display->lock);
- if (private_display->commit_type == TDM_COMMIT_TYPE_NONE)
- private_display->commit_type = TDM_COMMIT_TYPE_OUTPUT;
- else if (private_display->commit_type == TDM_COMMIT_TYPE_LAYER) {
- TDM_ERR("Can't supported. Use tdm_layer_commit");
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
+ private_src_output = (tdm_private_output*)src_output;
+
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_MIRROR)) {
+ TDM_INFO("output(%d) doesn't support the mirror.", private_output->pipe);
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- if (private_display->commit_per_vblank) {
- TDM_ERR("Use tdm_layer_commit");
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_BAD_REQUEST;
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_output_set_mirror((hal_tdm_output *)private_output->output_backend,
+ (hal_tdm_output *)private_src_output->output_backend, (hal_tdm_transform)transform);
}
+ else {
+ if (!func_output->output_set_mirror) {
+ TDM_WRN("not implemented!!");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
- TDM_ERR("output(%d) dpms: %s", private_output->pipe,
- tdm_dpms_str(private_output->current_dpms_value));
+ ret = func_output->output_set_mirror(private_output->output_backend,
+ private_src_output->output_backend,
+ transform);
+ }
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("output(%p) fails to set MIRROR.", private_output);
_pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_DPMS_OFF;
+ return TDM_ERROR_BAD_REQUEST;
}
- if (tdm_debug_module & TDM_DEBUG_COMMIT)
- TDM_INFO("output(%d) commit", private_output->pipe);
-
- ret = tdm_output_commit_internal(output, sync, func, user_data);
-
_pthread_mutex_unlock(&private_display->lock);
return ret;
+ /* LCOV_EXCL_STOP */
}
-EXTERN tdm_error
-tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode)
+tdm_error
+tdm_output_unset_mirror(tdm_output *output)
{
+ /* LCOV_EXCL_START */
+ tdm_private_module *private_module;
tdm_func_output *func_output;
- OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
+ OUTPUT_FUNC_ENTRY();
_pthread_mutex_lock(&private_display->lock);
- func_output = &private_display->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- if (!func_output->output_set_mode) {
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_MIRROR)) {
+ TDM_INFO("output(%d) doesn't support the mirror.", private_output->pipe);
_pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
+ return TDM_ERROR_BAD_REQUEST;
}
- ret = func_output->output_set_mode(private_output->output_backend, mode);
- if (ret == TDM_ERROR_NONE)
- private_output->current_mode = mode;
- _pthread_mutex_unlock(&private_display->lock);
-
- return ret;
-}
-
-EXTERN tdm_error
-tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
-{
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
-
- _pthread_mutex_lock(&private_display->lock);
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_output_unset_mirror((hal_tdm_output *)private_output->output_backend);
+ } else {
+ if (!func_output->output_unset_mirror) {
+ TDM_WRN("not implemented!!");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
- *mode = private_output->current_mode;
+ ret = func_output->output_unset_mirror(private_output->output_backend);
+ }
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("output(%p) fails to unset MIRROR.", private_output);
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_BAD_REQUEST;
+ }
_pthread_mutex_unlock(&private_display->lock);
return ret;
+ /* LCOV_EXCL_STOP */
}
-static tdm_error
-_tdm_output_dpms_changed_timeout(void *user_data)
+INTERN tdm_error
+tdm_output_choose_commit_per_vblank_mode(tdm_private_output *private_output, int mode)
{
- tdm_private_output *private_output = user_data;
- tdm_value value;
+ if (!private_output)
+ return TDM_ERROR_INVALID_PARAMETER;
+
+ if (mode < 0 || mode > 2)
+ return TDM_ERROR_INVALID_PARAMETER;
- value.u32 = private_output->current_dpms_value;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_sub,
- TDM_OUTPUT_CHANGE_DPMS,
- value, 0);
+ private_output->commit_per_vblank = mode;
+
+ if (private_output->commit_per_vblank == 0)
+ TDM_INFO("commit per vblank: disable");
+ else if (private_output->commit_per_vblank == 1)
+ TDM_INFO("commit per vblank: enable (1 layer)");
+ else if (private_output->commit_per_vblank == 2)
+ TDM_INFO("commit per vblank: enable (previous commit)");
return TDM_ERROR_NONE;
}
-INTERN void
-tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
+/* LCOV_EXCL_START */
+INTERN tdm_error
+tdm_voutput_destroy(tdm_voutput *voutput)
{
+ tdm_private_module *private_module = NULL;
+ tdm_voutput *voutput_backend = NULL;
+ tdm_func_voutput *func_voutput = NULL;
+
tdm_private_display *private_display;
- tdm_private_output *private_output = user_data;
- tdm_value value;
+ tdm_private_voutput *private_voutput;
+ tdm_private_output *private_output;
+ tdm_error ret = TDM_ERROR_NONE;
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
- TDM_RETURN_IF_FAIL(private_output);
+ _pthread_mutex_lock(&private_display->lock);
- private_display = private_output->private_display;
+ func_voutput = &private_module->func_voutput;
+ voutput_backend = private_voutput->voutput_backend;
+ private_output = private_voutput->private_output;
+ tdm_display_destroy_private_output(private_output);
+ LIST_DEL(&private_voutput->link);
+ free(private_voutput);
+ if (func_voutput->voutput_destroy)
+ ret = func_voutput->voutput_destroy(voutput_backend);
- if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) {
- tdm_thread_cb_output_dpms output_dpms;
- tdm_error ret;
+ _pthread_mutex_unlock(&private_display->lock);
- _tdm_output_update(output_backend, user_data);
+ return ret;
+}
- output_dpms.base.type = TDM_THREAD_CB_OUTPUT_DPMS;
- output_dpms.base.length = sizeof output_dpms;
- output_dpms.output_stamp = private_output->stamp;
- output_dpms.dpms = dpms;
- output_dpms.user_data = user_data;
+INTERN tdm_error
+tdm_voutput_set_available_mode(tdm_voutput *voutput, const tdm_output_mode *modes, int count)
+{
+ tdm_private_display *private_display;
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- value.u32 = dpms;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_sub,
- TDM_OUTPUT_CHANGE_DPMS,
- value, 0);
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(count != 0, TDM_ERROR_INVALID_PARAMETER);
- ret = tdm_thread_send_cb(private_display->private_loop, &output_dpms.base);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- return;
- }
+ _pthread_mutex_lock(&private_display->lock);
- private_output->current_dpms_value = dpms;
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_set_available_mode((hal_tdm_voutput *)private_voutput->voutput_backend,
+ (const hal_tdm_output_mode *)modes, count);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_set_available_mode)
+ ret = func_voutput->voutput_set_available_mode(private_voutput->voutput_backend, modes, count);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
+ }
+ _pthread_mutex_unlock(&private_display->lock);
- value.u32 = dpms;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_main,
- TDM_OUTPUT_CHANGE_DPMS,
- value, 0);
+ return ret;
}
-EXTERN tdm_error
-tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
+INTERN tdm_error
+tdm_voutput_set_physical_size(tdm_voutput *voutput, unsigned int mmwidth, unsigned int mmheight)
{
- tdm_func_output *func_output;
- OUTPUT_FUNC_ENTRY();
-
- if (dpms_value > TDM_OUTPUT_DPMS_OFF)
- dpms_value = TDM_OUTPUT_DPMS_OFF;
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_private_display *private_display;
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- if (private_output->current_dpms_value == dpms_value) {
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
- }
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(mmwidth != 0, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(mmheight != 0, TDM_ERROR_INVALID_PARAMETER);
- /** Use timer to call the output change callback of the sub-thread.
- * The output change callback of tdm_server and tdm_vblank was called
- * in the main thread. And it made the multi thread issue. If we use
- * the timer, we can call the sub-thread's output change callback in
- * sub-thread.
- */
- if (!private_output->dpms_changed_timer) {
- private_output->dpms_changed_timer =
- tdm_event_loop_add_timer_handler(private_output->private_display,
- _tdm_output_dpms_changed_timeout, private_output, NULL);
- if (!private_output->dpms_changed_timer) {
- TDM_ERR("can't create dpms timer!!");
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_OUT_OF_MEMORY;
- }
- }
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- func_output = &private_display->func_output;
+ _pthread_mutex_lock(&private_display->lock);
- if (!func_output->output_set_dpms) {
- _pthread_mutex_unlock(&private_display->lock);
- private_output->current_dpms_value = dpms_value;
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NONE;
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_set_physical_size((hal_tdm_voutput *)private_voutput->voutput_backend, mmwidth, mmheight);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_set_physical_size)
+ ret = func_voutput->voutput_set_physical_size(private_voutput->voutput_backend, mmwidth, mmheight);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
}
+ _pthread_mutex_unlock(&private_display->lock);
- if (func_output->output_set_dpms_handler) {
- if (!private_output->regist_dpms_cb) {
- private_output->regist_dpms_cb = 1;
- ret = func_output->output_set_dpms_handler(private_output->output_backend,
- tdm_output_cb_dpms, private_output);
- if (ret != TDM_ERROR_NONE) {
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("Can't set the dpms handler!!");
- return ret;
- }
- }
- }
+ return ret;
+}
- ret = func_output->output_set_dpms(private_output->output_backend, dpms_value);
+INTERN tdm_error
+tdm_voutput_connect(tdm_voutput *voutput)
+{
+ tdm_private_display *private_display;
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- if (ret == TDM_ERROR_NONE && !func_output->output_set_dpms_handler) {
- tdm_value value;
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- private_output->current_dpms_value = dpms_value;
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- value.u32 = dpms_value;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_main,
- TDM_OUTPUT_CHANGE_DPMS,
- value, 0);
+ _pthread_mutex_lock(&private_display->lock);
- if (!LIST_IS_EMPTY(&private_output->change_handler_list_sub)) {
- ret = tdm_event_loop_source_timer_update(private_output->dpms_changed_timer, 1);
- if (ret != TDM_ERROR_NONE)
- TDM_NEVER_GET_HERE();
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_connect((hal_tdm_voutput *)private_voutput->voutput_backend);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_connect)
+ ret = func_voutput->voutput_connect(private_voutput->voutput_backend);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
}
- }
-
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-EXTERN tdm_error
-tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
+INTERN tdm_error
+tdm_voutput_disconnect(tdm_voutput *voutput)
{
- tdm_func_output *func_output;
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(dpms_value != NULL, TDM_ERROR_INVALID_PARAMETER);
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_private_display *private_display;
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- func_output = &private_display->func_output;
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- if (!func_output->output_get_dpms) {
- *dpms_value = private_output->current_dpms_value;
- _pthread_mutex_unlock(&private_display->lock);
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NONE;
- }
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- ret = func_output->output_get_dpms(private_output->output_backend, dpms_value);
+ _pthread_mutex_lock(&private_display->lock);
- if (*dpms_value != private_output->current_dpms_value) {
- private_output->current_dpms_value = *dpms_value;
- TDM_WRN("current_dpms_value changed: %s", tdm_dpms_str(*dpms_value));
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_disconnect((hal_tdm_voutput *)private_voutput->voutput_backend);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_disconnect)
+ ret = func_voutput->voutput_disconnect(private_voutput->voutput_backend);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
}
-
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-EXTERN tdm_capture *
-tdm_output_create_capture(tdm_output *output, tdm_error *error)
+INTERN tdm_error
+tdm_voutput_set_commit_func(tdm_voutput *voutput, tdm_voutput_commit_handler func)
{
- tdm_capture *capture = NULL;
-
- OUTPUT_FUNC_ENTRY_ERROR();
-
- _pthread_mutex_lock(&private_display->lock);
+ tdm_private_display *private_display;
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error);
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- _pthread_mutex_unlock(&private_display->lock);
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- return capture;
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_set_commit_func((hal_tdm_voutput *)private_voutput->voutput_backend,
+ (hal_tdm_voutput_commit_handler)func);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_set_commit_func)
+ ret = func_voutput->voutput_set_commit_func(private_voutput->voutput_backend, func);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
+ }
+ return ret;
}
-INTERN void
-tdm_output_call_change_handler_internal(tdm_private_output *private_output,
- struct list_head *change_handler_list,
- tdm_output_change_type type,
- tdm_value value,
- int no_check_thread_id)
+INTERN tdm_error
+tdm_voutput_commit_done(tdm_voutput *voutput)
{
tdm_private_display *private_display;
- tdm_private_change_handler *change_handler = NULL;
-
- TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
- TDM_RETURN_IF_FAIL(private_output);
+ tdm_private_module *private_module = NULL;
+ tdm_private_voutput *private_voutput;
+ tdm_func_voutput *func_voutput = NULL;
+ tdm_error ret = TDM_ERROR_NONE;
- private_display = private_output->private_display;
- if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) {
- if (type & TDM_OUTPUT_CHANGE_CONNECTION)
- TDM_INFO("output(%d) changed: %s (%d)",
- private_output->pipe, tdm_status_str(value.u32), value.u32);
- if (type & TDM_OUTPUT_CHANGE_DPMS)
- TDM_INFO("output(%d) changed: dpms %s (%d)",
- private_output->pipe, tdm_dpms_str(value.u32), value.u32);
- }
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- if (LIST_IS_EMPTY(change_handler_list))
- return;
+ private_voutput = (tdm_private_voutput*)voutput;
+ private_display = private_voutput->private_display;
+ private_module = private_voutput->private_module;
+ TDM_RETURN_VAL_IF_FAIL(private_module == private_display->virtual_module, TDM_ERROR_BAD_MODULE);
- LIST_FOR_EACH_ENTRY(change_handler, change_handler_list, link) {
- if (!no_check_thread_id && change_handler->owner_tid != syscall(SYS_gettid))
- TDM_NEVER_GET_HERE();
+ _pthread_mutex_lock(&private_display->lock);
- _pthread_mutex_unlock(&private_display->lock);
- change_handler->func(private_output, type,
- value, change_handler->user_data);
- _pthread_mutex_lock(&private_display->lock);
+ if (private_module->use_hal_tdm) {
+ ret = (tdm_error)hal_tdm_voutput_commit_done((hal_tdm_voutput *)private_voutput->voutput_backend);
+ } else {
+ func_voutput = &private_module->func_voutput;
+ if (func_voutput->voutput_commit_done)
+ ret = func_voutput->voutput_commit_done(private_voutput->voutput_backend);
+ else
+ ret = TDM_ERROR_NOT_IMPLEMENTED;
}
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
}
+/* LCOV_EXCL_STOP */