Proximity sensors indicate high values for closer objects and vice-versa.
This patchset clarifies the ABI and fixes the SX9500 sensor.
We have 5 proximity sensors that got this right (gp2ap020a00f, jsa1212,
vcnl4000, cm36651, ltr501) and 2 that got it wrong (stk3310 and
sx9500).
For SX9500 the fix was trivial and it is included here, for stk3310 there
are more things to do and will try to fix in the near future.
Daniel Baluta (2):
iio: ABI: Clarify proximity output value
iio: proximity: sx9500: Fix proximity value
Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
drivers/iio/proximity/sx9500.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
--
1.9.1
Current description for proximity measurement is ambiguous. While
the first part says that proximity is measured by observing
reflectivity, the second part incorrectly infers that reported values
should behave like a distance.
This is because of AS3935 lightning sensor which uses the proximity
API, while not being a true proximity sensor.
Fixes: 614e8842ddf ("iio: ABI: add clarification for proximity")
Signed-off-by: Daniel Baluta <[email protected]>
---
Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index bbed111..70c9b1a 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1234,10 +1234,8 @@ Description:
object is near the sensor, usually be observing
reflectivity of infrared or ultrasound emitted.
Often these sensors are unit less and as such conversion
- to SI units is not possible. Where it is, the units should
- be meters. If such a conversion is not possible, the reported
- values should behave in the same way as a distance, i.e. lower
- values indicate something is closer to the sensor.
+ to SI units is not possible. Higher proximity measurements
+ indicate closer objects, and vice versa.
What: /sys/.../iio:deviceX/in_illuminance_input
What: /sys/.../iio:deviceX/in_illuminance_raw
--
1.9.1
Because of the ABI confusion proximity value exposed by SX9500
was inverted.
Signed-off-by: Daniel Baluta <[email protected]>
---
drivers/iio/proximity/sx9500.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 2042e37..01494cd 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
if (ret < 0)
return ret;
- *val = 32767 - (s16)be16_to_cpu(regval);
+ *val = be16_to_cpu(regval);
return IIO_VAL_INT;
}
--
1.9.1
On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
> Because of the ABI confusion proximity value exposed by SX9500
> was inverted.
>
> Signed-off-by: Daniel Baluta <[email protected]>
Reviewed-by: Vlad Dogaru <[email protected]>
Sorry for causing the confusion, it was the only proximity sensor I had
encountered to date.
> ---
> drivers/iio/proximity/sx9500.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 2042e37..01494cd 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
> if (ret < 0)
> return ret;
>
> - *val = 32767 - (s16)be16_to_cpu(regval);
> + *val = be16_to_cpu(regval);
>
> return IIO_VAL_INT;
> }
> --
> 1.9.1
>
On 12/06/15 08:40, Vlad Dogaru wrote:
> On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
>> Because of the ABI confusion proximity value exposed by SX9500
>> was inverted.
>>
>> Signed-off-by: Daniel Baluta <[email protected]>
>
> Reviewed-by: Vlad Dogaru <[email protected]>
>
> Sorry for causing the confusion, it was the only proximity sensor I had
> encountered to date.
Greg,
I've cc'd you to let you know that this fix causes an ABI change for
one driver. Technically that driver actually matched with the current documentation,
just the documentation was misleading and lots of drivers have ended up with
the reverse interpretation (question was whether proximity values get larger
or smaller as you get nearer).
Anyhow, given timing I doubt the pull request will reach you until after the
merge window. I am also going to mark this for stable to cover the 4.0 and 4.1
kernels that have this driver in them.
Hope that's fine!
Applied to the fixes-togreg branch of iio.git
Daniel, thanks for clearing this mess up and checking through all the drivers
and datasheets to figure out it was only this one!
Jonathan
>
>> ---
>> drivers/iio/proximity/sx9500.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
>> index 2042e37..01494cd 100644
>> --- a/drivers/iio/proximity/sx9500.c
>> +++ b/drivers/iio/proximity/sx9500.c
>> @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
>> if (ret < 0)
>> return ret;
>>
>> - *val = 32767 - (s16)be16_to_cpu(regval);
>> + *val = be16_to_cpu(regval);
>>
>> return IIO_VAL_INT;
>> }
>> --
>> 1.9.1
>>
On Sat, Jun 13, 2015 at 9:21 PM, Jonathan Cameron <[email protected]> wrote:
> On 12/06/15 08:40, Vlad Dogaru wrote:
>> On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
>>> Because of the ABI confusion proximity value exposed by SX9500
>>> was inverted.
>>>
>>> Signed-off-by: Daniel Baluta <[email protected]>
>>
>> Reviewed-by: Vlad Dogaru <[email protected]>
>>
>> Sorry for causing the confusion, it was the only proximity sensor I had
>> encountered to date.
> Greg,
>
> I've cc'd you to let you know that this fix causes an ABI change for
> one driver. Technically that driver actually matched with the current documentation,
> just the documentation was misleading and lots of drivers have ended up with
> the reverse interpretation (question was whether proximity values get larger
> or smaller as you get nearer).
>
> Anyhow, given timing I doubt the pull request will reach you until after the
> merge window. I am also going to mark this for stable to cover the 4.0 and 4.1
> kernels that have this driver in them.
>
> Hope that's fine!
>
> Applied to the fixes-togreg branch of iio.git
>
> Daniel, thanks for clearing this mess up and checking through all the drivers
> and datasheets to figure out it was only this one!
You are welcome. Also, lets not forget that as mentioned in the cover letter
there is still one driver that needs to be fixed. That is stk3310,
where the fix is not
trivial, but I have already talked with Tiberiu and he will take care of it.
thanks,
Daniel.
Hello,
> Current description for proximity measurement is ambiguous. While
> the first part says that proximity is measured by observing
> reflectivity, the second part incorrectly infers that reported values
> should behave like a distance.
>
> This is because of AS3935 lightning sensor which uses the proximity
> API, while not being a true proximity sensor.
Acked-by: Peter Meerwald <[email protected]>
> Fixes: 614e8842ddf ("iio: ABI: add clarification for proximity")
> Signed-off-by: Daniel Baluta <[email protected]>
> ---
> Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index bbed111..70c9b1a 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -1234,10 +1234,8 @@ Description:
> object is near the sensor, usually be observing
> reflectivity of infrared or ultrasound emitted.
> Often these sensors are unit less and as such conversion
> - to SI units is not possible. Where it is, the units should
> - be meters. If such a conversion is not possible, the reported
> - values should behave in the same way as a distance, i.e. lower
> - values indicate something is closer to the sensor.
> + to SI units is not possible. Higher proximity measurements
> + indicate closer objects, and vice versa.
>
> What: /sys/.../iio:deviceX/in_illuminance_input
> What: /sys/.../iio:deviceX/in_illuminance_raw
>
--
Peter Meerwald
+43-664-2444418 (mobile)
On 16/06/15 21:41, Peter Meerwald wrote:
> Hello,
>
>> Current description for proximity measurement is ambiguous. While
>> the first part says that proximity is measured by observing
>> reflectivity, the second part incorrectly infers that reported values
>> should behave like a distance.
>>
>> This is because of AS3935 lightning sensor which uses the proximity
>> API, while not being a true proximity sensor.
>
> Acked-by: Peter Meerwald <[email protected]>
Thanks Peter, this will stand for the record on the mailing list, but
now the patch is in a public (non testing tree) I'm not going to rebase
to add it to the patch.
Sorry about that, but 3 days too late :(
Jonathan
>
>> Fixes: 614e8842ddf ("iio: ABI: add clarification for proximity")
>> Signed-off-by: Daniel Baluta <[email protected]>
>> ---
>> Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
>> index bbed111..70c9b1a 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-iio
>> +++ b/Documentation/ABI/testing/sysfs-bus-iio
>> @@ -1234,10 +1234,8 @@ Description:
>> object is near the sensor, usually be observing
>
>> reflectivity of infrared or ultrasound emitted.
>> Often these sensors are unit less and as such conversion
>> - to SI units is not possible. Where it is, the units should
>> - be meters. If such a conversion is not possible, the reported
>> - values should behave in the same way as a distance, i.e. lower
>> - values indicate something is closer to the sensor.
>> + to SI units is not possible. Higher proximity measurements
>> + indicate closer objects, and vice versa.
>>
>> What: /sys/.../iio:deviceX/in_illuminance_input
>> What: /sys/.../iio:deviceX/in_illuminance_raw
>>
>