tdm_virtual: support hwc mode
[platform/core/uifw/libtdm.git] / src / tdm_hwc.c
index 65f232c..f3537bc 100644 (file)
@@ -528,6 +528,8 @@ tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_d
        tdm_private_module *private_module;
        tdm_func_hwc *func_hwc = NULL;
        tdm_private_hwc_commit_handler *hwc_commit_handler = NULL;
+       tdm_private_voutput *private_voutput = NULL;
+       tdm_private_voutput_commit_handler *voutput_commit_handler = NULL;
 
        HWC_FUNC_ENTRY();
 
@@ -558,6 +560,14 @@ tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_d
        if (tdm_debug_module & TDM_DEBUG_COMMIT)
                TDM_INFO("hwc(%d) commit", private_hwc->index);
 
+       if (private_module == private_display->virtual_module) {
+               if (!private_output->private_voutput) {
+                       TDM_ERR("virtual module but don't have voutput");
+                       _pthread_mutex_unlock(&private_display->lock);
+                       return TDM_ERROR_BAD_MODULE;
+               }
+       }
+
        if (!private_hwc->regist_commit_cb) {
                private_hwc->regist_commit_cb = 1;
                ret = func_hwc->hwc_set_commit_handler(private_hwc->hwc_backend, _tdm_hwc_cb_commit);
@@ -595,6 +605,15 @@ tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_d
        hwc_commit_handler->user_data = user_data;
        hwc_commit_handler->owner_tid = syscall(SYS_gettid);
 
+       if (private_module == private_display->virtual_module) {
+               private_voutput = private_output->private_voutput;
+
+               if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) {
+                       voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link);
+                       voutput_commit_handler->user_data = private_hwc->display_target_buffer;
+               }
+       }
+
        ret = func_hwc->hwc_commit(private_hwc->hwc_backend, sync, hwc_commit_handler);
        TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed);