This chapter focuses on the hardware abstraction layer:HAL. Hal is built on Linux Drive A set of libraries,Google for Android to join HAL mainly for the purpose of the following.
1. Calling interface for unified hardware
2. Fixed the issue of GPI copyright
3. For a number of special requirements
In the LED driver, we joined HAL to use the program does not need to care about the Linux driver and device files interactive way. To write a Linux driver that supports HAL:
First step: Writing Linux drivers
Step two: Write the HAL Library
Step three: Write the Service library
The steps and principles for writing the HAL module are as follows:
First step: defining structs and macros
Describes the hw-module-t structure of the HAL module
Describes the hw-device-t structure of a HAL device
HW-MODULE-METHODS-T Structure describing the module entry function
Step two: Write the HAL module's open function
Step three: Define HW-MODULE-METHODS-T structure variables
Fourth step: Define the hal-module-info-sym variable
Fifth step: Write the close function of the HAL module
Sixth step: Write the function that controls the LED
Linux drivers are used in Android systems in two ways. One is the traditional way to directly interact with the Linux driver, the other is Android -specific, is the HAL module.
Android Deep Explore (Vol. 1) Hal with Driver Development Nineth Chapter reading notes