aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorsrinivas pandruvada <srinivas.pandruvada@intel.com>2012-09-05 08:56:00 -0400
committerJonathan Cameron <jic23@kernel.org>2012-09-06 14:13:13 -0400
commit401ca24fb34aee0cedf9c4fef361e533224f15a1 (patch)
tree6841fc321a073643ebe8a4f9fd1a8c32fac13c3a /include/linux
parentc8147d9ea19bfe7d8e569351bc7239e118dd6997 (diff)
HID: sensors: introduce sensor framework
Adding processing for HID Sensor usage table as defined by HID 1.12, Request #: HUTRR39, dated 05 May, 2011. This driver uses HID driver framework to register, send and receive events. This uses MFD framework, so that actual processing for a specific usage id can be done in a different driver. For example an accelerometer driver can be a separate driver and use the interface provided by this driver to register for events. Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hid-sensor-hub.h160
-rw-r--r--include/linux/hid-sensor-ids.h112
2 files changed, 272 insertions, 0 deletions
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
new file mode 100644
index 000000000000..0aa5f4c42ae6
--- /dev/null
+++ b/include/linux/hid-sensor-hub.h
@@ -0,0 +1,160 @@
1/*
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_HUB_H
20#define _HID_SENSORS_HUB_H
21
22#include <linux/hid.h>
23#include <linux/hid-sensor-ids.h>
24
25/**
26 * struct hid_sensor_hub_attribute_info - Attribute info
27 * @usage_id: Parent usage id of a physical device.
28 * @attrib_id: Attribute id for this attribute.
29 * @report_id: Report id in which this information resides.
30 * @index: Field index in the report.
31 * @units: Measurment unit for this attribute.
32 * @unit_expo: Exponent used in the data.
33 * @size: Size in bytes for data size.
34 */
35struct hid_sensor_hub_attribute_info {
36 u32 usage_id;
37 u32 attrib_id;
38 s32 report_id;
39 s32 index;
40 s32 units;
41 s32 unit_expo;
42 s32 size;
43};
44
45/**
46 * struct hid_sensor_hub_device - Stores the hub instance data
47 * @hdev: Stores the hid instance.
48 * @vendor_id: Vendor id of hub device.
49 * @product_id: Product id of hub device.
50 */
51struct hid_sensor_hub_device {
52 struct hid_device *hdev;
53 u32 vendor_id;
54 u32 product_id;
55};
56
57/**
58 * struct hid_sensor_hub_callbacks - Client callback functions
59 * @pdev: Platform device instance of the client driver.
60 * @suspend: Suspend callback.
61 * @resume: Resume callback.
62 * @capture_sample: Callback to get a sample.
63 * @send_event: Send notification to indicate all samples are
64 * captured, process and send event
65 */
66struct hid_sensor_hub_callbacks {
67 struct platform_device *pdev;
68 int (*suspend)(struct hid_sensor_hub_device *hsdev, void *priv);
69 int (*resume)(struct hid_sensor_hub_device *hsdev, void *priv);
70 int (*capture_sample)(struct hid_sensor_hub_device *hsdev,
71 u32 usage_id, size_t raw_len, char *raw_data,
72 void *priv);
73 int (*send_event)(struct hid_sensor_hub_device *hsdev, u32 usage_id,
74 void *priv);
75};
76
77/* Registration functions */
78
79/**
80* sensor_hub_register_callback() - Register client callbacks
81* @hsdev: Hub device instance.
82* @usage_id: Usage id of the client (E.g. 0x200076 for Gyro).
83* @usage_callback: Callback function storage
84*
85* Used to register callbacks by client processing drivers. Sensor
86* hub core driver will call these callbacks to offload processing
87* of data streams and notifications.
88*/
89int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
90 u32 usage_id,
91 struct hid_sensor_hub_callbacks *usage_callback);
92
93/**
94* sensor_hub_remove_callback() - Remove client callbacks
95* @hsdev: Hub device instance.
96* @usage_id: Usage id of the client (E.g. 0x200076 for Gyro).
97*
98* If there is a callback registred, this call will remove that
99* callbacks, so that it will stop data and event notifications.
100*/
101int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
102 u32 usage_id);
103
104
105/* Hid sensor hub core interfaces */
106
107/**
108* sensor_hub_input_get_attribute_info() - Get an attribute information
109* @hsdev: Hub device instance.
110* @type: Type of this attribute, input/output/feature
111* @usage_id: Attribute usage id of parent physical device as per spec
112* @attr_usage_id: Attribute usage id as per spec
113* @info: return information about attribute after parsing report
114*
115* Parses report and returns the attribute information such as report id,
116* field index, units and exponet etc.
117*/
118int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
119 u8 type,
120 u32 usage_id, u32 attr_usage_id,
121 struct hid_sensor_hub_attribute_info *info);
122
123/**
124* sensor_hub_input_attr_get_raw_value() - Synchronous read request
125* @usage_id: Attribute usage id of parent physical device as per spec
126* @attr_usage_id: Attribute usage id as per spec
127* @report_id: Report id to look for
128*
129* Issues a synchronous read request for an input attribute. Returns
130* data upto 32 bits. Since client can get events, so this call should
131* not be used for data paths, this will impact performance.
132*/
133
134int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
135 u32 usage_id,
136 u32 attr_usage_id, u32 report_id);
137/**
138* sensor_hub_set_feature() - Feature set request
139* @report_id: Report id to look for
140* @field_index: Field index inside a report
141* @value: Value to set
142*
143* Used to set a field in feature report. For example this can set polling
144* interval, sensitivity, activate/deactivate state.
145*/
146int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
147 u32 field_index, s32 value);
148
149/**
150* sensor_hub_get_feature() - Feature get request
151* @report_id: Report id to look for
152* @field_index: Field index inside a report
153* @value: Place holder for return value
154*
155* Used to get a field in feature report. For example this can get polling
156* interval, sensitivity, activate/deactivate state.
157*/
158int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
159 u32 field_index, s32 *value);
160#endif
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
new file mode 100644
index 000000000000..ca8d7e94eb3c
--- /dev/null
+++ b/include/linux/hid-sensor-ids.h
@@ -0,0 +1,112 @@
1/*
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_IDS_H
20#define _HID_SENSORS_IDS_H
21
22#define HID_UP_SENSOR 0x00200000
23#define HID_MAX_PHY_DEVICES 0xFF
24
25/* Accel 3D (200073) */
26#define HID_USAGE_SENSOR_ACCEL_3D 0x200073
27#define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453
28#define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454
29#define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455
30
31/* ALS (200041) */
32#define HID_USAGE_SENSOR_ALS 0x200041
33#define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1
34
35/* Gyro 3D: (200076) */
36#define HID_USAGE_SENSOR_GYRO_3D 0x200076
37#define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457
38#define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458
39#define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459
40
41/*ORIENTATION: Compass 3D: (200083) */
42#define HID_USAGE_SENSOR_COMPASS_3D 0x200083
43#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING 0x200471
44#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X 0x200472
45#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y 0x200473
46#define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Z 0x200474
47
48#define HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH 0x200475
49#define HID_USAGE_SENSOR_ORIENT_COMP_TRUE_NORTH 0x200476
50#define HID_USAGE_SENSOR_ORIENT_MAGN_NORTH 0x200477
51#define HID_USAGE_SENSOR_ORIENT_TRUE_NORTH 0x200478
52
53#define HID_USAGE_SENSOR_ORIENT_DISTANCE 0x200479
54#define HID_USAGE_SENSOR_ORIENT_DISTANCE_X 0x20047A
55#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Y 0x20047B
56#define HID_USAGE_SENSOR_ORIENT_DISTANCE_Z 0x20047C
57#define HID_USAGE_SENSOR_ORIENT_DISTANCE_OUT_OF_RANGE 0x20047D
58#define HID_USAGE_SENSOR_ORIENT_TILT 0x20047E
59#define HID_USAGE_SENSOR_ORIENT_TILT_X 0x20047F
60#define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480
61#define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481
62#define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482
63#define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483
64#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
65
66#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_X_AXIS 0x200485
67#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS 0x200486
68#define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS 0x200487
69
70/* Units */
71#define HID_USAGE_SENSOR_UNITS_NOT_SPECIFIED 0x00
72#define HID_USAGE_SENSOR_UNITS_LUX 0x01
73#define HID_USAGE_SENSOR_UNITS_KELVIN 0x01000100
74#define HID_USAGE_SENSOR_UNITS_FAHRENHEIT 0x03000100
75#define HID_USAGE_SENSOR_UNITS_PASCAL 0xF1E1
76#define HID_USAGE_SENSOR_UNITS_NEWTON 0x11E1
77#define HID_USAGE_SENSOR_UNITS_METERS_PER_SECOND 0x11F0
78#define HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD 0x11E0
79#define HID_USAGE_SENSOR_UNITS_FARAD 0xE14F2000
80#define HID_USAGE_SENSOR_UNITS_AMPERE 0x01001000
81#define HID_USAGE_SENSOR_UNITS_WATT 0x21d1
82#define HID_USAGE_SENSOR_UNITS_HENRY 0x21E1E000
83#define HID_USAGE_SENSOR_UNITS_OHM 0x21D1E000
84#define HID_USAGE_SENSOR_UNITS_VOLT 0x21D1F000
85#define HID_USAGE_SENSOR_UNITS_HERTZ 0x01F0
86#define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SEC_SQRD 0x14E0
87#define HID_USAGE_SENSOR_UNITS_RADIANS 0x12
88#define HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND 0x12F0
89#define HID_USAGE_SENSOR_UNITS_RADIANS_PER_SEC_SQRD 0x12E0
90#define HID_USAGE_SENSOR_UNITS_SECOND 0x0110
91#define HID_USAGE_SENSOR_UNITS_GAUSS 0x01E1F000
92#define HID_USAGE_SENSOR_UNITS_GRAM 0x0101
93#define HID_USAGE_SENSOR_UNITS_CENTIMETER 0x11
94#define HID_USAGE_SENSOR_UNITS_G 0x1A
95#define HID_USAGE_SENSOR_UNITS_MILLISECOND 0x19
96#define HID_USAGE_SENSOR_UNITS_PERCENT 0x17
97#define HID_USAGE_SENSOR_UNITS_DEGREES 0x14
98#define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND 0x15
99
100/* Common selectors */
101#define HID_USAGE_SENSOR_PROP_REPORT_INTERVAL 0x20030E
102#define HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS 0x20030F
103#define HID_USAGE_SENSOR_PROP_SENSITIVITY_RANGE_PCT 0x200310
104#define HID_USAGE_SENSOR_PROP_SENSITIVITY_REL_PCT 0x200311
105#define HID_USAGE_SENSOR_PROP_ACCURACY 0x200312
106#define HID_USAGE_SENSOR_PROP_RESOLUTION 0x200313
107#define HID_USAGE_SENSOR_PROP_RANGE_MAXIMUM 0x200314
108#define HID_USAGE_SENSOR_PROP_RANGE_MINIMUM 0x200315
109#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316
110#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319
111
112#endif