driver-platform-hdmi-des.md 17.9 KB
Newer Older
A
annie_wangli 已提交
1
# HDMI
A
annie_wangli 已提交
2 3


A
annie_wangli 已提交
4
## Overview
A
annie_wangli 已提交
5

A
annie_wangli 已提交
6
### HDMI
A
annie_wangli 已提交
7

8
High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display.
9
HDMI works in primary/secondary mode and usually has a source and a sink.
10
The HDMI APIs provide a set of common functions for HDMI transmission, including:
A
annie_wangli 已提交
11

12 13 14 15 16
- 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 (HPD).
A
annie_wangli 已提交
17

A
annie_wangli 已提交
18
### Basic Concepts
A
annie_wangli 已提交
19

A
annie_wangli 已提交
20
HDMI is an audio and video transmission protocol released by Hitachi, Panasonic, Philips, Silicon Image, Sony, Thomson, and Toshiba. The transmission process complies with the Transition-minimized Differential Signaling (TMDS).
A
annie_wangli 已提交
21

A
annie_wangli 已提交
22 23 24 25 26 27
- TMDS is used to transmit audio, video, and various auxiliary data.
- Display data channel (DDC) allows the TX and RX ends to obtain the sending and receiving capabilities. However, the HDMI only needs to unidirectionally obtain the capabilities of the RX end (display).
- Consumer Electronics Control (CEC) enables interaction between the HDMI TX and RX devices.
- Fixed rate link (FRL) allows the maximum TMDS bandwidth to be increased from 18 Gbit/s to 48 Gbit/s.
- High-bandwidth Digital Content Protection (HDCP) prevents copying of digital audio and video content being transmitted across devices.
- Extended Display Identification Data (EDID), usually stored in the display firmware, provides the vendor information, EDID version, maximum image size, color settings, vendor pre-settings, frequency range limit, display name, and serial number.
A
annie_wangli 已提交
28

A
annie_wangli 已提交
29 30 31 32 33
### Working Principles

The HDMI source end provides +5 V and GND for DDC and CEC communication. Through the DDC, the source end obtains the sink end parameters, such as the RX capabilities. The CEC is optional. It is used to synchronize the control signals between the source and sink ends to improve user experience. There are four TMDS channels between the HDMI source and sink ends. The TMDS clock channel provides clock signals for TMDS, and the other three channels transmit audio, video, and auxiliary data. HPD is the hot plug detect port. When the sink end is connected, the source end responds by using an interrupt program.

The figure below shows the HDMI physical connection.
A
annie_wangli 已提交
34

A
annie_wangli 已提交
35
**Figure 1** HDMI physical connection
A
annie_wangli 已提交
36 37

![](figures/HDMI_physical_connection.png "HDMI_physical_connection")
A
annie_wangli 已提交
38 39 40 41 42 43 44 45 46 47 48 49

### Constraints

Currently, the HDMI module supports only the kernels (LiteOS) of mini and small systems.

## Development Guidelines

### When to Use

HDMI features high transmission rate, wide transmission bandwidth, high compatibility, and can transmit uncompressed audio and video signals. Compared with the traditional full analog interface, HDMI simplifies connection between devices and provides HDMI-specific intelligent features, which are ideal for high-quality audio and video transmission of small-sized devices.

### Available APIs
A
annie_wangli 已提交
50 51 52

**Table 1** HDMI driver APIs

A
annie_wangli 已提交
53

A
annie_wangli 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| API                       | Description                      |
| ----------------------------- | -------------------------- |
| HdmiOpen                      | Opens an HDMI controller.            |
| HdmiClose                     | Closes an HDMI controller.            |
| HdmiStart                     | Starts HDMI transmission.              |
| HdmiStop                      | Stops HDMI transmission.              |
| 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.               |
| HdmiReadSinkEdid              | Reads the raw EDID from a sink.    |
| HdmiRegisterHpdCallbackFunc   | Registers a callback for HDMI HPD.|
| HdmiUnregisterHpdCallbackFunc | Unregisters a callback for HDMI HPD.|

### How to Develop

The figure below illustrates the process of using an HDMI device.

**Figure 2** Process of using an HDMI device
A
annie_wangli 已提交
75

A
annie_wangli 已提交
76 77
![](figures/HDMI_usage_flowchart.png "HDMI_usage_flowchart")

A
annie_wangli 已提交
78
#### Opening an HDMI Controller
A
annie_wangli 已提交
79

A
annie_wangli 已提交
80
Before HDMI communication, call **HdmiOpen** to open an HDMI controller.
A
annie_wangli 已提交
81 82 83 84 85 86 87

```c
DevHandle HdmiOpen(int16_t number);
```

**Table 2** Description of HdmiOpen

A
annie_wangli 已提交
88 89 90
| Parameter      | Description            |
| ---------- | -------------------- |
| number     | HDMI controller ID.        |
91
| **Return Value**| **Description**     |
A
annie_wangli 已提交
92 93 94 95
| NULL       | Failed to open the HDMI controller.  |
| Controller handle| Handle of the opened HDMI controller.|

Example: Open controller 0 of the two HDMI controllers (numbered 0 and 1) in the system.
A
annie_wangli 已提交
96 97 98 99 100 101 102 103 104 105 106 107

```c
DevHandle hdmiHandle = NULL; /* HDMI controller handle /

/* Open HDMI controller 0. */
hdmiHandle = HdmiOpen(0);
if (hdmiHandle == NULL) {
    HDF_LOGE("HdmiOpen: failed\n");
    return;
}
```

A
annie_wangli 已提交
108
#### Registering a Callback for HPD
A
annie_wangli 已提交
109 110 111 112 113 114 115

```c
int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo *callback);
```

**Table 3** Description of HdmiRegisterHpdCallbackFunc

A
annie_wangli 已提交
116 117 118 119
| Parameter      | Description          |
| ---------- | ------------------ |
| handle     | HDMI controller handle.    |
| callback   | Pointer to the callback to be invoked to return the HPD result.|
120
| **Return Value**| **Description**   |
A
annie_wangli 已提交
121 122
| 0          | The operation is successful.          |
| Negative value      | The operation failed.          |
A
annie_wangli 已提交
123

A
annie_wangli 已提交
124
The following is an example of registering a callback for HPD:
A
annie_wangli 已提交
125 126

```c
A
annie_wangli 已提交
127
/* Definition of the callback for HPD */
A
annie_wangli 已提交
128 129 130
static void HdmiHpdHandle(void *data, bool hpd)
{
    if (data == NULL) {
A
annie_wangli 已提交
131 132 133
        HDF_LOGE("priv data is NULL");
        return;
    }
A
annie_wangli 已提交
134 135 136 137
    if (hpd == true) {
        HDF_LOGD("HdmiHpdHandle: hot plug");
        /* Add related processing if required. */
    } else {
A
annie_wangli 已提交
138
        HDF_LOGD("HdmiHpdHandle: hot unplug");
A
annie_wangli 已提交
139 140 141 142
        /* Add related processing if required. */
    }
}

A
annie_wangli 已提交
143 144 145 146 147 148 149 150 151 152
/* Example of registering a callback for HPD */
···
struct HdmiHpdCallbackInfo info = {0};
info.data = handle;
info.callbackFunc = HdmiHpdHandle;
ret = HdmiRegisterHpdCallbackFunc(hdmiHandle, info);
if (ret != 0) {
    HDF_LOGE("HdmiRegisterHpdCallbackFunc: Register failed.");
}
···
A
annie_wangli 已提交
153 154
```

A
annie_wangli 已提交
155
#### Reading the Raw EDID
A
annie_wangli 已提交
156 157 158 159 160 161 162

```c
int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len);
```

**Table 4** Description of HdmiReadSinkEdid

A
annie_wangli 已提交
163 164 165 166 167
| Parameter      | Description              |
| ---------- | ---------------------- |
| handle     | HDMI controller handle.        |
| buffer     | Pointer to the data buffer.            |
| len        | Data length.              |
168
| **Return Value**| **Description**       |
A
annie_wangli 已提交
169 170
| Positive integer    | Raw EDID read.|
| Negative number or 0   | Failed to read the EDID.              |
A
annie_wangli 已提交
171

A
annie_wangli 已提交
172
The following is an example of reading the raw EDID from a sink:
A
annie_wangli 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

```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 Audio Attributes

```c
int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr);
```

**Table 5** Description of HdmiSetAudioAttribute

A
annie_wangli 已提交
192 193 194 195 196

| Parameter  | Description      |
| ------ | -------------- |
| handle | HDMI controller handle.|
| attr   | Pointer to the audio attributes.      |
197
| **Return Value**| **Description**   |
A
annie_wangli 已提交
198 199
| 0      | The operation is successful.      |
| Negative value  | The operation failed.      |
A
annie_wangli 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

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

A
annie_wangli 已提交
226 227 228 229 230 231 232 233

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| attr       | Pointer to the video attributes.      |
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258

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

A
annie_wangli 已提交
259 260 261 262

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
A
annie_wangli 已提交
263
| attr       | Pinter to the HDR attributes.     |
A
annie_wangli 已提交
264 265 266
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292

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 HDMI AV Mute

```c
int32_t HdmiAvmuteSet(DevHandle handle, bool enable);
```

**Table 8** Description of HdmiAvmuteSet

A
annie_wangli 已提交
293 294 295 296

| Parameter      | Description         |
| ---------- | ----------------- |
| handle     | HDMI controller handle.   |
A
annie_wangli 已提交
297
| enable     | Whether to enable the AV mute feature.|
298
| **Return Value**| **Description**  |
A
annie_wangli 已提交
299 300
| 0          | The operation is successful.         |
| Negative value      | The operation failed.         |
A
annie_wangli 已提交
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320

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

A
annie_wangli 已提交
321 322 323 324 325 326 327 328

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| color      | Color depth to set.      |
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348

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

A
annie_wangli 已提交
349 350 351 352 353 354 355 356

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| color      | Pointer to the color depth.      |
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
357 358 359 360 361 362 363 364 365 366 367 368 369

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.");
}
```

A
annie_wangli 已提交
370
#### Starting HDMI Transmission
A
annie_wangli 已提交
371 372 373 374 375 376 377

```c
int32_t HdmiStart(DevHandle handle);
```

**Table 11** Description of HdmiStart

A
annie_wangli 已提交
378 379 380 381 382 383 384

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
385 386 387 388 389 390 391 392 393 394 395 396

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.");
}
```

A
annie_wangli 已提交
397
#### Stopping HDMI Transmission<a name="section11"></a>
A
annie_wangli 已提交
398 399 400 401 402 403 404

```c
int32_t HdmiStop(DevHandle handle);
```

**Table 12** Description of HdmiStop

A
annie_wangli 已提交
405 406 407 408 409 410 411

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
412 413 414 415 416 417 418 419 420 421 422 423

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.");
}
```

A
annie_wangli 已提交
424
#### Unregistering the Callback for HPD
A
annie_wangli 已提交
425 426 427 428 429 430 431

```c
int32_t HdmiUnregisterHpdCallbackFunc(DevHandle handle);
```

**Table 13** Description of HdmiUnregisterHpdCallbackFunc

A
annie_wangli 已提交
432 433 434 435 436 437 438

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
| **Return Value**| **Description**|
| 0          | The operation is successful.      |
| Negative value      | The operation failed.      |
A
annie_wangli 已提交
439

A
annie_wangli 已提交
440
The following is an example of unregistering the callback for HPD:
A
annie_wangli 已提交
441 442 443 444 445 446 447 448 449 450

```c
int32_t ret;

ret = HdmiUnregisterHpdCallbackFunc(hdmiHandle);
if (ret != 0) {
    HDF_LOGE("unregister failed.");
}
```

A
annie_wangli 已提交
451
#### Closing an HDMI Controller
A
annie_wangli 已提交
452 453 454 455 456 457 458

```c
void HdmiClose(DevHandle handle);
```

**Table 14** Description of HdmiClose

A
annie_wangli 已提交
459 460 461 462

| Parameter      | Description      |
| ---------- | -------------- |
| handle     | HDMI controller handle.|
A
annie_wangli 已提交
463 464 465 466 467 468 469

The following is an example of closing an HDMI controller:

```c
HdmiClose(hdmiHandle);
```

A
annie_wangli 已提交
470
### Development Example
A
annie_wangli 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485

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 */
A
annie_wangli 已提交
486
#include "osal_time.h"       /* Header file for delay and sleep APIs */
A
annie_wangli 已提交
487 488 489 490 491 492 493 494 495 496 497 498 499

/* 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 {
A
annie_wangli 已提交
500
        HDF_LOGD("HdmiHpdHandle: hot unplug");
A
annie_wangli 已提交
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
        /* 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;
}

618
```