Today, a small project is finally settled. Although my work in it is very simple, I still have some experiences and want to share with you.
First, we need to know why the driver in the Linux kernel can be compiled into the kernel. Here there are two important files that have to be mentioned: kconfig and makefile. Kconfig is distributed in various directories. These kconfig files constitute a distributed Kernel configuration database. Each kconfig describes the Kernel configuration menus related to the directory source document, this is the configuration menu generated after we use make menuconfig. This menu contains multiple layers, each of which is generated by kconfig in each directory. You can choose how to compile the kernel according to your needs, and then compile the kernel according to the. config result when executing makefile. The compilation process is completed through the kbuild system. It is not helpful to check the information in the specific process.
Through the above understanding, we can clearly understand what we need to do when we need to add or transplant drivers. If you do not understand it, you need to know that you are really a dish. However, if you have the patience, you can easily get started.
First, we need to add the module name of the file in kconfig. Here we can refer to the configuration of other modules in kconfig, of course, it should be clear that our configuration will affect whether the Loading Method of our modules is loaded by default or dynamic loading is required. This reminds us of our usual configuration options. Is it a little excited? After the kernel is added, users who use the kernel will be able to see and choose the kernel on their own.
Then, add the file corresponding to this module in makefile. Note the name of the file module and the file type of the module. Believe what you know ...... If ($ (XXX), Y) is also seen here. The judgment here is based on. config. The. config file in Android may be different ...... Actually, it is not unique to Android ......
Finally, we began to write our own drivers ......
However, sometimes the compilation will not take effect during the compilation process. In this case, we need to delete all the compiled target files and re-compile them. In particular, the kernel files are very interesting here ...... I may add this part in subsequent articles. Coming soon !!!!
Next let's take a look at the touch screen.
The touch screen is divided into XXX points, and XXXX are available ......
Let's give a brief introduction ...... I think the difference between the touch screen and other devices is in the register Settings section. Android provides services for input devices in the framework/base/Server/Input Folder. Therefore, by studying the eventhub. cpp file, we can find that the device is differentiated based on the register bit settings. Therefore, we will also write articles here in the driver, and the reading of reporting events is implemented in the inputreader. cpp file. Therefore, we should also pay attention to it during reporting.
Inputreader. cpp processes touch screens in two types of events: singletouchinputmappe and multipoint touch multitouchinputmapper. Both classes inherit touchinputmapper, which is used by synctouch to process the final touch screen action sending. For more information about device registration, reporting, and parameter definitions on the touch screen, see related blog posts. Recommended http://blog.csdn.net/andyhuabing/article/details/7085725 here
Specifically, we need to pay attention to three main points: one is the bus of the device, the connection method of the device, and the deshake processing of the device.
Connection Method
The connection method here mainly introduces the gpio method. This method is relatively simple. It mainly uses the APIS provided in Linux/gpio. h to declare tags and map gpio to IRQ interrupt.
Bus
Here, the iic bus is used, and the IIC driver architecture is used in Linux. I2c_add_driver () and i2c_del_driver ().
Shake
Many methods can be found online here. I suggest using the method of delay during interruption.
Enter technical information:
The android input subsystem supports a variety of devices, including the keyboard, joystick, trackball, mouse, and touch screen. The following describes how to write a touch screen device driver in the input device driver.
Enter the device configuration file
The input device configure file (. IDC File) contains configuration parameters for different devices, which affects the input device behavior.
Because the system supports standard input devices by default, IDC files are unnecessary for these devices. Such devices include standard physical devices such as the hid keyboard and mouse. However, some embedded input devices, especially touch screens, need IDC files to describe their behaviors.
Cause:
Android will automatically detect and configure most input devices based on the event types and parameters of the input device driver in the Linux kernel. This section will not be used as an example.
Positioning:
Enter the device configuration file to locate the device by using the USB product or product ID or by entering the device name. The configuration file is generally described in the product configuration file under the Device directory, so I will not take the Code as an example, because of the company's reasons ...... Note that the configuration of device. type may be the cause of device failure. But how can it take effect?
In Android, the configuration file takes effect through Mmm frameworks/base/tools/validatekeymaps. Install: Out/host/linux-x86/bin/validatekeymaps.
Keymap validation tool
Usage:
Validatekeymaps [*. Kl] [*. KCM] [*. IDC] [virtualkeys. *] [...]
Validates the specified key layouts, key character maps,
Input Device mappings, or virtual key definitions.
At this time, we can use the tool.