+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ *status = private_output->caps.status;
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+INTERN void
+tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status,
+ void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output = user_data;
+ tdm_value value;
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+ TDM_RETURN_IF_FAIL(private_output);
+
+ private_display = private_output->private_display;
+
+ if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) {
+ tdm_thread_cb_output_status output_status;
+ tdm_error ret;
+
+ output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS;
+ output_status.base.length = sizeof output_status;
+ output_status.output_stamp = private_output->stamp;
+ output_status.status = status;
+ output_status.user_data = user_data;
+
+ value.u32 = status;
+ tdm_output_call_change_handler_internal(private_output,
+ &private_output->change_handler_list_sub,
+ TDM_OUTPUT_CHANGE_CONNECTION,
+ value);
+
+ ret = tdm_thread_send_cb(private_display->private_loop, &output_status.base);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ return;
+ }
+
+ value.u32 = status;
+ tdm_output_call_change_handler_internal(private_output,
+ &private_output->change_handler_list_main,
+ TDM_OUTPUT_CHANGE_CONNECTION,
+ value);
+}
+
+EXTERN tdm_error
+tdm_output_add_change_handler(tdm_output *output,
+ tdm_output_change_handler func,
+ void *user_data)
+{
+ tdm_private_change_handler *change_handler;
+ OUTPUT_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ pthread_mutex_lock(&private_display->lock);
+
+ if (!private_output->regist_change_cb) {
+ _pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("not implemented!!");
+ return TDM_ERROR_NOT_IMPLEMENTED;
+ }
+
+ change_handler = calloc(1, sizeof(tdm_private_change_handler));
+ if (!change_handler) {
+ TDM_ERR("failed: alloc memory");
+ _pthread_mutex_unlock(&private_display->lock);
+ return TDM_ERROR_OUT_OF_MEMORY;
+ }
+
+ change_handler->private_output = private_output;
+ change_handler->func = func;
+ change_handler->user_data = user_data;
+ change_handler->owner_tid = syscall(SYS_gettid);
+
+ if (!tdm_thread_in_display_thread(change_handler->owner_tid))
+ LIST_ADD(&change_handler->link, &private_output->change_handler_list_sub);
+ else
+ LIST_ADD(&change_handler->link, &private_output->change_handler_list_main);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
+EXTERN void
+tdm_output_remove_change_handler(tdm_output *output,
+ tdm_output_change_handler func,
+ void *user_data)
+{
+ tdm_private_display *private_display;
+ tdm_private_output *private_output;
+ tdm_private_change_handler *h = NULL, *hh = NULL;