All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: hid-sensor-als: Add realtime data type parse support
@ 2016-10-28  1:20 Song Hongyan
  2016-10-30 16:26 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Song Hongyan @ 2016-10-28  1:20 UTC (permalink / raw)
  To: linux-iio; +Cc: srinivas.pandruvada, Song Hongyan

In parse report function it only support to parse absolute data type
reported. Some platforms which report realtime data cannot be parsed,
they will get "Invalid Argument" when try to get sensor data.

Add realtime data type support to match different platforms.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
---
 drivers/iio/light/hid-sensor-als.c | 11 +++++++++++
 include/linux/hid-sensor-ids.h     |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 8bb1f90..3b3aa66 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -252,6 +252,17 @@ 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/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	0x200850
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: hid-sensor-als: Add realtime data type parse support
  2016-10-28  1:20 [PATCH] iio: hid-sensor-als: Add realtime data type parse support Song Hongyan
@ 2016-10-30 16:26 ` Jonathan Cameron
  2016-10-31  0:37   ` Pandruvada, Srinivas
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2016-10-30 16:26 UTC (permalink / raw)
  To: Song Hongyan, linux-iio; +Cc: srinivas.pandruvada

On 28/10/16 02:20, Song Hongyan wrote:
> In parse report function it only support to parse absolute data type
> reported. Some platforms which report realtime data cannot be parsed,
> they will get "Invalid Argument" when try to get sensor data.
> 
> Add realtime data type support to match different platforms.
I'm not 100% sure that rel stands for real time here...

Relative percent?  There is also a percent of range option though no
idea if any hardware actually uses that.

Srinivas, could you take a look at this one as well.

thanks,

Jonathan
> 
> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
> ---
>  drivers/iio/light/hid-sensor-als.c | 11 +++++++++++
>  include/linux/hid-sensor-ids.h     |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index 8bb1f90..3b3aa66 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -252,6 +252,17 @@ 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/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	0x200850
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: hid-sensor-als: Add realtime data type parse support
  2016-10-30 16:26 ` Jonathan Cameron
@ 2016-10-31  0:37   ` Pandruvada, Srinivas
  2016-11-05 17:53     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Pandruvada, Srinivas @ 2016-10-31  0:37 UTC (permalink / raw)
  To: Song, Hongyan, linux-iio, jic23

T24gU3VuLCAyMDE2LTEwLTMwIGF0IDE2OjI2ICswMDAwLCBKb25hdGhhbiBDYW1lcm9uIHdyb3Rl
Og0KPiBPbiAyOC8xMC8xNiAwMjoyMCwgU29uZyBIb25neWFuIHdyb3RlOg0KPiA+IA0KPiA+IElu
IHBhcnNlIHJlcG9ydCBmdW5jdGlvbiBpdCBvbmx5IHN1cHBvcnQgdG8gcGFyc2UgYWJzb2x1dGUg
ZGF0YQ0KPiA+IHR5cGUNCj4gPiByZXBvcnRlZC4gU29tZSBwbGF0Zm9ybXMgd2hpY2ggcmVwb3J0
IHJlYWx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klUWV9SRUxfUENUCQ0KPiA+IAkweEUwMDANCj4gPiDCoA0KPiA+IMKgLyogUG93ZXIgc3Rh
dGUgZW51bWVyYXRpb25zICovDQo+ID4gwqAjZGVmaW5lIEhJRF9VU0FHRV9TRU5TT1JfUFJPUF9Q
T1dFUl9TVEFURV9VTkRFRklORURfRU5VTQkweA0KPiA+IDIwMDg1MA0KPiA+IA==

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: hid-sensor-als: Add realtime data type parse support
  2016-10-31  0:37   ` Pandruvada, Srinivas
@ 2016-11-05 17:53     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2016-11-05 17:53 UTC (permalink / raw)
  To: Pandruvada, Srinivas, Song, Hongyan, linux-iio

On 31/10/16 00:37, Pandruvada, Srinivas wrote:
> On Sun, 2016-10-30 at 16:26 +0000, Jonathan Cameron wrote:
>> On 28/10/16 02:20, Song Hongyan wrote:
>>>
>>> In parse report function it only support to parse absolute data
>>> type
>>> reported. Some platforms which report realtime data cannot be
>>> parsed,
>>> they will get "Invalid Argument" when try to get sensor data.
>>>
>>> Add realtime data type support to match different platforms.
>> I'm not 100% sure that rel stands for real time here...
>>
>> Relative percent?  There is also a percent of range option though no
>> idea if any hardware actually uses that.
>>
>> Srinivas, could you take a look at this one as well.
> I asked Hongyan to post to mailing list to seek some opinion.
> The IIO ABI hysteresis is absolute value, but this will specify a
> relative value with percentage.
> I think we need a new ABI.
Agreed.
> 
> Thanks,
> Srinivas
> 
> 
>>
>> thanks,
>>
>> Jonathan
>>>
>>>
>>> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
>>> ---
>>>  drivers/iio/light/hid-sensor-als.c | 11 +++++++++++
>>>  include/linux/hid-sensor-ids.h     |  1 +
>>>  2 files changed, 12 insertions(+)
>>>
>>> diff --git a/drivers/iio/light/hid-sensor-als.c
>>> b/drivers/iio/light/hid-sensor-als.c
>>> index 8bb1f90..3b3aa66 100644
>>> --- a/drivers/iio/light/hid-sensor-als.c
>>> +++ b/drivers/iio/light/hid-sensor-als.c
>>> @@ -252,6 +252,17 @@ 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_SENSITIVI
>>> TY_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/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	0x
>>> 200850


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-05 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28  1:20 [PATCH] iio: hid-sensor-als: Add realtime data type parse support Song Hongyan
2016-10-30 16:26 ` Jonathan Cameron
2016-10-31  0:37   ` Pandruvada, Srinivas
2016-11-05 17:53     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.