Replacing Touchscreen driver in Android Kernel

2020-07-10 02:40发布

问题:

I'm adapting a Gingerbread kernel for my custom board. I'm trying to replace a resistive touch screen that uses an on-chip ADC controller (S5PV210 processor from Samsung). In my design, I need a capacitive controller supported by eGalaxyTouch driver. It's connected to the USB. The driver can be easily enabled from the "make xconfig" menu. It somewhat works since I added some traces on the serial console and I can see it installing during the kernel boot and I see it install and uninstall itself when connecting/disconnecting the USB cable. But it doesn't do anything in the Android user interface. It is an HID type device. The problem is it does not hook-up to the proper Android touchscreen software layer. I must have miss something. There must be something else to call to force this HID to be connected to another software layer managing the touchscreen.

The touchscreen drivers are located at kernel/drivers/input/touchscreen. There is also some code straight in kernel/drivers/input.

Any clues on how to link that HID device to the Android Touchscreen layer? I look how they did the old resistive one and it is not done through an HID because it's a "custom made" device with ADCs integrated in the CPU and it's not going through USB.

回答1:

I succeeded to integrate the touchscreen driver. Here is a rough idea of the steps just to give an idea of how it works for the others who would face the same kind of problem.

First remove the original touchscreen driver to prevent conflict (make xconfig)

Originally, I had a driver that doesn't work eventhough it was provided by the touchscreen manufacturer. I decided to try the eGalax touchscreen driver already in the Kernel tree. This is a module driver. It is not enough to enable "module device drivers" in the make xconfig. Yes, it will allow to compile the .ko files. but it will not tell the building script what to do with the file.ko and they will not end up going with the kernel in the target system. So you have to take action by adding stuff to the build script or manually copy the file.ko in the proper root/modules location and add the loading of the module with the "insmod /modules/file.ko" command in the init.rc file. Don't forget to set the proper privileged to /modules and modules/file.ko with chmod command.

After that it basically worked, except for some minor problems not related to that question (the driver was for a slightly different chip with bits placed differently, easy to fix).