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_HAL_BASE_H_
21 #define _SENSOR_HAL_BASE_H_
23 #include <sensor_common.h>
24 #include <sensor_logs.h>
26 #include <sensor_hal.h>
29 * As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock
30 * Current kernel-headers package doesn't have it so we should define it here.
34 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */
40 std::string data_node_path;
41 std::string enable_node_path;
42 std::string interval_node_path;
43 std::string buffer_enable_node_path;
44 std::string buffer_length_node_path;
45 std::string trigger_node_path;
49 bool sensorhub_controlled;
50 std::string sensor_type;
52 std::string iio_enable_node_name;
53 std::string sensorhub_interval_node_name;
58 INPUT_EVENT_METHOD = 1,
67 #define DEFAULT_WAIT_TIME 0
69 class sensor_hal_base : public sensor_hal
73 virtual ~sensor_hal_base();
75 bool init(void *data = NULL);
76 long set_command(unsigned int cmd, long val);
77 bool set_wakeup(int wakeup);
78 int send_sensorhub_data(const char *data, int data_len);
81 bool set_enable_node(const std::string &node_path, bool sensorhub_controlled, bool enable, int enable_bit = 0);
83 static unsigned long long get_timestamp(void);
84 static unsigned long long get_timestamp(timeval *t);
85 static bool find_model_id(const std::string &sensor_type, std::string &model_id);
86 static bool is_sensorhub_controlled(const std::string &key);
87 static bool get_node_info(const node_info_query &query, node_info &info);
88 static void show_node_info(node_info &info);
89 static bool set_node_value(const std::string &node_path, int value);
90 static bool set_node_value(const std::string &node_path, unsigned long long value);
91 static bool get_node_value(const std::string &node_path, int &value);
93 static bool get_event_num(const std::string &node_path, std::string &event_num);
94 static bool get_input_method(const std::string &key, int &method, std::string &device_num);
96 static bool get_iio_node_info(const std::string& enable_node_name, const std::string& device_num, node_info &info);
97 static bool get_sensorhub_iio_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
98 static bool get_input_event_node_info(const std::string& device_num, node_info &info);
99 static bool get_sensorhub_input_event_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
101 #endif /*_SENSOR_HAL_BASE_H_*/