* 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
tdm_private_display *private_display; \
tdm_private_output *private_output; \
tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
- TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER); \
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); \
private_output = (tdm_private_output*)output; \
private_display = private_output->private_display
tdm_private_display *private_display; \
tdm_private_output *private_output; \
tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
- TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER, NULL); \
+ TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \
private_output = (tdm_private_output*)output; \
private_display = private_output->private_display
TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OPERATION_FAILED);
- TDM_ERR("TDM output(%d) vblank TIMEOUT!!", private_output->pipe);
+ private_output->vblank_timeout_timer_expired++;
+
+ 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" : "");
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)",
return;
}
TDM_INFO("output(%d) create vblank timeout timer", private_output->pipe);
+ private_output->vblank_timeout_timer_expired = 0;
}
ret = tdm_event_loop_source_timer_update(private_output->vblank_timeout_timer, ms_delay);
}
}
-static tdm_private_hwc_window *
-_tdm_output_find_private_hwc_window(tdm_private_output *private_output,
- tdm_hwc_window *hwc_window_backend)
+INTERN tdm_error
+tdm_output_init(tdm_private_display *private_display)
{
- tdm_private_hwc_window *private_hwc_window = NULL;
-
- LIST_FOR_EACH_ENTRY(private_hwc_window, &private_output->hwc_window_list, link) {
- if (private_hwc_window->hwc_window_backend == hwc_window_backend)
- return private_hwc_window;
- }
+ 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 NULL;
+ return TDM_ERROR_NONE;
}
INTERN tdm_error
-tdm_output_init(tdm_private_display *private_display)
+tdm_output_call_thread_cb_destroy(tdm_private_output *private_output)
{
- 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_CHANGE, tdm_display_find_output_stamp);
+ tdm_thread_cb_output_destroy output_destroy;
+ tdm_error ret;
+
+ 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;
+
+ ret = tdm_thread_cb_call(private_output, &output_destroy.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
return TDM_ERROR_NONE;
}
-EXTERN tdm_backend *
-tdm_output_get_backend(tdm_output *output, tdm_error *error)
+/* LCOV_EXCL_START */
+INTERN void
+tdm_output_thread_cb_destroy(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
+{
+ tdm_private_output *private_output = object;
+ tdm_private_output_destroy_handler *destroy_handler = user_data;
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ assert(destroy_handler->owner_tid == syscall(SYS_gettid));
+
+ _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_destroy_handler(tdm_output *output,
+ tdm_output_destroy_handler func,
+ void *user_data)
+{
+ 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);
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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);
+
+ return ret;
+}
+
+EXTERN void
+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_output_destroy_handler *destroy_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(destroy_handler, hh, &private_output->destroy_handler_list, link) {
+ if (destroy_handler->func != func || destroy_handler->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(&destroy_handler->link);
+ free(destroy_handler);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return;
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+}
+/* LCOV_EXCL_STOP */
+
+EXTERN tdm_module *
+tdm_output_get_backend_module(tdm_output *output, tdm_error *error)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
OUTPUT_FUNC_ENTRY_ERROR();
_pthread_mutex_lock(&private_display->lock);
- private_backend = private_output->private_backend;
+ private_module = private_output->private_module;
if (error)
*error = TDM_ERROR_NONE;
_pthread_mutex_unlock(&private_display->lock);
- return private_backend;
+ return private_module;
}
EXTERN tdm_error
return ret;
}
-/* LCOV_EXCL_START */
-static void
-_tdm_output_update(tdm_output *output_backend, void *user_data)
-{
- tdm_private_output *private_output = user_data;
- tdm_error ret;
-
- TDM_RETURN_IF_FAIL(private_output);
-
- ret = tdm_display_update_output(private_output->private_backend, output_backend, private_output->pipe);
- TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
-}
-/* LCOV_EXCL_STOP */
-
INTERN void
tdm_output_thread_cb_change(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
{
tdm_private_output *private_output = object;
- tdm_thread_cb_output_change *output_change = (tdm_thread_cb_output_change *)cb_base;
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_IF_FAIL(TDM_MUTEX_IS_LOCKED());
assert(change_handler->owner_tid == syscall(SYS_gettid));
+ 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, output_change->type, output_change->value, change_handler->user_data);
+ change_handler->func(private_output, type, value, change_handler->user_data);
_pthread_mutex_lock(&private_display->lock);
+
+}
+
+static tdm_error
+_tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output_conn_status status)
+{
+ tdm_thread_cb_output_status output_status;
+ pid_t caller_tid = syscall(SYS_gettid);
+ tdm_error ret;
+
+ 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;
+
+ ret = tdm_thread_cb_call(private_output, &output_status.base, 1);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ return TDM_ERROR_NONE;
}
static tdm_error
-_tdm_output_call_thread_cb_change(tdm_private_output *private_output, tdm_output_change_type type, tdm_value value)
+_tdm_output_call_thread_cb_dpms(tdm_private_output *private_output, tdm_output_dpms dpms)
{
- tdm_thread_cb_output_change output_change;
+ tdm_thread_cb_output_dpms output_dpms;
tdm_error ret;
- memset(&output_change, 0, sizeof output_change);
- output_change.base.type = TDM_THREAD_CB_OUTPUT_CHANGE;
- output_change.base.length = sizeof output_change;
- output_change.base.object_stamp = private_output->stamp;
- output_change.base.data = NULL;
- output_change.base.sync = 1;
- output_change.type = type;
- output_change.value = value;
+ 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;
- ret = tdm_thread_cb_call(private_output, &output_change.base);
+ ret = tdm_thread_cb_call(private_output, &output_dpms.base, 1);
TDM_WARNING_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_private_output *private_output = user_data;
- tdm_value value;
tdm_error ret;
- TDM_INFO("output(%d) main %s", private_output->pipe, tdm_status_str(status));
+ TDM_RETURN_IF_FAIL(private_output);
- _tdm_output_update(output_backend, user_data);
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status));
- value.u32 = status;
+ 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;
+ }
- ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_CONNECTION, value);
+ ret = _tdm_output_call_thread_cb_status(private_output, status);
TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
}
tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
{
tdm_private_output *private_output = user_data;
- tdm_value value;
tdm_error ret;
- TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(dpms));
+ TDM_INFO("output(%d) %s", private_output->pipe, tdm_dpms_str(dpms));
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));
+ TDM_INFO("output(%d) DPMS async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
+
+ ret = _tdm_output_call_thread_cb_dpms(private_output, dpms);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+INTERN void
+tdm_output_cb_status_hal_tdm(hal_tdm_output *output_backend, hal_tdm_output_conn_status status, void *user_data)
+{
+ 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;
- value.u32 = dpms;
+ 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_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+ 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;
+ 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 */
/* LCOV_EXCL_STOP */
}
- ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
+ 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;
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,
tdm_private_output *private_output;
tdm_private_output_change_handler *change_handler = NULL, *hh = NULL;
- TDM_RETURN_IF_FAIL(tdm_output_is_valid(output));
+ TDM_RETURN_IF_FAIL(output != NULL);
TDM_RETURN_IF_FAIL(func != NULL);
private_output = (tdm_private_output*)output;
if (change_handler->func != func || change_handler->user_data != user_data)
continue;
- tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
+ 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);
*count = 0;
LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
- (*count)++;
+ (*count)++;
if (*count == 0) {
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_NONE;
_pthread_mutex_lock(&private_display->lock);
- if (!tdm_backend_check_module_abi(private_output->private_backend, 1, 5)) {
-
- 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;
-
+ if (!tdm_module_check_abi(private_output->private_module, 1, 5)) {
_pthread_mutex_unlock(&private_display->lock);
-
- return TDM_ERROR_BAD_MODULE;
+ return TDM_ERROR_BAD_REQUEST;
}
if (min_w)
EXTERN tdm_error
tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
_pthread_mutex_lock(&private_display->lock);
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
- 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 */
- }
+ 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);
+ ret = func_output->output_set_property(private_output->output_backend, id, value);
+ }
_pthread_mutex_unlock(&private_display->lock);
EXTERN tdm_error
tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
_pthread_mutex_lock(&private_display->lock);
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
- 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 */
- }
+ 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;
- ret = func_output->output_get_property(private_output->output_backend, id,
- value);
+ 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;
vblank_handler->sent_to_frontend = 1;
- ret = tdm_thread_cb_call(vblank_handler->private_output, &output_vblank.base);
+ 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_thread_cb_commit(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
+_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_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_private_output_vblank_handler *vblank_handler = user_data;
+ tdm_thread_cb_output_vblank output_vblank;
+ tdm_error ret;
- tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL);
+ 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);
output_commit.tv_sec = tv_sec;
output_commit.tv_usec = tv_usec;
- ret = tdm_thread_cb_call(private_output, &output_commit.base);
+ 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
tdm_output_vblank_handler func, void *user_data,
unsigned int add_front)
{
- tdm_private_backend *private_backend;
+ 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_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
/* interval SHOULD be at least 1 */
if (interval <= 0)
interval = 1;
- if (!func_output->output_wait_vblank) {
- /* LCOV_EXCL_START */
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
+ 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);
+ 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("tdm_thread_cb_add failed");
goto wait_failed;
}
-
- ret = func_output->output_wait_vblank(private_output->output_backend, interval,
- sync, vblank_handler);
+ 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);
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);
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 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);
}
}
+/* LCOV_EXCL_START */
INTERN void
tdm_output_remove_commit_handler_internal(tdm_output *output, tdm_output_commit_handler func, void *user_data)
{
}
}
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
return ret;
}
+/* LCOV_EXCL_START */
EXTERN tdm_error
tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data)
{
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);
+
+ 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_backend *private_backend;
+ 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(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
private_output = (tdm_private_output*)output;
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_commit) {
- /* LCOV_EXCL_START */
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
+ 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 (func) {
- if (!private_output->regist_commit_cb) {
- private_output->regist_commit_cb = 1;
+ 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);
- }
+ 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) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed: alloc memory");
- return TDM_ERROR_OUT_OF_MEMORY;
- /* LCOV_EXCL_STOP */
- }
+ 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;
+ }
- 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");
+ 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 ret;
+ return TDM_ERROR_BAD_MODULE;
}
+ }
- 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);
+ 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;
}
- ret = func_output->output_commit(private_output->output_backend, sync,
- output_commit_handler);
+ 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)
if (!private_layer->waiting_buffer)
continue;
+ 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);
+ }
+
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,
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)
+ if (func) {
+ _pthread_mutex_unlock(&private_display->lock);
func(output, 0, 0, 0, user_data);
+ _pthread_mutex_lock(&private_display->lock);
+ }
}
return ret;
commit_failed:
- /* LCOV_EXCL_START */
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;
- /* LCOV_EXCL_STOP */
}
EXTERN tdm_error
return ret;
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
_pthread_mutex_lock(&private_display->lock);
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- 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 */
- }
+ 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_mode(private_output->output_backend, mode);
+ 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;
EXTERN tdm_error
tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
return TDM_ERROR_BAD_REQUEST;
}
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- TDM_INFO("output(%d) dpms '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
+ TDM_INFO("output(%d) DPMS '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
- 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("not implemented!!");
- goto done;
- /* LCOV_EXCL_STOP */
+ 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 */
+ }
}
-done:
if (ret == TDM_ERROR_NONE) {
if (private_output->current_dpms_value != dpms_value) {
- tdm_value value;
private_output->current_dpms_value = dpms_value;
- value.u32 = dpms_value;
- _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
- TDM_INFO("output(%d) dpms '%s' done", private_output->pipe, tdm_dpms_str(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;
/* update current_dpms_value forcely */
tdm_output_get_dpms_internal(output, &temp);
- TDM_ERR("output(%d) set_dpms failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
+ TDM_ERR("output(%d) set DPMS failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
}
_pthread_mutex_unlock(&private_display->lock);
EXTERN tdm_error
tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value)
{
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
+ int sync = 0;
OUTPUT_FUNC_ENTRY();
if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_ASYNC_DPMS)) {
return TDM_ERROR_BAD_REQUEST;
}
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
- if (!func_output->output_set_dpms_handler) {
- TDM_WRN("not implemented: output_set_dpms_handler");
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NOT_IMPLEMENTED;
- }
+ 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;
+ }
- if (!func_output->output_set_dpms_async) {
- TDM_WRN("not implemented: output_set_dpms_async");
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NOT_IMPLEMENTED;
+ 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 (!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 (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!!");
+ TDM_ERR("Can't set the DPMS handler!!");
return ret;
}
}
- TDM_INFO("output(%d) dpms async '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
+ TDM_INFO("output(%d) DPMS async '%s'", private_output->pipe, tdm_dpms_str(dpms_value));
- ret = func_output->output_set_dpms_async(private_output->output_backend, 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) {
- private_output->waiting_dpms_change = 1;
- TDM_INFO("output(%d) dpms async '%s' waiting", private_output->pipe, tdm_dpms_str(dpms_value));
+ 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;
/* 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));
+ TDM_ERR("output(%d) set DPMS async failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
}
_pthread_mutex_unlock(&private_display->lock);
tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value)
{
tdm_private_output *private_output;
- tdm_private_backend *private_backend;
+ tdm_private_module *private_module;
tdm_func_output *func_output;
tdm_error ret = TDM_ERROR_NONE;
- TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
private_output = (tdm_private_output*)output;
return TDM_ERROR_NONE;
}
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- if (!func_output->output_get_dpms) {
- /* LCOV_EXCL_START */
- *dpms_value = private_output->current_dpms_value;
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NONE;
- /* LCOV_EXCL_STOP */
- }
+ 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 */
+ }
- ret = func_output->output_get_dpms(private_output->output_backend, dpms_value);
+ 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");
+ TDM_ERR("output get DPMS failed");
*dpms_value = TDM_OUTPUT_DPMS_OFF;
/* LCOV_EXCL_STOP */
}
/* checking with backend's value */
if (*dpms_value != private_output->current_dpms_value) {
- tdm_value value;
- TDM_ERR("output(%d) dpms changed suddenly: %s -> %s",
- private_output->pipe, 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;
- value.u32 = *dpms_value;
- _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+ _tdm_output_call_thread_cb_dpms(private_output, *dpms_value);
}
return ret;
}
+INTERN tdm_error
+tdm_output_get_dpms_changing(tdm_output *output, int *changing)
+{
+ tdm_private_output *private_output;
+
+ TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(changing != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ private_output = (tdm_private_output*)output;
+
+ *changing = private_output->waiting_dpms_change;
+
+ return TDM_ERROR_NONE;
+}
+
+
EXTERN tdm_error
tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
{
return ret;
}
-EXTERN tdm_capture *
-tdm_output_create_capture(tdm_output *output, tdm_error *error)
+EXTERN tdm_error
+tdm_output_has_capture_capability(tdm_output *output, unsigned int *has_capability)
{
- tdm_capture *capture = NULL;
+ tdm_private_module *private_module;
- OUTPUT_FUNC_ENTRY_ERROR();
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(has_capability != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
- capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error);
+ private_module = private_output->private_module;
+
+ 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 capture;
+ return ret;
}
-EXTERN tdm_hwc_window *
-tdm_output_hwc_create_window(tdm_output *output, tdm_error *error)
+EXTERN tdm_capture *
+tdm_output_create_capture(tdm_output *output, tdm_error *error)
{
- tdm_hwc_window *hwc_window = NULL;
+ tdm_capture *capture = NULL;
OUTPUT_FUNC_ENTRY_ERROR();
_pthread_mutex_lock(&private_display->lock);
- if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
- hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 0, error);
- else {
- /* LCOV_EXCL_START */
- TDM_ERR("output(%p) not support HWC", private_output);
- if (error)
- *error = TDM_ERROR_BAD_REQUEST;
- /* LCOV_EXCL_STOP */
- }
+ capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error);
_pthread_mutex_unlock(&private_display->lock);
- return hwc_window;
+ return capture;
}
-EXTERN tdm_hwc_window *
-tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error)
+EXTERN tdm_hwc *
+tdm_output_get_hwc(tdm_output *output, tdm_error *error)
{
- tdm_hwc_window *hwc_window = NULL;
+ tdm_private_hwc *private_hwc = NULL;
OUTPUT_FUNC_ENTRY_ERROR();
_pthread_mutex_lock(&private_display->lock);
- if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
- hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 1, error);
- else {
- /* LCOV_EXCL_START */
- TDM_ERR("output(%p) not support HWC", private_output);
+ private_hwc = private_output->private_hwc;
+ if (!private_hwc) {
if (error)
*error = TDM_ERROR_BAD_REQUEST;
- /* LCOV_EXCL_STOP */
+ _pthread_mutex_unlock(&private_display->lock);
+ return NULL;
}
- _pthread_mutex_unlock(&private_display->lock);
-
- return hwc_window;
-}
-
-EXTERN tdm_error
-tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window)
-{
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(hwc_window != NULL, TDM_ERROR_INVALID_PARAMETER);
-
- _pthread_mutex_lock(&private_display->lock);
-
- ret = tdm_hwc_window_destroy_internal(hwc_window);
+ if (error)
+ *error = TDM_ERROR_NONE;
_pthread_mutex_unlock(&private_display->lock);
- return ret;
+ return private_hwc;
}
EXTERN tdm_error
-tdm_output_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds,
- uint32_t num_wnds, uint32_t *num_types)
+tdm_output_set_mirror(tdm_output *output, tdm_output *src_output, tdm_transform transform)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
- tdm_private_hwc_window **composited_wnds_frontend = NULL;
- tdm_hwc_window **composited_wnds_backend = NULL;
- int i;
+ /* 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(num_types != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(src_output != NULL, TDM_ERROR_INVALID_PARAMETER);
_pthread_mutex_lock(&private_display->lock);
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
+ 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;
}
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_hwc_validate) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
-
- if (num_wnds == 0) {
- ret = func_output->output_hwc_validate(private_output->output_backend, NULL, 0, num_types);
-
- _pthread_mutex_unlock(&private_display->lock);
-
- return ret;
+ 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;
+ }
- composited_wnds_backend = calloc(num_wnds, sizeof(tdm_hwc_window *));
- if (!composited_wnds_backend) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_OUT_OF_MEMORY;
- /* LCOV_EXCL_STOP */
+ ret = func_output->output_set_mirror(private_output->output_backend,
+ private_src_output->output_backend,
+ transform);
}
-
- composited_wnds_frontend = (tdm_private_hwc_window **)composited_wnds;
-
- for (i = 0; i < num_wnds; i++)
- composited_wnds_backend[i] = composited_wnds_frontend[i]->hwc_window_backend;
-
- ret = func_output->output_hwc_validate(private_output->output_backend, composited_wnds_backend, num_wnds, num_types);
-
- free(composited_wnds_backend);
-
- _pthread_mutex_unlock(&private_display->lock);
-
- return ret;
-}
-
-EXTERN tdm_error
-tdm_output_hwc_set_need_validate_handler(tdm_output *output,
- tdm_output_need_validate_handler hndl)
-{
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(hndl != NULL, TDM_ERROR_INVALID_PARAMETER);
-
- _pthread_mutex_lock(&private_display->lock);
-
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_ERR("output(%p) fails to set MIRROR.", private_output);
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- /* there's no reason to allow this */
- if (private_output->need_validate.hndl) {
-
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_OPERATION_FAILED;
- }
-
- private_output->need_validate.hndl = hndl;
-
_pthread_mutex_unlock(&private_display->lock);
return ret;
+ /* LCOV_EXCL_STOP */
}
-EXTERN tdm_error
-tdm_output_hwc_get_changed_composition_types(tdm_output *output,
- uint32_t *num_elements,
- tdm_hwc_window **hwc_window,
- tdm_hwc_window_composition *composition_types)
+tdm_error
+tdm_output_unset_mirror(tdm_output *output)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
- tdm_private_hwc_window * private_hwc_window = NULL;
- int i = 0;
+ /* LCOV_EXCL_START */
+ tdm_private_module *private_module;
+ tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
- TDM_RETURN_VAL_IF_FAIL(num_elements != NULL, TDM_ERROR_INVALID_PARAMETER);
-
_pthread_mutex_lock(&private_display->lock);
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_BAD_REQUEST;
- }
-
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_hwc_get_changed_composition_types) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_WRN("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
+ private_module = private_output->private_module;
+ func_output = &private_module->func_output;
- ret = func_output->output_hwc_get_changed_composition_types(private_output->output_backend,
- num_elements, hwc_window, composition_types);
- if (ret != TDM_ERROR_NONE) {
- /* LCOV_EXCL_START */
+ 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 ret;
- /* LCOV_EXCL_STOP */
- }
-
- if (hwc_window == NULL || composition_types == NULL) {
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
+ return TDM_ERROR_BAD_REQUEST;
}
- for (i = 0; i < *num_elements; i++) {
-
- private_hwc_window = _tdm_output_find_private_hwc_window(private_output, hwc_window[i]);
-
- if (private_hwc_window == NULL) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed! This should never happen!");
- func_output->output_hwc_destroy_window(private_output->output_backend, hwc_window[i]);
- *num_elements = 0;
+ 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_OPERATION_FAILED;
- /* LCOV_EXCL_STOP */
+ return TDM_ERROR_NOT_IMPLEMENTED;
}
- hwc_window[i] = (tdm_hwc_window*)private_hwc_window;
+ ret = func_output->output_unset_mirror(private_output->output_backend);
}
-
- _pthread_mutex_unlock(&private_display->lock);
-
- return ret;
-}
-
-tdm_error
-tdm_output_hwc_accept_changes(tdm_output *output)
-{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
-
- OUTPUT_FUNC_ENTRY();
-
- _pthread_mutex_lock(&private_display->lock);
-
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
+ 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;
}
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_hwc_validate) {
- /* 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_hwc_accept_changes(private_output->output_backend);
-
_pthread_mutex_unlock(&private_display->lock);
return ret;
+ /* LCOV_EXCL_STOP */
}
-tbm_surface_queue_h
-tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error)
+INTERN tdm_error
+tdm_output_choose_commit_per_vblank_mode(tdm_private_output *private_output, int mode)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
- tbm_surface_queue_h queue = NULL;
-
- OUTPUT_FUNC_ENTRY_ERROR();
-
- _pthread_mutex_lock(&private_display->lock);
-
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- if (error)
- *error = TDM_ERROR_BAD_REQUEST;
- _pthread_mutex_unlock(&private_display->lock);
- return NULL;
- }
-
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ if (!private_output)
+ return TDM_ERROR_INVALID_PARAMETER;
- if (!func_output->output_hwc_get_target_buffer_queue) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_WRN("not implemented!!");
- return NULL;
- /* LCOV_EXCL_STOP */
- }
+ if (mode < 0 || mode > 2)
+ return TDM_ERROR_INVALID_PARAMETER;
- queue = func_output->output_hwc_get_target_buffer_queue(private_output->output_backend, error);
+ private_output->commit_per_vblank = mode;
- _pthread_mutex_unlock(&private_display->lock);
+ 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 queue;
+ return TDM_ERROR_NONE;
}
-EXTERN tdm_error
-tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer, tdm_hwc_region damage)
+/* LCOV_EXCL_START */
+INTERN tdm_error
+tdm_voutput_destroy(tdm_voutput *voutput)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
+ tdm_private_module *private_module = NULL;
+ tdm_voutput *voutput_backend = NULL;
+ tdm_func_voutput *func_voutput = NULL;
- OUTPUT_FUNC_ENTRY();
+ tdm_private_display *private_display;
+ 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);
_pthread_mutex_lock(&private_display->lock);
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_BAD_REQUEST;
- }
-
- if (tdm_debug_dump & TDM_DUMP_FLAG_WINDOW) {
- /* LCOV_EXCL_START */
- char str[TDM_PATH_LEN];
- static int i;
- snprintf(str, TDM_PATH_LEN, "target_window_%d_%03d",
- private_output->index, i++);
- tdm_helper_dump_buffer_str(target_buffer, tdm_debug_dump_dir, str);
- /* LCOV_EXCL_STOP */
- }
-
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_hwc_set_client_target_buffer) {
- /* 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_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, damage);
+ 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);
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
-EXTERN tdm_error
-tdm_output_hwc_unset_client_target_buffer(tdm_output *output)
+INTERN tdm_error
+tdm_voutput_set_available_mode(tdm_voutput *voutput, const tdm_output_mode *modes, int count)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output = NULL;
-
- OUTPUT_FUNC_ENTRY();
-
- _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->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_BAD_REQUEST;
- }
+ 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);
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ 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);
- if (!func_output->output_hwc_unset_client_target_buffer) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
-
- ret = func_output->output_hwc_unset_client_target_buffer(private_output->output_backend);
+ _pthread_mutex_lock(&private_display->lock);
+ 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);
return ret;
}
-static void
-_tdm_output_hwc_layer_commit_handler(tdm_layer *layer, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
+INTERN tdm_error
+tdm_voutput_set_physical_size(tdm_voutput *voutput, unsigned int mmwidth, unsigned int mmheight)
{
- tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler = (tdm_private_output_hwc_target_buffer_commit_handler *)user_data;
- tdm_output_hwc_target_buffer_commit_handler func = output_hwc_target_buffer_commit_handler->func;
- tdm_output *output = (tdm_output *)output_hwc_target_buffer_commit_handler->private_output;
- void *data = output_hwc_target_buffer_commit_handler->user_data;
-
- func(output, sequence, tv_sec, tv_usec, data);
+ 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;
- free(output_hwc_target_buffer_commit_handler);
-}
+ 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);
-tdm_error
-tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_target_buffer_commit_handler func, void *user_data)
-{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output;
- tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler;
- tdm_layer *layer = NULL;
- tdm_private_layer *private_layer;
- const tdm_output_mode *mode;
- tbm_surface_h buffer;
-
- OUTPUT_FUNC_ENTRY();
+ 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);
_pthread_mutex_lock(&private_display->lock);
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_BAD_REQUEST;
- }
-
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
-
- if (!func_output->output_hwc_get_client_target_buffer_layer) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
-
- layer = func_output->output_hwc_get_client_target_buffer_layer(private_output->output_backend,
- &ret);
- if (!layer) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("no assigned layer!!");
- return TDM_ERROR_INVALID_PARAMETER;
- /* LCOV_EXCL_STOP */
- }
-
- private_layer = (tdm_private_layer*)layer;
-
- if (!func_output->output_hwc_get_client_target_buffer) {
- /* LCOV_EXCL_START */
- _pthread_mutex_unlock(&private_display->lock);
- TDM_ERR("not implemented!!");
- return TDM_ERROR_NOT_IMPLEMENTED;
- /* LCOV_EXCL_STOP */
- }
-
- buffer = func_output->output_hwc_get_client_target_buffer(private_output->output_backend,
- &ret);
- if (buffer)
- ret = tdm_layer_set_buffer_internal(private_layer, buffer);
- else
- ret = tdm_layer_unset_buffer_internal(private_layer);
- if (ret != TDM_ERROR_NONE) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed: layer set info(window)");
- /* LCOV_EXCL_STOP */
- return ret;
- }
-
- if (private_output->need_set_target_info) {
- mode = private_output->current_mode;
- private_output->target_buffer_info.src_config.size.h = mode->hdisplay;
- private_output->target_buffer_info.src_config.size.v = mode->vdisplay;
- private_output->target_buffer_info.src_config.pos.x = 0;
- private_output->target_buffer_info.src_config.pos.y = 0;
- private_output->target_buffer_info.src_config.pos.w = mode->hdisplay;
- private_output->target_buffer_info.src_config.pos.h = mode->vdisplay;
- private_output->target_buffer_info.dst_pos.x = 0;
- private_output->target_buffer_info.dst_pos.y = 0;
- private_output->target_buffer_info.dst_pos.w = mode->hdisplay;
- private_output->target_buffer_info.dst_pos.h = mode->vdisplay;
- private_output->target_buffer_info.transform = TDM_TRANSFORM_NORMAL;
-
- ret = tdm_layer_set_info_internal(private_layer, &private_output->target_buffer_info);
- if (ret != TDM_ERROR_NONE) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed: layer set info(window)");
- /* LCOV_EXCL_STOP */
- return ret;
- }
-
- private_output->need_set_target_info = 0;
- }
-
- output_hwc_target_buffer_commit_handler = calloc(1, sizeof(tdm_private_output_hwc_target_buffer_commit_handler));
- if (!output_hwc_target_buffer_commit_handler) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed: alloc memory");
- return TDM_ERROR_OUT_OF_MEMORY;
- /* LCOV_EXCL_STOP */
- }
-
- output_hwc_target_buffer_commit_handler->private_output = private_output;
- output_hwc_target_buffer_commit_handler->func = func;
- output_hwc_target_buffer_commit_handler->user_data = user_data;
-
- ret = tdm_layer_commit_internal(private_layer, _tdm_output_hwc_layer_commit_handler, user_data);
- if (ret != TDM_ERROR_NONE) {
- /* LCOV_EXCL_START */
- TDM_ERR("failed: commit layer(target buffer)");
- free(output_hwc_target_buffer_commit_handler);
- /* LCOV_EXCL_STOP */
- return ret;
+ 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);
return ret;
}
-tdm_error
-tdm_output_hwc_get_video_supported_formats(tdm_output *output, const tbm_format **formats,
- int *count)
+INTERN tdm_error
+tdm_voutput_connect(tdm_voutput *voutput)
{
- tdm_private_backend *private_backend;
- tdm_func_output *func_output;
- OUTPUT_FUNC_ENTRY();
-
- TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+ 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;
- _pthread_mutex_lock(&private_display->lock);
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- private_backend = private_output->private_backend;
- func_output = &private_backend->func_output;
+ 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);
- if (!func_output->output_hwc_get_video_supported_formats) {
- /* 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_hwc_get_video_supported_formats(
- private_output->output_backend, formats, count);
+ _pthread_mutex_lock(&private_display->lock);
+ 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;
}
-static int
-_is_hwc_output_still_existed(tdm_private_output *private_output)
+INTERN tdm_error
+tdm_voutput_disconnect(tdm_voutput *voutput)
{
- tdm_private_backend *private_backend = private_output->private_backend;
- tdm_private_output *o = NULL;
-
- LIST_FOR_EACH_ENTRY(o, &private_backend->output_list, link) {
- if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
- continue;
-
- if (o == private_output)
- goto exist;
- }
-
- return 0;
-
-exist:
- return 1;
-}
+ 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;
-/* gets called on behalf of the ecore-main-loop thread */
-INTERN void
-tdm_output_need_validate_handler_thread(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
-{
- tdm_private_output *private_output = object;
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_IF_FAIL(private_output != NULL);
+ 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);
_pthread_mutex_lock(&private_display->lock);
- /* as we get 'private_output' within an event, an output this 'private_output'
- * points to can be destroyed already */
- if (!_is_hwc_output_still_existed(private_output)) {
- _pthread_mutex_unlock(&private_display->lock);
- return;
+ 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);
- TDM_INFO("tdm-backend asks for revalidation for the output:%p.", private_output);
-
- if (private_output->need_validate.hndl)
- private_output->need_validate.hndl((tdm_output*)private_output);
-}
-
-/* gets called on behalf of the tdm-thread */
-static tdm_error
-_need_validate_handler(int fd, tdm_event_loop_mask mask, void *user_data)
-{
- tdm_thread_cb_need_validate ev;
- tdm_private_output *private_output;
- tdm_error ret;
- uint64_t value;
-
- private_output = (tdm_private_output *)user_data;
-
- if (read(private_output->need_validate.event_fd, &value, sizeof(value)) < 0) {
- TDM_ERR("error while trying to read from a need_validate.event_fd fd.");
- return TDM_ERROR_OPERATION_FAILED;
- }
-
- memset(&ev, 0, sizeof ev);
- ev.base.type = TDM_THREAD_CB_NEED_VALIDATE;
- ev.base.length = sizeof ev;
- ev.base.object_stamp = private_output->stamp;
- ev.base.data = NULL;
- ev.base.sync = 0;
-
- ret = tdm_thread_cb_call(private_output, &ev.base);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
-
- TDM_INFO("tdm-thread: get a 'need to revalidate' event for the ouptut:%p.", private_output);
-
- /* who cares about this? */
- return TDM_ERROR_NONE;
+ return ret;
}
INTERN tdm_error
-tdm_output_need_validate_event_init(tdm_output *output)
+tdm_voutput_set_commit_func(tdm_voutput *voutput, tdm_voutput_commit_handler func)
{
- int fd;
+ 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;
- OUTPUT_FUNC_ENTRY();
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
+ 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);
- if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
- TDM_ERR("output(%p) not support HWC", private_output);
- return TDM_ERROR_BAD_REQUEST;
+ 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;
}
-
- /* build in eventfd fds into event_loop listened & handled by the tdm-thread */
- fd = eventfd(0, 0);
- TDM_WARNING_IF_FAIL(fd >= 0);
-
- private_output->need_validate.event_source = tdm_event_loop_add_fd_handler(private_display,
- fd, TDM_EVENT_LOOP_READABLE, _need_validate_handler, private_output, &ret);
- TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
-
- private_output->need_validate.event_fd = fd;
-
- TDM_INFO("register an output:%p for the revalidation, event_fd:%d.", private_output, fd);
-
return ret;
}
INTERN tdm_error
-tdm_output_choose_commit_per_vblank_mode(tdm_private_output *private_output, int mode)
+tdm_voutput_commit_done(tdm_voutput *voutput)
{
- if (!private_output)
- return TDM_ERROR_INVALID_PARAMETER;
+ 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 (mode < 0 || mode > 2)
- return TDM_ERROR_INVALID_PARAMETER;
+ TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER);
- private_output->commit_per_vblank = mode;
+ 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);
- 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)");
+ _pthread_mutex_lock(&private_display->lock);
- return TDM_ERROR_NONE;
+ 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 */