output: call the output commit handler immediately when dpms off 32/117232/2
authorBoram Park <boram1288.park@samsung.com>
Fri, 3 Mar 2017 08:20:36 +0000 (17:20 +0900)
committerBoram Park <boram1288.park@samsung.com>
Fri, 3 Mar 2017 10:46:37 +0000 (19:46 +0900)
Change-Id: I33264947381669d3104c37c99f41b88b961b4c3f

src/tdm_output.c

index 3f077c2..8fa2fab 100644 (file)
@@ -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;