Merge "Adding AK8975 geo-sensor info in sensors.xml.in required by geo-plugin" into...
[platform/core/system/sensord.git] / src / proxi / proxi_sensor_hal.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _PROXI_SENSOR_HAL_H_
21 #define _PROXI_SENSOR_HAL_H_
22
23 #include <sensor_hal.h>
24 #include <string>
25
26 #define IIO_DIR                 "/sys/bus/iio/devices/"
27 #define NAME_NODE               "/name"
28 #define EVENT_DIR               "/events"
29 #define EVENT_EN_NODE   "/in_proximity_thresh_either_en"
30 #define DEV_DIR                 "/dev/"
31
32 #define IIO_DEV_BASE_NAME       "iio:device"
33 #define IIO_DEV_STR_LEN         10
34
35 #define PROXIMITY_NODE_STATE_NEAR       1
36 #define PROXIMITY_NODE_STATE_FAR        2
37 #define PROXIMITY_TYPE                          8
38
39 using std::string;
40
41 class proxi_sensor_hal : public sensor_hal
42 {
43 public:
44         proxi_sensor_hal();
45         virtual ~proxi_sensor_hal();
46         string get_model_id(void);
47         sensor_type_t get_type(void);
48         bool enable(void);
49         bool disable(void);
50         bool is_data_ready(bool wait);
51         virtual int get_sensor_data(sensor_data_t &data);
52         bool get_properties(sensor_properties_t &properties);
53         bool check_hw_node(void);
54
55 private:
56         unsigned int m_state;
57         int m_node_handle;
58         unsigned long long m_fired_time;
59         bool m_sensorhub_supported;
60
61         string m_model_id;
62         string m_name;
63         string m_vendor;
64         string m_chip_name;
65
66         string m_proxi_dir;
67
68         string m_enable_resource;
69         string m_event_resource;
70
71         cmutex m_value_mutex;
72
73         int m_event_fd;
74
75         bool enable_resource(bool enable);
76         bool update_value(bool wait);
77         bool is_sensorhub_supported(void);
78 };
79 #endif /*_PROXI_SENSOR_HAL_H_*/