msm8909+android5.1.1 Keyboard Driver------Overview

Source: Internet
Author: User

msm8909+android5.1.1 Keyboard Driver------Overview

Using SN7326 with smart finger scanning keyboard expansion chip, through the I²c interface to read the value of its status register can be known as a single button or multi-button press, you can know the specific key press. The keyboard driver then calls Input_event () to escalate the Linux scan code, such as Key_right, and then pass it on to the Android framework layer, such as:


Figure 1

Here are the main aspects involved in implementing keyboard drivers

1. Input Subsystem

The general types of Linux input devices are complex, including keys, keyboards, touch screens, mice, rocker and so on, they are character devices themselves, and the Linux kernel will be the common abstraction of these devices, simplifying the development of the drive to establish an input subsystem. The input subsystem consists of the core layer (input core), the drive layer, and the event processing layer (EventHandler) three. An input event, such as mouse movement, keyboard keys pressed, joystick movement, etc. through

Input driver, input core, Eventhandler-userspace arrives at the user-space pass to the application.


Figure 2

In addition to the input driver section, the other kernels have been written and basically do not need to be modified, so we need to write an i²c input driver.

2. Linux Kernel i²c device driver

Because we are scanning the keys via the sn7326 chip based on the I²c interface, we need to write the I²C device driver.

The Linux kernel I²c device driver consists of 3 layers [10], which are: I²c Bus drive (I²c core), I²c Controller driver (I²c adapter) and I²c device driver (i²c driver). I²c bus driver mainly realizes the management of I²c bus and controller and device driver. This part of the code is a common part, the Linux kernel has been perfected, no need to change. I²C controller driver is related to hardware, mainly constructs a data structure with the interface of the I²c bus layer, and registers a controller with the I²C bus via the interface function. At the same time, the realization of the function of the I²C device is realized by realizing the processing function of the interrupt of the I²C controller. I²c device driver mainly constructs a data structure with the interface of the I²c bus layer, and registers an I²C device driver through the interface function to the I²C bus layer. At the same time constructs a data structure with the user layer interface, through the interface function to register a character device to the kernel.

We are here to develop an I²C device driver.

3. Key hardware code, Linux scan code and Android keyboard code

3.1 Key Hardware Code

Hardware code is my name, that is, when the button is pressed, the initial key identification code value, this and the specific key design, the use of the keyboard expansion IC chip design related, such as sn7326


Figure 3

The mapping table here is the hardware code value.

3.2 Linux Scan Code

The scan code is the code value specified in the Linuxinput system, like the key value of each key on the PC keyboard. are numbers. After entering the command on the device, the key can detect the scan code of each key.

The scan code for Linux is defined in \kernel\include\uapi\linux\input.h, such as:/* *keys and buttons * *most of the keys/buttons is modeled after USB H UT 1.12 * (see http://www.usb.org/developers/hidpage). *abbreviations in the comments: * ac-application control * al-application Launch Button * Sc-system control */#define key_reserved           0#define key_esc               1#define key_1                   2#define key_2                   3#define key_3                   4#define key_4                   5 #define KEY_5                   6#define key_6                   7#define key_7                   8#define key_8                   9#define key_9                   10#define key_0                   11

3.3 Android Keyboard code

Android also defines a set of code, called the keyboard code, through a/system/usr/keylayout/to the two sets of code to match up. SN7326.KL is used here. (If there is no other *.kl, it is the default QWERTY.KL)

/FRAMEWORKS/BASE/DATA/KEYBOARDS/GENERIC.KL definitions, such as:

# # Generic key layout file for fullalphabetic US 中文版 PC Style external keyboards.## This file is intentionally very GE Nericand is intended to support a broad rang of keyboards.# does not edit the generic key layout tosupport a specific Keyboa Rd  Instead, create# a new key layout file with the Requiredkeyboard configuration.# key 1    escapekey 2    1key 3    2key 4    3key 5    4key 6    5key 7    6key 8    7key 9    8key ten   9key   0


Reference http://blog.csdn.net/kangear/article/details/12110951

msm8909+android5.1.1 Keyboard Driver------Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.