• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @addtogroup HDMI
11  * @{
12  *
13  * @brief Declares standard APIs of basic High-Definition Multimedia Interface (HDMI) capabilities.
14  *
15  * You can use this module to access the HDMI and enable the driver to operate an HDMI sink device.
16  * These capabilities include start and stop tramnsfer on HDMI, setting some attributes,
17  * and read sink device's EDID data.
18  *
19  * @since 1.0
20  */
21 
22 /**
23  * @file hdmi_if.h
24  *
25  * @brief Declares the standard HDMI interface functions.
26  *
27  * @since 1.0
28  */
29 
30 #ifndef HDMI_IF_H
31 #define HDMI_IF_H
32 
33 #include "platform_if.h"
34 
35 #ifdef __cplusplus
36 #if __cplusplus
37 extern "C" {
38 #endif
39 #endif /* __cplusplus */
40 
41 /**
42  * @brief Indicates that maximum length of an HDMI sink device's EDID is 512 bytes.
43  *
44  * @since 1.0
45  */
46 #define HDMI_EDID_MAX_LEN 512
47 
48 /**
49  * @brief Enumerates deep color,
50  * see the section 6.2.4 of HDMI Specification 1.4 for details.
51  *
52  * @since 1.0
53  */
54 enum HdmiDeepColor {
55     HDMI_DEEP_COLOR_24BITS = 0,
56     HDMI_DEEP_COLOR_30BITS = 1,
57     HDMI_DEEP_COLOR_36BITS = 2,
58     HDMI_DEEP_COLOR_48BITS = 3,
59     HDMI_DEEP_COLOR_OFF = 0xff,
60     HDMI_DEEP_COLOR_BUTT,
61 };
62 
63 /**
64  * @brief Enumerates video bit depth
65  * see the section 6.6 of HDMI Specification 1.4 for details.
66  *
67  * @since 1.0
68  */
69 enum HdmiVideoBitDepth {
70     HDMI_VIDEO_BIT_DEPTH_8 = 0,
71     HDMI_VIDEO_BIT_DEPTH_10 = 1,
72     HDMI_VIDEO_BIT_DEPTH_12 = 2,
73     HDMI_VIDEO_BIT_DEPTH_16 = 3,
74     HDMI_VIDEO_BIT_DEPTH_OFF,
75 };
76 
77 /**
78  * @brief Enumerates color space,
79  * see the section 6 of HDMI Specification 1.4 for details.
80  *
81  * @since 1.0
82  */
83 enum HdmiColorSpace {
84     HDMI_COLOR_SPACE_RGB = 0,
85     HDMI_COLOR_SPACE_YCBCR422 = 1,
86     HDMI_COLOR_SPACE_YCBCR444 = 2,
87     HDMI_COLOR_SPACE_YCBCR420 = 3,
88     HDMI_COLOR_SPACE_BUTT,
89 };
90 
91 /**
92  * @brief Enumerates colorimetry, see the section 6.7 of HDMI Specification 1.4 and
93  * the section 7.2 of HDMI Specification 2.0 for details.
94  *
95  * @since 1.0
96  */
97 enum HdmiColorimetry {
98     HDMI_COLORIMETRY_NO_DATA = 0,
99     HDMI_COLORIMETRY_ITU601 = 1,
100     HDMI_COLORIMETRY_ITU709 = 2,
101     HDMI_COLORIMETRY_EXTENDED = 3,
102 };
103 
104 /**
105  * @brief Enumerates extended colorimetry, see the section 6.7 of HDMI Specification 1.4 and
106  * the section 7.2 of HDMI Specification 2.0 for details.
107  *
108  * @since 1.0
109  */
110 enum HdmiExtendedColorimetry {
111     HDMI_EXTENDED_COLORIMETRY_XV_YCC_601 = 0,
112     HDMI_EXTENDED_COLORIMETRY_XV_YCC_709 = 1,
113     HDMI_EXTENDED_COLORIMETRY_S_YCC_601 = 2,
114     HDMI_EXTENDED_COLORIMETRY_OPYCC_601 = 3,
115     HDMI_EXTENDED_COLORIMETRY_OPRGB = 4,
116     HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM = 5,
117     HDMI_EXTENDED_COLORIMETRY_BT2020 = 6,
118     HDMI_EXTENDED_COLORIMETRY_ADDITIONAL = 7,
119     HDMI_EXTENDED_COLORIMETRY_BUTT,
120 };
121 
122 /**
123  * @brief Enumerates quantization range, see the section 6.6 of HDMI Specification 1.4 and
124  * the section 7.3 of HDMI Specification 2.0 for details.
125  *
126  * @since 1.0
127  */
128 enum HdmiQuantizationRange {
129     HDMI_QUANTIZATION_RANGE_DEFAULT = 0,
130     HDMI_QUANTIZATION_RANGE_LIMITED = 1,
131     HDMI_QUANTIZATION_RANGE_FULL = 2,
132     HDMI_QUANTIZATION_RANGE_BUTT,
133 };
134 
135 /**
136  * @brief Enumerates YCC quantization range, see the section 6.6 of HDMI Specification 1.4 and
137  * the section 7.3 of HDMI Specification 2.0 for details.
138  *
139  * @since 1.0
140  */
141 enum HdmiYccQuantizationRange {
142     HDMI_YCC_QUANTIZATION_RANGE_LIMITED = 0,
143     HDMI_YCC_QUANTIZATION_RANGE_FULL = 1,
144     HDMI_YCC_QUANTIZATION_RANGE_BUTT,
145 };
146 
147 /**
148  * @brief Enumerates video 3d structure,
149  * see the section 8.2.3 of HDMI Specification 1.4 for details.
150  *
151  * @since 1.0
152  */
153 enum HdmiVideo3dStructure {
154     HDMI_VS_VIDEO_3D_FRAME_PACKING = 0,
155     HDMI_VS_VIDEO_3D_FIELD_ALTERNATIVE = 1,
156     HDMI_VS_VIDEO_3D_LINE_ALTERNATIVE = 2,
157     HDMI_VS_VIDEO_3D_SIDE_BY_SIDE_FULL = 3,
158     HDMI_VS_VIDEO_3D_L_DEPTH = 4,
159     HDMI_VS_VIDEO_3D_L_DEPTH_GFX_GFX_DEPTH = 5,
160     HDMI_VS_VIDEO_3D_TOP_AND_BOTTOM = 6,
161     HDMI_VS_VIDEO_3D_SIDE_BY_SIDE_HALF = 8,
162     HDMI_VS_VIDEO_3D_BUTT,
163 };
164 
165 /**
166  * @brief Enumerates video timing,
167  * see the section 8.2.3 of HDMI Specification 1.4 for details.
168  *
169  * @since 1.0
170  */
171 enum HdmiVideoTiming {
172     HDMI_VIDEO_TIMING_NONE = 0,
173     HDMI_VIDEO_TIMING_640X480P60 = 1,
174     HDMI_VIDEO_TIMING_720X480P60 = 2,
175     HDMI_VIDEO_TIMING_720X480P120 = 3,
176     HDMI_VIDEO_TIMING_720X480P240 = 4,
177     HDMI_VIDEO_TIMING_720X576P50 = 5,
178     HDMI_VIDEO_TIMING_720X576P100 = 6,
179     HDMI_VIDEO_TIMING_720X576P200 = 7,
180     HDMI_VIDEO_TIMING_1280X720P24 = 8,
181     HDMI_VIDEO_TIMING_1280X720P25 = 9,
182     HDMI_VIDEO_TIMING_1280X720P30 = 10,
183     HDMI_VIDEO_TIMING_1280X720P48 = 11,
184     HDMI_VIDEO_TIMING_1280X720P50 = 12,
185     HDMI_VIDEO_TIMING_1280X720P60 = 13,
186     HDMI_VIDEO_TIMING_1280X720P100 = 14,
187     HDMI_VIDEO_TIMING_1280X720P120 = 15,
188     HDMI_VIDEO_TIMING_1440X240P60 = 16,
189     HDMI_VIDEO_TIMING_1440X288P50 = 17,
190     HDMI_VIDEO_TIMING_1440X480I60 = 18,
191     HDMI_VIDEO_TIMING_1440X480P60 = 19,
192     HDMI_VIDEO_TIMING_1440X480I120 = 20,
193     HDMI_VIDEO_TIMING_1440X480I240 = 21,
194     HDMI_VIDEO_TIMING_1440X576I50 = 22,
195     HDMI_VIDEO_TIMING_1440X576P50 = 23,
196     HDMI_VIDEO_TIMING_1440X576I60 = 24,
197     HDMI_VIDEO_TIMING_1440X576I100 = 25,
198     HDMI_VIDEO_TIMING_1440X576I200 = 26,
199     HDMI_VIDEO_TIMING_2880X288P50 = 27,
200     HDMI_VIDEO_TIMING_2880X480I60 = 28,
201     HDMI_VIDEO_TIMING_2880X480P60 = 29,
202     HDMI_VIDEO_TIMING_2880X240I60 = 30,
203     HDMI_VIDEO_TIMING_2880X576I50 = 31,
204     HDMI_VIDEO_TIMING_2880X576P50 = 32,
205     HDMI_VIDEO_TIMING_1680X720P24 = 33,
206     HDMI_VIDEO_TIMING_1680X720P25 = 34,
207     HDMI_VIDEO_TIMING_1680X720P30 = 35,
208     HDMI_VIDEO_TIMING_1680X720P48 = 36,
209     HDMI_VIDEO_TIMING_1680X720P50 = 37,
210     HDMI_VIDEO_TIMING_1680X720P60 = 38,
211     HDMI_VIDEO_TIMING_1680X720P100 = 39,
212     HDMI_VIDEO_TIMING_1680X720P120 = 40,
213     HDMI_VIDEO_TIMING_2560X1080P24 = 41,
214     HDMI_VIDEO_TIMING_2560X1080P25 = 42,
215     HDMI_VIDEO_TIMING_2560X1080P30 = 43,
216     HDMI_VIDEO_TIMING_2560X1080P48 = 44,
217     HDMI_VIDEO_TIMING_2560X1080P50 = 45,
218     HDMI_VIDEO_TIMING_2560X1080P60 = 46,
219     HDMI_VIDEO_TIMING_2560X1080P100 = 47,
220     HDMI_VIDEO_TIMING_2560X1080P120 = 48,
221     HDMI_VIDEO_TIMING_1920X1080I60 = 49,
222     HDMI_VIDEO_TIMING_1920X1080P60 = 50,
223     HDMI_VIDEO_TIMING_1920X1080I50 = 51,
224     HDMI_VIDEO_TIMING_1920X1080P50 = 52,
225     HDMI_VIDEO_TIMING_1920X1080P24 = 53,
226     HDMI_VIDEO_TIMING_1920X1080P25 = 54,
227     HDMI_VIDEO_TIMING_1920X1080P30 = 55,
228     HDMI_VIDEO_TIMING_1920X1080P48 = 56,
229     HDMI_VIDEO_TIMING_1920X1080I100 = 57,
230     HDMI_VIDEO_TIMING_1920X1080I120 = 58,
231     HDMI_VIDEO_TIMING_1920X1080P120 = 59,
232     HDMI_VIDEO_TIMING_1920X1080P100 = 60,
233     HDMI_VIDEO_TIMING_3840X2160P24 = 61,
234     HDMI_VIDEO_TIMING_3840X2160P25 = 62,
235     HDMI_VIDEO_TIMING_3840X2160P30 = 63,
236     HDMI_VIDEO_TIMING_3840X2160P48 = 64,
237     HDMI_VIDEO_TIMING_3840X2160P50 = 65,
238     HDMI_VIDEO_TIMING_3840X2160P60 = 66,
239     HDMI_VIDEO_TIMING_3840X2160P100 = 67,
240     HDMI_VIDEO_TIMING_3840X2160P120 = 68,
241     HDMI_VIDEO_TIMING_4096X2160P24 = 69,
242     HDMI_VIDEO_TIMING_4096X2160P25 = 70,
243     HDMI_VIDEO_TIMING_4096X2160P30 = 71,
244     HDMI_VIDEO_TIMING_4096X2160P48 = 72,
245     HDMI_VIDEO_TIMING_4096X2160P50 = 73,
246     HDMI_VIDEO_TIMING_4096X2160P60 = 74,
247     HDMI_VIDEO_TIMING_4096X2160P100 = 75,
248     HDMI_VIDEO_TIMING_4096X2160P120 = 76,
249     HDMI_VIDEO_TIMING_5120X2160P24 = 77,
250     HDMI_VIDEO_TIMING_5120X2160P25 = 78,
251     HDMI_VIDEO_TIMING_5120X2160P30 = 79,
252     HDMI_VIDEO_TIMING_5120X2160P48 = 80,
253     HDMI_VIDEO_TIMING_5120X2160P50 = 81,
254     HDMI_VIDEO_TIMING_5120X2160P60 = 82,
255     HDMI_VIDEO_TIMING_5120X2160P100 = 83,
256     HDMI_VIDEO_TIMING_5120X2160P120 = 84,
257     HDMI_VIDEO_TIMING_7680X4320P24 = 85,
258     HDMI_VIDEO_TIMING_7680X4320P25 = 86,
259     HDMI_VIDEO_TIMING_7680X4320P30 = 87,
260     HDMI_VIDEO_TIMING_7680X4320P48 = 88,
261     HDMI_VIDEO_TIMING_7680X4320P50 = 89,
262     HDMI_VIDEO_TIMING_7680X4320P60 = 90,
263     HDMI_VIDEO_TIMING_7680X4320P100 = 91,
264     HDMI_VIDEO_TIMING_7680X4320P120 = 92,
265     HDMI_VIDEO_TIMING_10240X4320P24 = 93,
266     HDMI_VIDEO_TIMING_10240X4320P25 = 94,
267     HDMI_VIDEO_TIMING_10240X4320P30 = 95,
268     HDMI_VIDEO_TIMING_10240X4320P48 = 96,
269     HDMI_VIDEO_TIMING_10240X4320P50 = 97,
270     HDMI_VIDEO_TIMING_10240X4320P60 = 98,
271     HDMI_VIDEO_TIMING_10240X4320P100 = 99,
272     HDMI_VIDEO_TIMING_10240X4320P120 = 100,
273     HDMI_VIDEO_TIMING_VESA_DEFINE = 101,
274     HDMI_VIDEO_TIMING_VESA_800X600_60 = 102,
275     HDMI_VIDEO_TIMING_VESA_848X480_60 = 103,
276     HDMI_VIDEO_TIMING_VESA_1024X768_60 = 104,
277     HDMI_VIDEO_TIMING_VESA_1280X720_60 = 105,
278     HDMI_VIDEO_TIMING_VESA_1280X768_60 = 106,
279     HDMI_VIDEO_TIMING_VESA_1280X768_60_RB = 107,
280     HDMI_VIDEO_TIMING_VESA_1280X800_60 = 108,
281     HDMI_VIDEO_TIMING_VESA_1280X800_60_RB = 109,
282     HDMI_VIDEO_TIMING_VESA_1280X960_60 = 110,
283     HDMI_VIDEO_TIMING_VESA_1280X1024_60 = 111,
284     HDMI_VIDEO_TIMING_VESA_1360X768_60 = 112,
285     HDMI_VIDEO_TIMING_VESA_1366X768_60 = 113,
286     HDMI_VIDEO_TIMING_VESA_1400X1050_60 = 114,
287     HDMI_VIDEO_TIMING_VESA_1440X900_60 = 115,
288     HDMI_VIDEO_TIMING_VESA_1440X900_60_RB = 116,
289     HDMI_VIDEO_TIMING_VESA_1440X1050_60 = 117,
290     HDMI_VIDEO_TIMING_VESA_1440X1050_60_RB = 118,
291     HDMI_VIDEO_TIMING_VESA_1600X900_60_RB = 119,
292     HDMI_VIDEO_TIMING_VESA_1600X1200_60 = 120,
293     HDMI_VIDEO_TIMING_VESA_1680X1050_60 = 113,
294     HDMI_VIDEO_TIMING_VESA_1680X1050_60_RB = 114,
295     HDMI_VIDEO_TIMING_VESA_1792X1344_60 = 115,
296     HDMI_VIDEO_TIMING_VESA_1856X1392_60 = 116,
297     HDMI_VIDEO_TIMING_VESA_1920X1080_60 = 117,
298     HDMI_VIDEO_TIMING_VESA_1920X1200_60 = 118,
299     HDMI_VIDEO_TIMING_VESA_1920X1200_60_RB = 119,
300     HDMI_VIDEO_TIMING_VESA_1920X1440_60 = 120,
301     HDMI_VIDEO_TIMING_VESA_2048X1152_60 = 121,
302     HDMI_VIDEO_TIMING_VESA_2560X1440_60_RB = 122,
303     HDMI_VIDEO_TIMING_VESA_2560X1600_60 = 123,
304     HDMI_VIDEO_TIMING_VESA_2560X1600_60_RB = 124,
305     HDMI_VIDEO_TIMING_USER_DEFINE = 125,
306     HDMI_VIDEO_TIMING_USER_1920X2160_30 = 126,
307     HDMI_VIDEO_TIMING_USER_2560X1440_30 = 127,
308     HDMI_VIDEO_TIMING_USER_2560X1440_60 = 128,
309     HDMI_VIDEO_TIMING_USER_1280X720_60 = 129,
310     HDMI_VIDEO_TIMING_USER_1366X768_60 = 130,
311     HDMI_VIDEO_TIMING_USER_1600X900_60_RB = 131,
312     HDMI_VIDEO_TIMING_USER_1920X1080_60 = 132,
313     HDMI_VIDEO_TIMING_USER_2048X1152_60 = 133,
314     HDMI_VIDEO_TIMING_BUTT,
315 };
316 
317 /**
318  * @brief Enumerates picture aspect ratio,
319  * see the section 8.2.1 of HDMI Specification 1.4 for details.
320  *
321  * @since 1.0
322  */
323 enum HdmiPictureAspectRatio {
324     HDMI_PICTURE_ASPECT_NO_DATA = 0,
325     HDMI_PICTURE_ASPECT_4_3 = 1,
326     HDMI_PICTURE_ASPECT_16_9 = 2,
327     HDMI_PICTURE_ASPECT_64_27 = 3,
328     HDMI_PICTURE_ASPECT_256_135 = 4,
329     HDMI_PICTURE_ASPECT_BUTT = 5,
330 };
331 
332 /**
333  * @brief Enumerates active format aspect ratio,
334  * see the section 8.2.1 of HDMI Specification 1.4 for details.
335  *
336  * @since 1.0
337  */
338 enum HdmiActiveFormatAspectRatio {
339     HDMI_ACTIVE_FORMAT_ASPECT_16_9_TOP = 2,
340     HDMI_ACTIVE_FORMAT_ASPECT_14_9_TOP = 3,
341     HDMI_ACTIVE_FORMAT_ASPECT_16_9_CENTER = 4,
342     HDMI_ACTIVE_FORMAT_ASPECT_PICTURE = 8,
343     HDMI_ACTIVE_FORMAT_ASPECT_4_3 = 9,
344     HDMI_ACTIVE_FORMAT_ASPECT_16_9 = 10,
345     HDMI_ACTIVE_FORMAT_ASPECT_14_9 = 11,
346     HDMI_ACTIVE_FORMAT_ASPECT_4_3_SP_14_9 = 13,
347     HDMI_ACTIVE_FORMAT_ASPECT_16_9_SP_14_9 = 14,
348     HDMI_ACTIVE_FORMAT_ASPECT_16_9_SP_4_3 = 15,
349     HDMI_ACTIVE_FORMAT_ASPECT_BUTT,
350 };
351 
352 /**
353  * @brief Enumerates Nups(non-uniform picture scaling),
354  * see the section 8.2.1 of HDMI Specification 1.4 for details.
355  *
356  * @since 1.0
357  */
358 enum HdmiNups {
359     HDMI_NUPS_UNKNOWN = 0,      /* No Known non-uniform scaling */
360     HDMI_NUPS_HORIZONTAL = 1,   /* Picture has been scaled horizontally */
361     HDMI_NUPS_VERTICAL = 2,     /* Picture has been scaled vertically */
362     HDMI_NUPS_BOTH = 3,         /* Picture has been scaled horizontally and vertically */
363 };
364 
365 /**
366  * @brief Defines the video attribute struct.
367  *
368  * @since 1.0
369  */
370 struct HdmiVideoAttr {
371     uint32_t tmdsClock;  /* unit: KHz */
372     uint32_t pixelClock; /* unit: KHz */
373     uint32_t pixelRepeat;
374     enum HdmiColorSpace colorSpace;
375     enum HdmiColorimetry colorimetry;
376     enum HdmiExtendedColorimetry extColorimetry;
377     enum HdmiQuantizationRange quantization;
378     enum HdmiYccQuantizationRange yccQuantization;
379     enum HdmiDeepColor deepColor;
380     enum HdmiVideo3dStructure _3dStruct;
381     enum HdmiVideoTiming timing;
382     enum HdmiPictureAspectRatio aspect;
383     enum HdmiActiveFormatAspectRatio activeAspect;
384     enum HdmiNups nups;
385     bool xvycc;
386 };
387 
388 /**
389  * @brief Enumerates audio coding type,
390  * see the section 7 of HDMI Specification 1.4 for details.
391  *
392  * @since 1.0
393  */
394 enum HdmiAudioCodingType {
395     HDMI_AUDIO_CODING_TYPE_STREAM = 0,
396     HDMI_AUDIO_CODING_TYPE_LPCM = 1,
397     HDMI_AUDIO_CODING_TYPE_AC3 = 2,
398     HDMI_AUDIO_CODING_TYPE_MPEG1 = 3,
399     HDMI_AUDIO_CODING_TYPE_MP3 = 4,
400     HDMI_AUDIO_CODING_TYPE_MPEG2 = 5,
401     HDMI_AUDIO_CODING_TYPE_AAC_LC = 6,
402     HDMI_AUDIO_CODING_TYPE_DTS = 7,
403     HDMI_AUDIO_CODING_TYPE_ATRAC = 8,
404     HDMI_AUDIO_CODING_TYPE_OBA = 9,
405     HDMI_AUDIO_CODING_TYPE_EAC3 = 10,
406     HDMI_AUDIO_CODING_TYPE_DTS_HD = 11,
407     HDMI_AUDIO_CODING_TYPE_MLP = 12,
408     HDMI_AUDIO_CODING_TYPE_DST = 13,
409     HDMI_AUDIO_CODING_TYPE_WMA_PRO = 14,
410     HDMI_AUDIO_CODING_TYPE_CXT = 15,
411 };
412 
413 /**
414  * @brief Enumerates audio interface type.
415  *
416  * @since 1.0
417  */
418 enum HdmiAudioInterfaceType {
419     HDMI_AUDIO_IF_TYPE_I2S = 0,    /* Inter-IC Sound */
420     HDMI_AUDIO_IF_TYPE_SPDIF = 1,  /* Sony/Philips Digital Interface */
421     HDMI_AUDIO_IF_TYPE_OTHER,
422 };
423 
424 /**
425  * @brief Enumerates audio bit depth,
426  * see the section 7 of HDMI Specification 1.4 for details.
427  *
428  * @since 1.0
429  */
430 enum HdmiAudioBitDepth {
431     HDMI_ADIO_BIT_DEPTH_UNKNOWN,
432     HDMI_ADIO_BIT_DEPTH_8 = 8,
433     HDMI_ADIO_BIT_DEPTH_16 = 16,
434     HDMI_ADIO_BIT_DEPTH_18 = 18,
435     HDMI_ADIO_BIT_DEPTH_20 = 20,
436     HDMI_ADIO_BIT_DEPTH_24 = 24,
437     HDMI_ADIO_BIT_DEPTH_32 = 32,
438     HDMI_ADIO_BIT_DEPTH_BUTT,
439 };
440 
441 /**
442  * @brief Enumerates sample rate used for audio,
443  * see the section 7.3 of HDMI Specification 1.4 for details.
444  *
445  * @since 1.0
446  */
447 enum HdmiSampleRate {
448     HDMI_SAMPLE_RATE_UNKNOWN,
449     HDMI_SAMPLE_RATE_8K = 8000,
450     HDMI_SAMPLE_RATE_11K = 11025,
451     HDMI_SAMPLE_RATE_12K = 12000,
452     HDMI_SAMPLE_RATE_16K = 16000,
453     HDMI_SAMPLE_RATE_22K = 22050,
454     HDMI_SAMPLE_RATE_24K = 24000,
455     HDMI_SAMPLE_RATE_32K = 32000,
456     HDMI_SAMPLE_RATE_44K = 44100,
457     HDMI_SAMPLE_RATE_48K = 48000,
458     HDMI_SAMPLE_RATE_88K = 88200,
459     HDMI_SAMPLE_RATE_96K = 96000,
460     HDMI_SAMPLE_RATE_176K = 176400,
461     HDMI_SAMPLE_RATE_192K = 192000,
462     HDMI_SAMPLE_RATE_768K = 768000,
463     HDMI_SAMPLE_RATE_BUTT,
464 };
465 
466 /**
467  * @brief Enumerates audio format channel,
468  * see the section 7 of HDMI Specification 1.4 for details.
469  *
470  * @since 1.0
471  */
472 enum HdmiAudioFormatChannel {
473     HDMI_AUDIO_FORMAT_CHANNEL_2 = 2,
474     HDMI_AUDIO_FORMAT_CHANNEL_3,
475     HDMI_AUDIO_FORMAT_CHANNEL_4,
476     HDMI_AUDIO_FORMAT_CHANNEL_5,
477     HDMI_AUDIO_FORMAT_CHANNEL_6,
478     HDMI_AUDIO_FORMAT_CHANNEL_7,
479     HDMI_AUDIO_FORMAT_CHANNEL_8,
480     HDMI_AUDIO_FORMAT_CHANNEL_BUTT,
481 };
482 
483 /**
484  * @brief Defines the audio attribute struct.
485  *
486  * @since 1.0
487  */
488 struct HdmiAudioAttr {
489     enum HdmiAudioCodingType codingType;
490     enum HdmiAudioInterfaceType ifType;
491     enum HdmiAudioBitDepth bitDepth;
492     enum HdmiSampleRate sampleRate;
493     bool downSample;
494     enum HdmiAudioFormatChannel channels;
495 };
496 
497 /**
498  * @brief Enumerates Electro-Optical Transfer Function (EOTF),
499  * see the section 6.9 of CTA-861-G for details.
500  *
501  * @since 1.0
502  */
503 enum HdmiEotfType {
504     HDMI_EOTF_SDR_LUMIN = 0,        /* Traditional gamma - SDR Luminance Range */
505     HDMI_EOTF_HDR_LUMIN = 1,        /* Traditional gamma - HDR Luminance Range */
506     HDMI_EOTF_SMPTE_ST_2048 = 2,    /* SMPTE ST 2048 */
507     HDMI_EOTF_HLG = 3,              /* Hybrid Log-Gamma (HLG) based on ITU-R BT.2100-0 */
508     HDMI_EOTF_BUTT,
509 };
510 
511 /**
512  * @brief Enumerates hdr colormetry,
513  * see HDMI Specification 2.1 for details.
514  *
515  * @since 1.0
516  */
517 enum HdmiHdrColormetry {
518     HDMI_HDR_COLORIMETRY_NONE,
519     HDMI_HDR_COLORIMETRY_ITU_601,
520     HDMI_HDR_COLORIMETRY_ITU_709,
521     HDMI_HDR_COLORIMETRY_EXTENDED,
522     HDMI_HDR_EXTENDED_COLORIMETRY_XV_YCC_601,
523     HDMI_HDR_EXTENDED_COLORIMETRY_XV_YCC_709,
524     HDMI_HDR_EXTENDED_COLORIMETRY_S_YCC_601,
525     HDMI_HDR_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
526     HDMI_HDR_EXTENDED_COLORIMETRY_ADOBE_RGB,
527     HDMI_HDR_EXTENDED_COLORIMETRY_2020_CONST_LUMINOUS, /* BT2020 c_ycc */
528     HDMI_HDR_EXTENDED_COLORIMETRY_2020_NON_CONST_LUMINOUW
529 };
530 
531 /**
532  * @brief Enumerates hdr mode,
533  * see HDMI Specification 2.1 for details.
534  *
535  * @since 1.0
536  */
537 enum HdmiHdrMode {
538     HDMI_HDR_MODE_DISABLE,          /* HDR & dolby mode disable */
539     HDMI_HDR_MODE_DOLBY_NORMAL,     /* dolby normal(ycbcr422-12bit) mode enable */
540     HDMI_HDR_MODE_DOLBY_TUNNELING,  /* dolby tunneling(RGB-8bit) mode enable */
541     HDMI_HDR_MODE_CEA_861_3,        /* HDR standard mode enable(according to <CEA-861-3.2015>) */
542     HDMI_HDR_MODE_CEA_861_3_AUTHEN, /* HDR authen mode */
543     HDMI_HDR_MODE_BUTT
544 };
545 
546 /**
547  * @brief Enumerates hdr user mode,
548  * see HDMI Specification 2.1 for details.
549  *
550  * @since 1.0
551  */
552 enum HdmiHdrUserMode {
553     HDMI_HDR_USERMODE_SDR,
554     HDMI_HDR_USERMODE_HDR10,
555     HDMI_HDR_USERMODE_DOLBY,
556     HDMI_HDR_USERMODE_BUTT
557 };
558 
559 /**
560  * @brief Enumerates static metadata type,
561  * see the section 6.9 of CTA-861-G for details.
562  *
563  * @since 1.0
564  */
565 enum HdmiStaticMetadataType {
566     HDMI_DRM_STATIC_METADATA_TYPE_1 = 0, /* Static Metadata Type 1 */
567     HDMI_DRM_STATIC_METADATA_BUTT,
568 };
569 
570 /**
571  * @brief Enumerates static metadata descriptor1st,
572  * see the section 6.9 of CTA-861-G for details.
573  *
574  * @since 1.0
575  */
576 struct HdmiStaticMetadataDescriptor1st {
577     uint16_t displayPrimaries0X;            /* display_primaries_x[0], in units of 0.00002 */
578     uint16_t displayPrimaries0Y;            /* display_primaries_y[0], in units of 0.00002 */
579     uint16_t displayPrimaries1X;            /* display_primaries_x[1], in units of 0.00002 */
580     uint16_t displayPrimaries1Y;            /* display_primaries_y[1], in units of 0.00002 */
581     uint16_t displayPrimaries2X;            /* display_primaries_x[2], in units of 0.00002 */
582     uint16_t displayPrimaries2Y;            /* display_primaries_y[2], in units of 0.00002 */
583     uint16_t whitePointX;                   /* white_point_x, in units of 0.00002 */
584     uint16_t whitePointY;                   /* white_point_y, in units of 0.00002 */
585     uint16_t maxDisplayMasteringLuminance;  /* max_display_mastering_luminance, in units of 1 cd/m^2 */
586     uint16_t minDisplayMasteringLuminance;  /* min_display_mastering_luminance, in units of 0.0001 cd/m^2 */
587     uint16_t maxContentLightLevel;          /* Maximum Content Light Level, in units of 1 cd/m^2 */
588     uint16_t maxFrameAverageLightLevel;     /* Maximum Frame-average Light Level, in units of 1 cd/m^2 */
589 };
590 
591 /**
592  * @brief Defines the static metadata descriptor,
593  * see the section 6.9 of CTA-861-G for details.
594  *
595  * @since 1.0
596  */
597 union HdmiStaticMetadataDescriptor {
598     struct HdmiStaticMetadataDescriptor1st type1;
599 };
600 
601 /**
602  * @brief Defines the hdr attribute struct.
603  *
604  * @since 1.0
605  */
606 struct HdmiHdrAttr {
607     enum HdmiHdrMode mode;
608     enum HdmiHdrUserMode userMode;
609     /* The following members are valid, when mode is HDMI_HDR_MODE_CEA_861_3. */
610     enum HdmiEotfType eotfType;
611     enum HdmiStaticMetadataType metadataType;
612     union HdmiStaticMetadataDescriptor descriptor;
613     enum HdmiHdrColormetry colorimetry;
614 };
615 
616 /**
617  * @brief Defines the hdmi HPD(Hot Plug Detect) callback info.
618  *
619  * @since 1.0
620  */
621 struct HdmiHpdCallbackInfo {
622     void *data;
623     void (*callbackFunc)(void *data, bool hdp);
624 };
625 
626 /**
627  * @brief Opens an HDMI controller with a specified bus number.
628  *
629  * Before using the HDMI interface, you can obtain the device handle of the HDMI controller
630  * by calling {@link HdmiOpen}. This function is used in pair with {@link HdmiClose}.
631  *
632  * @param busNum Indicates the bus number.
633  *
634  * @return Returns the device handle {@link DevHandle} of the HDMI controller if the operation is successful;
635  * returns <b>NULL</b> otherwise.
636  *
637  * @since 1.0
638  */
639 DevHandle HdmiOpen(uint16_t busNum);
640 
641 /**
642  * @brief HDMI transmission start.
643  *
644  * This function is used in pair with {@link HdmiStop}.
645  *
646  * @param handle Indicates the pointer to the device handle of the HDMI controller.
647  *
648  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
649  *
650  * @since 1.0
651  */
652 int32_t HdmiStart(DevHandle handle);
653 
654 /**
655  * @brief HDMI transmission stop.
656  *
657  * This function is used in pair with {@link HdmiStart}.
658  *
659  * @param handle Indicates the pointer to the device handle of the HDMI controller.
660  *
661  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
662  *
663  * @since 1.0
664  */
665 int32_t HdmiStop(DevHandle handle);
666 
667 /**
668  * @brief HDMI Avmute set.
669  *
670  * First put the display device into the black screen mute state, waitting for the HDMI output device switch,
671  * and then send a Clear AVMute signal, so that the display device to boot, so that the switching process of
672  * the screen will be shielded.
673  *
674  * @param handle Indicates the pointer to the device handle of the HDMI controller.
675  * @param enable Indicates whether to enable avmute.
676  *
677  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
678  *
679  * @since 1.0
680  */
681 int32_t HdmiAvmuteSet(DevHandle handle, bool enable);
682 
683 
684 /**
685  * @brief HDMI deep color set.
686  *
687  * @param handle Indicates the pointer to the device handle of the HDMI controller.
688  * @param color Indicates the deep color to be set, see {@link HdmiDeepColor}.
689  *
690  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
691  *
692  * @since 1.0
693  */
694 int32_t HdmiDeepColorSet(DevHandle handle, enum HdmiDeepColor color);
695 
696 /**
697  * @brief HDMI deep color get.
698  *
699  * @param handle Indicates the pointer to the device handle of the HDMI controller.
700  * @param color Indicates the pointer to the deep color to read, see {@link HdmiDeepColor}.
701  *
702  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
703  *
704  * @since 1.0
705  */
706 int32_t HdmiDeepColorGet(DevHandle handle, enum HdmiDeepColor *color);
707 
708 /**
709  * @brief HDMI set video attribute.
710  *
711  * @param handle Indicates the pointer to the device handle of the HDMI controller.
712  * @param attr Indicates the pointer to the video attribute to set, see {@link HdmiVideoAttr}.
713  *
714  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
715  *
716  * @since 1.0
717  */
718 int32_t HdmiSetVideoAttribute(DevHandle handle, struct HdmiVideoAttr *attr);
719 
720 /**
721  * @brief HDMI set audio attribute.
722  *
723  * @param handle Indicates the pointer to the device handle of the HDMI controller.
724  * @param attr Indicates the pointer to the audio attribute to set, see {@link HdmiAudioAttr}.
725  *
726  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
727  *
728  * @since 1.0
729  */
730 int32_t HdmiSetAudioAttribute(DevHandle handle, struct HdmiAudioAttr *attr);
731 
732 /**
733  * @brief HDMI set hdr attribute.
734  *
735  * @param handle Indicates the pointer to the device handle of the HDMI controller.
736  * @param attr Indicates the pointer to the hdr attribute to set, see {@link HdmiHdrAttr}.
737  *
738  * @return Returns <b>0</b> if the operation is successful; returns a negative value if the operation fails.
739  *
740  * @since 1.0
741  */
742 int32_t HdmiSetHdrAttribute(DevHandle handle, struct HdmiHdrAttr *attr);
743 
744 /**
745  * @brief HDMI read sink device's raw EDID data.
746  *
747  * @param handle Indicates the pointer to the device handle of the HDMI controller.
748  * @param buffer Indicates the pointer to the data to read.
749  * @param len Indicates the length of the data to read.
750  *
751  * @return Returns the length of the data read if the operation is successful;
752  * returns a negative value or 0 if the operation fails.
753  *
754  * @since 1.0
755  */
756 int32_t HdmiReadSinkEdid(DevHandle handle, uint8_t *buffer, uint32_t len);
757 
758 /**
759  * @brief HDMI register HPD(Hot Plug Detect) callback function.
760  *
761  * @param handle Indicates the pointer to the device handle of the HDMI controller.
762  * @param callback Indicates the pointer to the callback info.
763  *
764  * @return Returns the length of the data read if the operation is successful;
765  * returns a negative value or 0 if the operation fails.
766  *
767  * @since 1.0
768  */
769 int32_t HdmiRegisterHpdCallbackFunc(DevHandle handle, struct HdmiHpdCallbackInfo *callback);
770 
771 /**
772  * @brief HDMI unregister HPD(Hot Plug Detect) callback function.
773  *
774  * @param handle Indicates the pointer to the device handle of the HDMI controller.
775  *
776  * @return Returns the length of the data read if the operation is successful;
777  * returns a negative value or 0 if the operation fails.
778  *
779  * @since 1.0
780  */
781 int32_t HdmiUnregisterHpdCallbackFunc(DevHandle handle);
782 
783 /**
784  * @brief Closes an HDMI controller.
785  *
786  * After the HDMI interface is used, you can close the HDMI controller by calling {@link HdmiClose}.
787  * This function is used in pair with {@link HdmiOpen}.
788  *
789  * @param handle Indicates the pointer to the device handle of the HDMI controller.
790  *
791  * @since 1.0
792  */
793 void HdmiClose(DevHandle handle);
794 
795 #ifdef __cplusplus
796 #if __cplusplus
797 }
798 #endif
799 #endif /* __cplusplus */
800 
801 #endif /* HDMI_IF_H */
802