未验证 提交 0deeff72 编写于 作者: O openharmony_ci 提交者: Gitee

!4013 【OpenHarmony开源贡献者计划2022】ADC,DAC,GPIO,HDMI等相关格式及表达问题

Merge pull request !4013 from king_he/driver-3a
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
## Overview<a name="section1"></a> ## Overview<a name="section1"></a>
- An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals. An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
- The ADC APIs provide a set of common functions for ADC data transfer, including: The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device - Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result - Obtaining the analog-to-digital (AD) conversion result
**Figure 1** ADC physical connection<a name="fig1"></a> **Figure 1** ADC physical connection<a name="fig1"></a>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
The analog-to-digital converter \(ADC\) is a device that converts analog signals into digital signals. In the Hardware Driver Foundation \(HDF\), the ADC module uses the unified service mode for API adaptation. In this mode, a device service is used as the ADC manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the ADC has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The analog-to-digital converter \(ADC\) is a device that converts analog signals into digital signals. In the Hardware Driver Foundation \(HDF\), the ADC module uses the unified service mode for API adaptation. In this mode, a device service is used as the ADC manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the ADC has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services.
**Figure 1** Unified service mode<a name="fig14423182615525"></a> **Figure 1** Unified service mode<a name="fig14423182615525"></a>
![](figures/unified-service-mode.png "ADC-unified-service-mode") ![](figures/unified-service-mode.png "ADC-unified-service-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -19,7 +19,7 @@ struct AdcMethod { ...@@ -19,7 +19,7 @@ struct AdcMethod {
}; };
``` ```
**Table 1** Callbacks for the members in the AdcMethod structure **Table 1** Callbacks for the members in the AdcMethod structure
<a name="table1943202316536"></a> <a name="table1943202316536"></a>
<table><thead align="left"><tr id="row2451223135315"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p845123185313"><a name="p845123185313"></a><a name="p845123185313"></a>Callback</p> <table><thead align="left"><tr id="row2451223135315"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p845123185313"><a name="p845123185313"></a><a name="p845123185313"></a>Callback</p>
...@@ -76,39 +76,36 @@ struct AdcMethod { ...@@ -76,39 +76,36 @@ struct AdcMethod {
The ADC module adaptation involves the following steps: The ADC module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **adc\_config.hcs** file. - \(Optional\) Add the **adc\_config.hcs** file.
3. Instantiate the ADC controller object. 3. Instantiate the ADC controller object.
- Initialize **AdcDevice**. - Initialize **AdcDevice**.
- Instantiate **AdcMethod** in the **AdcDevice** object. - Instantiate **AdcMethod** in the **AdcDevice** object.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis). 4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
## Development Example<a name="section1745221471165048"></a> ## Development Example<a name="section1745221471165048"></a>
The following uses **adc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **adc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits.
- ADC driver entry reference - ADC driver entry reference
Many devices may connect to the ADC. In the HDF, a manager object needs to be created for the ADC. When a device needs to be started, the manager object locates the device based on the specified parameters. Many devices may connect to the ADC. In the HDF, a manager object needs to be created for the ADC. When a device needs to be started, the manager object locates the device based on the specified parameters.
The driver of the ADC manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **AdcDeviceAdd** function of the core layer must be called to implement the corresponding features. The driver of the ADC manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **AdcDeviceAdd** function of the core layer must be called to implement the corresponding features.
``` ```
static struct HdfDriverEntry g_hi35xxAdcDriverEntry = { static struct HdfDriverEntry g_hi35xxAdcDriverEntry = {
...@@ -129,9 +126,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -129,9 +126,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
HDF_INIT(g_adcManagerEntry); HDF_INIT(g_adcManagerEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **adc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **AdcDevice** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **adc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **AdcDevice** members at the core layer.
In the unified service mode, the first device node in the **device\_info** file must be the ADC manager, and the parameters must be set as follows: In the unified service mode, the first device node in the **device\_info** file must be the ADC manager, and the parameters must be set as follows:
<a name="table1344068233165048"></a> <a name="table1344068233165048"></a>
<table><thead align="left"><tr id="row1551612465165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1856185125165048p0"><a name="entry1856185125165048p0"></a><a name="entry1856185125165048p0"></a>Member</p> <table><thead align="left"><tr id="row1551612465165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1856185125165048p0"><a name="entry1856185125165048p0"></a><a name="entry1856185125165048p0"></a>Member</p>
...@@ -163,9 +160,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -163,9 +160,9 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
</tbody> </tbody>
</table> </table>
Configure ADC controller information from the second node. This node specifies a type of ADC controllers rather than an ADC controller. In this example, there is only one ADC device. If there are multiple ADC devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **adc\_config** file. Configure ADC controller information from the second node. This node specifies a type of ADC controllers rather than an ADC controller. In this example, there is only one ADC device. If there are multiple ADC devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **adc\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -221,10 +218,10 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -221,10 +218,10 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
} }
``` ```
3. Initialize the **AdcDevice** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **AdcMethod** \(used to call underlying functions of the driver\) in **AdcDevice**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **AdcDevice** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **AdcMethod** \(used to call underlying functions of the driver\) in **AdcDevice**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **adc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **AdcDevice** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **adc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **AdcDevice** object at the core layer.
``` ```
struct Hi35xxAdcDevice { struct Hi35xxAdcDevice {
...@@ -254,7 +251,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -254,7 +251,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
}; };
``` ```
- Instantiate the callback function structure **AdcMethod** in **AdcDevice**. The **AdcLockMethod** callback function structure is not implemented in this example. To instantiate the structure, refer to the I2C driver development. Other members are initialized in the **Init** function. - Instantiate the callback function structure **AdcMethod** in **AdcDevice**. The **AdcLockMethod** callback function structure is not implemented in this example. To instantiate the structure, refer to the I2C driver development. Other members are initialized in the **Init** function.
``` ```
static const struct AdcMethod g_method = { static const struct AdcMethod g_method = {
...@@ -268,11 +265,11 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -268,11 +265,11 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table127573104165048"></a> <a name="table127573104165048"></a>
<table><thead align="left"><tr id="row1932243367165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry405408385165048p0"><a name="entry405408385165048p0"></a><a name="entry405408385165048p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row1932243367165048"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry405408385165048p0"><a name="entry405408385165048p0"></a><a name="entry405408385165048p0"></a>Status (Value)</p>
...@@ -316,7 +313,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -316,7 +313,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Initializes the custom structure object and **AdcDevice**, and calls the **AdcDeviceAdd** function at the core layer. Initializes the custom structure object and **AdcDevice**, and calls the **AdcDeviceAdd** function at the core layer.
``` ```
static int32_t Hi35xxAdcInit(struct HdfDeviceObject *device) static int32_t Hi35xxAdcInit(struct HdfDeviceObject *device)
...@@ -371,7 +368,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -371,7 +368,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -379,7 +376,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -379,7 +376,7 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void Hi35xxAdcRelease(struct HdfDeviceObject *device) static void Hi35xxAdcRelease(struct HdfDeviceObject *device)
...@@ -414,7 +411,4 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha ...@@ -414,7 +411,4 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
OsalMemFree(hi35xx); OsalMemFree(hi35xx);
} }
return return
``` ```
\ No newline at end of file
...@@ -42,7 +42,8 @@ The DAC module is divided into the following layers: ...@@ -42,7 +42,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices. - The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode **Figure 1** Unified service mode
...@@ -88,10 +89,10 @@ DevHandle DacOpen(uint32_t number); ...@@ -88,10 +89,10 @@ DevHandle DacOpen(uint32_t number);
**Table 2** Description of DacOpen **Table 2** Description of DacOpen
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | ----------------- | | ---------- | ----------------- |
| number | DAC device number. | | number | DAC device number. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| NULL | Failed to open the DAC device. | | NULL | Failed to open the DAC device. |
| Device handle | Handle of the DAC device opened.| | Device handle | Handle of the DAC device opened.|
...@@ -119,7 +120,7 @@ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); ...@@ -119,7 +120,7 @@ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
**Table 3** Description of DacWrite **Table 3** Description of DacWrite
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | -------------- | | ---------- | -------------- |
| handle | DAC device handle. | | handle | DAC device handle. |
| channel | DAC channel number. | | channel | DAC channel number. |
...@@ -148,7 +149,7 @@ void DacClose(DevHandle handle); ...@@ -148,7 +149,7 @@ void DacClose(DevHandle handle);
**Table 4** Description of DacClose **Table 4** Description of DacClose
| **Parameter** | Description | | **Parameter** | Description |
| ---------- | -------------- | | ---------- | -------------- |
| handle | DAC device handle. | | handle | DAC device handle. |
| **Return Value**| **Description**| | **Return Value**| **Description**|
...@@ -208,4 +209,4 @@ static int32_t TestCaseDac(void) ...@@ -208,4 +209,4 @@ static int32_t TestCaseDac(void)
return 0; return 0;
} }
``` ```
\ No newline at end of file
...@@ -36,7 +36,8 @@ The DAC module is divided into the following layers: ...@@ -36,7 +36,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices. - The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode<a name="fig14423182615525"></a> **Figure 1** Unified service mode<a name="fig14423182615525"></a>
...@@ -129,7 +130,7 @@ The DAC module adaptation procedure is as follows: ...@@ -129,7 +130,7 @@ The DAC module adaptation procedure is as follows:
Configure DAC controller information from the second node. This node specifies a type of DAC controllers rather than a specific DAC controller. In this example, there is only one DAC device. If there are multiple DAC devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **dac_config** file. Configure DAC controller information from the second node. This node specifies a type of DAC controllers rather than a specific DAC controller. In this example, there is only one DAC device. If there are multiple DAC devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **dac_config** file.
**device_info.hcs** configuration reference **device_info.hcs** configuration reference
``` ```
root { root {
...@@ -283,15 +284,15 @@ The DAC module adaptation procedure is as follows: ...@@ -283,15 +284,15 @@ The DAC module adaptation procedure is as follows:
}; };
``` ```
![](../public_sys-resources/icon-note.gif) **NOTE**<br/> >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
For details about **DacMethod**, see [Available APIs](#available-apis). >For details about **DacMethod**, see [Available APIs](#available-apis).
- **Init** function - **Init** function
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value: Return value:
...@@ -388,11 +389,11 @@ The DAC module adaptation procedure is as follows: ...@@ -388,11 +389,11 @@ The DAC module adaptation procedure is as follows:
} }
``` ```
- **Release** function - **Release** function
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value Return value
...@@ -465,6 +466,4 @@ The DAC module adaptation procedure is as follows: ...@@ -465,6 +466,4 @@ The DAC module adaptation procedure is as follows:
4. Debug the driver. 4. Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded. (Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
\ No newline at end of file
...@@ -15,7 +15,7 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -15,7 +15,7 @@ The GPIO APIs define a set of standard functions for performing operations on GP
## Available APIs<a name="section589913442203"></a> ## Available APIs<a name="section589913442203"></a>
**Table 1** APIs available for the GPIO driver **Table 1** APIs available for the GPIO driver
<a name="table89681075215"></a> <a name="table89681075215"></a>
<table><thead align="left"><tr id="row996807162115"><th class="cellrowborder" valign="top" width="19.74%" id="mcps1.2.4.1.1"><p id="p296817716212"><a name="p296817716212"></a><a name="p296817716212"></a>Capability</p> <table><thead align="left"><tr id="row996807162115"><th class="cellrowborder" valign="top" width="19.74%" id="mcps1.2.4.1.1"><p id="p296817716212"><a name="p296817716212"></a><a name="p296817716212"></a>Capability</p>
...@@ -75,16 +75,16 @@ The GPIO APIs define a set of standard functions for performing operations on GP ...@@ -75,16 +75,16 @@ The GPIO APIs define a set of standard functions for performing operations on GP
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section259614242196"></a> ## Usage Guidelines<a name="section259614242196"></a>
### How to Use<a name="section103477714216"></a> ### How to Use<a name="section103477714216"></a>
The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO. The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO.
**Figure 1** Process of using a GPIO<a name="fig16151101653713"></a> **Figure 1** Process of using a GPIO<a name="fig16151101653713"></a>
![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio") ![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio")
### Determining a GPIO Pin Number<a name="section370083272117"></a> ### Determining a GPIO Pin Number<a name="section370083272117"></a>
...@@ -116,7 +116,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -116,7 +116,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\); int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\);
**Table 2** Description of GpioSetDir **Table 2** Description of GpioSetDir
<a name="table63111557616"></a> <a name="table63111557616"></a>
<table><tbody><tr id="row17311165469"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p53110515616"><a name="p53110515616"></a><a name="p53110515616"></a><strong id="b1142022718160"><a name="b1142022718160"></a><a name="b1142022718160"></a>Parameter</strong></p> <table><tbody><tr id="row17311165469"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p53110515616"><a name="p53110515616"></a><a name="p53110515616"></a><strong id="b1142022718160"><a name="b1142022718160"></a><a name="b1142022718160"></a>Parameter</strong></p>
...@@ -159,7 +159,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -159,7 +159,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\); int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\);
**Table 3** Description of GpioRead **Table 3** Description of GpioRead
<a name="table20347743174816"></a> <a name="table20347743174816"></a>
<table><tbody><tr id="row17348144394816"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p19348164313481"><a name="p19348164313481"></a><a name="p19348164313481"></a><strong id="b4862227121610"><a name="b4862227121610"></a><a name="b4862227121610"></a>Parameter</strong></p> <table><tbody><tr id="row17348144394816"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p19348164313481"><a name="p19348164313481"></a><a name="p19348164313481"></a><strong id="b4862227121610"><a name="b4862227121610"></a><a name="b4862227121610"></a>Parameter</strong></p>
...@@ -199,7 +199,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -199,7 +199,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\); int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\);
**Table 4** Description of GpioWrite **Table 4** Description of GpioWrite
<a name="table1214911207520"></a> <a name="table1214911207520"></a>
<table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p> <table><tbody><tr id="row6149720175218"><td class="cellrowborder" valign="top" width="48.120000000000005%"><p id="p18149132005216"><a name="p18149132005216"></a><a name="p18149132005216"></a><strong id="b19864427181615"><a name="b19864427181615"></a><a name="b19864427181615"></a>Parameter</strong></p>
...@@ -269,7 +269,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -269,7 +269,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\); int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\);
**Table 5** Description of GpioSetIrq **Table 5** Description of GpioSetIrq
<a name="table16804111812466"></a> <a name="table16804111812466"></a>
<table><tbody><tr id="row880401834615"><td class="cellrowborder" valign="top" width="48.54%"><p id="p380491819469"><a name="p380491819469"></a><a name="p380491819469"></a><strong id="b0865192761614"><a name="b0865192761614"></a><a name="b0865192761614"></a>Parameter</strong></p> <table><tbody><tr id="row880401834615"><td class="cellrowborder" valign="top" width="48.54%"><p id="p380491819469"><a name="p380491819469"></a><a name="p380491819469"></a><strong id="b0865192761614"><a name="b0865192761614"></a><a name="b0865192761614"></a>Parameter</strong></p>
...@@ -316,13 +316,13 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -316,13 +316,13 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
</table> </table>
>![](../public_sys-resources/icon-caution.gif) **CAUTION:** >![](../public_sys-resources/icon-caution.gif) **CAUTION:**
>Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced. >Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced.
If the ISR function is no longer required, call the following function to cancel the setting: If the ISR function is no longer required, call the following function to cancel the setting:
int32\_t GpioUnSetIrq\(uint16\_t gpio\); int32\_t GpioUnSetIrq\(uint16\_t gpio\);
**Table 6** Description of GpioUnSetIrq **Table 6** Description of GpioUnSetIrq
<a name="table1157224664316"></a> <a name="table1157224664316"></a>
<table><tbody><tr id="row175721546174317"><td class="cellrowborder" valign="top" width="48.54%"><p id="p16572144694311"><a name="p16572144694311"></a><a name="p16572144694311"></a><strong id="b16866132761617"><a name="b16866132761617"></a><a name="b16866132761617"></a>Parameter</strong></p> <table><tbody><tr id="row175721546174317"><td class="cellrowborder" valign="top" width="48.54%"><p id="p16572144694311"><a name="p16572144694311"></a><a name="p16572144694311"></a><strong id="b16866132761617"><a name="b16866132761617"></a><a name="b16866132761617"></a>Parameter</strong></p>
...@@ -357,7 +357,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -357,7 +357,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioEnableIrq\(uint16\_t gpio\); int32\_t GpioEnableIrq\(uint16\_t gpio\);
**Table 7** Description of GpioEnableIrq **Table 7** Description of GpioEnableIrq
<a name="table26659291568"></a> <a name="table26659291568"></a>
<table><tbody><tr id="row866632919566"><td class="cellrowborder" valign="top" width="50%"><p id="p066642985615"><a name="p066642985615"></a><a name="p066642985615"></a><strong id="b108661927171614"><a name="b108661927171614"></a><a name="b108661927171614"></a>Parameter</strong></p> <table><tbody><tr id="row866632919566"><td class="cellrowborder" valign="top" width="50%"><p id="p066642985615"><a name="p066642985615"></a><a name="p066642985615"></a><strong id="b108661927171614"><a name="b108661927171614"></a><a name="b108661927171614"></a>Parameter</strong></p>
...@@ -395,7 +395,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ...@@ -395,7 +395,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll
int32\_t GpioDisableIrq\(uint16\_t gpio\); int32\_t GpioDisableIrq\(uint16\_t gpio\);
**Table 8** Description of GpioDisableIrq **Table 8** Description of GpioDisableIrq
<a name="table186682041918"></a> <a name="table186682041918"></a>
<table><tbody><tr id="row186684413116"><td class="cellrowborder" valign="top" width="50%"><p id="p866844916"><a name="p866844916"></a><a name="p866844916"></a><strong id="b88678273169"><a name="b88678273169"></a><a name="b88678273169"></a>Parameter</strong></p> <table><tbody><tr id="row186684413116"><td class="cellrowborder" valign="top" width="50%"><p id="p866844916"><a name="p866844916"></a><a name="p866844916"></a><strong id="b88678273169"><a name="b88678273169"></a><a name="b88678273169"></a>Parameter</strong></p>
...@@ -545,5 +545,4 @@ static int32_t TestCaseGpioIrqEdge(void) ...@@ -545,5 +545,4 @@ static int32_t TestCaseGpioIrqEdge(void)
(void)GpioUnSetIrq(gpio); (void)GpioUnSetIrq(gpio);
return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE; return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE;
} }
``` ```
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
## Overview<a name="section1826197354103451"></a> ## Overview<a name="section1826197354103451"></a>
In the Hardware Driver Foundation \(HDF\) framework, the general-purpose input/output \(GPIO\) module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object. In the Hardware Driver Foundation \(HDF\) framework, the general-purpose input/output \(GPIO\) module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig5511033193814"></a> **Figure 1** Service-free mode<a name="fig5511033193814"></a>
![](figures/service-free-mode.png "service-free-mode") ![](figures/service-free-mode.png "service-free-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -26,7 +26,7 @@ struct GpioMethod { ...@@ -26,7 +26,7 @@ struct GpioMethod {
int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local); int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local);
} }
``` ```
**Table 1** Callbacks for the members in the GpioMethod structure **Table 1** Callbacks for the members in the GpioMethod structure
<a name="table151341544111"></a> <a name="table151341544111"></a>
<table><thead align="left"><tr id="row19514101504111"><th class="cellrowborder" align="center" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p451461513418"><a name="p451461513418"></a><a name="p451461513418"></a>Callback</p> <table><thead align="left"><tr id="row19514101504111"><th class="cellrowborder" align="center" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p451461513418"><a name="p451461513418"></a><a name="p451461513418"></a>Callback</p>
...@@ -152,32 +152,30 @@ The GPIO controller manages all pins by group. The related parameters are descri ...@@ -152,32 +152,30 @@ The GPIO controller manages all pins by group. The related parameters are descri
The GPIO module adaptation involves the following steps: The GPIO module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **gpio\_config.hcs** file. - \(Optional\) Add the **gpio\_config.hcs** file.
3. Instantiate the GPIO controller object. 3. Instantiate the GPIO controller object.
- Initialize **GpioCntlr**. - Initialize **GpioCntlr**.
- Instantiate **GpioMethod** in the **GpioCntlr** object. - Instantiate **GpioMethod** in the **GpioCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:** For details, see [Available APIs](#section752964871810).
>For details, see [Available APIs](#section752964871810).
4. Debug the driver. 4. \(Optional\) Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts. For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts.
## Development Example<a name="section800425816103451"></a> ## Development Example<a name="section800425816103451"></a>
The following uses **gpio\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **gpio\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits.
- GPIO driver entry reference - GPIO driver entry reference
...@@ -193,11 +191,11 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -193,11 +191,11 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
HDF_INIT(g_gpioDriverEntry); HDF_INIT(g_gpioDriverEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **gpio\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **GpioCntlr** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **gpio\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **GpioCntlr** members at the core layer.
In this example, there is only one GPIO controller. If there are multiple GPIO controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **gpio\_config** file. In this example, there is only one GPIO controller. If there are multiple GPIO controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **gpio\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -220,7 +218,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -220,7 +218,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
} }
``` ```
- **gpio\_config.hcs** configuration reference - **gpio\_config.hcs** configuration reference
``` ```
root { root {
...@@ -240,10 +238,10 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -240,10 +238,10 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
} }
``` ```
3. Initialize the **GpioCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **GpioMethod** \(used to call underlying functions of the driver\) in **GpioCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **GpioCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **GpioMethod** \(used to call underlying functions of the driver\) in **GpioCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **gpio\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the index and the number of pins, are also passed to the **GpioCntlr** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **gpio\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the index and the number of pins, are also passed to the **GpioCntlr** object at the core layer.
``` ```
struct Pl061GpioCntlr { struct Pl061GpioCntlr {
...@@ -279,7 +277,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -279,7 +277,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
}; };
``` ```
- Instantiate the callback function structure **GpioMethod** in **GpioCntlr**. Other members are initialized by using the **Init** function. - Instantiate the callback function structure **GpioMethod** in **GpioCntlr**. Other members are initialized by using the **Init** function.
``` ```
// The members of the GpioMethod structure are all callbacks. Vendors need to implement the corresponding functions according to [Table 1](#table151341544111). // The members of the GpioMethod structure are all callbacks. Vendors need to implement the corresponding functions according to [Table 1](#table151341544111).
...@@ -304,13 +302,13 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -304,13 +302,13 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 2** Init function description **Table 2** Init function description
<a name="table165981547354"></a> <a name="table165981547354"></a>
<table><thead align="left"><tr id="row8599145423516"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p959995453515"><a name="p959995453515"></a><a name="p959995453515"></a>Status (Value)</p> <table><thead align="left"><tr id="row8599145423516"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p959995453515"><a name="p959995453515"></a><a name="p959995453515"></a>Status (Value)</p>
...@@ -354,7 +352,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -354,7 +352,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Function description: Function description:
Initializes the custom structure object and **GpioCntlr**, calls the **GpioCntlrAdd** function at the core layer, and connects to the VFS \(optional\). Initializes the custom structure object and **GpioCntlr**, calls the **GpioCntlrAdd** function at the core layer, and connects to the VFS \(optional\).
``` ```
static int32_t Pl061GpioInit(struct HdfDeviceObject *device) static int32_t Pl061GpioInit(struct HdfDeviceObject *device)
...@@ -392,7 +390,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -392,7 +390,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -400,7 +398,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -400,7 +398,7 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
...@@ -421,8 +419,4 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th ...@@ -421,8 +419,4 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
OsalIoUnmap((void *)pl061->regBase);// (Mandatory) Remove the address mapping. OsalIoUnmap((void *)pl061->regBase);// (Mandatory) Remove the address mapping.
pl061->regBase = NULL; pl061->regBase = NULL;
} }
``` ```
\ No newline at end of file
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
### HDMI ### HDMI
- High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display. High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display.
- HDMI works in master/slave mode and usually has a source and a sink. HDMI works in primary/secondary mode and usually has a source and a sink.
- The HDMI APIs provide a set of common functions for HDMI transmission, including: The HDMI APIs provide a set of common functions for HDMI transmission, including:
- Opening and closing an HDMI controller - Opening and closing an HDMI controller
- Starting and stopping HDMI transmission - Starting and stopping HDMI transmission
- Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute - Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute
- Reading the raw Extended Display Identification Data (EDID) from a sink - Reading the raw Extended Display Identification Data (EDID) from a sink
- Registering and unregistering a callback for HDMI hot plug detect (HPD). - Registering and unregistering a callback for HDMI hot plug detect (HPD).
### Basic Concepts ### Basic Concepts
...@@ -88,7 +88,7 @@ DevHandle HdmiOpen(int16_t number); ...@@ -88,7 +88,7 @@ DevHandle HdmiOpen(int16_t number);
| Parameter | Description | | Parameter | Description |
| ---------- | -------------------- | | ---------- | -------------------- |
| number | HDMI controller ID. | | number | HDMI controller ID. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| NULL | Failed to open the HDMI controller. | | NULL | Failed to open the HDMI controller. |
| Controller handle| Handle of the opened HDMI controller.| | Controller handle| Handle of the opened HDMI controller.|
...@@ -117,7 +117,7 @@ int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo ...@@ -117,7 +117,7 @@ int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo
| ---------- | ------------------ | | ---------- | ------------------ |
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| callback | Pointer to the callback to be invoked to return the HPD result.| | callback | Pointer to the callback to be invoked to return the HPD result.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -165,7 +165,7 @@ int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len); ...@@ -165,7 +165,7 @@ int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len);
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| buffer | Pointer to the data buffer. | | buffer | Pointer to the data buffer. |
| len | Data length. | | len | Data length. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| Positive integer | Raw EDID read.| | Positive integer | Raw EDID read.|
| Negative number or 0 | Failed to read the EDID. | | Negative number or 0 | Failed to read the EDID. |
...@@ -194,7 +194,7 @@ int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr); ...@@ -194,7 +194,7 @@ int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr);
| ------ | -------------- | | ------ | -------------- |
| handle | HDMI controller handle.| | handle | HDMI controller handle.|
| attr | Pointer to the audio attributes. | | attr | Pointer to the audio attributes. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -295,7 +295,7 @@ int32_t HdmiAvmuteSet(DevHandle handle, bool enable); ...@@ -295,7 +295,7 @@ int32_t HdmiAvmuteSet(DevHandle handle, bool enable);
| ---------- | ----------------- | | ---------- | ----------------- |
| handle | HDMI controller handle. | | handle | HDMI controller handle. |
| enable | Whether to enable the AV mute feature.| | enable | Whether to enable the AV mute feature.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation failed. | | Negative value | The operation failed. |
...@@ -615,4 +615,4 @@ static int32_t TestCaseHdmi(void) ...@@ -615,4 +615,4 @@ static int32_t TestCaseHdmi(void)
return 0; return 0;
} }
``` ```
\ No newline at end of file
...@@ -40,7 +40,7 @@ Currently, the HDMI module supports only the kernels (LiteOS) of mini and small ...@@ -40,7 +40,7 @@ Currently, the HDMI module supports only the kernels (LiteOS) of mini and small
HDMI features high transmission rate, wide transmission bandwidth, high compatibility, and can transmit uncompressed audio and video signals. Compared with the traditional full analog interface, HDMI simplifies connection between devices and provides HDMI-specific intelligent features, which are ideal for high-quality audio and video transmission of small-sized devices. HDMI features high transmission rate, wide transmission bandwidth, high compatibility, and can transmit uncompressed audio and video signals. Compared with the traditional full analog interface, HDMI simplifies connection between devices and provides HDMI-specific intelligent features, which are ideal for high-quality audio and video transmission of small-sized devices.
### Available APIs ### Available APIs
**HdmiCntlrOps**: **HdmiCntlrOps**:
```c ```c
struct HdmiCntlrOps { struct HdmiCntlrOps {
...@@ -149,7 +149,7 @@ The HDMI module adaptation involves the following steps: ...@@ -149,7 +149,7 @@ The HDMI module adaptation involves the following steps:
.Bind = HdmiAdapterBind, .Bind = HdmiAdapterBind,
.Init = HdmiAdapterInit, .Init = HdmiAdapterInit,
.Release = HdmiAdapterRelease, .Release = HdmiAdapterRelease,
.moduleName = "adapter_hdmi_driver",// (mandatory) The value must be the same as that in the .hcs file. .moduleName = "adapter_hdmi_driver",// (Mandatory) The value must be the same as that in the .hcs file.
}; };
HDF_INIT(g_hdmiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. HDF_INIT(g_hdmiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
``` ```
...@@ -315,11 +315,11 @@ The HDMI module adaptation involves the following steps: ...@@ -315,11 +315,11 @@ The HDMI module adaptation involves the following steps:
- **Bind()** function - **Bind()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
**HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.) **HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.)
| State | Description | | State | Description |
|:-|:-| |:-|:-|
...@@ -330,7 +330,7 @@ The HDMI module adaptation involves the following steps: ...@@ -330,7 +330,7 @@ The HDMI module adaptation involves the following steps:
|HDF_SUCCESS |Transmission successful.| |HDF_SUCCESS |Transmission successful.|
|HDF_FAILURE |Transmission failed.| |HDF_FAILURE |Transmission failed.|
**Function description**: **Function description**:
Initializes the custom structure object **HdmiAdapterHost** and **HdmiCntlr**, and calls the **HdmiCntlrAdd** function to add the HDMI controller to the core layer. Initializes the custom structure object **HdmiAdapterHost** and **HdmiCntlr**, and calls the **HdmiCntlrAdd** function to add the HDMI controller to the core layer.
The **HdmiCntlr**, **HdmiAdapterHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully. The **HdmiCntlr**, **HdmiAdapterHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully.
...@@ -374,13 +374,13 @@ The HDMI module adaptation involves the following steps: ...@@ -374,13 +374,13 @@ The HDMI module adaptation involves the following steps:
- **Init()** function - **Init()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
HDF_STATUS HDF_STATUS
**Function description**: **Function description**:
Implements the **HdmiAdapterInit** function. Implements the **HdmiAdapterInit** function.
...@@ -393,13 +393,13 @@ The HDMI module adaptation involves the following steps: ...@@ -393,13 +393,13 @@ The HDMI module adaptation involves the following steps:
- **Release()** function - **Release()** function
**Input parameter**: **Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
**Return value**: **Return value**:
**Function description**: **Function description**:
Releases the memory and deletes the controller. This function assigns a value to the **Release()** API in the driver entry structure. If the HDF fails to call the **Init()** function to initialize the driver, the **Release()** function can be called to release driver resources. Releases the memory and deletes the controller. This function assigns a value to the **Release()** API in the driver entry structure. If the HDF fails to call the **Init()** function to initialize the driver, the **Release()** function can be called to release driver resources.
```c ```c
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
The Inter-Integrated Circuit \(I2C\) bus is a simple and bidirectional two-wire synchronous serial bus developed by Philips. In the Hardware Driver Foundation (HDF) framework, the I2C module uses the unified service mode for API adaptation. In this mode, a device service is used as the I2C manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the I2C module has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The Inter-Integrated Circuit \(I2C\) bus is a simple and bidirectional two-wire synchronous serial bus developed by Philips. In the Hardware Driver Foundation (HDF) framework, the I2C module uses the unified service mode for API adaptation. In this mode, a device service is used as the I2C manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the I2C module has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services.
**Figure 1** Unified service mode<a name="fig17640124912440"></a> **Figure 1** Unified service mode<a name="fig17640124912440"></a>
![](figures/unified-service-mode.png "unified-service-mode-8") ![](figures/unified-service-mode.png "unified-service-mode-8")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -23,7 +23,7 @@ struct I2cLockMethod {// Lock mechanism operation structure ...@@ -23,7 +23,7 @@ struct I2cLockMethod {// Lock mechanism operation structure
}; };
``` ```
**Table 1** Callbacks for the members in the I2cMethod structure **Table 1** Callbacks for the members in the I2cMethod structure
<a name="table10549174014611"></a> <a name="table10549174014611"></a>
<table><thead align="left"><tr id="row17550114013460"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p155014403467"><a name="p155014403467"></a><a name="p155014403467"></a>Callback</p> <table><thead align="left"><tr id="row17550114013460"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p155014403467"><a name="p155014403467"></a><a name="p155014403467"></a>Callback</p>
...@@ -57,41 +57,39 @@ struct I2cLockMethod {// Lock mechanism operation structure ...@@ -57,41 +57,39 @@ struct I2cLockMethod {// Lock mechanism operation structure
The I2C module adaptation involves the following steps: The I2C module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **i2c\_config.hcs** file. - \(Optional\) Add the **i2c\_config.hcs** file.
3. Instantiate the I2C controller object. 3. Instantiate the I2C controller object.
- Initialize **I2cCntlr**. - Initialize **I2cCntlr**.
- Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**. - Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
>For details, see [Available APIs](#available-apis). For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section1773332551114257"></a> ## Development Example<a name="section1773332551114257"></a>
The following uses **i2c\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **i2c\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
- I2C driver entry reference - I2C driver entry reference
Many devices may be connected to the I2C module. Therefore, in the HDF framework, a manager object is created for the I2C, and a manager service is launched to handle external access requests in a unified manner. When a user wants to open a device, the user obtains the manager service first. Then, the manager service locates the target device based on the parameters specified by the user. Many devices may be connected to the I2C module. Therefore, in the HDF framework, a manager object is created for the I2C, and a manager service is launched to handle external access requests in a unified manner. When a user wants to open a device, the user obtains the manager service first. Then, the manager service locates the target device based on the parameters specified by the user.
The driver of the I2C manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **I2cCntlrAdd** function of the core layer must be called to implement the corresponding features. The driver of the I2C manager is implemented by the core layer. Vendors do not need to pay attention to the implementation of this part. However, when they implement the **Init** function, the **I2cCntlrAdd** function of the core layer must be called to implement the corresponding features.
``` ```
struct HdfDriverEntry g_i2cDriverEntry = { struct HdfDriverEntry g_i2cDriverEntry = {
...@@ -113,11 +111,11 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -113,11 +111,11 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
HDF_INIT(g_i2cManagerEntry); HDF_INIT(g_i2cManagerEntry);
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **i2c\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **I2cCntlr** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **i2c\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the driver implementation and the default values or value ranges of the **I2cCntlr** members at the core layer.
In the unified service mode, the first device node in the **device\_info** file must be the I2C manager. [Table 2](#table96651915911) lists settings of its parameters. In the unified service mode, the first device node in the **device\_info** file must be the I2C manager. [Table 2](#table96651915911) lists settings of its parameters.
**Table 2** Settings of the I2C manager **Table 2** Settings of the I2C manager
<a name="table96651915911"></a> <a name="table96651915911"></a>
<table><thead align="left"><tr id="row96618194915"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1066119790"><a name="p1066119790"></a><a name="p1066119790"></a>Member</p> <table><thead align="left"><tr id="row96618194915"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1066119790"><a name="p1066119790"></a><a name="p1066119790"></a>Member</p>
...@@ -149,9 +147,9 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -149,9 +147,9 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
</tbody> </tbody>
</table> </table>
Configure I2C controller information from the second node. This node specifies a type of I2C controllers rather than an I2C controller. The **busID** and **reg\_pbase** parameters distinguish controllers, which can be seen in the **i2c\_config** file. Configure I2C controller information from the second node. This node specifies a type of I2C controllers rather than an I2C controller. The **busID** and **reg\_pbase** parameters distinguish controllers, which can be seen in the **i2c\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -180,7 +178,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -180,7 +178,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
``` ```
- **i2c\_config.hcs** configuration reference - **i2c\_config.hcs** configuration reference
``` ```
root { root {
...@@ -208,10 +206,10 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -208,10 +206,10 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
``` ```
3. Initialize the **I2cCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **I2cMethod** \(used to call underlying functions of the driver\) in **I2cCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **I2cCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **I2cMethod** \(used to call underlying functions of the driver\) in **I2cCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **i2c\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **I2cCntlr** object at the core layer. To the driver, the custom structure carries parameters and data. The values in the **i2c\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the **I2cCntlr** object at the core layer.
``` ```
// Vendor custom function structure // Vendor custom function structure
...@@ -238,7 +236,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -238,7 +236,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
}; };
``` ```
- Instantiate the member callback function structure **I2cMethod** in **I2cCntlr** and the lock callback function structure **I2cLockMethod**. Other members are initialized by using the **Init** function. - Instantiate the member callback function structure **I2cMethod** in **I2cCntlr** and the lock callback function structure **I2cLockMethod**. Other members are initialized by using the **Init** function.
``` ```
// Example in i2c_hi35xx.c // Example in i2c_hi35xx.c
...@@ -256,13 +254,13 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -256,13 +254,13 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 3** Input parameters and return values of the Init function **Table 3** Input parameters and return values of the Init function
<a name="table1743073181511"></a> <a name="table1743073181511"></a>
<table><thead align="left"><tr id="row443033171513"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p34306341517"><a name="p34306341517"></a><a name="p34306341517"></a>Status (Value)</p> <table><thead align="left"><tr id="row443033171513"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p34306341517"><a name="p34306341517"></a><a name="p34306341517"></a>Status (Value)</p>
...@@ -306,7 +304,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -306,7 +304,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Initializes the custom structure object and **I2cCntlr**, calls the **I2cCntlrAdd** function at the core layer, and connects to the VFS \(optional\). Initializes the custom structure object and **I2cCntlr**, calls the **I2cCntlrAdd** function at the core layer, and connects to the VFS \(optional\).
``` ```
static int32_t Hi35xxI2cInit(struct HdfDeviceObject *device) static int32_t Hi35xxI2cInit(struct HdfDeviceObject *device)
...@@ -358,7 +356,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -358,7 +356,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -366,7 +364,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -366,7 +364,7 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources.
``` ```
static void Hi35xxI2cRelease(struct HdfDeviceObject *device) static void Hi35xxI2cRelease(struct HdfDeviceObject *device)
...@@ -394,7 +392,4 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha ...@@ -394,7 +392,4 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
} }
return; return;
} }
``` ```
\ No newline at end of file
...@@ -24,7 +24,7 @@ The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidir ...@@ -24,7 +24,7 @@ The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidir
}; };
``` ```
**Table 1** APIs for the members in the I3cMethod structure **Table 1** APIs for the members in the I3cMethod structure
|Method|Input Parameter|Output Parameter|Return Value|Description| |Method|Input Parameter|Output Parameter|Return Value|Description|
|-|-|-|-|-| |-|-|-|-|-|
...@@ -52,7 +52,9 @@ The I3C module adaptation involves the following steps: ...@@ -52,7 +52,9 @@ The I3C module adaptation involves the following steps:
3. Instantiate the I3C controller object. 3. Instantiate the I3C controller object.
- Initialize **I3cCntlr**. - Initialize **I3cCntlr**.
- Instantiate **I3cMethod** in **I3cCntlr**. For details, see [Available APIs](#available-apis). - Instantiate **I3cMethod** in **I3cCntlr**.
For details, see [Available APIs](#available-apis).
4. Register an interrupt handler. 4. Register an interrupt handler.
Register an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features. Register an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features.
...@@ -197,7 +199,7 @@ The I3C module adaptation involves the following steps: ...@@ -197,7 +199,7 @@ The I3C module adaptation involves the following steps:
- **Init** function - **Init** function
> Input parameter: > Input parameter:
> **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration.
> >
> Return value: > Return value:
> **HDF_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.) > **HDF_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** definition in the **/drivers/framework/include/utils/hdf\_base.h file**.)
...@@ -410,4 +412,4 @@ The I3C module adaptation involves the following steps: ...@@ -410,4 +412,4 @@ The I3C module adaptation involves the following steps:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
``` ```
\ No newline at end of file
# MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a> # MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a>
- [Overview](#section72226945170128)
- [Available APIs](#section735525713405)
- [How to Develop](#section378858277170128)
- [Development Example](#section2049027816170128)
## Overview<a name="section72226945170128"></a> ## Overview<a name="section72226945170128"></a>
Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object. Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig260692723120"></a> **Figure 1** Service-free mode<a name="fig260692723120"></a>
![](figures/service-free-mode.png "Service-free mode") ![](figures/service-free-mode.png "Service-free mode")
...@@ -34,7 +29,7 @@ struct MipiCsiCntlrMethod { ...@@ -34,7 +29,7 @@ struct MipiCsiCntlrMethod {
}; };
``` ```
**Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure **Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure
<a name="table1233500677170128"></a> <a name="table1233500677170128"></a>
<table><thead align="left"><tr id="row1000451054170128"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="entry1111988081170128p0"><a name="entry1111988081170128p0"></a><a name="entry1111988081170128p0"></a>Callback</p> <table><thead align="left"><tr id="row1000451054170128"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="entry1111988081170128p0"><a name="entry1111988081170128p0"></a><a name="entry1111988081170128p0"></a>Callback</p>
...@@ -202,35 +197,33 @@ struct MipiCsiCntlrMethod { ...@@ -202,35 +197,33 @@ struct MipiCsiCntlrMethod {
The MIPI CSI module adaptation involves the following steps: The MIPI CSI module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mipicsi\_config.hcs** file. - \(Optional\) Add the **mipicsi\_config.hcs** file.
3. Instantiate the MIPI CSI controller object. 3. Instantiate the MIPI CSI controller object.
- Initialize **MipiCsiCntlr**. - Initialize **MipiCsiCntlr**.
- Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object. - Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>For details, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted. 4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section2049027816170128"></a> ## Development Example<a name="section2049027816170128"></a>
The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration. 1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file. >In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file.
**device\_info.hcs** configuration reference: **device\_info.hcs** configuration reference:
``` ```
root { root {
...@@ -253,9 +246,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -253,9 +246,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
} }
``` ```
2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit. Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
MIPI CSI driver entry reference: MIPI CSI driver entry reference:
...@@ -269,11 +262,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -269,11 +262,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
``` ```
3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference: - Custom structure reference:
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**. >To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**.
``` ```
typedef struct { typedef struct {
...@@ -328,7 +321,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -328,7 +321,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
}; };
``` ```
- **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function. - **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function.
``` ```
static struct MipiCsiCntlrMethod g_method = { static struct MipiCsiCntlrMethod g_method = {
...@@ -351,11 +344,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -351,11 +344,11 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table683892652170128"></a> <a name="table683892652170128"></a>
<table><thead align="left"><tr id="row466801181170128"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry433041536170128p0"><a name="entry433041536170128p0"></a><a name="entry433041536170128p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row466801181170128"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry433041536170128p0"><a name="entry433041536170128p0"></a><a name="entry433041536170128p0"></a>Status (Value)</p>
...@@ -399,7 +392,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -399,7 +392,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Function description: Function description:
Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations. Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations.
``` ```
static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device) static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device)
...@@ -408,9 +401,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -408,9 +401,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: enter!", __func__); HDF_LOGI("%s: enter!", __func__);
g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined. g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined.
//static struct MipiCsiCntlr g_mipiCsi = { // static struct MipiCsiCntlr g_mipiCsi = {
//.devNo = 0 // .devNo = 0
//}; // };
g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance. g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance.
#ifdef CONFIG_HI_PROC_SHOW_SUPPORT #ifdef CONFIG_HI_PROC_SHOW_SUPPORT
g_mipiCsi.debugs = &g_debugMethod; g_mipiCsi.debugs = &g_debugMethod;
...@@ -468,7 +461,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -468,7 +461,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -476,7 +469,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -476,7 +469,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device) static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device)
...@@ -484,7 +477,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -484,7 +477,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
struct MipiCsiCntlr *cntlr = NULL; struct MipiCsiCntlr *cntlr = NULL;
... ...
cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved. cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved.
//return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service; // return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service;
... ...
OsalSpinDestroy(&cntlr->ctxLock); OsalSpinDestroy(&cntlr->ctxLock);
...@@ -497,7 +490,4 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content ...@@ -497,7 +490,4 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: unload mipi csi driver success!", __func__); HDF_LOGI("%s: unload mipi csi driver success!", __func__);
} }
``` ```
\ No newline at end of file
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
## Overview<a name="section16806142183217"></a> ## Overview<a name="section16806142183217"></a>
- The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals. The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
- MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode. MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
- [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals. [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
**Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a> **Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a>
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface") ![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface")
## Available APIs<a name="section12720125432316"></a> ## Available APIs<a name="section12720125432316"></a>
**Table 1** APIs for MIPI DSI **Table 1** APIs for MIPI DSI
<a name="table4199102313245"></a> <a name="table4199102313245"></a>
<table><thead align="left"><tr id="row1619910238244"><th class="cellrowborder" valign="top" width="26.619999999999997%" id="mcps1.2.4.1.1"><p id="p141991023182411"><a name="p141991023182411"></a><a name="p141991023182411"></a>Capability</p> <table><thead align="left"><tr id="row1619910238244"><th class="cellrowborder" valign="top" width="26.619999999999997%" id="mcps1.2.4.1.1"><p id="p141991023182411"><a name="p141991023182411"></a><a name="p141991023182411"></a>Capability</p>
...@@ -75,25 +75,25 @@ ...@@ -75,25 +75,25 @@
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions described in this document can be called only in kernel space. >All functions described in this document can be called only in kernel space.
## Usage Guidelines<a name="section037231715335"></a> ## Usage Guidelines<a name="section037231715335"></a>
### How to Use<a name="section49299119344"></a> ### How to Use<a name="section49299119344"></a>
[Figure 2](#fig129103491241) shows the process of using a MIPI DSI device. [Figure 2](#fig129103491241) shows the process of using a MIPI DSI device.
**Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a> **Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a>
![](figures/process-of-using-a-mipi-dsi-device.png) ![](figures/process-of-using-a-mipi-dsi-device.png)
### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a> ### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a>
Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID. Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID.
DevHandle MipiDsiOpen\(uint8\_t id\); DevHandle MipiDsiOpen\(uint8\_t id\);
**Table 2** Description of **MipiDsiOpen** **Table 2** Description of **MipiDsiOpen**
<a name="table7603619123820"></a> <a name="table7603619123820"></a>
<table><thead align="left"><tr id="row1060351914386"><th class="cellrowborder" valign="top" width="20.66%" id="mcps1.2.3.1.1"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b824620346298"><a name="b824620346298"></a><a name="b824620346298"></a>Parameter</strong></p> <table><thead align="left"><tr id="row1060351914386"><th class="cellrowborder" valign="top" width="20.66%" id="mcps1.2.3.1.1"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b824620346298"><a name="b824620346298"></a><a name="b824620346298"></a>Parameter</strong></p>
...@@ -125,7 +125,7 @@ DevHandle MipiDsiOpen\(uint8\_t id\); ...@@ -125,7 +125,7 @@ DevHandle MipiDsiOpen\(uint8\_t id\);
</tbody> </tbody>
</table> </table>
The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**: The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**:
``` ```
DevHandle mipiDsiHandle = NULL; /* Device handle */ DevHandle mipiDsiHandle = NULL; /* Device handle */
...@@ -145,7 +145,7 @@ if (mipiDsiHandle == NULL) { ...@@ -145,7 +145,7 @@ if (mipiDsiHandle == NULL) {
int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\); int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
**Table 3** Description of **MipiDsiSetCfg** **Table 3** Description of **MipiDsiSetCfg**
<a name="table10692555281"></a> <a name="table10692555281"></a>
<table><thead align="left"><tr id="row116914559288"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1169195516288"><a name="p1169195516288"></a><a name="p1169195516288"></a><strong id="b1804534152914"><a name="b1804534152914"></a><a name="b1804534152914"></a>Parameter</strong></p> <table><thead align="left"><tr id="row116914559288"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1169195516288"><a name="p1169195516288"></a><a name="p1169195516288"></a><strong id="b1804534152914"><a name="b1804534152914"></a><a name="b1804534152914"></a>Parameter</strong></p>
...@@ -213,7 +213,7 @@ if (ret != 0) { ...@@ -213,7 +213,7 @@ if (ret != 0) {
int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\); int32\_t MipiDsiGetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
**Table 4** Description of **MipiDsiGetCfg** **Table 4** Description of **MipiDsiGetCfg**
<a name="table7709554280"></a> <a name="table7709554280"></a>
<table><thead align="left"><tr id="row670115515282"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p470205515287"><a name="p470205515287"></a><a name="p470205515287"></a><strong id="b14806334142912"><a name="b14806334142912"></a><a name="b14806334142912"></a>Parameter</strong></p> <table><thead align="left"><tr id="row670115515282"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p470205515287"><a name="p470205515287"></a><a name="p470205515287"></a><strong id="b14806334142912"><a name="b14806334142912"></a><a name="b14806334142912"></a>Parameter</strong></p>
...@@ -267,7 +267,7 @@ if (ret != HDF_SUCCESS) { ...@@ -267,7 +267,7 @@ if (ret != HDF_SUCCESS) {
int32\_t MipiDsiTx\(PalHandle handle, struct DsiCmdDesc \*cmd\); int32\_t MipiDsiTx\(PalHandle handle, struct DsiCmdDesc \*cmd\);
**Table 5** Description of **MipiDsiTx** **Table 5** Description of **MipiDsiTx**
<a name="table1018490043"></a> <a name="table1018490043"></a>
<table><thead align="left"><tr id="row31848013417"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b1280873492913"><a name="b1280873492913"></a><a name="b1280873492913"></a>Parameter</strong></p> <table><thead align="left"><tr id="row31848013417"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b1280873492913"><a name="b1280873492913"></a><a name="b1280873492913"></a>Parameter</strong></p>
...@@ -335,7 +335,7 @@ HdfFree(cmd); ...@@ -335,7 +335,7 @@ HdfFree(cmd);
int32\_t MipiDsiRx\(DevHandle handle, struct DsiCmdDesc \*cmd, uint32\_t readLen, uint8\_t \*out\); int32\_t MipiDsiRx\(DevHandle handle, struct DsiCmdDesc \*cmd, uint32\_t readLen, uint8\_t \*out\);
**Table 6** Description of **MipiDsiRx** **Table 6** Description of **MipiDsiRx**
<a name="table223910318361"></a> <a name="table223910318361"></a>
<table><thead align="left"><tr id="row924033173613"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p16240143143611"><a name="p16240143143611"></a><a name="p16240143143611"></a><strong id="b19809334172910"><a name="b19809334172910"></a><a name="b19809334172910"></a>Parameter</strong></p> <table><thead align="left"><tr id="row924033173613"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p16240143143611"><a name="p16240143143611"></a><a name="p16240143143611"></a><strong id="b19809334172910"><a name="b19809334172910"></a><a name="b19809334172910"></a>Parameter</strong></p>
...@@ -417,9 +417,9 @@ After the MIPI DSI communication, release the MIPI DSI device handle by calling ...@@ -417,9 +417,9 @@ After the MIPI DSI communication, release the MIPI DSI device handle by calling
void MipiDsiClose\(DevHandle handle\); void MipiDsiClose\(DevHandle handle\);
This function releases the resources requested by **MipiDsiOpen**. This function releases the resources requested by **MipiDsiOpen**.
**Table 7** Description of **MipiDsiClose** **Table 7** Description of **MipiDsiClose**
<a name="table72517953115"></a> <a name="table72517953115"></a>
<table><thead align="left"><tr id="row1525793312"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p115402031153111"><a name="p115402031153111"></a><a name="p115402031153111"></a><strong id="b1487612133120"><a name="b1487612133120"></a><a name="b1487612133120"></a>Parameter</strong></p> <table><thead align="left"><tr id="row1525793312"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p115402031153111"><a name="p115402031153111"></a><a name="p115402031153111"></a><strong id="b1487612133120"><a name="b1487612133120"></a><a name="b1487612133120"></a>Parameter</strong></p>
...@@ -536,5 +536,4 @@ void PalMipiDsiTestSample(void) ...@@ -536,5 +536,4 @@ void PalMipiDsiTestSample(void)
/* Release the MIPI DSI device handle. */ /* Release the MIPI DSI device handle. */
MipiDsiClose(handle); MipiDsiClose(handle);
} }
``` ```
\ No newline at end of file
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
## Overview<a name="section1266787503161538"></a> ## Overview<a name="section1266787503161538"></a>
The Display Serial Interface \(DSI\) is a specification developed by the Mobile Industry Processor Interface \(MIPI\) Alliance to reduce the cost of display controllers in mobile devices. In the Hardware Driver Foundation (HDF) framework, the MIPI DSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object. The Display Serial Interface \(DSI\) is a specification developed by the Mobile Industry Processor Interface \(MIPI\) Alliance to reduce the cost of display controllers in mobile devices. In the Hardware Driver Foundation (HDF) framework, the MIPI DSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS system that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** \(a void pointer\) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig207610236189"></a> **Figure 1** Service-free mode<a name="fig207610236189"></a>
![](figures/service-free-mode.png "service-free-mode") ![](figures/service-free-mode.png "service-free-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -26,7 +26,7 @@ struct MipiDsiCntlrMethod {// Member functions of the core layer structure ...@@ -26,7 +26,7 @@ struct MipiDsiCntlrMethod {// Member functions of the core layer structure
}; };
``` ```
**Table 1** Callbacks for the members in the MipiDsiCntlrMethod structure **Table 1** Callbacks for the members in the MipiDsiCntlrMethod structure
<a name="table218771071713"></a> <a name="table218771071713"></a>
<table><thead align="left"><tr id="row1188121012177"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p118851010174"><a name="p118851010174"></a><a name="p118851010174"></a>Callback</p> <table><thead align="left"><tr id="row1188121012177"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p118851010174"><a name="p118851010174"></a><a name="p118851010174"></a>Callback</p>
...@@ -105,36 +105,33 @@ struct MipiDsiCntlrMethod {// Member functions of the core layer structure ...@@ -105,36 +105,33 @@ struct MipiDsiCntlrMethod {// Member functions of the core layer structure
The MIPI DSI module adaptation involves the following steps: The MIPI DSI module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mipidsi\_config.hcs** file. - \(Optional\) Add the **mipidsi\_config.hcs** file.
3. Instantiate the MIPI DSI controller object. 3. Instantiate the MIPI DSI controller object.
- Initialize **MipiDsiCntlr**. - Initialize **MipiDsiCntlr**.
- Instantiate **MipiDsiCntlrMethod** in the **MipiDsiCntlr** object. - Instantiate **MipiDsiCntlrMethod** in the **MipiDsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
4. Debug the driver. For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section1167576616161538"></a> ## Development Example<a name="section1167576616161538"></a>
The following uses **mipi\_tx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **mipi\_tx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Generally, you need to configure the device attributes in **xx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiDsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration. 1. Generally, you need to configure the device attributes in **xx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiDsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration.
In this example, no additional attribute needs to be configured for the MIPI DSI controller. If required, you need to add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the **mipidsi\_config** file. In this example, no additional attribute needs to be configured for the MIPI DSI controller. If required, you need to add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the **mipidsi\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -157,9 +154,9 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -157,9 +154,9 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
} }
``` ```
2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exits.
- MIPI DSI driver entry reference - MIPI DSI driver entry reference
...@@ -173,10 +170,10 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -173,10 +170,10 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
HDF_INIT(g_mipiTxDriverEntry); // Call HDF_INIT to register the driver entry with the HDF framework. HDF_INIT(g_mipiTxDriverEntry); // Call HDF_INIT to register the driver entry with the HDF framework.
``` ```
3. Initialize the **MipiDsiCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **MipiDsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiDsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **MipiDsiCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **MipiDsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiDsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI DSI has no device attribute file. Therefore, the basic member structure is similar to that of **MipiDsiCntlr**. To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI DSI has no device attribute file. Therefore, the basic member structure is similar to that of **MipiDsiCntlr**.
``` ```
typedef struct { typedef struct {
...@@ -202,7 +199,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -202,7 +199,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
}; };
``` ```
- Instantiate the callback function structure **MipiDsiCntlrMethod** in **MipiDsiCntlr**. Other members are initialized by using the Init function. - Instantiate the callback function structure **MipiDsiCntlrMethod** in **MipiDsiCntlr**. Other members are initialized by using the Init function.
``` ```
static struct MipiDsiCntlrMethod g_method = { static struct MipiDsiCntlrMethod g_method = {
...@@ -218,11 +215,11 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -218,11 +215,11 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table344041707161538"></a> <a name="table344041707161538"></a>
<table><thead align="left"><tr id="row1205250994161538"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1646623665161538p0"><a name="entry1646623665161538p0"></a><a name="entry1646623665161538p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row1205250994161538"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry1646623665161538p0"><a name="entry1646623665161538p0"></a><a name="entry1646623665161538p0"></a>Status (Value)</p>
...@@ -266,16 +263,16 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -266,16 +263,16 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
Function description: Function description:
Connects to the **MipiDsiCntlrMethod** instance, calls **MipiDsiRegisterCntlr**, and performs other vendor-defined initialization operations. Connects to the **MipiDsiCntlrMethod** instance, calls **MipiDsiRegisterCntlr**, and performs other vendor-defined initialization operations.
``` ```
static int32_t Hi35xxMipiTxInit(struct HdfDeviceObject *device) static int32_t Hi35xxMipiTxInit(struct HdfDeviceObject *device)
{ {
int32_t ret; int32_t ret;
g_mipiTx.priv = NULL; // g_mipiTx is a global variable. g_mipiTx.priv = NULL; // g_mipiTx is a global variable.
//static struct MipiDsiCntlr g_mipiTx { // static struct MipiDsiCntlr g_mipiTx {
// .devNo=0 // .devNo=0
//}; // };
g_mipiTx.ops = &g_method;// Connect to the MipiDsiCntlrMethod instance. g_mipiTx.ops = &g_method;// Connect to the MipiDsiCntlrMethod instance.
ret = MipiDsiRegisterCntlr(&g_mipiTx, device);// (Mandatory) Call the function at the core layer and g_mipiTx to initialize global variables at the core layer. ret = MipiDsiRegisterCntlr(&g_mipiTx, device);// (Mandatory) Call the function at the core layer and g_mipiTx to initialize global variables at the core layer.
... ...
...@@ -308,7 +305,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -308,7 +305,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -316,7 +313,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -316,7 +313,7 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void Hi35xxMipiTxRelease(struct HdfDeviceObject *device) static void Hi35xxMipiTxRelease(struct HdfDeviceObject *device)
...@@ -331,7 +328,4 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content ...@@ -331,7 +328,4 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
g_mipiTx.priv = NULL; g_mipiTx.priv = NULL;
HDF_LOGI("%s: unload mipi_tx driver 1212!", __func__); HDF_LOGI("%s: unload mipi_tx driver 1212!", __func__);
} }
``` ```
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
In the Hardware Driver Foundation \(HDF\) framework, the MultiMedia Card \(MMC\) uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage. In the Hardware Driver Foundation \(HDF\) framework, the MultiMedia Card \(MMC\) uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage.
**Figure 1** Independent service mode<a name="fig19517114132810"></a> **Figure 1** Independent service mode<a name="fig19517114132810"></a>
![](figures/independent-service-mode.png "independent-service-mode") ![](figures/independent-service-mode.png "independent-service-mode")
## Available APIs<a name="section752964871810"></a> ## Available APIs<a name="section752964871810"></a>
...@@ -31,7 +31,7 @@ struct MmcCntlrOps { ...@@ -31,7 +31,7 @@ struct MmcCntlrOps {
}; };
``` ```
**Table 1** Callbacks for the members in the MmcCntlrOps structure **Table 1** Callbacks for the members in the MmcCntlrOps structure
<a name="table99129433019"></a> <a name="table99129433019"></a>
<table><thead align="left"><tr id="row1891214163012"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p79129483017"><a name="p79129483017"></a><a name="p79129483017"></a>Callback</p> <table><thead align="left"><tr id="row1891214163012"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p79129483017"><a name="p79129483017"></a><a name="p79129483017"></a>Callback</p>
...@@ -196,33 +196,30 @@ struct MmcCntlrOps { ...@@ -196,33 +196,30 @@ struct MmcCntlrOps {
The MMC module adaptation involves the following steps: The MMC module adaptation involves the following steps:
1. Instantiate the driver entry. 1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure. - Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
2. Configure attribute files. 2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file. - Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mmc\_config.hcs** file. - \(Optional\) Add the **mmc\_config.hcs** file.
3. Instantiate the MMC controller object. 3. Instantiate the MMC controller object.
- Initialize **MmcCntlr**. - Initialize **MmcCntlr**.
- Instantiate **MmcCntlrOps** in the **MmcCntlr** object. - Instantiate **MmcCntlrOps** in the **MmcCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE** For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis). 4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the mount operation and whether the device starts successfully.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the mount operation and whether the device starts successfully.
## Development Example<a name="section1220893490162704"></a> ## Development Example<a name="section1220893490162704"></a>
The following uses **himci.c** as an example to present the contents that need to be provided by the vendor to implement device functions. The following uses **himci.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. 1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit. Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
- MMC driver entry reference - MMC driver entry reference
...@@ -237,11 +234,11 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -237,11 +234,11 @@ The following uses **himci.c** as an example to present the contents that need
HDF_INIT(g_mmcDriverEntry); // Call HDF_INIT to register the driver entry with the HDF framework. HDF_INIT(g_mmcDriverEntry); // Call HDF_INIT to register the driver entry with the HDF framework.
``` ```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **mmc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **MmcCntlr** members at the core layer. 2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **mmc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **MmcCntlr** members at the core layer.
If there are multiple devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **mmc\_config** file. If there are multiple devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **mmc\_config** file.
- **device\_info.hcs** configuration reference - **device\_info.hcs** configuration reference
``` ```
root { root {
...@@ -281,7 +278,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -281,7 +278,7 @@ The following uses **himci.c** as an example to present the contents that need
} }
``` ```
- **mmc\_config.hcs** configuration reference - **mmc\_config.hcs** configuration reference
``` ```
root { root {
...@@ -334,10 +331,10 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -334,10 +331,10 @@ The following uses **himci.c** as an example to present the contents that need
} }
``` ```
3. Initialize the **MmcCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **MmcCntlrOps** \(used to call underlying functions of the driver\) in **MmcCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). 3. Initialize the **MmcCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **MmcCntlrOps** \(used to call underlying functions of the driver\) in **MmcCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference - Custom structure reference
To the driver, the custom structure carries parameters and data. The values in the **mmc\_config.hcs** file are read by the HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values are also transferred to the objects at the core layer. To the driver, the custom structure carries parameters and data. The values in the **mmc\_config.hcs** file are read by the HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values are also transferred to the objects at the core layer.
``` ```
struct HimciHost { struct HimciHost {
...@@ -389,7 +386,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -389,7 +386,7 @@ The following uses **himci.c** as an example to present the contents that need
}; };
``` ```
- Instantiate the callback function structure **MmcCntlrOps** in **MmcCntlr**. Other members are initialized by using the **Bind** function. - Instantiate the callback function structure **MmcCntlrOps** in **MmcCntlr**. Other members are initialized by using the **Bind** function.
``` ```
static struct MmcCntlrOps g_himciHostOps = { static struct MmcCntlrOps g_himciHostOps = {
...@@ -415,11 +412,11 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -415,11 +412,11 @@ The following uses **himci.c** as an example to present the contents that need
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\) HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table1428218958162704"></a> <a name="table1428218958162704"></a>
<table><thead align="left"><tr id="row1723943104162704"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry136979408162704p0"><a name="entry136979408162704p0"></a><a name="entry136979408162704p0"></a>Status (Value)</p> <table><thead align="left"><tr id="row1723943104162704"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry136979408162704p0"><a name="entry136979408162704p0"></a><a name="entry136979408162704p0"></a>Status (Value)</p>
...@@ -463,7 +460,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -463,7 +460,7 @@ The following uses **himci.c** as an example to present the contents that need
Function description: Function description:
Initializes the custom structure **HimciHost** object and **MmcCntlr**, and calls the **MmcCntlrAdd** function at the core layer. **MmcCntlr**, **HimciHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully. Initializes the custom structure **HimciHost** object and **MmcCntlr**, and calls the **MmcCntlrAdd** function at the core layer. **MmcCntlr**, **HimciHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully.
``` ```
static int32_t HimciMmcBind(struct HdfDeviceObject *obj) static int32_t HimciMmcBind(struct HdfDeviceObject *obj)
...@@ -501,7 +498,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -501,7 +498,7 @@ The following uses **himci.c** as an example to present the contents that need
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -531,7 +528,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -531,7 +528,7 @@ The following uses **himci.c** as an example to present the contents that need
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values: Return values:
...@@ -539,7 +536,7 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -539,7 +536,7 @@ The following uses **himci.c** as an example to present the contents that need
Function description: Function description:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
``` ```
static void HimciMmcRelease(struct HdfDeviceObject *obj) static void HimciMmcRelease(struct HdfDeviceObject *obj)
...@@ -550,7 +547,4 @@ The following uses **himci.c** as an example to present the contents that need ...@@ -550,7 +547,4 @@ The following uses **himci.c** as an example to present the contents that need
... ...
HimciDeleteHost((struct HimciHost *)cntlr->priv);// Memory release function customized by the vendor. A forced conversion from MmcCntlr to HimciHost is involved in the process. HimciDeleteHost((struct HimciHost *)cntlr->priv);// Memory release function customized by the vendor. A forced conversion from MmcCntlr to HimciHost is involved in the process.
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册