Clarify proximity output value interpretation
cover Clarify proximity output value interpretation
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(-)
Signature · 1 line
1.9.1
PATCH 1/2 iio: ABI: Clarify proximity output value
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.
--- Documentation/ABI/testing/sysfs-bus-iio | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Documentation/ABI/testing/sysfs-bus-iio +2 -4
@@ -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
Signature · 1 line
1.9.1
Re: [PATCH 1/2] iio: ABI: Clarify proximity output value
Hello,
Quoted 7 lines
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.
Quoted 25 lines
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(-)Documentation/ABI/testing/sysfs-bus-iio +2
-4@@ -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_inputWhat: /sys/.../iio:deviceX/in_illuminance_raw
Signature · 2 lines
Peter Meerwald +43-664-2444418 (mobile)
Jonathan Cameron
maintainerRe: [PATCH 1/2] iio: ABI: Clarify proximity output value
Quoted 11 lines · Peter Meerwald
Hello,
Quoted 7 lines
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
Quoted 23 lines
Quoted 23 lines
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(-)Documentation/ABI/testing/sysfs-bus-iio +2
-4@@ -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.
Quoted 4 lines
Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-iio +0
-0What: /sys/.../iio:deviceX/in_illuminance_inputWhat: /sys/.../iio:deviceX/in_illuminance_raw
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
PATCH 2/2 iio: proximity: sx9500: Fix proximity value
In reply to Daniel BalutaBecause of the ABI confusion proximity value exposed by SX9500 was inverted.
--- drivers/iio/proximity/sx9500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/sx9500.c +1 -1
@@ -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 ; }
Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
Quoted 4 lines · Daniel Baluta
Because of the ABI confusion proximity value exposed by SX9500 was inverted.
Signed-off-by Daniel Baluta <[email protected]>
Sorry for causing the confusion, it was the only proximity sensor I had encountered to date.
Quoted 20 lines
--- drivers/iio/proximity/sx9500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/proximity/sx9500.c +1
-1@@ -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 ; }Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
Quoted 10 lines · Vlad Dogaru
Quoted 4 lines · Daniel Baluta
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
Quoted 21 lines
Quoted 21 lines
--- drivers/iio/proximity/sx9500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/proximity/sx9500.c +1
-1@@ -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 ; }Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
Quoted 23 lines · Jonathan Cameron
Quoted 10 lines · Vlad Dogaru
Quoted 4 lines · Daniel Baluta
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.
Quoted 6 lines
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.