Initialize HAL APIs 14/251014/7
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 7 Jan 2021 01:42:17 +0000 (10:42 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 7 Jan 2021 09:13:22 +0000 (18:13 +0900)
Change-Id: I2a30e8591be4db12a82a7fa99c98206f352fb2e3
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
39 files changed:
CMakeLists.txt
include/common.h
include/device-error.h [deleted file]
include/hal-battery-interface.h [new file with mode: 0644]
include/hal-battery.h
include/hal-bezel-interface.h [new file with mode: 0644]
include/hal-bezel.h [new file with mode: 0644]
include/hal-board-interface.h [new file with mode: 0644]
include/hal-board.h [new file with mode: 0644]
include/hal-display-enum.h [deleted file]
include/hal-display-interface.h [new file with mode: 0644]
include/hal-display.h
include/hal-external_connection-interface.h [new file with mode: 0644]
include/hal-external_connection.h [new file with mode: 0644]
include/hal-ir-interface.h [new file with mode: 0644]
include/hal-ir.h
include/hal-led-interface.h [new file with mode: 0644]
include/hal-led.h
include/hal-temperature.h [deleted file]
include/hal-thermal-interface.h [new file with mode: 0644]
include/hal-thermal.h [new file with mode: 0644]
include/hal-touchscreen-interface.h [new file with mode: 0644]
include/hal-touchscreen.h [new file with mode: 0644]
include/list.h [deleted file]
packaging/hal-api-device.spec
src/battery.c
src/bezel.c [new file with mode: 0644]
src/board.c [new file with mode: 0644]
src/common.c [deleted file]
src/device.c [deleted file]
src/display.c
src/external_connection.c [new file with mode: 0644]
src/haptic.c [deleted file]
src/ir.c
src/led.c
src/memory.c [deleted file]
src/temperature.c [deleted file]
src/thermal.c [new file with mode: 0644]
src/touchscreen.c

index af3a967..d278190 100644 (file)
@@ -12,13 +12,7 @@ INCLUDE_DIRECTORIES(${INC_DIR})
 
 SET(PKG_MODULES
                dlog
-               vconf
-               capi-base-common
-               capi-system-device
-               capi-system-info
-               gio-2.0
-               tracker
-               libsyscommon
+               hal-api-common
 )
 
 INCLUDE(FindPkgConfig)
index 273ed79..499b6d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
@@ -18,7 +18,7 @@
 #define __COMMON_H__
 
 #ifdef FEATURE_DEVICE_DLOG
-    #define LOG_TAG "SYSTEM_DEVICE"
+    #define LOG_TAG "HALAPI_DEVICE"
     #include <dlog.h>
     #define _D(fmt, args...)   SLOGD(fmt, ##args)
     #define _I(fmt, args...)   SLOGI(fmt, ##args)
 #define __CONSTRUCTOR__ __attribute__ ((constructor))
 #endif
 
-#include "device-error.h"
-
-static inline int errno_to_device_error(int err)
-{
-       switch (err) {
-       case 0:
-               return DEVICE_ERROR_NONE;
-       case -EACCES:
-       case -EPERM:
-               return DEVICE_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE System Error
-       case -EBUSY:
-               return DEVICE_ERROR_RESOURCE_BUSY;
-       case -ENOTSUP:
-       case -ENODEV:
-       case -ENOENT:
-               return DEVICE_ERROR_NOT_SUPPORTED;
-       default:
-               return DEVICE_ERROR_OPERATION_FAILED;
-       }
-}
-
-struct parse_result {
-       char *section;
-       char *name;
-       char *value;
-};
-
-int config_parse(const char *file_name,
-               int cb(struct parse_result *result, void *data),
-               void *user_data);
-
-typedef enum {
-       TIZEN_PROFILE_UNKNOWN = 0,
-       TIZEN_PROFILE_MOBILE = 0x1,
-       TIZEN_PROFILE_WEARABLE = 0x2,
-       TIZEN_PROFILE_TV = 0x4,
-       TIZEN_PROFILE_IVI = 0x8,
-       TIZEN_PROFILE_COMMON = 0x10,
-} tizen_profile_t;
-extern tizen_profile_t _get_tizen_profile();
-
-#define CHECK_RATE_THRESHOLD   100
-#define CHECK_RATE_PERIOD_LEN  5
-int check_async_call_rate(long *num_calls);
-
-#define TIZEN_FEATURE_TRACKER (_get_tizen_profile() == TIZEN_PROFILE_TV)
+#ifndef EXPORT
+#define EXPORT __attribute__ ((visibility("default")))
+#endif
 
-bool is_emulator(void);
-int is_display_state_supported(void);
-int is_display_supported(void);
 #endif /* __COMMON_H__ */
diff --git a/include/device-error.h b/include/device-error.h
deleted file mode 100644 (file)
index 9b70367..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2014 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 __TIZEN_SYSTEM_DEVICE_ERROR_H__
-#define __TIZEN_SYSTEM_DEVICE_ERROR_H__
-
-
-#include <tizen.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_MODULE
- * @{
- */
-
-
-/**
- * @brief Enumeration for device's error code.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
-       DEVICE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-       DEVICE_ERROR_OPERATION_FAILED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */
-       DEVICE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-       DEVICE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
-       DEVICE_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
-       DEVICE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported in this device */
-       DEVICE_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */
-       DEVICE_ERROR_NOT_INITIALIZED = TIZEN_ERROR_DEVICE | 0x13, /**< Not initialized */
-} device_error_e;
-
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif  // __TIZEN_SYSTEM_DEVICE_ERROR_H__
diff --git a/include/hal-battery-interface.h b/include/hal-battery-interface.h
new file mode 100644 (file)
index 0000000..01e1180
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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_BATTERY_INTERFACE_H__
+#define __HAL_BATTERY_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct battery_info {
+       char *name;
+       char *status;
+       char *health;
+       char *power_source;
+
+       int online;
+       int present;
+       int capacity;
+
+       int current_now;
+       int current_average;
+       int voltage_now;
+       int voltage_average;
+       int temperature;
+
+       int freq_strength; /* charging frequency strength from charger */
+};
+
+typedef void (*BatteryUpdated)(struct battery_info *info, void *data);
+
+typedef struct _hal_backend_battery_funcs {
+       /* Register battery event */
+       int (*register_changed_event)(BatteryUpdated updated_cb, void *data);
+       void (*unregister_changed_event)(BatteryUpdated updated_cb);
+
+       /* Get current states */
+       int (*get_current_state)(BatteryUpdated updated_cb, void *data);
+} hal_backend_battery_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_BATTERY_INTERFACE_H__ */
index e706f4f..5dee8fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#ifndef __TIZEN_SYSTEM_BATTERY_H__
-#define __TIZEN_SYSTEM_BATTERY_H__
-
-
-#include <stdbool.h>
-#include "device-error.h"
+#ifndef __HAL_BATTERY_H__
+#define __HAL_BATTERY_H__
 
+#include "hal-battery-interface.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define BATTERY_INFO_MAX 32
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_BATTERY_MODULE
- * @{
- */
-
-
-/**
- * @brief Enumeration for the battery level status.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
-    DEVICE_BATTERY_LEVEL_EMPTY = 0, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */
-    DEVICE_BATTERY_LEVEL_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */
-    DEVICE_BATTERY_LEVEL_LOW, /**< The battery has little charge left. */
-    DEVICE_BATTERY_LEVEL_HIGH, /**< The battery status is not to be careful. */
-    DEVICE_BATTERY_LEVEL_FULL, /**< The battery status is fully charged. It means no more charge. */
-} device_battery_level_e;
-
-
-/**
- * @brief Enumeration for battery health information.
- * @since_tizen 3.0
- */
-typedef enum {
-       DEVICE_BATTERY_HEALTH_GOOD, /**< The battery health is good */
-       DEVICE_BATTERY_HEALTH_COLD, /**< The temperature of the battery is cold */
-       DEVICE_BATTERY_HEALTH_DEAD, /**< The battery is dead */
-       DEVICE_BATTERY_HEALTH_OVER_HEAT, /**< The temperature of the battery is high */
-       DEVICE_BATTERY_HEALTH_OVER_VOLTAGE, /**< The battery is in over voltage state */
-} device_battery_health_e;
-
-
-/**
- * @brief Enumeration for power source information.
- * @since_tizen 3.0
- */
-typedef enum {
-       DEVICE_BATTERY_POWER_SOURCE_NONE, /**< There is no power source */
-       DEVICE_BATTERY_POWER_SOURCE_AC, /**< AC power cable is connected */
-       DEVICE_BATTERY_POWER_SOURCE_USB, /**< USB power cable is connected */
-       DEVICE_BATTERY_POWER_SOURCE_WIRELESS, /**< Power is provided by a wireless source */
-} device_battery_power_source_e;
-
-
-/**
- * @brief Enumeration for battery property information.
- * @since_tizen 3.0
- */
-typedef enum {
-       DEVICE_BATTERY_PROPERTY_CAPACITY, /**< The battery capacity (0 ~ 100 %) */
-       DEVICE_BATTERY_PROPERTY_CURRENT_NOW, /**< The battery current (uA) */
-       DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE, /**< The average battery current (uA) */
-       DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW, /**< The battery voltage (uV) (Since 5.0) */
-       DEVICE_BATTERY_PROPERTY_VOLTAGE_AVERAGE, /**< The average battery voltage (uV) (Since 5.0) */
-       DEVICE_BATTERY_PROPERTY_TEMPERATURE, /**< The battery temperature (`C) (Since 5.0) */
-} device_battery_property_e;
-
-
-/**
- * @brief Enumeration for battery status information.
- * @since_tizen 3.0
- */
-typedef enum {
-       DEVICE_BATTERY_STATUS_CHARGING, /**< Battery is charging */
-       DEVICE_BATTERY_STATUS_DISCHARGING, /**< Battery is discharging */
-       DEVICE_BATTERY_STATUS_FULL, /**< Battery is fully charged */
-       DEVICE_BATTERY_STATUS_NOT_CHARGING, /**< Battery is not charging */
-} device_battery_status_e;
-
-
-struct device_battery_info {
-       char status[BATTERY_INFO_MAX];
-       char health[BATTERY_INFO_MAX];
-       char power_source[BATTERY_INFO_MAX];
-       int online;
-       int present;
-       int capacity;
-       int current_now;
-       int current_average;
-       int voltage_now;
-       int voltage_average;
-       int temperature;
-};
-
-/**
- * @brief Gets the battery charge percentage.
- * @details It returns an integer value from @c 0 to @c 100 that indicates remaining battery charge
- *          as a percentage of the maximum level.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
- * @param[out] percent The remaining battery charge percentage (@c 0 ~ @c 100)
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_battery_get_percent(int *percent);
-
-
-/**
- * @brief Gets the charging state.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[out] charging The battery charging state
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_add_callback
- * @see device_remove_callback
- * @see #DEVICE_CALLBACK_BATTERY_CHARGING
- */
-int device_battery_is_charging(bool *charging);
-
-
-/**
- * @brief Gets the battery level status.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[out] status The battery level status
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_battery_level_e
- * @see device_add_callback
- * @see device_remove_callback
- * @see #DEVICE_CALLBACK_BATTERY_LEVEL
- */
-int device_battery_get_level_status(device_battery_level_e *status);
-
-
-/**
- * @brief Gets the battery health information.
- * @since_tizen 3.0
- * @param[out] health The battery health information
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_battery_get_health(device_battery_health_e *health);
-
-
-/**
- * @brief Gets the battery power source information.
- * @since_tizen 3.0
- * @param[out] source The battery power source information
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_battery_get_power_source(device_battery_power_source_e *source);
-
-
-/**
- * @brief Gets the battery properties.
- * @since_tizen 3.0
- * @param[in] property The property type
- * @param[out] value The battery information for the property given
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_battery_get_property(device_battery_property_e property, int *value);
-
-
-/**
- * @brief Gets the battery status information.
- * @since_tizen 3.0
- * @param[out] status The battery status information
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_battery_get_status(device_battery_status_e *status);
-
-
-/**
- * @}
- */
-
+int hal_device_battery_get_backend(void);
+int hal_device_battery_put_backend(void);
+int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *data);
+int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb);
+int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data);
 
 #ifdef __cplusplus
 }
 #endif
 
-
-#endif  // __TIZEN_SYSTEM_BATTERY_H__
+#endif  // __HAL_BATTERY_H__
diff --git a/include/hal-bezel-interface.h b/include/hal-bezel-interface.h
new file mode 100644 (file)
index 0000000..5b0154e
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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_BEZEL_INTERFACE_H__
+#define __HAL_BEZEL_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum bezel_state {
+       BEZEL_TURNOFF = 0,
+       BEZEL_TURNON,
+};
+
+enum bezel_vib_state {
+       BEZEL_VIB_NONE = 0,
+       BEZEL_VIB_LIGHT,
+       BEZEL_VIB_MEDIUM,
+       BEZEL_VIB_STRONG,
+};
+
+typedef struct _hal_backend_bezel_funcs {
+       /* Control hardware bezel state */
+       int (*get_state)(enum bezel_state *state);
+       int (*set_state)(enum bezel_state state);
+       /* Control software bezel state */
+       int (*get_sw_state)(enum bezel_state *state);
+       int (*set_sw_state)(enum bezel_state state);
+
+       /* Control bezel vibration state */
+       int (*get_vib_state)(enum bezel_vib_state *state);
+       int (*set_vib_state)(enum bezel_vib_state state);
+} hal_backend_bezel_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_BEZEL_INTERFACE_H__ */
diff --git a/include/hal-bezel.h b/include/hal-bezel.h
new file mode 100644 (file)
index 0000000..bad7f79
--- /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_BEZEL_H__
+#define __HAL_BEZEL_H__
+
+#include "hal-bezel-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_bezel_get_backend(void);
+int hal_device_bezel_put_backend(void);
+int hal_device_bezel_get_state(enum bezel_state *state);
+int hal_device_bezel_set_state(enum bezel_state state);
+int hal_device_bezel_get_sw_state(enum bezel_state *state);
+int hal_device_bezel_set_sw_state(enum bezel_state state);
+int hal_device_bezel_get_vib_state(enum bezel_state *state);
+int hal_device_bezel_set_vib_state(enum bezel_state state);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  /* __HAL_BEZEL_H__ */
diff --git a/include/hal-board-interface.h b/include/hal-board-interface.h
new file mode 100644 (file)
index 0000000..5948232
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_BOARD_INTERFACE_H__
+#define __HAL_BOARD_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _hal_backend_board_funcs {
+       /* Serial number of this device */
+       int (*get_device_serial)(char **serial);
+       int (*get_device_revision)(int *revision);
+} hal_backend_board_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_BOARD_INTERFACE_H__ */
diff --git a/include/hal-board.h b/include/hal-board.h
new file mode 100644 (file)
index 0000000..a090c9e
--- /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_BOARD_H__
+#define __HAL_BOARD_H__
+
+#include "hal-board-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_board_get_backend(void);
+int hal_device_board_put_backend(void);
+int hal_device_board_get_device_serial(char **serial);
+int hal_device_board_get_device_revision(int *revision);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  /* __HAL_BOARD_H__ */
diff --git a/include/hal-display-enum.h b/include/hal-display-enum.h
deleted file mode 100644 (file)
index 9434bde..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __TIZEN_SYSTEM_DISPLAY_ENUM_H__
-#define __TIZEN_SYSTEM_DISPLAY_ENUM_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_DISPLAY_MODULE
- * @{
- */
-/**
- * @brief Enumeration for the available display states.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks #DISPLAY_STATE_SCREEN_DIM may be ignored if the DIM state is disabled on the platform.
- */
-
-typedef enum
-{
-    DISPLAY_STATE_NORMAL, /**< Normal state */
-    DISPLAY_STATE_SCREEN_DIM, /**< Screen dim state */
-    DISPLAY_STATE_SCREEN_OFF, /**< Screen off state */
-} display_state_e;
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __TIZEN_SYSTEM_DISPLAY_ENUM_H__
diff --git a/include/hal-display-interface.h b/include/hal-display-interface.h
new file mode 100644 (file)
index 0000000..d2ecc35
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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_DISPLAY_INTERFACE_H__
+#define __HAL_DISPLAY_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum display_state {
+       DISPLAY_ON,       /* In use */
+       DISPLAY_STANDBY,  /* Blanked, low power */
+       DISPLAY_SUSPEND,  /* Blanked, lower power */
+       DISPLAY_OFF,      /* Shut off, awaiting activity */
+       DISPLAY_DETACH,   /* Detached display at runtime */
+};
+
+enum display_image_effect {
+       DISPLAY_IMAGE_EFFECT_STANDARD,     /* No effect */
+       DISPLAY_IMAGE_EFFECT_NEGATIVE,         /* Negative effect */
+       DISPLAY_IMAGE_EFFECT_GREY,             /* Grey effect */
+       DISPLAY_IMAGE_EFFECT_GREY_NEGATIVE,    /* Grey Negative effect */
+       DISPLAY_IMAGE_EFFECT_MAX,
+};
+
+enum display_panel_mode {
+       DISPLAY_PANEL_MODE_STANDARD,      /* Standard mode */
+       DISPLAY_PANEL_MODE_OUTDOOR,       /* Outdoor mode */
+       DISPLAY_PANEL_MODE_CONTENTS,      /* Contents adaptive brightness control mode */
+       DISPLAY_PANEL_MODE_LOWPOWER,      /* Low power mode */
+};
+
+enum display_aod_mode {
+       DISPLAY_AOD_MODE_OFF,
+       DISPLAY_AOD_MODE_ON,
+};
+
+typedef struct _hal_backend_display_funcs {
+       /* Control display brightness */
+       int (*get_max_brightness)(int *brightness);
+       int (*get_brightness)(int *brightness);
+       int (*set_brightness)(int brightness);
+       int (*set_multi_brightness)(int brightness, int step, int delay);
+
+       /* Control display brightness by sensor */
+       int (*get_auto_brightness)(float lmax, float lmin, float light, int *brightness);
+
+       /* Control display state */
+       int (*get_state)(enum display_state *state);
+       int (*set_state)(enum display_state state);
+
+       /* Control image effect */
+       int (*get_image_effect)(enum display_image_effect *effect);
+       int (*set_image_effect)(enum display_image_effect effect);
+
+       /* Control panel mode */
+       int (*get_panel_mode)(enum display_panel_mode *mode);
+       int (*set_panel_mode)(enum display_panel_mode mode);
+
+       /* Control AOD mode */
+       int (*get_aod_mode)(enum display_aod_mode *mode);
+
+       /* Control AOD brightness */
+       int (*get_aod_brightness)(int *max, int *normal, int *min, int *charging);
+
+       /* Control display frame rate */
+       int (*get_max_frame_rate)(int *rate);
+       int (*get_min_frame_rate)(int *rate);
+       int (*get_frame_rate)(int *rate);
+       int (*set_frame_rate)(int rate);
+} hal_backend_display_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_DISPLAY_INTERFACE_H__ */
index 8f05d42..e01b4b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#ifndef __TIZEN_SYSTEM_DISPLAY_H__
-#define __TIZEN_SYSTEM_DISPLAY_H__
+#ifndef __HAL_DISPLAY_H__
+#define __HAL_DISPLAY_H__
 
-
-#include "device-error.h"
-#include "hal-display-enum.h"
+#include "hal-display-interface.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_DISPLAY_MODULE
- * @{
- */
-
-
-/**
- * @brief Gets the number of display devices.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/display
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
- * @param[out] device_number The total number of displays
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_display_get_brightness()
- * @see device_display_set_brightness()
- * @see device_display_get_max_brightness()
- */
-int device_display_get_numbers(int *device_number);
-
-
-/**
- * @brief Gets the maximum brightness value that can be set.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/display
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
- * @param[in] display_index The index of the display \n
- *                          It can be greater than or equal to @c 0 and less than the number of displays returned by device_display_get_numbers(). \n
- *                          The index zero is always assigned to the main display
- * @param[out] max_brightness The maximum brightness value of the display
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_display_get_numbers()
- * @see device_display_set_brightness()
- * @see device_display_get_brightness()
- */
-int device_display_get_max_brightness(int display_index, int *max_brightness);
-
-
-/**
- * @brief Gets the display brightness value.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/display
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
- * @param[in] display_index The index of the display \n
- *                          It can be greater than or equal to @c 0 and less than the number of displays returned by device_display_get_numbers(). \n
- *                          The index zero is always assigned to the main display
- * @param[out] brightness The current brightness value of the display
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_display_get_numbers()
- * @see device_display_set_brightness()
- * @see device_display_get_max_brightness()
- */
-int device_display_get_brightness(int display_index, int *brightness);
-
-
-/**
- * @brief Sets the display brightness value.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/display
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
- * @param[in] display_index The index of the display \n
- *                          It can be greater than or equal to @c 0 and less than the number of displays returned by device_display_get_numbers(). \n
- *                          The index zero is always assigned to the main display
- * @param[in] brightness The new brightness value to set \n
- *                       The maximum value can be represented by device_display_get_max_brightness()
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_display_get_numbers()
- * @see device_display_get_max_brightness()
- * @see device_display_get_brightness()
- */
-int device_display_set_brightness(int display_index, int brightness);
-
-
-/**
- * @brief Gets the current display state.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
- * @param[out] state The display state
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_add_callback
- * @see device_remove_callback
- * @see #DEVICE_CALLBACK_DISPLAY_STATE
- */
-int device_display_get_state(display_state_e *state);
-
-
-/**
- * @brief Changes the display state by force.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/display
- * @remarks This API triggers display change process and then updates the status when it completes. While the operation is on-going, the device_display_get_state() function returns previous display state.
- * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display.state.
- * @param[in] state The display state
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @see device_power_request_lock()
- * @see device_power_release_lock()
- * @see device_add_callback
- * @see device_remove_callback
- * @see #DEVICE_CALLBACK_DISPLAY_STATE
- *
- * @par Example
- * @code
- *  ...
- *  result = device_display_change_state(DISPLAY_STATE_SCREEN_OFF);
- *  if (result < 0)
- *      dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] return value result =%d, \n",result);
- *  else
- *      dlog_print(DLOG_DEBUG, LOG_TAG, "[SUCCESS] return value result =%d \n",result);
- *  ...
- * @endcode
- */
-int device_display_change_state(display_state_e state);
-
-
-/**
- * @}
- */
-
+int hal_device_display_get_backend(void);
+int hal_device_display_put_backend(void);
+int hal_device_display_get_max_brightness(int *brightness);
+int hal_device_display_get_brightness(int *brightness);
+int hal_device_display_set_brightness(int brightness);
+int hal_device_display_set_multi_brightness(int brightness, int step, int delay);
+int hal_device_display_get_auto_brightness(float lmax, float lmin, float light, int *brightness);
+int hal_device_display_get_state(enum display_state *state);
+int hal_device_display_set_state(enum display_state state);
+int hal_device_display_get_image_effect(enum display_image_effect *effect);
+int hal_device_display_set_image_effect(enum display_image_effect effect);
+int hal_device_display_get_panel_mode(enum display_panel_mode *mode);
+int hal_device_display_set_panel_mode(enum display_panel_mode mode);
+int hal_device_display_get_aod_mode(enum display_aod_mode *mode);
+int hal_device_display_get_aod_brightness(int *max, int *normal, int *min, int *charging);
+int hal_device_display_get_max_frame_rate(int *rate);
+int hal_device_display_get_min_frame_rate(int *rate);
+int hal_device_display_get_frame_rate(int *rate);
+int hal_device_display_set_frame_rate(int rate);
 
 #ifdef __cplusplus
 }
 #endif
 
 
-#endif  // __TIZEN_SYSTEM_DISPLAY_H__
+#endif  // __HAL_DISPLAY_H__
diff --git a/include/hal-external_connection-interface.h b/include/hal-external_connection-interface.h
new file mode 100644 (file)
index 0000000..a05fd4c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_EXTERNAL_CONNECTION_INTERFACE_H__
+#define __HAL_EXTERNAL_CONNECTION_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct connection_info {
+       char *name;
+       char *state;
+       int flags;
+};
+
+typedef void (*ConnectionUpdated)(struct connection_info *info, void *data);
+
+typedef struct _hal_backend_external_connection_funcs {
+       /* Register external_connection event */
+       int (*register_changed_event)(ConnectionUpdated updated_cb, void *data);
+       void (*unregister_changed_event)(ConnectionUpdated updated_cb);
+
+       /* Get current states */
+       int (*get_current_state)(ConnectionUpdated updated_cb, void *data);
+} hal_backend_external_connection_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_EXTERNAL_CONNECTION_INTERFACE_H__ */
diff --git a/include/hal-external_connection.h b/include/hal-external_connection.h
new file mode 100644 (file)
index 0000000..46da093
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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_BEZEL_H__
+#define __HAL_BEZEL_H__
+
+#include "hal-external_connection-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_external_connection_get_backend(void);
+int hal_device_external_connection_put_backend(void);
+int hal_device_external_connection_register_changed_event(ConnectionUpdated updated_cb, void *data);
+int hal_device_external_connection_unregister_changed_event(ConnectionUpdated updated_cb);
+int hal_device_external_connection_get_current_state(ConnectionUpdated updated_cb, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  /* __HAL_BEZEL_H__ */
diff --git a/include/hal-ir-interface.h b/include/hal-ir-interface.h
new file mode 100644 (file)
index 0000000..f311405
--- /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_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__ */
index 957831a..c0efc47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#ifndef __TIZEN_SYSTEM_IR_H__
-#define __TIZEN_SYSTEM_IR_H__
-
+#ifndef __HAL_IR_H__
+#define __HAL_IR_H__
 
 #include <stdbool.h>
-#include "device-error.h"
-
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_IR_MODULE
- * @{
- */
-
-
-/**
- * @brief Gets the information whether IR module is available.
- * @since_tizen 3.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/use_ir
- * @param[out] available The information whether IR is available
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_ir_is_available(bool *available);
-
-
-/**
- * @brief Transmits IR command.
- * @since_tizen 3.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/use_ir
- * @param[in] carrier_frequency Carrier frequency to transmit IR command (Hertz)
- * @param[in] pattern Integer array of IR command
- * @param[in] size Size of IR command pattern
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_ir_transmit(int carrier_frequency, int *pattern, int size);
-
-
-/**
- * @}
- */
-
+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  /* __TIZEN_SYSTEM_IR_H__ */
+#endif  /* __HAL_IR_H__ */
diff --git a/include/hal-led-interface.h b/include/hal-led-interface.h
new file mode 100644 (file)
index 0000000..d9d5bdd
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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_LED_INTERFACE_H__
+#define __HAL_LED_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum led_type {
+       LED_TYPE_MANUAL,
+       LED_TYPE_BLINK,
+};
+
+struct led_state {
+       /* Led type */
+       enum led_type type;
+       /**
+        * The first byte means opaque and the other 3 bytes are RGB values.
+        * You can use opaque byte as a led brightness value.
+        * If the first byte is 0x00, led will be turned off.
+        * Anything else will be worked as on. The max value is 0xFF.
+        */
+       unsigned int color;
+       /* Turn on time in milliseconds */
+       int duty_on;
+       /* Turn off time in milliseconds */
+       int duty_off;
+};
+
+struct keyled_state {
+       int keycode;
+       int brightness;
+};
+
+typedef struct _hal_backend_led_funcs {
+       /* Set led state */
+       int (*set_state)(struct led_state *state);
+
+       /* Get led state */
+       int (*get_state)(struct led_state **state);
+
+       /* Get led number */
+       int (*get_number)(void);
+
+       /* Set led number */
+       void (*set_num)(int number);
+
+       /* Get max led number */
+       int (*get_max_num)(void);
+
+       /* Set keyled state */
+       int (*keyled_set_state)(struct keyled_state *state);
+
+       /* Get keyled state */
+       int (*keyled_get_state)(int *keycode, int *brightness);
+} hal_backend_led_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_LED_INTERFACE_H__ */
index 2463f2d..7ba6663 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#ifndef __TIZEN_SYSTEM_LED_H__
-#define __TIZEN_SYSTEM_LED_H__
-
-
-#include "device-error.h"
+#ifndef __HAL_LED_H__
+#define __HAL_LED_H__
 
+#include "hal-led-interface.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_LED_MODULE
- * @{
- */
-
-
-/**
- * @brief Gets the max brightness value of a LED that is located next to the camera.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/led
- * @remarks This API is related to the following feature: %http://tizen.org/feature/camera.back.flash
- * @param[out] max_brightness The max brightness value of the LED
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_flash_get_max_brightness(int *max_brightness);
-
-
-/**
- * @brief Gets the brightness value of a LED that is located next to the camera.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/led
- * @remarks This API is related to the following feature: %http://tizen.org/feature/camera.back.flash
- * @param[out] brightness The brightness value of LED (@c 0 ~ MAX)
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_flash_get_brightness(int *brightness);
-
-
-/**
- * @brief Sets the brightness value of a LED that is located next to the camera.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/led
- * @remarks Since @if Mobile 2.4 @elseif WEARABLE 3.0 @endif, this API check camera flash status whether camera API preempted flash or not, so it could be failed if flash was preempted by camera API. In this case, API will return #DEVICE_ERROR_RESOURCE_BUSY error.
- *          This API is related to the following feature: %http://tizen.org/feature/camera.back.flash
- * @param[in] brightness The brightness value of LED (@c 0 ~ MAX)
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @retval #DEVICE_ERROR_RESOURCE_BUSY Device or resource busy
- */
-int device_flash_set_brightness(int brightness);
-
-
-/**
- * @brief Enumeration for custom LED flags.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
-    LED_CUSTOM_DUTY_ON = 1 << 0, /**< blink LED */
-    LED_CUSTOM_DEFAULT = (LED_CUSTOM_DUTY_ON), /**< Default flag */
-} led_custom_flags;
-
-
-/**
- * @brief Plays the custom effect of the service LED that is located to the front of a device.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/led
- * @remarks This API is related to the following feature: %http://tizen.org/feature/led
- * @param[in] on Turn on time in milliseconds
- * @param[in] off Turn off time in milliseconds
- * @param[in] color The Color value \n
- *                  The first byte means opaque and the other 3 bytes are RGB values
- * @param[in] flags The combination of enum #led_custom_flags
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_led_play_custom(int on, int off, unsigned int color, unsigned int flags);
-
-
-/**
- * @brief Stops the custom effect of the service LED that is located to the front of a device.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/led
- * @remarks This API is related to the following feature: %http://tizen.org/feature/led
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- */
-int device_led_stop_custom(void);
-
-
-/**
- * @}
- */
-
+int hal_device_led_get_backend(void);
+int hal_device_led_put_backend(void);
+int hal_device_led_set_state(struct led_state *state);
+int hal_device_led_get_state(struct led_state **state);
+int hal_device_led_get_number(void);
+int hal_device_led_set_number(int number);
+int hal_device_led_get_max_num(void);
+int hal_device_keyled_set_state(struct keyled_state *state);
+int hal_device_keyled_get_state(int *keycode, int *brightness);
 
 #ifdef __cplusplus
 }
 #endif
 
 
-#endif  // __TIZEN_SYSTEM_LED_H__
+#endif  // __HAL_LED_H__
diff --git a/include/hal-temperature.h b/include/hal-temperature.h
deleted file mode 100644 (file)
index 91fea6d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2019 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 __TIZEN_SYSTEM_TEMPERATURE_H__
-#define __TIZEN_SYSTEM_TEMPERATURE_H__
-
-
-#include <stdbool.h>
-#include "device-error.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * @addtogroup CAPI_SYSTEM_DEVICE_THERMAL_MODULE
- * @{
- */
-
-
-/**
- * @brief Enumeration for the device temperature.
- * @since_tizen 5.5
- */
-typedef enum
-{
-    DEVICE_THERMAL_AP,      /**< Temperature for Application Processor */
-    DEVICE_THERMAL_CP,      /**< Temperature for Communication Processor */
-    DEVICE_THERMAL_BATTERY, /**< Temperature for Battery */
-} device_thermal_e;
-
-
-/**
- * @brief Gets the temperature value.
- * @since_tizen 5.5
- * @param[in] type The index of the device
- * @param[out] temp The temperature value in degrees Celsius
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #DEVICE_ERROR_NONE Successful
- * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
- * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
- */
-int device_thermal_get_temperature(device_thermal_e type, int *temp);
-
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif  /* __TIZEN_SYSTEM_TEMPERATURE_H__ */
diff --git a/include/hal-thermal-interface.h b/include/hal-thermal-interface.h
new file mode 100644 (file)
index 0000000..5c33746
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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_TEMPERATURE_INTERFACE_H__
+#define __HAL_TEMPERATURE_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+    DEVICE_THERMAL_AP,      /* AP temperature */
+    DEVICE_THERMAL_CP,      /* CP temperature */
+    DEVICE_THERMAL_BATTERY, /* Battery temperature */
+} device_thermal_e;
+
+struct thermal_info {
+       int temp;
+       int adc;
+};
+
+typedef void (*ThermalUpdated)(struct thermal_info *info, void *data);
+
+typedef struct _hal_backend_thermal_funcs {
+       /* Get thermal state */
+       int (*get_info)(device_thermal_e type, struct thermal_info *info);
+
+       /* Register thermal event */
+       int (*register_changed_event)(ThermalUpdated updated_cb, void *data);
+       int (*unregister_changed_event)(ThermalUpdated updated_cb);
+} hal_backend_thermal_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_TEMPERATURE_INTERFACE_H__ */
diff --git a/include/hal-thermal.h b/include/hal-thermal.h
new file mode 100644 (file)
index 0000000..4cd4493
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_TEMPERATURE_H__
+#define __HAL_TEMPERATURE_H__
+
+#include <hal/hal-common.h>
+#include "hal-thermal-interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int hal_device_thermal_get_backend(void);
+int hal_device_thermal_put_backend(void);
+int hal_device_thermal_get_info(device_thermal_e type, struct thermal_info *info);
+int hal_device_thermal_register_changed_event(ThermalUpdated updated_cb, void *data);
+int hal_device_thermal_unregister_changed_event(ThermalUpdated updated_cb);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  /* __HAL_TEMPERATURE_H__ */
diff --git a/include/hal-touchscreen-interface.h b/include/hal-touchscreen-interface.h
new file mode 100644 (file)
index 0000000..f148736
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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
+
+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
new file mode 100644 (file)
index 0000000..9444559
--- /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_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/include/list.h b/include/list.h
deleted file mode 100644 (file)
index 712ca70..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 __LIST_H__
-#define __LIST_H__
-
-#include <stdio.h>
-
-#define EINA_LIST_APPEND(a, b) \
-       a = eina_list_append(a, b)
-
-#define EINA_LIST_REMOVE(a, b) \
-       a = eina_list_remove(a, b)
-
-#define EINA_LIST_REMOVE_LIST(a, b) \
-       a = eina_list_remove_list(a, b)
-
-#define EINA_LIST_FREE_LIST(a) \
-       a = eina_list_free(a)
-
-#define EINA_LIST_PROMOTE_LIST(a, b) \
-       a = eina_list_promote_list(a, b)
-
-#ifdef EINA_LIST
-#include <Ecore.h>
-typedef Eina_List dd_list;
-#define DD_LIST_PREPEND(a, b)  \
-       a = eina_list_prepend(a, b)
-#define DD_LIST_APPEND(a, b)   \
-       a = eina_list_append(a, b)
-#define DD_LIST_REMOVE(a, b)   \
-       a = eina_list_remove(a, b)
-#define DD_LIST_LENGTH(a)              \
-       eina_list_count(a)
-#define DD_LIST_NTH(a, b)                      \
-       eina_list_nth(a, b)
-#define DD_LIST_FREE_LIST(a)    \
-       a = eina_list_free(a)
-#define DD_LIST_FOREACH(head, elem, node)      \
-       EINA_LIST_FOREACH(head, elem, node)
-#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
-       EINA_LIST_FOREACH_SAFE(head, elem, elem_next, node)
-
-#else
-#include <glib.h>
-typedef GList dd_list;
-#define DD_LIST_PREPEND(a, b)          \
-       a = g_list_prepend(a, (gpointer)b)
-#define DD_LIST_APPEND(a, b)           \
-       a = g_list_append(a, (gpointer)b)
-#define DD_LIST_REMOVE(a, b)           \
-       a = g_list_remove(a, (gpointer)b)
-#define DD_LIST_LENGTH(a)                      \
-       g_list_length(a)
-#define DD_LIST_NTH(a, b)                      \
-       g_list_nth_data(a, b)
-#define DD_LIST_FREE_LIST(a)        \
-       g_list_free(a)
-#define DD_LIST_FOREACH(head, elem, node)      \
-       for (elem = head, node = NULL; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL)
-#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
-       for (elem = head, elem_next = g_list_next(elem), node = NULL; \
-                       elem && ((node = elem->data) != NULL); \
-                       elem = elem_next, elem_next = g_list_next(elem), node = NULL)
-
-#endif
-
-#endif
index 2d404aa..f93b0fc 100644 (file)
@@ -7,14 +7,8 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    hal-api-device.manifest
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(capi-base-common)
-BuildRequires:  pkgconfig(capi-system-device)
-BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(gio-2.0)
-BuildRequires:  pkgconfig(tracker)
-BuildRequires:  pkgconfig(libsyscommon)
+BuildRequires:  pkgconfig(hal-api-common)
 
 %description
 API library for HAL device modules
index 794da65..72d368b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <vconf.h>
-#define _GNU_SOURCE
-#include <dlfcn.h>
-#include <libsyscommon/dbus-system.h>
+#include <hal/hal-common.h>
 
-#include "hal-battery.h"
+#include "hal-battery-interface.h"
 #include "common.h"
-#include <system_info.h>
 
-#define METHOD_GET_PERCENT             "GetPercent"
-#define METHOD_GET_INFO         "GetBatteryInfo"
+static hal_backend_battery_funcs *g_battery_funcs = NULL;
 
-#define BATTERY_FEATURE              "http://tizen.org/feature/battery"
-
-#ifndef LIBPATH
-#error LIBPATH is not defined.
-#endif
-
-#define BATTERY_PLUGIN         LIBPATH"/libbattery-plugin.so"
-#define GET_INFO_FUNC          "battery_get_info_direct"
-
-static void *handle;
-static int (*plugin_battery_get_info)(void *);
-
-static int is_battery_supported(void)
-{
-       int ret;
-       bool battery_avail;
-
-       ret = system_info_get_platform_bool(BATTERY_FEATURE, &battery_avail);
-       if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get value of battery feature");
-               return false;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !battery_avail) {
-//LCOV_EXCL_START System Error
-               _D("Battery is not supported");
-               return false;
-//LCOV_EXCL_STOP
-       } else
-               return true;
-}
-
-
-int device_battery_get_percent(int *percent)
+EXPORT
+int hal_device_battery_get_backend(void)
 {
        int ret;
 
-       if (!percent)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
-                       METHOD_GET_PERCENT, NULL);
-       /* regard not suppoted as disconnected */
-       if (ret == -ENOTSUP)
-               ret = 0;
-       else if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *percent = ret;
-       return DEVICE_ERROR_NONE;
-}
-
-int device_battery_is_charging(bool *charging)
-{
-       int ret, val;
-
-       if (!charging)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &val);
-       /* regard not supported as disconnected */
-       if (val == -ENOTSUP)
-               val = 0; //LCOV_EXCL_LINE System Error
-       else if (ret < 0 || val < 0 || val > 1)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       *charging = val;
-       return DEVICE_ERROR_NONE;
-}
-
-int device_battery_get_level_status(device_battery_level_e *status)
-{
-       int val, ret;
-
-       if (!status)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS, &val);
-       if (ret < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       if (val == VCONFKEY_SYSMAN_BAT_LEVEL_EMPTY)
-               *status = DEVICE_BATTERY_LEVEL_EMPTY;
-       else if (val == VCONFKEY_SYSMAN_BAT_LEVEL_CRITICAL)
-               *status = DEVICE_BATTERY_LEVEL_CRITICAL;
-       else if (val == VCONFKEY_SYSMAN_BAT_LEVEL_LOW)
-               *status = DEVICE_BATTERY_LEVEL_LOW;
-       else if (val == VCONFKEY_SYSMAN_BAT_LEVEL_HIGH)
-               *status = DEVICE_BATTERY_LEVEL_HIGH;
-       else if (val == VCONFKEY_SYSMAN_BAT_LEVEL_FULL)
-               *status = DEVICE_BATTERY_LEVEL_FULL;
-//LCOV_EXCL_START System Error
-       /* regard not supported as disconnected */
-       else if (val == -ENOTSUP)
-               *status = DEVICE_BATTERY_LEVEL_EMPTY;
-//LCOV_EXCL_STOP
-       else
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       return DEVICE_ERROR_NONE;
-}
-
-static int load_battery_plugin()
-{
-       if (plugin_battery_get_info)
-               return 0;
-
-       if (!handle) {
-               handle = dlopen(BATTERY_PLUGIN, RTLD_NOW);
-               if (!handle) {
-//LCOV_EXCL_START System Error
-                       _E("Failed to open '%s' : %s", BATTERY_PLUGIN, dlerror());
-                       return -1;
-//LCOV_EXCL_STOP
-               }
-       }
-
-       plugin_battery_get_info = (int (*)(void *))dlsym(handle, GET_INFO_FUNC);
-       if (!plugin_battery_get_info) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get symbol '%s' : %s", GET_INFO_FUNC, dlerror());
+       if (g_battery_funcs)
                return -1;
-//LCOV_EXCL_STOP
-       }
 
-       return 0;
-}
-
-int device_battery_get_info_direct(struct device_battery_info *info)
-{
-       int ret;
-
-       if (!info)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (load_battery_plugin() < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       ret = plugin_battery_get_info(info);
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_BATTERY, (void **)&g_battery_funcs);
        if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get battery info: %d", ret);
-               return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
+                _E("Failed to get battery backend");
+               return -EINVAL;
        }
 
-       return DEVICE_ERROR_NONE;
+       return 0;
 }
 
-int device_battery_get_info(struct device_battery_info *info)
+EXPORT
+int hal_device_battery_put_backend(void)
 {
-       int ret;
-       GVariant *output = NULL;
-       char *status = NULL;
-       char *health = NULL;
-       char *power_source = NULL;
-       int online;
-       int present;
-       int capacity;
-       int current_now;
-       int current_average;
-       int voltage_now;
-       int voltage_average;
-       int temperature;
-
-       if (!info)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       output = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
-                       METHOD_GET_INFO, NULL);
-
-       if (!output)
-               return DEVICE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE System Error
-
-       g_variant_get(output, "(isssiiiiiiii)", &ret,
-                       &status, &health, &power_source,
-                       &online, &present, &capacity,
-                       &current_now, &current_average, &voltage_now,
-                       &voltage_average, &temperature);
-
-       if (ret < 0) {
-               //LCOV_EXCL_START System Error
-               ret = errno_to_device_error(ret);
-               goto out;
-               //LCOV_EXCL_STOP
-       }
-
-       snprintf(info->status, sizeof(info->status), "%s", status);
-       snprintf(info->health, sizeof(info->health), "%s", health);
-       snprintf(info->power_source, sizeof(info->power_source), "%s", power_source);
-       info->online = online;
-       info->present = present;
-       info->capacity = capacity;
-       info->current_now = current_now;
-       info->current_average = current_average;
-       info->voltage_now = voltage_now;
-       info->voltage_average = voltage_average;
-       info->temperature = temperature;
-
-       ret = DEVICE_ERROR_NONE;
+       if (!g_battery_funcs)
+               return -1;
 
-out:
-       g_free(status);
-       g_free(health);
-       g_free(power_source);
-       g_variant_unref(output);
+       hal_common_put_backend(HAL_MODULE_DEVICE_BATTERY, (void *)g_battery_funcs);
+       g_battery_funcs = NULL;
 
-       return ret;
+       return 0;
 }
 
-int device_battery_get_health(device_battery_health_e *health)
-{
-       struct device_battery_info info;
-       int ret;
-       size_t len;
-
-       if (!health)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = device_battery_get_info(&info);
-       if (ret != DEVICE_ERROR_NONE) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get battery info (%d)", ret);
-               return ret;
-//LCOV_EXCL_STOP
-       }
-
-       len = strlen(info.health);
-       if (!strncmp(info.health, "Good", len))
-               *health = DEVICE_BATTERY_HEALTH_GOOD;
-       else if (!strncmp(info.health, "Cold", len))
-               *health = DEVICE_BATTERY_HEALTH_COLD;
-       else if (!strncmp(info.health, "Dead", len))
-               *health = DEVICE_BATTERY_HEALTH_DEAD;
-       else if (!strncmp(info.health, "Overheat", len))
-               *health = DEVICE_BATTERY_HEALTH_OVER_HEAT;
-       else if (!strncmp(info.health, "Over voltage", len))
-               *health = DEVICE_BATTERY_HEALTH_OVER_VOLTAGE;
-       else
-               return DEVICE_ERROR_OPERATION_FAILED;
 
-       return DEVICE_ERROR_NONE;
-}
-
-int device_battery_get_power_source(device_battery_power_source_e *source)
+EXPORT
+int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *data)
 {
-       struct device_battery_info info;
-       int ret;
-       size_t len;
-
-       if (!source)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = device_battery_get_info(&info);
-       if (ret != DEVICE_ERROR_NONE) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get battery info (%d)", ret);
-               return ret;
-//LCOV_EXCL_STOP
-       }
-
-       len = strlen(info.power_source);
-       if (!strncmp(info.power_source, "ac", len))
-               *source = DEVICE_BATTERY_POWER_SOURCE_AC;
-       else if (!strncmp(info.power_source, "usb", len))
-               *source = DEVICE_BATTERY_POWER_SOURCE_USB;
-       else if (!strncmp(info.power_source, "wireless", len))
-               *source = DEVICE_BATTERY_POWER_SOURCE_WIRELESS;
-       else
-               *source = DEVICE_BATTERY_POWER_SOURCE_NONE;
+       if (!g_battery_funcs ||
+           !g_battery_funcs->register_changed_event)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_battery_funcs->register_changed_event(updated_cb, data);
 }
 
-int device_battery_get_property(device_battery_property_e property, int *val)
+EXPORT
+int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb)
 {
-       struct device_battery_info info = {0, };
-       int ret;
-
-       if (!val)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = device_battery_get_info(&info);
-       if (ret != DEVICE_ERROR_NONE) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get battery info (%d)", ret);
-               return ret;
-//LCOV_EXCL_STOP
-       }
-
-       switch (property) {
-       case DEVICE_BATTERY_PROPERTY_CAPACITY:
-               *val = info.capacity;
-               break;
-       case DEVICE_BATTERY_PROPERTY_CURRENT_NOW:
-               *val = info.current_now;
-               break;
-       case DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE:
-               *val = info.current_average;
-               break;
-       case DEVICE_BATTERY_PROPERTY_VOLTAGE_NOW:
-               *val = info.voltage_now;
-               break;
-       case DEVICE_BATTERY_PROPERTY_VOLTAGE_AVERAGE:
-               *val = info.voltage_average;
-               break;
-       case DEVICE_BATTERY_PROPERTY_TEMPERATURE:
-               *val = info.temperature;
-               break;
-
-       default:
-               return DEVICE_ERROR_INVALID_PARAMETER;
-       }
+       if (!g_battery_funcs ||
+           !g_battery_funcs->unregister_changed_event)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       g_battery_funcs->unregister_changed_event(updated_cb);
+       return 0;
 }
 
-int device_battery_get_status(device_battery_status_e *status)
+EXPORT
+int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data)
 {
-       struct device_battery_info info;
-       int ret;
-       size_t len;
-
-       if (!status)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_battery_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = device_battery_get_info(&info);
-       if (ret != DEVICE_ERROR_NONE) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get battery info (%d)", ret);
-               return ret;
-//LCOV_EXCL_STOP
-       }
-
-       len = strlen(info.status);
-       if (!strncmp(info.status, "Charging", len))
-               *status = DEVICE_BATTERY_STATUS_CHARGING;
-       else if (!strncmp(info.status, "Discharging", len))
-               *status = DEVICE_BATTERY_STATUS_DISCHARGING;
-       else if (!strncmp(info.status, "Full", len))
-               *status = DEVICE_BATTERY_STATUS_FULL;
-       else if (!strncmp(info.status, "Not charging", len))
-               *status = DEVICE_BATTERY_STATUS_NOT_CHARGING;
-       else
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       return DEVICE_ERROR_NONE;
-}
+       if (!g_battery_funcs ||
+           !g_battery_funcs->get_current_state)
+               return -1;
 
-void __attribute__ ((destructor)) battery_finalize(void)
-{
-       if (handle) {
-               dlclose(handle);
-               handle = NULL;
-       }
+       return g_battery_funcs->get_current_state(updated_cb, data);
 }
diff --git a/src/bezel.c b/src/bezel.c
new file mode 100644 (file)
index 0000000..7da993f
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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-bezel-interface.h"
+#include "common.h"
+
+static hal_backend_bezel_funcs *g_bezel_funcs = NULL;
+
+EXPORT
+int hal_device_bezel_get_backend(void)
+{
+       int ret;
+
+       if (g_bezel_funcs)
+               return -1;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_BEZEL, (void **)&g_bezel_funcs);
+       if (ret < 0) {
+                _E("Failed to get bezel backend");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+EXPORT
+int hal_device_bezel_put_backend(void)
+{
+       if (!g_bezel_funcs)
+               return -1;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_BEZEL, (void *)g_bezel_funcs);
+       g_bezel_funcs = NULL;
+
+       return 0;
+}
+
+
+EXPORT
+int hal_device_bezel_get_state(enum bezel_state *state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->get_state)
+               return -1;
+
+       return g_bezel_funcs->get_state(state);
+}
+
+EXPORT
+int hal_device_bezel_set_state(enum bezel_state state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->set_state)
+               return -1;
+
+       return g_bezel_funcs->set_state(state);
+}
+
+EXPORT
+int hal_device_bezel_get_sw_state(enum bezel_state *state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->get_sw_state)
+               return -1;
+
+       return g_bezel_funcs->get_sw_state(state);
+}
+
+EXPORT
+int hal_device_bezel_set_sw_state(enum bezel_state state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->set_sw_state)
+               return -1;
+
+       return g_bezel_funcs->set_sw_state(state);
+}
+
+EXPORT
+int hal_device_bezel_get_vib_state(enum bezel_vib_state *state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->get_vib_state)
+               return -1;
+
+       return g_bezel_funcs->get_vib_state(state);
+}
+
+EXPORT
+int hal_device_bezel_set_vib_state(enum bezel_vib_state state)
+{
+       if (!g_bezel_funcs ||
+           !g_bezel_funcs->set_vib_state)
+               return -1;
+
+       return g_bezel_funcs->set_vib_state(state);
+}
+
diff --git a/src/board.c b/src/board.c
new file mode 100644 (file)
index 0000000..8994be0
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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-board-interface.h"
+#include "common.h"
+
+static hal_backend_board_funcs *g_board_funcs = NULL;
+
+EXPORT
+int hal_device_board_get_backend(void)
+{
+       int ret;
+
+       if (g_board_funcs)
+               return -1;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_BOARD, (void **)&g_board_funcs);
+       if (ret < 0) {
+                _E("Failed to get board backend");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+EXPORT
+int hal_device_board_put_backend(void)
+{
+       if (!g_board_funcs)
+               return -1;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_BOARD, (void *)g_board_funcs);
+       g_board_funcs = NULL;
+
+       return 0;
+}
+
+EXPORT
+int hal_device_board_get_device_serial(char **serial)
+{
+       if (!g_board_funcs ||
+           !g_board_funcs->get_device_serial)
+               return -1;
+
+       return g_board_funcs->get_device_serial(serial);
+}
+
+EXPORT
+int hal_device_board_get_device_revision(int *revision)
+{
+       if (!g_board_funcs ||
+           !g_board_funcs->get_device_revision)
+               return -1;
+
+       return g_board_funcs->get_device_revision(revision);
+}
+
diff --git a/src/common.c b/src/common.c
deleted file mode 100644 (file)
index 893c7b9..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * 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 <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <system_info.h>
-#include "common.h"
-#include <sys/time.h>
-
-#define MAX_LINE       128
-#define MAX_SECTION    64
-#define WHITESPACE     " \t"
-#define NEWLINE                "\n\r"
-#define COMMENT                '#'
-
-#define MODEL_NAME      "http://tizen.org/system/model_name"
-#define MODEL_EMULATOR  "Emulator"
-#define DISPLAY_FEATURE     "http://tizen.org/feature/display"
-#define DISPLAY_STATE_FEATURE     "http://tizen.org/feature/display.state"
-
-static inline char *trim_str(char *s)
-{
-       char *t;
-       /* left trim */
-       s += strspn(s, WHITESPACE);
-
-       /* right trim */
-       for (t = strchr(s, 0); t > s; t--)
-               if (!strchr(WHITESPACE, t[-1]))
-                       break;
-       *t = 0;
-       return s;
-}
-
-int config_parse(const char *file_name, int cb(struct parse_result *result,
-                       void *user_data), void *user_data)
-{
-       FILE *f = NULL;
-       struct parse_result result;
-       /* use stack for parsing */
-       char line[MAX_LINE];
-       char section[MAX_SECTION];
-       char *start, *end, *name, *value;
-       int lineno = 0, ret = 0;
-
-       if (!file_name || !cb) {
-//LCOV_EXCL_START System Error
-               ret = -EINVAL;
-               goto error;
-//LCOV_EXCL_STOP
-       }
-
-       /* open conf file */
-       f = fopen(file_name, "r");
-       if (!f) {
-//LCOV_EXCL_START System Error
-               if (errno == ENOENT) {
-                       _I("There is no power config file");
-                       return 0;
-//LCOV_EXCL_STOP
-               }
-
-//LCOV_EXCL_START System Error
-               _E("Failed to open file %s", file_name);
-               ret = -EIO;
-               goto error;
-//LCOV_EXCL_STOP
-       }
-
-       /* parsing line by line */
-       while (fgets(line, MAX_LINE, f) != NULL) {
-               lineno++;
-
-               start = line;
-               start[strcspn(start, NEWLINE)] = '\0';
-               start = trim_str(start);
-
-               if (*start == COMMENT) {
-                       continue;
-               } else if (*start == '[') {
-                       /* parse section */
-                       end = strchr(start, ']');
-                       if (!end || *end != ']') {
-//LCOV_EXCL_START System Error
-                               ret = -EBADMSG;
-                               goto error;
-//LCOV_EXCL_STOP
-                       }
-
-                       *end = '\0';
-                       strncpy(section, start + 1, sizeof(section));
-                       section[MAX_SECTION-1] = '\0';
-               } else if (*start) {
-                       /* parse name & value */
-                       end = strchr(start, '=');
-                       if (!end || *end != '=') {
-//LCOV_EXCL_START System Error
-                               ret = -EBADMSG;
-                               goto error;
-//LCOV_EXCL_STOP
-                       }
-                       *end = '\0';
-                       name = trim_str(start);
-                       value = trim_str(end + 1);
-                       end = strchr(value, COMMENT);
-                       if (end && *end == COMMENT) {
-                               *end = '\0';
-                               value = trim_str(value);
-                       }
-
-                       result.section = section;
-                       result.name = name;
-                       result.value = value;
-                       /* callback with parse result */
-                       ret = cb(&result, user_data);
-                       if (ret < 0) {
-//LCOV_EXCL_START System Error
-                               ret = -EBADMSG;
-                               goto error;
-//LCOV_EXCL_STOP
-                       }
-               }
-       }
-       _D("Success to load %s", file_name);
-       fclose(f);
-       return 0;
-
-//LCOV_EXCL_START System Error
-error:
-       if (f)
-               fclose(f);
-       _E("Failed to read %s:%d!", file_name, lineno);
-//LCOV_EXCL_STOP
-       return ret;
-}
-
-tizen_profile_t _get_tizen_profile()
-{
-       static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
-       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
-               return profile;
-
-       char *profileName;
-       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
-       switch (*profileName) {
-       case 'm':
-       case 'M':
-               profile = TIZEN_PROFILE_MOBILE;
-               break;
-       case 'w':
-       case 'W':
-               profile = TIZEN_PROFILE_WEARABLE; //LCOV_EXCL_LINE
-               break; //LCOV_EXCL_LINE
-       case 't':
-       case 'T':
-               profile = TIZEN_PROFILE_TV; //LCOV_EXCL_LINE
-               break; //LCOV_EXCL_LINE
-       case 'i':
-       case 'I':
-               profile = TIZEN_PROFILE_IVI; //LCOV_EXCL_LINE
-               break; //LCOV_EXCL_LINE
-       default: // common or unknown ==> ALL ARE COMMON.
-               profile = TIZEN_PROFILE_COMMON; //LCOV_EXCL_LINE
-       }
-       free(profileName);
-
-       return profile;
-}
-
-int check_async_call_rate(long *num_calls)
-{
-       static int status;
-       static struct timeval prev;
-       struct timeval cur;
-       int ret;
-
-       if (status < 0)
-               return status;
-
-       ret = gettimeofday(&cur, NULL);
-       if (ret < 0)
-               return 0;
-
-       if (*num_calls > 0) {
-               long rate;
-               struct timeval diff;
-               timersub(&cur, &prev, &diff);
-
-               if (diff.tv_sec > 0) {
-                       rate = *num_calls / diff.tv_sec;
-
-                       if (rate > CHECK_RATE_THRESHOLD) {
-                               status = -1;
-                               return status;
-                       }
-
-                       if (diff.tv_sec > CHECK_RATE_PERIOD_LEN) {
-                               /* Reset the check period */
-                               *num_calls = 0;
-                               return 0;
-                       }
-               }
-       } else {
-               /* Start a new check period */
-               prev = cur;
-       }
-
-       *num_calls += 1;
-       return 0;
-}
-
-//LCOV_EXCL_START Not used function
-bool is_emulator(void)
-{
-       int ret;
-       char *model_name = NULL;
-       static bool emul = false;
-       static int set = 0;
-
-       if (set)
-               return emul;
-
-       ret = system_info_get_platform_string(MODEL_NAME, &model_name);
-       if (ret < 0) {
-               _E("Cannot get model name(%d)", ret);
-               return emul;
-       }
-
-       if (!strncmp(MODEL_EMULATOR, model_name, strlen(model_name) + 1))
-               emul = true;
-
-       set = 1;
-       free(model_name);
-
-       return emul;
-}
-//LCOV_EXCL_STOP
-
-int is_display_supported(void)
-{
-       int ret;
-       bool display_avail;
-
-       ret = system_info_get_platform_bool(DISPLAY_FEATURE, &display_avail);
-       if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get value of display feature");
-               return false;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !display_avail) {
-//LCOV_EXCL_START System Error
-               _D("Display feature is not supported");
-               return false;
-//LCOV_EXCL_STOP
-       } else
-               return true;
-}
-
-int is_display_state_supported(void)
-{
-       int ret;
-       bool display_state_avail;
-
-       ret = system_info_get_platform_bool(DISPLAY_STATE_FEATURE, &display_state_avail);
-       if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get value of display state feature");
-               return false;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !display_state_avail) {
-//LCOV_EXCL_START System Error
-               _D("Display state feature is not supported");
-               return false;
-//LCOV_EXCL_STOP
-       } else
-               return true;
-}
diff --git a/src/device.c b/src/device.c
deleted file mode 100644 (file)
index 4d580e1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2011 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 <string.h>
-#include <errno.h>
-#include <vconf.h>
-
-#include "hal-device.h"
-#include "hal-display.h"
-#include "common.h"
-
-#define CHECK_ERR(val) \
-       do {    \
-               if (val < 0) {          \
-                       if (errno == ENODEV)    \
-                               return DEVICE_ERROR_NOT_SUPPORTED;      \
-                       return DEVICE_ERROR_OPERATION_FAILED;   \
-               }       \
-       } while (0)
-
-//LCOV_EXCL_START
-int device_get_display_numbers(int* device_number)
-{
-       return device_display_get_numbers(device_number);
-}
-
-int device_get_brightness(int disp_idx, int* value)
-{
-       return device_display_get_brightness(disp_idx, value);
-}
-
-int device_set_brightness(int disp_idx, int new_value)
-{
-       _E("Deprecated api.");
-       return DEVICE_ERROR_NOT_SUPPORTED;
-}
-
-int device_get_max_brightness(int disp_idx, int* max_value)
-{
-       return device_display_get_max_brightness(disp_idx, max_value);
-}
-
-int device_set_brightness_from_settings(int disp_idx)
-{
-       _E("Deprecated api.");
-       return DEVICE_ERROR_NOT_SUPPORTED;
-}
-
-int device_set_brightness_to_settings(int disp_idx, int new_value)
-{
-       return device_display_set_brightness(disp_idx, new_value);
-}
-//LCOV_EXCL_STOP
index 941641c..350944f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#include <stdio.h>
-#include <errno.h>
-#include <vconf.h>
-#include <libsyscommon/dbus-system.h>
+#include <hal/hal-common.h>
 
-#include "hal-display.h"
+#include "hal-display-interface.h"
 #include "common.h"
 
-#define METHOD_GET_DISPLAY_COUNT        "GetDisplayCount"
-#define METHOD_GET_MAX_BRIGHTNESS       "GetMaxBrightness"
-#define METHOD_GET_BRIGHTNESS           "GetBrightness"
-#define METHOD_SET_BRIGHTNESS           "SetBrightness"
-#define METHOD_CHANGE_STATE             "changestate"
-#define METHOD_CHANGE_STATE_BY_REASON   "ChangeStateByReason"
+static hal_backend_display_funcs *g_display_funcs = NULL;
 
-#define STR_LCD_OFF   "lcdoff"
-#define STR_LCD_DIM   "lcddim"
-#define STR_LCD_ON    "lcdon"
-
-static int display_cnt = -1;
-struct display {
-       int normal_max;
-       int dim_max;
-} *display_arr;
-
-static int alloc_display(void)
+EXPORT
+int hal_device_display_get_backend(void)
 {
-       int i;
-
-       if (display_cnt < 0)
-               return -ENODEV;
+       int ret;
 
-       display_arr = malloc(sizeof(struct display) * display_cnt);
-       if (!display_arr)
-               return -ENOMEM;
+       if (g_display_funcs)
+               return 0;
 
-       for (i = 0; i < display_cnt; ++i) {
-               display_arr[i].normal_max = -1;
-               display_arr[i].dim_max = -1;
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_DISPLAY, (void **)&g_display_funcs);
+       if (ret < 0) {
+                _E("Failed to get display backend");
+               return -EINVAL;
        }
 
        return 0;
 }
 
-int device_display_get_numbers(int *device_number)
+EXPORT
+int hal_device_display_put_backend(void)
 {
-       int ret;
+       if (!g_display_funcs)
+               return -1;
 
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (!device_number)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       /* if it is a first request */
-       if (display_cnt < 0) {
-               ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                               DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                               METHOD_GET_DISPLAY_COUNT, NULL);
-               if (ret < 0)
-                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-               display_cnt = ret;
-               alloc_display();
-       }
-
-       *device_number = display_cnt;
-       _I("device_number : %d", *device_number);
-       return DEVICE_ERROR_NONE;
+       hal_common_put_backend(HAL_MODULE_DEVICE_DISPLAY, (void *)g_display_funcs);
+       g_display_funcs = NULL;
+       
+       return 0;
 }
 
-int device_display_get_max_brightness(int display_index, int *max_brightness)
+EXPORT
+int hal_device_display_get_max_brightness(int *brightness)
 {
-       int ret;
-
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_max_brightness)
+               return -1;
 
-       if (!max_brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
-
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (!display_arr && alloc_display() < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       if (display_arr[display_index].normal_max < 0) {
-               ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                               DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                               METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
-               if (ret < 0)
-                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-               display_arr[display_index].normal_max = ret;
-       }
-
-       *max_brightness = display_arr[display_index].normal_max;
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->get_max_brightness(brightness);
 }
 
-int device_display_get_brightness(int display_index, int *brightness)
+EXPORT
+int hal_device_display_get_brightness(int *brightness)
 {
-       int ret;
-
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_brightness)
+               return -1;
 
-       if (!brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
-
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *brightness = ret;
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->get_brightness(brightness);
 }
 
-int device_display_set_brightness(int display_index, int brightness)
+EXPORT
+int hal_device_display_set_brightness(int brightness)
 {
-       int ret, max;
-
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
-
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (display_arr[display_index].normal_max < 0)
-               device_display_get_max_brightness(display_index, &max);
+       if (!g_display_funcs ||
+           !g_display_funcs->set_brightness)
+               return -1;
 
-       if (brightness < 0 || brightness > display_arr[display_index].normal_max)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)DISPLAY_STATE_NORMAL, brightness));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->set_brightness(brightness);
 }
 
-int device_display_get_state(display_state_e *state)
+EXPORT
+int hal_device_display_set_multi_brightness(int brightness, int step, int delay)
 {
-       int ret, val;
-
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (!state)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = vconf_get_int(VCONFKEY_PM_STATE, &val);
-       if (ret < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
+       if (!g_display_funcs ||
+           !g_display_funcs->set_multi_brightness)
+               return -1;
 
-       if (val == VCONFKEY_PM_STATE_NORMAL)
-               *state = DISPLAY_STATE_NORMAL;
-       else if (val == VCONFKEY_PM_STATE_LCDDIM)
-               *state = DISPLAY_STATE_SCREEN_DIM;
-       else if (val == VCONFKEY_PM_STATE_LCDOFF || val == VCONFKEY_PM_STATE_SLEEP)
-               *state = DISPLAY_STATE_SCREEN_OFF;
-       else
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->set_multi_brightness(brightness, step, delay);
 }
 
-static char *get_state_str(display_state_e state)
+EXPORT
+int hal_device_display_get_auto_brightness(float lmax, float lmin, float light, int *brightness)
 {
-       switch (state) {
-       case DISPLAY_STATE_NORMAL:
-               return STR_LCD_ON;
-       case DISPLAY_STATE_SCREEN_DIM:
-               return STR_LCD_DIM;
-       case DISPLAY_STATE_SCREEN_OFF:
-               return STR_LCD_OFF;
-       default:
-               break;
-       }
-       return NULL;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_auto_brightness)
+               return -1;
+
+       return g_display_funcs->get_auto_brightness(lmax, lmin, light, brightness);
 }
 
-static void change_cb(GVariant *result, void *data, GError *err)
+EXPORT
+int hal_device_display_get_state(enum display_state *state)
 {
-       int ret;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_state)
+               return -1;
 
-       if (!result) {
-//LCOV_EXCL_START System Error
-               _E("no message : %s", err->message);
-               return;
-//LCOV_EXCL_STOP
-       }
-
-       g_variant_get(result, "(i)", &ret);
-       _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, ret);
+       return g_display_funcs->get_state(state);
 }
 
-int device_display_change_state(display_state_e state)
+EXPORT
+int hal_device_display_set_state(enum display_state state)
 {
-       char *str;
-       int ret;
-       static int privilege = -1;
-       static long num_calls = 0;
-
-       ret = is_display_state_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (check_async_call_rate(&num_calls) < 0) {
-//LCOV_EXCL_START System Error
-               _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
-                               , CHECK_RATE_THRESHOLD);
-               return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
-       }
-
-       if (state < DISPLAY_STATE_NORMAL || state > DISPLAY_STATE_SCREEN_OFF)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (privilege < 0) {
-               ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                               DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                               METHOD_CHANGE_STATE, g_variant_new("(s)", "privilege check"));
-//LCOV_EXCL_START System Error
-               if (ret < 0)
-                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-//LCOV_EXCL_STOP
-               else
-                       privilege = 1;
-       }
-
-       str = get_state_str(state);
-       if (!str)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_CHANGE_STATE, g_variant_new("(s)", str), change_cb, -1, NULL);
+       if (!g_display_funcs ||
+           !g_display_funcs->set_state)
+               return -1;
 
-       if (ret < 0)
-               ret = errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       return ret;
+       return g_display_funcs->set_state(state);
 }
 
-int device_display_get_max_brightness_state(int display_index, display_state_e state, int *brightness)
+EXPORT
+int hal_device_display_get_image_effect(enum display_image_effect *effect)
 {
-       int ret;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_image_effect)
+               return -1;
 
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (!brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (state > DISPLAY_STATE_SCREEN_DIM)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
-
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (!display_arr && alloc_display() < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                               DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                               METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)state));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+       return g_display_funcs->get_image_effect(effect);
+}
 
-       if (state == DISPLAY_STATE_NORMAL) {
-               display_arr[display_index].normal_max = ret;
-               *brightness = display_arr[display_index].normal_max;
-       } else {
-               display_arr[display_index].dim_max = ret;
-               *brightness = display_arr[display_index].dim_max;
-       }
+EXPORT
+int hal_device_display_set_image_effect(enum display_image_effect effect)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->set_image_effect)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->set_image_effect(effect);
 }
-//LCOV_EXCL_STOP
 
-int device_display_get_brightness_state(int display_index, display_state_e state, int *brightness)
+EXPORT
+int hal_device_display_get_panel_mode(enum display_panel_mode *mode)
 {
-       int ret;
-
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_panel_mode)
+               return -1;
 
-       if (!brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
+       return g_display_funcs->get_panel_mode(mode);
+}
 
-       if (state > DISPLAY_STATE_SCREEN_DIM)
-               return DEVICE_ERROR_INVALID_PARAMETER;
+EXPORT
+int hal_device_display_set_panel_mode(enum display_panel_mode mode)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->set_panel_mode)
+               return -1;
 
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
+       return g_display_funcs->set_panel_mode(mode);
+}
 
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
+EXPORT
+int hal_device_display_get_aod_mode(enum display_aod_mode *mode)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->get_aod_mode)
+               return -1;
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)state));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+       return g_display_funcs->get_aod_mode(mode);
+}
 
-       *brightness = ret;
+EXPORT
+int hal_device_display_get_aod_brightness(int *max, int *normal, int *min, int *charging)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->get_aod_brightness)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->get_aod_brightness(max, normal, min, charging);
 }
 
-int device_display_set_brightness_state(int display_index, display_state_e state, int brightness)
+EXPORT
+int hal_device_display_get_max_frame_rate(int *rate)
 {
-       int ret, max;
+       if (!g_display_funcs ||
+           !g_display_funcs->get_max_frame_rate)
+               return -1;
 
-       ret = is_display_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       return g_display_funcs->get_max_frame_rate(rate);
+}
 
-       if (display_cnt < 0) {
-               ret = device_display_get_numbers(&display_cnt);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
+EXPORT
+int hal_device_display_get_min_frame_rate(int *rate)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->get_min_frame_rate)
+               return -1;
 
-       if (state > DISPLAY_STATE_SCREEN_DIM)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (display_index < 0 || display_index >= display_cnt)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       switch (state) {
-       case DISPLAY_STATE_NORMAL:
-               if (display_arr[display_index].normal_max < 0)
-                       device_display_get_max_brightness_state(display_index, DISPLAY_STATE_NORMAL, &max);
-               if (brightness < 0 || brightness > display_arr[display_index].normal_max)
-                       return DEVICE_ERROR_INVALID_PARAMETER;
-               break;
-       case DISPLAY_STATE_SCREEN_DIM:
-               if (display_arr[display_index].dim_max < 0)
-                       device_display_get_max_brightness_state(display_index, DISPLAY_STATE_SCREEN_DIM, &max);
-               if (brightness < 0 || brightness > display_arr[display_index].dim_max)
-                       return DEVICE_ERROR_INVALID_PARAMETER;
-               break;
-       default:
-               break;
-       }
+       return g_display_funcs->get_min_frame_rate(rate);
+}
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)state, brightness));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+EXPORT
+int hal_device_display_get_frame_rate(int *rate)
+{
+       if (!g_display_funcs ||
+           !g_display_funcs->get_frame_rate)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_display_funcs->get_frame_rate(rate);
 }
 
-int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb)
+EXPORT
+int hal_device_display_set_frame_rate(int rate)
 {
-       int ret;
-
-       ret = dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
-                       METHOD_CHANGE_STATE_BY_REASON, g_variant_new("(isi)", (int)type, reason, timeout), cb, -1, NULL);
+       if (!g_display_funcs ||
+           !g_display_funcs->set_frame_rate)
+               return -1;
 
-       return errno_to_device_error(ret);
+       return g_display_funcs->set_frame_rate(rate);
 }
diff --git a/src/external_connection.c b/src/external_connection.c
new file mode 100644 (file)
index 0000000..a0243cc
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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-external_connection-interface.h"
+#include "common.h"
+
+static hal_backend_external_connection_funcs *g_external_connection_funcs = NULL;
+
+EXPORT
+int hal_device_external_connection_get_backend(void)
+{
+       int ret;
+
+       if (g_external_connection_funcs)
+               return -1;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void **)&g_external_connection_funcs);
+       if (ret < 0) {
+                _E("Failed to get external connection backend");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+EXPORT
+int hal_device_external_connection_put_backend(void)
+{
+       if (!g_external_connection_funcs)
+               return -1;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void *)g_external_connection_funcs);
+       g_external_connection_funcs = NULL;
+
+       return 0;
+}
+
+
+EXPORT
+int hal_device_external_connection_register_changed_event(ConnectionUpdated updated_cb, void *data)
+{
+       if (!g_external_connection_funcs ||
+           !g_external_connection_funcs->register_changed_event)
+               return -1;
+
+       return g_external_connection_funcs->register_changed_event(updated_cb, data);
+}
+
+EXPORT
+int hal_device_external_connection_unregister_changed_event(ConnectionUpdated updated_cb)
+{
+       if (!g_external_connection_funcs ||
+           !g_external_connection_funcs->unregister_changed_event)
+               return -1;
+
+       g_external_connection_funcs->unregister_changed_event(updated_cb);
+       return 0;
+}
+
+EXPORT
+int hal_device_external_connection_get_current_state(ConnectionUpdated updated_cb, void *data)
+{
+       if (!g_external_connection_funcs ||
+           !g_external_connection_funcs->get_current_state)
+               return -1;
+
+       return g_external_connection_funcs->get_current_state(updated_cb, data);
+}
+
diff --git a/src/haptic.c b/src/haptic.c
deleted file mode 100644 (file)
index 09e38e1..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
- *
- * 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 <errno.h>
-#include <stdlib.h>
-#include <system_info.h>
-#include <libsyscommon/dbus-system.h>
-
-#include "hal-haptic.h"
-#include "common.h"
-#include "list.h"
-
-#define SIGNAL_VIBRATOR_INITIATED      "InitiateVibrator"
-
-#define METHOD_GET_COUNT                       "GetCount"
-#define METHOD_OPEN_DEVICE                     "OpenDevice"
-#define METHOD_CLOSE_DEVICE                    "CloseDevice"
-#define METHOD_STOP_DEVICE                     "StopDevice"
-#define METHOD_VIBRATE_MONOTONE                "VibrateMonotone"
-
-#define VIBRATION_FEATURE              "http://tizen.org/feature/feedback.vibration"
-
-enum feedback_e {
-       HAPTIC_FEEDBACK_MIN = 0,
-       HAPTIC_FEEDBACK_MAX = 100,
-};
-
-enum priority_e {
-       HAPTIC_PRIORITY_MIN = 0,
-       HAPTIC_PRIORITY_MIDDLE,
-       HAPTIC_PRIORITY_HIGH,
-};
-
-struct haptic_handle {
-       int index;
-       int handle;
-};
-
-static guint haptic_id = 0;
-static dd_list *handle_list;
-
-static int is_haptic_supported(void)
-{
-       int ret;
-       bool haptic_avail;
-
-       ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
-       if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get value of haptic feature");
-               return false;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !haptic_avail) {
-//LCOV_EXCL_START System Error
-               _D("Haptic is not supported");
-               return false;
-//LCOV_EXCL_STOP
-       } else
-               return true;
-}
-
-int device_haptic_get_count(int *device_number)
-{
-       int ret;
-
-       if (!device_number)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_haptic_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       /* request to deviced to get haptic count */
-       ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_GET_COUNT, NULL);
-       /**
-        * there is no haptic method in no vibration model.
-        * so -ENOTSUP means that haptic count is zero.
-        */
-       if (ret == -ENOTSUP)
-               ret = 0;
-       else if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *device_number = ret;
-       return DEVICE_ERROR_NONE;
-}
-
-//LCOV_EXCL_START Not called Callback
-static void restart_callback(void)
-{
-       dd_list *elem, *elem_next;
-       struct haptic_handle *temp;
-       int ret;
-
-       DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
-               ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                               VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                               METHOD_OPEN_DEVICE, g_variant_new("(i)", temp->index));
-               if (ret < 0) {
-                       _E("Failed to open device");
-                       continue;
-               }
-               temp->handle = ret;
-       }
-
-}
-//LCOV_EXCL_STOP
-
-//LCOV_EXCL_START Not called Callback
-static void haptic_signal_callback(GDBusConnection  *conn,
-                                                       const gchar      *sender,
-                                                       const gchar      *path,
-                                                       const gchar      *iface,
-                                                       const gchar      *signal,
-                                                       GVariant         *param,
-                                                       gpointer          data)
-{
-       size_t iface_len, signal_len;
-
-       if (!param || !sender || !path || !iface || !signal)
-               return;
-
-       iface_len = strlen(iface) + 1;
-       signal_len = strlen(signal) + 1;
-
-       if (strncmp(iface, VIBRATOR_INTERFACE_HAPTIC, iface_len))
-               return;
-
-       if (strncmp(signal, SIGNAL_VIBRATOR_INITIATED, signal_len))
-               return;
-
-       restart_callback();
-}
-//LCOV_EXCL_STOP
-
-int device_haptic_open(int device_index, haptic_device_h *device_handle)
-{
-       dd_list *elem, *elem_next;
-       struct haptic_handle *handle;
-       struct haptic_handle *temp;
-       int ret, max;
-       bool found = false;
-
-       ret = device_haptic_get_count(&max);
-       if (ret < 0)
-               return ret;
-
-       if (device_index < 0 || device_index >= max)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (!device_handle)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_haptic_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       /* request to deviced to open haptic device */
-       ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_OPEN_DEVICE, g_variant_new("(i)", device_index));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
-               if (temp->handle == ret) {
-                       found = true;
-                       temp->index = device_index;
-                       break;
-               }
-       }
-
-       if (!found) {
-               handle = (struct haptic_handle *)malloc(sizeof(struct haptic_handle));
-               if (!handle) {
-//LCOV_EXCL_START System Error
-                       _E("Failed to malloc");
-                       return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
-               }
-
-               handle->handle = ret;
-               handle->index = device_index;
-               DD_LIST_APPEND(handle_list, handle);
-               *device_handle = (haptic_device_h)handle;
-       }
-       if (DD_LIST_LENGTH(handle_list) == 1) {
-               haptic_id = subscribe_dbus_signal(NULL,
-                               VIBRATOR_PATH_HAPTIC,
-                               VIBRATOR_INTERFACE_HAPTIC,
-                               NULL,
-                               haptic_signal_callback,
-                               NULL,
-                               NULL);
-               if (haptic_id <= 0)
-                       _E("Faild to register signal handler"); //LCOV_EXCL_LINE Logs
-       }
-
-       return DEVICE_ERROR_NONE;
-}
-
-int device_haptic_close(haptic_device_h device_handle)
-{
-       dd_list *elem, *elem_next;
-       struct haptic_handle *handle = (struct haptic_handle *)device_handle;
-       struct haptic_handle *temp;
-       int ret;
-       bool found = false;
-
-       if (!device_handle)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_haptic_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
-               if (temp->handle != handle->handle)
-                       continue;
-               found = true;
-               break;
-       }
-
-       if (!found)
-               return DEVICE_ERROR_OPERATION_FAILED;
-       DD_LIST_REMOVE(handle_list, handle);
-
-       /* request to deviced to open haptic device */
-       ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_CLOSE_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle));
-
-       free(handle);
-
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       if (DD_LIST_LENGTH(handle_list) == 0)
-               unsubscribe_dbus_signal(NULL, haptic_id);
-
-       return DEVICE_ERROR_NONE;
-}
-
-int device_haptic_vibrate(haptic_device_h device_handle, int duration, int feedback, haptic_effect_h *effect_handle)
-{
-       dd_list *elem, *elem_next;
-       struct haptic_handle *handle = (struct haptic_handle *)device_handle;
-       struct haptic_handle *temp;
-       int ret, priority;
-       bool found = false;
-
-       if (!device_handle)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (duration < 0)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (feedback < HAPTIC_FEEDBACK_MIN || feedback > HAPTIC_FEEDBACK_MAX)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_haptic_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       priority = HAPTIC_PRIORITY_MIN;
-
-       DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
-               if (temp != handle)
-                       continue;
-               found = true;
-               break;
-       }
-       if (!found)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       /* request to deviced to vibrate haptic device */
-       ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_VIBRATE_MONOTONE,
-                       g_variant_new("(uiii)", (unsigned int)handle->handle, duration, feedback, priority));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       if (effect_handle)
-               *effect_handle = (haptic_effect_h)ret;
-
-       return DEVICE_ERROR_NONE;
-}
-
-int device_haptic_stop(haptic_device_h device_handle, haptic_effect_h effect_handle)
-{
-       dd_list *elem, *elem_next;
-       struct haptic_handle *handle = (struct haptic_handle *)device_handle;
-       struct haptic_handle *temp;
-       int ret;
-       bool found = false;
-
-       if (!device_handle)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_haptic_supported();
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
-               if (temp != handle)
-                       continue;
-               found = true;
-               break;
-       }
-       if (!found)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       /* TODO : support to stop haptic effect */
-
-       /* request to deviced to open haptic device */
-       ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
-                       VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
-                       METHOD_STOP_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       return DEVICE_ERROR_NONE;
-}
index aa0ed20..95375c3 100644 (file)
--- a/src/ir.c
+++ b/src/ir.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 #include <stdio.h>
-#include <system_info.h>
-#include <libsyscommon/dbus-system.h>
+#include <hal/hal-common.h>
 
-#include "hal-ir.h"
+#include "hal-ir-interface.h"
 #include "common.h"
 
-#define METHOD_IS_AVAILABLE            "IRIsAvailable"
-#define METHOD_TRANSMIT                        "TransmitIR"
-#define IR_FEATURE                     "http://tizen.org/feature/consumer_ir"
+static hal_backend_ir_funcs *g_ir_funcs = NULL;
 
-
-int device_ir_is_available(bool *available)
+EXPORT
+int hal_device_ir_get_backend(void)
 {
        int ret;
-       bool ir_avail;
-
-       if (!available)
-               return DEVICE_ERROR_INVALID_PARAMETER;
 
-       ret = system_info_get_platform_bool(IR_FEATURE, &ir_avail);
+       if (g_ir_funcs)
+               return -1;
 
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_IR, (void **)&g_ir_funcs);
        if (ret < 0) {
-//LCOV_EXCL_START System Error
-               *available = false;
-               return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !ir_avail) {
-               *available = false;
-               return DEVICE_ERROR_NOT_SUPPORTED;
+                _E("Failed to get ir backend");
+               return -EINVAL;
        }
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR,
-                       DEVICED_INTERFACE_IR, METHOD_IS_AVAILABLE,
-                       NULL);
-
-//LCOV_EXCL_START System Error
-       if (ret == -EACCES || ret == -EPERM)
-               return DEVICE_ERROR_PERMISSION_DENIED;
-       if (!ret) {
-               *available = false;
-               return DEVICE_ERROR_OPERATION_FAILED;
-       }
-//LCOV_EXCL_STOP
-
-       *available = ir_avail;
-       return DEVICE_ERROR_NONE;
+       return 0;
 }
 
-int device_ir_transmit(int carrier_frequency, int *pattern, int size)
+EXPORT
+int hal_device_ir_put_backend(void)
 {
-       int ret;
-       int i;
-       bool ir_avail;
-       GVariantBuilder *builder;
+       if (!g_ir_funcs)
+               return -1;
 
-       ret = device_ir_is_available(&ir_avail);
-       if (!ir_avail) {
-               if (ret < 0) {
-                       _E("IR is not supported or IR operation failed");
-                       return ret;
-               }
-//LCOV_EXCL_START System Error
-               _E("IR is not supported");
-               return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
-       }
-//LCOV_EXCL_START System Error
-       if (!pattern)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-       if (size <= 0) {
-               _E("IR pattern size is invalid");
-               return DEVICE_ERROR_INVALID_PARAMETER;
-       }
-//LCOV_EXCL_STOP
-       builder = g_variant_builder_new(G_VARIANT_TYPE ("ai"));
+       hal_common_put_backend(HAL_MODULE_DEVICE_IR, (void *)g_ir_funcs);
+       g_ir_funcs = NULL;
+
+       return 0;
+}
 
-       g_variant_builder_add(builder, "i", carrier_frequency);
-       for (i = 0; i < size; ++i)
-               g_variant_builder_add(builder, "i", pattern[i]);
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR,
-                       DEVICED_INTERFACE_IR, METHOD_TRANSMIT,
-                       g_variant_new("(ai)", builder));
+EXPORT
+int hal_device_ir_is_available(bool *available)
+{
+       if (!g_ir_funcs ||
+           !g_ir_funcs->is_available)
+               return -1;
 
-       g_variant_builder_unref(builder);
-//LCOV_EXCL_START System Error
-       if (ret == -EACCES || ret == -EPERM)
-               return DEVICE_ERROR_PERMISSION_DENIED;
-       if (ret < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-//LCOV_EXCL_STOP
+       return g_ir_funcs->is_available(available);
+}
+
+EXPORT
+int hal_device_ir_transmit(int *frequency_pattern, int size)
+{
+       if (!g_ir_funcs ||
+           !g_ir_funcs->transmit)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_ir_funcs->transmit(frequency_pattern, size);
 }
index c3ddb4a..1d09ceb 100644 (file)
--- a/src/led.c
+++ b/src/led.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  */
 
 
-#include <stdio.h>
 #include <stdbool.h>
-#include <errno.h>
-#include <system_info.h>
-#include <libsyscommon/dbus-system.h>
+#include <hal/hal-common.h>
 
-#include "hal-led.h"
 #include "common.h"
+#include "hal-led-interface.h"
 
-#define METHOD_GET_MAX_BRIGHTNESS      "GetMaxBrightness"
-#define METHOD_GET_BRIGHTNESS          "GetBrightness"
-#define METHOD_SET_BRIGHTNESS          "SetBrightness"
-#define METHOD_PLAY_CUSTOM             "playcustom"
-#define METHOD_GET_LED_NUMBER          "GetNumOfLeds"
-#define METHOD_MULTI_LED_CONTROL       "multi_led_control"
-#define METHOD_STOP_CUSTOM             "stopcustom"
+static hal_backend_led_funcs *g_led_funcs = NULL;
 
-#define FRONT_LED_FEATURE              "tizen.org/feature/led"
-#define CAMERA_LED_FEATURE             "tizen.org/feature/camera.back.flash"
-
-static bool support_front_led;
-static bool support_camera_led;
-static int number_of_devices = -1;
-
-static void __CONSTRUCTOR__ init(void)
+EXPORT
+int hal_device_led_get_backend(void)
 {
        int ret;
-       bool val;
 
-       ret = system_info_get_platform_bool(FRONT_LED_FEATURE, &val);
-       if (ret == SYSTEM_INFO_ERROR_NONE && val)
-               support_front_led = true;
+       if (g_led_funcs)
+               return -1;
 
-       ret = system_info_get_platform_bool(CAMERA_LED_FEATURE, &val);
-       if (ret == SYSTEM_INFO_ERROR_NONE && val)
-               support_camera_led = true;
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_LED, (void **)&g_led_funcs);
+       if (ret < 0) {
+                _E("Failed to get led backend");
+               return -EINVAL;
+       }
+
+       return 0;
 }
 
-int device_flash_get_max_brightness(int *max_brightness)
+EXPORT
+int hal_device_led_put_backend(void)
 {
-       int ret;
+       if (!g_led_funcs)
+               return -1;
 
-       if (!support_camera_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       hal_common_put_backend(HAL_MODULE_DEVICE_LED, (void *)g_led_funcs);
+       g_led_funcs = NULL;
 
-       if (!max_brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_GET_MAX_BRIGHTNESS, NULL);
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *max_brightness = ret;
-       return DEVICE_ERROR_NONE;
+       return 0;
 }
 
-int device_flash_get_brightness(int *brightness)
+EXPORT
+int hal_device_led_set_state(struct led_state *state)
 {
-       int ret;
-
-       if (!support_camera_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       if (!g_led_funcs ||
+           !g_led_funcs->set_state)
+               return -1;
 
-       if (!brightness)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_GET_BRIGHTNESS, NULL);
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *brightness = ret;
-       return DEVICE_ERROR_NONE;
+       return g_led_funcs->set_state(state);
 }
 
-int device_flash_set_brightness(int brightness)
+EXPORT
+int hal_device_led_get_state(struct led_state **state)
 {
-       int max, ret;
-
-       if (!support_camera_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = device_flash_get_max_brightness(&max);
-       if (ret < 0)
-               return ret;
-
-       if (brightness < 0 || brightness > max)
-               return DEVICE_ERROR_INVALID_PARAMETER;
+       if (!g_led_funcs ||
+           !g_led_funcs->get_state)
+               return -1;
 
-       /* if camera API preempt a flash device, it will return -EBUSY error. */
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", brightness, 0));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       return DEVICE_ERROR_NONE;
+       return g_led_funcs->get_state(state);
 }
 
-int device_led_play_custom(int on, int off, unsigned int color, unsigned int flags)
+EXPORT
+int hal_device_led_get_number(void)
 {
-       int ret;
-
-       if (!support_front_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (on < 0 || off < 0)
-               return DEVICE_ERROR_INVALID_PARAMETER;
+       if (!g_led_funcs ||
+           !g_led_funcs->get_number)
+               return -1;
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_PLAY_CUSTOM, g_variant_new("(iiuu)", on, off, (unsigned int)color, (unsigned int)flags));
-//LCOV_EXCL_START System Error
-       if (ret < 0)
-               return errno_to_device_error(ret);
-//LCOV_EXCL_STOP
-
-       return DEVICE_ERROR_NONE;
+       return g_led_funcs->get_number();
 }
 
-int device_led_stop_custom(void)
+EXPORT
+int hal_device_led_set_number(int number)
 {
-       int ret;
-
-       if (!support_front_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
+       if (!g_led_funcs ||
+           !g_led_funcs->set_num)
+               return -1;
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                       METHOD_STOP_CUSTOM, NULL);
-//LCOV_EXCL_START System Error
-       if (ret < 0)
-               return errno_to_device_error(ret);
-//LCOV_EXCL_STOP
+       g_led_funcs->set_num(number);
 
-       return DEVICE_ERROR_NONE;
+       return 0;
 }
 
-int device_multi_led_get_number(int *num_of_leds)
+EXPORT
+int hal_device_led_get_max_num(void)
 {
-       int ret;
-
-       if (!support_front_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (!num_of_leds)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (number_of_devices < 0) {
-               ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                               DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
-                               METHOD_GET_LED_NUMBER, NULL);
-               if (ret < 0)
-                       return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-               number_of_devices = ret;
-       }
-
-       *num_of_leds = number_of_devices;
+       if (!g_led_funcs ||
+           !g_led_funcs->get_max_num)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_led_funcs->get_max_num();
 }
 
-int device_multi_led_control(unsigned int color[])
+EXPORT
+int hal_device_keyled_set_state(struct keyled_state *state)
 {
-       GVariantBuilder *builder = NULL;
-       GVariant *var = NULL;
-       int i, ret;
+       if (!g_led_funcs ||
+           !g_led_funcs->keyled_set_state)
+               return -1;
 
-       if (!support_front_led)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       if (color == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       if (number_of_devices < 0) {
-               ret = device_multi_led_get_number(&number_of_devices);
-               if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
-                       return ret;
-       }
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("au"));
-       for (i = 0; i < number_of_devices; i++)
-               g_variant_builder_add(builder, "u", color[i]);
-
-       var = g_variant_new("(au)", builder);
-       g_variant_builder_unref(builder);
+       return g_led_funcs->keyled_set_state(state);
+}
 
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED,
-                               DEVICED_INTERFACE_LED, METHOD_MULTI_LED_CONTROL, var);
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+EXPORT
+int hal_device_keyled_get_state(int *keycode, int *brightness)
+{
+       if (!g_led_funcs ||
+           !g_led_funcs->keyled_get_state)
+               return -1;
 
-       return DEVICE_ERROR_NONE;
+       return g_led_funcs->keyled_get_state(keycode, brightness);
 }
+
diff --git a/src/memory.c b/src/memory.c
deleted file mode 100644 (file)
index 58f3adf..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * capi-system-device
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "hal-device.h"
-#include "common.h"
-
-#define PROC_MEMORY            "/proc/meminfo"
-
-enum {
-       _MI_TOTAL,
-       _MI_FREE,
-       _MI_BUF,
-       _MI_CACHED,
-       _MI_SWAP,
-       _MI_SHMEM,
-       _MI_MAX,
-};
-
-struct meminfo {
-       unsigned long l[_MI_MAX];
-};
-
-static const char *_mi_str[] = {
-       [_MI_TOTAL] = "MemTotal",
-       [_MI_FREE] = "MemFree",
-       [_MI_BUF] = "Buffers",
-       [_MI_CACHED] = "Cached",
-       [_MI_SWAP] = "SwapCached",
-       [_MI_SHMEM] = "Shmem",
-};
-
-//LCOV_EXCL_START Not used function
-static inline int _get_idx(const char *name)
-{
-       int i;
-
-       for (i = 0; i < sizeof(_mi_str)/sizeof(_mi_str[0]); ++i) {
-               if (name && _mi_str[i] && !strcmp(name, _mi_str[i]))
-                       return i;
-       }
-
-       return -1;
-}
-
-static int _get_meminfo(struct meminfo *mi)
-{
-       FILE *fp;
-       char buf[4096];
-       char *s, *name, *num;
-       int idx;
-
-       assert(mi);
-
-       fp = fopen(PROC_MEMORY, "r");
-       if (!fp)
-               return -1;
-
-       memset(mi, 0, sizeof(*mi));
-
-       while (!feof(fp)) {
-               s = fgets(buf, sizeof(buf), fp);
-               if (!s)
-                       break;
-
-               s = strchr(buf, ':');
-               if (!s)
-                       continue;
-
-               *s = '\0';
-               name = buf;
-
-               s++;
-               while (*s == ' ')
-                       s++;
-               num = s;
-
-               idx = _get_idx(name);
-               if (idx < 0)
-                       continue;
-
-               mi->l[idx] = strtol(num, NULL, 10);
-       }
-
-       fclose(fp);
-       return 0;
-}
-
-int device_memory_get_total(unsigned int *total_mem)
-{
-       struct meminfo mi;
-       int ret;
-
-       if (total_mem == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = _get_meminfo(&mi);
-       if (ret < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       *total_mem = mi.l[_MI_TOTAL];
-       return DEVICE_ERROR_NONE;
-}
-
-int device_memory_get_available(unsigned int *avail_mem)
-{
-       struct meminfo mi;
-       int ret;
-
-       if (avail_mem == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = _get_meminfo(&mi);
-       if (ret < 0)
-               return DEVICE_ERROR_OPERATION_FAILED;
-
-       *avail_mem = mi.l[_MI_FREE] + mi.l[_MI_BUF] + mi.l[_MI_CACHED] + mi.l[_MI_SWAP] - mi.l[_MI_SHMEM];
-       return DEVICE_ERROR_NONE;
-}
-//EXCL_LCOV_STOP
diff --git a/src/temperature.c b/src/temperature.c
deleted file mode 100644 (file)
index 36545cc..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2019 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 <stdlib.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <glib.h>
-#include <system_info.h>
-#include <libsyscommon/dbus-system.h>
-
-#include "common.h"
-#include "hal-temperature.h"
-
-#define METHOD_GET_TEMPERATURE   "GetTemperature"
-
-#define THERMAL_AP_FEATURE             "http://tizen.org/feature/thermistor.ap"
-#define THERMAL_CP_FEATURE             "http://tizen.org/feature/thermistor.cp"
-#define THERMAL_BATTERY_FEATURE                "http://tizen.org/feature/thermistor.battery"
-
-static int is_temperature_supported(device_thermal_e type)
-{
-       int ret = 0;
-       bool thermal_avail;
-
-       if (type == DEVICE_THERMAL_AP)
-               ret = system_info_get_platform_bool(THERMAL_AP_FEATURE, &thermal_avail);
-       else if (type == DEVICE_THERMAL_CP)
-               ret = system_info_get_platform_bool(THERMAL_CP_FEATURE, &thermal_avail);
-       else
-               ret = system_info_get_platform_bool(THERMAL_BATTERY_FEATURE, &thermal_avail);
-       if (ret < 0) {
-//LCOV_EXCL_START System Error
-               _E("Failed to get value of temp feature : %d", ret);
-               return false;
-//LCOV_EXCL_STOP
-       } else if (ret == 0 && !thermal_avail) {
-//LCOV_EXCL_START System Error
-               _D("Temperature is not supported");
-               return false;
-//LCOV_EXCL_STOP
-       } else
-               return true;
-}
-
-int device_thermal_get_temperature(device_thermal_e type, int *temp)
-{
-       int ret;
-
-       if (type > DEVICE_THERMAL_BATTERY)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = is_temperature_supported(type);
-       if (!ret)
-               return DEVICE_ERROR_NOT_SUPPORTED;
-
-       ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME,
-                       DEVICED_PATH_TEMPERATURE,
-                       DEVICED_INTERFACE_TEMPERATURE,
-                       METHOD_GET_TEMPERATURE, g_variant_new("(i)", type));
-       if (ret < 0)
-               return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
-
-       *temp = ret;
-       return DEVICE_ERROR_NONE;
-}
-
diff --git a/src/thermal.c b/src/thermal.c
new file mode 100644 (file)
index 0000000..45e6943
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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 <hal/hal-common.h>
+
+#include "common.h"
+#include "hal-thermal-interface.h"
+
+static hal_backend_thermal_funcs *g_thermal_funcs = NULL;
+
+EXPORT
+int hal_device_thermal_get_backend(void)
+{
+       int ret;
+
+       if (g_thermal_funcs)
+               return -1;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_THERMAL, (void **)&g_thermal_funcs);
+       if (ret < 0) {
+                _E("Failed to get thermal backend");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+EXPORT
+int hal_device_thermal_put_backend(void)
+{
+       if (!g_thermal_funcs)
+               return -1;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_THERMAL, (void *)g_thermal_funcs);
+       g_thermal_funcs = NULL;
+
+       return 0;
+}
+
+EXPORT
+int hal_device_thermal_get_info(device_thermal_e type, struct thermal_info *info)
+{
+       if (!g_thermal_funcs ||
+           !g_thermal_funcs->get_info)
+               return -1;
+
+       return g_thermal_funcs->get_info(type, info);
+}
+
+EXPORT
+int hal_device_thermal_register_changed_event(ThermalUpdated updated_cb, void *data)
+{
+       if (!g_thermal_funcs ||
+           !g_thermal_funcs->register_changed_event)
+               return -1;
+
+       return g_thermal_funcs->register_changed_event(updated_cb, data);
+}
+
+EXPORT
+int hal_device_thermal_unregister_changed_event(ThermalUpdated updated_cb)
+{
+       if (!g_thermal_funcs ||
+           !g_thermal_funcs->unregister_changed_event)
+               return -1;
+
+       return g_thermal_funcs->unregister_changed_event(updated_cb);
+}
+
index 1dc0eaa..c718d45 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ * 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.
  * limitations under the License.
  */
 
-#include <libsyscommon/dbus-system.h>
 
+#include <stdio.h>
+#include <hal/hal-common.h>
+
+#include "hal-touchscreen-interface.h"
 #include "common.h"
 
-#define METHOD_TOUCHSCREEN_ENABLE  "Enable"
-#define METHOD_TOUCHSCREEN_DISABLE "Disable"
+static hal_backend_touchscreen_funcs *g_touchscreen_funcs = NULL;
 
-int device_touchscreen_enable(dbus_pending_cb cb)
+EXPORT
+int hal_device_touchscreen_get_backend(void)
 {
        int ret;
 
-       ret = dbus_handle_method_async_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH,
-                       METHOD_TOUCHSCREEN_ENABLE, NULL, NULL, cb, -1, NULL);
+       if (g_touchscreen_funcs)
+               return -1;
+
+       ret = hal_common_get_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void **)&g_touchscreen_funcs);
+       if (ret < 0) {
+                _E("Failed to get touchscreen backend");
+               return -EINVAL;
+       }
 
-       return errno_to_device_error(ret);
+       return 0;
 }
 
-int device_touchscreen_disable(dbus_pending_cb cb)
+EXPORT
+int hal_device_touchscreen_put_backend(void)
 {
-       int ret;
+       if (!g_touchscreen_funcs)
+               return -1;
+
+       hal_common_put_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void *)g_touchscreen_funcs);
+       g_touchscreen_funcs = NULL;
+
+       return 0;
+}
+
+
+EXPORT
+int hal_device_touchscreen_get_state(enum touchscreen_state *state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->get_state)
+               return -1;
+
+       return g_touchscreen_funcs->get_state(state);
+}
+
+EXPORT
+int hal_device_touchscreen_set_state(enum touchscreen_state state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->set_state)
+               return -1;
+
+       return g_touchscreen_funcs->set_state(state);
+}
+
+EXPORT
+int hal_device_touchscreen_get_powersaving(int *state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->get_powersaving)
+               return -1;
+
+       return g_touchscreen_funcs->get_powersaving(state);
+}
+
+EXPORT
+int hal_device_touchscreen_set_powersaving(int state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->set_powersaving)
+               return -1;
 
-       ret = dbus_handle_method_async_with_reply(DEVICED_BUS_NAME,
-                       DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH,
-                       METHOD_TOUCHSCREEN_DISABLE, NULL, NULL, cb, -1, NULL);
+       return g_touchscreen_funcs->set_powersaving(state);
+}
+
+EXPORT
+int hal_device_touchscreen_glove_mode_get_state(int *state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->glove_mode_get_state)
+               return -1;
+
+       return g_touchscreen_funcs->glove_mode_get_state(state);
+}
+
+EXPORT
+int hal_device_touchscreen_glove_mode_set_state(int state)
+{
+       if (!g_touchscreen_funcs ||
+           !g_touchscreen_funcs->glove_mode_set_state)
+               return -1;
 
-       return errno_to_device_error(ret);
+       return g_touchscreen_funcs->glove_mode_set_state(state);
 }