From bd4b00a9f0b9a11c189b87bcffb870ae53c70ecb Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 3 Mar 2017 17:20:36 +0900 Subject: [PATCH] output: call the output commit handler immediately when dpms off Change-Id: I33264947381669d3104c37c99f41b88b961b4c3f --- src/tdm_output.c | 69 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 3f077c2..8fa2fab 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -805,6 +805,7 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl tdm_func_output *func_output; tdm_private_output_commit_handler *output_commit_handler = NULL; tdm_private_layer *private_layer = NULL; + tdm_output_dpms dpms_value = TDM_OUTPUT_DPMS_ON; OUTPUT_FUNC_ENTRY(); @@ -815,33 +816,46 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl return TDM_ERROR_NOT_IMPLEMENTED; } - if (func) { - if (!private_output->regist_commit_cb) { - private_output->regist_commit_cb = 1; - 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); + if (!func_output->output_get_dpms) { + dpms_value = private_output->current_dpms_value; + } else { + ret = func_output->output_get_dpms(private_output->output_backend, &dpms_value); + if (ret != TDM_ERROR_NONE) { + TDM_ERR("output_get_dpms failed"); + dpms_value = TDM_OUTPUT_DPMS_OFF; } + } - 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; - } + if (dpms_value == TDM_OUTPUT_DPMS_ON) { + if (func) { + if (!private_output->regist_commit_cb) { + private_output->regist_commit_cb = 1; + 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); + } - 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); - } + 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; + } + + 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 = func_output->output_commit(private_output->output_backend, sync, - output_commit_handler); - TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed); + 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) - TDM_INFO("output(%d) backend commit: handle(%p)", private_output->pipe, output_commit_handler); + if (tdm_debug_module & TDM_DEBUG_COMMIT) + TDM_INFO("output(%d) backend commit: handle(%p) func(%p) user_data(%p)", + private_output->pipe, output_commit_handler, func, user_data); + } LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { if (!private_layer->waiting_buffer) @@ -855,6 +869,12 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl 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 (func) + func(output, 0, 0, 0, user_data); + } + return ret; commit_failed: @@ -1107,6 +1127,11 @@ tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value) ret = func_output->output_get_dpms(private_output->output_backend, dpms_value); + if (*dpms_value != private_output->current_dpms_value) { + private_output->current_dpms_value = *dpms_value; + TDM_WRN("current_dpms_value changed: %s", tdm_dpms_str(*dpms_value)); + } + _pthread_mutex_unlock(&private_display->lock); return ret; -- 2.7.4