mmi-provider: add initial provider interface 05/264005/1
authorSung-Jin Park <sj76.park@samsung.com>
Mon, 5 Jul 2021 13:20:42 +0000 (22:20 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 11:23:30 +0000 (20:23 +0900)
Change-Id: I78aa6724835be3b4c7364272e6d5588cc8d70e99
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
packaging/mmi-manager.spec
src/meson.build
src/mmi-common.h [new file with mode: 0644]
src/mmi-manager-event-types.h [new file with mode: 0644]
src/mmi-provider-iface.h [new file with mode: 0644]
src/mmi-provider-interface.h [new file with mode: 0644]
src/mmi-provider.c

index 6eedf43..c71694d 100644 (file)
@@ -67,7 +67,7 @@ DESTDIR=%{buildroot} ninja -C builddir install
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %license COPYING
-%{_includedir}/mmi-manager.h
+%{_includedir}/mmi-*.h
 %{_libdir}/pkgconfig/*
 
 %files tests
index c0d399b..7b7dd0c 100644 (file)
@@ -11,13 +11,19 @@ mmi_manager_srcs = [
        'mmi-fusion.c',
        'mmi-provider.c',
        'mmi-fusion.h',
+       'mmi-common.h',
        'mmi-provider.h',
+       'mmi-provider-iface.h',
+       'mmi-manager-event-types.h',
        'interface/mmifw_stub.h',
-       'interface/mmifw_stub.c'
+       'interface/mmifw_stub.c',
        ]
 
 install_headers(
-       'mmi-manager.h'
+       'mmi-manager.h',
+       'mmi-common.h',
+       'mmi-manager-event-types.h',
+       'mmi-provider-iface.h'
        )
 
 glib_dep = dependency('glib-2.0')
diff --git a/src/mmi-common.h b/src/mmi-common.h
new file mode 100644 (file)
index 0000000..30f53a9
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_COMMON_H__
+#define __MMI_COMMON_H__
+
+typedef unsigned long long ull;
+
+typedef enum mmi_provider_op_mode
+{
+   MODALITY_PROVIDER_MODE_NONE,
+   MODALITY_PROVIDER_MODE_PROPAGATE_EVENT,
+   MODALITY_PROVIDER_MODE_KEEP_EVENT,
+   MODALITY_PROVIDER_MODE_DROP_EVENT,
+} mmi_provider_op_mode;
+
+typedef enum mmi_provider_capability
+{
+   MODALITY_PROVIDER_CAP_NONE = 0,
+   MODALITY_PROVIDER_CAP_KEY_EVENT = (1 << 0),
+   MODALITY_PROVIDER_CAP_MOUSE_EVENT = (1 << 1),
+   MODALITY_PROVIDER_CAP_TOUCH_EVENT = (1 << 2),
+   MODALITY_PROVIDER_CAP_GESTURE_EVENT = (1 << 3),
+   MODALITY_PROVIDER_CAP_VOICE_EVENT = (1 << 4),
+   MODALITY_PROVIDER_CAP_VISION_EVENT = (1 << 5),
+   MODALITY_PROVIDER_CAP_UNKNOWN = ((ull)1 << 62),
+   MODALITY_PROVIDER_CAP_MAX = ((ull)1 << 63)
+} mmi_provider_capability;
+
+typedef enum mmi_provider_result
+{
+   MODALITY_PROVIDER_RESULT_NONE,
+   MODALITY_PROVIDER_RESULT_FAIL,
+   MODALITY_PROVIDER_RESULT_SUCCESS
+} mmi_provider_result;
+
+typedef struct _mmi_provider_module_data mmi_provider_module_data;
+typedef struct _mmi_provider_module mmi_provider_module;
+typedef struct _mmi_provider_handle mmi_provider_handle;
+
+#endif //__MMI_COMMON_H__
diff --git a/src/mmi-manager-event-types.h b/src/mmi-manager-event-types.h
new file mode 100644 (file)
index 0000000..b47e005
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_MANAGER_EVENT_TYPES_H__
+#define __MMI_MANAGER_EVENT_TYPES_H__
+
+MMI_API extern int MMI_PROVIDER_EVENT_KEY;
+MMI_API extern int MMI_PROVIDER_EVENT_GESTURE;
+MMI_API extern int MMI_PROVIDER_EVENT_VOICE;
+MMI_API extern int MMI_PROVIDER_EVENT_VISION;
+
+typedef struct
+{
+   int type;//down or up
+   int timestamp;
+   void *user_data;
+   int duration;
+   double confidence;
+   int keycode;
+   bool key_down;
+   char *keyname;
+   char *source;//event source information
+} mmi_provider_event_key;
+
+typedef struct gesture_event
+{
+   int type;//swipe up, down, left, palm open, palm cover
+   int timestamp;
+   void *user_data;
+   int duration;
+   double confidence;
+   char *source;//event source information
+} mmi_provider_event_gesture;
+
+typedef struct
+{
+   int type;//play, pause, ..., yes, no
+   int timestamp;
+   void *user_data;
+   int duration;
+   double confidence;
+   char *cmd;
+   char **args;
+   int nargs;//num of args
+   char *source;//event source information
+} mmi_provider_event_voice;
+
+typedef struct
+{
+   int type;//leave, enter, move away, move closer
+   int timestamp;
+   void *user_data;
+   int duration;
+   double confidence;
+   char *cmd;
+   char **args;
+   int nargs;//num of args
+   char *source;//event source information
+} mmi_provider_event_vision;
+
+#endif //__MMI_MANAGER_EVENTS_TYPES_H__
diff --git a/src/mmi-provider-iface.h b/src/mmi-provider-iface.h
new file mode 100644 (file)
index 0000000..64f9f9f
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_PROVIDER_IFACE_H__
+#define __MMI_PROVIDER_IFACE_H__
+
+#include "mmi-common.h"
+
+#define MMI_PROVIDER_ABI_MAJOR_MASK     0xFFFF0000
+#define MMI_PROVIDER_ABI_MINOR_MASK     0x0000FFFF
+
+#define MMI_PROVIDER_GET_ABI_MAJOR(m)   (((m) & MMI_PROVIDER_ABI_MAJOR_MASK) >> 16)
+#define MMI_PROVIDER_GET_ABI_MINOR(m)   ((m) & MMI_PROVIDER_ABI_MINOR_MASK)
+
+#define MMI_PROVIDER_SET_ABI_VERSION(major, minor)      \
+                ((((major) << 16) & MMI_PROVIDER_ABI_MAJOR_MASK) \
+                 | ((minor) & MMI_PROVIDER_ABI_MINOR_MASK))
+
+#define MMI_PROVIDER_API __attribute__ ((visibility("default")))
+
+#ifndef bool
+typedef int bool;
+#endif
+
+struct _mmi_provider_module
+{
+   const char *name; /**< The name of a provider module */
+   const char *so_name; /**< The shared library name of a provider module */
+   const unsigned long long capabilities; /**< The capabilities provided by a provider module */
+   unsigned long abi_version; /**< The API version of a provider module */
+
+   mmi_provider_module_data *(*provider_init)(void);
+   void (*provider_deinit)(mmi_provider_module_data *provider_data);
+};
+
+struct _mmi_provider_handle
+{
+   mmi_provider_module module_info;
+   unsigned long long capabilities;
+   mmi_provider_op_mode op_mode;
+};
+
+struct _mmi_provider_module_data
+{
+   bool (*set_mode)(mmi_provider_op_mode mode);
+   mmi_provider_op_mode (*get_mode)(void);
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//APIs for providers
+int mmi_provider_register_caps(mmi_provider_handle provider, int caps);
+void *mmi_provider_alloc_event(int ev_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_PROVIDER_IFACE_H__
diff --git a/src/mmi-provider-interface.h b/src/mmi-provider-interface.h
new file mode 100644 (file)
index 0000000..487fa38
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_PROVIDER_INTERFACE_H__
+#define __MMI_PROVIDER_INTERFACE_H__
+
+#include "mmi-common.h"
+
+#define MMI_PROVIDER_ABI_MAJOR_MASK    0xFFFF0000
+#define MMI_PROVIDER_ABI_MINOR_MASK    0x0000FFFF
+
+#define MMI_PROVIDER_GET_ABI_MAJOR(m)  (((m) & MMI_PROVIDER_ABI_MAJOR_MASK) >> 16)
+#define MMI_PROVIDER_GET_ABI_MINOR(m)  ((m) & MMI_PROVIDER_ABI_MINOR_MASK)
+
+#define MMI_PROVIDER_SET_ABI_VERSION(major, minor)     \
+               ((((major) << 16) & MMI_PROVIDER_ABI_MAJOR_MASK) \
+                | ((minor) & MMI_PROVIDER_ABI_MINOR_MASK))
+
+#define MMI_PROVIDER_API __attribute__ ((visibility("default")))
+
+#ifndef bool
+typedef int bool;
+#endif
+
+typedef struct _mmi_provider_module_data mmi_provider_module_data;
+struct _mmi_provider_module_data
+{
+   bool (*set_mode)(mmi_provider_op_mode mode);
+   mmi_provider_op_mode (*get_mode)(void);
+};
+
+typedef struct _mmi_provider_module mmi_provider_module;
+struct _mmi_provider_module
+{
+   const char *name; /**< The name of a provider module */
+   const char *so_name; /**< The shared library name of a provider module */
+   const unsigned long long capabilities; /**< The capabilities provided by a provider module */
+   unsigned long abi_version; /**< The API version of a provider module */
+
+   mmi_provider_module_data *(*provider_init)(void);
+   void (*provider_deinit)(mmi_provider_module_data *provider_data);
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_PROVIDER_INTERFACE_H__
index 3c88d50..8cbba5a 100644 (file)
 * DEALINGS IN THE SOFTWARE.
 */
 
-#include "mmi-provider.h"
+#include "mmi-provider-iface.h"
+
+int
+mmi_provider_register_caps(mmi_provider_handle provider, int caps)
+{
+       (void) provider;
+       (void) caps;
+
+       return 0;
+}
+
+void *
+mmi_provider_alloc_event(int ev_type)
+{
+       (void) ev_type;
+
+       return (void *)0;
+}
 
 void
 modality_providers_init(void)
 {
+       //Lookup and init modality providers
 }
 
 void
 modality_providers_shutdown(void)
 {
-}
\ No newline at end of file
+       //Do shutdown for intialized providers
+}