#include "config.h"
#endif
-#include "tdm.h"
-#include "tdm_backend.h"
#include "tdm_private.h"
-#include "tdm_helper.h"
#define COUNT_MAX 10
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(output != NULL, TDM_ERROR_INVALID_PARAMETER); \
+ TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), 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(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \
+ TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER, NULL); \
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,
return ret;
}
+/* LCOV_EXCL_START */
static void
_tdm_output_update(tdm_output *output_backend, void *user_data)
{
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_OUTPUT_CHANGE_CONNECTION,
value, 0);
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_output_add_change_handler(tdm_output *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) {
+ /* LCOV_EXCL_START */
TDM_ERR("failed: alloc memory");
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
change_handler->private_output = private_output;
tdm_private_output *private_output;
tdm_private_change_handler *h = NULL, *hh = NULL;
- TDM_RETURN_IF_FAIL(output != NULL);
+ TDM_RETURN_IF_FAIL(tdm_output_is_valid(output));
TDM_RETURN_IF_FAIL(func != NULL);
private_output = (tdm_private_output*)output;
_pthread_mutex_lock(&private_display->lock);
- if (private_display->hwc_enable) {
+ if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
+ TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
*count = 0;
_pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
+ return TDM_ERROR_BAD_REQUEST;
}
*count = 0;
if (error)
*error = TDM_ERROR_NONE;
- if (private_display->hwc_enable) {
+ if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) {
_pthread_mutex_unlock(&private_display->lock);
+ TDM_ERR("output(%p) support HWC. Use HWC functions", private_output);
if (error)
- *error = TDM_ERROR_INVALID_PARAMETER;
+ *error = TDM_ERROR_BAD_REQUEST;
return NULL;
}
func_output = &private_display->func_output;
if (!func_output->output_set_property) {
+ /* 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_set_property(private_output->output_backend, id,
func_output = &private_display->func_output;
if (!func_output->output_get_property) {
+ /* 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_get_property(private_output->output_backend, id,
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();
TDM_INFO("handler(%p)", output_commit_handler);
}
- if (private_display->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
+ if (private_output->commit_type == TDM_COMMIT_TYPE_OUTPUT) {
/* In case of layer commit, the below will be handled in the layer commit callback */
LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) {
if (private_layer->committed_buffer)
interval = 1;
if (!func_output->output_wait_vblank) {
+ /* LCOV_EXCL_START */
TDM_ERR("not implemented!!");
return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
}
if (!private_output->regist_vblank_cb) {
vblank_handler = calloc(1, sizeof(tdm_private_vblank_handler));
if (!vblank_handler) {
+ /* LCOV_EXCL_START */
TDM_ERR("failed: alloc memory");
return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
if (tdm_debug_module & TDM_DEBUG_COMMIT)
sync, vblank_handler);
TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
+ _tdm_output_vblank_timeout_update(private_output, 1000);
+
if (tdm_debug_module & TDM_DEBUG_COMMIT)
TDM_INFO("output(%d) backend wait_vblank", private_output->pipe);
}
return ret;
wait_failed:
+ /* LCOV_EXCL_START */
if (vblank_handler) {
LIST_DEL(&vblank_handler->link);
free(vblank_handler);
}
return ret;
+ /* LCOV_EXCL_STOP */
}
EXTERN tdm_error
_pthread_mutex_lock(&private_display->lock);
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
TDM_WRN("output(%d) dpms: %s", private_output->pipe,
tdm_dpms_str(private_output->current_dpms_value));
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
+/* LCOV_EXCL_START */
EXTERN tdm_error
tdm_output_wait_vblank_add_front(tdm_output *output, int interval, int sync,
tdm_output_vblank_handler func, void *user_data)
_pthread_mutex_lock(&private_display->lock);
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
TDM_WRN("output(%d) dpms: %s", private_output->pipe,
tdm_dpms_str(private_output->current_dpms_value));
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
+/* LCOV_EXCL_STOP */
INTERN void
tdm_output_remove_vblank_handler_internal(tdm_output *output, tdm_output_vblank_handler func, void *user_data)
func_output = &private_display->func_output;
if (!func_output->output_commit) {
+ /* LCOV_EXCL_START */
TDM_ERR("not implemented!!");
return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
}
- /* TODO: this is ugly. But before using tdm_output_get_dpms_internal, we have
- * to check if all backends's DPMS operation has no problem.
- */
- if (private_display->commit_per_vblank)
- tdm_output_get_dpms_internal(output, &dpms_value);
- else
- dpms_value = private_output->current_dpms_value;
+ ret = tdm_output_get_dpms_internal(output, &dpms_value);
+ TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
- if (dpms_value == TDM_OUTPUT_DPMS_ON) {
+ if (!TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms_value)) {
if (func) {
if (!private_output->regist_commit_cb) {
private_output->regist_commit_cb = 1;
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 */
}
LIST_ADDTAIL(&output_commit_handler->link, &private_output->output_commit_handler_list);
private_layer->committed_buffer->buffer);
}
- if (dpms_value != TDM_OUTPUT_DPMS_ON) {
- TDM_WRN("TDM_OUTPUT_DPMS_OFF. Directly call commit handler instead of commit.");
+ 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)
func(output, 0, 0, 0, user_data);
}
return ret;
commit_failed:
+ /* LCOV_EXCL_START */
if (output_commit_handler) {
LIST_DEL(&output_commit_handler->link);
free(output_commit_handler);
}
return ret;
+ /* LCOV_EXCL_STOP */
}
EXTERN tdm_error
_pthread_mutex_lock(&private_display->lock);
- if (private_display->commit_type == TDM_COMMIT_TYPE_NONE)
- private_display->commit_type = TDM_COMMIT_TYPE_OUTPUT;
- else if (private_display->commit_type == TDM_COMMIT_TYPE_LAYER) {
+ if (private_output->commit_type == TDM_COMMIT_TYPE_NONE)
+ private_output->commit_type = TDM_COMMIT_TYPE_OUTPUT;
+ else if (private_output->commit_type == TDM_COMMIT_TYPE_LAYER) {
TDM_ERR("Can't supported. Use tdm_layer_commit");
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- if (private_display->commit_per_vblank) {
+ if (private_output->commit_per_vblank) {
TDM_ERR("Use tdm_layer_commit");
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) {
+ if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->current_dpms_value)) {
TDM_ERR("output(%d) dpms: %s", private_output->pipe,
tdm_dpms_str(private_output->current_dpms_value));
_pthread_mutex_unlock(&private_display->lock);
func_output = &private_display->func_output;
if (!func_output->output_set_mode) {
+ /* 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_set_mode(private_output->output_backend, mode);
- if (ret == TDM_ERROR_NONE)
+ if (ret == TDM_ERROR_NONE) {
private_output->current_mode = mode;
+ TDM_INFO("mode: %dx%d %dhz", mode->hdisplay, mode->vdisplay, mode->vrefresh);
+ }
+
_pthread_mutex_unlock(&private_display->lock);
return ret;
return TDM_ERROR_NONE;
}
+static tdm_error
+tdm_output_call_dpms_change_handler(tdm_output *output)
+{
+ tdm_private_output *private_output = (tdm_private_output*)output;
+ tdm_value value;
+
+ /** Use timer to call the output change callback of the sub-thread.
+ * The output change callback of tdm_server and tdm_vblank was called
+ * in the main thread. And it made the multi thread issue. If we use
+ * the timer, we can call the sub-thread's output change callback in
+ * sub-thread.
+ */
+ if (!private_output->dpms_changed_timer) {
+ private_output->dpms_changed_timer =
+ tdm_event_loop_add_timer_handler(private_output->private_display,
+ _tdm_output_dpms_changed_timeout, private_output, NULL);
+ if (!private_output->dpms_changed_timer) {
+ /* LCOV_EXCL_START */
+ TDM_ERR("can't create dpms timer!!");
+ return TDM_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+ }
+
+ value.u32 = private_output->current_dpms_value;
+ tdm_output_call_change_handler_internal(private_output,
+ &private_output->change_handler_list_main,
+ TDM_OUTPUT_CHANGE_DPMS,
+ value, 0);
+
+ if (!LIST_IS_EMPTY(&private_output->change_handler_list_sub)) {
+ tdm_error ret = tdm_event_loop_source_timer_update(private_output->dpms_changed_timer, 1);
+ if (ret != TDM_ERROR_NONE)
+ TDM_NEVER_GET_HERE();
+ }
+
+ return TDM_ERROR_NONE;
+}
+
+/* LCOV_EXCL_START */
INTERN void
tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
{
private_output->current_dpms_value = dpms;
private_output->waiting_dpms_change = 0;
- TDM_INFO("output(%d) dpms %s", private_output->pipe, tdm_dpms_str(dpms));
+ TDM_INFO("output(%d) dpms async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
value.u32 = dpms;
tdm_output_call_change_handler_internal(private_output,
TDM_OUTPUT_CHANGE_DPMS,
value, 0);
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
tdm_func_output *func_output;
OUTPUT_FUNC_ENTRY();
- if (dpms_value > TDM_OUTPUT_DPMS_OFF)
- dpms_value = TDM_OUTPUT_DPMS_OFF;
+ if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
+ if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
+ TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
+ TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
+ private_output->pipe, tdm_dpms_str(dpms_value));
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
_pthread_mutex_lock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- if (private_output->current_dpms_value == dpms_value) {
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
- }
-
- /** Use timer to call the output change callback of the sub-thread.
- * The output change callback of tdm_server and tdm_vblank was called
- * in the main thread. And it made the multi thread issue. If we use
- * the timer, we can call the sub-thread's output change callback in
- * sub-thread.
- */
- if (!private_output->dpms_changed_timer) {
- private_output->dpms_changed_timer =
- tdm_event_loop_add_timer_handler(private_output->private_display,
- _tdm_output_dpms_changed_timeout, private_output, NULL);
- if (!private_output->dpms_changed_timer) {
- TDM_ERR("can't create dpms timer!!");
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_OUT_OF_MEMORY;
- }
- }
-
func_output = &private_display->func_output;
+ 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 */
}
done:
if (ret == TDM_ERROR_NONE) {
- tdm_value value;
-
- private_output->current_dpms_value = dpms_value;
- TDM_INFO("output(%d) dpms %s", private_output->pipe, tdm_dpms_str(dpms_value));
+ if (private_output->current_dpms_value != dpms_value) {
+ private_output->current_dpms_value = dpms_value;
+ TDM_INFO("output(%d) dpms '%s' done", private_output->pipe, tdm_dpms_str(dpms_value));
+ tdm_output_call_dpms_change_handler(output);
+ }
+ } else {
+ tdm_output_dpms temp = TDM_OUTPUT_DPMS_OFF;
- value.u32 = dpms_value;
- tdm_output_call_change_handler_internal(private_output,
- &private_output->change_handler_list_main,
- TDM_OUTPUT_CHANGE_DPMS,
- value, 0);
+ /* update current_dpms_value forcely */
+ tdm_output_get_dpms_internal(output, &temp);
- if (!LIST_IS_EMPTY(&private_output->change_handler_list_sub)) {
- ret = tdm_event_loop_source_timer_update(private_output->dpms_changed_timer, 1);
- if (ret != TDM_ERROR_NONE)
- TDM_NEVER_GET_HERE();
- }
+ TDM_ERR("output(%d) set_dpms failed: dpms '%s'", private_output->pipe, tdm_dpms_str(temp));
}
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
+/* LCOV_EXCL_START */
EXTERN tdm_error
tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value)
{
return TDM_ERROR_BAD_REQUEST;
}
- if (dpms_value > TDM_OUTPUT_DPMS_OFF)
- dpms_value = TDM_OUTPUT_DPMS_OFF;
+ if (dpms_value > TDM_OUTPUT_DPMS_OFF) {
+ if (dpms_value & TDM_OUTPUT_DPMS_DEFAULT_MASK) {
+ TDM_ERR("Don't use the low-4bit for an extended DPMS mode: dpms_value(%x)", dpms_value);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS)) {
+ TDM_ERR("output(%d) doesn't support the extended DPMS control: '%s'",
+ private_output->pipe, tdm_dpms_str(dpms_value));
+ return TDM_ERROR_BAD_REQUEST;
+ }
+ }
_pthread_mutex_lock(&private_display->lock);
return TDM_ERROR_BAD_REQUEST;
}
- if (private_output->current_dpms_value == dpms_value) {
- _pthread_mutex_unlock(&private_display->lock);
- return TDM_ERROR_NONE;
- }
-
func_output = &private_display->func_output;
if (!func_output->output_set_dpms_handler) {
TDM_ERR("not implemented: output_set_dpms_handler");
}
}
+ 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 (ret == TDM_ERROR_NONE)
+ 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));
+ } 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));
+ }
_pthread_mutex_unlock(&private_display->lock);
return ret;
}
+/* LCOV_EXCL_STOP */
INTERN tdm_error
tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value)
TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ /* TODO: this is ugly. But before calling backend's output_get_dpms(), we have
+ * to check if all backends's DPMS operation has no problem. In future, we'd
+ * better use new env instead of using commit_per_vblank variable to distinguish
+ * whether we use the stored value or backend's output_get_dpms.
+ */
+ if (!private_output->commit_per_vblank) {
+ *dpms_value = private_output->current_dpms_value;
+ return TDM_ERROR_NONE;
+ }
+
func_output = &private_display->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 */
}
ret = func_output->output_get_dpms(private_output->output_backend, dpms_value);
if (ret != TDM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
TDM_ERR("output_get_dpms failed");
*dpms_value = TDM_OUTPUT_DPMS_OFF;
+ /* LCOV_EXCL_STOP */
}
- /* TODO: this is ugly. But we have to check if all backends's DPMS operation has no problem. */
- if (private_display->commit_per_vblank)
- if (*dpms_value != private_output->current_dpms_value) {
- private_output->current_dpms_value = *dpms_value;
- TDM_ERR("output(%d) dpms changed suddenly: %s",
- private_output->pipe, tdm_dpms_str(*dpms_value));
- }
+ /* checking with backend's value */
+ if (*dpms_value != private_output->current_dpms_value) {
+ TDM_ERR("output(%d) dpms changed suddenly: %s -> %s",
+ private_output->pipe, private_output->current_dpms_value,
+ tdm_dpms_str(*dpms_value));
+ private_output->current_dpms_value = *dpms_value;
+ tdm_output_call_dpms_change_handler(output);
+ }
return ret;
}
_pthread_mutex_lock(&private_display->lock);
- if (private_display->hwc_enable)
- hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, error);
- else
+ 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 */
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return hwc_window;
+}
+
+EXTERN tdm_hwc_window *
+tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error)
+{
+ tdm_hwc_window *hwc_window = 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);
if (error)
*error = TDM_ERROR_BAD_REQUEST;
+ /* LCOV_EXCL_STOP */
+ }
_pthread_mutex_unlock(&private_display->lock);
}
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();
_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;
+ }
+
func_output = &private_display->func_output;
if (!func_output->output_hwc_validate) {
+ /* LCOV_EXCL_START */
_pthread_mutex_unlock(&private_display->lock);
TDM_ERR("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;
+ }
+
+ 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_hwc_validate(private_output->output_backend, num_types);
+ 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);
_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;
+ }
+
/* there's no reason to allow this */
if (private_output->need_validate.hndl) {
_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;
+ }
+
func_output = &private_display->func_output;
if (!func_output->output_hwc_get_changed_composition_types) {
+ /* 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_get_changed_composition_types(private_output->output_backend,
num_elements, hwc_window, composition_types);
if (ret != TDM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
_pthread_mutex_unlock(&private_display->lock);
return ret;
+ /* LCOV_EXCL_STOP */
}
if (hwc_window == NULL || composition_types == NULL) {
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;
_pthread_mutex_unlock(&private_display->lock);
return TDM_ERROR_OPERATION_FAILED;
+ /* LCOV_EXCL_STOP */
}
hwc_window[i] = (tdm_hwc_window*)private_hwc_window;
_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;
+ }
+
func_output = &private_display->func_output;
if (!func_output->output_hwc_validate) {
+ /* 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_accept_changes(private_output->output_backend);
_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;
+ }
+
func_output = &private_display->func_output;
if (!func_output->output_hwc_get_target_buffer_queue) {
+ /* LCOV_EXCL_START */
_pthread_mutex_unlock(&private_display->lock);
TDM_ERR("not implemented!!");
return NULL;
+ /* LCOV_EXCL_STOP */
}
queue = func_output->output_hwc_get_target_buffer_queue(private_output->output_backend, error);
return queue;
}
-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;
-}
-
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;
_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 */
}
func_output = &private_display->func_output;
if (!func_output->output_hwc_set_client_target_buffer) {
+ /* LCOV_EXCL_START */
_pthread_mutex_unlock(&private_display->lock);
TDM_ERR("not implemented!!");
return TDM_ERROR_NOT_IMPLEMENTED;
+ /* LCOV_EXCL_STOP */
}
- /* dump buffer */
- if (tdm_dump_enable)
- _tdm_target_window_dump_buffer((tdm_private_output *)output, target_buffer);
-
ret = func_output->output_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, damage);
_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)
+{
+ 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);
+
+ _pthread_mutex_lock(&private_display->lock);
+
+ func_output = &private_display->func_output;
+
+ if (!func_output->output_hwc_get_video_supported_formats) {
+ /* 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_get_video_supported_formats(
+ private_output->output_backend, formats, count);
+
+ _pthread_mutex_unlock(&private_display->lock);
+
+ return ret;
+}
+
INTERN void
tdm_output_call_change_handler_internal(tdm_private_output *private_output,
struct list_head *change_handler_list,
}
}
+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;
TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
+ if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) {
+ TDM_ERR("output(%p) not support HWC", private_output);
+ return TDM_ERROR_BAD_REQUEST;
+ }
+
/* build in eventfd fds into event_loop listened & handled by the tdm-thread */
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;
return ret;
}
+
+INTERN tdm_error
+tdm_output_choose_commit_per_vblank_mode(tdm_private_output *private_output, int mode)
+{
+ if (!private_output)
+ return TDM_ERROR_INVALID_PARAMETER;
+
+ if (mode < 0 || mode > 2)
+ return TDM_ERROR_INVALID_PARAMETER;
+
+ private_output->commit_per_vblank = mode;
+
+ if (private_output->commit_per_vblank == 0)
+ TDM_INFO("commit per vblank: disable");
+ else if (private_output->commit_per_vblank == 1)
+ TDM_INFO("commit per vblank: enable (1 layer)");
+ else if (private_output->commit_per_vblank == 2)
+ TDM_INFO("commit per vblank: enable (previous commit)");
+
+ return TDM_ERROR_NONE;
+}