• 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 #ifndef HDMI_COMMON_H
10 #define HDMI_COMMON_H
11 
12 #include "hdf_base.h"
13 #include "hdmi_if.h"
14 
15 #ifdef __cplusplus
16 #if __cplusplus
17 extern "C" {
18 #endif
19 #endif /* __cplusplus */
20 
21 #define HDMI_CEA_VIDEO_CODE_MAX 44
22 #define HDMI_VESA_VIDEO_CODE_MAX 31
23 #define HDMI_VIDEO_4K_CODES_MAX 4
24 
25 #define HDMI_BIT0_MARK 0x01
26 #define HDMI_BIT1_MARK 0x02
27 #define HDMI_BIT2_MARK 0x04
28 #define HDMI_BIT3_MARK 0x08
29 #define HDMI_BIT4_MARK 0x10
30 #define HDMI_BIT5_MARK 0x20
31 #define HDMI_BIT6_MARK 0x40
32 #define HDMI_BIT7_MARK 0x80
33 #define HDMI_UPPER_NIBBLE_MARK 0xf0
34 #define HDMI_LOWER_NIBBLE_MARK 0x0f
35 #define HDMI_BITS_OF_ONE_BYTE 8
36 #define HDMI_ONE_BYTE_SHIFT 8
37 #define HDMI_6_BITS_SHIFT 6
38 #define HDMI_NIBBLE_SHIFT 4
39 #define HDMI_2_BITS_SHIFT 2
40 #define HDMI_ONE_BYTE_MARK 0xFF
41 #define HDMI_TWO_BYTES_SHIFT 16
42 
43 #define HDMI_HDMI14_MAX_TMDS_RATE 340000  /* unit: KHz */
44 #define HDMI_HDMI20_MAX_TMDS_RATE 600000  /* unit: KHz */
45 #define HDMI_MULTIPLE_2P0(x)    (2 * (x))
46 #define HDMI_MULTIPLE_1P5(x)    (((x) * 3) >> 1)
47 #define HDMI_MULTIPLE_1P25(x)   (((x) * 5) >> 2)
48 #define HDMI_MULTIPLE_0P5(x)    ((x) >> 1)
49 
50 enum HdmiTmdsModeType {
51     HDMI_TMDS_MODE_NULL = 0,
52     HDMI_TMDS_MODE_DVI = 1,
53     HDMI_TMDS_MODE_HDMI_1_4 = 2,
54     HDMI_TMDS_MODE_HDMI_2_0 = 3,
55     HDMI_TMDS_MODE_AUTO = 4,
56     HDMI_TMDS_MODE_HDMI_2_1 = 5,
57     HDMI_TMDS_MODE_BUTT,
58 };
59 
60 /*
61  * Video Identification Code (VIC).
62  * see CTA-861-G, table 3.
63  */
64 enum HdmiVic {
65     HDMI_VIC_NONE = 0,    /* No Video Identification Code Available(Used with AVI InfoFrame only) */
66     HDMI_VIC_640X480P60_4_3 = 1,
67     HDMI_VIC_720X480P60_4_3 = 2,
68     HDMI_VIC_720X480P60_16_9 = 3,
69     HDMI_VIC_1280X720P60_16_9 = 4,
70     HDMI_VIC_1920X1080I60_16_9 = 5,
71     HDMI_VIC_1440X480I60_4_3 = 6,
72     HDMI_VIC_1440X480I60_16_9 = 7,
73     HDMI_VIC_1440X240P60_4_3 = 8,
74     HDMI_VIC_1440X240P60_16_9 = 9,
75     HDMI_VIC_2880X480I60_4_3 = 10,
76     HDMI_VIC_2880X480I60_16_9 = 11,
77     HDMI_VIC_2880X240P60_4_3 = 12,
78     HDMI_VIC_2880X240P60_16_9 = 13,
79     HDMI_VIC_1440X480P60_4_3 = 14,
80     HDMI_VIC_1440X480P60_16_9 = 15,
81     HDMI_VIC_1920X1080P60_16_9 = 16,
82     HDMI_VIC_720X576P50_4_3 = 17,
83     HDMI_VIC_720X576P50_16_9 = 18,
84     HDMI_VIC_1280X720P50_16_9 = 19,
85     HDMI_VIC_1920X1080I50_16_9 = 20,
86     HDMI_VIC_1440X576I50_4_3 = 21,
87     HDMI_VIC_1440X576I50_16_9 = 22,
88     HDMI_VIC_1440X288P50_4_3 = 23,
89     HDMI_VIC_1440X288P50_16_9 = 24,
90     HDMI_VIC_2880X576I50_4_3 = 25,
91     HDMI_VIC_2880X576I50_16_9 = 26,
92     HDMI_VIC_2880X288P50_4_3 = 27,
93     HDMI_VIC_2880X288P50_16_9 = 28,
94     HDMI_VIC_1440X576P50_4_3 = 29,
95     HDMI_VIC_1440X576P50_16_9 = 30,
96     HDMI_VIC_1920X1080P50_16_9 = 31,
97     HDMI_VIC_1920X1080P24_16_9 = 32,
98     HDMI_VIC_1920X1080P25_16_9 = 33,
99     HDMI_VIC_1920X1080P30_16_9 = 34,
100     HDMI_VIC_2880X480P60_4_3 = 35,
101     HDMI_VIC_2880X480P60_16_9 = 36,
102     HDMI_VIC_2880X576P50_4_3 = 37,
103     HDMI_VIC_2880X576P50_16_9 = 38,
104     HDMI_VIC_1920X1080I50_1250_16_9 = 39,
105     HDMI_VIC_1920X1080I100_16_9 = 40,
106     HDMI_VIC_1280X720P100_16_9 = 41,
107     HDMI_VIC_720X576P100_4_3 = 42,
108     HDMI_VIC_720X576P100_16_9 = 43,
109     HDMI_VIC_1440X576I100_4_3 = 44,
110     HDMI_VIC_1440X576I100_16_9 = 45,
111     HDMI_VIC_1920X1080I120_16_9 = 46,
112     HDMI_VIC_1280X720P120_16_9 = 47,
113     HDMI_VIC_720X480P120_4_3 = 48,
114     HDMI_VIC_720X480P120_16_9 = 49,
115     HDMI_VIC_1440X480I120_4_3 = 50,
116     HDMI_VIC_1440X480I120_16_9 = 51,
117     HDMI_VIC_720X576P200_4_3 = 52,
118     HDMI_VIC_720X576P200_16_9 = 53,
119     HDMI_VIC_1440X576I120_4_3 = 54,
120     HDMI_VIC_1440X576I120_16_9 = 55,
121     HDMI_VIC_720X480P240_4_3 = 56,
122     HDMI_VIC_720X480P240_16_9 = 57,
123     HDMI_VIC_1440X480I240_4_3 = 58,
124     HDMI_VIC_1440X480I240_16_9 = 59,
125     HDMI_VIC_1280X720P24_16_9 = 60,
126     HDMI_VIC_1280X720P25_16_9 = 61,
127     HDMI_VIC_1280X720P30_16_9 = 62,
128     HDMI_VIC_1920X1080P120_16_9 = 63,
129     HDMI_VIC_1920X1080P100_16_9 = 64,
130     HDMI_VIC_1280X720P24_64_27 = 65,
131     HDMI_VIC_1280X720P25_64_27 = 66,
132     HDMI_VIC_1280X720P30_64_27 = 67,
133     HDMI_VIC_1280X720P50_64_27 = 68,
134     HDMI_VIC_1280X720P60_64_27 = 69,
135     HDMI_VIC_1280X720P100_64_27 = 70,
136     HDMI_VIC_1280X720P120_64_27 = 71,
137     HDMI_VIC_1920X1080P24_64_27 = 72,
138     HDMI_VIC_1920X1080P25_64_27 = 73,
139     HDMI_VIC_1920X1080P30_64_27 = 74,
140     HDMI_VIC_1920X1080P50_64_27 = 75,
141     HDMI_VIC_1920X1080P60_64_27 = 76,
142     HDMI_VIC_1920X1080P100_64_27 = 77,
143     HDMI_VIC_1920X1080P120_64_27 = 78,
144     HDMI_VIC_1680X720P24_64_27 = 79,
145     HDMI_VIC_1680X720P25_64_27 = 80,
146     HDMI_VIC_1680X720P30_64_27 = 81,
147     HDMI_VIC_1680X720P50_64_27 = 82,
148     HDMI_VIC_1680X720P60_64_27 = 83,
149     HDMI_VIC_1680X720P100_64_27 = 84,
150     HDMI_VIC_1680X720P120_64_27 = 85,
151     HDMI_VIC_2560X1080P24_64_27 = 86,
152     HDMI_VIC_2560X1080P25_64_27 = 87,
153     HDMI_VIC_2560X1080P30_64_27 = 88,
154     HDMI_VIC_2560X1080P50_64_27 = 89,
155     HDMI_VIC_2560X1080P60_64_27 = 90,
156     HDMI_VIC_2560X1080P100_64_27 = 91,
157     HDMI_VIC_2560X1080P120_64_27 = 92,
158     HDMI_VIC_3840X2160P24_16_9 = 93,
159     HDMI_VIC_3840X2160P25_16_9 = 94,
160     HDMI_VIC_3840X2160P30_16_9 = 95,
161     HDMI_VIC_3840X2160P50_16_9 = 96,
162     HDMI_VIC_3840X2160P60_16_9 = 97,
163     HDMI_VIC_4096X2160P24_256_135 = 98,
164     HDMI_VIC_4096X2160P25_256_135 = 99,
165     HDMI_VIC_4096X2160P30_256_135 = 100,
166     HDMI_VIC_4096X2160P50_256_135 = 101,
167     HDMI_VIC_4096X2160P60_256_135 = 102,
168     HDMI_VIC_3840X2160P24_64_27 = 103,
169     HDMI_VIC_3840X2160P25_64_27 = 104,
170     HDMI_VIC_3840X2160P30_64_27 = 105,
171     HDMI_VIC_3840X2160P50_64_27 = 106,
172     HDMI_VIC_3840X2160P60_64_27 = 107,
173     HDMI_VIC_1280X720P48_16_9 = 108,
174     HDMI_VIC_1280X720P48_64_27 = 109,
175     HDMI_VIC_1680X720P48_64_27 = 110,
176     HDMI_VIC_1920X1080P48_16_9 = 111,
177     HDMI_VIC_1920X1080P48_64_27 = 112,
178     HDMI_VIC_2560X1080P48_64_27 = 113,
179     HDMI_VIC_3840X2160P48_16_9 = 114,
180     HDMI_VIC_4096X2160P48_256_135 = 115,
181     HDMI_VIC_3840X2160P48_64_27 = 116,
182     HDMI_VIC_3840X2160P100_16_9 = 117,
183     HDMI_VIC_3840X2160P120_16_9 = 118,
184     HDMI_VIC_3840X2160P100_64_27 = 119,
185     HDMI_VIC_3840X2160P120_64_27 = 120,
186     HDMI_VIC_5120X2160P24_64_27 = 121,
187     HDMI_VIC_5120X2160P25_64_27 = 122,
188     HDMI_VIC_5120X2160P30_64_27 = 123,
189     HDMI_VIC_5120X2160P48_64_27 = 124,
190     HDMI_VIC_5120X2160P50_64_27 = 125,
191     HDMI_VIC_5120X2160P60_64_27 = 126,
192     HDMI_VIC_5120X2160P100_64_27 = 127,
193     HDMI_VIC_5120X2160P120_64_27 = 193,
194     HDMI_VIC_7680X4320P24_16_9 = 194,
195     HDMI_VIC_7680X4320P25_16_9 = 195,
196     HDMI_VIC_7680X4320P30_16_9 = 196,
197     HDMI_VIC_7680X4320P48_16_9 = 197,
198     HDMI_VIC_7680X4320P50_16_9 = 198,
199     HDMI_VIC_7680X4320P60_16_9 = 199,
200     HDMI_VIC_7680X4320P100_16_9 = 200,
201     HDMI_VIC_7680X4320P120_16_9 = 201,
202     HDMI_VIC_7680X4320P24_64_27 = 202,
203     HDMI_VIC_7680X4320P25_164_27 = 203,
204     HDMI_VIC_7680X4320P30_64_27 = 204,
205     HDMI_VIC_7680X4320P48_64_27 = 205,
206     HDMI_VIC_7680X4320P50_64_27 = 206,
207     HDMI_VIC_7680X4320P60_64_27 = 207,
208     HDMI_VIC_7680X4320P100_64_27 = 208,
209     HDMI_VIC_7680X4320P120_64_27 = 209,
210     HDMI_VIC_10240X4320P24_64_27 = 210,
211     HDMI_VIC_10240X4320P25_64_27 = 211,
212     HDMI_VIC_10240X4320P30_64_27 = 212,
213     HDMI_VIC_10240X4320P48_64_27 = 213,
214     HDMI_VIC_10240X4320P50_64_27 = 214,
215     HDMI_VIC_10240X4320P60_64_27 = 215,
216     HDMI_VIC_10240X4320P100_64_27 = 216,
217     HDMI_VIC_10240X4320P120_64_27 = 217,
218     HDMI_VIC_4096X2160P100_256_135 = 218,
219     HDMI_VIC_4096X2160P120_256_135 = 219,
220 };
221 
222 enum HdmiVideoFormatType {
223     HDMI_VIDEO_FORMAT_NULL = 0,
224     HDMI_VIDEO_FORMAT_PROGRESSIVE = 1,
225     HDMI_VIDEO_FORMA_INTERLACE = 2,
226     HDMI_VIDEO_FORMA_BUTT,
227 };
228 
229 enum HdmiColorDeep {
230     HDMI_COLOR_DEEP_8BITS = 8,
231     HDMI_COLOR_DEEP_10BITS = 10,
232     HDMI_COLOR_DEEP_12BITS = 12,
233     HDMI_COLOR_DEEP_16BITS = 16,
234     HDMI_COLOR_DEEP_BUTT,
235 };
236 
237 enum HdmiPhyModeCfg {
238     HDMI_PHY_MODE_TMDS = 0,
239     HDMI_PHY_MODE_FRL = 1,
240     HDMI_PHY_MODE_TXFFE = 2,
241     HDMI_PHY_MODE_BUTT,
242 };
243 
244 enum HdmiHdcpMode {
245     HDMI_HDCP_MODE_AUTO = 0,
246     HDMI_HDCP_MODE_1_4 = 1,
247     HDMI_HDCP_MODE_2_2 = 2,
248     HDMI_HDCP_MODE_BUTT
249 };
250 
251 struct HdmiVideoDefInfo {
252     enum HdmiVic vic;
253     uint32_t pixclk;
254     uint32_t rate;
255     uint32_t hactive;
256     uint32_t vactive;
257     uint32_t hblank;
258     uint32_t vblank;
259     uint32_t hfront;
260     uint32_t hsync;
261     uint32_t hback;
262     uint32_t vfront;
263     uint32_t vsync;
264     uint32_t vback;
265     enum HdmiPictureAspectRatio aspect;
266     enum HdmiVideoTiming timing;
267     enum HdmiVideoFormatType formatType;
268 };
269 
270 /* see hdmi spec2.0 table 10-2. */
271 enum Hdmi4kVic {
272     HDMI_4K_VIC_3840X2160_30 = 1,
273     HDMI_4K_VIC_3840X2160_25,
274     HDMI_4K_VIC_3840X2160_24,
275     HDMI_4K_VIC_4096X2160_24
276 };
277 
278 struct HdmiVideo4kInfo {
279     enum Hdmi4kVic _4kVic;
280     enum HdmiVic vic;
281     uint32_t pixclk;
282     uint32_t rate;
283     uint32_t hactive;
284     uint32_t vactive;
285     enum HdmiPictureAspectRatio aspect;
286     enum HdmiVideoTiming timing;
287     enum HdmiVideoFormatType formatType;
288 };
289 
290 struct HdmiCommonStatus {
291     bool hotplug;
292     bool avmute;
293     bool sinkPowerOn;
294     enum HdmiTmdsModeType tmdsMode;
295 };
296 
297 struct HdmiAudioStatus {
298     bool mute;
299     bool enable;
300     bool downSample;
301     enum HdmiSampleRate sampleRate;
302     enum HdmiAudioInterfaceType interface;
303     enum HdmiAudioBitDepth bitDepth;
304     enum HdmiAudioFormatChannel channel;
305     uint32_t refN;
306     uint32_t regN;
307     uint32_t refCts;
308     uint32_t regCts;
309 };
310 
311 struct HdmiVideoStatus {
312     bool mute;
313     bool ycbcr2Rgb;
314     bool rgb2Ycbcr;
315     bool ycbcr444422;
316     bool ycbcr422420;
317     bool ycbcr420422;
318     bool ycbcr422444;
319     bool in420Ydemux;
320     bool out420Ydemux;
321     bool vSyncPol;
322     bool hSyncPol;
323     bool syncPol;
324     bool dePol;
325     bool swapHsCs;
326     enum HdmiColorSpace inColorSpace;
327     enum HdmiColorSpace outColorSpace;
328     enum HdmiVideoBitDepth outBitDepth;
329     enum HdmiQuantizationRange quantization;
330 };
331 
332 struct HdmiCommonAttr {
333     bool enableHdmi;
334     bool enableVideo;
335     bool enableAudio;
336     bool xvyccMode;
337     bool avi;
338     bool spd;
339     bool mpeg;
340     bool audio;
341     bool drm;
342     bool hdcpEnable;
343     bool vsifDolby;
344     enum HdmiColorSpace  colorSpace;
345     enum HdmiQuantizationRange quantization;
346     enum HdmiDeepColor deepColor;
347     enum HdmiHdcpMode hdcpMode;
348 };
349 
350 enum HdmiVideoBitDepth HdmiCommonDeepClolorConvertToColorDepth(enum HdmiDeepColor deepColor);
351 enum HdmiDeepColor HdmiCommonColorDepthConvertToDeepClolor(enum HdmiVideoBitDepth colorDepth);
352 enum HdmiVic HdmiCommonGetVic(enum HdmiVideoTiming timing,
353     enum HdmiPictureAspectRatio aspect, bool enable3d);
354 struct HdmiVideoDefInfo *HdmiCommonGetVideoDefInfo(enum HdmiVideoTiming timing,
355     enum HdmiPictureAspectRatio aspect, bool enable3d);
356 struct HdmiVideo4kInfo *HdmiCommonGetVideo4kInfo(uint32_t _4kVic);
357 enum HdmiVideoTiming HdmiCommonGetVideoTiming(enum HdmiVic vic, enum HdmiPictureAspectRatio aspect);
358 enum HdmiVideoTiming HdmiCommonGetVideo4kTiming(uint32_t _4kVic);
359 
360 #ifdef __cplusplus
361 #if __cplusplus
362 }
363 #endif
364 #endif /* __cplusplus */
365 
366 #endif /* HDMI_COMMON_H */
367