diff options
author | Yunhee Seo <yuni.seo@samsung.com> | 2024-04-18 19:20:23 +0900 |
---|---|---|
committer | Yunhee Seo <yuni.seo@samsung.com> | 2024-04-19 13:35:09 +0900 |
commit | 2fe08b1926da04fcf2305a1d41a3e40f94937f76 (patch) | |
tree | ca357bf39b660a52eb049b8cace375025963ab72 | |
parent | 5ae4b1c07cf3497e856ff3439b3e6895d7a5de91 (diff) | |
download | device-2fe08b1926da04fcf2305a1d41a3e40f94937f76.tar.gz device-2fe08b1926da04fcf2305a1d41a3e40f94937f76.tar.bz2 device-2fe08b1926da04fcf2305a1d41a3e40f94937f76.zip |
device-input: Apply HAL ABI versioning rule
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>
-rw-r--r-- | include/hal-device-input-interface-1.h | 33 | ||||
-rw-r--r-- | include/hal-device-input-interface.h | 30 | ||||
-rw-r--r-- | include/hal-device-input-types.h | 41 | ||||
-rw-r--r-- | src/hal-api-device-input.c (renamed from src/input.c) | 19 |
4 files changed, 94 insertions, 29 deletions
diff --git a/include/hal-device-input-interface-1.h b/include/hal-device-input-interface-1.h new file mode 100644 index 0000000..639c160 --- /dev/null +++ b/include/hal-device-input-interface-1.h @@ -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__ */ diff --git a/include/hal-device-input-interface.h b/include/hal-device-input-interface.h index c67dca0..3b94e34 100644 --- a/include/hal-device-input-interface.h +++ b/include/hal-device-input-interface.h @@ -14,30 +14,10 @@ * 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 index 0000000..9f80464 --- /dev/null +++ b/include/hal-device-input-types.h @@ -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/input.c b/src/hal-api-device-input.c index 1f2ae1b..bf00d95 100644 --- a/src/input.c +++ b/src/hal-api-device-input.c @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include <stdlib.h> #include <hal/hal-common.h> @@ -28,9 +29,15 @@ int hal_device_input_get_backend(void) 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 input backend"); + _E("Failed to get device-input backend"); + free(hal_device_input_funcs); + hal_device_input_funcs = NULL; return ret; } @@ -46,10 +53,11 @@ int hal_device_input_put_backend(void) ret = hal_common_put_backend(HAL_MODULE_DEVICE_INPUT, (void *)hal_device_input_funcs); if(ret < 0) { - _E("Failed to put input backend"); + _E("Failed to put device-input backend"); return ret; } + free(hal_device_input_funcs); hal_device_input_funcs = NULL; return 0; @@ -66,7 +74,7 @@ int hal_device_input_set_event_state(int input_device_id, int on) if (!hal_device_input_funcs || !hal_device_input_funcs->set_event_state) - return -ENODEV; + return -ENOTSUP; return hal_device_input_funcs->set_event_state(input_device_id, on); } @@ -75,6 +83,9 @@ 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; @@ -82,7 +93,7 @@ int hal_device_input_get_event_state(int input_device_id, int* on) if (!hal_device_input_funcs || !hal_device_input_funcs->get_event_state) - return -ENODEV; + return -ENOTSUP; return hal_device_input_funcs->get_event_state(input_device_id, on); }
\ No newline at end of file |