device-touchscreen: Apply HAL ABI versioning rule 19/310019/1
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 07:32:49 +0000 (16:32 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 07:32:49 +0000 (16:32 +0900)
In HAL-API-[module], source file name should follow hal-api-[module].c format
for applying HAL ABI versioning.

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

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

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

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

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

index 7c3e7a7d0b65cca9c239f5bc6d3f90d867f833ec..1c62bf936c61acf44c6b8ae72a311229d364cdc3 100644 (file)
@@ -1,14 +1,14 @@
 #include <system_info.h>
 
 #include "haltest.h"
-#include "hal-touchscreen.h"
+#include "hal-device-touchscreen.h"
 
 class TOUCHSCREEN : public testing::Test
 {
        protected:
                static void SetUpHalTestSuite() {
                        int ret_val, val;
-                       enum touchscreen_state state;
+                       hal_device_touchscreen_state_e state;
 
                        ret_val = hal_device_touchscreen_get_backend();
                        ASSERT_EQ(ret_val, 0) << strerr("Failed to get touchscreeen backend", ret_val);
@@ -27,7 +27,7 @@ class TOUCHSCREEN : public testing::Test
 
                static void TearDownHalTestSuite() {
                        if (TOUCHSCREEN::orig_state != -1)
-                               hal_device_touchscreen_set_state((enum touchscreen_state)TOUCHSCREEN::orig_state);
+                               hal_device_touchscreen_set_state((hal_device_touchscreen_state_e)TOUCHSCREEN::orig_state);
                        if (TOUCHSCREEN::orig_powersaving != -1)
                                hal_device_touchscreen_set_powersaving(TOUCHSCREEN::orig_powersaving);
                        if (TOUCHSCREEN::orig_glove_mode != -1)
@@ -48,7 +48,7 @@ int TOUCHSCREEN::orig_glove_mode = -1;
 TEST_F(TOUCHSCREEN, GetStateP)
 {
        int ret_val;
-       enum touchscreen_state state;
+       hal_device_touchscreen_state_e state;
 
        if (!TOUCHSCREEN::supported) {
                SKIP_MESSAGE("Touchscreen not supported");
@@ -66,7 +66,7 @@ TEST_F(TOUCHSCREEN, GetStateP)
 TEST_F(TOUCHSCREEN, SetStateP)
 {
        int ret_val;
-       enum touchscreen_state state;
+       hal_device_touchscreen_state_e state;
 
 
        if (!TOUCHSCREEN::supported) {
@@ -74,7 +74,7 @@ TEST_F(TOUCHSCREEN, SetStateP)
                return;
        }
 
-       ret_val = hal_device_touchscreen_set_state(TOUCHSCREEN_OFF);
+       ret_val = hal_device_touchscreen_set_state(HAL_DEVICE_TOUCHSCREEN_OFF);
        if (ret_val == -ENODEV) {
                SKIP_MESSAGE("Not supported HAL");
                return;
@@ -87,9 +87,9 @@ TEST_F(TOUCHSCREEN, SetStateP)
                return;
        }
        EXPECT_EQ(ret_val, 0) << strerr("Failed to get touchscreen state", ret_val);
-       EXPECT_EQ(state, TOUCHSCREEN_OFF) << "Failed to set touchscreen state";
+       EXPECT_EQ(state, HAL_DEVICE_TOUCHSCREEN_OFF) << "Failed to set touchscreen state";
 
-       ret_val = hal_device_touchscreen_set_state(TOUCHSCREEN_ON);
+       ret_val = hal_device_touchscreen_set_state(HAL_DEVICE_TOUCHSCREEN_ON);
        if (ret_val == -ENODEV) {
                SKIP_MESSAGE("Not supported HAL");
                return;
@@ -102,11 +102,11 @@ TEST_F(TOUCHSCREEN, SetStateP)
                return;
        }
        EXPECT_EQ(ret_val, 0) << strerr("Failed to get touchscreen state", ret_val);
-       EXPECT_EQ(state, TOUCHSCREEN_ON) << "Failed to set touchscreen state";
+       EXPECT_EQ(state, HAL_DEVICE_TOUCHSCREEN_ON) << "Failed to set touchscreen state";
 
        // restore
        if (TOUCHSCREEN::orig_state != -1)
-               hal_device_touchscreen_set_state((enum touchscreen_state)TOUCHSCREEN::orig_state);
+               hal_device_touchscreen_set_state((hal_device_touchscreen_state_e)TOUCHSCREEN::orig_state);
 }
 
 TEST_F(TOUCHSCREEN, GetPowersavingP)
@@ -169,7 +169,7 @@ TEST_F(TOUCHSCREEN,SetPowersavingP)
 
        // restore
        if (TOUCHSCREEN::orig_powersaving != -1)
-               hal_device_touchscreen_set_powersaving((enum touchscreen_state)TOUCHSCREEN::orig_powersaving);
+               hal_device_touchscreen_set_powersaving((hal_device_touchscreen_state_e)TOUCHSCREEN::orig_powersaving);
 }
 
 TEST_F(TOUCHSCREEN, GetGloveModeStateP)
@@ -199,7 +199,7 @@ TEST_F(TOUCHSCREEN, SetGloveModeStateP)
                return;
        }
 
-       ret_val = hal_device_touchscreen_glove_mode_set_state((int)GLOVE_MODE_OFF);
+       ret_val = hal_device_touchscreen_glove_mode_set_state((int)HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_OFF);
        if (ret_val == -ENODEV) {
                SKIP_MESSAGE("Not supported HAL");
                return;
@@ -212,9 +212,9 @@ TEST_F(TOUCHSCREEN, SetGloveModeStateP)
                return;
        }
        EXPECT_EQ(ret_val, 0) << strerr("Failed to get glove mode", ret_val);
-       EXPECT_EQ(glove_mode, (int)GLOVE_MODE_OFF) << "Failed to set glove mode";
+       EXPECT_EQ(glove_mode, (int)HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_OFF) << "Failed to set glove mode";
 
-       ret_val = hal_device_touchscreen_glove_mode_set_state((int)GLOVE_MODE_ON);
+       ret_val = hal_device_touchscreen_glove_mode_set_state((int)HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_ON);
        if (ret_val == -ENODEV) {
                SKIP_MESSAGE("Not supported HAL");
                return;
@@ -227,7 +227,7 @@ TEST_F(TOUCHSCREEN, SetGloveModeStateP)
                return;
        }
        EXPECT_EQ(ret_val, 0) << strerr("Failed to get glove mode", ret_val);
-       EXPECT_EQ(glove_mode, (int)GLOVE_MODE_ON) << "Failed to set glove mode";
+       EXPECT_EQ(glove_mode, (int)HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_ON) << "Failed to set glove mode";
 
        // restore
        if (TOUCHSCREEN::orig_glove_mode != -1)
diff --git a/include/hal-device-touchscreen-interface-1.h b/include/hal-device-touchscreen-interface-1.h
new file mode 100644 (file)
index 0000000..a3e23ed
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2024 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_TOUCHSCREEN_INTERFACE_1_H__
+#define __HAL_DEVICE_TOUCHSCREEN_INTERFACE_1_H__
+
+#include "hal-device-touchscreen-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _hal_backend_device_touchscreen_funcs {
+       /* Control touchscreen state */
+       int (*get_state)(hal_device_touchscreen_state_e *state);
+       int (*set_state)(hal_device_touchscreen_state_e state);
+       int (*get_powersaving)(int *state);
+       int (*set_powersaving)(int state);
+
+       /* Control touch sensitivity state */
+       int (*glove_mode_get_state)(int *state);
+       int (*glove_mode_set_state)(int state);
+} hal_backend_device_touchscreen_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_TOUCHSCREEN_INTERFACE_H__1_ */
diff --git a/include/hal-device-touchscreen-interface.h b/include/hal-device-touchscreen-interface.h
new file mode 100644 (file)
index 0000000..216eac8
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_TOUCHSCREEN_INTERFACE_H__
+#define __HAL_DEVICE_TOUCHSCREEN_INTERFACE_H__
+
+#include "hal-device-touchscreen-types.h"
+#include "hal-device-touchscreen-interface-1.h"
+
+#endif /* __HAL_DEVICE_TOUCHSCREEN_INTERFACE_H__ */
diff --git a/include/hal-device-touchscreen-types.h b/include/hal-device-touchscreen-types.h
new file mode 100644 (file)
index 0000000..fcc3eaf
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2024 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_TOUCHSCREEN_TYPES_H__
+#define __HAL_DEVICE_TOUCHSCREEN_TYPES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* FIXME: These macros should be changed to enum type */
+#define TOUCHSENSITIVITY_GLOVE_MODE_OFF  0     /* Disable glove mode */
+#define TOUCHSENSITIVITY_GLOVE_MODE_ON  1      /* Enable glove mode */
+
+/**
+ * @brief Enumeration for touchscreen state.
+ * @since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0
+ */
+typedef enum {
+       HAL_DEVICE_TOUCHSCREEN_OFF,     /* Disable touchscreen (Since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0) */
+       HAL_DEVICE_TOUCHSCREEN_ON,              /* Enable touchscreen (Since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0) */
+} hal_device_touchscreen_state_e;
+
+/**
+ * @brief Enumeration for touchscreen sensitivity state.
+ * @since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0
+ */
+typedef enum {
+       HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_OFF,          /* Disable glove mode (Since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0) */
+       HAL_DEVICE_TOUCHSCREEN_GLOVE_MODE_ON,           /* Enable glove mode (Since HAL_MODULE_DEVICE_TOUCHSCREEN 1.0) */
+} hal_device_touchscreen_sensitivity_state_e;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DEVICE_TOUCHSCREEN_TYPES_H__ */
diff --git a/include/hal-device-touchscreen.h b/include/hal-device-touchscreen.h
new file mode 100644 (file)
index 0000000..03a0e7c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_TOUCHSCREEN_H__
+#define __HAL_DEVICE_TOUCHSCREEN_H__
+
+#include <hal/hal-common.h>
+#include "hal-device-touchscreen-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_touchscreen_get_backend(void);
+int hal_device_touchscreen_put_backend(void);
+int hal_device_touchscreen_get_state(hal_device_touchscreen_state_e *state);
+int hal_device_touchscreen_set_state(hal_device_touchscreen_state_e state);
+int hal_device_touchscreen_get_powersaving(int *state);
+int hal_device_touchscreen_set_powersaving(int state);
+int hal_device_touchscreen_glove_mode_get_state(int *state);
+int hal_device_touchscreen_glove_mode_set_state(int state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* __HAL_DEVICE_TOUCHSCREEN_H__ */
diff --git a/include/hal-touchscreen-interface.h b/include/hal-touchscreen-interface.h
deleted file mode 100644 (file)
index 040f481..0000000
+++ /dev/null
@@ -1,53 +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_TOUCHSCREEN_INTERFACE_H__
-#define __HAL_TOUCHSCREEN_INTERFACE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define TOUCHSENSITIVITY_GLOVE_MODE_OFF  0     /* Disable glove mode */
-#define TOUCHSENSITIVITY_GLOVE_MODE_ON  1      /* Enable glove mode */
-
-enum touchscreen_state {
-       TOUCHSCREEN_OFF,     /* Disable touchscreen */
-       TOUCHSCREEN_ON,      /* Enable touchscreen */
-};
-
-enum touchscreen_sensitivity_state {
-       GLOVE_MODE_OFF,     /* Disable glove mode */
-       GLOVE_MODE_ON,      /* Enable glove mode */
-};
-
-typedef struct _hal_backend_touchscreen_funcs {
-       /* Control touchscreen state */
-       int (*get_state)(enum touchscreen_state *state);
-       int (*set_state)(enum touchscreen_state state);
-       int (*get_powersaving)(int *state);
-       int (*set_powersaving)(int state);
-
-       /* Control touch sensitivity state */
-       int (*glove_mode_get_state)(int *state);
-       int (*glove_mode_set_state)(int state);
-} hal_backend_touchscreen_funcs;
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __HAL_TOUCHSCREEN_INTERFACE_H__ */
diff --git a/include/hal-touchscreen.h b/include/hal-touchscreen.h
deleted file mode 100644 (file)
index 9444559..0000000
+++ /dev/null
@@ -1,41 +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_TOUCHSCREEN_H__
-#define __HAL_TOUCHSCREEN_H__
-
-#include <hal/hal-common.h>
-#include "hal-touchscreen-interface.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int hal_device_touchscreen_get_backend(void);
-int hal_device_touchscreen_put_backend(void);
-int hal_device_touchscreen_get_state(enum touchscreen_state *state);
-int hal_device_touchscreen_set_state(enum touchscreen_state state);
-int hal_device_touchscreen_get_powersaving(int *state);
-int hal_device_touchscreen_set_powersaving(int state);
-int hal_device_touchscreen_glove_mode_get_state(int *state);
-int hal_device_touchscreen_glove_mode_set_state(int state);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* __HAL_TOUCHSCREEN_H__ */
diff --git a/src/hal-api-device-touchscreen.c b/src/hal-api-device-touchscreen.c
new file mode 100644 (file)
index 0000000..0347b0d
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * 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-touchscreen-interface.h"
+#include "common.h"
+
+static hal_backend_device_touchscreen_funcs *hal_device_touchscreen_funcs = NULL;
+
+int hal_device_touchscreen_get_backend(void)
+{
+       int ret;
+
+       if (hal_device_touchscreen_funcs)
+               return 0;
+
+       hal_device_touchscreen_funcs = calloc(1, sizeof(hal_backend_device_touchscreen_funcs));
+       if (!hal_device_touchscreen_funcs)
+               return -ENOMEM;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void **)&hal_device_touchscreen_funcs);
+       if (ret < 0) {
+               _E("Failed to get device-touchscreen backend");
+               free(hal_device_touchscreen_funcs);
+               hal_device_touchscreen_funcs = NULL;
+               return -ENOTSUP;
+       }
+
+       return 0;
+}
+
+int hal_device_touchscreen_put_backend(void)
+{
+       int ret = 0;
+
+       if (!hal_device_touchscreen_funcs)
+               return 0;
+
+       ret = hal_common_put_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void *)hal_device_touchscreen_funcs);
+       if (ret < 0) {
+               _E("Failed to put device-touchscreen backend");
+               return ret;
+       }
+
+       free(hal_device_touchscreen_funcs);
+       hal_device_touchscreen_funcs = NULL;
+
+       return 0;
+}
+
+
+int hal_device_touchscreen_get_state(hal_device_touchscreen_state_e *state)
+{
+       int ret;
+
+       if (!state)
+               return -EINVAL;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->get_state)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->get_state(state);
+}
+
+int hal_device_touchscreen_set_state(hal_device_touchscreen_state_e state)
+{
+       int ret;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->set_state)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->set_state(state);
+}
+
+int hal_device_touchscreen_get_powersaving(int *state)
+{
+       int ret;
+
+       if (!state)
+               return -EINVAL;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->get_powersaving)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->get_powersaving(state);
+}
+
+int hal_device_touchscreen_set_powersaving(int state)
+{
+       int ret;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->set_powersaving)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->set_powersaving(state);
+}
+
+int hal_device_touchscreen_glove_mode_get_state(int *state)
+{
+       int ret;
+
+       if (!state)
+               return -EINVAL;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->glove_mode_get_state)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->glove_mode_get_state(state);
+}
+
+int hal_device_touchscreen_glove_mode_set_state(int state)
+{
+       int ret;
+
+       if (!hal_device_touchscreen_funcs) {
+               if ((ret = hal_device_touchscreen_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_device_touchscreen_funcs ||
+               !hal_device_touchscreen_funcs->glove_mode_set_state)
+               return -ENOTSUP;
+
+       return hal_device_touchscreen_funcs->glove_mode_set_state(state);
+}
diff --git a/src/touchscreen.c b/src/touchscreen.c
deleted file mode 100644 (file)
index b920b71..0000000
+++ /dev/null
@@ -1,148 +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-touchscreen-interface.h"
-#include "common.h"
-
-static hal_backend_touchscreen_funcs *hal_touchscreen_funcs = NULL;
-
-int hal_device_touchscreen_get_backend(void)
-{
-       int ret;
-
-       if (hal_touchscreen_funcs)
-               return 0;
-
-       ret = hal_common_get_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void **)&hal_touchscreen_funcs);
-       if (ret < 0) {
-                _E("Failed to get touchscreen backend");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-int hal_device_touchscreen_put_backend(void)
-{
-       if (!hal_touchscreen_funcs)
-               return 0;
-
-       hal_common_put_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void *)hal_touchscreen_funcs);
-       hal_touchscreen_funcs = NULL;
-
-       return 0;
-}
-
-
-int hal_device_touchscreen_get_state(enum touchscreen_state *state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->get_state)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->get_state(state);
-}
-
-int hal_device_touchscreen_set_state(enum touchscreen_state state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->set_state)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->set_state(state);
-}
-
-int hal_device_touchscreen_get_powersaving(int *state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->get_powersaving)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->get_powersaving(state);
-}
-
-int hal_device_touchscreen_set_powersaving(int state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->set_powersaving)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->set_powersaving(state);
-}
-
-int hal_device_touchscreen_glove_mode_get_state(int *state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->glove_mode_get_state)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->glove_mode_get_state(state);
-}
-
-int hal_device_touchscreen_glove_mode_set_state(int state)
-{
-       int ret;
-
-       if (!hal_touchscreen_funcs) {
-               if ((ret = hal_device_touchscreen_get_backend()) < 0)
-                       return ret;
-       }
-
-       if (!hal_touchscreen_funcs ||
-           !hal_touchscreen_funcs->glove_mode_set_state)
-               return -ENODEV;
-
-       return hal_touchscreen_funcs->glove_mode_set_state(state);
-}