Re: [PATCH] iio: light and pressure: change data fields for ambient light and pressure sensor

From: Srinivas Pandruvada
Date: Thu Nov 03 2016 - 09:35:53 EST


On Thu, 2016-11-03 at 18:43 +0800, Ooi, Joyce wrote:
> Sensitivity Percent Relative is added for ambient light sensor as it
> is
> used based on HID Sensor Usages specifications.
The same patch is submitted by Song Hongyan <hongyan.song@xxxxxxxxx>
. We may need new IIO ABI to specify relative percent hyst.

Thanks,
Srinivas

>
> Other changes include adding HID_USAGE_SENSOR_LIGHT_ILLUM and
> HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE for ambient light and pressure
> sensor respectively to be in sync with HID Sensor Usages
> specifications.
>
> Signed-off-by: Ooi, Joyce <joyce.ooi@xxxxxxxxx>
> ---
> Âdrivers/iio/light/hid-sensor-als.cÂÂÂÂÂÂ| 10 ++++++++++
> Âdrivers/iio/pressure/hid-sensor-press.c | 10 ++++++++++
> Âinclude/linux/hid-sensor-ids.hÂÂÂÂÂÂÂÂÂÂ|ÂÂ1 +
> Â3 files changed, 21 insertions(+)
>
> diff --git a/drivers/iio/light/hid-sensor-als.c
> b/drivers/iio/light/hid-sensor-als.c
> index 8bb1f90..6f3ca18 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -252,6 +252,16 @@ static int als_parse_report(struct
> platform_device *pdev,
> Â st->common_attributes.sensitivity.index,
> Â st-
> >common_attributes.sensitivity.report_id);
> Â }
> + 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
> _REL_PCT |
> + HID_USAGE_SENSOR_LIGHT_ILLUM,
> + &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;
> Â}
> Â
> diff --git a/drivers/iio/pressure/hid-sensor-press.c
> b/drivers/iio/pressure/hid-sensor-press.c
> index 6848d8c..4cbbf88 100644
> --- a/drivers/iio/pressure/hid-sensor-press.c
> +++ b/drivers/iio/pressure/hid-sensor-press.c
> @@ -249,6 +249,16 @@ static int press_parse_report(struct
> platform_device *pdev,
> Â st->common_attributes.sensitivity.index,
> Â st-
> >common_attributes.sensitivity.report_id);
> Â }
> + 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_ATMOSPHERIC_PRESSURE,
> + &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;
> Â}
> Â
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-
> sensor-ids.h
> index f2ee90a..755f5e2 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -141,6 +141,7 @@
> Â/* Per data field properties */
> Â#define HID_USAGE_SENSOR_DATA_MOD_NONE
> 0x00
> Â#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS
> 0x1000
> +#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_REL_PCT
> 0xE000
> Â
> Â/* Power state enumerations */
> Â#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x20
> 0850