diff options
Diffstat (limited to 'include/linux/hid-sensor-hub.h')
-rw-r--r-- | include/linux/hid-sensor-hub.h | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 4173a8fdad9e..0408421d885f 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h | |||
@@ -49,19 +49,43 @@ struct hid_sensor_hub_attribute_info { | |||
49 | }; | 49 | }; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * struct sensor_hub_pending - Synchronous read pending information | ||
53 | * @status: Pending status true/false. | ||
54 | * @ready: Completion synchronization data. | ||
55 | * @usage_id: Usage id for physical device, E.g. Gyro usage id. | ||
56 | * @attr_usage_id: Usage Id of a field, E.g. X-AXIS for a gyro. | ||
57 | * @raw_size: Response size for a read request. | ||
58 | * @raw_data: Place holder for received response. | ||
59 | */ | ||
60 | struct sensor_hub_pending { | ||
61 | bool status; | ||
62 | struct completion ready; | ||
63 | u32 usage_id; | ||
64 | u32 attr_usage_id; | ||
65 | int raw_size; | ||
66 | u8 *raw_data; | ||
67 | }; | ||
68 | |||
69 | /** | ||
52 | * struct hid_sensor_hub_device - Stores the hub instance data | 70 | * struct hid_sensor_hub_device - Stores the hub instance data |
53 | * @hdev: Stores the hid instance. | 71 | * @hdev: Stores the hid instance. |
54 | * @vendor_id: Vendor id of hub device. | 72 | * @vendor_id: Vendor id of hub device. |
55 | * @product_id: Product id of hub device. | 73 | * @product_id: Product id of hub device. |
74 | * @usage: Usage id for this hub device instance. | ||
56 | * @start_collection_index: Starting index for a phy type collection | 75 | * @start_collection_index: Starting index for a phy type collection |
57 | * @end_collection_index: Last index for a phy type collection | 76 | * @end_collection_index: Last index for a phy type collection |
77 | * @mutex: synchronizing mutex. | ||
78 | * @pending: Holds information of pending sync read request. | ||
58 | */ | 79 | */ |
59 | struct hid_sensor_hub_device { | 80 | struct hid_sensor_hub_device { |
60 | struct hid_device *hdev; | 81 | struct hid_device *hdev; |
61 | u32 vendor_id; | 82 | u32 vendor_id; |
62 | u32 product_id; | 83 | u32 product_id; |
84 | u32 usage; | ||
63 | int start_collection_index; | 85 | int start_collection_index; |
64 | int end_collection_index; | 86 | int end_collection_index; |
87 | struct mutex mutex; | ||
88 | struct sensor_hub_pending pending; | ||
65 | }; | 89 | }; |
66 | 90 | ||
67 | /** | 91 | /** |
@@ -152,40 +176,51 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, | |||
152 | * @usage_id: Attribute usage id of parent physical device as per spec | 176 | * @usage_id: Attribute usage id of parent physical device as per spec |
153 | * @attr_usage_id: Attribute usage id as per spec | 177 | * @attr_usage_id: Attribute usage id as per spec |
154 | * @report_id: Report id to look for | 178 | * @report_id: Report id to look for |
179 | * @flag: Synchronous or asynchronous read | ||
155 | * | 180 | * |
156 | * Issues a synchronous read request for an input attribute. Returns | 181 | * Issues a synchronous or asynchronous read request for an input attribute. |
157 | * data upto 32 bits. Since client can get events, so this call should | 182 | * Returns data upto 32 bits. |
158 | * not be used for data paths, this will impact performance. | ||
159 | */ | 183 | */ |
160 | 184 | ||
185 | enum sensor_hub_read_flags { | ||
186 | SENSOR_HUB_SYNC, | ||
187 | SENSOR_HUB_ASYNC, | ||
188 | }; | ||
189 | |||
161 | int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, | 190 | int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, |
162 | u32 usage_id, | 191 | u32 usage_id, |
163 | u32 attr_usage_id, u32 report_id); | 192 | u32 attr_usage_id, u32 report_id, |
193 | enum sensor_hub_read_flags flag | ||
194 | ); | ||
195 | |||
164 | /** | 196 | /** |
165 | * sensor_hub_set_feature() - Feature set request | 197 | * sensor_hub_set_feature() - Feature set request |
166 | * @hsdev: Hub device instance. | 198 | * @hsdev: Hub device instance. |
167 | * @report_id: Report id to look for | 199 | * @report_id: Report id to look for |
168 | * @field_index: Field index inside a report | 200 | * @field_index: Field index inside a report |
169 | * @value: Value to set | 201 | * @buffer_size: size of the buffer |
202 | * @buffer: buffer to use in the feature set | ||
170 | * | 203 | * |
171 | * Used to set a field in feature report. For example this can set polling | 204 | * Used to set a field in feature report. For example this can set polling |
172 | * interval, sensitivity, activate/deactivate state. | 205 | * interval, sensitivity, activate/deactivate state. |
173 | */ | 206 | */ |
174 | int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | 207 | int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, |
175 | u32 field_index, s32 value); | 208 | u32 field_index, int buffer_size, void *buffer); |
176 | 209 | ||
177 | /** | 210 | /** |
178 | * sensor_hub_get_feature() - Feature get request | 211 | * sensor_hub_get_feature() - Feature get request |
179 | * @hsdev: Hub device instance. | 212 | * @hsdev: Hub device instance. |
180 | * @report_id: Report id to look for | 213 | * @report_id: Report id to look for |
181 | * @field_index: Field index inside a report | 214 | * @field_index: Field index inside a report |
182 | * @value: Place holder for return value | 215 | * @buffer_size: size of the buffer |
216 | * @buffer: buffer to copy output | ||
183 | * | 217 | * |
184 | * Used to get a field in feature report. For example this can get polling | 218 | * Used to get a field in feature report. For example this can get polling |
185 | * interval, sensitivity, activate/deactivate state. | 219 | * interval, sensitivity, activate/deactivate state. On success it returns |
220 | * number of bytes copied to buffer. On failure, it returns value < 0. | ||
186 | */ | 221 | */ |
187 | int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | 222 | int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, |
188 | u32 field_index, s32 *value); | 223 | u32 field_index, int buffer_size, void *buffer); |
189 | 224 | ||
190 | /* hid-sensor-attributes */ | 225 | /* hid-sensor-attributes */ |
191 | 226 | ||