aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2014-01-23 21:50:21 -0500
committerJiri Kosina <jkosina@suse.cz>2014-02-17 09:09:46 -0500
commite02cee4819ae51f26333471c8eed50678b08572a (patch)
treed3d345f5eacbaf69b952ff23e16401e02973c8d5 /drivers/hid
parent4988abf1749241bc80600a6b3283d03898d2717c (diff)
HID: hid-sensor-hub: Add selector api
In some report descriptors, they leave holes in the selectors. In this case if we use hardcoded selector values, this will result in invalid values. For example, if there is selectors defined for Power State from OFF to D0 to D3. We can't use indexes of these states if some states are not implemented or not present in the report decriptors. In this case, we need to get the indexes from report descriptors. One API is added to get the index of a selector. This API will search for usage id in the field usage list and return the index. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-sensor-hub.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 46f4480035bc..ad2b8692ad77 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -291,6 +291,28 @@ err_free:
291} 291}
292EXPORT_SYMBOL_GPL(sensor_hub_input_attr_get_raw_value); 292EXPORT_SYMBOL_GPL(sensor_hub_input_attr_get_raw_value);
293 293
294int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev,
295 u32 report_id, int field_index, u32 usage_id)
296{
297 struct hid_report *report;
298 struct hid_field *field;
299 int i;
300
301 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
302 if (!report || (field_index >= report->maxfield))
303 goto done_proc;
304
305 field = report->field[field_index];
306 for (i = 0; i < field->maxusage; ++i) {
307 if (field->usage[i].hid == usage_id)
308 return field->usage[i].usage_index;
309 }
310
311done_proc:
312 return -EINVAL;
313}
314EXPORT_SYMBOL_GPL(hid_sensor_get_usage_index);
315
294int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, 316int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
295 u8 type, 317 u8 type,
296 u32 usage_id, 318 u32 usage_id,