OSDN Git Service

iio: hid-sensors: Add connection type
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Mon, 14 Oct 2013 17:41:32 +0000 (10:41 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 17 Dec 2014 15:59:45 +0000 (23:59 +0800)
Some sensor hub firmware are very strict about the connection type
setting. The connection type specifies whether it is an integrated
or external sensor hub.
By default choosing integrated type unless changed via a module
param.

Change-Id: I32cb8346f048af52a54a5831f129d3bde5d60cd6
For: AXIA-3283
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Joakim Nordell <joakim.nordell@intel.com>
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
include/linux/hid-sensor-hub.h
include/linux/hid-sensor-ids.h

index 69e91fd..a4f4ce7 100644 (file)
@@ -389,7 +389,7 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
 
        sensor_hub_input_get_attribute_info(hsdev,
                                        HID_FEATURE_REPORT, usage_id,
-                                       HID_USAGE_SENSOR_PROY_POWER_STATE,
+                                       HID_USAGE_SENSOR_PROT_POWER_STATE,
                                        &st->power_state);
 
        sensor_hub_input_get_attribute_info(hsdev,
@@ -397,11 +397,17 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
                        HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
                         &st->sensitivity);
 
-       hid_dbg(hsdev->hdev, "common attributes: %x:%x, %x:%x, %x:%x %x:%x\n",
+       sensor_hub_input_get_attribute_info(hsdev,
+                               HID_FEATURE_REPORT, usage_id,
+                               HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE,
+                               &st->conn_type);
+
+       hid_dbg(hsdev->hdev, "common attributes: %x:%x, %x:%x, %x:%x %x:%x %x:%x\n",
                        st->poll.index, st->poll.report_id,
                        st->report_state.index, st->report_state.report_id,
                        st->power_state.index, st->power_state.report_id,
-                       st->sensitivity.index, st->sensitivity.report_id);
+                       st->sensitivity.index, st->sensitivity.report_id,
+                       st->conn_type.index, st->conn_type.report_id);
 
        return 0;
 }
index 92068cd..1df6b26 100644 (file)
 #include <linux/iio/sysfs.h>
 #include "hid-sensor-trigger.h"
 
+static int hid_sensor_conn_type = HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM;
+module_param(hid_sensor_conn_type, int, 0644);
+MODULE_PARM_DESC(hid_sensor_conn_type, "HID SENSOR CONNECT TYPE (1 to 3).");
+
 int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
 {
        int state_val;
@@ -78,6 +82,11 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
        sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
                                        st->power_state.index,
                                        &state_val);
+
+       sensor_hub_set_feature(st->hsdev, st->conn_type.report_id,
+                                       st->conn_type.index,
+                                       hid_sensor_conn_type);
+
        return 0;
 }
 EXPORT_SYMBOL(hid_sensor_power_state);
index 51f7cca..9a413ba 100644 (file)
@@ -195,6 +195,7 @@ struct hid_sensor_common {
        struct hid_sensor_hub_attribute_info report_state;
        struct hid_sensor_hub_attribute_info power_state;
        struct hid_sensor_hub_attribute_info sensitivity;
+       struct hid_sensor_hub_attribute_info conn_type;
 };
 
 /* Convert from hid unit expo to regular exponent */
index 109f0e6..908d3db 100644 (file)
 #define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND              0x15
 
 /* Common selectors */
+#define HID_USAGE_SENSOR_PROP_SENSOR_CONNECTION_TYPE           0x200309
 #define HID_USAGE_SENSOR_PROP_REPORT_INTERVAL                  0x20030E
 #define HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS                  0x20030F
 #define HID_USAGE_SENSOR_PROP_SENSITIVITY_RANGE_PCT            0x200310
 #define HID_USAGE_SENSOR_PROP_RANGE_MAXIMUM                    0x200314
 #define HID_USAGE_SENSOR_PROP_RANGE_MINIMUM                    0x200315
 #define HID_USAGE_SENSOR_PROP_REPORT_STATE                     0x200316
-#define HID_USAGE_SENSOR_PROY_POWER_STATE                      0x200319
+#define HID_USAGE_SENSOR_PROT_POWER_STATE                      0x200319
+
+/* Default connection type */
+#define HID_USAGE_SENSOR_PROP_CONNEC_TYPE_PC_INT_ENUM          0x01
 
 /* Per data field properties */
 #define HID_USAGE_SENSOR_DATA_MOD_NONE                                 0x00