4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef _SENSOR_DEVICE_BASE_H_
21 #define _SENSOR_DEVICE_BASE_H_
23 #include <sensor_logs.h>
25 #include <sensor_hal.h>
28 * As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock
29 * Current kernel-headers package doesn't have it so we should define it here.
33 /* Set clockid to be used for timestamps */
34 #define EVIOCSCLOCKID _IOW('E', 0xa0, int)
39 std::string data_node_path;
40 std::string enable_node_path;
41 std::string interval_node_path;
42 std::string buffer_enable_node_path;
43 std::string buffer_length_node_path;
44 std::string trigger_node_path;
48 bool sensorhub_controlled;
49 std::string sensor_type;
51 std::string iio_enable_node_name;
52 std::string sensorhub_interval_node_name;
57 INPUT_EVENT_METHOD = 1,
66 class sensor_device_base : public sensor_device
70 virtual ~sensor_device_base();
73 bool set_enable_node(const std::string &node_path, bool sensorhub_controlled, bool enable, int enable_bit = 0);
75 static unsigned long long get_timestamp(void);
76 static unsigned long long get_timestamp(timeval *t);
77 static bool is_sensorhub_controlled(const std::string &key);
78 static bool get_node_info(const node_info_query &query, node_info &info);
79 static void show_node_info(node_info &info);
80 static bool set_node_value(const std::string &node_path, int value);
81 static bool set_node_value(const std::string &node_path, unsigned long long value);
82 static bool get_node_value(const std::string &node_path, int &value);
84 static bool get_event_num(const std::string &node_path, std::string &event_num);
85 static bool get_input_method(const std::string &key, int &method, std::string &device_num);
87 static bool get_iio_node_info(const std::string& enable_node_name, const std::string& device_num, node_info &info);
88 static bool get_sensorhub_iio_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
89 static bool get_input_event_node_info(const std::string& device_num, node_info &info);
90 static bool get_sensorhub_input_event_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
92 #endif /*_SENSOR_DEVICE_BASE_H_*/