iio: hid-sensors: accelerometer: Add sensitivity
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 30 Oct 2013 22:48:00 +0000 (22:48 +0000)
committerJonathan Cameron <jic23@kernel.org>
Tue, 5 Nov 2013 23:02:43 +0000 (23:02 +0000)
A number of Properties that can be applied to Data Fields are per data
field basis or for all data fields. Adding sensitivity field for all
accelerometer fields, which is most commonly used in currently
available sensor hubs.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/accel/hid-sensor-accel-3d.c
include/linux/hid-sensor-ids.h

index dcda17395c4e68f31f3382cd0c393a5845b025c5..6b8735ce8345b21f6f68526519587315148890d4 100644 (file)
@@ -262,6 +262,18 @@ static int accel_3d_parse_report(struct platform_device *pdev,
                        st->accel[1].index, st->accel[1].report_id,
                        st->accel[2].index, st->accel[2].report_id);
 
+       /* Set Sensitivity field ids, when there is no individual modifier */
+       if (st->common_attributes.sensitivity.index < 0) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                       HID_FEATURE_REPORT, usage_id,
+                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                       HID_USAGE_SENSOR_DATA_ACCELERATION,
+                       &st->common_attributes.sensitivity);
+               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+                       st->common_attributes.sensitivity.index,
+                       st->common_attributes.sensitivity.report_id);
+       }
+
        return ret;
 }
 
index 4f945d3ed49fc7a511affdc307ea84aff60565cb..4dda3b791c82bc9bb7a4c12ec60102031c5f6a73 100644 (file)
@@ -23,6 +23,7 @@
 
 /* Accel 3D (200073) */
 #define HID_USAGE_SENSOR_ACCEL_3D                              0x200073
+#define HID_USAGE_SENSOR_DATA_ACCELERATION                     0x200452
 #define HID_USAGE_SENSOR_ACCEL_X_AXIS                          0x200453
 #define HID_USAGE_SENSOR_ACCEL_Y_AXIS                          0x200454
 #define HID_USAGE_SENSOR_ACCEL_Z_AXIS                          0x200455
 #define HID_USAGE_SENSOR_PROP_REPORT_STATE                     0x200316
 #define HID_USAGE_SENSOR_PROY_POWER_STATE                      0x200319
 
+/* Per data field properties */
+#define HID_USAGE_SENSOR_DATA_MOD_NONE                                 0x00
+#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS               0x1000
+
 #endif