Skip to contentSkip to conversation

iio: hid-sensors: Set default unit of measure for report interval

PATCH Applied Archana Patni 2 participants 2 messages May 8, 2014 – May 10, 2014 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: hid-sensors: Set default unit of measure for report interval

For PROP_REPORT_INTERVAL, the spec does not mandate the presence of the report interval unit in the feature report and expects the default unit of measure to be used as milliseconds.

Currently, when the unit is not present, it gets set as zero leading to issues in sampling frequency.

This patch sets the unit of measure to the default unit if it is not defined by firmware.

---
 .../iio/common/hid-sensors/hid-sensor-attributes.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +15 -2
index 75b5473..55047af 100644
@@ -209,15 +209,28 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
 }
 EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
 
-int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
+int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev,
 					u32 usage_id,
 					struct hid_sensor_common *st)
 {
-
 	sensor_hub_input_get_attribute_info(hsdev,
 					HID_FEATURE_REPORT, usage_id,
 					HID_USAGE_SENSOR_PROP_REPORT_INTERVAL,
 					&st->poll);
+	/* Default unit of measure is milliseconds */
+	if (st->poll.units == 0)
+		st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND;
+	return 0;
+
+}
+
+int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
+					u32 usage_id,
+					struct hid_sensor_common *st)
+{
+
+
+	hid_sensor_get_reporting_interval(hsdev, usage_id, st);
 
 	sensor_hub_input_get_attribute_info(hsdev,
 					HID_FEATURE_REPORT, usage_id,
Signature · 1 line
1.7.9.5
maintainer Applied
#1 lore raw
Quoted 7 lines · Archana Patni

For PROP_REPORT_INTERVAL, the spec does not mandate the presence of the report interval unit in the feature report and expects the default unit of measure to be used as milliseconds.

Currently, when the unit is not present, it gets set as zero leading to issues in sampling frequency.

Quoted 6 lines

This patch sets the unit of measure to the default unit if it is not defined by firmware.

Applied to the togreg branch of iio.git

Thanks,

Quoted 40 lines
---
  .../iio/common/hid-sensors/hid-sensor-attributes.c |   17 +++++++++++++++--
  1 file changed, 15 insertions(+), 2 deletions(-)
drivers/iio/common/hid-sensors/hid-sensor-attributes.c +15 -2
index 75b5473..55047af 100644
@@ -209,15 +209,28 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
  }
  EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
 
-int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
+int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev,
  					u32 usage_id,
  					struct hid_sensor_common *st)
  {
-
  	sensor_hub_input_get_attribute_info(hsdev,
  					HID_FEATURE_REPORT, usage_id,
  					HID_USAGE_SENSOR_PROP_REPORT_INTERVAL,
  					&st->poll);
+	/* Default unit of measure is milliseconds */
+	if (st->poll.units == 0)
+		st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND;
+	return 0;
+
+}
+
+int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
+					u32 usage_id,
+					struct hid_sensor_common *st)
+{
+
+
+	hid_sensor_get_reporting_interval(hsdev, usage_id, st);
 
  	sensor_hub_input_get_attribute_info(hsdev,
  					HID_FEATURE_REPORT, usage_id,