• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #include "hdmi_common.h"
10 #include "hdf_log.h"
11 
12 #define HDF_LOG_TAG hdmi_common_c
13 
14 /*
15  * vic, pixel clk, vfreq, hactive, vactive, hblank, vblank, hfront, hsync, hback, vfront, vsync, vback, aspect,
16  * timing, I/P
17  */
18 struct HdmiVideoDefInfo g_ceaVideoDefInfoMap[HDMI_CEA_VIDEO_CODE_MAX] = {
19     { 0,                              0,       0,      0,    0,    0,    0,   0,    0,   0,   0,  0,  0,
20       HDMI_PICTURE_ASPECT_NO_DATA, HDMI_VIDEO_TIMING_NONE,         HDMI_VIDEO_FORMAT_NULL },
21     { HDMI_VIC_640X480P60_4_3,        25175,   59940,  640,  480,  160,  45,  16,   96,  48,  10, 2,  33,
22       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_640X480P60,   HDMI_VIDEO_FORMAT_PROGRESSIVE },
23     { HDMI_VIC_720X480P60_4_3,        27000,   59940,  720,  480,  138,  45,  16,   62,  60,  9,  6,  30,
24       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_720X480P60,   HDMI_VIDEO_FORMAT_PROGRESSIVE },
25     { HDMI_VIC_720X480P60_16_9,       27000,   59940,  720,  480,  138,  45,  16,   62,  60,  9,  6,  30,
26       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_720X480P60,   HDMI_VIDEO_FORMAT_PROGRESSIVE },
27     { HDMI_VIC_1280X720P60_16_9,      74250,   60000,  1280, 720,  370,  30,  110,  40,  220, 5,  5,  20,
28       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1280X720P60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
29     { HDMI_VIC_1920X1080I60_16_9,     74250,   60000,  1920, 1080, 280,  22,  88,   44,  148, 2,  5,  15,
30       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080I60, HDMI_VIDEO_FORMA_INTERLACE },
31     { HDMI_VIC_1440X480I60_4_3,       27000,   59940,  1440, 480,  276,  22,  38,   124, 114, 4,  3,  15,
32       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_1440X480I60,  HDMI_VIDEO_FORMA_INTERLACE },
33     { HDMI_VIC_1440X480I60_16_9,      27000,   59940,  1440, 480,  276,  22,  38,   124, 114, 4,  3,  15,
34       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1440X480I60,  HDMI_VIDEO_FORMA_INTERLACE },
35     { HDMI_VIC_1440X240P60_4_3,       27000,   60054,  1440, 240,  276,  22,  38,   124, 114, 4,  3,  15,
36       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_1440X240P60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
37     { HDMI_VIC_1440X240P60_16_9,      27000,   60054,  1440, 240,  276,  22,  38,   124, 114, 4,  3,  15,
38       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1440X240P60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
39     { HDMI_VIC_2880X480I60_4_3,       54000,   59940,  2880, 480,  552,  22,  76,   248, 228, 4,  3,  15,
40       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_2880X480I60,  HDMI_VIDEO_FORMA_INTERLACE },
41     { HDMI_VIC_2880X480I60_16_9,      54000,   59940,  2880, 480,  552,  22,  76,   248, 228, 4,  3,  15,
42       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_2880X480I60,  HDMI_VIDEO_FORMA_INTERLACE },
43     { HDMI_VIC_2880X240P60_4_3,       54000,   60054,  2880, 240,  552,  22,  76,   248, 228, 4,  3,  15,
44       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_2880X240I60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
45     { HDMI_VIC_2880X240P60_16_9,      54000,   60054,  2880, 240,  552,  23,  76,   248, 228, 4,  3,  15,
46       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_2880X240I60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
47     { HDMI_VIC_1440X480P60_4_3,       54000,   59940,  1440, 480,  276,  45,  32,   124, 120, 9,  6,  30,
48       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_1440X480P60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
49     { HDMI_VIC_1440X480P60_16_9,      54000,   59940,  1440, 480,  276,  45,  32,   124, 120, 9,  6,  30,
50       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1440X480P60,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
51     { HDMI_VIC_1920X1080P60_16_9,     148500,  60000,  1920, 1080, 280,  45,  88,   44,  148, 4,  5,  36,
52       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080P60, HDMI_VIDEO_FORMAT_PROGRESSIVE },
53     { HDMI_VIC_720X576P50_4_3,        27000,   50000,  720,  576,  144,  49,  12,   64,  68,  5,  5,  39,
54       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_720X576P50,   HDMI_VIDEO_FORMAT_PROGRESSIVE },
55     { HDMI_VIC_720X576P50_16_9,       27000,   50000,  720,  576,  144,  49,  12,   64,  68,  5,  5,  39,
56       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_720X576P50,   HDMI_VIDEO_FORMAT_PROGRESSIVE },
57     { HDMI_VIC_1280X720P50_16_9,      74250,   50000,  1280, 720,  700,  30,  440,  40,  220, 5,  5,  20,
58       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1280X720P50,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
59     { HDMI_VIC_1920X1080I50_16_9,     74250,   50000,  1920, 1080, 720,  24,  528,  44,  148, 2,  5,  15,
60       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080I50, HDMI_VIDEO_FORMA_INTERLACE },
61     { HDMI_VIC_1440X576I50_4_3,       27000,   50000,  1440, 576,  288,  24,  24,   126, 138, 2,  3,  19,
62       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_1440X576I50,  HDMI_VIDEO_FORMA_INTERLACE },
63     { HDMI_VIC_1440X576I50_16_9,      27000,   50000,  1440, 576,  288,  24,  24,   126, 138, 2,  3,  19,
64       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1440X576I50,  HDMI_VIDEO_FORMA_INTERLACE },
65     { HDMI_VIC_1440X576P50_4_3,       54000,   50000,  1440, 576,  288,  49,  24,   128, 136, 5,  5,  39,
66       HDMI_PICTURE_ASPECT_4_3,     HDMI_VIDEO_TIMING_1440X576P50,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
67     { HDMI_VIC_1440X576P50_16_9,      54000,   50000,  1440, 576,  288,  49,  24,   128, 136, 5,  5,  39,
68       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1440X576P50,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
69     { HDMI_VIC_1920X1080P50_16_9,     148500,  50000,  1920, 1080, 720,  45,  528,  44,  148, 4,  5,  36,
70       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080P50, HDMI_VIDEO_FORMAT_PROGRESSIVE },
71     { HDMI_VIC_1920X1080P24_16_9,     742500,  24000,  1920, 1080, 830,  45,  638,  44,  148, 4,  5,  36,
72       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080P24, HDMI_VIDEO_FORMAT_PROGRESSIVE },
73     { HDMI_VIC_1920X1080P25_16_9,     742500,  25000,  1920, 1080, 720,  45,  528,  44,  148, 4,  5,  36,
74       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080P25, HDMI_VIDEO_FORMAT_PROGRESSIVE },
75     { HDMI_VIC_1920X1080P30_16_9,     742500,  30000,  1920, 1080, 280,  45,  88,   44,  148, 4,  5,  36,
76       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_1920X1080P30, HDMI_VIDEO_FORMAT_PROGRESSIVE },
77     { HDMI_VIC_3840X2160P24_16_9,     297000,  24000,  3840, 2160, 1660, 90,  1276, 88,  296, 8,  10, 72,
78       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P24, HDMI_VIDEO_FORMAT_PROGRESSIVE },
79     { HDMI_VIC_3840X2160P25_16_9,     297000,  25000,  3840, 2160, 1440, 90,  1056, 88,  296, 8,  10, 72,
80       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P25, HDMI_VIDEO_FORMAT_PROGRESSIVE },
81     { HDMI_VIC_3840X2160P30_16_9,     297000,  30000,  3840, 2160, 560,  90,  176,  88,  296, 8,  10, 72,
82       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P30, HDMI_VIDEO_FORMAT_PROGRESSIVE },
83     { HDMI_VIC_3840X2160P50_16_9,     594000,  50000,  3840, 2160, 1440, 90,  1056, 88,  296, 8,  10, 72,
84       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P50, HDMI_VIDEO_FORMAT_PROGRESSIVE },
85     { HDMI_VIC_3840X2160P60_16_9,     594000,  60000,  3840, 2160, 560,  90,  176,  88,  296, 8,  10, 72,
86       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P60, HDMI_VIDEO_FORMAT_PROGRESSIVE },
87     { HDMI_VIC_4096X2160P24_256_135,  297000,  24000,  4096, 2160, 1404, 90,  1020, 88,  296, 8,  10, 72,
88       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P24, HDMI_VIDEO_FORMAT_PROGRESSIVE },
89     { HDMI_VIC_4096X2160P25_256_135,  297000,  25000,  4096, 2160, 1184, 90,  968,  88,  128, 8,  10, 72,
90       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P25, HDMI_VIDEO_FORMAT_PROGRESSIVE },
91     { HDMI_VIC_4096X2160P30_256_135,  297000,  30000,  4096, 2160, 304,  90,  88,   88,  128, 8,  10, 72,
92       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P30, HDMI_VIDEO_FORMAT_PROGRESSIVE },
93     { HDMI_VIC_4096X2160P50_256_135,  594000,  50000,  4096, 2160, 1184, 90,  968,  88,  128, 8,  10, 72,
94       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P50, HDMI_VIDEO_FORMAT_PROGRESSIVE },
95     { HDMI_VIC_4096X2160P60_256_135,  594000,  60000,  4096, 2160, 304,  90,  88,   88,  128, 8,  10, 72,
96       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P60, HDMI_VIDEO_FORMAT_PROGRESSIVE },
97     { HDMI_VIC_3840X2160P120_16_9,    1188000, 120000, 3840, 2160, 560,  90,  176,  88,  296, 8,  10, 72,
98       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_3840X2160P120, HDMI_VIDEO_FORMAT_PROGRESSIVE },
99     { HDMI_VIC_7680X4320P24_16_9,     1188000, 24000,  7680, 4320, 3320, 180, 2552, 176, 592, 16, 20, 144,
100       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_7680X4320P24, HDMI_VIDEO_FORMAT_PROGRESSIVE },
101     { HDMI_VIC_7680X4320P25_16_9,     1188000, 25000,  7680, 4320, 3120, 80,  2352, 176, 592, 16, 20, 44,
102       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_7680X4320P25, HDMI_VIDEO_FORMAT_PROGRESSIVE },
103     { HDMI_VIC_7680X4320P30_16_9,     1188000, 30000,  7680, 4320, 1320, 80,  552,  176, 592, 16, 20, 44,
104       HDMI_PICTURE_ASPECT_16_9,    HDMI_VIDEO_TIMING_7680X4320P30, HDMI_VIDEO_FORMAT_PROGRESSIVE },
105     { HDMI_VIC_4096X2160P120_256_135, 1188000, 120000, 4096, 2160, 304,  90,  88,   88,  128, 8,  10, 72,
106       HDMI_PICTURE_ASPECT_256_135, HDMI_VIDEO_TIMING_4096X2160P120, HDMI_VIDEO_FORMAT_PROGRESSIVE }
107 };
108 
109 struct HdmiVideoDefInfo g_vesaVideoDefInfoMap[HDMI_VESA_VIDEO_CODE_MAX] = {
110     { 0, 0,      0,     0,    0,    0,   0,   0,   0,   0,   0, 0, 0,  HDMI_PICTURE_ASPECT_NO_DATA,
111         HDMI_VIDEO_TIMING_NONE,               HDMI_VIDEO_FORMAT_NULL },
112     { 0, 40000,  60317, 800,  600,  256, 28,  40,  128, 88,  1, 4, 23, HDMI_PICTURE_ASPECT_16_9,
113         HDMI_VIDEO_TIMING_VESA_800X600_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
114     { 0, 33750,  60000, 848,  480,  240, 37,  16,  112, 112, 6, 8, 23, HDMI_PICTURE_ASPECT_16_9,
115         HDMI_VIDEO_TIMING_VESA_848X480_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
116     { 0, 65000,  60004, 1024, 768,  320, 38,  24,  136, 160, 3, 6, 29, HDMI_PICTURE_ASPECT_16_9,
117       HDMI_VIDEO_TIMING_VESA_1024X768_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
118     { 0, 74250,  60000, 1280, 720,  370, 30,  110, 40,  220, 5, 5, 20, HDMI_PICTURE_ASPECT_16_9,
119       HDMI_VIDEO_TIMING_VESA_1280X720_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
120     { 0, 68250,  59995, 1280, 768,  160, 22,  48,  32,  80,  3, 7, 12, HDMI_PICTURE_ASPECT_16_9,
121       HDMI_VIDEO_TIMING_VESA_1280X768_60_RB,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
122     { 0, 79500,  59870, 1280, 768,  384, 30,  64,  128, 192, 3, 7, 20, HDMI_PICTURE_ASPECT_16_9,
123       HDMI_VIDEO_TIMING_VESA_1280X768_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
124     { 0, 71001,  59910, 1280, 800,  160, 23,  48,  32,  80,  3, 6, 14, HDMI_PICTURE_ASPECT_16_9,
125       HDMI_VIDEO_TIMING_VESA_1280X800_60_RB,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
126     { 0, 83500,  59810, 1280, 800,  400, 31,  72,  128, 200, 3, 6, 22, HDMI_PICTURE_ASPECT_16_9,
127       HDMI_VIDEO_TIMING_VESA_1280X800_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
128     { 0, 108000, 60000, 1280, 960,  520, 40,  96,  112, 312, 1, 3, 36, HDMI_PICTURE_ASPECT_16_9,
129       HDMI_VIDEO_TIMING_VESA_1280X960_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
130     { 0, 108000, 60020, 1280, 1024, 408, 42,  48,  112, 248, 1, 3, 38, HDMI_PICTURE_ASPECT_16_9,
131       HDMI_VIDEO_TIMING_VESA_1280X1024_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
132     { 0, 85500,  60015, 1360, 768,  432, 27,  64,  112, 256, 3, 6, 18, HDMI_PICTURE_ASPECT_16_9,
133       HDMI_VIDEO_TIMING_VESA_1360X768_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
134     { 0, 85501,  59790, 1366, 768,  426, 30,  70,  143, 213, 3, 3, 24, HDMI_PICTURE_ASPECT_16_9,
135       HDMI_VIDEO_TIMING_VESA_1366X768_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
136     { 0, 121749, 59978, 1400, 1050, 464, 39,  88,  144, 232, 3, 4, 32, HDMI_PICTURE_ASPECT_16_9,
137       HDMI_VIDEO_TIMING_VESA_1400X1050_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
138     { 0, 88749,  59901, 1440, 900,  160, 26,  48,  32,  80,  3, 6, 17, HDMI_PICTURE_ASPECT_16_9,
139       HDMI_VIDEO_TIMING_VESA_1440X900_60_RB,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
140     { 0, 106499, 59887, 1440, 900,  464, 34,  80,  152, 232, 3, 6, 25, HDMI_PICTURE_ASPECT_16_9,
141       HDMI_VIDEO_TIMING_VESA_1440X900_60,     HDMI_VIDEO_FORMAT_PROGRESSIVE },
142     { 0, 108000, 60000, 1440, 1050, 144, 49,  12,  64,  68,  3, 6, 25, HDMI_PICTURE_ASPECT_16_9,
143       HDMI_VIDEO_TIMING_VESA_1440X1050_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
144     { 0, 108000, 60000, 1440, 1050, 144, 49,  12,  64,  68,  3, 6, 25, HDMI_PICTURE_ASPECT_16_9,
145       HDMI_VIDEO_TIMING_VESA_1440X1050_60_RB, HDMI_VIDEO_FORMAT_PROGRESSIVE },
146     { 0, 108000, 60000, 1600, 900,  200, 100, 24,  80,  96,  1, 3, 96, HDMI_PICTURE_ASPECT_16_9,
147       HDMI_VIDEO_TIMING_VESA_1600X900_60_RB,  HDMI_VIDEO_FORMAT_PROGRESSIVE },
148     { 0, 162000, 60000, 1600, 1200, 560, 50,  64,  192, 304, 1, 3, 46, HDMI_PICTURE_ASPECT_16_9,
149       HDMI_VIDEO_TIMING_VESA_1600X1200_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
150     { 0, 118999, 59883, 1680, 1050, 160, 30,  48,  32,  80,  3, 6, 21, HDMI_PICTURE_ASPECT_16_9,
151       HDMI_VIDEO_TIMING_VESA_1680X1050_60_RB, HDMI_VIDEO_FORMAT_PROGRESSIVE },
152     { 0, 146249, 59954, 1680, 1050, 560, 39,  104, 176, 280, 3, 6, 30, HDMI_PICTURE_ASPECT_16_9,
153       HDMI_VIDEO_TIMING_VESA_1680X1050_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
154     { 0, 204751, 60000, 1792, 1344, 656, 50,  128, 200, 328, 1, 3, 46, HDMI_PICTURE_ASPECT_16_9,
155       HDMI_VIDEO_TIMING_VESA_1792X1344_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
156     { 0, 218249, 59995, 1856, 1392, 672, 47,  96,  224, 352, 1, 3, 43, HDMI_PICTURE_ASPECT_16_9,
157       HDMI_VIDEO_TIMING_VESA_1856X1392_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
158     { 0, 148500, 60000, 1920, 1080, 280, 45,  88,  44,  148, 4, 5, 36, HDMI_PICTURE_ASPECT_16_9,
159       HDMI_VIDEO_TIMING_VESA_1920X1080_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
160     { 0, 154000, 59950, 1920, 1200, 160, 35,  48,  32,  80,  3, 6, 26, HDMI_PICTURE_ASPECT_16_9,
161       HDMI_VIDEO_TIMING_VESA_1920X1200_60_RB, HDMI_VIDEO_FORMAT_PROGRESSIVE },
162     { 0, 193251, 59885, 1920, 1200, 672, 45,  136, 200, 336, 3, 6, 36, HDMI_PICTURE_ASPECT_16_9,
163       HDMI_VIDEO_TIMING_VESA_1920X1200_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
164     { 0, 234000, 60000, 1920, 1440, 680, 60,  128, 208, 344, 1, 3, 56, HDMI_PICTURE_ASPECT_16_9,
165       HDMI_VIDEO_TIMING_VESA_1920X1440_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
166     { 0, 162000, 60000, 2048, 1152, 202, 48,  26,  80,  96,  1, 3, 44, HDMI_PICTURE_ASPECT_16_9,
167       HDMI_VIDEO_TIMING_VESA_2048X1152_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
168     { 0, 82500,  50000, 2560, 1440, 520, 30,  260, 40,  220, 3, 3, 24, HDMI_PICTURE_ASPECT_16_9,
169       HDMI_VIDEO_TIMING_VESA_2560X1440_60_RB, HDMI_VIDEO_FORMAT_PROGRESSIVE },
170     { 0, 348502, 59987, 2560, 1600, 944, 58,  192, 280, 472, 3, 6, 49, HDMI_PICTURE_ASPECT_16_9,
171       HDMI_VIDEO_TIMING_VESA_2560X1600_60,    HDMI_VIDEO_FORMAT_PROGRESSIVE },
172 };
173 
174 struct HdmiVideo4kInfo g_video4kInfoMap[HDMI_VIDEO_4K_CODES_MAX] = {
175     { HDMI_4K_VIC_3840X2160_30,     HDMI_VIC_3840X2160P30_16_9,     296703, 30, 3840, 2160,
176       HDMI_PICTURE_ASPECT_16_9,     HDMI_VIDEO_TIMING_3840X2160P30, HDMI_VIDEO_FORMAT_PROGRESSIVE },
177     { HDMI_4K_VIC_3840X2160_25,     HDMI_VIC_3840X2160P25_16_9,     297000, 25, 3840, 2160,
178       HDMI_PICTURE_ASPECT_16_9,     HDMI_VIDEO_TIMING_3840X2160P25, HDMI_VIDEO_FORMAT_PROGRESSIVE },
179     { HDMI_4K_VIC_3840X2160_24,     HDMI_VIC_3840X2160P24_16_9,     296703, 24, 3840, 2160,
180       HDMI_PICTURE_ASPECT_16_9,     HDMI_VIDEO_TIMING_3840X2160P24, HDMI_VIDEO_FORMAT_PROGRESSIVE },
181     { HDMI_4K_VIC_4096X2160_24,     HDMI_VIC_4096X2160P24_256_135,  297000, 24, 4096, 2160,
182       HDMI_PICTURE_ASPECT_256_135,  HDMI_VIDEO_TIMING_4096X2160P24, HDMI_VIDEO_FORMAT_PROGRESSIVE }
183 };
184 
HdmiCommonDeepClolorConvertToColorDepth(enum HdmiDeepColor deepColor)185 enum HdmiVideoBitDepth HdmiCommonDeepClolorConvertToColorDepth(enum HdmiDeepColor deepColor)
186 {
187     enum HdmiVideoBitDepth colorDepth;
188 
189     switch (deepColor) {
190         case HDMI_DEEP_COLOR_24BITS:
191             colorDepth = HDMI_VIDEO_BIT_DEPTH_8;
192             break;
193         case HDMI_DEEP_COLOR_30BITS:
194             colorDepth = HDMI_VIDEO_BIT_DEPTH_10;
195             break;
196         case HDMI_DEEP_COLOR_36BITS:
197             colorDepth = HDMI_VIDEO_BIT_DEPTH_12;
198             break;
199         case HDMI_DEEP_COLOR_48BITS:
200             colorDepth = HDMI_VIDEO_BIT_DEPTH_16;
201             break;
202         default:
203             HDF_LOGD("deep color %d is not support, use default value.", deepColor);
204             colorDepth = HDMI_VIDEO_BIT_DEPTH_8;
205             break;
206     }
207     return colorDepth;
208 }
209 
HdmiCommonColorDepthConvertToDeepClolor(enum HdmiVideoBitDepth colorDepth)210 enum HdmiDeepColor HdmiCommonColorDepthConvertToDeepClolor(enum HdmiVideoBitDepth colorDepth)
211 {
212     enum HdmiDeepColor deepColor;
213 
214     switch (colorDepth) {
215         case HDMI_VIDEO_BIT_DEPTH_8:
216             deepColor = HDMI_DEEP_COLOR_24BITS;
217             break;
218         case HDMI_VIDEO_BIT_DEPTH_10:
219             deepColor = HDMI_DEEP_COLOR_30BITS;
220             break;
221         case HDMI_VIDEO_BIT_DEPTH_12:
222             deepColor = HDMI_DEEP_COLOR_36BITS;
223             break;
224         case HDMI_VIDEO_BIT_DEPTH_16:
225             deepColor = HDMI_DEEP_COLOR_48BITS;
226             break;
227         case HDMI_VIDEO_BIT_DEPTH_OFF:
228             deepColor = HDMI_DEEP_COLOR_OFF;
229             break;
230         default:
231             deepColor = HDMI_DEEP_COLOR_BUTT;
232             break;
233     }
234     return deepColor;
235 }
236 
HdmiCommonGetVic(enum HdmiVideoTiming timing,enum HdmiPictureAspectRatio aspect,bool enable3d)237 enum HdmiVic HdmiCommonGetVic(enum HdmiVideoTiming timing,
238     enum HdmiPictureAspectRatio aspect, bool enable3d)
239 {
240     uint32_t i;
241     uint32_t len;
242     enum HdmiVic vic = 0;
243 
244     len = sizeof(g_ceaVideoDefInfoMap) / sizeof(g_ceaVideoDefInfoMap[0]);
245     for (i = 0; i < len; i++) {
246         if (timing == g_ceaVideoDefInfoMap[i].timing && aspect == g_ceaVideoDefInfoMap[i].aspect) {
247             vic = g_ceaVideoDefInfoMap[i].vic;
248             break;
249         }
250     }
251 
252     if (enable3d == true) {
253         /* see hdmi spec 10.2. */
254         if (vic == HDMI_VIC_3840X2160P24_16_9 || vic == HDMI_VIC_3840X2160P25_16_9 ||
255             vic == HDMI_VIC_3840X2160P30_16_9 || vic == HDMI_VIC_4096X2160P24_256_135) {
256             HDF_LOGI("4k x 2k 2D vic:%d.", vic);
257             vic = HDMI_VIC_NONE;
258         }
259     }
260     return vic;
261 }
262 
HdmiCommonGetCommFormatInfo(enum HdmiVic vic)263 static struct HdmiVideoDefInfo *HdmiCommonGetCommFormatInfo(enum HdmiVic vic)
264 {
265     uint32_t i;
266     uint32_t len;
267 
268     len = sizeof(g_ceaVideoDefInfoMap) / sizeof(g_ceaVideoDefInfoMap[0]);
269     for (i = 0; i < len; i++) {
270         if (vic == g_ceaVideoDefInfoMap[i].vic) {
271             return &g_ceaVideoDefInfoMap[i];
272         }
273     }
274     return NULL;
275 }
276 
HdmiCommonGetVesaFormatInfo(enum HdmiVideoTiming timing)277 static struct HdmiVideoDefInfo *HdmiCommonGetVesaFormatInfo(enum HdmiVideoTiming timing)
278 {
279     uint32_t i;
280     uint32_t len;
281 
282     len = sizeof(g_vesaVideoDefInfoMap) / sizeof(g_vesaVideoDefInfoMap[0]);
283     for (i = 0; i < len; i++) {
284         if (timing == g_vesaVideoDefInfoMap[i].timing) {
285             return &g_vesaVideoDefInfoMap[i];
286         }
287     }
288     return NULL;
289 }
290 
HdmiCommonGetVideoDefInfo(enum HdmiVideoTiming timing,enum HdmiPictureAspectRatio aspect,bool enable3d)291 struct HdmiVideoDefInfo *HdmiCommonGetVideoDefInfo(enum HdmiVideoTiming timing,
292     enum HdmiPictureAspectRatio aspect, bool enable3d)
293 {
294     enum HdmiVic vic;
295     struct HdmiVideoDefInfo *info = NULL;
296 
297     if (timing < HDMI_VIDEO_TIMING_VESA_DEFINE) {
298         vic = HdmiCommonGetVic(timing, aspect, enable3d);
299         info = HdmiCommonGetCommFormatInfo(vic);
300     } else if (timing < HDMI_VIDEO_TIMING_USER_DEFINE) {
301         info = HdmiCommonGetVesaFormatInfo(timing);
302     }
303     return info;
304 }
305 
HdmiCommonGetVideoTiming(enum HdmiVic vic,enum HdmiPictureAspectRatio aspect)306 enum HdmiVideoTiming HdmiCommonGetVideoTiming(enum HdmiVic vic, enum HdmiPictureAspectRatio aspect)
307 {
308     uint32_t i;
309     uint32_t len;
310     enum HdmiVideoTiming timing = HDMI_VIDEO_TIMING_NONE;
311 
312     len = sizeof(g_ceaVideoDefInfoMap) / sizeof(g_ceaVideoDefInfoMap[0]);
313     for (i = 0; i < len; i++) {
314         if (vic == g_ceaVideoDefInfoMap[i].vic && aspect == g_ceaVideoDefInfoMap[i].aspect) {
315             timing = g_ceaVideoDefInfoMap[i].timing;
316             break;
317         }
318     }
319     return timing;
320 }
321 
HdmiCommonGetVideo4kInfo(uint32_t _4kVic)322 struct HdmiVideo4kInfo *HdmiCommonGetVideo4kInfo(uint32_t _4kVic)
323 {
324     uint32_t i;
325     uint32_t len;
326 
327     len = sizeof(g_video4kInfoMap) / sizeof(g_video4kInfoMap[0]);
328     for (i = 0; i < len; i++) {
329         if (_4kVic == g_video4kInfoMap[i]._4kVic) {
330             return &g_video4kInfoMap[i];
331         }
332     }
333     HDF_LOGD("4k not support vic = %u", _4kVic);
334     return NULL;
335 }
336 
HdmiCommonGetVideo4kTiming(uint32_t _4kVic)337 enum HdmiVideoTiming HdmiCommonGetVideo4kTiming(uint32_t _4kVic)
338 {
339     uint32_t i;
340     uint32_t len;
341     enum HdmiVideoTiming timing = HDMI_VIDEO_TIMING_NONE;
342 
343     len = sizeof(g_video4kInfoMap) / sizeof(g_video4kInfoMap[0]);
344     for (i = 0; i < len; i++) {
345         if (_4kVic == g_video4kInfoMap[i]._4kVic) {
346             timing = g_video4kInfoMap[i].timing;
347             break;
348         }
349     }
350     return timing;
351 }
352