diff --git a/en/device-dev/driver/Readme-EN.md b/en/device-dev/driver/Readme-EN.md index 47851b4dbf94f87febcbc7364d29df31d2c283b8..55f5c19b5fcf88377f7ccd2f0b2148aff2dd883b 100644 --- a/en/device-dev/driver/Readme-EN.md +++ b/en/device-dev/driver/Readme-EN.md @@ -10,25 +10,35 @@ - [Platform Driver Development](driver-develop.md) - [ADC](driver-platform-adc-develop.md) - [GPIO](driver-platform-gpio-develop.md) + - [HDMI](driver-platform-hdmi-develop.md) - [I2C](driver-platform-i2c-develop.md) + - [I3C](driver-platform-i3c-develop.md) + - [MIPI CSI](driver-platform-mipicsi-develop.md) - [MIPI DSI](driver-platform-mipidsi-develop.md) - [MMC](driver-platform-mmc-develop.md) + - [PIN](driver-platform-pin-develop.md) - [PWM](driver-platform-pwm-develop.md) + - [Regulator](driver-platform-regulator-develop.md) - [RTC](driver-platform-rtc-develop.md) - [SDIO](driver-platform-sdio-develop.md) - [SPI](driver-platform-spi-develop.md) - [UART](driver-platform-uart-develop.md) - [Watchdog](driver-platform-watchdog-develop.md) - [Platform Driver Usage](driver-platform.md) + - [ADC](driver-platform-adc-des.md) - [GPIO](driver-platform-gpio-des.md) + - [HDMI](driver-platform-hdmi-des.md) - [I2C](driver-platform-i2c-des.md) - - [MIPI DSI](driver-platform-mipidsi-develop.md) + - [I3C](driver-platform-i3c-des.md) + - [MIPI CSI](driver-platform-mipicsi-des.md) + - [MIPI DSI](driver-platform-mipidsi-des.md) - [PWM](driver-platform-pwm-des.md) + - [Regulator](driver-platform-regulator-des.md) - [RTC](driver-platform-rtc-des.md) - [SDIO](driver-platform-sdio-des.md) - [SPI](driver-platform-spi-des.md) - [UART](driver-platform-uart-des.md) - - [Watchdog](driver-platform-watchdog-des.md) + - [Watchdog](driver-platform-watchdog-des.md) - [Peripheral Driver Usage](driver-peripherals.md) - [LCD](driver-peripherals-lcd-des.md) - [Touchscreen](driver-peripherals-touch-des.md) diff --git a/en/device-dev/driver/driver-develop.md b/en/device-dev/driver/driver-develop.md index 7967bb405068886414ca2f3195b8465973ce69b3..e3effaeb8ea3bdfc1dd4276c188de0127ad20a83 100644 --- a/en/device-dev/driver/driver-develop.md +++ b/en/device-dev/driver/driver-develop.md @@ -4,9 +4,15 @@ - **[GPIO](driver-platform-gpio-develop.md)** +- **[HDMI](driver-platform-hdmi-develop.md)** + - **[I2C](driver-platform-i2c-develop.md)** -- **[MIPI-DSI](driver-platform-mipidsi-develop.md)** +- **[I3C](driver-platform-i3c-develop.md)** + +- **[MIPI CSI](driver-platform-mipicsi-develop.md)** + +- **[MIPI DSI](driver-platform-mipidsi-develop.md)** - **[MMC](driver-platform-mmc-develop.md)** diff --git a/en/device-dev/driver/driver-platform-adc-des.md b/en/device-dev/driver/driver-platform-adc-des.md new file mode 100644 index 0000000000000000000000000000000000000000..63da8cd7e0fc7b6a6024b42e4d1e7be260ecdd4c --- /dev/null +++ b/en/device-dev/driver/driver-platform-adc-des.md @@ -0,0 +1,256 @@ +# ADC + +## Overview + +- 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: + - Opening or closing an ADC device + - Obtaining the analog-to-digital (AD) conversion result + + **Figure 1** ADC physical connection + + ![](figures/ADC_physical_connection.png "ADC_physical_connection") + +## Available APIs + +**Table 1** APIs of the ADC driver + + + + + + + + + + + + + + + + + + + +

Category

+

API

+

Description

+

Managing ADC devices

+

AdcOpen

+
Opens an ADC device.

+

AdcClose

+

Closes an ADC device.

+

Obtaining the conversion result

+

AdcRead

+

Reads the AD conversion result.

+
+ +## Usage Guidelines + +### How to Use + +[Figure 2](#fig2) shows how an ADC device works. + + **Figure 2** How ADC works + +![](figures/ADC_flowchart.png "ADC_flowchart") + +### Opening an ADC Device + +Call **AdcOpen** to open an ADC device. + +```c +DevHandle AdcOpen(int16_t number); +``` + +**Table 2** Description of AdcOpen + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

number

+

ADC device number.

+

Return Value

+

Description

+

NULL

+

Failed to open the ADC device.

+

Device handle

+

Handle of the ADC device opened.

+
+ +For example, open device 1 of the two ADCs (numbered 0 and 1) in the system. + +```c +DevHandle adcHandle = NULL; /* ADC device handle / + +/* Open the ADC device. */ +adcHandle = AdcOpen(1); +if (adcHandle == NULL) { + HDF_LOGE("AdcOpen: failed\n"); + return; +} +``` + +### Obtaining the AD Conversion Result + +```c +int32_t AdcRead(DevHandle handle, uint32_t channel, uint32_t *val); +``` + +**Table 3** Description of AdcRead + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

ADC device handle.

+

channel

+

ADC device channel number.

+

val

+

AD conversion result.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

Failed to obtain the AC conversion result.

+
+ +### Closing an ADC Device + +Call **AdcClose** to close the ADC device after the ADC communication is complete. +```c +void AdcClose(DevHandle handle); +``` +**Table 4** Description of AdcClose + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

ADC device handle.

+

Return Value

+

Description

+

None

+

No value is returned if the ADC device is closed.

+
+ +Example: + +```c +AdcClose(adcHandle); /* Close the ADC device. */ +``` + +## Example + +This following example shows how to use ADC APIs to manage an ADC device on a Hi3516D V300 development board. + +The basic hardware information is as follows: + +- SoC: hi3516dv300 + +- The potentiometer is connected to channel 1 of ADC device 0. + +Perform continuous read operations on the ADC device to check whether the ADC is functioning. + +Example: + +```c +#include "adc_if.h" /* Header file for ADC APIs */ +#include "hdf_log.h" /* Header file for log APIs */ + +/* Define device 0, channel 1. */ +#define ADC_DEVICE_NUM 0 +#define ADC_CHANNEL_NUM 1 + +/* Main entry of ADC routines. */ +static int32_t TestCaseAdc(void) +{ + int32_t i; + int32_t ret; + DevHandle adcHandle; + uint32_t Readbuf[30] = {0}; + + /* Open the ADC device. */ + adcHandle = AdcOpen(ADC_DEVICE_NUM); + if (adcHandle == NULL) { + HDF_LOGE("%s: Open ADC%u fail!", __func__, ADC_DEVICE_NUM); + return -1; + } + + /* Perform 30 times of AD conversions continuously and read the conversion results. */ + for (i = 0; i < 30; i++) { + ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &Readbuf[i]); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: tp ADC write reg fail!:%d", __func__, ret); + AdcClose(adcHandle); + return -1; + } + } + HDF_LOGI("%s: ADC read successful!", __func__); + + /* Close the ADC device. */ + AdcClose(adcHandle); + + return 0; +} +``` diff --git a/en/device-dev/driver/driver-platform-adc-develop.md b/en/device-dev/driver/driver-platform-adc-develop.md index ef511390aed3ecf668542ea2f78b307267d58fcf..1a303dc429a6d19f05d652f1175ad371809c40d8 100644 --- a/en/device-dev/driver/driver-platform-adc-develop.md +++ b/en/device-dev/driver/driver-platform-adc-develop.md @@ -1,36 +1,13 @@ # ADC - ## Overview The analog-to-digital converter \(ADC\) is a device that converts analog signals into digital signals. In the Hardware Driver Foundation \(HDF\) framework, 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 -![](figures/unified-service-mode.png "unified-service-mode") - -## How to Develop - -The ADC module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **adc\_config.hcs** file. - -3. Instantiate the ADC controller object. - - Initialize **AdcDevice**. - - Instantiate **AdcMethod** in the **AdcDevice** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [AdcMethod](#section1618135285210) and [Table 1](#table1943202316536). - - -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. +![](figures/unified-service-mode.png "ADC-unified-service-mode") +## Available APIs ### AdcMethod @@ -94,6 +71,30 @@ struct AdcMethod { +## How to Develop + +The ADC module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **adc\_config.hcs** file. + +3. Instantiate the ADC controller object. + - Initialize **AdcDevice**. + - Instantiate **AdcMethod** in the **AdcDevice** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [AdcMethod](#section1618135285210) and [Table 1](#table1943202316536). + + +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 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. diff --git a/en/device-dev/driver/driver-platform-gpio-develop.md b/en/device-dev/driver/driver-platform-gpio-develop.md index 1b31e3a4ff503ca1bcc4e84fc5eadf1bdc4d93bd..2851ea6e4d09546309d6bd6f8767a2cbcf9cf6e0 100644 --- a/en/device-dev/driver/driver-platform-gpio-develop.md +++ b/en/device-dev/driver/driver-platform-gpio-develop.md @@ -1,12 +1,5 @@ # GPIO -- [Overview](#section1826197354103451) -- [Available APIs](#section752964871810) -- [How to Develop](#section731175315103451) -- [Development Example](#section800425816103451) - - - ## Overview 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. diff --git a/en/device-dev/driver/driver-platform-hdmi-des.md b/en/device-dev/driver/driver-platform-hdmi-des.md new file mode 100644 index 0000000000000000000000000000000000000000..c1243dcbe9ae5fd191f411250b08ef72c9363ffa --- /dev/null +++ b/en/device-dev/driver/driver-platform-hdmi-des.md @@ -0,0 +1,991 @@ +# HDMI + +## Overview + +- The High-Definition Multimedia Interface (HDMI) is an audio/video transmission protocol released by Hitachi, Panasonic, Philips, Silicon Image, Sony, Thomson, Toshiba. +- The HDMI works in master/slave mode and usually has a source and a sink. +- The HDMI APIs provide a set of common functions for HDMI transmission, including: + + - Opening and closing an HDMI controller. + - Starting and stopping HDMI transmission. + - 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. + - Registering and unregistering a callback for HDMI hot plug detect. +- [Figure 1](#fig1) shows the HDMI physical connection. + + **Figure 1** HDMI physical connection + + ![](figures/HDMI_physical_connection.png "HDMI_physical_connection") + +## Available APIs + +**Table 1** HDMI driver APIs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Category

+

API

+

Description

+

Managing HDMI controllers

+

HdmiOpen

+
Opens an HDMI controller.

+

HdmiClose

+

Closes an HDMI controller.

+

Starting or stopping HDMI transmission

+

HdmiStart

+
Starts HDMI transmission.

+

HdmiStop

+

Stops HDMI transmission.

+

Setting an HDMI controller

+

HdmiAvmuteSet

+
Sets the AV mute feature.

+

HdmiDeepColorSet

+

Sets the color depth.

+

HdmiDeepColorGet

+

Obtains the color depth.

+

HdmiSetVideoAttribute

+

Sets video attributes.

+

HdmiSetAudioAttribute

+

Sets audio attributes.

+

HdmiSetHdrAttribute

+

Sets HDR attributes.

+

Reading EDID

+

HdmiReadSinkEdid

+
Reads the raw EDID from a sink.

+

Registering or unregistering a callback for HDMI hot plug detect

+

HdmiRegisterHpdCallbackFunc

+
Registers a callback for HDMI hot plug detect.

+

HdmiUnregisterHpdCallbackFunc

+

Unregisters the callback for HDMI hot plug detect.

+
+ +## Usage Guidelines + +### How to Use + +[Figure 2](#fig2) shows how HDMI works. + +**Figure 2** How HDMI works + +![](figures/HDMI_usage_flowchart.png "HDMI_usage_flowchart") + +### Opening an HDMI Controller + +Before HDMI communication, call **HdmiOpen** to enable an HDMI controller. + +```c +DevHandle HdmiOpen(int16_t number); +``` + +**Table 2** Description of HdmiOpen + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

number

+

HDMI controller ID.

+

Return Value

+

Description

+

NULL

+

Failed to open the HDMI controller.

+

Controller handle

+

Handle of the HDMI controller opened.

+
+ +For example, the system has two HDMI controllers, numbered 0 and 1. Open controller 0. + +```c +DevHandle hdmiHandle = NULL; /* HDMI controller handle / + +/* Open HDMI controller 0. */ +hdmiHandle = HdmiOpen(0); +if (hdmiHandle == NULL) { + HDF_LOGE("HdmiOpen: failed\n"); + return; +} +``` + +### Registering a Callback for Hot Plug Detect + +```c +int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo *callback); +``` + +**Table 3** Description of HdmiRegisterHpdCallbackFunc + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

callback

+

Callback invoked to return the hot plug detect result.

+

Return Value

+

Description

+

0

+

The callback is registered successfully.

+

Negative number

+

Failed to register the callback.

+
+ +The following is an example of registering a callback for hot plug detect: + +```c +/* Definition of the callback for hot plug detect */ +static void HdmiHpdHandle(void *data, bool hpd) +{ + if (data == NULL) { + HDF_LOGE("priv data is NULL"); + return; +} + + if (hpd == true) { + HDF_LOGD("HdmiHpdHandle: hot plug"); + /* Add related processing if required. */ + } else { + HDF_LOGD("HdmiHpdHandle: hot unplog"); + /* Add related processing if required. */ + } +} + + /* Example of registering a callback for hot plug detect */ + struct HdmiHpdCallbackInfo info = {0}; + info.data = handle; + info.callbackFunc = HdmiHpdHandle; + ret = HdmiRegisterHpdCallbackFunc(hdmiHandle, info); + if (ret != 0) { + HDF_LOGE("HdmiRegisterHpdCallbackFunc: Register failed."); + } +``` + +### Reading the EDID + +```c +int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len); +``` + +**Table 4** Description of HdmiReadSinkEdid + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

buffer

+

Data buffer.

+

len

+

Data length.

+

Return Value

+

Description

+

Positive integer

+

Raw EDID read.

+

Negative number or **0**

+

Failed to read the EDID.

+
+ +The following is an example of reading the raw EDID data from a sink: + +```c +int32_t len; +uint8_t edid[HDMI_EDID_MAX_LEN] = {0}; + +len = HdmiReadSinkEdid(hdmiHandle, edid, HDMI_EDID_MAX_LEN); +if (len <= 0) { + HDF_LOGE("%s: HdmiReadSinkEdid failed len = %d.", __func__, len); +} +``` + +### Setting Video, Audio, and HDR Attributes + +#### Setting Audio Attributes + +```c +int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr); +``` + +**Table 5** Description of HdmiSetAudioAttribute + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

attr

+

Audio attributes.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of setting audio attributes: + +```c +struct HdmiAudioAttr audioAttr = {0}; +int32_t ret; + +audioAttr.codingType = HDMI_AUDIO_CODING_TYPE_MP3; +audioAttr.ifType = HDMI_AUDIO_IF_TYPE_I2S; +audioAttr.bitDepth = HDMI_ADIO_BIT_DEPTH_16; +audioAttr.sampleRate = HDMI_SAMPLE_RATE_8K; +audioAttr.channels = HDMI_AUDIO_FORMAT_CHANNEL_3; +ret = HdmiSetAudioAttribute(handle, &audioAttr); +if (ret != 0) { + HDF_LOGE("HdmiSetAudioAttribute failed."); +} +``` + +#### Setting Video Attributes + +```c +int32_t HdmiSetVideoAttribute(DevHandle handle, struct HdmiVideoAttr *attr); +``` + +**Table 6** Description of HdmiSetVideoAttribute + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

attr

+

Video attributes.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of setting video attributes: + +```c +struct HdmiVideoAttr videoAttr = {0}; +int32_t ret; + +videoAttr.colorSpace = HDMI_COLOR_SPACE_YCBCR444; +videoAttr.colorimetry = HDMI_COLORIMETRY_EXTENDED; +videoAttr.extColorimetry = HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM; +videoAttr.quantization = HDMI_QUANTIZATION_RANGE_FULL; +ret = HdmiSetVideoAttribute(handle, &videoAttr); +if (ret != 0) { + HDF_LOGE("HdmiSetVideoAttribute failed."); +} +``` + +#### Setting HDR Attributes + +```c +int32_t HdmiSetHdrAttribute(DevHandle handle, struct HdmiHdrAttr *attr); +``` + +**Table 7** Description of HdmiSetHdrAttribute + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

attr

+

HDR attributes.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of setting HDR attributes: + +```c +struct HdmiHdrAttr hdrAttr = {0}; +int32_t ret; + +hdrAttr.mode = HDMI_HDR_MODE_CEA_861_3; +hdrAttr.userMode = HDMI_HDR_USERMODE_DOLBY; +hdrAttr.eotfType = HDMI_EOTF_SMPTE_ST_2048; +hdrAttr.metadataType = HDMI_DRM_STATIC_METADATA_TYPE_1; +hdrAttr.colorimetry = HDMI_HDR_EXTENDED_COLORIMETRY_XV_YCC_709; +ret = HdmiSetHdrAttribute(handle, &hdrAttr); +if (ret != 0) { + HDF_LOGE("HdmiSetHdrAttribute failed."); +} +``` + +### Setting Other Attributes + +#### Setting HDMI AV Mute + +```c +int32_t HdmiAvmuteSet(DevHandle handle, bool enable); +``` + +**Table 8** Description of HdmiAvmuteSet + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

enable

+

Whether the AV mute feature is enabled. +

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of setting AV mute: + +```c +int32_t ret; + +ret = HdmiAvmuteSet(hdmiHandle, true); +if (ret != 0) { + HDF_LOGE("HdmiAvmuteSet failed."); +} +``` + +#### Setting the Color Depth + +```c +int32_t HdmiDeepColorSet(DevHandle handle, enum HdmiDeepColor color); +``` + +**Table 9** Description of HdmiDeepColorSet + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

color

+

Color depth to set.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of setting the color depth: + +```c +int32_t ret; + +ret = HdmiDeepColorSet(handle, HDMI_DEEP_COLOR_48BITS); +if (ret != 0) { + HDF_LOGE("HdmiDeepColorSet failed."); +} +``` + +#### Obtaining the Color Depth + +```c +int32_t HdmiDeepColorGet(DevHandle handle, enum HdmiDeepColor *color); +``` + +**Table 10** Description of HdmiDeepColorGet + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

color

+

Color depth.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of obtaining the color depth: + +```c +enum HdmiDeepColor color; +int32_t ret; + +ret = HdmiDeepColorGet(handle, &color); +if (ret != 0) { + HDF_LOGE("HdmiDeepColorGet failed."); +} +``` + +### Starting HDMI Transmission + +```c +int32_t HdmiStart(DevHandle handle); +``` + +**Table 11** Description of HdmiStart + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of starting HDMI transmission: + +```c +int32_t ret; + +ret = HdmiStart(hdmiHandle); +if (ret != 0) { + HDF_LOGE("Failed to start transmission."); +} +``` + +### Stopping HDMI Transmission + +```c +int32_t HdmiStop(DevHandle handle); +``` + +**Table 12** Description of HdmiStop + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of stopping HDMI transmission: + +```c +int32_t ret; + +ret = HdmiStop(hdmiHandle); +if (ret != 0) { + HDF_LOGE("Failed to stop transmission."); +} +``` + +### Unregistering the Callback for Hot Plug Detect + +```c +int32_t HdmiUnregisterHpdCallbackFunc(DevHandle handle); +``` + +**Table 13** Description of HdmiUnregisterHpdCallbackFunc + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

The operation failed.

+
+ +The following is an example of unregistering the callback for hot plug detect: + +```c +int32_t ret; + +ret = HdmiUnregisterHpdCallbackFunc(hdmiHandle); +if (ret != 0) { + HDF_LOGE("unregister failed."); +} +``` + +### Closing an HDMI Controller + +```c +void HdmiClose(DevHandle handle); +``` + +**Table 14** Description of HdmiClose + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

HDMI controller handle.

+
+ +The following is an example of closing an HDMI controller: + +```c +HdmiClose(hdmiHandle); +``` + +## Example + +This following example shows how to use HDMI APIs to manage an HDMI device on a Hi3516D V300 development board. + +A virtual driver is used in this example. The hardware information is as follows: + +- SoC: Hi3516D V300 + +- HDMI controller: HDMI controller 0 + + +The sample code is as follows: + +```c +#include "hdmi_if.h" /* Header file for HDMI standard APIs */ +#include "hdf_log.h" /* Header file for log APIs */ +##include "osal_time.h" /* Header file for delay and sleep APIs */ + +/* Callback for hog plug detect */ +static void HdmiHpdHandle(void *data, bool hpd) +{ + if (data == NULL) { + HDF_LOGE("priv data is NULL"); + return; + } + + if (hpd == true) { + HDF_LOGD("HdmiHpdHandle: hot plug"); + /* Add related processing if required. */ + } else { + HDF_LOGD("HdmiHpdHandle: hot unplog"); + /* Add related processing if required. */ + } +} + +/* Set HDMI attributes. */ +static int32_t TestHdmiSetAttr(DevHandle handle) +{ + enum HdmiDeepColor color; + struct HdmiVideoAttr videoAttr = {0}; + struct HdmiAudioAttr audioAttr = {0}; + struct HdmiHdrAttr hdrAttr = {0}; + int32_t ret; + + ret = HdmiDeepColorSet(handle, HDMI_DEEP_COLOR_48BITS); + + if (ret != 0) { + HDF_LOGE("HdmiDeepColorSet failed."); + return ret; + } + ret = HdmiDeepColorGet(handle, &color); + if (ret != 0) { + HDF_LOGE("HdmiDeepColorGet failed."); + return ret; + } + HDF_LOGE("HdmiDeepColorGet successful, color = %d.", color); + videoAttr.colorSpace = HDMI_COLOR_SPACE_YCBCR444; + videoAttr.colorimetry = HDMI_COLORIMETRY_EXTENDED; + videoAttr.extColorimetry = HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM; + videoAttr.quantization = HDMI_QUANTIZATION_RANGE_FULL; + ret = HdmiSetVideoAttribute(handle, &videoAttr); + if (ret != 0) { + HDF_LOGE("HdmiSetVideoAttribute failed."); + return ret; + } + audioAttr.codingType = HDMI_AUDIO_CODING_TYPE_MP3; + audioAttr.ifType = HDMI_AUDIO_IF_TYPE_I2S; + audioAttr.bitDepth = HDMI_ADIO_BIT_DEPTH_16; + audioAttr.sampleRate = HDMI_SAMPLE_RATE_8K; + audioAttr.channels = HDMI_AUDIO_FORMAT_CHANNEL_3; + ret = HdmiSetAudioAttribute(handle, &audioAttr); + if (ret != 0) { + HDF_LOGE("HdmiSetAudioAttribute failed."); + return ret; + } + hdrAttr.mode = HDMI_HDR_MODE_CEA_861_3; + hdrAttr.userMode = HDMI_HDR_USERMODE_DOLBY; + hdrAttr.eotfType = HDMI_EOTF_SMPTE_ST_2048; + hdrAttr.metadataType = HDMI_DRM_STATIC_METADATA_TYPE_1; + hdrAttr.colorimetry = HDMI_HDR_EXTENDED_COLORIMETRY_XV_YCC_709; + ret = HdmiSetHdrAttribute(handle, &hdrAttr); + if (ret != 0) { + HDF_LOGE("HdmiSetHdrAttribute failed."); + return ret; + } + + return 0; +} + +/* Main entry of HDMI routines */ +static int32_t TestCaseHdmi(void) +{ + DevHandle handle = NULL; + int32_t ret; + + struct HdmiHpdCallbackInfo info = {0}; + uint8_t data[128] = {0}; + + HDF_LOGD("HdmiAdapterInit: successful."); + handle = HdmiOpen(0); + if (handle == NULL) { + HDF_LOGE("HdmiOpen failed."); + return ret; + } + info.data = handle; + info.callbackFunc = HdmiHpdHandle; + ret = HdmiRegisterHpdCallbackFunc(handle, &info); + if (ret != 0) { + HDF_LOGE("HdmiRegisterHpdCallbackFunc failed."); + return ret; + } + + ret = HdmiReadSinkEdid(handle, data, 128); + if (ret <= 0) { + HDF_LOGE("HdmiReadSinkEdid failed."); + return ret; + } + HDF_LOGE("HdmiReadSinkEdid successful, data[6] = %d, data[8] = %d.", data[6], data[8]); + + ret = TestHdmiSetAttr(handle); + if (ret != 0) { + HDF_LOGE("TestHdmiSetAttr failed."); + return ret; + } + + ret = HdmiStart(handle); + if (ret != 0) { + HDF_LOGE("HdmiStart failed."); + return ret; + } + + OsalMSleep(1000); + + ret = HdmiStop(handle); + if (ret != 0) { + HDF_LOGE("HdmiStop failed."); + return ret; + } + + ret = HdmiUnregisterHpdCallbackFunc(handle); + if (ret != 0) { + HDF_LOGE("HdmiUnregisterHpdCallbackFunc failed."); + return ret; + } + HdmiClose(handle); + return 0; +} + +``` diff --git a/en/device-dev/driver/driver-platform-hdmi-develop.md b/en/device-dev/driver/driver-platform-hdmi-develop.md new file mode 100644 index 0000000000000000000000000000000000000000..2cb7bdfd6bf17ce28e61eb68175cb0e57c96a749 --- /dev/null +++ b/en/device-dev/driver/driver-platform-hdmi-develop.md @@ -0,0 +1,379 @@ +# HDMI + +## Overview + +The High-Definition Multimedia Interface (HDMI) is an audio/video transmission protocol released by Hitachi, Panasonic, Philips, SiliconImage, Sony, Thomson and Toshiba. It is used to transmit audio or video data from an audio or video source device, such as a DVD player or STB, to a sink device, such as a TV or monitor. The transmission process complies with the Transition Minimized Differential Signaling (TMDS) protocol. + +In the HDF, the HDMI module uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to process external access requests. After receiving an access request, 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 node for each device, which increases the memory usage. + + **Figure 1** Independent service mode + +![image1](figures/independent-service-mode.png) + +## How to Develop + +The HDMI module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device_info.hcs** file. + - (Optional) Add the **hdmi_config.hcs** file. + +3. Instantiate the HDMI controller object. + - Initialize **HdmiCntlr**. + - Instantiate **HdmiCntlrOps** in **HdmiCntlr**. For details, see the following description of **HdmiCntlrOps**. + + HdmiCntlrOps: + ```c + struct HdmiCntlrOps { + void (*hardWareInit)(struct HdmiCntlr *cntlr); + void (*hardWareStatusGet)(struct HdmiCntlr *cntlr, struct HdmiHardwareStatus *status); + void (*controllerReset)(struct HdmiCntlr *cntlr); + bool (*hotPlugStateGet)(struct HdmiCntlr *cntlr); + bool (*hotPlugInterruptStateGet)(struct HdmiCntlr *cntlr); + void (*lowPowerSet)(struct HdmiCntlr *cntlr, bool enable); + void (*tmdsModeSet)(struct HdmiCntlr *cntlr, enum HdmiTmdsModeType mode); + int32_t (*tmdsConfigSet)(struct HdmiCntlr *cntlr, struct HdmiTmdsConfig mode); + void (*infoFrameEnable)(struct HdmiCntlr *cntlr, enum HdmiPacketType infoFrameType, bool enable); + int32_t (*infoFrameSend)(struct HdmiCntlr *cntlr, enum HdmiPacketType infoFrameType, uint8_t *data, uint32_t len); + int32_t (*infoFrameDataSet)(struct HdmiCntlr *cntlr, uint32_t type, uint8_t *data, uint32_t len); + int32_t (*cecMsgSend)(struct HdmiCntlr *cntlr, struct HdmiCecMsg *msg); + void (*audioPathEnable)(struct HdmiCntlr *cntlr, bool enable); + void (*audioPathSet)(struct HdmiCntlr *cntlr, struct HdmiAudioConfigInfo *config); + void (*phyOutputEnable)(struct HdmiCntlr *cntlr, bool enable); + void (*phyOutputSet)(struct HdmiCntlr *cntlr, struct HdmiPhyCfg *cfg); + void (*blackDataSet)(struct HdmiCntlr *cntlr, bool enable); + void (*videoMuteEnable)(struct HdmiCntlr *cntlr, bool enable); + void (*videoPathSet)(struct HdmiCntlr *cntlr, struct HdmiVideoAttr *attr); + void (*audioMuteEnable)(struct HdmiCntlr *cntlr, bool enable); + void (*avmuteSet)(struct HdmiCntlr *cntlr, bool enable); + int32_t (*ddcTransfer)(struct HdmiCntlr *cntlr, struct HdmiDdcCfg *ddcCfg); + bool (*scdcSourceScrambleGet)(struct HdmiCntlr *cntlr); + int32_t (*scdcSourceScrambleSet)(struct HdmiCntlr *cntlr, bool enable); + void (*frlSet)(struct HdmiCntlr *cntlr); + int32_t (*frlEnable)(struct HdmiCntlr *cntlr, bool enable); + int32_t (*audioNctsSet)(struct HdmiCntlr *cntlr, struct HdmiFrlAudioNctsConfig *cfg); + void (*frlTrainingConfigSet)(struct HdmiCntlr *cntlr, struct HdmiFrlTrainConfig *cfg); + void (*frlTrainingStart)(struct HdmiCntlr *cntlr); + void (*frlGetTriningRslt)(struct HdmiCntlr *cntlr, struct HdmiFrlTrainRslt *rslt); + void (*hdcpRegInit)(struct HdmiCntlr *cntlr); + int32_t (*hdcpGenerateAksvAndAn)(struct HdmiCntlr *cntlr); + int32_t (*hdcpOptReg)(struct HdmiCntlr *cntlr, enum HdmiHdcpRegOptType type, uint8_t *data, uint32_t len); + void (*hdrTimerSet)(struct HdmiCntlr *cntlr, struct HdmiHdrTimerConfig *config); + }; + ``` + + **Table 1** Callbacks for the members in the HdmiCntlrOps structure + + | Function Member| Input Parameter| Output Parameter| Return Value| Description| + | ------------------------ | ------------------------------------------------------------ | -------------------------------------- | ------------------ | -------------------------------------------------- | + | hardWareInit | **cntlr**: structure pointer to an HDMI controller at the core layer.| –| –| Initializes HDMI hardware.| + | hardWareStatusGet | **cntlr**: structure pointer to an HDMI controller at the core layer.
| **status**: HDMI hardware status.| –| Obtains the HDMI hardware status.| + | controllerReset | **cntlr**: structure pointer to an HDMI controller at the core layer.| –| –| Resets an HDMI controller.| + | hotPlugStateGet | **cntlr**: structure pointer to an HDMI controller at the core layer.| -| **bool**: HDMI hot-plug status.| Obtains the HDMI hot-plug status.| + | hotPlugInterruptStateGet | **cntlr**: structure pointer to an HDMI controller at the core layer.| –| **bool**: HDMI hot-plug interrupt status.| Obtains the HDMI hot-plug interrupt status.| + | lowPowerSet | **cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether low power consumption is enabled.| –| –| Enables or disables low power consumption.| + | tmdsModeSet | **cntlr**: structure pointer to an HDMI controller at the core layer.
**mode**: TMDS mode.| –| –| Set the TMDS mode.| + |tmdsConfigSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**mode**: TMDS mode parameters.|–|HDF_STATUS|Sets TMDS parameters.| + |infoFrameEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**infoFrameType**: packet type.
**enable**: whether infoFrame is enabled.|–|–|Enables or disables infoFrame.| + |infoFrameSend|**cntlr**: structure pointer to an HDMI controller at the core layer.
**infoFrameType**: packet type.
**data**: infoFrame data.
**len**: data length.|–|HDF_STATUS|Sends an infoFrame.| + |cecMsgSend|**cntlr**: structure pointer to an HDMI controller at the core layer.
**msg**: Consumer Electronics Control (CEC) message.|–|HDF_STATUS|Sends a CEC message.| + |audioPathEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the audio path is enabled.|–|–|Enables or disables the audio path.| + |audioPathSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**config**: audio path configuration.|–|–|Sets the audio path.| + |phyOutputEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the physical layer output is enabled.|–|–|Enables or disables the physical layer output.| + |phyOutputSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**cfg**: physical layer configuration.|–|–|Sets the physical layer information.| + |blackDataSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the black screen is enabled.|–|–|Sets the black screen.| + |videoMuteEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the video mute feature is enabled.|–|–|Enables or disables the video mute feature.| + |videoPathSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**attr**: configuration.|–|–|Sets the video path.| + |audioMuteEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the audio mute feature is enabled.|–|–|Enables or disables the audio mute feature.| + |avmuteSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether the AV mute feature is enabled.|–|–|Enables or disables the AV mute feature.| + |ddcTransfer|**cntlr**: structure pointer to an HDMI controller at the core layer.
**ddcCfg**: DDC configuration.|**ddcCfg**: DDC configuration.|HDF_STATUS|Reads and writes data through the display data channel (DDC).| + |scdcSourceScrambleGet|**cntlr**: structure pointer to an HDMI controller at the core layer.|–|Scrambling status of the source.|Obtains the scrambling status of the source.| + |scdcSourceScrambleSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether scrambling is enabled for the source.|–|HDF_STATUS|Enables or disable scrambling for the source.| + |frlEnable|**cntlr**: structure pointer to an HDMI controller at the core layer.
**enable**: whether fixed rate link (FRL) is enabled.|–|HDF_STATUS|Enables or disables the FRL.| + |audioNctsSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**cfg**: N/CTS configuration.|–|HDF_STATUS|Sets the audio N/CTS information.| + |frlTrainingConfigSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**cfg**: FRL training configuration.|–|–|Sets FRL training information.| + |frlTrainingStart|**cntlr**: structure pointer to an HDMI controller at the core layer.|–|–|Starts FRL training.| + |frlGetTriningRslt|**cntlr**: structure pointer to an HDMI controller at the core layer.|**rslt**: FRL training result.|–|Obtains the FRL training result.| + |hdcpRegInit|**cntlr**: structure pointer to an HDMI controller at the core layer.|–|–|Initializes registers related to the High-bandwidth Digital Content Protection (HDCP) process.| + |hdcpGenerateAksvAndAn|**cntlr**: structure pointer to an HDMI controller at the core layer.|–|HDF_STATUS|Generates the **Aksv** and **An** in the HDCP process.| + |hdcpOptReg|**cntlr**: structure pointer to an HDMI controller at the core layer.
**type**: operation type.
**data**: register data.
**len**: data length.|**data**: register data.|HDF_STATUS|Reads or writes the registers in the HDCP process.| + |hdrTimerSet|**cntlr**: structure pointer to an HDMI controller at the core layer.
**config**: timer configuration.|–|–|Sets the HDR-related timer.| + +## Development Example + +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 are 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. + + HDMI driver entry reference: + + ```c + struct HdfDriverEntry g_hdmiDriverEntry = { + .moduleVersion = 1, + .Bind = HdmiAdapterBind, + .Init = HdmiAdapterInit, + .Release = HdmiAdapterRelease, + .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. + ``` + +2. Add **deviceNode** to the **device_info.hcs** file, and configure the device attributes in the **hdmi_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 restriction ranges of the **HdmiCntlr** members at the core layer. + + Configure HDMI controller information from the second node. This node specifies a type of HDMI controllers rather than a specific HDMI controller. In this example, there is only one HDMI controller. If there are multiple HDMI controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **hdmi_config** file. + + - **device_info.hcs** configuration reference + + ```c + root { + platform :: host { + device_hdmi :: device { + device0 :: deviceNode { + policy = 2; // The value 2 means to publish a service. + priority = 20; // Driver startup priority. + permission = 0644; // Permission to create device nodes for the driver. + serviceName = "HDF_PLATFORM_HDMI_0"; // (Mandatory) Unique name of the service published by the driver. + moduleName = "hdmi_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry. + deviceMatchAttr = "adapter_hdmi_driver"; // (Mandatory) Controller private data, which must be same as that of the corresponding controller in hdmi_config.hcs. + } // The specific controller information is in hdmi_config.hcs. + } + } + } + ``` + + - **hdmi_config.hcs** configuration reference + + ```c + root { + platform { + hdmi_config { + template hdmi_controller { // Template configuration. In the template, you can configure the common parameters shared by service nodes. + match_attr = ""; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. + index = 0; // (Mandatory) HDMI controller number. + regBasePhy = 0x10100000; // (Mandatory) Physical base address of the register. + regSize = 0xd1; // (Mandatory) Register bit width. + irqNum = 100; //(Mandatory) Interrupt request (IRQ) number. + maxTmdsClock = 300; + videoTiming = 10; + quantization = 1; + colorSpace = 0; + colorimetry = 0; + audioIfType = 0; + audioBitDepth = 1; + audioSampleRate = 2; + audioChannels = 1; + hdrColorimetry = 4; + hdrUserMode = 1; + cap = 0xd001e045; + } + controller_0x10100000 :: hdmi_controller { + match_attr = "adapter_hdmi_driver"; + index = 0; + regBasePhy = 0x10100000; + irqNum = 100; + maxTmdsClock = 400; + defTmdsClock = 300; + maxFrlRate = 600; + videoTiming = 10; + quantization = 1; + colorSpace = 0; + colorimetry = 0; + audioIfType = 0; + audioSampleRate = 2; + audioChannels = 1; + hdrColorimetry = 4; + hdrUserMode = 1; + cap = 0xd001e045; + } + } + } + } + ``` + +3. Initialize the **HdmiCntlr** object at the core layer, including initializing the vendor custom structure (transferring parameters and data) and instantiating the **HdmiCntlrOps** (used to call the underlying functions of the driver). The **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) must be implemented in this step. + + - Custom structure reference + + > ![](../public_sys-resources/icon-note.gif) **NOTE:** + > To the driver, the custom structure carries parameters and data. The values in the **hdmi_config.hcs** file are read by the HDF, and structure members are initialized by **DeviceResourceIface**. Some important values (such as the device number and bus number) are also passed to the **HdmiCntlr** object of the core layer. + + ```c + struct HdmiAdapterHost { + struct HdmiCntlr *cntlr; // (Mandatory) Control object of the core layer. The details are as follows: + volatile unsigned char *regBase;// (Mandatory) Register base address. + uint32_t regBasePhy // (Mandatory) Physical base address of the register. + uint32_t regSize; // (Mandatory) Register bit width. + uint32_t irqNum; // (Mandatory) IRQ number. + }; + + /* HdmiCntlr is the controller structure at the core layer. Its members are assigned with values by using the Init function. */ + struct HdmiCntlr { + struct IDeviceIoService service; + struct HdfDeviceObject *hdfDevObj; + struct PlatformDevice device; + struct OsalMutex mutex; + struct PlatformQueue *msgQueue; + struct HdmiCntlrCap cap; + struct HdmiAttr attr; + struct HdmiCntlrOps *ops; + uint32_t deviceIndex; + uint32_t state; // Controller status. + enum HdmiTmdsModeType tmdsMode; + struct HdmiDevice *hdmi; + struct HdmiInfoframe infoframe; + struct HdmiScdc *scdc; + struct HdmiDdc ddc; + struct HdmiFrl *frl; + struct HdmiHdcp *hdcp; + struct HdmiCec *cec; + struct HdmiEvent event; + struct HdmiHdr *hdr; + void *priv; + }; + ``` + + - **(Important)** Instantiate the callback structure **HdmiCntlrOps** in **HdmiCntlr**. + + ```c + static struct HdmiCntlrOps g_hdmiAdapterHostOps = { + .hardWareInit = HdmiAdapterHardWareInit, + .hardWareStatusGet = HdmiAdapterHardWareStatusGet, + .controllerReset = HdmiAdapterControllerReset, + .hotPlugStateGet = HdmiAdapterHotPlugStateGet, + .hotPlugInterruptStateGet = HdmiAdapterHotPlugInterruptStateGet, + .lowPowerSet = HdmiAdapterLowPowerSet, + .tmdsModeSet = HdmiAdapterTmdsModeSet, + .tmdsConfigSet = HdmiAdapterTmdsConfigSet, + .infoframeEnable = HdmiAdapterInfoframeEnable, + .infoframeSend = HdmiAdapterInfoframeSend, + .infoframeDataSet = HdmiAdapterInfoframeDataSet, + .cecMsgSend = HdmiAdapterCecMsgSend, + .audioPathEnable = HdmiAdapterAudioPathEnable, + .audioPathSet = HdmiAdapterAudioPathSet, + .phyOutputEnable = HdmiAdapterPhyOutputEnable, + .phyOutputSet = HdmiAdapterPhyOutputSet, + .blackDataSet = HdmiAdapterBlackDataSet, + .videoMuteEnable = HdmiAdapterVideoMuteEnable, + .videoPathSet = HdmiAdapterVideoPathSet, + .audioMuteEnable = HdmiAdapterAudioMuteEnable, + .avmuteSet = HdmiAdapterAvmuteSet, + .ddcTransfer = HdmiAdapterDdcTransfer, + .scdcSourceScrambleGet = HdmiAdapterScdcSourceScrambleGet, + .scdcSourceScrambleSet = HdmiAdapterScdcSourceScrambleSet, + .frlSet = HdmiAdapterFrlSet, + .frlEnable = HdmiAdapterFrlEnable, + .audioNctsSet = HdmiAdapterAudioNctsSet, + .frlTrainingConfigSet = HdmiAdapterFrlTrainingConfigSet, + .frlTrainingStart = HdmiAdapterFrlTrainingStart, + .frlGetTriningRslt = HdmiAdapterFrlGetTriningRslt, + .hdcpRegInit = HdmiAdapterHdcpRegInit, + .hdcpGenerateAksvAndAn = HdmiAdapterHdcpGenerateAksvAndAn, + .hdcpOptReg = HdmiAdapterHdcpOptReg, + .hdrTimerSet = HdmiAdapterHdrTimerSet, + }; + ``` + + - **Bind function** + + > **Input parameter**: + > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + > + > **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**.) + + |State (Value)|Status| + |:-|:-| + |HDF_ERR_INVALID_OBJECT|Invalid controller object.| + |HDF_ERR_INVALID_PARAM |Invalid parameter.| + |HDF_ERR_MALLOC_FAIL |Failed to allocate memory.| + |HDF_ERR_IO |I/O error.| + |HDF_SUCCESS |Transmission successful.| + |HDF_FAILURE |Transmission failed.| + + > **Function description:** + > 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. + + ```c + static int32_t HdmiAdapterBind(struct HdfDeviceObject *obj) + { + struct HdmiCntlr *cntlr = NULL; + struct HimciAdapterHost *host = NULL; + int32_t ret; + cntlr = (struct HdmiCntlr *)OsalMemCalloc(sizeof(struct HdmiCntlr)); + if (cntlr == NULL) { + HDF_LOGE("%s: malloc cntlr failed!", __func__); + return HDF_ERR_MALLOC_FAIL; + } + host = (struct HimciAdapterHost *)OsalMemCalloc(sizeof(struct HimciAdapterHost)); + if (host == NULL) { + HDF_LOGE("%s: malloc host failed!", __func__); + return HDF_ERR_MALLOC_FAIL; + } + cntlr->priv = (void *)host; // (Mandatory) Store host to the private data of cntlr. + cntlr->ops = &g_hdmiHostOps; // (Mandatory) Connect to the HdmiCntlrOps instance. + cntlr->hdfDevObj = obj; // (Mandatory) Prerequisites for conversion between HdfDeviceObject and HdmiCntlr. + obj->service = &cntlr->service; // (Mandatory) Prerequisites for conversion between HdfDeviceObject and HdmiCntlr. + ret = HdmiAdapterCntlrParse(cntlr, obj); // (Mandatory) Initialize cntlr. If the operation fails, execute goto__ERR. + ... + ret = HdmiAdapterHostParse(host, obj); // (Mandatory) Initialize the attributes of the host object. If the initialization fails, execute goto__ERR. + ... + ret = HdmiAdapterHostInit(host, cntlr); // Perform vendor custom initialization. If the initialization fails, execute goto __ERR. + ... + ret = HdmiCntlrAdd(cntlr); // Call the function at the core layer. If the operation fails, execute goto__ERR. + ... + HDF_LOGD("HdmiAdapterBind: success."); + return HDF_SUCCESS; + __ERR: + HdmiAdapterDeleteHost(host); + HDF_LOGD("HdmiAdapterBind: fail, err = %d.", ret); + return ret; + } + ``` + + - **Init function** + + >**Input parameter**: + >**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + > + >**Return value** + >HDF_STATUS + > + >Function description: + > + >Implements the **HdmiAdapterInit** function. + + ```c + static int32_t HdmiAdapterInit(struct HdfDeviceObject *obj) + { + return HDF_SUCCESS; + } + ``` + + - **Release function** + + > **Input parameter**: + > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + > + > **Return value** + > – + > + > **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. + + ```c + static void HdmiAdapterRelease(struct HdfDeviceObject *obj) + { + struct HdmiCntlr *cntlr = NULL; + ... + cntlr = (struct MmcCntlr *)obj->service;// Forcibly convert HdfDeviceObject to HdmiCntlr by using service. For details about the value assignment, see the Bind function. + ... + HimciDeleteHost((struct HimciAdapterHost *)cntlr->priv);// Memory release function customized by the vendor. A forced conversion from HdmiCntlr to HimciAdapterHost is involved in the process. + } + ``` + > All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. diff --git a/en/device-dev/driver/driver-platform-i2c-des.md b/en/device-dev/driver/driver-platform-i2c-des.md index f0fc3530d5fef97b40bbe31aa912c9a6522bb2ff..16b1d22f7a2f02985671934100642647f828ad8f 100644 --- a/en/device-dev/driver/driver-platform-i2c-des.md +++ b/en/device-dev/driver/driver-platform-i2c-des.md @@ -1,15 +1,5 @@ # I2C -- [Overview](#section5361140416) -- [Available APIs](#section545869122317) -- [Usage Guidelines](#section1695201514281) - - [How to Use](#section1338373417288) - - [Opening an I2C Controller](#section13751110132914) - - [Performing I2C Communication](#section9202183372916) - - [Closing an I2C Controller](#section19481164133018) - -- [Usage Example](#section5302202015300) - ## Overview - The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires. diff --git a/en/device-dev/driver/driver-platform-i2c-develop.md b/en/device-dev/driver/driver-platform-i2c-develop.md index 6d3bea6f18837b54ddb94dcf88cba576dd35d74e..f7199bbd8ef3c720697694be10d7aeab1f914b68 100644 --- a/en/device-dev/driver/driver-platform-i2c-develop.md +++ b/en/device-dev/driver/driver-platform-i2c-develop.md @@ -1,10 +1,6 @@ # I2C -- [Overview](#section2040078630114257) -- [How to Develop](#section1085786591114257) - - [I2cMethod and I2cLockMethod](#section1683458184518) -- [Development Example](#section1773332551114257) ## Overview @@ -13,31 +9,9 @@ The Inter-Integrated Circuit \(I2C\) bus is a simple and bidirectional two-wire **Figure 1** Unified service mode ![](figures/unified-service-mode.png "unified-service-mode-8") -## How to Develop +## Available APIs -The I2C module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **i2c\_config.hcs** file. - -3. Instantiate the I2C controller object. - - Initialize **I2cCntlr**. - - Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [I2cMethod and I2cLockMethod](#section1683458184518) and [Table 1](#table10549174014611). - - -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. - - -### I2cMethod and I2cLockMethod +I2cMethod and I2cLockMethod ``` struct I2cMethod { @@ -78,6 +52,32 @@ struct I2cLockMethod {// Lock mechanism operation structure +## How to Develop + +The I2C module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **i2c\_config.hcs** file. + +3. Instantiate the I2C controller object. + - Initialize **I2cCntlr**. + - Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [I2cMethod and I2cLockMethod](#section1683458184518) and [Table 1](#table10549174014611). + + +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 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. diff --git a/en/device-dev/driver/driver-platform-i3c-des.md b/en/device-dev/driver/driver-platform-i3c-des.md new file mode 100644 index 0000000000000000000000000000000000000000..e24a7561b5ee0e18695359ac9966f8e6eee8914b --- /dev/null +++ b/en/device-dev/driver/driver-platform-i3c-des.md @@ -0,0 +1,613 @@ +# I3C + + +## Overview + +The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidirectional 2-wire synchronous serial bus protocol developed by the Mobile Industry Processor Interface (MIPI) Alliance. + +I3C is backward compatible with legacy Inter-Integrated Circuit (I2C) devices. Moreover, it provides the in-band interrupt (IBI) function and supports hot-join of I3C devices. This eliminates the need for adding an extra interrupt line to implement interrupts in I2C. + +The I2C device, I3C slave device, and I3C secondary master device can coexist on the I3C bus. + +The I3C APIs provide a set of common functions for I3C transfer, including: + +- Opening and closing an I3C controller. +- Obtaining and setting I3C controller parameters. +- Performing customized I3C message transfer by using a message array. +- Requesting and releasing an IBI. + +[Figure 1](#fig1) shows the I3C physical connection. + +**Figure 1** I3C physical connection +![](figures/I3C_physical_connection.png "I3C_physical_connection.png") + + +## Available APIs + +**Table 1** I3C driver APIs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Category

+

API

+

Description

+

I3C controller management

+

I3cOpen

+
Opens an I3C controller.

+

I3cClose

+

Closes an I3C controller.

+

I3C transfer

+

I3cTransfer

+

Customizes an I3C transfer.

+

I3C controller configuration

+

I3cSetConfig

+
Sets an I3C controller.

+

I3cGetConfig

+

Obtains the I3C controller configuration.

+

I3C IBI

+

I3cRequestIbi

+
Requests an IBI.

+

I3cFreeIbi

+

Releases an IBI.

+
+ + + +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>All functions described in this document can be called only in kernel space. + +## Usage Guidelines + +### How to Use + +[Figure 2](#fig2) shows how I3C works. + +**Figure 2** How I3C works + +![](figures/I3C_usage_flowchart.png "I3C_usage_flowchart") + +### Opening an I3C Controller + +Before I3C communication, call **I3cOpen** to open an I3C controller. +```c +DevHandle I3cOpen(int16_t number); +``` + +**Table 2** Description of I3cOpen + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

number

+

I3C controller ID.

+

Return Value

+

Description

+

NULL

+

Failed to open the I3C controller.

+

Controller handle

+

Handle of the I3C controller opened.

+
+ +In the following example, open I3C controller 1 of the eight I3C controllers (numbered from 0 to 7) in the system. + +```c +DevHandle i3cHandle = NULL; /* I3C controller handle. / + +/* Open I3C controller 1. */ +i3cHandle = I3cOpen(1); +if (i3cHandle == NULL) { + HDF_LOGE("I3cOpen: failed\n"); + return; +} +``` + +### Performing I3C Communication + +Call **I3cTransfer()** to transfer messages. +```c +int32_t I3cTransfer(DevHandle handle, struct I3cMsg *msgs, int16_t count, enum TransMode mode); +``` + +**Table 3** Description of I3cTransfer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+

msgs

+

Message structure array of the data to be transmitted.

+

count

+

Length of the message array.

+

mode

+

Transmission mode, where the value 0 indicates the I2C mode, 1 indicates the I3C mode, and 2 indicates transmission of the Common Command Code (CCC). +

Return Value

+

Description

+

Positive integer

+

Number of message structures successfully transferred.

+

Negative number

+

The operation failed.

+
+ +The I3C messages are of the I3cMsg type. Each message structure indicates a read or write operation. A message array is used to perform multiple read or write operations. + +```c +int32_t ret; +uint8_t wbuff[2] = { 0x12, 0x13 }; +uint8_t rbuff[2] = { 0 }; +struct I3cMsg msgs[2]; /* Custom message array for transfer. */ +msgs[0].buf = wbuff; /* Data to write */ +msgs[0].len = 2; /* Length of the data to write. */ +msgs[0].addr = 0x3F; /* Address of the device to which the data is written. */ +msgs[0].flags = 0; /* Transfer flag. An write operation is performed by default. */ +msgs[1].buf = rbuff; /* Data to read */ +msgs[1].len = 2; /* Length of the data to read. */ +msgs[1].addr = 0x3F; /* Address of the device from which the data is read. */ +msgs[1].flags = I3C_FLAG_READ /* I3C_FLAG_READ is set. */ +/* Transfer two messages in I2C mode. */ +ret = I3cTransfer(i3cHandle, msgs, 2, I2C_MODE); +if (ret != 2) { + HDF_LOGE("I3cTransfer: failed, ret %d\n", ret); + return; +} +``` + +>![](../public_sys-resources/icon-caution.gif) **Caution** +>- The device address in the **I3cMsg** structure does not contain the read/write flag bit. The read/write information is passed by the read/write control bit in the member variable **flags**. +>- The **I3cTransfer()** function does not limit the number of message structures or the length of data in each message structure. The I3C controller determines these two parameters. +>- Using **I3cTransfer()** may cause the system to sleep. Do not call it in the interrupt context. + +### Obtaining the I3C Controller Configuration + +```c +int32_t I3cGetConfig(DevHandle handle, struct I3cConfig *config); +``` + +**Table 4** Description of I3cGetConfig + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+

config

+

I3C controller configuration.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

Failed to obtain the I3C controller configuration.

+
+ +### Configuring an I3C Controller + +```c +int32_t I3cSetConfig(DevHandle handle, struct I3cConfig *config); +``` + +**Table 5** Description of I3cSetConfig + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+

config

+

I3C controller configuration.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

Failed to configure the I3C controller.

+
+ +### Requesting an IBI + +```c +int32_t I3cRequestIbi(DevHandle handle, uint16_t addr, I3cIbiFunc func, uint32_t payload); +``` + +**Table 6** Description of I3cRequestIbi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+

addr

+

I3C device address.

+

func

+

Callback used to return the IBI.

+

payload

+

IBI payload.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

Failed to request the IBI.

+
+ +```c +static int32_t TestI3cIbiFunc(DevHandle handle, uint16_t addr, struct I3cIbiData data) +{ + (void)handle; + (void)addr; + HDF_LOGD("%s: %.16s", __func__, (char *)data.buf); + + return 0; +} + +int32_t I3cTestRequestIbi(void) +{ + DevHandle i3cHandle = NULL; + int32_t ret; + + /* Open an I3C controller. */ + i3cHandle = I3cOpen(1); + if (i3cHandle == NULL) { + HDF_LOGE("I3cOpen: failed\n"); + return; +} + ret = I3cRequestIbi(i3cHandle, 0x3F, TestI3cIbiFunc, 16); + if (ret != 0) { + HDF_LOGE("%s: Requset IBI failed!", __func__); + return -1; + } + + I3cClose(i3cHandle); + HDF_LOGD("%s: Done", __func__); + + return 0; +} +``` + +### Releasing an IBI + +```c +int32_t I3cFreeIbi(DevHandle handle, uint16_t addr); +``` + +**Table 7** Description of I3cFreeIbi + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+

addr

+

I3C device address.

+

Return Value

+

Description

+

0

+

The operation is successful.

+

Negative number

+

Failed to release the IBI.

+
+ +```c +I3cFreeIbi(i3cHandle, 0x3F); /* Release an IBI. */ +``` + +### Closing an I3C controller + +Call **I3cClose()** to close the I3C controller after the communication is complete. +```c +void I3cClose(DevHandle handle); +``` + +**Table 8** Description of I3cClose + + + + + + + + + + + +

Parameter

+

Description

+

handle

+

I3C controller handle.

+
+ + +```c +I3cClose(i3cHandle); /* Close an I3C controller. */ +``` + +## Example + +This following example shows how to use I3C APIs to manage an I3C device on a Hi3516D V300 development board. + +Because the Hi3516D V300 SoC has no I3C controller, this example describes how to perform simple transfer operations on a virtual driver on a Hi3516D V300. The basic information is as follows: + +- SoC: Hi3516D V300 + +- Virtual: The I3C address is 0x3f, and the register bit width is 1 byte. + +- The virtual I3C devices are connected to virtual I3C controllers 18 and 19. + +Perform simple I3C transfer to test whether the I3C channels are normal. + +The sample code is as follows: + +```c +#include "i3c_if.h" /* Header file for I3C standard APIs */ +#include "i3c_ccc.h" /* Header file for I3C CCCs */ +#include "hdf_log.h" /* Header file for log APIs */ +##include "osal_io.h" /* Header file for I/O read and write APIs */ +##include "osal_time.h" /* Header file for delay and sleep APIs */ + +/* Define a device structure to hold information. */ +struct TestI3cDevice { + uint16_t busNum; /* I3C bus number */ + uint16_t addr; /* I3C device address */ + uint16_t regLen; /* Register bit width */ + DevHandle i3cHandle; /* I3C controller handle */ +}; + +/* Use I3cTransfer to encapsulate a register read/write helper function. Use flag to indicate a read or write operation. */ +static int TestI3cReadWrite(struct TestI3cDevice *testDevice, unsigned int regAddr, + unsigned char *regData, unsigned int dataLen, uint8_t flag) +{ + int index = 0; + unsigned char regBuf[4] = {0}; + struct I3cMsg msgs[2] = {0}; + + /* Perform length adaptation for the single- or dual-byte register. */ + if (testDevice->regLen == 1) { + regBuf[index++] = regAddr & 0xFF; + } else { + regBuf[index++] = (regAddr >> 8) & 0xFF; + regBuf[index++] = regAddr & 0xFF; + } + + /* Fill in the I3cMsg message structure. */ + msgs[0].addr = testDevice->addr; + msgs[0].flags = 0; /* The flag 0 indicates a write operation. */ + msgs[0].len = testDevice->regLen; + msgs[0].buf = regBuf; + + msgs[1].addr = testDevice->addr; + msgs[1].flags = (flag == 1) ? I3C_FLAG_READ: 0; /* Add a read flag bit to read data. */ + msgs[1].len = dataLen; + msgs[1].buf = regData; + + if (I3cTransfer(testDevice->i3cHandle, msgs, 2, I2C_MODE) != 2) { + HDF_LOGE("%s: i3c read err", __func__); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + +/* Read data from the register. */ +static inline int TestI3cReadReg(struct TestI3cDevice *testDevice, unsigned int regAddr, + unsigned char *regData, unsigned int dataLen) +{ + return TestI3cReadWrite(testDevice, regAddr, regData, dataLen, 1); +} + +/* Write data to the register. */ +static inline int TestI3cWriteReg(struct TestI3cDevice *testDevice, unsigned int regAddr, + unsigned char *regData, unsigned int dataLen) +{ + return TestI3cReadWrite(testDevice, regAddr, regData, dataLen, 0); +} + +/* Main entry of I3C routines. */ +static int32_t TestCaseI3c(void) +{ + int32_t i; + int32_t ret; + unsigned char bufWrite[7] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xA, 0xB, 0xC }; + unsigned char bufRead[7] = {0}; + static struct TestI3cDevice testDevice; + + /* Initialize device information. */ + testDevice.busNum = 18; + testDevice.addr = 0x3F; + testDevice.regLen = 1; + testDevice.i3cHandle = NULL; + + /* Open an I3C controller. */ + testDevice.i3cHandle = I3cOpen(testDevice.busNum); + if (testDevice.i3cHandle == NULL) { + HDF_LOGE("%s: Open I3c:%u fail!", __func__, testDevice.busNum); + return -1; + } + + /* Write 7-byte data continuously to the device whose address is 0x3F. */ + ret = TestI3cWriteReg(&testDevice, 0x3F, bufWrite, 7); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: test i3c write reg fail!:%d", __func__, ret); + I3cClose(testDevice.i3cHandle); + return -1; + } + OsalMSleep(10); + + /* Read 7-byte data continuously from the device whose address is 0x3F. */ + ret = TestI3cReadReg(&testDevice, 0x3F, bufRead, 7); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: test i3c read reg fail!:%d", __func__, ret); + I3cClose(testDevice.i3cHandle); + return -1; + } + HDF_LOGI("%s: test i3c write&read reg success!", __func__); + + /* Close the I3C controller. */ + I3cClose(testDevice.i3cHandle); + + return 0; +} +``` diff --git a/en/device-dev/driver/driver-platform-i3c-develop.md b/en/device-dev/driver/driver-platform-i3c-develop.md new file mode 100644 index 0000000000000000000000000000000000000000..567e4bf34bf8cb3f588704a87f8ce22ee305de75 --- /dev/null +++ b/en/device-dev/driver/driver-platform-i3c-develop.md @@ -0,0 +1,406 @@ +# I3C + +## Overview + +The Improved Inter-Integrated Circuit (I3C) is a simple and cost-efficient bidirectional 2-wire synchronous serial bus protocol developed by the Mobile Industry Processor Interface (MIPI) Alliance. In the Hardware Driver Foundation (HDF), the I3C module uses the unified service mode for API adaptation. In this mode, a device service is used as the I3C 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 I3C 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. + +![image1](figures/unified-service-mode.png) + +## How to Develop + +The I3C module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF. + +2. Configure attribute files. + + - Add the **deviceNode** information to the **device_info.hcs** file. + - (Optional) Add the **i3c_config.hcs** file. + +3. **Instantiate the I3C controller object.** + + - Initialize **I3cCntlr**. + - Instantiate **I3cMethod** in **I3cCntlr**. For details, see the following description of **I3cMethod**. + +4. Register an interrupt handler. + Registers an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features. + + I3cMethod: + ```c + struct I3cMethod { + int32_t (*sendCccCmd)(struct I3cCntlr *cntlr, struct I3cCccCmd *ccc); + int32_t (*transfer)(struct I3cCntlr *cntlr, struct I3cMsg *msgs, int16_t count); + int32_t (*i2cTransfer)(struct I3cCntlr *cntlr, struct I3cMsg *msgs, int16_t count); + int32_t (*setConfig)(struct I3cCntlr *cntlr, struct I3cConfig *config); + int32_t (*getConfig)(struct I3cCntlr *cntlr, struct I3cConfig *config); + int32_t (*requestIbi)(struct I3cDevice *dev); + void (*freeIbi)(struct I3cDevice *dev); + }; + ``` + + **Table 1** Callbacks for the members in the I3cMethod structure + + |Callback|Input Parameter|Output Parameter|Return Value|Description| + |-|-|-|-|-| + |sendCccCmd|**cntlr**: structure pointer to an I3C controller at the core layer.
**ccc**: pointer to the input common command code (CCC) structure.|**ccc**: pointer to the output CCC structure.|HDF_STATUS|Sends a CCC.| + |Transfer |**cntlr**: structure pointer to an I3C controller at the core layer.
**msgs**: structure pointer to user messages.
**count**: number of messages, which is of the int16_t type.|**msgs**: structure pointer to user messages.|HDF_STATUS|Transfers user messages in I3C mode.| + |i2cTransfer |**cntlr**: structure pointer to an I3C controller at the core layer.
**msgs**: structure pointer to user messages.
**count**: number of messages, which is of the int16_t type.|**msgs**: structure pointer to user messages.|HDF_STATUS|Transfers user messages in I2C mode.| + |setConfig|**cntlr**: structure pointer to an I3C controller at the core layer.
**config**: controller configuration parameters.|–|HDF_STATUS|Configures an I3C controller.| + |getConfig|**cntlr**: structure pointer to an I3C controller at the core layer.|**config**: controller configuration parameters.|HDF_STATUS|Obtains the configuration of an I3C controller.| + |requestIbi|**device**: structure pointer to an I3C device at the core layer.|–|HDF_STATUS|Requests an IBI for an I3C device.| + |freeIbi|**device**: structure pointer to an I3C device at the core layer.|–|HDF_STATUS|Releases the IBI for an I3C device.| + +## Development Example + +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 are 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. + + I3C driver entry reference + + > The I3C module may be connected with multiple controllers. Therefore, in the HDF, a manager object is created for the I3C, and a manager service is published to handle external access requests in a unified manner. Before a controller is opened, the manager service is obtained first. Then, the manager service locates the target controller based on the specified parameters. + > + > The core layer implements the driver of the I3C manager service. **Vendors do not need to care about the implementation. When **Init()** is implemented, the **I3cCntlrAdd()** function at the core layer needs to be called to implement related features.** + + ```c + static struct HdfDriverEntry g_virtualI3cDriverEntry = { + .moduleVersion = 1, + .Init = VirtualI3cInit, + .Release = VirtualI3cRelease, + .moduleName = "virtual_i3c_driver",// (Mandatory) The value must be the same as that in the .hcs file. + }; + HDF_INIT(g_virtualI3cDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. + + /* Driver entry of the i3c_core.c manager service at the core layer */ + struct HdfDriverEntry g_i3cManagerEntry = { + .moduleVersion = 1, + .Init = I3cManagerInit, + .Release = I3cManagerRelease, + .moduleName = "HDF_PLATFORM_I3C_MANAGER",// Correspond to device0 in the device_info file. + }; + HDF_INIT(g_i3cManagerEntry); + ``` + +2. Add **deviceNode** to the **device_info.hcs** file, and configure the device attributes in the **i3c_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 restriction ranges of the **I3cCntlr** members at the core layer. + + In the unified service mode, the first device node in the **device_info** file must be the I3C manager. The I3C manager parameters must be set as follows: + + |Member|Value| + |-|-| + |moduleName |HDF_PLATFORM_I3C_MANAGER| + |serviceName|- (reserved)| + |policy|0| + |cntlrMatchAttr| - (reserved)| + + Configure I3C controller information from the second node. This node specifies a type of I3C controllers rather than a specific I3C controller. In this example, there is only one I3C controller. If there are multiple I3C controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **i3c_config** file. + + - **device_info.hcs** configuration reference + + ```c + root { + device_i3c :: device { + device0 :: deviceNode { + policy = 0; + priority = 52; + permission = 0644; + serviceName = "HDF_PLATFORM_I3C_MANAGER"; + moduleName = "HDF_PLATFORM_I3C_MANAGER"; + } + } + i3c_virtual :: deviceNode { + policy = 0; // The value 0 indicates that no service is published. + priority = 56; // Driver startup priority. + permission = 0644; // Permission to create device nodes for the driver. + moduleName = "virtual_i3c_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry. + serviceName = "VIRTUAL_I3C_DRIVER"; // (Mandatory) Unique name of the service published by the driver. + deviceMatchAttr = "virtual_i3c"; // (Mandatory) Controller private data, which must be same as that of the corresponding controller in i3c_config.hcs. + } // The specific controller information is in i3c_config.hcs. + } + ``` + + - i3c_config.hcs configuration reference + + ```c + root { + platform { + i3c_config { + match_attr = "virtual_i3c"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. + template i3c_controller { // Template configuration. In the template, you can configure the common parameters shared by service nodes. + busId = 0; // (Mandatory) I3C bus number. + busMode = 0x0; // Bus mode. Which can be 0x0 (pure), 0x1 (mixed-fast), 0x2 (mixed-limited), or 0x3 (mixed-slow). + regBasePhy = 0x120b0000; // (Mandatory) Physical base address. + regSize = 0xd1; // (Mandatory) Register bit width. + IrqNum = 20; // (Mandatory) Interrupt request (IRQ) number. + i3cMaxRate = 12900000; // (Optional) Maximum clock rate in I3C mode. + i3cRate = 12500000; // (Optional) Clock rate in I3C mode. + i2cFmRate = 1000000; // (Optional) Clock rate in I2C FM mode. + i2cFmPlusRate = 400000; // (Optional) Clock rate in I2C FM+ mode. + } + controller_0 :: i3c_controller { + busId = 18; + IrqNum = 20; + } + } + } + } + ``` + +3. Initialize the **I3cCntlr** object at the core layer, including initializing the vendor custom structure (transferring parameters and data) and instantiating **I3cMethod** (used to call the underlying functions of the driver) in **I3cCntlr**. + + The **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) must be implemented in this step. + + - Custom structure reference + + > To the driver, the custom structure carries parameters and data. The values in the **i3c_config.hcs** file are read by the 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 **I3cCntlr** object at the core layer. + + ```c + struct VirtualI3cCntlr { + struct AdcDevice device;// (Mandatory) Control object at the core layer. For details, see the following description of **I3cCntlr**. + volatile unsigned char *regBase;// (Mandatory) Register base address. + uint32_t regBasePhy; // (Mandatory) Physical base address of the register. + uint32_t regSize; // (Mandatory) Bit width of the register. + uint16_t busId; // (Mandatory) Device number. + uint16_t busMode; + uint16_t IrqNum; + uint32_t i3cMaxRate; + uint32_t i3cRate; + uint32_t i2cFmRate; + uint32_t i2cFmPlusRate; + }; + + /* I3cCntlr is the controller structure at the core layer. Its members are assigned with values by using the Init function. + struct I3cCntlr { + OsalSpinlock lock; + void *owner; + int16_t busId; + struct I3cConfig config; + uint16_t addrSlot[(I3C_ADDR_MAX + 1) / ADDRS_PER_UINT16]; + struct I3cIbiInfo *ibiSlot[I3C_IBI_MAX]; + const struct I3cMethod *ops; + const struct I3cLockMethod *lockOps; + void *priv; + }; + ``` + + > **(Important)** The following shows instantiation of the **I3cCntlr** member callback structure **I3cMethod**. This example does not provide the instantiation of the **I3cLockMethod** callback structure. For details, see the I2C driver development. Other members are initialized in the **Init** function. + + + - **Init function** + + > **Input parameter**: + > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + > + > **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**.) + + |State (Value)|Description| + |:-|:-:| + |HDF_ERR_INVALID_OBJECT|Invalid controller object.| + |HDF_ERR_INVALID_PARAM |Invalid parameter.| + |HDF_ERR_MALLOC_FAIL |Failed to allocate memory.| + |HDF_ERR_IO |I/O error.| + |HDF_SUCCESS |Transmission successful.| + |HDF_FAILURE |Transmission failed.| + + > **Function description:** + > Initializes the custom structure object and **I3cCntlr**, and calls the **I3cCntlrAdd** function to add the i3C controller to the core layer. + + ```c + static int32_t VirtualI3cParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node) + { + int32_t ret; + struct VirtualI3cCntlr *virtual = NULL; // (Mandatory) Custom structure object. + (void)device; + + virtual = (struct VirtualI3cCntlr *)OsalMemCalloc(sizeof(*virtual)); // (Mandatory) Allocate memory. + if (virtual == NULL) { + HDF_LOGE("%s: Malloc virtual fail!", __func__); + return HDF_ERR_MALLOC_FAIL; + } + + ret = VirtualI3cReadDrs(virtual, node); // (Mandatory) Fill the default values defined in the i3c_config file to the structure. + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: Read drs fail! ret:%d", __func__, ret); + goto __ERR__; + } + ... + virtual->regBase = OsalIoRemap(virtual->regBasePhy, virtual->regSize);// (Mandatory) Address mapping. + ret = OsalRegisterIrq(hi35xx->softIrqNum, OSAL_IRQF_TRIGGER_NONE, I3cIbiHandle, "I3C", virtual); // (Mandatory) Register the interrupt handler. + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: register irq failed!", __func__); + return ret; + } + ... + VirtualI3cCntlrInit(virtual); // (Mandatory) Initialize the I3C device. + virtual->cntlr.priv = (void *)node; // (Mandatory) Set the storage device attributes. + virtual->cntlr.busId = virtual->busId; // (Mandatory) Initialize I3cCntlr. + virtual->cntlr.ops = &g_method; // (Mandatory) Connect to the I3cMethod instance. + (void)OsalSpinInit(&virtual->spin); + ret = I3cCntlrAdd(&virtual->cntlr); // (Mandatory) Call this function to add the controller to the core layer. If a success signal is returned, the driver is completely connected to the core layer of the platform. + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: add i3c controller failed! ret = %d", __func__, ret); + (void)OsalSpinDestroy(&virtual->spin); + goto __ERR__; + } + + return HDF_SUCCESS; + __ERR__: // If the controller fails to be added, deinitialize related functions. + if (virtual != NULL) { + OsalMemFree(virtual); + virtual = NULL; + } + + return ret; + } + + static int32_t VirtualI3cInit(struct HdfDeviceObject *device) + { + int32_t ret; + const struct DeviceResourceNode *childNode = NULL; + + if (device == NULL || device->property == NULL) { + HDF_LOGE("%s: device or property is NULL", __func__); + return HDF_ERR_INVALID_OBJECT; + } + + DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { + ret = VirtualI3cParseAndInit(device, childNode); + if (ret != HDF_SUCCESS) { + break; + } + } + + return ret; + } + ``` + + - **Release function** + + > **Input parameter**: + > **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + > + > **Return value** + > None. + > + > **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 forcible conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. + + ```c + static void VirtualI3cRemoveByNode(const struct DeviceResourceNode *node) + { + int32_t ret; + int16_t busId; + struct I3cCntlr *cntlr = NULL; + struct VirtualI3cCntlr *virtual = NULL; + struct DeviceResourceIface *drsOps = NULL; + + drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); + if (drsOps == NULL || drsOps->GetUint32 == NULL) { + HDF_LOGE("%s: invalid drs ops fail!", __func__); + return; + } + + ret = drsOps->GetUint16(node, "busId", (uint16_t *)&busId, 0); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: read busId fail!", __func__); + return; + } + ... + /* Call the I3cCntlrGet function to obtain the I3cCntlr object through the cntlrNum of the device, and call the I3cCntlrRemove function to release the I3cCntlr object. */ + cntlr = I3cCntlrGet(busId); + if (cntlr != NULL && cntlr->priv == node) { + I3cCntlrPut(cntlr); + I3cCntlrRemove(cntlr); // (Mandatory) Remove the I3cCntlr object from the manager driver. + virtual = (struct VirtualI3cCntlr *)cntlr; // (Mandatory) Obtain the custom object through a forcible conversion and perform the release operation. + (void)OsalSpinDestroy(&virtual->spin); + OsalMemFree(virtual); + } + return; + } + + static void VirtualI3cRelease(struct HdfDeviceObject *device) + { + const struct DeviceResourceNode *childNode = NULL; + + HDF_LOGI("%s: enter", __func__); + + if (device == NULL || device->property == NULL) { + HDF_LOGE("%s: device or property is NULL", __func__); + return; + } + ... + // Traverse and parse all nodes in i3c_config.hcs and perform the release operation on each node. + DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { + VirtualI3cRemoveByNode(childNode); // See the description of VirtualI3cRemoveByNode for more details. + } + } + ``` + +4. Implement the interrupt handler. The interrupt handler helps implement operations such as hot-join and IBI based on the address of the interrupt generated. + + ```c + static int32_t VirtualI3cReservedAddrWorker(struct VirtualI3cCntlr *virtual, uint16_t addr) + { + (void)virtual; + switch (addr) { + case I3C_HOT_JOIN_ADDR: + VirtualI3cHotJoin(virtual); + break; + case I3C_RESERVED_ADDR_7H3E: + case I3C_RESERVED_ADDR_7H5E: + case I3C_RESERVED_ADDR_7H6E: + case I3C_RESERVED_ADDR_7H76: + case I3C_RESERVED_ADDR_7H7A: + case I3C_RESERVED_ADDR_7H7C: + case I3C_RESERVED_ADDR_7H7F: + /* All single-bit errors in the broadcast address */ + HDF_LOGW("%s: broadcast Address single bit error!", __func__); + break; + default: + HDF_LOGD("%s: Reserved address which is not supported!", __func__); + break; + } + + return HDF_SUCCESS; + } + ``` + + ```c + static int32_t I3cIbiHandle(uint32_t irq, void *data) + { + struct VirtualI3cCntlr *virtual = NULL; + struct I3cDevice *device = NULL; + uint16_t ibiAddr; + char *testStr = "Hello I3C!"; + + (void)irq; + if (data == NULL) { + HDF_LOGW("%s: data is NULL!", __func__); + return HDF_ERR_INVALID_PARAM; + } + virtual = (struct VirtualI3cCntlr *)data; + /* (Mandatory) Obtain the address where the interrupt is generated. Use the CHECK_RESERVED_ADDR macro to determine whether the address is the reserved address of the I3C. */ + ibiAddr = VirtualI3cGetIbiAddr(); + if (CHECK_RESERVED_ADDR(ibiAddr) == I3C_ADDR_RESERVED) { + HDF_LOGD("%s: Calling VirtualI3cResAddrWorker...", __func__); + return VirtualI3cReservedAddrWorker(virtual, ibiAddr); + } else { + HDF_LOGD("%s: Calling I3cCntlrIbiCallback...", __func__); + device = GetDeviceByAddr(&virtual->cntlr, ibiAddr); + if (device == NULL) { + HDF_LOGE("func:%s device is NULL!",__func__); + return HDF_ERR_MALLOC_FAIL; + } + if (device->ibi->payload > VIRTUAL_I3C_TEST_STR_LEN) { + /* Place the string "Hello I3C!" into the IBI buffer. */ + *device->ibi->data = *testStr; + } + /* Invoke the IBI callback based on the I3C device that generates the IBI. */ + return I3cCntlrIbiCallback(device); + } + + return HDF_SUCCESS; + } + ``` diff --git a/en/device-dev/driver/driver-platform-mipidsi-des.md b/en/device-dev/driver/driver-platform-mipidsi-des.md index 0bb5db5da12730afc9e4653ba00b64895dd4ec69..c7cecdc8e1c4a9d2d661ea1d3a9f072cae36ff66 100644 --- a/en/device-dev/driver/driver-platform-mipidsi-des.md +++ b/en/device-dev/driver/driver-platform-mipidsi-des.md @@ -1,16 +1,5 @@ # MIPI DSI -- [Overview](#section16806142183217) -- [Available APIs](#section12720125432316) -- [Usage Guidelines](#section037231715335) - - [How to Use](#section49299119344) - - [Obtaining a MIPI DSI Device Handle](#section5126155683811) - - [Setting MIPI DSI Configuration Parameters](#section201164274344) - - [Sending/Receiving the Pointer to a Command](#section199401342173415) - - [Releasing the MIPI DSI Device Handle](#section161011610357) - -- [Usage Example](#section17470126123520) - ## Overview - 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. diff --git a/en/device-dev/driver/driver-platform-mipidsi-develop.md b/en/device-dev/driver/driver-platform-mipidsi-develop.md index 38461bae03cc51ab53fdef786f03d63879c179dd..26ad1a56240f4a48ffb23283112b3676714d6d7a 100644 --- a/en/device-dev/driver/driver-platform-mipidsi-develop.md +++ b/en/device-dev/driver/driver-platform-mipidsi-develop.md @@ -1,10 +1,5 @@ # MIPI DSI -- [Overview](#section1266787503161538) -- [How to Develop](#section545182932161538) - - [MipiDsiCntlrMethod](#section10711202141617) - -- [Development Example](#section1167576616161538) ## Overview @@ -13,31 +8,9 @@ The Display Serial Interface \(DSI\) is a specification developed by the Mobile **Figure 1** Service-free mode ![](figures/service-free-mode.png "service-free-mode") -## How to Develop - -The MIPI DSI module adaptation involves the following steps: +## Available APIs -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **mipidsi\_config.hcs** file. - -3. Instantiate the MIPI DSI controller object. - - Initialize **MipiDsiCntlr**. - - Instantiate **MipiDsiCntlrMethod** in the **MipiDsiCntlr** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [MipiDsiCntlrMethod](#section10711202141617) and [Table 1](#table218771071713). - - -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. - - -### MipiDsiCntlrMethod +MipiDsiCntlrMethod ``` struct MipiDsiCntlrMethod {// Member functions of the core layer structure @@ -127,6 +100,31 @@ struct MipiDsiCntlrMethod {// Member functions of the core layer structure +## How to Develop + +The MIPI DSI module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **mipidsi\_config.hcs** file. + +3. Instantiate the MIPI DSI controller object. + - Initialize **MipiDsiCntlr**. + - Instantiate **MipiDsiCntlrMethod** in the **MipiDsiCntlr** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [MipiDsiCntlrMethod](#section10711202141617) and [Table 1](#table218771071713). + + +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 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. diff --git a/en/device-dev/driver/driver-platform-mmc-develop.md b/en/device-dev/driver/driver-platform-mmc-develop.md index d6a0e3f9b8953266ba611fcb3b386bfd95029997..26b6ecf7acb4ab5e9f60d9fb0d0062fa2a35ead4 100644 --- a/en/device-dev/driver/driver-platform-mmc-develop.md +++ b/en/device-dev/driver/driver-platform-mmc-develop.md @@ -1,11 +1,5 @@ # MMC -- [Overview](#section1846388309162704) -- [How to Develop](#section1617495117162704) - - [MmcCntlrOps](#section6203107192915) - -- [Development Example](#section1220893490162704) - ## Overview 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. @@ -13,31 +7,9 @@ In the Hardware Driver Foundation \(HDF\) framework, the MultiMedia Card \(MMC\) **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode") -## How to Develop - -The MMC module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **mmc\_config.hcs** file. - -3. Instantiate the MMC controller object. - - Initialize **MmcCntlr**. - - Instantiate **MmcCntlrOps** in the **MmcCntlr** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [MmcCntlrOps](#section6203107192915) and [Table 1](#table99129433019). - - -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. - +## Available APIs -### MmcCntlrOps +MmcCntlrOps ``` struct MmcCntlrOps { @@ -219,6 +191,30 @@ struct MmcCntlrOps { +## How to Develop + +The MMC module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **mmc\_config.hcs** file. + +3. Instantiate the MMC controller object. + - Initialize **MmcCntlr**. + - Instantiate **MmcCntlrOps** in the **MmcCntlr** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [MmcCntlrOps](#section6203107192915) and [Table 1](#table99129433019). + + +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 The following uses **himci.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform-pwm-des.md b/en/device-dev/driver/driver-platform-pwm-des.md index 6c1e273c10eed66c2eedff8800dc89722e28b641..ca50d1809e7989eccb7ffe85c173c899ab08de59 100644 --- a/en/device-dev/driver/driver-platform-pwm-des.md +++ b/en/device-dev/driver/driver-platform-pwm-des.md @@ -1,22 +1,5 @@ # PWM -- [Overview](#section1_PWM_des) - - [PwmConfig Structure](#section1.1_PWM_des) -- [Available APIs](#section2_PWM_des) -- [Usage Guidelines](#section3_PWM_des) - - [How to Use](#section3.1_PWM_des) - - [Opening a PWM Device Handle](#section3.2_PWM_des) - - [Closing a PWM Device Handle](#section3.3_PWM_des) - - [Enabling a PWM Device](#section3.4_PWM_des) - - [Disabling a PWM Device](#section3.5_PWM_des) - - [Setting the PWM Period](#section3.6_PWM_des) - - [Setting the PWM Signal ON-State Time](#section3.7_PWM_des) - - [Setting the PWM Polarity](#section3.8_PWM_des) - - [Setting PWM Device Parameters](#section3.9_PWM_des) - - [Obtaining PWM Device Parameters](#section3.10_PWM_des) - -- [Usage Example](#section3_PWM_des) - ## Overview Pulse width modulation (PWM) is a method used to digitally encode analog signal levels and convert them into pulses. It can be used for motor control and backlight brightness adjustment. diff --git a/en/device-dev/driver/driver-platform-pwm-develop.md b/en/device-dev/driver/driver-platform-pwm-develop.md index 3dee4faaf4d9ae03db430da4a6d8ac682bef7a45..0af82ba636f135d6af1ffc027812cc18a1833179 100644 --- a/en/device-dev/driver/driver-platform-pwm-develop.md +++ b/en/device-dev/driver/driver-platform-pwm-develop.md @@ -1,11 +1,5 @@ # PWM -- [Overview](#section1591602238164144) -- [How to Develop](#section967396342164144) - - [PwmMethod](#section14560119104318) - -- [Development Example](#section1883877829164144) - ## Overview In the Hardware Driver Foundation \(HDF\) framework, the Pulse Width Modulator \(PWM\) 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 HDF Device Manager can be directly used. However, you need to configure a device node for each device, which increases the memory usage. @@ -13,31 +7,9 @@ In the Hardware Driver Foundation \(HDF\) framework, the Pulse Width Modulator \ **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode-10") -## How to Develop - -The PWM module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **pwm\_config.hcs** file. - -3. Instantiate the PWM controller object. - - Initialize **PwmDev**. - - Instantiate **PwmMethod** in the **PwmDev** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [PwmMethod](#section14560119104318) and [Table 1](#table11173154124311). - - -4. Debug the driver. - - \(Optional\) For new drivers, verify the basic functions, such as the PWM control status and response to interrupts. - +## Available APIs -### PwmMethod +PwmMethod ``` struct PwmMethod { @@ -91,6 +63,30 @@ struct PwmMethod { +## How to Develop + +The PWM module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **pwm\_config.hcs** file. + +3. Instantiate the PWM controller object. + - Initialize **PwmDev**. + - Instantiate **PwmMethod** in the **PwmDev** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [PwmMethod](#section14560119104318) and [Table 1](#table11173154124311). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify the basic functions, such as the PWM control status and response to interrupts. + + ## Development Example The following uses **pwm\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform-rtc-des.md b/en/device-dev/driver/driver-platform-rtc-des.md index 161603462933e996a22bfd39039f93a0c7fb89c9..b124a0cd79fd3214479a155e54a3352e970e3315 100644 --- a/en/device-dev/driver/driver-platform-rtc-des.md +++ b/en/device-dev/driver/driver-platform-rtc-des.md @@ -1,16 +1,5 @@ # RTC -- [Overview](#section104842041574) -- [Available APIs](#section20331159102519) -- [Usage Guidelines](#section20636145604113) - - [How to Use](#section16919828134215) - - [Creating an RTC Device Handle](#section1131212144310) - - [Releasing the RTC Device Handle](#section10744117144314) - - [Registering RtcAlarmCallback](#section14839440184320) - - [Performing RTC-related Operations](#section161927578433) - -- [Usage Example](#section1186111020456) - ## Overview The real-time clock \(RTC\) driver provides precise real time for the operating system \(OS\). If the OS is powered off, the RTC driver continues to keep track of the system time using an external battery. diff --git a/en/device-dev/driver/driver-platform-rtc-develop.md b/en/device-dev/driver/driver-platform-rtc-develop.md index 7ad6888da8b4ce2724a8395f9d62fa717b33d5a3..19a635fa1477fda48f7248cb8efa3e075b1d0a38 100644 --- a/en/device-dev/driver/driver-platform-rtc-develop.md +++ b/en/device-dev/driver/driver-platform-rtc-develop.md @@ -13,31 +13,9 @@ In the Hardware Driver Foundation \(HDF\) framework, the real-time clock \(RTC\) **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode-11") -## How to Develop - -The RTC module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **rtc\_config.hcs** file. - -3. Instantiate the RTC controller object. - - Initialize **RtcHost**. - - Instantiate **RtcMethod** in the **RtcHost** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [RtcMethod](#section13652132473017) and [Table 1](#table12929217311). +## Available APIs - -4. Debug the driver. - - \(Optional\) For new drivers, verify the basic functions, such as the RTC control status and response to interrupts. - - -### RtcMethod +RtcMethod ``` struct RtcMethod { @@ -206,6 +184,30 @@ struct RtcMethod { +## How to Develop + +The RTC module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **rtc\_config.hcs** file. + +3. Instantiate the RTC controller object. + - Initialize **RtcHost**. + - Instantiate **RtcMethod** in the **RtcHost** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [RtcMethod](#section13652132473017) and [Table 1](#table12929217311). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify the basic functions, such as the RTC control status and response to interrupts. + + ## Development Example The following uses **rtc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform-sdio-des.md b/en/device-dev/driver/driver-platform-sdio-des.md index e781662256ccee630e3ca9ecf185135c53148ae3..98c11950f2f8e4cd3ccb8e328543e4531d365401 100644 --- a/en/device-dev/driver/driver-platform-sdio-des.md +++ b/en/device-dev/driver/driver-platform-sdio-des.md @@ -1,21 +1,5 @@ # SDIO -- [Overview](#section1155271783811) -- [Available APIs](#section12601496259) -- [Usage Guidelines](#section1878939192515) - - [How to Use](#section1490685512255) - - [Opening an SDIO Controller](#section10782428132616) - - [Claiming a Host Exclusively](#section11263172312715) - - [Enabling the SDIO Device](#section17861486271) - - [Claiming an SDIO IRQ](#section521213262286) - - [Performing SDIO Communication](#section85661522153420) - - [Releasing the SDIO IRQ](#section1683449352) - - [Disabling the SDIO Device](#section15379324143611) - - [Releasing the Exclusively Claimed Host](#section536018263713) - - [Closing an SDIO Controller](#section4752739183716) - -- [Usage Example](#section376910122382) - ## Overview - Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface. diff --git a/en/device-dev/driver/driver-platform-sdio-develop.md b/en/device-dev/driver/driver-platform-sdio-develop.md index f954769c943e33c72d2286c98893a04cbd4890c5..cdc43461d11497a8c8c02d9cbeb78879ac769fbe 100644 --- a/en/device-dev/driver/driver-platform-sdio-develop.md +++ b/en/device-dev/driver/driver-platform-sdio-develop.md @@ -1,10 +1,5 @@ # SDIO -- [Overview](#section1347805272150053) -- [How to Develop](#section581179475150053) - - [SdioDeviceOps](#section482911395315) - -- [Development Example](#section2112250242150053) ## Overview @@ -13,31 +8,9 @@ A Secure Digital Input Output \(SDIO\) card is an extension of the SD specificat **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode-12") -## How to Develop - -The SDIO module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **sdio\_config.hcs** file. - -3. Instantiate the SDIO controller object. - - Initialize **SdioDevice**. - - Instantiate **SdioDeviceOps** in the **SdioDevice** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [SdioDeviceOps](#section482911395315) and [Table 1](#table878215448417). - - -4. Debug the driver. - - \(Optional\) For new drivers, verify the basic functions, such as the SDIO control status and response to interrupts. - +## Available APIs -### SdioDeviceOps +SdioDeviceOps ``` // Function template @@ -300,6 +273,30 @@ struct SdioDeviceOps { >- **irqCap**: specifies the interrupt request \(IRQ\) capabilities. >- **\(void \*\)data** +## How to Develop + +The SDIO module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **sdio\_config.hcs** file. + +3. Instantiate the SDIO controller object. + - Initialize **SdioDevice**. + - Instantiate **SdioDeviceOps** in the **SdioDevice** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [SdioDeviceOps](#section482911395315) and [Table 1](#table878215448417). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify the basic functions, such as the SDIO control status and response to interrupts. + + ## Development Example The following uses **sdio\_adapter.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform-spi-des.md b/en/device-dev/driver/driver-platform-spi-des.md index a11b55062427658966c10c6ae206d26f3ef4da69..4388fdd99bec26e45ce91d29016fc5a2fba21f31 100644 --- a/en/device-dev/driver/driver-platform-spi-des.md +++ b/en/device-dev/driver/driver-platform-spi-des.md @@ -1,17 +1,5 @@ # SPI -- [Overview](#section193356154511) -- [Available APIs](#section1325964832615) -- [Usage Guidelines](#section71363452477) - - [How to Use](#section32846814820) - - [Obtaining an SPI Device Handle](#section1927265711481) - - [Obtaining SPI Device Configuration Parameters](#section541133418493) - - [Setting SPI Device Configuration Parameters](#section7870106145010) - - [Performing SPI Communication](#section13324155195013) - - [Destroying the SPI Device Handle](#section19661632135117) - -- [Usage Example](#section06541058155120) - ## Overview - Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication. diff --git a/en/device-dev/driver/driver-platform-spi-develop.md b/en/device-dev/driver/driver-platform-spi-develop.md index b09cf5f47158fcd3855da7a92993914030256049..687a93aa9072a6cf7ea9020f4935269484b10543 100644 --- a/en/device-dev/driver/driver-platform-spi-develop.md +++ b/en/device-dev/driver/driver-platform-spi-develop.md @@ -1,10 +1,5 @@ # SPI -- [Overview](#section84922229152909) -- [Available APIs](#section752964871810) -- [How to Develop](#section799667984152909) -- [Development Example](#section956157227152909) - ## Overview diff --git a/en/device-dev/driver/driver-platform-uart-des.md b/en/device-dev/driver/driver-platform-uart-des.md index f6d43fd109b0b41de72fa00e09de73b4298fc972..0d8809f05bc3bd9a100142b07d46a8e014259915 100644 --- a/en/device-dev/driver/driver-platform-uart-des.md +++ b/en/device-dev/driver/driver-platform-uart-des.md @@ -1,21 +1,5 @@ # UART -- [Overview](#section833012453535) -- [Available APIs](#section1928742202715) -- [Usage Guidelines](#section12779050105412) - - [How to Use](#section1858116395510) - - [Obtaining a UART Device Handle](#section124512065617) - - [Setting the UART Baud Rate](#section86881004579) - - [Obtaining the UART Baud Rate](#section897032965712) - - [Setting the UART Device Attributes](#section129141884588) - - [Obtaining UART Device Attributes](#section18689637165812) - - [Setting the UART Transmission Mode](#section72713435918) - - [Writing Data of a Specified Length into a UART Device](#section128001736155919) - - [Reading Data of a Specified Length from a UART Device](#section92851601604) - - [Destroying the UART Device Handle](#section1477410521406) - -- [Usage Example](#section35404241311) - ## Overview - The Universal Asynchronous Receiver/Transmitter \(UART\) is a universal serial data bus used for asynchronous communication. It enables bi-directional communication between devices in full-duplex mode. diff --git a/en/device-dev/driver/driver-platform-uart-develop.md b/en/device-dev/driver/driver-platform-uart-develop.md index 3964b5ad1b43c7bba48491ea8b4f40eafafd80ff..fc92e1a98c6eb0195ed2e44cd785e9ba5364e085 100644 --- a/en/device-dev/driver/driver-platform-uart-develop.md +++ b/en/device-dev/driver/driver-platform-uart-develop.md @@ -13,31 +13,9 @@ In the Hardware Driver Foundation \(HDF\) framework, the Universal Asynchronous **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode-14") -## How to Develop - -The UART module adaptation involves the following steps: - -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **uart\_config.hcs** file. - -3. Instantiate the UART controller object. - - Initialize **UartHost**. - - Instantiate **UartHostMethod** in the **UartHost** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [UartHostMethod](#section192316441461) and [Table 1](#table22862114719). +## Available APIs - -4. Debug the driver. - - \(Optional\) For new drivers, verify the basic functions, such as the UART control status and response to interrupts. - - -### UartHostMethod +UartHostMethod ``` struct UartHostMethod { @@ -190,6 +168,30 @@ struct UartHostMethod { +## How to Develop + +The UART module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **uart\_config.hcs** file. + +3. Instantiate the UART controller object. + - Initialize **UartHost**. + - Instantiate **UartHostMethod** in the **UartHost** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [UartHostMethod](#section192316441461) and [Table 1](#table22862114719). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify the basic functions, such as the UART control status and response to interrupts. + + ## Development Example The following uses **uart\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform-watchdog-des.md b/en/device-dev/driver/driver-platform-watchdog-des.md index ba879b0aea477c8babc0f125c51e9ee5bc0d6ac2..e571e6fc34ab8a343e750310a84ac656025b9243 100644 --- a/en/device-dev/driver/driver-platform-watchdog-des.md +++ b/en/device-dev/driver/driver-platform-watchdog-des.md @@ -1,20 +1,5 @@ # Watchdog -- [Overview](#section14918241977) -- [Available APIs](#section1180575010271) -- [Usage Guidelines](#section10103184312813) - - [How to Use](#section10181195910815) - - [Opening a Watchdog](#section66089201107) - - [Obtaining the Watchdog Status](#section786624341011) - - [Setting the Timeout Duration](#section182386137111) - - [Obtaining the Timeout Duration](#section1883310371114) - - [Starting a Watchdog](#section82501405123) - - [Feeding a Watchdog](#section3547530101211) - - [Stopping a Watchdog](#section944595841217) - - [Closing a Watchdog](#section96561824121311) - -- [Usage Example](#section1724514523135) - ## Overview A watchdog, also called a watchdog timer, is a hardware timing device. If an error occurs in the main program of the system and fails to reset the watchdog timer, the watchdog timer sends a reset signal to restore the system to a normal state. diff --git a/en/device-dev/driver/driver-platform-watchdog-develop.md b/en/device-dev/driver/driver-platform-watchdog-develop.md index 2c01a9b2dc518efe665f7386f502b888a01af299..6d1bb7bebdee38a4d394879bd35c30a121302fce 100644 --- a/en/device-dev/driver/driver-platform-watchdog-develop.md +++ b/en/device-dev/driver/driver-platform-watchdog-develop.md @@ -1,10 +1,5 @@ # Watchdog -- [Overview](#section1315827527160117) -- [How to Develop](#section477974542160117) - - [WatchdogMethod](#section220331929) - -- [Development Example](#section1832270347160117) ## Overview @@ -13,31 +8,9 @@ In the Hardware Driver Foundation \(HDF\) framework, the Watchdog \(also called **Figure 1** Independent service mode ![](figures/independent-service-mode.png "independent-service-mode-15") -## How to Develop - -The Watchdog module adaptation involves the following steps: +## Available APIs -1. Instantiate the driver entry. - - Instantiate the **HdfDriverEntry** structure. - - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **watchdog\_config.hcs** file. - -3. Instantiate the Watchdog controller object. - - Initialize **WatchdogCntlr**. - - Instantiate **WatchdogMethod** in the **WatchdogCntlr** object. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >For details, see [WatchdogMethod](#section220331929) and [Table 1](#table1370451732). - - -4. Debug the driver. - - \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the watchdog timer is successfully set. - - -### WatchdogMethod +WatchdogMethod ``` struct WatchdogMethod { @@ -137,6 +110,31 @@ struct WatchdogMethod { + +## How to Develop + +The Watchdog module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **watchdog\_config.hcs** file. + +3. Instantiate the Watchdog controller object. + - Initialize **WatchdogCntlr**. + - Instantiate **WatchdogMethod** in the **WatchdogCntlr** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [WatchdogMethod](#section220331929) and [Table 1](#table1370451732). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the watchdog timer is successfully set. + + ## Development Example The following uses **watchdog\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. diff --git a/en/device-dev/driver/driver-platform.md b/en/device-dev/driver/driver-platform.md index c84f14e45a7fe6b519b87b55e8e025f58932b030..6001bec2a5a8ba9ece5ec83141b85987e9ccd543 100644 --- a/en/device-dev/driver/driver-platform.md +++ b/en/device-dev/driver/driver-platform.md @@ -1,9 +1,21 @@ -# Platform Driver Usage +# Driver Platform Usage + +- **[ADC](driver-platform-adc-des.md)** - **[GPIO](driver-platform-gpio-des.md)** +- **[HDMI](driver-platform-hdmi-des.md)** + - **[I2C](driver-platform-i2c-des.md)** +- **[I3C](driver-platform-i3c-des.md)** + +- **[MIPI CSI](driver-platform-mipicsi-des.md)** + +- **[MIPI DSI](driver-platform-mipidsi-des.md)** + +- **[PWM](driver-platform-pwm-des.md)** + - **[RTC](driver-platform-rtc-des.md)** - **[SDIO](driver-platform-sdio-des.md)** @@ -13,9 +25,3 @@ - **[UART](driver-platform-uart-des.md)** - **[Watchdog](driver-platform-watchdog-des.md)** - -- **[MIPI DSI](driver-platform-mipidsi-des.md)** - -- **[PWM](driver-platform-pwm-des.md)** - - diff --git a/en/device-dev/driver/figures/ADC_flowchart.png b/en/device-dev/driver/figures/ADC_flowchart.png new file mode 100644 index 0000000000000000000000000000000000000000..cc8e6494c3ddcf5def7962020210e127f68aec5d Binary files /dev/null and b/en/device-dev/driver/figures/ADC_flowchart.png differ diff --git a/en/device-dev/driver/figures/ADC_physical_connection.png b/en/device-dev/driver/figures/ADC_physical_connection.png new file mode 100644 index 0000000000000000000000000000000000000000..da94f3b486edb6b269ef341b12b1816f23036c32 Binary files /dev/null and b/en/device-dev/driver/figures/ADC_physical_connection.png differ diff --git a/en/device-dev/driver/figures/HDMI_physical_connection.png b/en/device-dev/driver/figures/HDMI_physical_connection.png new file mode 100644 index 0000000000000000000000000000000000000000..9c1618562e33dd6fd08d2ec7f48454a43c1e1541 Binary files /dev/null and b/en/device-dev/driver/figures/HDMI_physical_connection.png differ diff --git a/en/device-dev/driver/figures/HDMI_usage_flowchart.png b/en/device-dev/driver/figures/HDMI_usage_flowchart.png new file mode 100644 index 0000000000000000000000000000000000000000..b5832da900957cef38bf2c8785cc721f6671c7d6 Binary files /dev/null and b/en/device-dev/driver/figures/HDMI_usage_flowchart.png differ diff --git a/en/device-dev/driver/figures/I3C_physical_connection.png b/en/device-dev/driver/figures/I3C_physical_connection.png new file mode 100644 index 0000000000000000000000000000000000000000..e83d1b2f65c29c86596d7113e7653fc6377123e5 Binary files /dev/null and b/en/device-dev/driver/figures/I3C_physical_connection.png differ diff --git a/en/device-dev/driver/figures/I3C_usage_flowchart.png b/en/device-dev/driver/figures/I3C_usage_flowchart.png new file mode 100644 index 0000000000000000000000000000000000000000..394b5c321bf5ce09cc2ffbfd3fc69fc8875f1b1e Binary files /dev/null and b/en/device-dev/driver/figures/I3C_usage_flowchart.png differ