Revert "Revert "output: seperate output-status and output-dpms change"" 71/172771/1
authorBoram Park <boram1288.park@samsung.com>
Fri, 16 Mar 2018 00:17:07 +0000 (09:17 +0900)
committerBoram Park <boram1288.park@samsung.com>
Fri, 16 Mar 2018 01:19:36 +0000 (10:19 +0900)
This reverts commit 3dab774282940b13db1792b57deaf50109d9d5e3.

Change-Id: I64aec7755e0822b85b28e420b4fd2727b6763e51

src/tdm.c
src/tdm_macro.h
src/tdm_output.c
src/tdm_private_types.h
src/tdm_thread.c

index c17e9fc16dbf27677ed3b51b024cd3eb4c089087..42387fd0072d02957b8f7043b82557a5abbd827a 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -198,7 +198,8 @@ _tdm_display_destroy_private_output(tdm_private_output *private_output)
 
        LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list, link) {
                LIST_DEL(&h->link);
-               tdm_thread_cb_remove(h->private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, h);
+               tdm_thread_cb_remove(h->private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, h);
+               tdm_thread_cb_remove(h->private_output, TDM_THREAD_CB_OUTPUT_STATUS, NULL, tdm_output_thread_cb_change, h);
                free(h);
        }
 
index 45bde6518aac3e2f5082f5b2eb169c1e7edc11cf..acdc9f30d50d40119da0aec7ab2fa42331e5c2d4 100644 (file)
@@ -244,7 +244,8 @@ static struct tdm_type_name tdm_cb_type_names[] = {
        { TDM_THREAD_CB_NONE, "none" },
        { TDM_THREAD_CB_OUTPUT_COMMIT, "output-commit" },
        { TDM_THREAD_CB_OUTPUT_VBLANK, "output-vblank" },
-       { TDM_THREAD_CB_OUTPUT_CHANGE, "output-change" },
+       { TDM_THREAD_CB_OUTPUT_STATUS, "output-status" },
+       { TDM_THREAD_CB_OUTPUT_DPMS, "output-dpms" },
        { TDM_THREAD_CB_PP_DONE, "pp-done" },
        { TDM_THREAD_CB_CAPTURE_DONE, "capture-done" },
        { TDM_THREAD_CB_VBLANK_SW, "vblank-sw" },
index b87da848dad11e17233e45f94f5c62a848e1a7e1..652e26257ab01754fd1329f3932b5d0c2b498a16 100644 (file)
@@ -146,7 +146,9 @@ tdm_output_init(tdm_private_display *private_display)
 {
        tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_COMMIT, tdm_display_find_output_stamp);
        tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_VBLANK, tdm_display_find_output_stamp);
-       tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_CHANGE, tdm_display_find_output_stamp);
+       tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_STATUS, tdm_display_find_output_stamp);
+       tdm_thread_cb_set_find_func(TDM_THREAD_CB_OUTPUT_DPMS, tdm_display_find_output_stamp);
+
 
        return TDM_ERROR_NONE;
 }
@@ -226,34 +228,68 @@ INTERN void
 tdm_output_thread_cb_change(tdm_private_display *private_display, void *object, tdm_thread_cb_base *cb_base, void *user_data)
 {
        tdm_private_output *private_output = object;
-       tdm_thread_cb_output_change *output_change = (tdm_thread_cb_output_change *)cb_base;
        tdm_private_output_change_handler *change_handler = user_data;
+       tdm_output_change_type type = TDM_OUTPUT_CHANGE_CONNECTION;
+       tdm_value value = {.u32 = 0 };
 
        TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
 
        assert(change_handler->owner_tid == syscall(SYS_gettid));
 
+       if (cb_base->type == TDM_THREAD_CB_OUTPUT_STATUS) {
+               tdm_thread_cb_output_status *output_status = (tdm_thread_cb_output_status *)cb_base;
+               type = TDM_OUTPUT_CHANGE_CONNECTION;
+               value.u32 = output_status->status;
+       } else if (cb_base->type == TDM_THREAD_CB_OUTPUT_DPMS) {
+               tdm_thread_cb_output_dpms *output_dpms = (tdm_thread_cb_output_dpms *)cb_base;
+               type = TDM_OUTPUT_CHANGE_DPMS;
+               value.u32 = output_dpms->dpms;
+       } else {
+               TDM_NEVER_GET_HERE();
+               return;
+       }
+
        _pthread_mutex_unlock(&private_display->lock);
-       change_handler->func(private_output, output_change->type, output_change->value, change_handler->user_data);
+       change_handler->func(private_output, type, value, change_handler->user_data);
        _pthread_mutex_lock(&private_display->lock);
+
 }
 
 static tdm_error
-_tdm_output_call_thread_cb_change(tdm_private_output *private_output, tdm_output_change_type type, tdm_value value)
+_tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output_conn_status status)
 {
-       tdm_thread_cb_output_change output_change;
+       tdm_thread_cb_output_status output_status;
        tdm_error ret;
 
-       memset(&output_change, 0, sizeof output_change);
-       output_change.base.type = TDM_THREAD_CB_OUTPUT_CHANGE;
-       output_change.base.length = sizeof output_change;
-       output_change.base.object_stamp = private_output->stamp;
-       output_change.base.data = NULL;
-       output_change.base.sync = 1;
-       output_change.type = type;
-       output_change.value = value;
+       memset(&output_status, 0, sizeof output_status);
+       output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS;
+       output_status.base.length = sizeof output_status;
+       output_status.base.object_stamp = private_output->stamp;
+       output_status.base.data = NULL;
+       output_status.base.sync = 1;
+       output_status.status = status;
 
-       ret = tdm_thread_cb_call(private_output, &output_change.base);
+       ret = tdm_thread_cb_call(private_output, &output_status.base);
+       TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+
+       return TDM_ERROR_NONE;
+}
+
+static tdm_error
+_tdm_output_call_thread_cb_dpms(tdm_private_output *private_output, tdm_output_dpms dpms)
+{
+       tdm_thread_cb_output_dpms output_dpms;
+       tdm_error ret;
+
+       memset(&output_dpms, 0, sizeof output_dpms);
+       output_dpms.base.type = TDM_THREAD_CB_OUTPUT_DPMS;
+       output_dpms.base.length = sizeof output_dpms;
+       output_dpms.base.object_stamp = private_output->stamp;
+       output_dpms.base.data = NULL;
+       output_dpms.base.sync = 0;
+       output_dpms.dpms = dpms;
+
+       ret = tdm_thread_cb_call(private_output, &output_dpms.base);
        TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
 
        return TDM_ERROR_NONE;
@@ -263,7 +299,6 @@ INTERN void
 tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, void *user_data)
 {
        tdm_private_output *private_output = user_data;
-       tdm_value value;
        tdm_error ret;
 
        TDM_RETURN_IF_FAIL(private_output);
@@ -278,9 +313,7 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status,
                private_output->caps.status = status;
        }
 
-       value.u32 = status;
-
-       ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_CONNECTION, value);
+       ret = _tdm_output_call_thread_cb_status(private_output, status);
        TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
 }
 
@@ -288,7 +321,6 @@ INTERN void
 tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
 {
        tdm_private_output *private_output = user_data;
-       tdm_value value;
        tdm_error ret;
 
        TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(dpms));
@@ -297,9 +329,7 @@ tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_
        private_output->waiting_dpms_change = 0;
        TDM_INFO("output(%d) dpms async '%s' done", private_output->pipe, tdm_dpms_str(dpms));
 
-       value.u32 = dpms;
-
-       ret = _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+       ret = _tdm_output_call_thread_cb_dpms(private_output, dpms);
        TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
 }
 
@@ -332,10 +362,21 @@ tdm_output_add_change_handler(tdm_output *output,
                /* LCOV_EXCL_STOP */
        }
 
-       ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
+       ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
+       if (ret != TDM_ERROR_NONE) {
+               /* LCOV_EXCL_START */
+               TDM_ERR("tdm_thread_cb_add failed");
+               free(change_handler);
+               _pthread_mutex_unlock(&private_display->lock);
+               return TDM_ERROR_OPERATION_FAILED;
+               /* LCOV_EXCL_STOP */
+       }
+
+       ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_STATUS, NULL, tdm_output_thread_cb_change, change_handler);
        if (ret != TDM_ERROR_NONE) {
                /* LCOV_EXCL_START */
                TDM_ERR("tdm_thread_cb_add failed");
+               tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
                free(change_handler);
                _pthread_mutex_unlock(&private_display->lock);
                return TDM_ERROR_OPERATION_FAILED;
@@ -375,7 +416,8 @@ tdm_output_remove_change_handler(tdm_output *output,
                if (change_handler->func != func || change_handler->user_data != user_data)
                        continue;
 
-               tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, change_handler);
+               tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_DPMS, NULL, tdm_output_thread_cb_change, change_handler);
+               tdm_thread_cb_remove(private_output, TDM_THREAD_CB_OUTPUT_STATUS, NULL, tdm_output_thread_cb_change, change_handler);
 
                LIST_DEL(&change_handler->link);
                free(change_handler);
@@ -1302,10 +1344,8 @@ tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
 done:
        if (ret == TDM_ERROR_NONE) {
                if (private_output->current_dpms_value != dpms_value) {
-                       tdm_value value;
                        private_output->current_dpms_value = dpms_value;
-                       value.u32 = dpms_value;
-                       _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+                       _tdm_output_call_thread_cb_dpms(private_output, dpms_value);
                        TDM_INFO("output(%d) dpms '%s' done", private_output->pipe, tdm_dpms_str(dpms_value));
                }
        } else {
@@ -1446,13 +1486,11 @@ tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value)
 
        /* checking with backend's value */
        if (*dpms_value != private_output->current_dpms_value) {
-               tdm_value value;
                TDM_ERR("output(%d) dpms changed suddenly: %s -> %s",
                                private_output->pipe, tdm_dpms_str(private_output->current_dpms_value),
                                tdm_dpms_str(*dpms_value));
                private_output->current_dpms_value = *dpms_value;
-               value.u32 = *dpms_value;
-               _tdm_output_call_thread_cb_change(private_output, TDM_OUTPUT_CHANGE_DPMS, value);
+               _tdm_output_call_thread_cb_dpms(private_output, *dpms_value);
        }
 
        return ret;
index d1c132dd5d2336225946a9d5d984e6b7e4e05b43..a5b44233456d9ba0ff77032a20c6c1670da200c2 100644 (file)
@@ -449,7 +449,8 @@ typedef enum {
        TDM_THREAD_CB_NONE,
        TDM_THREAD_CB_OUTPUT_COMMIT,
        TDM_THREAD_CB_OUTPUT_VBLANK,
-       TDM_THREAD_CB_OUTPUT_CHANGE,
+       TDM_THREAD_CB_OUTPUT_STATUS,
+       TDM_THREAD_CB_OUTPUT_DPMS,
        TDM_THREAD_CB_PP_DONE,
        TDM_THREAD_CB_CAPTURE_DONE,
        TDM_THREAD_CB_VBLANK_SW,
@@ -461,7 +462,8 @@ typedef enum {
 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
-typedef struct _tdm_thread_cb_output_change tdm_thread_cb_output_change;
+typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
+typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
@@ -483,10 +485,14 @@ struct _tdm_thread_cb_output_vblank {
        unsigned int tv_usec;
 };
 
-struct _tdm_thread_cb_output_change {
+struct _tdm_thread_cb_output_status {
        tdm_thread_cb_base base;
-       tdm_output_change_type type;
-       tdm_value value;
+       tdm_output_conn_status status;
+};
+
+struct _tdm_thread_cb_output_dpms {
+       tdm_thread_cb_base base;
+       tdm_output_dpms dpms;
 };
 
 struct _tdm_thread_cb_pp_done {
index ff8c238283f894d48969f620f8af890e79c1fc00..6e891d7ea6e8b3f65c75dd184e719307873e039c 100644 (file)
@@ -432,7 +432,8 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop)
                switch (base->type) {
                case TDM_THREAD_CB_OUTPUT_COMMIT:
                case TDM_THREAD_CB_OUTPUT_VBLANK:
-               case TDM_THREAD_CB_OUTPUT_CHANGE:
+               case TDM_THREAD_CB_OUTPUT_STATUS:
+               case TDM_THREAD_CB_OUTPUT_DPMS:
                case TDM_THREAD_CB_PP_DONE:
                case TDM_THREAD_CB_CAPTURE_DONE:
                case TDM_THREAD_CB_VBLANK_SW:
@@ -609,16 +610,18 @@ tdm_thread_cb_call(void *object, tdm_thread_cb_base *cb_base)
        TDM_RETURN_VAL_IF_FAIL(cb_base != NULL, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(cb_base->type > 0, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(cb_base->length > 0, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(cb_base->sync == 0 || cb_base->sync == 1, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(cb_base->object_stamp > 0, TDM_ERROR_INVALID_PARAMETER);
 
        caller_tid = syscall(SYS_gettid);
 
        assert(find_funcs[cb_base->type] != NULL);
 
-       /* When there is the previous waiting sync call, the other type sync call CAN't be handlered */
-       if (waiting_tid > 0 && cb_base->sync == 1)
-               assert(waiting_cb_type == cb_base->type);
+       /* handling only output-status as sync */
+       if (cb_base->type == TDM_THREAD_CB_OUTPUT_STATUS) {
+               TDM_RETURN_VAL_IF_FAIL(cb_base->sync == 1, TDM_ERROR_INVALID_PARAMETER);
+       } else {
+               TDM_RETURN_VAL_IF_FAIL(cb_base->sync == 0, TDM_ERROR_INVALID_PARAMETER);
+       }
 
        if (!object) {
                object = find_funcs[cb_base->type](private_display, cb_base->object_stamp);