device-input: Apply HAL ABI versioning rule 65/309965/2
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 18 Apr 2024 10:20:23 +0000 (19:20 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 04:35:09 +0000 (13:35 +0900)
In HAL-API-[module], source file name should follow hal-api-[module].c format
for applying HAL ABI versioning.

hal-api-device-input.c
 -> HAL-INTERFACE Wrapper call according to major version and implemenation of
    functions declared in hal-device-external_connection.h

To apply HAL ABI versioning, the backend function structure memory allocation part
was moved to hal-api-device-input.

Furthermore, existing interface file is devided.
Below is a description of the purpose of header files.

hal-device-input-types.h
 -> Common data types like structures or enums used between the device-input
    HAL-API and HAL-BACKEND
hal-device-input-interface-1.h
 -> Declaration of functions to be implemented in the device-input HAL-BACKEND(Major version 1),
    as well as definitions of data structures used between the HAL-API and HAL-BACKEND(Major version 1)
hal-device-input-interface.h
 -> Includes the hal-device-input-interface-[major].h files for each supported
    major version.
hal-device-input.h
 -> Declaration of the device-input HAL-API functions

As applying HAL ABI versioning, definitions are also chaged in Native API style.

Change-Id: I0255a683c22eeb89988c2c56fbeb122140043e1f
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
include/hal-device-input-interface-1.h [new file with mode: 0644]
include/hal-device-input-interface.h
include/hal-device-input-types.h [new file with mode: 0644]
src/hal-api-device-input.c [new file with mode: 0644]
src/input.c [deleted file]

diff --git a/include/hal-device-input-interface-1.h b/include/hal-device-input-interface-1.h
new file mode 100644 (file)
index 0000000..639c160
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HAL_DEVICE_INPUT_INTERFACE_H__
+#define __HAL_DEVICE_INPUT_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _hal_backend_device_input_funcs {
+       /* Control input device event */
+       int (*set_event_state)(int input_device_id, int on);
+       int (*get_event_state)(int input_device_id, int* on);
+} hal_backend_device_input_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_INPUT_INTERFACE_H__ */
index c67dca04199e7cc42bc5ed58c2193f73b435bfe1..3b94e34525af7b15238391984faf6c5c3b0ee590 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __HAL_DEVICE_INPUT_INTERFACE_H__
-#define __HAL_DEVICE_INPUT_INTERFACE_H__
+#ifndef __HAL_DEVICE_INPUT_INTERFACE_1_H__
+#define __HAL_DEVICE_INPUT_INTERFACE_1_H__
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "hal-device-input-types.h"
+#include "hal-device-input-interface-1.h"
 
-typedef enum {
-       HAL_DEVICE_INPUT_TYPE_UNKNOWN = 0, /**< Input device type which is not defined. */
-       HAL_DEVICE_INPUT_TYPE_ALL, /**< Input device type which is all kinds of input devices */
-       HAL_DEVICE_INPUT_TYPE_MOUSE, /**< Input device type which is mouse-type */
-       HAL_DEVICE_INPUT_TYPE_KEYBOARD, /**< Input device type which is keyboard-type */
-       HAL_DEVICE_INPUT_TYPE_TOUCHSCREEN, /**< Input device type which is touchscreen-type */
-
-       HAL_DEVICE_INPUT_TYPE_CUSTOM_KNOB = 1000, /**< Input device type which is customed knob-type */
-} hal_device_input_type;
-
-typedef struct _hal_backend_device_input_funcs {
-       /* Control input device event */
-       int (*set_event_state)(int input_device_id, int on);
-       int (*get_event_state)(int input_device_id, int* on);
-} hal_backend_device_input_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __HAL_DEVICE_INPUT_INTERFACE_H__ */
+#endif /* __HAL_DEVICE_INPUT_INTERFACE_1_H__ */
diff --git a/include/hal-device-input-types.h b/include/hal-device-input-types.h
new file mode 100644 (file)
index 0000000..9f80464
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HAL_DEVICE_INPUT_TYPES_H__
+#define __HAL_DEVICE_INPUT_TYPES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enumeration for the type of input devices
+ * @since HAL_MODULE_DEVICE_INPUT 1.0
+ */
+typedef enum {
+       HAL_DEVICE_INPUT_TYPE_UNKNOWN = 0, /**< Input device type which is not defined. */
+       HAL_DEVICE_INPUT_TYPE_ALL, /**< Input device type which is all kinds of input devices */
+       HAL_DEVICE_INPUT_TYPE_MOUSE, /**< Input device type which is mouse-type */
+       HAL_DEVICE_INPUT_TYPE_KEYBOARD, /**< Input device type which is keyboard-type */
+       HAL_DEVICE_INPUT_TYPE_TOUCHSCREEN, /**< Input device type which is touchscreen-type */
+
+       HAL_DEVICE_INPUT_TYPE_CUSTOM_KNOB = 1000, /**< Input device type which is customed knob-type */
+} hal_device_input_type_e;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_INPUT_TYPES_H__ */
diff --git a/src/hal-api-device-input.c b/src/hal-api-device-input.c
new file mode 100644 (file)
index 0000000..bf00d95
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdlib.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-device-input-interface.h"
+#include "common.h"
+
+static hal_backend_device_input_funcs *hal_device_input_funcs = NULL;
+
+int hal_device_input_get_backend(void)
+{
+       int ret;
+
+       if (hal_device_input_funcs)
+               return 0;
+
+       hal_device_input_funcs = calloc(1, sizeof(hal_backend_device_input_funcs));
+       if (!hal_device_input_funcs)
+               return -ENOMEM;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_INPUT, (void **)&hal_device_input_funcs);
+       if (ret < 0) {
+               _E("Failed to get device-input backend");
+               free(hal_device_input_funcs);
+               hal_device_input_funcs = NULL;
+               return ret;
+       }
+
+       return 0;
+}
+
+int hal_device_input_put_backend(void)
+{
+       int ret;
+
+       if (!hal_device_input_funcs)
+               return 0;
+
+       ret = hal_common_put_backend(HAL_MODULE_DEVICE_INPUT, (void *)hal_device_input_funcs);
+       if(ret < 0) {
+               _E("Failed to put device-input backend");
+               return ret;
+       }
+
+       free(hal_device_input_funcs);
+       hal_device_input_funcs = NULL;
+
+       return 0;
+}
+
+int hal_device_input_set_event_state(int input_device_id, int on)
+{
+       int ret;
+
+       if (!hal_device_input_funcs) {
+               if ((ret = hal_device_input_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_input_funcs ||
+               !hal_device_input_funcs->set_event_state)
+               return -ENOTSUP;
+
+       return hal_device_input_funcs->set_event_state(input_device_id, on);
+}
+
+int hal_device_input_get_event_state(int input_device_id, int* on)
+{
+       int ret;
+
+       if (!on)
+               return -EINVAL;
+
+       if (!hal_device_input_funcs) {
+               if ((ret = hal_device_input_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_input_funcs ||
+               !hal_device_input_funcs->get_event_state)
+               return -ENOTSUP;
+
+       return hal_device_input_funcs->get_event_state(input_device_id, on);
+}
\ No newline at end of file
diff --git a/src/input.c b/src/input.c
deleted file mode 100644 (file)
index 1f2ae1b..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hal/hal-common.h>
-
-#include "hal-device-input-interface.h"
-#include "common.h"
-
-static hal_backend_device_input_funcs *hal_device_input_funcs = NULL;
-
-int hal_device_input_get_backend(void)
-{
-       int ret;
-
-       if (hal_device_input_funcs)
-               return 0;
-
-       ret = hal_common_get_backend(HAL_MODULE_DEVICE_INPUT, (void **)&hal_device_input_funcs);
-       if (ret < 0) {
-               _E("Failed to get input backend");
-               return ret;
-       }
-
-       return 0;
-}
-
-int hal_device_input_put_backend(void)
-{
-       int ret;
-
-       if (!hal_device_input_funcs)
-               return 0;
-
-       ret = hal_common_put_backend(HAL_MODULE_DEVICE_INPUT, (void *)hal_device_input_funcs);
-       if(ret < 0) {
-               _E("Failed to put input backend");
-               return ret;
-       }
-
-       hal_device_input_funcs = NULL;
-
-       return 0;
-}
-
-int hal_device_input_set_event_state(int input_device_id, int on)
-{
-       int ret;
-
-       if (!hal_device_input_funcs) {
-               if ((ret = hal_device_input_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_device_input_funcs ||
-               !hal_device_input_funcs->set_event_state)
-               return -ENODEV;
-
-       return hal_device_input_funcs->set_event_state(input_device_id, on);
-}
-
-int hal_device_input_get_event_state(int input_device_id, int* on)
-{
-       int ret;
-
-       if (!hal_device_input_funcs) {
-               if ((ret = hal_device_input_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_device_input_funcs ||
-               !hal_device_input_funcs->get_event_state)
-               return -ENODEV;
-
-       return hal_device_input_funcs->get_event_state(input_device_id, on);
-}
\ No newline at end of file