From 7bb3c48979d29544276b671b545b2a9b593ff1c0 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Sat, 4 Mar 2017 23:09:47 +0900 Subject: [PATCH] layer: call the layer commit handlers once tdm_layer_commit returns success Once _tdm_layer_commit returns success, the layer commit handler MUST be called always. That is, even if we get error in _tdm_layer_got_output_vblank() function for some reasons, the layer commit handler MUST be called. Change-Id: Ia251061c965a9dec89ed655266bb23667a097e5e --- src/tdm_layer.c | 37 ++++++++++++++++++++++++++++++------- src/tdm_output.c | 3 +++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/tdm_layer.c b/src/tdm_layer.c index d677f16..f127664 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -568,13 +568,15 @@ _tdm_layer_got_output_vblank(tdm_private_output *private_output, unsigned int se if (tdm_debug_module & TDM_DEBUG_COMMIT) TDM_INFO("layer commit: output(%d) commit", private_output->pipe); - /* tdm_vblank APIs is for server. it should be called in unlock status*/ - if (!private_output->layer_waiting_vblank) { - _pthread_mutex_unlock(&private_display->lock); - ret = tdm_vblank_wait(private_output->vblank, 0, 0, 1, _tdm_layer_cb_wait_vblank, private_output); - _pthread_mutex_lock(&private_display->lock); - TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); - private_output->layer_waiting_vblank = 1; + if (private_output->current_dpms_value == TDM_OUTPUT_DPMS_ON) { + /* tdm_vblank APIs is for server. it should be called in unlock status*/ + if (!private_output->layer_waiting_vblank) { + _pthread_mutex_unlock(&private_display->lock); + ret = tdm_vblank_wait(private_output->vblank, 0, 0, 1, _tdm_layer_cb_wait_vblank, private_output); + _pthread_mutex_lock(&private_display->lock); + TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); + private_output->layer_waiting_vblank = 1; + } } if (tdm_debug_module & TDM_DEBUG_COMMIT) @@ -585,13 +587,30 @@ _tdm_layer_got_output_vblank(tdm_private_output *private_output, unsigned int se LIST_ADDTAIL(&lm->link, &private_output->layer_commit_handler_list); } + if (private_output->current_dpms_value != TDM_OUTPUT_DPMS_ON) { + TDM_WRN("TDM_OUTPUT_DPMS_OFF. Directly call vblank callback."); + _pthread_mutex_unlock(&private_display->lock); + _tdm_layer_cb_wait_vblank(private_output->vblank, 0, 0, 0, 0, private_output); + _pthread_mutex_lock(&private_display->lock); + } + return; wait_failed: + /* CAUTION: Once _tdm_layer_commit returns success, the layer commit handler MUST be called always. + * That is, even if we get error in _tdm_layer_got_output_vblank() function for some reasons, + * the layer commit handler MUST be called. + */ LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &pending_clone_list, link) { + TDM_WRN("Directly call layer commit handlers: ret(%d)\n", ret); LIST_DEL(&lm->link); + _pthread_mutex_unlock(&private_display->lock); + if (lm->func) + lm->func(lm->private_layer, sequence, tv_sec, tv_usec, lm->user_data); + _pthread_mutex_lock(&private_display->lock); _tdm_layer_free_buffer(lm->private_layer, lm->committed_buffer); free(lm); } + return; } @@ -699,6 +718,10 @@ _tdm_layer_commit_possible(tdm_private_layer *private_layer) return 0; } +/* CAUTION: Once _tdm_layer_commit returns success, the layer commit handler MUST be called always. + * That is, even if we get error in _tdm_layer_got_output_vblank() function for some reasons, + * the layer commit handler MUST be called. + */ static tdm_error _tdm_layer_commit(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data) { diff --git a/src/tdm_output.c b/src/tdm_output.c index 6b83f36..7654873 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -849,6 +849,9 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl private_output->pipe, output_commit_handler, func, user_data); } + /* Even if DPMS is off, committed_buffer should be changed because it will be referred + * for tdm_layer_committed() function. + */ LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { if (!private_layer->waiting_buffer) continue; -- 2.7.4