add eom wayland protocol output add / remove 19/210919/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 26 Jul 2019 02:57:49 +0000 (11:57 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 26 Jul 2019 09:12:47 +0000 (18:12 +0900)
add new api for supporting tdm voutput.
tdm virtual output can be created and destroyed.
so eom have to check the virtual output creation and destruction.

Change-Id: Ibf2115c10f69231d1b7314d393a9d38609c9654f
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
protocol/eom.xml
src/eom-wayland.c
src/eom.c

index 2492452..6d33389 100644 (file)
       <arg name="error" type="uint"/>
     </event>
 
+    <event name="output_add">
+      <description summary="output add info">
+        Send information of output add.
+      </description>
+      <arg name="output_id" type="uint"/>
+    </event>
+
+    <event name="output_remove">
+      <description summary="output remove info">
+        Send information of output remove.
+      </description>
+      <arg name="output_id" type="uint"/>
+    </event>
   </interface>
 
 </protocol>
index 1f18d56..f8bfe2e 100644 (file)
@@ -692,7 +692,46 @@ _eom_wl_eom_output_set_window(void *data,
        eom_wl_output->error = error;
 }
 
+static void
+_eom_wl_eom_output_add(void *data,
+                       struct wl_eom *wl_eom,
+                       uint32_t output_id)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       INFO("OUTPUT ADD - %d", output_id);
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
+               &eom_client_info->eom_wl_output_list, output_id);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_ADD);
+}
+
+static void
+_eom_wl_eom_output_remove(void *data,
+                       struct wl_eom *wl_eom,
+                       uint32_t output_id)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *)data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       INFO("OUTPUT REMOVE - %d", output_id);
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(
+               &eom_client_info->eom_wl_output_list, output_id);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       wl_list_remove(&eom_wl_output->link);
+
+       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_REMOVE);
+
+       free(eom_wl_output);
+       eom_wl_output = NULL;
+}
 /*LCOV_EXCL_STOP*/
+
 static const struct wl_eom_listener eom_wl_eom_listener = {
        _eom_wl_eom_output_count,
        _eom_wl_eom_output_info,
@@ -700,6 +739,8 @@ static const struct wl_eom_listener eom_wl_eom_listener = {
        _eom_wl_eom_output_mode,
        _eom_wl_eom_output_attribute,
        _eom_wl_eom_output_set_window,
+       _eom_wl_eom_output_add,
+       _eom_wl_eom_output_remove,
 };
 
 static void
index 300e249..69cd0b6 100644 (file)
--- a/src/eom.c
+++ b/src/eom.c
@@ -278,6 +278,106 @@ _eom_reset_output_info(eom_output_info *output_info)
        output_info->mm_height = 0;
 }
 
+static eom_output_id *
+_eom_get_eom_output_ids(int *count)
+{
+       GArray *ret_array = NULL;
+       eom_output_id *output_ids = NULL;
+       int i;
+
+       ret_array = eom_wayland_client_get_output_ids();
+
+       if (!ret_array)
+               return NULL;
+
+       if (ret_array->len == 0)
+               goto done;
+
+       output_ids = calloc(ret_array->len, sizeof(eom_output_id));
+       if (output_ids == NULL) {
+               ERR("alloc fail");
+               goto done;
+       }
+
+       *count = ret_array->len;
+       for (i = 0; i < ret_array->len; i++) {
+               GValue *v = &g_array_index(ret_array, GValue, i);
+
+               output_ids[i] = g_value_get_int(v);
+               INFO("output_ids: %d", output_ids[i]);
+       }
+
+       return output_ids;
+
+done:
+       g_array_free(ret_array, FALSE);
+       return NULL;
+}
+
+static void
+_eom_update_output_info_list()
+{
+       GArray *ret_array = NULL;
+       eom_output_id *output_ids = NULL;
+       int i, count;
+
+       output_ids = _eom_get_eom_output_ids(&count);
+       RET_IF_FAIL(output_ids != NULL);
+
+       /* TODO: redesign the life-cycle of output_infos */
+       for (i = 0; i < count; i++) {
+               /* add output_info to output_info_list */
+               eom_output_info *output_info;
+               eom_output_id output_id = output_ids[i];
+
+               output_info = _eom_find_output_info(output_id);
+               if (output_info)
+                       continue;
+
+               ret_array = eom_wayland_client_get_output_info(output_id);
+               if (ret_array) {
+               /*
+                 * 0:output_id, 1:output_type, 2:output_mode,
+                 * 3:w, 4:h, 5:w_mm, 6:h_mm, 7:attribute
+                 */
+                       output_info = _eom_alloc_output_info(
+                               g_value_get_int(&g_array_index(
+                                       ret_array, GValue, 0)),
+                               g_value_get_int(&g_array_index(
+                                       ret_array, GValue, 1)));
+                       if (output_info) {
+                               output_info_list = g_list_append(
+                                       output_info_list, output_info);
+                               _eom_set_output_info_mode(output_info,
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 2)));
+                               _eom_set_output_info_size(output_info,
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 3)),
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 4)));
+                               _eom_set_output_info_phy_size(output_info,
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 5)),
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 6)));
+                               _eom_set_output_attribute(output_info,
+                                       g_value_get_int(&g_array_index(
+                                               ret_array, GValue, 7)));
+                               INFO("GetOutputInfo: %s(%d)",
+                                       TYPE(output_info->type),
+                                               output_info->id);
+                       }
+
+                       g_array_free(ret_array, FALSE);
+                       ret_array = NULL;
+               } else
+                       ERR("fail: get id(%d)'s information", output_id);
+       }
+
+       free(output_ids);
+}
+
 static void
 _eom_output_call_notify_cb(eom_output_notify_s *notify)
 {
@@ -385,7 +485,14 @@ _eom_output_process_notify_cb(void *data, GArray *array)
        _eom_mutex_lock();
 
        output_info = _eom_find_output_info(output_id);
-       GOTO_IF_FAIL(output_info != NULL, exit);
+       if (output_info == NULL) {
+               if (notify_type == EOM_OUTPUT_NOTIFY_ADD) {
+                       _eom_update_output_info_list();
+                       output_info = _eom_find_output_info(output_id);
+               }
+
+               GOTO_IF_FAIL(output_info != NULL, exit);
+       }
 
        switch (notify_type) {
        case EOM_OUTPUT_NOTIFY_ADD:
@@ -578,9 +685,7 @@ eom_deinit(void)
 API eom_output_id*
 eom_get_eom_output_ids(int *count)
 {
-       GArray *ret_array = NULL;
        eom_output_id *output_ids = NULL;
-       int i;
 
        if (!count) {
                set_last_result(EOM_ERROR_INVALID_PARAMETER);
@@ -589,106 +694,14 @@ eom_get_eom_output_ids(int *count)
 
        _eom_mutex_lock();
 
-       ret_array = eom_wayland_client_get_output_ids();
-
-       if (!ret_array) {
-               *count = 0;
-               _eom_mutex_unlock();
-               set_last_result(EOM_ERROR_NONE);
-               return NULL;
-       }
-/*LCOV_EXCL_START*/
-       if (ret_array->len == 0) {
-               g_array_free(ret_array, FALSE);
-               *count = 0;
-               _eom_mutex_unlock();
-               set_last_result(EOM_ERROR_NONE);
-               return NULL;
-       }
-
-       output_ids = calloc(ret_array->len, sizeof(eom_output_id));
-       GOTO_IF_FAIL(output_ids != NULL, fail);
-
-       *count = ret_array->len;
-       for (i = 0; i < ret_array->len; i++) {
-               GValue *v = &g_array_index(ret_array, GValue, i);
-
-               output_ids[i] = g_value_get_int(v);
-               INFO("output_ids: %d", output_ids[i]);
-       }
-
-       g_array_free(ret_array, FALSE);
-       ret_array = NULL;
-
-       /* TODO: redesign the life-cycle of output_infos */
-       for (i = 0; i < *count; i++) {
-               /* add output_info to output_info_list */
-               eom_output_info *output_info;
-               eom_output_id output_id = output_ids[i];
-
-               output_info = _eom_find_output_info(output_id);
-               if (output_info)
-                       continue;
-
-               ret_array = eom_wayland_client_get_output_info(output_id);
-               if (ret_array) {
-               /*
-                 * 0:output_id, 1:output_type, 2:output_mode,
-                 * 3:w, 4:h, 5:w_mm, 6:h_mm, 7:attribute
-                 */
-                       output_info = _eom_alloc_output_info(
-                               g_value_get_int(&g_array_index(
-                                       ret_array, GValue, 0)),
-                               g_value_get_int(&g_array_index(
-                                       ret_array, GValue, 1)));
-                       if (output_info) {
-                               output_info_list = g_list_append(
-                                       output_info_list, output_info);
-                               _eom_set_output_info_mode(output_info,
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 2)));
-                               _eom_set_output_info_size(output_info,
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 3)),
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 4)));
-                               _eom_set_output_info_phy_size(output_info,
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 5)),
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 6)));
-                               _eom_set_output_attribute(output_info,
-                                       g_value_get_int(&g_array_index(
-                                               ret_array, GValue, 7)));
-                               INFO("GetOutputInfo: %s(%d)",
-                                       TYPE(output_info->type),
-                                               output_info->id);
-                       }
-
-                       g_array_free(ret_array, FALSE);
-                       ret_array = NULL;
-               } else
-                       ERR("fail: get id(%d)'s information", output_id);
-       }
+       output_ids = _eom_get_eom_output_ids(count);
+       _eom_update_output_info_list();
 
        _eom_mutex_unlock();
 
        set_last_result(EOM_ERROR_NONE);
 
        return output_ids;
-
-fail:
-       if (ret_array)
-               g_array_free(ret_array, FALSE);
-
-       *count = 0;
-
-       _eom_mutex_unlock();
-
-       set_last_result(EOM_ERROR_OUT_OF_MEMORY);
-
-       return NULL;
-/*LCOV_EXCL_STOP*/
 }
 
 API int