device-ir: Apply HAL ABI versioning rule 66/309966/3
authorYunhee Seo <yuni.seo@samsung.com>
Thu, 18 Apr 2024 10:40:54 +0000 (19:40 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 04:35:31 +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-ir.c
 -> HAL-INTERFACE Wrapper call according to major version and implemenation of
    functions declared in hal-device-ir.h

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

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

hal-device-ir-types.h
 -> Common data types like structures or enums used between the device-ir
    HAL-API and HAL-BACKEND
hal-device-ir-interface-1.h
 -> Declaration of functions to be implemented in the device-ir 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-ir-interface.h
 -> Includes the hal-device-ir-interface-[major].h files for each supported
    major version.
hal-device-ir.h
 -> Declaration of the device-ir HAL-API functions

As applying HAL ABI versioning, definitions are also chaged in Native API style.
The module names that are not being used well have been modified to proper names.
"ir" -> "device-ir"

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

diff --git a/include/hal-device-ir-interface-1.h b/include/hal-device-ir-interface-1.h
new file mode 100644 (file)
index 0000000..daa0121
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021 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_IR_INTERFACE_1_H__
+#define __HAL_DEVICE_IR_INTERFACE_1_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _hal_backend_device_ir_funcs {
+       /* Control ir state */
+       int (*is_available)(bool *available);
+       int (*transmit)(int *frequency_pattern, int size);
+} hal_backend_device_ir_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_IR_INTERFACE_1_H__ */
diff --git a/include/hal-device-ir-interface.h b/include/hal-device-ir-interface.h
new file mode 100644 (file)
index 0000000..3203222
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 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_IR_INTERFACE_H__
+#define __HAL_DEVICE_IR_INTERFACE_H__
+
+#include "hal-device-ir-interface-1.h"
+
+#endif /* __HAL_DEVICE_IR_INTERFACE_H__ */
diff --git a/include/hal-device-ir.h b/include/hal-device-ir.h
new file mode 100644 (file)
index 0000000..edeebd6
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021 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_IR_H__
+#define __HAL_DEVICE_IR_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_ir_get_backend(void);
+int hal_device_ir_put_backend(void);
+int hal_device_ir_is_available(bool *available);
+int hal_device_ir_transmit(int *frequency_pattern, int size);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  /* __HAL_DEVICE_IR_H__ */
diff --git a/include/hal-ir-interface.h b/include/hal-ir-interface.h
deleted file mode 100644 (file)
index f311405..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2021 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_IR_INTERFACE_H__
-#define __HAL_IR_INTERFACE_H__
-
-#include "hal-ir.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _hal_backend_ir_funcs {
-       /* Control ir state */
-       int (*is_available)(bool *available);
-       int (*transmit)(int *frequency_pattern, int size);
-} hal_backend_ir_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __HAL_IR_INTERFACE_H__ */
diff --git a/include/hal-ir.h b/include/hal-ir.h
deleted file mode 100644 (file)
index c0efc47..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2021 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_IR_H__
-#define __HAL_IR_H__
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int hal_device_ir_get_backend(void);
-int hal_device_ir_put_backend(void);
-int hal_device_ir_is_available(bool *available);
-int hal_device_ir_transmit(int *frequency_pattern, int size);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif  /* __HAL_IR_H__ */
diff --git a/src/hal-api-device-ir.c b/src/hal-api-device-ir.c
new file mode 100644 (file)
index 0000000..fa5bac3
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2021 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 <stdio.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-device-ir-interface.h"
+#include "common.h"
+
+static hal_backend_device_ir_funcs *hal_device_ir_funcs = NULL;
+
+int hal_device_ir_get_backend(void)
+{
+       int ret;
+
+       if (hal_device_ir_funcs)
+               return 0;
+
+       hal_device_ir_funcs = calloc(1, sizeof(hal_backend_device_ir_funcs));
+       if (!hal_device_ir_funcs)
+               return -ENOMEM;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_IR, (void **)&hal_device_ir_funcs);
+       if (ret < 0) {
+               _E("Failed to get device-ir backend");
+               free(hal_device_ir_funcs);
+               hal_device_ir_funcs = NULL;
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int hal_device_ir_put_backend(void)
+{
+       if (!hal_device_ir_funcs)
+               return 0;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_IR, (void *)hal_device_ir_funcs);
+       free(hal_device_ir_funcs);
+       hal_device_ir_funcs = NULL;
+
+       return 0;
+}
+
+
+int hal_device_ir_is_available(bool *available)
+{
+       int ret;
+
+       if (!available)
+               return -EINVAL;
+
+       if (!hal_device_ir_funcs) {
+               if ((ret = hal_device_ir_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_ir_funcs ||
+               !hal_device_ir_funcs->is_available)
+               return -ENOTSUP;
+
+       return hal_device_ir_funcs->is_available(available);
+}
+
+int hal_device_ir_transmit(int *frequency_pattern, int size)
+{
+       int ret;
+
+       if (!frequency_pattern)
+               return -EINVAL;
+
+       if (!hal_device_ir_funcs) {
+               if ((ret = hal_device_ir_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_ir_funcs ||
+               !hal_device_ir_funcs->transmit)
+               return -ENOTSUP;
+
+       return hal_device_ir_funcs->transmit(frequency_pattern, size);
+}
diff --git a/src/ir.c b/src/ir.c
deleted file mode 100644 (file)
index 687e59a..0000000
--- a/src/ir.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2021 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 <stdio.h>
-#include <hal/hal-common.h>
-
-#include "hal-ir-interface.h"
-#include "common.h"
-
-static hal_backend_ir_funcs *hal_ir_funcs = NULL;
-
-int hal_device_ir_get_backend(void)
-{
-       int ret;
-
-       if (hal_ir_funcs)
-               return 0;
-
-       ret = hal_common_get_backend(HAL_MODULE_DEVICE_IR, (void **)&hal_ir_funcs);
-       if (ret < 0) {
-                _E("Failed to get ir backend");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-int hal_device_ir_put_backend(void)
-{
-       if (!hal_ir_funcs)
-               return 0;
-
-       hal_common_put_backend(HAL_MODULE_DEVICE_IR, (void *)hal_ir_funcs);
-       hal_ir_funcs = NULL;
-
-       return 0;
-}
-
-
-int hal_device_ir_is_available(bool *available)
-{
-       int ret;
-
-       if (!hal_ir_funcs) {
-               if ((ret = hal_device_ir_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_ir_funcs ||
-           !hal_ir_funcs->is_available)
-               return -ENODEV;
-
-       return hal_ir_funcs->is_available(available);
-}
-
-int hal_device_ir_transmit(int *frequency_pattern, int size)
-{
-       int ret;
-
-       if (!hal_ir_funcs) {
-               if ((ret = hal_device_ir_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_ir_funcs ||
-           !hal_ir_funcs->transmit)
-               return -ENODEV;
-
-       return hal_ir_funcs->transmit(frequency_pattern, size);
-}