* WARNING: if this patch is applied only, it cannot be built.
please apply the series of the patches
Change-Id: I3095e9c7b387a0e00cddf5b4086fb18331584231
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
BuildRequires: pkgconfig(cynara-session)
Requires: libsensord = %{version}-%{release}
-%define auto_rotation_state ON
+%define auto_rotation_state OFF
%define orientation_state OFF
%define gravity_state OFF
%define linear_accel_state OFF
%define gaming_rv_state OFF
%define tilt_state OFF
%define gyroscope_uncal_state OFF
-%define build_test_suite ON
+%define build_test_suite OFF
%description
Sensor daemon
#ifndef __SENSOR_COMMON_H__
#define __SENSOR_COMMON_H__
+#include <sensor_hal.h>
+#include <sensor_types.h>
+#include <stdint.h>
+
#ifndef DEPRECATED
#define DEPRECATED __attribute__((deprecated))
#endif
{
#endif
-/**
- * @defgroup SENSOR_FRAMEWORK SensorFW
- * To support the unified API for the various sensors
- */
-
-/**
- * @defgroup SENSOR_FRAMEWORK_COMMON Sensor Framework Common API
- * @ingroup SENSOR_FRAMEWORK
- *
- * These APIs are used to control the sensors.
- * @{
- */
-
-typedef unsigned int sensor_id_t;
+/*
+typedef union {
+ struct {
+ sensor_type_t type;
+ int16_t sensor_id;
+ int16_t device_id;
+ } __attribute__((packed));
+ int64_t id;
+} sensor_id_t;
+*/
+typedef int64_t sensor_id_t;
typedef void *sensor_t;
SENSOR_PRIVILEGE_INTERNAL,
} sensor_privilege_t;
-
-#define SENSOR_DATA_VALUE_SIZE 16
-
-/*
- * When modifying it, check copy_sensor_data()
- */
-typedef struct sensor_data_t {
-/*
- * Use "accuracy" instead of "data_accuracy"
- * which is going to be removed soon
- */
- union {
- int accuracy;
- int data_accuracy; //deprecated
- };
-
- union {
- unsigned long long timestamp;
- unsigned long long time_stamp; //deprecated
- };
-
-/*
- * Use "value_count" instead of "values_num"
- * which is going to be removed soon
- */
- union {
- int value_count;
- int values_num; //deprecated
- };
-
- float values[SENSOR_DATA_VALUE_SIZE];
-} sensor_data_t;
-
#define SENSOR_HUB_DATA_SIZE 4096
typedef struct sensorhub_data_t {
float data[16];
} sensorhub_data_t;
-enum sensor_accuracy_t {
- SENSOR_ACCURACY_UNDEFINED = -1,
- SENSOR_ACCURACY_BAD = 0,
- SENSOR_ACCURACY_NORMAL =1,
- SENSOR_ACCURACY_GOOD = 2,
- SENSOR_ACCURACY_VERYGOOD = 3
-};
-
/*
* To prevent naming confliction as using same enums as sensor CAPI use
*/
SENSOR_INTERVAL_NORMAL = 200,
};
-
typedef enum {
CONDITION_NO_OP,
CONDITION_EQUAL,
#define _SENSOR_HAL_H_
#include <stdint.h>
+
+#ifdef __cplusplus
#include <string>
#include <vector>
-#include <sensor_common.h>
-#include <sf_common.h>
+#endif /* __cplusplus */
#define SENSOR_HAL_VERSION(maj,min) \
((((maj) & 0xffff) << 24) | ((min) & 0xffff))
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
/*
* Sensor Types
* These types are used to controll the sensors
SENSOR_DEVICE_ROTATION_VECTOR_RAW,
} sensor_device_type;
+typedef struct sensor_info_t {
+ const char *model_name;
+ const char *vendor;
+ float min_range;
+ float max_range;
+ float resolution;
+ int min_interval;
+ int max_batch_count;
+ bool wakeup_supported;
+} sensor_info_t;
+
/*
* A platform sensor handler is generated based on this handle
* ID can be assigned from HAL developer. so it has to be unique in HAL.
*/
typedef struct sensor_handle_t {
- uint32_t id;
- std::string name;
+ uint16_t id;
+ const char *name;
sensor_device_type type;
unsigned int event_type; // for Internal API
- sensor_properties_s properties;
+ sensor_info_t info;
} sensor_handle_t;
+enum sensor_accuracy_t {
+ SENSOR_ACCURACY_UNDEFINED = -1,
+ SENSOR_ACCURACY_BAD = 0,
+ SENSOR_ACCURACY_NORMAL =1,
+ SENSOR_ACCURACY_GOOD = 2,
+ SENSOR_ACCURACY_VERYGOOD = 3
+};
+
+#define SENSOR_DATA_VALUE_SIZE 16
+
+/* sensor_data_t */
+typedef struct sensor_data_t {
+ int accuracy;
+ unsigned long long timestamp;
+ int value_count;
+ float values[SENSOR_DATA_VALUE_SIZE];
+} sensor_data_t;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+typedef struct {
+ std::vector<void*> devices;
+} sensor_devices;
+
+typedef sensor_devices* (*create_t)(void);
+
/*
* Sensor device interface
- * 1 HAL must be abstracted from 1 device event node
+ * 1 device must be abstracted from 1 device event node
*/
class sensor_device
{
virtual int get_poll_fd(void) = 0;
virtual bool get_sensors(std::vector<sensor_handle_t> &sensors) = 0;
- /* enable/disable sensor device */
- virtual bool enable(uint32_t id) = 0;
- virtual bool disable(uint32_t id) = 0;
-
- /* set_command or set_option? */
- virtual bool set_command(uint32_t id, std::string command, std::string value) = 0;
+ virtual bool enable(uint16_t id) = 0;
+ virtual bool disable(uint16_t id) = 0;
- /* the belows can be merged to one */
- virtual bool set_interval(uint32_t id, unsigned long val) = 0;
- virtual bool set_batch_latency(uint32_t id, unsigned long val) = 0;
+ virtual bool set_interval(uint16_t id, unsigned long val) = 0;
+ virtual bool set_batch_latency(uint16_t id, unsigned long val) = 0;
+ virtual bool set_attribute(uint16_t id, int32_t attribute, int32_t value) = 0;
- /* sensor fw read the data when is_data_ready() is true */
- virtual bool is_data_ready() = 0;
- virtual bool get_sensor_data(uint32_t id, sensor_data_t &data) = 0;
- virtual int get_sensor_event(uint32_t id, sensor_event_t **event) = 0;
+ virtual bool read_fd(std::vector<uint16_t> &ids) = 0;
+ virtual int get_data(uint16_t id, sensor_data_t **data) = 0;
- /* TODO: use get_sensors() instead of get_properties() */
- virtual bool get_properties(uint32_t id, sensor_properties_s &properties) = 0;
+ virtual bool flush(uint16_t id) = 0;
};
+#endif /* __cplusplus */
+
#endif /* _SENSOR_HAL_H_ */
#define CLIENT_ID_INVALID -1
-#define SENSOR_TYPE_MASK 0xFFFF
-
enum packet_type_t {
CMD_NONE = 0,
CMD_GET_ID,
typedef struct {
int client_id;
- int sensor;
+ sensor_id_t sensor;
} cmd_hello_t;
typedef struct {
typedef struct {
int data_len;
- char data[0];
+ int data;
} cmd_send_sensorhub_data_t;
#define EVENT_CHANNEL_MAGIC 0xCAFECAFE
int client_id;
} event_channel_ready_t;
-
-typedef struct {
- std::string name;
- std::string vendor;
- float min_range;
- float max_range;
- float resolution;
- int min_interval;
- int fifo_count;
- int max_batch_count;
- bool wakeup_supported;
-} sensor_properties_s;
-
-
-/*
- * When modifying it, check copy_sensor*_data()
- */
typedef struct sensor_event_t {
unsigned int event_type;
sensor_id_t sensor_id;
- sensor_data_t data;
+ unsigned int data_length;
+ sensor_data_t *data;
} sensor_event_t;
-
typedef struct sensorhub_event_t {
unsigned int event_type;
sensor_id_t sensor_id;
+ unsigned int data_length;
sensorhub_data_t data;
} sensorhub_event_t;
-typedef struct sensor_devices {
- std::vector<void*> devices;
-} sensor_devices;
-
-typedef sensor_devices* (*create_t)(void);
-
typedef void *(*cmd_func_t)(void *data, void *cb_data);
typedef std::vector<unsigned int> event_type_vector;
-enum sensorhub_enable_bit {
- SENSORHUB_ACCELEROMETER_ENABLE_BIT = 0,
- SENSORHUB_GYROSCOPE_ENABLE_BIT,
- SENSORHUB_GEOMAGNETIC_UNCALIB_ENABLE_BIT,
- SENSORHUB_GEOMAGNETIC_RAW_ENABLE_BIT,
- SENSORHUB_GEOMAGNETIC_ENABLE_BIT,
- SENSORHUB_PRESSURE_ENABLE_BIT,
- SENSORHUB_GESTURE_ENABLE_BIT,
- SENSORHUB_PROXIMITY_ENABLE_BIT,
- SENSORHUB_TEMPERATURE_HUMIDITY_ENABLE_BIT,
- SENSORHUB_LIGHT_ENABLE_BIT,
- SENSORHUB_PROXIMITY_RAW_ENABLE_BIT,
- SENSORHUB_ORIENTATION_ENABLE_BIT,
- SENSORHUB_STEP_DETECTOR_ENABLE_BIT = 12,
- SENSORHUB_SIG_MOTION_ENABLE_BIT,
- SENSORHUB_GYRO_UNCALIB_ENABLE_BIT,
- SENSORHUB_GAME_ROTATION_VECTOR_ENABLE_BIT = 15,
- SENSORHUB_ROTATION_VECTOR_ENABLE_BIT,
- SENSORHUB_STEP_COUNTER_ENABLE_BIT,
- SENSORHUB_BIO_HRM_RAW_ENABLE_BIT,
- SENSORHUB_BIO_HRM_RAW_FAC_ENABLE_BIT,
- SENSORHUB_BIO_HRM_LIB_ENABLE_BIT,
- SENSORHUB_TILT_MOTION,
- SENSORHUB_UV_SENSOR,
- SENSORHUB_PIR_ENABLE_BIT,
- SENSORHUB_ENABLE_BIT_MAX,
-};
-
enum sensor_permission_t {
SENSOR_PERMISSION_NONE = 0,
SENSOR_PERMISSION_STANDARD = (1 << 0),