• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef __EDID_UTILS_H__
6 #define __EDID_UTILS_H__
7 
8 #include "stdio.h"
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 /* These match the EDID encoding for Standard Timing block */
15 #define ASPECT_16_10 0
16 #define ASPECT_4_3 1
17 #define ASPECT_5_4 2
18 #define ASPECT_16_9 3
19 #define N_ASPECTS 4
20 
21 /* Defines based on EDID and CEA-861D descriptions */
22 #define EDID_HDR 0
23 #define EDID_MFG_EID 0x8
24 #define EDID_MFG_PROD_LO 0x0A
25 #define EDID_MFG_PROD_HI 0x0B
26 #define EDID_MFG_SERIAL 0x0C
27 #define EDID_MFG_WEEK 0x10
28 #define EDID_MFG_YEAR 0x11
29 #define EDID_VERSION 0x12
30 #define EDID_REVISION 0x13
31 #define EDID_VIDEO_IN 0x14
32 #define EDID_MAX_HSIZE 0x15
33 #define EDID_MAX_VSIZE 0x16
34 #define EDID_GAMMA 0x17
35 #define EDID_FEATURES 0x18
36 
37 #define EDID_ESTTIME1 0x23
38 #define EDID_ESTTIME2 0x24
39 #define EDID_MFGTIME 0x25
40 /* Next two repeat 8 times for standard timings 1-8 */
41 #define EDID_STDTIMEH 0x26
42 #define EDID_STDTIMEV 0x27
43 #define EDID_N_STDTIME 8
44 
45 /* There are 4 DTD blocks in the EDID */
46 #define EDID_DTD_BASE 0x36
47 #define EDID_N_DTDS 4
48 
49 #define EDID_EXT_FLAG 0x7E
50 #define EDID_CSUM 0x7F
51 #define EDID_SIZE 0x80
52 
53 #define EEXT_TAG 0
54 #define EEXT_REV 1
55 #define EEXT_SIZE 0x80
56 
57 #define EEDID_SIZE (EDID_SIZE + EEXT_SIZE)
58 
59 /* 2 byte standard timing structure */
60 #define STDTIME_HBASE 248
61 #define STDTIME_HMULT 8
62 #define STDTIME_VASPECT_SHIFT 6
63 #define STDTIME_VREFMINUS60_MASK 0x3f
64 #define STDTIME_SIZE 2
65 
66 /* 18 byte DTD structure */
67 #define DTD_PCLK_LO 0
68 #define DTD_PCLK_HI 1
69 #define DTD_HA_LO 2
70 #define DTD_HBL_LO 3
71 #define DTD_HABL_HI 4
72 #define DTD_VA_LO 5
73 #define DTD_VBL_LO 6
74 #define DTD_VABL_HI 7
75 #define DTD_HSO_LO 8
76 #define DTD_HSW_LO 9
77 #define DTD_VSX_LO 10
78 #define DTD_HVSX_HI 11
79 #define DTD_HSIZE_LO 12
80 #define DTD_VSIZE_LO 13
81 #define DTD_HVSIZE_HI 14
82 #define DTD_HBORDER 15
83 #define DTD_VBORDER 16
84 #define DTD_FLAGS 17
85 #define DTD_SIZE 18
86 
87 /* These apply when PCLK is zero */
88 #define DTD_TYPETAG 3
89 #define DTD_STRING 5
90 #define DTD_MINV_HZ 5
91 #define DTD_MAXV_HZ 6
92 #define DTD_MINH_kHZ 7
93 #define DTD_MAXH_kHZ 8
94 #define DTD_MAXCLK_100kHZ 9
95 
96 /* Types in the TYPETAG field */
97 #define DTDTYPE_MANUF 0x0f
98 #define DTDTYPE_STDTIME 0xfa
99 #define DTDTYPE_COLPOINT 0xfb
100 #define DTDTYPE_NAME 0xfc
101 #define DTDTYPE_LIMITS 0xfd
102 #define DTDTYPE_STRING 0xfe
103 #define DTDTYPE_SERIAL 0xff
104 
105 /* This is the CEA extension version 3 */
106 #define CEA_TAG 0
107 #define CEA_REV 1
108 #define CEA_DTD_OFFSET 2
109 /* Next two are low nibble, high nibble of same byte */
110 #define CEA_NATIVE_DTDS 3
111 #define CEA_SUPPORT 3
112 #define CEA_DBC_START 4
113 /* Last DBC is at [CEA_DTD_OFFSET]-1, first DTD is at [CEA_DTD_OFFSET] */
114 /* Padding needs min of two (gives PCLK=00 in DTD) */
115 #define CEA_LAST_PAD 125
116 #define CEA_END_PAD 126
117 #define CEA_CHECKSUM 127
118 
119 /* Data Block Collections */
120 /* Same byte: upper 3 bits tag, low five length */
121 #define DBC_TAG_LENGTH 0
122 #define DBC_LEN_MASK 0x1f
123 #define DBC_TAG_SHIFT 5
124 #define DBC_ETAG 1
125 
126 #define DBCA_FORMAT 0
127 #define DBCA_RATE 1
128 #define DBCA_INFO 2
129 #define DBCA_SIZE 3
130 
131 #define DBCA_FMT_LPCM 1
132 
133 #define DBCV_CODE 0
134 #define DBCV_SIZE 1
135 
136 #define DBCVND_IEEE_LO 0
137 #define DBCVND_IEEE_MID 1
138 #define DBCVND_IEEE_HI 2
139 
140 #define DBCVHDMI_CEC_LO 3
141 #define DBCVHDMI_CEC_HI 4
142 #define DBCVHDMI_SUPPORT 5
143 #define DBCVHDMI_MAXTMDS_5MHz 6
144 #define DBCVHDMI_LATFLAGS 7
145 #define DBCVHDMI_VLAT 8
146 #define DBCVHDMI_ALAT 9
147 #define DBCVHDMI_IVLAT 10
148 #define DBCVHDMI_IALAT 11
149 
150 #define DBCSP_ALLOC 0
151 #define DBCSP_SIZE 3
152 
153 #define DBC_TAG_AUDIO 1
154 #define DBC_TAG_VIDEO 2
155 #define DBC_TAG_VENDOR 3
156 #define DBC_TAG_SPEAKER 4
157 #define DBC_TAG_VESA 5
158 #define DBC_TAG_EXTENDED 7
159 
160 #define DBC_ETAG_VCDB 0
161 #define DBC_ETAG_VENDOR_VDB 1
162 #define DBC_ETAG_COL 5
163 
164 #define VCDB_TAG 0
165 #define VCDB_ETAG 1
166 #define VCDB_FLAGS 2
167 #define VCDB_S_PT(x) (((x)&0x30) >> 4)
168 #define VCDB_S_IT(x) (((x)&0x0C) >> 2)
169 #define VCDB_S_CE(x) (((x)&0x03))
170 
171 #define COL_TAG 0
172 #define COL_ETAG 1
173 #define COL_FLAGS 2
174 #define COL_META 3
175 
176 /* Number of test EDID arrays available to get/show_test_edid */
177 #define N_TEST_EDIDS 6
178 
179 int edid_valid(const unsigned char *edid_data);
180 int edid_has_hdmi_info(const unsigned char *edid_data, int ext);
181 int edid_lpcm_support(const unsigned char *edid_data, int ext);
182 void show_edid_data(FILE *outfile, unsigned char *edid_data, int items,
183 		    int base);
184 void show_edid(FILE *outfile, unsigned char *edid_data, int ext);
185 int find_aspect(int h, int v);
186 int find_aspect_fromisize(unsigned char *edid_data);
187 extern char *aspect_to_str[];
188 int get_test_edid(int n, unsigned char *dst);
189 int show_test_edid(FILE *outfile, int n);
190 
191 /* Gets monitor name from EDID.
192  * Args:
193  *    edid_data - EDID data.
194  *    buf - buffer to store monitor name.
195  *    buf_size - buffer size.
196  */
197 int edid_get_monitor_name(const unsigned char *edid_data, char *buf,
198 			  unsigned int buf_size);
199 
200 #ifdef __cplusplus
201 } /* extern "C" */
202 #endif
203 
204 #endif
205