sensor-hal-tm1: modify Sensor HAL interface
[platform/adaptation/tm1/sensor-hal-tm1.git] / src / util.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _SENSOR_UTIL_H_
19 #define _SENSOR_UTIL_H_
20
21 #include <sys/time.h>
22 #include <string>
23
24 typedef struct {
25         int method;
26         std::string data_node_path;
27         std::string enable_node_path;
28         std::string interval_node_path;
29         std::string buffer_enable_node_path;
30         std::string buffer_length_node_path;
31         std::string trigger_node_path;
32 } node_info;
33
34 typedef struct {
35         bool sensorhub_controlled;
36         std::string sensor_type;
37         std::string key;
38         std::string iio_enable_node_name;
39         std::string sensorhub_interval_node_name;
40 } node_info_query;
41
42 enum input_method {
43         IIO_METHOD = 0,
44         INPUT_EVENT_METHOD = 1,
45 };
46
47 typedef struct {
48         int method;
49         std::string dir_path;
50         std::string prefix;
51 } input_method_info;
52
53 namespace util {
54         bool set_enable_node(const std::string &node_path, bool sensorhub_controlled, bool enable, int enable_bit = 0);
55
56         unsigned long long get_timestamp(void);
57         unsigned long long get_timestamp(timeval *t);
58
59         bool is_sensorhub_controlled(const std::string &key);
60         bool get_node_info(const node_info_query &query, node_info &info);
61         void show_node_info(node_info &info);
62         bool set_node_value(const std::string &node_path, int value);
63         bool set_node_value(const std::string &node_path, unsigned long long value);
64 }
65 #endif /*_SENSOR_UTIL_H_*/