{
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_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);
+
return TDM_ERROR_NONE;
}
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_change(tdm_private_output *private_output, tdm_output_change_type type, tdm_value value)
+_tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output_conn_status status)
{
- tdm_thread_cb_output_change output_change;
+ tdm_thread_cb_output_status output_status;
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_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;
+ output_status.base.sync = 1;
+ output_status.status = status;
- ret = tdm_thread_cb_call(private_output, &output_change.base);
+ ret = tdm_thread_cb_call(private_output, &output_status.base);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ return TDM_ERROR_NONE;
+}
+
+static tdm_error
+_tdm_output_call_thread_cb_dpms(tdm_private_output *private_output, tdm_output_dpms dpms)
+{
+ tdm_thread_cb_output_dpms output_dpms;
+ tdm_error ret;
+
+ 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_dpms.base);
TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
return TDM_ERROR_NONE;
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_RETURN_IF_FAIL(private_output);
private_output->caps.status = status;
}
- value.u32 = 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));
private_output->waiting_dpms_change = 0;
TDM_INFO("output(%d) dpms async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
- value.u32 = dpms;
-
- ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+ ret = _tdm_output_call_thread_cb_dpms(private_output, dpms);
TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
}
/* 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;
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);
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_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 {
/* 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, 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;