linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* supporting binary (near-far) proximity sensors over gpio
@ 2023-11-17 18:21 Sicelo
  2023-11-19  0:09 ` David Lechner
  0 siblings, 1 reply; 7+ messages in thread
From: Sicelo @ 2023-11-17 18:21 UTC (permalink / raw)
  To: linux-iio; +Cc: maemo-leste, Ivaylo Dimitrov, linux-input

Hi

Some phones have 1-bit proximity sensors, which simply toggle a GPIO
line to indicate that an object is near or far. Thresholds are set at
hardware level. One such sensor is OSRAM SFH 7741 [1], which is used on
the Nokia N900.

It is currently exported over evdev, emitting the SW_FRONT_PROXIMITY key
code [2].

So the question is: should a new, general purpose iio-gpio driver be
written, that would switch such a proximity sensor to the iio framework?
Or evdev is really the best place to support it?

There are a couple of people who are willing to write such an iio
driver, if iio is the way to go.

Regards,
Sicelo

[1] https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
[2] https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-17 18:21 supporting binary (near-far) proximity sensors over gpio Sicelo
@ 2023-11-19  0:09 ` David Lechner
  2023-11-20 17:31   ` Jonathan Cameron
  2023-11-26  4:33   ` Jeff LaBundy
  0 siblings, 2 replies; 7+ messages in thread
From: David Lechner @ 2023-11-19  0:09 UTC (permalink / raw)
  To: Sicelo; +Cc: linux-iio, maemo-leste, Ivaylo Dimitrov, linux-input

On Fri, Nov 17, 2023 at 12:22 PM Sicelo <absicsz@gmail.com> wrote:
>
> Hi
>
> Some phones have 1-bit proximity sensors, which simply toggle a GPIO
> line to indicate that an object is near or far. Thresholds are set at
> hardware level. One such sensor is OSRAM SFH 7741 [1], which is used on
> the Nokia N900.
>
> It is currently exported over evdev, emitting the SW_FRONT_PROXIMITY key
> code [2].
>
> So the question is: should a new, general purpose iio-gpio driver be
> written, that would switch such a proximity sensor to the iio framework?
> Or evdev is really the best place to support it?
>
> There are a couple of people who are willing to write such an iio
> driver, if iio is the way to go.
>
> Regards,
> Sicelo
>
> [1] https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
> [2] https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111
>
Since this is really a proximity switch (it is either on or off)
rather than measuring a proximity value over a continuous range, it
doesn't seem like a good fit for the iio subsystem. If the sensor is
on a phone, then it is likely to detect human presence so the input
subsystem does seem like the right one for that application.

More at https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-19  0:09 ` David Lechner
@ 2023-11-20 17:31   ` Jonathan Cameron
  2023-11-20 20:23     ` Sicelo
  2023-11-26  4:33   ` Jeff LaBundy
  1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2023-11-20 17:31 UTC (permalink / raw)
  To: David Lechner
  Cc: Sicelo, linux-iio, maemo-leste, Ivaylo Dimitrov, linux-input

On Sat, 18 Nov 2023 18:09:18 -0600
David Lechner <dlechner@baylibre.com> wrote:

> On Fri, Nov 17, 2023 at 12:22 PM Sicelo <absicsz@gmail.com> wrote:
> >
> > Hi
> >
> > Some phones have 1-bit proximity sensors, which simply toggle a GPIO
> > line to indicate that an object is near or far. Thresholds are set at
> > hardware level. One such sensor is OSRAM SFH 7741 [1], which is used on
> > the Nokia N900.
> >
> > It is currently exported over evdev, emitting the SW_FRONT_PROXIMITY key
> > code [2].
> >
> > So the question is: should a new, general purpose iio-gpio driver be
> > written, that would switch such a proximity sensor to the iio framework?
> > Or evdev is really the best place to support it?
> >
> > There are a couple of people who are willing to write such an iio
> > driver, if iio is the way to go.
> >
> > Regards,
> > Sicelo
> >
> > [1] https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
> > [2] https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111
> >  
> Since this is really a proximity switch (it is either on or off)
> rather than measuring a proximity value over a continuous range, it
> doesn't seem like a good fit for the iio subsystem. If the sensor is
> on a phone, then it is likely to detect human presence so the input
> subsystem does seem like the right one for that application.
> 
> More at https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html
> 
Agreed.  This one at least has a working distance of 30mm sensor, so
definitely switch type usecases where input tends to be the right choice.

If we wanted to use proximity range sensor for this usecase, we'd probably
bridge it to input (maybe in userspace, maybe in kernel) from the
underlying IIO driver.

Jonathan

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-20 17:31   ` Jonathan Cameron
@ 2023-11-20 20:23     ` Sicelo
  0 siblings, 0 replies; 7+ messages in thread
From: Sicelo @ 2023-11-20 20:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, linux-iio, maemo-leste, Ivaylo Dimitrov,
	linux-input

Hi

On Mon, Nov 20, 2023 at 05:31:31PM +0000, Jonathan Cameron wrote:
> > Since this is really a proximity switch (it is either on or off)
> > rather than measuring a proximity value over a continuous range, it
> > doesn't seem like a good fit for the iio subsystem. If the sensor is
> > on a phone, then it is likely to detect human presence so the input
> > subsystem does seem like the right one for that application.
> > 
> > More at https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html
> > 
> Agreed.  This one at least has a working distance of 30mm sensor, so
> definitely switch type usecases where input tends to be the right choice.
> 
> If we wanted to use proximity range sensor for this usecase, we'd probably
> bridge it to input (maybe in userspace, maybe in kernel) from the
> underlying IIO driver.
> 
> Jonathan

Thank you so much for the input. It makes sense.

Sincerely
Sicelo

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-19  0:09 ` David Lechner
  2023-11-20 17:31   ` Jonathan Cameron
@ 2023-11-26  4:33   ` Jeff LaBundy
  2023-11-26 10:59     ` Philipp Jungkamp
  1 sibling, 1 reply; 7+ messages in thread
From: Jeff LaBundy @ 2023-11-26  4:33 UTC (permalink / raw)
  To: David Lechner
  Cc: Sicelo, linux-iio, maemo-leste, Ivaylo Dimitrov, linux-input

Hi Sicelo and David,

On Sat, Nov 18, 2023 at 06:09:18PM -0600, David Lechner wrote:
> On Fri, Nov 17, 2023 at 12:22 PM Sicelo <absicsz@gmail.com> wrote:
> >
> > Hi
> >
> > Some phones have 1-bit proximity sensors, which simply toggle a GPIO
> > line to indicate that an object is near or far. Thresholds are set at
> > hardware level. One such sensor is OSRAM SFH 7741 [1], which is used on
> > the Nokia N900.
> >
> > It is currently exported over evdev, emitting the SW_FRONT_PROXIMITY key
> > code [2].
> >
> > So the question is: should a new, general purpose iio-gpio driver be
> > written, that would switch such a proximity sensor to the iio framework?
> > Or evdev is really the best place to support it?
> >
> > There are a couple of people who are willing to write such an iio
> > driver, if iio is the way to go.
> >
> > Regards,
> > Sicelo
> >
> > [1] https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
> > [2] https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111
> >
> Since this is really a proximity switch (it is either on or off)
> rather than measuring a proximity value over a continuous range, it
> doesn't seem like a good fit for the iio subsystem. If the sensor is
> on a phone, then it is likely to detect human presence so the input
> subsystem does seem like the right one for that application.
> 
> More at https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html
> 

I tend to agree; if there are only two discrete states as is the case for a
GPIO, then this is technically a switch and not a sensor. Therefore, input
seems like a better fit; that is just my $.02.

FWIW, a similar discussion came up a few years ago in [1] and again the key
differentiator was whether the output is discrete or continuous.

Kind regards,
Jeff LaBundy

[1] https://lore.kernel.org/linux-iio/9f9b0ff6-3bf1-63c4-eb36-901cecd7c4d9@redhat.com/

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-26  4:33   ` Jeff LaBundy
@ 2023-11-26 10:59     ` Philipp Jungkamp
  2023-12-04 10:09       ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Jungkamp @ 2023-11-26 10:59 UTC (permalink / raw)
  To: Jeff LaBundy, David Lechner
  Cc: Sicelo, linux-iio, maemo-leste, Ivaylo Dimitrov, linux-input

Hi,

would it make sense to move the HID human presence driver at
drivers/iio/light/hid-sensor-prox.c to the input system then? This
driver only checks for the "Biometric" (0x2004b0) and "Biometric: Human
Presence" (0x2004b1) HID usages. The former has a vendor defined value
range, the latter is defined as a boolean switch. See the HID Usage
Tables, section 21.1 and 21.6.

I take from this discussion that the input subsystem would make more
sense for the "Biometric: Human Presence" usage.

I just wanted to chime in as there seems to be some older precedent for
a binary sensor in the iio subsystem. I tried to get that sensor
working for the proximity sensor on my laptop last year.

Regards,
Philipp Jungkamp

On Sat, 2023-11-25 at 22:33 -0600, Jeff LaBundy wrote:
> Hi Sicelo and David,
> 
> On Sat, Nov 18, 2023 at 06:09:18PM -0600, David Lechner wrote:
> > On Fri, Nov 17, 2023 at 12:22 PM Sicelo <absicsz@gmail.com> wrote:
> > > 
> > > Hi
> > > 
> > > Some phones have 1-bit proximity sensors, which simply toggle a
> > > GPIO
> > > line to indicate that an object is near or far. Thresholds are
> > > set at
> > > hardware level. One such sensor is OSRAM SFH 7741 [1], which is
> > > used on
> > > the Nokia N900.
> > > 
> > > It is currently exported over evdev, emitting the
> > > SW_FRONT_PROXIMITY key
> > > code [2].
> > > 
> > > So the question is: should a new, general purpose iio-gpio driver
> > > be
> > > written, that would switch such a proximity sensor to the iio
> > > framework?
> > > Or evdev is really the best place to support it?
> > > 
> > > There are a couple of people who are willing to write such an iio
> > > driver, if iio is the way to go.
> > > 
> > > Regards,
> > > Sicelo
> > > 
> > > [1]
> > > https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
> > > [2]
> > > https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111
> > > 
> > Since this is really a proximity switch (it is either on or off)
> > rather than measuring a proximity value over a continuous range, it
> > doesn't seem like a good fit for the iio subsystem. If the sensor
> > is
> > on a phone, then it is likely to detect human presence so the input
> > subsystem does seem like the right one for that application.
> > 
> > More at
> > https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html
> > 
> 
> I tend to agree; if there are only two discrete states as is the case
> for a
> GPIO, then this is technically a switch and not a sensor. Therefore,
> input
> seems like a better fit; that is just my $.02.
> 
> FWIW, a similar discussion came up a few years ago in [1] and again
> the key
> differentiator was whether the output is discrete or continuous.
> 
> Kind regards,
> Jeff LaBundy
> 
> [1]
> https://lore.kernel.org/linux-iio/9f9b0ff6-3bf1-63c4-eb36-901cecd7c4d9@redhat.com/
> 

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

* Re: supporting binary (near-far) proximity sensors over gpio
  2023-11-26 10:59     ` Philipp Jungkamp
@ 2023-12-04 10:09       ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2023-12-04 10:09 UTC (permalink / raw)
  To: Philipp Jungkamp
  Cc: Jeff LaBundy, David Lechner, Sicelo, linux-iio, maemo-leste,
	Ivaylo Dimitrov, linux-input

On Sun, 26 Nov 2023 11:59:05 +0100
Philipp Jungkamp <p.jungkamp@gmx.net> wrote:

> Hi,
> 
> would it make sense to move the HID human presence driver at
> drivers/iio/light/hid-sensor-prox.c to the input system then? This
> driver only checks for the "Biometric" (0x2004b0) and "Biometric: Human
> Presence" (0x2004b1) HID usages. The former has a vendor defined value
> range, the latter is defined as a boolean switch. See the HID Usage
> Tables, section 21.1 and 21.6.

These boundaries always get messy.  Given there is a value range, it
might get used for something else.
> 
> I take from this discussion that the input subsystem would make more
> sense for the "Biometric: Human Presence" usage.

Potentially yes
> 
> I just wanted to chime in as there seems to be some older precedent for
> a binary sensor in the iio subsystem. I tried to get that sensor
> working for the proximity sensor on my laptop last year.

I guess this one landed because it looked much like the hid light sensors
and no one raised the question at the time (that I recall).

Probably not worth moving it, but we may well have suggested putting
it in input if we'd noticed at the time!

Jonathan

> 
> Regards,
> Philipp Jungkamp
> 
> On Sat, 2023-11-25 at 22:33 -0600, Jeff LaBundy wrote:
> > Hi Sicelo and David,
> > 
> > On Sat, Nov 18, 2023 at 06:09:18PM -0600, David Lechner wrote:  
> > > On Fri, Nov 17, 2023 at 12:22 PM Sicelo <absicsz@gmail.com> wrote:  
> > > > 
> > > > Hi
> > > > 
> > > > Some phones have 1-bit proximity sensors, which simply toggle a
> > > > GPIO
> > > > line to indicate that an object is near or far. Thresholds are
> > > > set at
> > > > hardware level. One such sensor is OSRAM SFH 7741 [1], which is
> > > > used on
> > > > the Nokia N900.
> > > > 
> > > > It is currently exported over evdev, emitting the
> > > > SW_FRONT_PROXIMITY key
> > > > code [2].
> > > > 
> > > > So the question is: should a new, general purpose iio-gpio driver
> > > > be
> > > > written, that would switch such a proximity sensor to the iio
> > > > framework?
> > > > Or evdev is really the best place to support it?
> > > > 
> > > > There are a couple of people who are willing to write such an iio
> > > > driver, if iio is the way to go.
> > > > 
> > > > Regards,
> > > > Sicelo
> > > > 
> > > > [1]
> > > > https://media.digikey.com/pdf/Data%20Sheets/Osram%20PDFs/SFH_7741.pdf
> > > > [2]
> > > > https://elixir.bootlin.com/linux/v6.6.1/source/arch/arm/boot/dts/ti/omap/omap3-n900.dts#L111
> > > >   
> > > Since this is really a proximity switch (it is either on or off)
> > > rather than measuring a proximity value over a continuous range, it
> > > doesn't seem like a good fit for the iio subsystem. If the sensor
> > > is
> > > on a phone, then it is likely to detect human presence so the input
> > > subsystem does seem like the right one for that application.
> > > 
> > > More at
> > > https://www.kernel.org/doc/html/latest/driver-api/iio/intro.html
> > >   
> > 
> > I tend to agree; if there are only two discrete states as is the case
> > for a
> > GPIO, then this is technically a switch and not a sensor. Therefore,
> > input
> > seems like a better fit; that is just my $.02.
> > 
> > FWIW, a similar discussion came up a few years ago in [1] and again
> > the key
> > differentiator was whether the output is discrete or continuous.
> > 
> > Kind regards,
> > Jeff LaBundy
> > 
> > [1]
> > https://lore.kernel.org/linux-iio/9f9b0ff6-3bf1-63c4-eb36-901cecd7c4d9@redhat.com/
> >   
> 


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

end of thread, other threads:[~2023-12-04 10:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 18:21 supporting binary (near-far) proximity sensors over gpio Sicelo
2023-11-19  0:09 ` David Lechner
2023-11-20 17:31   ` Jonathan Cameron
2023-11-20 20:23     ` Sicelo
2023-11-26  4:33   ` Jeff LaBundy
2023-11-26 10:59     ` Philipp Jungkamp
2023-12-04 10:09       ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).