blob: a4676a0c3de587dcdff560589be9fc80535130ae [file] [log] [blame]
srinivas pandruvada73c67682012-09-05 13:56:00 +01001/*
2 * HID Sensors Driver
3 * Copyright (c) 2012, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19#ifndef _HID_SENSORS_ATTRIBUTES_H
20#define _HID_SENSORS_ATTRIBUTES_H
21
22/* Common hid sensor iio structure */
23struct hid_sensor_iio_common {
24 struct hid_sensor_hub_device *hsdev;
25 struct platform_device *pdev;
26 unsigned usage_id;
27 bool data_ready;
28 struct hid_sensor_hub_attribute_info poll;
29 struct hid_sensor_hub_attribute_info report_state;
30 struct hid_sensor_hub_attribute_info power_state;
31 struct hid_sensor_hub_attribute_info sensitivity;
32};
33
34/*Convert from hid unit expo to regular exponent*/
35static inline int hid_sensor_convert_exponent(int unit_expo)
36{
37 if (unit_expo < 0x08)
38 return unit_expo;
39 else if (unit_expo <= 0x0f)
40 return -(0x0f-unit_expo+1);
41 else
42 return 0;
43}
44
45int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
46 u32 usage_id,
47 struct hid_sensor_iio_common *st);
48int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
49 int val1, int val2);
50int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
51 int *val1, int *val2);
52int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
53 int val1, int val2);
54int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
55 int *val1, int *val2);
56
57#endif