--- /dev/null
+/*
+ * 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__ */
--- /dev/null
+/*
+ * 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__ */
--- /dev/null
+/*
+ * 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__ */
+++ /dev/null
-/*
- * 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__ */
+++ /dev/null
-/*
- * 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__ */
--- /dev/null
+/*
+ * 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);
+}
+++ /dev/null
-/*
- * 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);
-}