#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
+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)
+{
+ tdm_private_output *private_output = user_data;
+ tdm_private_vblank_handler *v = NULL;
+
+ TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OPERATION_FAILED);
+
+ TDM_ERR("TDM output(%d) vblank TIMEOUT!!", private_output->pipe);
+
+ 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;
+}
+
+INTERN void
+tdm_output_vblank_print_wait_information(tdm_private_output *private_output, void *user_data)
+{
+ tdm_private_vblank_handler *v = NULL;
+
+ TDM_RETURN_IF_FAIL(private_output != NULL);
+ TDM_RETURN_IF_FAIL(user_data != NULL);
+
+ TDM_ERR("TDM output(%d) vblank user_data(%p) info!!", private_output->pipe, user_data);
+
+ 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);
+ }
+}
+
+static void
+_tdm_output_vblank_timeout_update(tdm_private_output *private_output, int ms_delay)
+{
+ tdm_error ret;
+
+ 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);
+ }
+
+ 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;
+ }
+}
static tdm_private_hwc_window *
_tdm_output_find_private_hwc_window(tdm_private_output *private_output,
TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status));
_tdm_output_update(output_backend, user_data);
+ private_output->caps.status = status;
output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS;
output_status.base.length = sizeof output_status;
if (!tdm_thread_is_running())
_tdm_output_update(output_backend, user_data);
+ private_output->caps.status = status;
value.u32 = status;
tdm_output_call_change_handler_internal(private_output,
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) {
tdm_thread_cb_output_vblank output_vblank;
tdm_error ret;
+ vblank_handler->sent_to_frontend = 1;
+
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;
return;
}
+ vblank_handler->sent_to_frontend = 0;
+
+ _tdm_output_vblank_timeout_update(private_output, 0);
+
if (vblank_handler->owner_tid != tid)
TDM_NEVER_GET_HERE();
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);
}
}
EXTERN tdm_error
-tdm_output_hwc_validate(tdm_output *output, uint32_t *num_types)
+tdm_output_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds,
+ uint32_t num_wnds, uint32_t *num_types)
{
tdm_func_output *func_output = NULL;
+ tdm_private_hwc_window **composited_wnds_frontend = NULL;
+ tdm_hwc_window **composited_wnds_backend = NULL;
+ int i;
OUTPUT_FUNC_ENTRY();
/* LCOV_EXCL_STOP */
}
- ret = func_output->output_hwc_validate(private_output->output_backend, num_types);
+ 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;
+ }
+
+ 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 */
+ }
+
+ 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 queue;
}
-/* LCOV_EXCL_START */
-static void
-_tdm_target_window_dump_buffer(tdm_private_output *private_output, tbm_surface_h buffer)
-{
- unsigned int pipe;
- char fname[PATH_MAX];
-
- pipe = private_output->pipe;
-
- snprintf(fname, sizeof(fname), "tdm_%d_target_win", pipe);
-
- tbm_surface_internal_dump_buffer(buffer, fname);
- TDM_DBG("%s dump excute", fname);
-
- return;
-}
-/* LCOV_EXCL_STOP */
-
EXTERN tdm_error
-tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer,
- tdm_hwc_region damage)
+tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer, tdm_hwc_region damage)
{
tdm_func_output *func_output = NULL;
/* LCOV_EXCL_STOP */
}
- /* dump buffer */
- if (tdm_dump_enable)
- /* LCOV_EXCL_START */
- _tdm_target_window_dump_buffer((tdm_private_output *)output, target_buffer);
- /* LCOV_EXCL_STOP */
-
ret = func_output->output_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, damage);
_pthread_mutex_unlock(&private_display->lock);
}
}
+static int
+_is_hwc_output_still_existed(tdm_private_output *private_output)
+{
+ tdm_private_display *dpy;
+ tdm_private_output *o = NULL;
+
+ dpy = tdm_display_init(NULL);
+ TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_OPERATION_FAILED);
+
+ LIST_FOR_EACH_ENTRY(o, &dpy->output_list, link) {
+ if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
+ continue;
+
+ if (o == private_output)
+ goto exist;
+ }
+
+ tdm_display_deinit(dpy);
+ return 0;
+
+exist:
+ tdm_display_deinit(dpy);
+ return 1;
+}
/* gets called on behalf of the ecore-main-loop thread */
INTERN tdm_error
{
TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ /* 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))
+ return TDM_ERROR_NONE;
+
TDM_INFO("tdm-backend asks for revalidation for the output:%p.", private_output);
if (private_output->need_validate.hndl)
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;
+ }
+
ev.base.type = TDM_THREAD_CB_NEED_VALIDATE;
ev.base.length = sizeof ev;
ev.o = private_output;
fd = eventfd(0, 0);
TDM_WARNING_IF_FAIL(fd >= 0);
- tdm_event_loop_add_fd_handler(private_display, fd, TDM_EVENT_LOOP_READABLE,
- _need_validate_handler, private_output, &ret);
+ 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;