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