1e41f4b71Sopenharmony_ci# MIPI CSI 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciDefined by the Mobile Industry Processor Interface (MIPI) Alliance, the Camera Serial Interface (CSI) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. As the second release, the MIPI CSI-2 consists of the application layer, protocol layer, and physical layer. It supports a maximum of four-lane data transmission and a single-lane transmission rate of 1 Gbit/s. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ciThe physical layer supports the high speed (HS) and low speed (LS) modes. Using low-voltage differential signaling (LVDS), the HS mode delivers 80 Mbit/s to 1 Gbit/s transmission speed but high power consumption. The unidirectional LS mode provides lower power consumption but lower transmission speed (< 10 Mbit/s). The blend of the two modes ensures high-speed transmission of massive data (such as images) and minimized power consumption when less data is transmitted. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ciThe figure below shows a simplified CSI. The D-PHY transmits data by using one pair of source-synchronized differential clocks and one to four pairs of differential data lanes. Data is transmitted in Double Data Rate (DDR) mode, that is, data is transmitted on both the rising and falling edges of the clock. 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci **Figure 1** CSI TX and RX interfaces 13e41f4b71Sopenharmony_ci  14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci### ComboDevAttr Structure 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Table 1** ComboDevAttr structure 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci<a name="table1_MIPI_CSIDes"></a> 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci| Name | Description | 22e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------------- | 23e41f4b71Sopenharmony_ci| devno | Device number. | 24e41f4b71Sopenharmony_ci| inputMode | Input mode, which can be MIPI, LVDS, sub-LVDS, HiSPI, or DC. | 25e41f4b71Sopenharmony_ci| dataRate | Input rate of the MIPI RX scalable low voltage signaling (SLVS). | 26e41f4b71Sopenharmony_ci| imgRect | Crop area of the MIPI RX device (same as the size of the input image of the sensor).| 27e41f4b71Sopenharmony_ci| MIPIAttr | Attributes of the MIPI device. | 28e41f4b71Sopenharmony_ci| lvdsAttr | Attributes of the LVDS, sub-LVDS, or HiSPi device. | 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci### ExtDataType Structure 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci**Table 2** ExtDataType structure 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci<a name="table2_MIPI_CSIDes"></a> 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci| Name | Description | 37e41f4b71Sopenharmony_ci| --------------- | ------------------------------- | 38e41f4b71Sopenharmony_ci| devno | Device number. | 39e41f4b71Sopenharmony_ci| num | Sensor number. | 40e41f4b71Sopenharmony_ci| extDataBitWidth | Bit depth of an image. | 41e41f4b71Sopenharmony_ci| extDataType | Pointer to the YUV, raw data format, and bit depth.| 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci### Available APIs 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci**Table 3** MIPI CSI APIs 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci<a name="table3_MIPI_CSIDes"></a> 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci| Category| API| 50e41f4b71Sopenharmony_ci| -------- | -------- | 51e41f4b71Sopenharmony_ci| Opening or closing the MIPI CSI controller operation handle| **MipiCsiOpen**: opens the MIPI CSI controller operation handle.<br>**MipiCsiClose**: closes the MIPI CSI controller operation handle.| 52e41f4b71Sopenharmony_ci| Setting MIPI CSI attributes | **MipiCsiSetComboDevAttr**: sets attributes of the MIPI, CMOS, or LVDS camera to the controller. The attributes include the working mode, image area, image depth, data rate, and physical channel.<br>**MipiCsiSetExtDataType** (optional): sets the YUV and RAW data formats and bit depths.<br>**MipiCsiSetHsMode**: sets the MIPI RX lane distribution. Set the mode based on the hardware connection.<br>**MipiCsiSetPhyCmvmode**: sets the common-mode voltage (CMV) mode. | 53e41f4b71Sopenharmony_ci| Resetting a sensor or deasserting the reset of a sensor| **MipiCsiResetSensor**: resets a sensor.<br>**MipiCsiUnresetSensor**: deasserts the reset of a sensor.| 54e41f4b71Sopenharmony_ci| Resetting the MIPI RX or deasserting the reset of the MIPI RX| **MipiCsiResetRx**: resets the MIPI&nbsp;RX. The value of **enSnsType** varies depending on the value of **s32WorkingViNum**.<br>**MipiCsiUnresetRx**: deasserts the reset on the MIPI&nbsp;RX.| 55e41f4b71Sopenharmony_ci| Enabling or disabling the MIPI clock| **MipiCsiEnableClock**: enables the MIPI clock. The **enSnsType** passed by the upper-layer function during electrophoresis determines whether MIPI or LVDS is used.<br>**MipiCsiDisableClock**: disables the MIPI clock.| 56e41f4b71Sopenharmony_ci| Enabling or disabling the MIPI sensor clock| **MipiCsiEnableSensorClock**: enables the MIPI sensor clock.<br>**MipiCsiDisableSensorClock**: disables the MIPI sensor clock.| 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci## Usage Guidelines 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci### How to Use 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciThe figure below illustrates the general development process. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**Figure 2** Using MIPI CSI driver APIs 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci### Opening a MIPI CSI Controller Operation Handle 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ciBefore starting MIPI CSI communication, call **MipiCsiOpen** to open the MIPI CSI device handle. This function returns the MIPI CSI device handle with the specified lane ID. 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci```c 75e41f4b71Sopenharmony_ciDevHandle MipiCsiOpen(uint8_t id); 76e41f4b71Sopenharmony_ci``` 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**Table 4** Description of MipiCsiOpen 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci<a name="table4_MIPI_CSIDes"></a> 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci| Parameter | Description | 83e41f4b71Sopenharmony_ci| ---------- | ----------------------------------------------- | 84e41f4b71Sopenharmony_ci| id | MIPI CSI lane ID. | 85e41f4b71Sopenharmony_ci| **Return Value**| **Description** | 86e41f4b71Sopenharmony_ci| NULL | The operation failed. | 87e41f4b71Sopenharmony_ci| Device handle | The operation is successful. The MIPI CSI device handle with the specified lane ID is returned. The data type is **DevHandle**. | 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciFor example, open the controller operation handle of MIPI CSI lane 0: 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci```c 92e41f4b71Sopenharmony_ciDevHandle mipiCsiHandle = NULL; /* Device handle */ 93e41f4b71Sopenharmony_ciid = 0; /* MIPI CSI lane ID */ 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci/* Open the controller operation handle. */ 96e41f4b71Sopenharmony_ciMipiCsiHandle = MipiCsiOpen(id); 97e41f4b71Sopenharmony_ciif (MipiCsiHandle == NULL) { 98e41f4b71Sopenharmony_ci HDF_LOGE("MipiCsiOpen: failed\n"); 99e41f4b71Sopenharmony_ci return; 100e41f4b71Sopenharmony_ci} 101e41f4b71Sopenharmony_ci``` 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci### Setting MIPI CSI Attributes 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci- Set MIPI CSI attributes. 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci ```c 108e41f4b71Sopenharmony_ci int32_t MipiCsiSetComboDevAttr(DevHandle handle, ComboDevAttr *pAttr); 109e41f4b71Sopenharmony_ci ``` 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci **Table 5** Description of MipiCsiSetComboDevAttr 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci <a name="table5_MIPI_CSIDes"></a> 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci | Parameter | Description | 116e41f4b71Sopenharmony_ci | ---------- | -------------------------- | 117e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 118e41f4b71Sopenharmony_ci | pAttr | Pointer to the MIPI CSI structure.| 119e41f4b71Sopenharmony_ci | **Return Value**| **Description** | 120e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 121e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci ```c 124e41f4b71Sopenharmony_ci int32_t ret; 125e41f4b71Sopenharmony_ci struct ComboDevAttr attr; 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci /* The current configuration is as follows: */ 128e41f4b71Sopenharmony_ci (void)memset_s(&attr, sizeof(ComboDevAttr), 0, sizeof(ComboDevAttr)); 129e41f4b71Sopenharmony_ci attr.devno = 0; /* Device 0 */ 130e41f4b71Sopenharmony_ci attr.inputMode = INPUT_MODE_MIPI; /* The input mode is MIPI. */ 131e41f4b71Sopenharmony_ci attr.dataRate = MIPI_DATA_RATE_X1; /* The data rate is 1 pixel per clock cycle. */ 132e41f4b71Sopenharmony_ci attr.imgRect.x = 0; /* The value 0 indicates the upper left position of the image sensor. */ 133e41f4b71Sopenharmony_ci attr.imgRect.y = 0; /* The value 0 indicates the upper right position of the image sensor. */ 134e41f4b71Sopenharmony_ci attr.imgRect.width = 2592; /* The width of the image sensor is 2592. */ 135e41f4b71Sopenharmony_ci attr.imgRect.height = 1944; /* The height of the image sensor is 1944. */ 136e41f4b71Sopenharmony_ci /* Write the MIPI CSI configuration. */ 137e41f4b71Sopenharmony_ci ret = MipiCsiSetComboDevAttr(MipiCsiHandle, &attr); 138e41f4b71Sopenharmony_ci if (ret != 0) { 139e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetComboDevAttr fail! ret=%d\n", __func__, ret); 140e41f4b71Sopenharmony_ci return -1; 141e41f4b71Sopenharmony_ci } 142e41f4b71Sopenharmony_ci ``` 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci- Set the YUV, RAW data format, and bit depth. 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci ```c 147e41f4b71Sopenharmony_ci int32_t MipiCsiSetExtDataType(DevHandle handle, ExtDataType* dataType); 148e41f4b71Sopenharmony_ci ``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci **Table 6** Description of MipiCsiSetExtDataType 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci <a name="table6_MIPI_CSIDes"></a> 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci | Parameter | Description | 155e41f4b71Sopenharmony_ci | ---------- | ------------------------------- | 156e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 157e41f4b71Sopenharmony_ci | dataType | Pointer to the YUV, raw data format, and bit depth.| 158e41f4b71Sopenharmony_ci | **Return Value**| **Description** | 159e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 160e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci ```c 163e41f4b71Sopenharmony_ci int32_t ret; 164e41f4b71Sopenharmony_ci struct ExtDataType dataType; 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci /* Set the YUV, raw data format, and bit depth. */ 167e41f4b71Sopenharmony_ci dataType.devno = 0; /* Device 0 */ 168e41f4b71Sopenharmony_ci dataType.num = 0; /* sensor 0 */ 169e41f4b71Sopenharmony_ci dataType.extDataBitWidth[0] = 12; /* Bit depth array element 0 */ 170e41f4b71Sopenharmony_ci dataType.extDataBitWidth[1] = 12; /* Bit depth array element 1 */ 171e41f4b71Sopenharmony_ci dataType.extDataBitWidth[2] = 12; /* Bit depth array element 2 */ 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci dataType.extDataType[0] = 0x39; /* Define YUV, raw data format, and bit depth element 0. */ 174e41f4b71Sopenharmony_ci dataType.extDataType[1] = 0x39; /* Define YUV, raw data format, and bit depth element 1. */ 175e41f4b71Sopenharmony_ci dataType.extDataType[2] = 0x39; /* Define YUV, raw data format, and bit depth element 2. */ 176e41f4b71Sopenharmony_ci /* Set the YUV, raw data format, and bit depth. */ 177e41f4b71Sopenharmony_ci ret = MipiCsiSetExtDataType(MipiCsiHandle, &dataType); 178e41f4b71Sopenharmony_ci if (ret != 0) { 179e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetExtDataType fail! ret=%d\n", __func__, ret); 180e41f4b71Sopenharmony_ci return -1; 181e41f4b71Sopenharmony_ci } 182e41f4b71Sopenharmony_ci ``` 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci- Set the MIPI RX lane distribution. 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci ```c 187e41f4b71Sopenharmony_ci int32_t MipiCsiSetHsMode(DevHandle handle, LaneDivideMode laneDivideMode); 188e41f4b71Sopenharmony_ci ``` 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci **Table 7** Description of MipiCsiSetHsMode 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci <a name="table7_MIPI_CSIDes"></a> 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci | Parameter | Description | 195e41f4b71Sopenharmony_ci | -------------- | -------------- | 196e41f4b71Sopenharmony_ci | handle | Controller operation handle.| 197e41f4b71Sopenharmony_ci | laneDivideMode | Lane mode. | 198e41f4b71Sopenharmony_ci | **Return Value** | **Description**| 199e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 200e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci ```c 203e41f4b71Sopenharmony_ci int32_t ret; 204e41f4b71Sopenharmony_ci enum LaneDivideMode mode; 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci /* Set the lane mode to 0. */ 207e41f4b71Sopenharmony_ci mode = LANE_DIVIDE_MODE_0; 208e41f4b71Sopenharmony_ci /* Set the MIPI RX lane distribution. */ 209e41f4b71Sopenharmony_ci ret = MipiCsiSetHsMode(MipiCsiHandle, mode); 210e41f4b71Sopenharmony_ci if (ret != 0) { 211e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetHsMode fail! ret=%d\n", __func__, ret); 212e41f4b71Sopenharmony_ci return -1; 213e41f4b71Sopenharmony_ci } 214e41f4b71Sopenharmony_ci ``` 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci- Set the CMV mode. 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci ```c 219e41f4b71Sopenharmony_ci int32_t MipiCsiSetPhyCmvmode(DevHandle handle, uint8_t devno, PhyCmvMode cmvMode); 220e41f4b71Sopenharmony_ci ``` 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci **Table 8** Description of MipiCsiSetPhyCmvmode 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci <a name="table8_MIPI_CSIDes"></a> 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci | Parameter | Description | 227e41f4b71Sopenharmony_ci | ---------- | ---------------- | 228e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 229e41f4b71Sopenharmony_ci | cmvMode | CMV mode.| 230e41f4b71Sopenharmony_ci | devno | Device number. | 231e41f4b71Sopenharmony_ci | **Return Value**| **Description** | 232e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 233e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci ```c 236e41f4b71Sopenharmony_ci int32_t ret; 237e41f4b71Sopenharmony_ci enum PhyCmvMode mode; 238e41f4b71Sopenharmony_ci uint8_t devno; 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci /* Set the CMV mode to 0. */ 241e41f4b71Sopenharmony_ci mode = PHY_CMV_GE1200MV; 242e41f4b71Sopenharmony_ci /* The device number is 0. */ 243e41f4b71Sopenharmony_ci devno = 0; 244e41f4b71Sopenharmony_ci /* Set the CMV mode. */ 245e41f4b71Sopenharmony_ci ret = MipiCsiSetPhyCmvmode(MipiCsiHandle, devno, mode); 246e41f4b71Sopenharmony_ci if (ret != 0) { 247e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetPhyCmvmode fail! ret=%d\n", __func__, ret); 248e41f4b71Sopenharmony_ci return -1; 249e41f4b71Sopenharmony_ci } 250e41f4b71Sopenharmony_ci ``` 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci### Resetting a Sensor or Deasserting the Reset of a Sensor 253e41f4b71Sopenharmony_ci 254e41f4b71Sopenharmony_ci- Reset a sensor. 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci ```c 257e41f4b71Sopenharmony_ci int32_t MipiCsiResetSensor(DevHandle handle, uint8_t snsResetSource); 258e41f4b71Sopenharmony_ci ``` 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci **Table 9** Description of MipiCsiResetSensor 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci <a name="table9_MIPI_CSIDes"></a> 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci | Parameter | Description | 265e41f4b71Sopenharmony_ci | -------------- | ------------------------------------------------ | 266e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 267e41f4b71Sopenharmony_ci | snsResetSource | Sensor's reset signal cable number, which is called "sensor reset source" in software. | 268e41f4b71Sopenharmony_ci | **Return Value** | **Description** | 269e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 270e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 271e41f4b71Sopenharmony_ci 272e41f4b71Sopenharmony_ci ```c 273e41f4b71Sopenharmony_ci int32_t ret; 274e41f4b71Sopenharmony_ci uint8_t snsResetSource; 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ci /* The sensor's reset signal cable number is 0. */ 277e41f4b71Sopenharmony_ci snsResetSource = 0; 278e41f4b71Sopenharmony_ci /* Reset the sensor. */ 279e41f4b71Sopenharmony_ci ret = MipiCsiResetSensor(MipiCsiHandle, snsResetSource); 280e41f4b71Sopenharmony_ci if (ret != 0) { 281e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiResetSensor fail! ret=%d\n", __func__, ret); 282e41f4b71Sopenharmony_ci return -1; 283e41f4b71Sopenharmony_ci } 284e41f4b71Sopenharmony_ci ``` 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci- Deassert the reset of a sensor. 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci ```c 289e41f4b71Sopenharmony_ci int32_t MipiCsiUnresetSensor(DevHandle handle, uint8_t snsResetSource); 290e41f4b71Sopenharmony_ci ``` 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci **Table 10** Description of MipiCsiUnresetSensor 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ci <a name="table10_MIPI_CSIDes"></a> 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci | Parameter | Description | 297e41f4b71Sopenharmony_ci | -------------- | ------------------------------------------------ | 298e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 299e41f4b71Sopenharmony_ci | snsResetSource | Sensor's reset signal cable number, which is called "sensor reset source" in software. | 300e41f4b71Sopenharmony_ci | **Return Value** | **Description** | 301e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 302e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci ```c 305e41f4b71Sopenharmony_ci int32_t ret; 306e41f4b71Sopenharmony_ci uint8_t snsResetSource; 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci /* The sensor's reset signal cable number is 0. */ 309e41f4b71Sopenharmony_ci snsResetSource = 0; 310e41f4b71Sopenharmony_ci /* Deassert the reset of the sensor. */ 311e41f4b71Sopenharmony_ci ret = MipiCsiUnresetSensor(MipiCsiHandle, snsResetSource); 312e41f4b71Sopenharmony_ci if (ret != 0) { 313e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiUnresetSensor fail! ret=%d\n", __func__, ret); 314e41f4b71Sopenharmony_ci return -1; 315e41f4b71Sopenharmony_ci } 316e41f4b71Sopenharmony_ci ``` 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci### Resetting the MIPI RX or Deasserting the Reset of the MIPI RX 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci- Reset the MIPI RX. 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci ```c 323e41f4b71Sopenharmony_ci int32_t MipiCsiResetRx(DevHandle handle, uint8_t comboDev); 324e41f4b71Sopenharmony_ci ``` 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci **Table 11** Description of MipiCsiResetRx 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci <a name="table11_MIPI_CSIDes"></a> 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci | Parameter | Description | 331e41f4b71Sopenharmony_ci | ---------- | --------------------- | 332e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 333e41f4b71Sopenharmony_ci | comboDev | MIPI RX or LVDS channel number.| 334e41f4b71Sopenharmony_ci | **Return Value**| **Description** | 335e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 336e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ci ```c 339e41f4b71Sopenharmony_ci int32_t ret; 340e41f4b71Sopenharmony_ci uint8_t comboDev; 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 343e41f4b71Sopenharmony_ci comboDev = 0; 344e41f4b71Sopenharmony_ci /* Reset the MIPI RX. */ 345e41f4b71Sopenharmony_ci ret = MipiCsiResetRx(MipiCsiHandle, comboDev); 346e41f4b71Sopenharmony_ci if (ret != 0) { 347e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiResetRx fail! ret=%d\n", __func__, ret); 348e41f4b71Sopenharmony_ci return -1; 349e41f4b71Sopenharmony_ci } 350e41f4b71Sopenharmony_ci ``` 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci- Deassert the reset of the MIPI RX. 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci ```c 355e41f4b71Sopenharmony_ci int32_t MipiCsiUnresetRx(DevHandle handle, uint8_t comboDev); 356e41f4b71Sopenharmony_ci ``` 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci **Table 12** Description of MipiCsiUnresetRx 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci <a name="table12_MIPI_CSIDes"></a> 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci | Parameter | Description | 363e41f4b71Sopenharmony_ci | ---------- | --------------------- | 364e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 365e41f4b71Sopenharmony_ci | comboDev | MIPI RX or LVDS channel number.| 366e41f4b71Sopenharmony_ci | **Return Value**| **Description** | 367e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 368e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci ```c 371e41f4b71Sopenharmony_ci int32_t ret; 372e41f4b71Sopenharmony_ci uint8_t comboDev; 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 375e41f4b71Sopenharmony_ci comboDev = 0; 376e41f4b71Sopenharmony_ci /* Deassert the reset of the MIPI RX. */ 377e41f4b71Sopenharmony_ci ret = MipiCsiUnresetRx(MipiCsiHandle, comboDev); 378e41f4b71Sopenharmony_ci if (ret != 0) { 379e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiUnresetRx fail! ret=%d\n", __func__, ret); 380e41f4b71Sopenharmony_ci return -1; 381e41f4b71Sopenharmony_ci } 382e41f4b71Sopenharmony_ci ``` 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci### Enabling or Disabling the MIPI Clock 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci- Enable the MIPI clock. 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci ```c 389e41f4b71Sopenharmony_ci int32_t MipiCsiEnableClock(DevHandle handle, uint8_t comboDev); 390e41f4b71Sopenharmony_ci ``` 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci **Table 13** Description of MipiCsiEnableClock 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci <a name="table13_MIPI_CSIDes"></a> 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci | Parameter | Description | 397e41f4b71Sopenharmony_ci | ---------- | -------------- | 398e41f4b71Sopenharmony_ci | handle | Controller operation handle.| 399e41f4b71Sopenharmony_ci | comboDev | Channel number. | 400e41f4b71Sopenharmony_ci | **Return Value**| **Description**| 401e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 402e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ci ```c 405e41f4b71Sopenharmony_ci int32_t ret; 406e41f4b71Sopenharmony_ci uint8_t comboDev; 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 409e41f4b71Sopenharmony_ci comboDev = 0; 410e41f4b71Sopenharmony_ci /* Enable the MIPI clock. */ 411e41f4b71Sopenharmony_ci ret = MipiCsiEnableClock(MipiCsiHandle, comboDev); 412e41f4b71Sopenharmony_ci if (ret != 0) { 413e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiEnableClock fail! ret=%d\n", __func__, ret); 414e41f4b71Sopenharmony_ci return -1; 415e41f4b71Sopenharmony_ci } 416e41f4b71Sopenharmony_ci ``` 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci- Disable the MIPI clock. 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ci ```c 421e41f4b71Sopenharmony_ci int32_t MipiCsiDisableClock(DevHandle handle, uint8_t comboDev); 422e41f4b71Sopenharmony_ci ``` 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci **Table 14** Description of MipiCsiDisableClock 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci <a name="table14_MIPI_CSIDes"></a> 427e41f4b71Sopenharmony_ci 428e41f4b71Sopenharmony_ci | Parameter | Description | 429e41f4b71Sopenharmony_ci | ---------- | -------------- | 430e41f4b71Sopenharmony_ci | handle | Controller operation handle.| 431e41f4b71Sopenharmony_ci | comboDev | Channel number. | 432e41f4b71Sopenharmony_ci | **Return Value**| **Description**| 433e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 434e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci ```c 437e41f4b71Sopenharmony_ci int32_t ret; 438e41f4b71Sopenharmony_ci uint8_t comboDev; 439e41f4b71Sopenharmony_ci 440e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 441e41f4b71Sopenharmony_ci comboDev = 0; 442e41f4b71Sopenharmony_ci /* Disable the MIPI clock. */ 443e41f4b71Sopenharmony_ci ret = MipiCsiDisableClock(MipiCsiHandle, comboDev); 444e41f4b71Sopenharmony_ci if (ret != 0) { 445e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiDisableClock fail! ret=%d\n", __func__, ret); 446e41f4b71Sopenharmony_ci return -1; 447e41f4b71Sopenharmony_ci } 448e41f4b71Sopenharmony_ci ``` 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci### Enabling or Disabling the MIPI Sensor Clock 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ci- Enable the MIPI sensor clock. 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci ```c 455e41f4b71Sopenharmony_ci int32_t MipiCsiEnableSensorClock(DevHandle handle, uint8_t snsClkSource); 456e41f4b71Sopenharmony_ci ``` 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci **Table 15** Description of MipiCsiEnableSensorClock 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci <a name="table15_MIPI_CSIDes"></a> 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci | Parameter | Description | 463e41f4b71Sopenharmony_ci | ------------ | ------------------------------------------------ | 464e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 465e41f4b71Sopenharmony_ci | snsClkSource | Sensor's clock signal cable number, which is called clock source of the sensor in software.| 466e41f4b71Sopenharmony_ci | **Return Value** | **Description** | 467e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 468e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_ci ```c 471e41f4b71Sopenharmony_ci int32_t ret; 472e41f4b71Sopenharmony_ci uint8_t snsClkSource; 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci /* The sensor's clock signal cable number is 0. */ 475e41f4b71Sopenharmony_ci snsClkSource = 0; 476e41f4b71Sopenharmony_ci /* Enable the MIPI sensor clock. */ 477e41f4b71Sopenharmony_ci ret = MipiCsiEnableSensorClock(MipiCsiHandle, snsClkSource); 478e41f4b71Sopenharmony_ci if (ret != 0) { 479e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiEnableSensorClock fail! ret=%d\n", __func__, ret); 480e41f4b71Sopenharmony_ci return -1; 481e41f4b71Sopenharmony_ci } 482e41f4b71Sopenharmony_ci ``` 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci- Disable the MIPI sensor clock. 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ci ```c 487e41f4b71Sopenharmony_ci int32_t MipiCsiDisableSensorClock(DevHandle handle, uint8_t snsClkSource); 488e41f4b71Sopenharmony_ci ``` 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci **Table 16** Description of MipiCsiDisableSensorClock 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci <a name="table16_MIPI_CSIDes"></a> 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci | Parameter | Description | 495e41f4b71Sopenharmony_ci | ------------ | ------------------------------------------------ | 496e41f4b71Sopenharmony_ci | handle | Controller operation handle. | 497e41f4b71Sopenharmony_ci | snsClkSource | Sensor's clock signal cable number, which is called clock source of the sensor in software.| 498e41f4b71Sopenharmony_ci | **Return Value** | **Description** | 499e41f4b71Sopenharmony_ci | 0 | The operation is successful. | 500e41f4b71Sopenharmony_ci | Negative value | The operation failed. | 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ci ```c 503e41f4b71Sopenharmony_ci int32_t ret; 504e41f4b71Sopenharmony_ci uint8_t snsClkSource; 505e41f4b71Sopenharmony_ci 506e41f4b71Sopenharmony_ci /* The sensor's clock signal cable number is 0. */ 507e41f4b71Sopenharmony_ci snsClkSource = 0; 508e41f4b71Sopenharmony_ci /* Disable the MIPI sensor clock. */ 509e41f4b71Sopenharmony_ci ret = MipiCsiDisableSensorClock(MipiCsiHandle, snsClkSource); 510e41f4b71Sopenharmony_ci if (ret != 0) { 511e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiDisableSensorClock fail! ret=%d\n", __func__, ret); 512e41f4b71Sopenharmony_ci return -1; 513e41f4b71Sopenharmony_ci } 514e41f4b71Sopenharmony_ci ``` 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ci### Closing a MIPI CSI Controller Operation Handle 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ciCall **MipiCsiClose()** to close the MIPI CSI controller handle after the MIPI CSI communication is complete. 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci```c 521e41f4b71Sopenharmony_civoid MipiCsiClose(DevHandle handle); 522e41f4b71Sopenharmony_ci``` 523e41f4b71Sopenharmony_ci 524e41f4b71Sopenharmony_ciThis function releases the resources requested by **MipiCsiOpen**. 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ci**Table 17** Description of MipiCsiClose 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ci<a name="table17_MIPI_CSIDes"></a> 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci | Parameter | Description | 531e41f4b71Sopenharmony_ci | ------------ | ------------------------------------------------ | 532e41f4b71Sopenharmony_ci | handle | MIPI CSI controller operation handle. | 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ci```c 535e41f4b71Sopenharmony_ciMipiCsiClose(MIPIHandle); /* Close the operation handle of the MIPI CSI controller. */ 536e41f4b71Sopenharmony_ci``` 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci## Example 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ciThe sample code is as follows: 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ci```c 543e41f4b71Sopenharmony_ci#include "hdf.h" 544e41f4b71Sopenharmony_ci#include "MIPI_csi_if.h" 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_civoid PalMipiCsiTestSample(void) 547e41f4b71Sopenharmony_ci{ 548e41f4b71Sopenharmony_ci uint8_t id; 549e41f4b71Sopenharmony_ci int32_t ret; 550e41f4b71Sopenharmony_ci uint8_t comboDev; 551e41f4b71Sopenharmony_ci uint8_t snsClkSource; 552e41f4b71Sopenharmony_ci uint8_t devno; 553e41f4b71Sopenharmony_ci enum LaneDivideMode mode; 554e41f4b71Sopenharmony_ci enum PhyCmvMode mode; 555e41f4b71Sopenharmony_ci struct ComboDevAttr attr; 556e41f4b71Sopenharmony_ci struct ExtDataType dataType; 557e41f4b71Sopenharmony_ci DevHandle MipiCsiHandle = NULL; 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci /* Controller ID */ 560e41f4b71Sopenharmony_ci id = 0; 561e41f4b71Sopenharmony_ci /* Open the controller operation handle. */ 562e41f4b71Sopenharmony_ci MipiCsiHandle = MipiCsiOpen(id); 563e41f4b71Sopenharmony_ci if (MipiCsiHandle == NULL) { 564e41f4b71Sopenharmony_ci HDF_LOGE("MipiCsiOpen: failed!\n"); 565e41f4b71Sopenharmony_ci return; 566e41f4b71Sopenharmony_ci } 567e41f4b71Sopenharmony_ci 568e41f4b71Sopenharmony_ci /* Set the lane mode to 0. */ 569e41f4b71Sopenharmony_ci mode = LANE_DIVIDE_MODE_0; 570e41f4b71Sopenharmony_ci /* Set the MIPI RX lane distribution. */ 571e41f4b71Sopenharmony_ci ret = MipiCsiSetHsMode(MipiCsiHandle, mode); 572e41f4b71Sopenharmony_ci if (ret != 0) { 573e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetHsMode fail! ret=%d\n", __func__, ret); 574e41f4b71Sopenharmony_ci return; 575e41f4b71Sopenharmony_ci } 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 578e41f4b71Sopenharmony_ci comboDev = 0; 579e41f4b71Sopenharmony_ci /* Enable the MIPI clock. */ 580e41f4b71Sopenharmony_ci ret = MipiCsiEnableClock(MipiCsiHandle, comboDev); 581e41f4b71Sopenharmony_ci if (ret != 0) { 582e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiEnableClock fail! ret=%d\n", __func__, ret); 583e41f4b71Sopenharmony_ci return; 584e41f4b71Sopenharmony_ci } 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci /* Reset the MIPI RX. */ 587e41f4b71Sopenharmony_ci ret = MipiCsiResetRx(MipiCsiHandle, comboDev); 588e41f4b71Sopenharmony_ci if (ret != 0) { 589e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiResetRx fail! ret=%d\n", __func__, ret); 590e41f4b71Sopenharmony_ci return; 591e41f4b71Sopenharmony_ci } 592e41f4b71Sopenharmony_ci 593e41f4b71Sopenharmony_ci /* The sensor's clock signal cable number is 0. */ 594e41f4b71Sopenharmony_ci snsClkSource = 0; 595e41f4b71Sopenharmony_ci /* Enable the MIPI sensor clock. */ 596e41f4b71Sopenharmony_ci ret = MipiCsiEnableSensorClock(MipiCsiHandle, snsClkSource); 597e41f4b71Sopenharmony_ci if (ret != 0) { 598e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiEnableSensorClock fail! ret=%d\n", __func__, ret); 599e41f4b71Sopenharmony_ci return; 600e41f4b71Sopenharmony_ci } 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci /* Reset the sensor. */ 603e41f4b71Sopenharmony_ci ret = MipiCsiResetSensor(MipiCsiHandle, snsResetSource); 604e41f4b71Sopenharmony_ci if (ret != 0) { 605e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiResetSensor fail! ret=%d\n", __func__, ret); 606e41f4b71Sopenharmony_ci return; 607e41f4b71Sopenharmony_ci } 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ci /* Set MIPI parameters. */ 610e41f4b71Sopenharmony_ci (void)memset_s(&attr, sizeof(ComboDevAttr), 0, sizeof(ComboDevAttr)); 611e41f4b71Sopenharmony_ci attr.devno = 0; /* Device 0 */ 612e41f4b71Sopenharmony_ci attr.inputMode = INPUT_MODE_MIPI; /* The input mode is MIPI. */ 613e41f4b71Sopenharmony_ci attr.dataRate = MIPI_DATA_RATE_X1; /* The data rate is 1 pixel per clock cycle. */ 614e41f4b71Sopenharmony_ci attr.imgRect.x = 0; /* The value 0 indicates the upper left position of the image sensor. */ 615e41f4b71Sopenharmony_ci attr.imgRect.y = 0; /* The value 0 indicates the upper right position of the image sensor. */ 616e41f4b71Sopenharmony_ci attr.imgRect.width = 2592; /* The width of the image sensor is 2592. */ 617e41f4b71Sopenharmony_ci attr.imgRect.height = 1944; /* The height of the image sensor is 1944. */ 618e41f4b71Sopenharmony_ci /* Write the MIPI CSI configuration. */ 619e41f4b71Sopenharmony_ci ret = MipiCsiSetComboDevAttr(MipiCsiHandle, &attr); 620e41f4b71Sopenharmony_ci if (ret != 0) { 621e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetComboDevAttr fail! ret=%d\n", __func__, ret); 622e41f4b71Sopenharmony_ci return; 623e41f4b71Sopenharmony_ci } 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_ci /* Set the CMV mode to 0. */ 626e41f4b71Sopenharmony_ci mode = PHY_CMV_GE1200MV; 627e41f4b71Sopenharmony_ci /* The device number is 0. */ 628e41f4b71Sopenharmony_ci devno = 0; 629e41f4b71Sopenharmony_ci /* Set the CMV mode. */ 630e41f4b71Sopenharmony_ci ret = MipiCsiSetPhyCmvmode(MipiCsiHandle, devno, mode); 631e41f4b71Sopenharmony_ci if (ret != 0) { 632e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiSetPhyCmvmode fail! ret=%d\n", __func__, ret); 633e41f4b71Sopenharmony_ci return; 634e41f4b71Sopenharmony_ci } 635e41f4b71Sopenharmony_ci 636e41f4b71Sopenharmony_ci /* The channel number is 0.*/ 637e41f4b71Sopenharmony_ci comboDev = 0; 638e41f4b71Sopenharmony_ci /* Deassert the reset of the MIPI RX. */ 639e41f4b71Sopenharmony_ci ret = MipiCsiUnresetRx(MipiCsiHandle, comboDev); 640e41f4b71Sopenharmony_ci if (ret != 0) { 641e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiUnresetRx fail! ret=%d\n", __func__, ret); 642e41f4b71Sopenharmony_ci return; 643e41f4b71Sopenharmony_ci } 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci /* Disable the MIPI clock. */ 646e41f4b71Sopenharmony_ci ret = MipiCsiDisableClock(MipiCsiHandle, comboDev); 647e41f4b71Sopenharmony_ci if (ret != 0) { 648e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiDisableClock fail! ret=%d\n", __func__, ret); 649e41f4b71Sopenharmony_ci return; 650e41f4b71Sopenharmony_ci } 651e41f4b71Sopenharmony_ci 652e41f4b71Sopenharmony_ci /* The sensor's reset signal cable number is 0. */ 653e41f4b71Sopenharmony_ci snsResetSource = 0; 654e41f4b71Sopenharmony_ci /* Deassert the reset of the sensor. */ 655e41f4b71Sopenharmony_ci ret = MipiCsiUnresetSensor(MipiCsiHandle, snsResetSource); 656e41f4b71Sopenharmony_ci if (ret != 0) { 657e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiUnresetSensor fail! ret=%d\n", __func__, ret); 658e41f4b71Sopenharmony_ci return; 659e41f4b71Sopenharmony_ci } 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci /* Disable the MIPI sensor clock. */ 662e41f4b71Sopenharmony_ci ret = MipiCsiDisableSensorClock(MipiCsiHandle, snsClkSource); 663e41f4b71Sopenharmony_ci if (ret != 0) { 664e41f4b71Sopenharmony_ci HDF_LOGE("%s: MipiCsiDisableSensorClock fail! ret=%d\n", __func__, ret); 665e41f4b71Sopenharmony_ci return; 666e41f4b71Sopenharmony_ci } 667e41f4b71Sopenharmony_ci 668e41f4b71Sopenharmony_ci /* Close the MIPI CSI device handle. */ 669e41f4b71Sopenharmony_ci MipiCsiClose(MipiCsiHandle); 670e41f4b71Sopenharmony_ci} 671e41f4b71Sopenharmony_ci``` 672