iio A/D converter input to input event subsystem
Hi,
I would like to use a couple of resistors and keys and one Analog input[1], read the analogue voltage from a kernel driver, figure out which key is pressed and pass this on to the Linux input subsystem. (Am I really the only one with this use case?)
In my specific case it's about a beagle bone black, which means that the A/D driver is an iio adc driver[2].
How would it be possible to reuse the iio A/D converter driver code for my driver? Maybe it would even be possible to create something more generic so iio A/D converter channels could be used as input keys. Some sample code which would enable me to choose an analog input and read from it from kernel space would help me to write some basic sample driver, I guess.
The reason I would like to write a device driver instead of a user space application is mainly the input subsystem. From the user space application's point of view utilizing a device driver which feeds the input subsystem would make it easy to exchange what's underneath without user space even noticing. (keys to Input pins, a key matrix to I/O pins, i2c input, A/D converter,...).
Regards,
Robert
[1] http://21stdigitalhome.blogspot.gr/2013/11/sensing-switches-on-analog-input.html
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/adc/ti_am335x_adc.c?id=refs/tags/v3.16-rc7
Hi Robert,
Quoted 17 lines · On 02/08/2014 at 13:14:30 -0500, [email protected] wrote :
Hi,
I would like to use a couple of resistors and keys and one Analog input[1], read the analogue voltage from a kernel driver, figure out which key is pressed and pass this on to the Linux input subsystem. (Am I really the only one with this use case?)
In my specific case it's about a beagle bone black, which means that the A/D driver is an iio adc driver[2].
How would it be possible to reuse the iio A/D converter driver code for my driver? Maybe it would even be possible to create something more generic so iio A/D converter channels could be used as input keys. Some sample code which would enable me to choose an analog input and read from it from kernel space would help me to write some basic sample driver, I guess.
Quoted 7 lines
The reason I would like to write a device driver instead of a user space application is mainly the input subsystem. From the user space application's point of view utilizing a device driver which feeds the input subsystem would make it easy to exchange what's underneath without user space even noticing. (keys to Input pins, a key matrix to I/O pins, i2c input, A/D converter,...).
Did you have a look at uinput? This would allow you to inject input events after processing the ADC values in userspace.
Simple example: http://thiemonge.org/getting-started-with-uinput
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Hi,
Quoted 7 lines · Alexandre Belloni
Hi Robert,
Did you have a look at uinput? This would allow you to inject input events after processing the ADC values in userspace.
Simple example: http://thiemonge.org/getting-started-with-uinput
Thanks this looks interesting. I had in the meantime a look at iio_hwmon [1] which does something similar to what I want for the hwmon subsystem instead of the input event subsystem.
Regards,
Robert
Jonathan Cameron
maintainerQuoted 6 lines · On 03/08/14 16:08, [email protected] wrote:
Hi,
Quoted 3 lines · Alexandre Belloni
Hi Robert,
Quoted 7 lines
Quoted 4 lines
Did you have a look at uinput? This would allow you to inject input events after processing the ADC values in userspace.
Simple example: http://thiemonge.org/getting-started-with-uinput
Thanks this looks interesting. I had in the meantime a look at
iio_hwmon[1] which does something similar to what I want for the hwmon subsystem instead of the input event subsystem.
There is a rather aged iio_input driver, that uses the buffered interface (not polled) and could probably be adapted to your usecase reasonably easily. The case is different enough that I'd probably suggest a new driver for it though rather than trying to blugeon it into the existing driver.
http://www.spinics.net/lists/linux-iio/msg06881.html (latest version I think). The infrastructure for this went in back then, but the input driver never quite got the attention it needed.
One big issue outstanding around this stuff is that no one likes the device tree bindings. Probably doesn't matter for your project in the short term however!
Jonathan
Quoted 6 lines
Regards,
Robert
=
Hi,
Quoted 5 lines · Jonathan Cameron
http://www.spinics.net/lists/linux-iio/msg06881.html (latest version I think). The infrastructure for this went in back then, but the input driver never quite got the
attention it needed.
Thanks!
I'll try to have some hardware prototype by end of August and will see if I can get my stuff to work as Alexandre suggested.
Ideally I'll try to cook up something similar to your iio_input stuff.
Which mainline kernel version would you suggest?
3.14 or 3.16?
Regards,
Robert
Jonathan Cameron
maintainerQuoted 11 lines · On 03/08/14 17:39, [email protected] wrote:
Hi,
Quoted 5 lines · Jonathan Cameron
http://www.spinics.net/lists/linux-iio/msg06881.html (latest version I think). The infrastructure for this went in back then, but the input driver never quite got the
attention it needed.Thanks!
Quoted 7 lines
I'll try to have some hardware prototype by end of August and will see if I can get my stuff to work as Alexandre suggested.
Ideally I'll try to cook up something similar to your
iio_inputstuff.Which mainline kernel version would you suggest?
3.14 or 3.16?
Always as recent as possible. Anything else makes getting support from anyone tricky as no one can remember how it used to work :)
Jonathan
Quoted 10 lines
Regards,
Robert
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html