androidlinux-kernellinux-device-driverspiinput-devices

How input received by SPI may be interpreted by Android


This is my first question on stackoverflow even though I'm a continuous reader of this problem-solving source.

Anyway, this is the issue I'm facing :

I'm trying to connect with a bus SPI two evalboards :

I would like to connect those two by SPI and send from the Linux one to Android the touch sequence (according to the multi-touch protocol (https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt)). spidev is enabled, but I have no idea about how to "perform" the touches I will receive.

From what I see : I can't use Android input Devices (https://source.android.com/devices/input/input-device-configuration-files.html) because it can't rely on SPI communication. Must I create a driver in the linux kernel then ? What is the "best practice" in this particular situation ?

Thanks in advance, you might be saving my internship :)


Solution

  • If your Android Linux kernel is set up to expose /dev/spidev (or you can set that up in the kernel), you do not have to create a Linux kernel module. You can access /dev/spidev from Android by writing an NDK wrapper in c/c++. I have done that and it works. I would suggest that you start with writing a small c-program that configures and opens a /dev/spidev spi channel, and sends/receives some test data. When that works, rewrite the c-program into an NDK wrapper library you can access from an Android program.

    This assumes that the Android app is one you write yourself. If you want to make the touch-events available to Android in general, I think you need to write a touch-driver as a kernel module.