Patrick Georgi | 593124d | 2020-05-10 19:44:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: MIT */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 2 | |
| 3 | /* this is a pretty robust parser for EDID, and we're tasked with parsing |
| 4 | * an arbitrary panel. We will pass it a raw EDID block and a struct which |
| 5 | * it must fill in with values. The set of values we need is pretty limited |
| 6 | * at present. |
| 7 | */ |
| 8 | |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 9 | #include <assert.h> |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 10 | #include <commonlib/helpers.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 11 | #include <console/console.h> |
Joel Kitching | 393c71c | 2019-06-16 16:09:42 +0800 | [diff] [blame] | 12 | #include <ctype.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | #include <string.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 15 | #include <edid.h> |
Ronald G. Minnich | b2893a01 | 2013-04-23 10:59:11 -0700 | [diff] [blame] | 16 | #include <vbe.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 17 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 18 | struct edid_context { |
| 19 | int claims_one_point_oh; |
| 20 | int claims_one_point_two; |
| 21 | int claims_one_point_three; |
| 22 | int claims_one_point_four; |
| 23 | int nonconformant_digital_display; |
| 24 | int nonconformant_extension; |
| 25 | int did_detailed_timing; |
| 26 | int has_name_descriptor; |
| 27 | int has_range_descriptor; |
| 28 | int has_preferred_timing; |
| 29 | int has_valid_checksum; |
| 30 | int has_valid_cvt; |
| 31 | int has_valid_dummy_block; |
| 32 | int has_valid_week; |
| 33 | int has_valid_year; |
| 34 | int has_valid_detailed_blocks; |
| 35 | int has_valid_extension_count; |
| 36 | int has_valid_descriptor_ordering; |
| 37 | int has_valid_descriptor_pad; |
| 38 | int has_valid_range_descriptor; |
| 39 | int has_valid_max_dotclock; |
| 40 | int has_valid_string_termination; |
| 41 | int manufacturer_name_well_formed; |
| 42 | int seen_non_detailed_descriptor; |
| 43 | int warning_excessive_dotclock_correction; |
| 44 | int warning_zero_preferred_refresh; |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 45 | enum edid_status conformant; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 46 | }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 47 | |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 48 | /* Stuff that isn't used anywhere but is nice to pretty-print while |
| 49 | we're decoding everything else. */ |
| 50 | static struct { |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 51 | unsigned int model; |
| 52 | unsigned int serial; |
| 53 | unsigned int year; |
| 54 | unsigned int week; |
| 55 | unsigned int version[2]; |
| 56 | unsigned int nonconformant; |
| 57 | unsigned int type; |
| 58 | |
| 59 | unsigned int x_mm; |
| 60 | unsigned int y_mm; |
| 61 | |
| 62 | unsigned int voltage; |
| 63 | unsigned int sync; |
| 64 | |
| 65 | const char *syncmethod; |
| 66 | const char *range_class; |
| 67 | const char *stereo; |
| 68 | } extra_info; |
| 69 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 70 | static struct edid tmp_edid; |
| 71 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 72 | static int manufacturer_name(unsigned char *x, char *output) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 73 | { |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 74 | output[0] = ((x[0] & 0x7C) >> 2) + '@'; |
| 75 | output[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
| 76 | output[2] = (x[1] & 0x1F) + '@'; |
| 77 | output[3] = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 78 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 79 | if (isupper(output[0]) && |
| 80 | isupper(output[1]) && |
| 81 | isupper(output[2])) |
| 82 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 83 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 84 | memset(output, 0, 4); |
| 85 | return 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static int |
Douglas Anderson | 14dd370 | 2015-10-28 11:19:57 -0700 | [diff] [blame] | 89 | detailed_cvt_descriptor(unsigned char *x, int first) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 90 | { |
| 91 | const unsigned char empty[3] = { 0, 0, 0 }; |
Lee Leahy | 36984d8 | 2017-03-10 17:56:44 -0800 | [diff] [blame] | 92 | static const char *names[] = { "50", "60", "75", "85" }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 93 | int width = 0, height = 0; |
| 94 | int valid = 1; |
| 95 | int fifty = 0, sixty = 0, seventyfive = 0, eightyfive = 0, reduced = 0; |
| 96 | |
| 97 | if (!first && !memcmp(x, empty, 3)) |
| 98 | return valid; |
| 99 | |
| 100 | height = x[0]; |
| 101 | height |= (x[1] & 0xf0) << 4; |
| 102 | height++; |
| 103 | height *= 2; |
| 104 | |
| 105 | switch (x[1] & 0x0c) { |
| 106 | case 0x00: |
| 107 | width = (height * 4) / 3; break; |
| 108 | case 0x04: |
| 109 | width = (height * 16) / 9; break; |
| 110 | case 0x08: |
| 111 | width = (height * 16) / 10; break; |
| 112 | case 0x0c: |
| 113 | width = (height * 15) / 9; break; |
| 114 | } |
| 115 | |
| 116 | if (x[1] & 0x03) |
| 117 | valid = 0; |
| 118 | if (x[2] & 0x80) |
| 119 | valid = 0; |
| 120 | if (!(x[2] & 0x1f)) |
| 121 | valid = 0; |
| 122 | |
| 123 | fifty = (x[2] & 0x10); |
| 124 | sixty = (x[2] & 0x08); |
| 125 | seventyfive = (x[2] & 0x04); |
| 126 | eightyfive = (x[2] & 0x02); |
| 127 | reduced = (x[2] & 0x01); |
| 128 | |
| 129 | if (!valid) { |
| 130 | printk(BIOS_SPEW, " (broken)\n"); |
| 131 | } else { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 132 | printk(BIOS_SPEW, |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 133 | " %dx%d @ (%s%s%s%s%s) Hz (%s%s preferred)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 134 | width, height, |
| 135 | fifty ? "50 " : "", |
| 136 | sixty ? "60 " : "", |
| 137 | seventyfive ? "75 " : "", |
| 138 | eightyfive ? "85 " : "", |
| 139 | reduced ? "60RB " : "", |
| 140 | names[(x[2] & 0x60) >> 5], |
| 141 | (((x[2] & 0x60) == 0x20) && reduced) ? "RB" : ""); |
| 142 | } |
| 143 | |
| 144 | return valid; |
| 145 | } |
| 146 | |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 147 | /* extract a CP437 string from a detailed subblock, checking for termination (if |
| 148 | * less than len of bytes) with LF and padded with SP. |
| 149 | */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 150 | static char * |
| 151 | extract_string(unsigned char *x, int *valid_termination, int len) |
| 152 | { |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 153 | static char ret[EDID_ASCII_STRING_LENGTH + 1]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 154 | int i, seen_newline = 0; |
| 155 | |
| 156 | memset(ret, 0, sizeof(ret)); |
| 157 | |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 158 | for (i = 0; i < MIN(len, EDID_ASCII_STRING_LENGTH); i++) { |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 159 | if (seen_newline) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 160 | if (x[i] != 0x20) { |
| 161 | *valid_termination = 0; |
| 162 | return ret; |
| 163 | } |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 164 | } else if (x[i] == 0x0a) { |
| 165 | seen_newline = 1; |
| 166 | } else { |
| 167 | /* normal characters */ |
| 168 | ret[i] = x[i]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
| 172 | return ret; |
| 173 | } |
| 174 | |
| 175 | /* 1 means valid data */ |
| 176 | static int |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 177 | detailed_block(struct edid *result_edid, unsigned char *x, int in_extension, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 178 | struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 179 | { |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 180 | struct edid *out = &tmp_edid; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 181 | int i; |
Angel Pons | cc335c7 | 2018-10-02 11:58:28 +0200 | [diff] [blame] | 182 | |
| 183 | if (console_log_level(BIOS_SPEW)) { |
| 184 | printk(BIOS_SPEW, "Hex of detail: "); |
| 185 | for (i = 0; i < 18; i++) |
| 186 | printk(BIOS_SPEW, "%02x", x[i]); |
| 187 | printk(BIOS_SPEW, "\n"); |
| 188 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 189 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 190 | /* Result might already have some valid fields like mode_is_supported */ |
| 191 | *out = *result_edid; |
| 192 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 193 | if (x[0] == 0 && x[1] == 0) { |
| 194 | /* Monitor descriptor block, not detailed timing descriptor. */ |
| 195 | if (x[2] != 0) { |
| 196 | /* 1.3, 3.10.3 */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 197 | printk(BIOS_SPEW, |
| 198 | "Monitor descriptor block has byte 2 nonzero (0x%02x)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 199 | x[2]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 200 | c->has_valid_descriptor_pad = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 201 | } |
| 202 | if (x[3] != 0xfd && x[4] != 0x00) { |
| 203 | /* 1.3, 3.10.3 */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 204 | printk(BIOS_SPEW, |
| 205 | "Monitor descriptor block has byte 4 nonzero (0x%02x)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 206 | x[4]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 207 | c->has_valid_descriptor_pad = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 210 | c->seen_non_detailed_descriptor = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 211 | if (x[3] <= 0xF) { |
| 212 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 213 | * in principle we can decode these, if we know what |
| 214 | * they are. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 215 | * 0x0f seems to be common in laptop panels. |
| 216 | * 0x0e is used by EPI: http://www.epi-standard.org/ |
| 217 | */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 218 | printk(BIOS_SPEW, |
| 219 | "Manufacturer-specified data, tag %d\n", x[3]); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 220 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 221 | } |
| 222 | switch (x[3]) { |
| 223 | case 0x10: |
| 224 | printk(BIOS_SPEW, "Dummy block\n"); |
| 225 | for (i = 5; i < 18; i++) |
| 226 | if (x[i] != 0x00) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 227 | c->has_valid_dummy_block = 0; |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 228 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 229 | case 0xF7: |
| 230 | /* TODO */ |
| 231 | printk(BIOS_SPEW, "Established timings III\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 232 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 233 | case 0xF8: |
| 234 | { |
| 235 | int valid_cvt = 1; /* just this block */ |
| 236 | printk(BIOS_SPEW, "CVT 3-byte code descriptor:\n"); |
| 237 | if (x[5] != 0x01) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 238 | c->has_valid_cvt = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | for (i = 0; i < 4; i++) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 242 | valid_cvt &= detailed_cvt_descriptor(x + 6 |
| 243 | + (i * 3), (i == 0)); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 244 | c->has_valid_cvt &= valid_cvt; |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 245 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 246 | } |
| 247 | case 0xF9: |
| 248 | /* TODO */ |
| 249 | printk(BIOS_SPEW, "Color management data\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 250 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 251 | case 0xFA: |
| 252 | /* TODO */ |
| 253 | printk(BIOS_SPEW, "More standard timings\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 254 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 255 | case 0xFB: |
| 256 | /* TODO */ |
| 257 | printk(BIOS_SPEW, "Color point\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 258 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 259 | case 0xFC: |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 260 | printk(BIOS_SPEW, "Monitor name: %s\n", |
| 261 | extract_string(x + 5, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 262 | &c->has_valid_string_termination, |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 263 | EDID_ASCII_STRING_LENGTH)); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 264 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 265 | case 0xFD: |
| 266 | { |
| 267 | int h_max_offset = 0, h_min_offset = 0; |
| 268 | int v_max_offset = 0, v_min_offset = 0; |
| 269 | int is_cvt = 0; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 270 | c->has_range_descriptor = 1; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 271 | extra_info.range_class = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 272 | /* |
| 273 | * XXX todo: implement feature flags, vtd blocks |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 274 | * XXX check: ranges are well-formed; block termination |
| 275 | * if no vtd |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 276 | */ |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 277 | if (c->claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 278 | if (x[4] & 0x02) { |
| 279 | v_max_offset = 255; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 280 | if (x[4] & 0x01) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 281 | v_min_offset = 255; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 282 | } |
| 283 | if (x[4] & 0x04) { |
| 284 | h_max_offset = 255; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 285 | if (x[4] & 0x03) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 286 | h_min_offset = 255; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 287 | } |
| 288 | } else if (x[4]) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 289 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /* |
| 293 | * despite the values, this is not a bitfield. |
| 294 | */ |
| 295 | switch (x[10]) { |
| 296 | case 0x00: /* default gtf */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 297 | extra_info.range_class = "GTF"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 298 | break; |
| 299 | case 0x01: /* range limits only */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 300 | extra_info.range_class = "bare limits"; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 301 | if (!c->claims_one_point_four) |
| 302 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 303 | break; |
| 304 | case 0x02: /* secondary gtf curve */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 305 | extra_info.range_class = "GTF with icing"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 306 | break; |
| 307 | case 0x04: /* cvt */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 308 | extra_info.range_class = "CVT"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 309 | is_cvt = 1; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 310 | if (!c->claims_one_point_four) |
| 311 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 312 | break; |
| 313 | default: /* invalid */ |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 314 | c->has_valid_range_descriptor = 0; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 315 | extra_info.range_class = "invalid"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 316 | break; |
| 317 | } |
| 318 | |
| 319 | if (x[5] + v_min_offset > x[6] + v_max_offset) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 320 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 321 | if (x[7] + h_min_offset > x[8] + h_max_offset) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 322 | c->has_valid_range_descriptor = 0; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 323 | printk(BIOS_SPEW, |
| 324 | "Monitor ranges (%s): %d-%dHz V, %d-%dkHz H", |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 325 | extra_info.range_class, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 326 | x[5] + v_min_offset, x[6] + v_max_offset, |
| 327 | x[7] + h_min_offset, x[8] + h_max_offset); |
| 328 | if (x[9]) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 329 | printk(BIOS_SPEW, |
| 330 | ", max dotclock %dMHz\n", x[9] * 10); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 331 | else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 332 | if (c->claims_one_point_four) |
| 333 | c->has_valid_max_dotclock = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 334 | printk(BIOS_SPEW, "\n"); |
| 335 | } |
| 336 | |
| 337 | if (is_cvt) { |
| 338 | int max_h_pixels = 0; |
| 339 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 340 | printk(BIOS_SPEW, "CVT version %d.%d\n", |
| 341 | x[11] & 0xf0 >> 4, x[11] & 0x0f); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 342 | |
| 343 | if (x[12] & 0xfc) { |
| 344 | int raw_offset = (x[12] & 0xfc) >> 2; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 345 | printk(BIOS_SPEW, |
| 346 | "Real max dotclock: %dKHz\n", |
| 347 | (x[9] * 10000) |
| 348 | - (raw_offset * 250)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 349 | if (raw_offset >= 40) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 350 | c->warning_excessive_dotclock_correction = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | max_h_pixels = x[12] & 0x03; |
| 354 | max_h_pixels <<= 8; |
| 355 | max_h_pixels |= x[13]; |
| 356 | max_h_pixels *= 8; |
| 357 | if (max_h_pixels) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 358 | printk(BIOS_SPEW, |
| 359 | "Max active pixels per line: %d\n", |
| 360 | max_h_pixels); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 361 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 362 | printk(BIOS_SPEW, |
| 363 | "Supported aspect ratios: %s %s %s %s %s\n", |
| 364 | x[14] & 0x80 ? "4:3" : "", |
| 365 | x[14] & 0x40 ? "16:9" : "", |
| 366 | x[14] & 0x20 ? "16:10" : "", |
| 367 | x[14] & 0x10 ? "5:4" : "", |
| 368 | x[14] & 0x08 ? "15:9" : ""); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 369 | if (x[14] & 0x07) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 370 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 371 | |
| 372 | printk(BIOS_SPEW, "Preferred aspect ratio: "); |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 373 | switch ((x[15] & 0xe0) >> 5) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 374 | case 0x00: |
| 375 | printk(BIOS_SPEW, "4:3"); |
| 376 | break; |
| 377 | case 0x01: |
| 378 | printk(BIOS_SPEW, "16:9"); |
| 379 | break; |
| 380 | case 0x02: |
| 381 | printk(BIOS_SPEW, "16:10"); |
| 382 | break; |
| 383 | case 0x03: |
| 384 | printk(BIOS_SPEW, "5:4"); |
| 385 | break; |
| 386 | case 0x04: |
| 387 | printk(BIOS_SPEW, "15:9"); |
| 388 | break; |
| 389 | default: |
| 390 | printk(BIOS_SPEW, "(broken)"); |
| 391 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 392 | } |
| 393 | printk(BIOS_SPEW, "\n"); |
| 394 | |
| 395 | if (x[15] & 0x04) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 396 | printk(BIOS_SPEW, |
| 397 | "Supports CVT standard blanking\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 398 | if (x[15] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 399 | printk(BIOS_SPEW, |
| 400 | "Supports CVT reduced blanking\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 401 | |
| 402 | if (x[15] & 0x07) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 403 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 404 | |
| 405 | if (x[16] & 0xf0) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 406 | printk(BIOS_SPEW, |
| 407 | "Supported display scaling:\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 408 | if (x[16] & 0x80) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 409 | printk(BIOS_SPEW, |
| 410 | " Horizontal shrink\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 411 | if (x[16] & 0x40) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 412 | printk(BIOS_SPEW, |
| 413 | " Horizontal stretch\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 414 | if (x[16] & 0x20) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 415 | printk(BIOS_SPEW, |
| 416 | " Vertical shrink\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 417 | if (x[16] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 418 | printk(BIOS_SPEW, |
| 419 | " Vertical stretch\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | if (x[16] & 0x0f) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 423 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 424 | |
| 425 | if (x[17]) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 426 | printk(BIOS_SPEW, |
| 427 | "Preferred vertical refresh: %d Hz\n", |
| 428 | x[17]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 429 | else |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 430 | c->warning_zero_preferred_refresh = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 434 | * Slightly weird to return a global, but I've never |
| 435 | * seen any EDID block wth two range descriptors, so |
| 436 | * it's harmless. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 437 | */ |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 438 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 439 | } |
| 440 | case 0xFE: |
| 441 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 442 | * TODO: Two of these in a row, in the third and fourth |
| 443 | * slots, seems to be specified by SPWG: |
| 444 | * http://www.spwg.org/ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 445 | */ |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 446 | strcpy(result_edid->ascii_string, extract_string(x + 5, |
| 447 | &c->has_valid_string_termination, |
| 448 | EDID_ASCII_STRING_LENGTH)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 449 | printk(BIOS_SPEW, "ASCII string: %s\n", |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 450 | result_edid->ascii_string); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 451 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 452 | case 0xFF: |
| 453 | printk(BIOS_SPEW, "Serial number: %s\n", |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 454 | extract_string(x + 5, |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 455 | &c->has_valid_string_termination, |
| 456 | EDID_ASCII_STRING_LENGTH)); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 457 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 458 | default: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 459 | printk(BIOS_SPEW, |
| 460 | "Unknown monitor description type %d\n", |
| 461 | x[3]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 462 | return 0; |
| 463 | } |
| 464 | } |
| 465 | |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 466 | if (c->seen_non_detailed_descriptor && !in_extension) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 467 | c->has_valid_descriptor_ordering = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 468 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 469 | /* Edid contains pixel clock in terms of 10KHz */ |
| 470 | out->mode.pixel_clock = (x[0] + (x[1] << 8)) * 10; |
| 471 | /* |
| 472 | LVDS supports following pixel clocks |
| 473 | 25000...112000 kHz: single channel |
| 474 | 80000...224000 kHz: dual channel |
| 475 | There is some overlap in theoretically supported |
| 476 | pixel clock between single-channel and dual-channel. |
| 477 | In practice with current panels all panels |
| 478 | <= 75200 kHz: single channel |
| 479 | >= 97750 kHz: dual channel |
| 480 | We have no samples between those values, so put a |
| 481 | threshold at 95000 kHz. If we get anything over |
| 482 | 95000 kHz with single channel, we can make this |
| 483 | more sofisticated but it's currently not needed. |
| 484 | */ |
| 485 | out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000); |
| 486 | extra_info.x_mm = (x[12] + ((x[14] & 0xF0) << 4)); |
| 487 | extra_info.y_mm = (x[13] + ((x[14] & 0x0F) << 8)); |
| 488 | out->mode.ha = (x[2] + ((x[4] & 0xF0) << 4)); |
| 489 | out->mode.hbl = (x[3] + ((x[4] & 0x0F) << 8)); |
| 490 | out->mode.hso = (x[8] + ((x[11] & 0xC0) << 2)); |
| 491 | out->mode.hspw = (x[9] + ((x[11] & 0x30) << 4)); |
| 492 | out->mode.hborder = x[15]; |
| 493 | out->mode.va = (x[5] + ((x[7] & 0xF0) << 4)); |
| 494 | out->mode.vbl = (x[6] + ((x[7] & 0x0F) << 8)); |
| 495 | out->mode.vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2)); |
| 496 | out->mode.vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4)); |
| 497 | out->mode.vborder = x[16]; |
Furquan Shaikh | d0a81f7 | 2013-07-30 12:41:08 -0700 | [diff] [blame] | 498 | |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 499 | /* We assume rgb888 (32 bits per pixel) framebuffers by default. |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 500 | * Chipsets that want something else will need to override this with |
| 501 | * another call to edid_set_framebuffer_bits_per_pixel(). As a cheap |
| 502 | * heuristic, assume that X86 systems require a 64-byte row alignment |
| 503 | * (since that seems to be true for most Intel chipsets). */ |
Kyösti Mälkki | 7336f97 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 504 | if (ENV_X86) |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 505 | edid_set_framebuffer_bits_per_pixel(out, 32, 64); |
| 506 | else |
| 507 | edid_set_framebuffer_bits_per_pixel(out, 32, 0); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 508 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 509 | switch ((x[17] & 0x18) >> 3) { |
| 510 | case 0x00: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 511 | extra_info.syncmethod = " analog composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 512 | break; |
| 513 | case 0x01: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 514 | extra_info.syncmethod = " bipolar analog composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 515 | break; |
| 516 | case 0x02: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 517 | extra_info.syncmethod = " digital composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 518 | break; |
| 519 | case 0x03: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 520 | extra_info.syncmethod = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 521 | break; |
| 522 | } |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 523 | out->mode.pvsync = (x[17] & (1 << 2)) ? '+' : '-'; |
| 524 | out->mode.phsync = (x[17] & (1 << 1)) ? '+' : '-'; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 525 | switch (x[17] & 0x61) { |
| 526 | case 0x20: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 527 | extra_info.stereo = "field sequential L/R"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 528 | break; |
| 529 | case 0x40: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 530 | extra_info.stereo = "field sequential R/L"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 531 | break; |
| 532 | case 0x21: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 533 | extra_info.stereo = "interleaved right even"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 534 | break; |
| 535 | case 0x41: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 536 | extra_info.stereo = "interleaved left even"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 537 | break; |
| 538 | case 0x60: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 539 | extra_info.stereo = "four way interleaved"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 540 | break; |
| 541 | case 0x61: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 542 | extra_info.stereo = "side by side interleaved"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 543 | break; |
| 544 | default: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 545 | extra_info.stereo = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 546 | break; |
| 547 | } |
| 548 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 549 | printk(BIOS_SPEW, |
| 550 | "Detailed mode (IN HEX): Clock %d KHz, %x mm x %x mm\n" |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 551 | " %04x %04x %04x %04x hborder %x\n" |
| 552 | " %04x %04x %04x %04x vborder %x\n" |
Paul Menzel | 433bf77 | 2016-11-29 21:02:04 +0100 | [diff] [blame] | 553 | " %chsync %cvsync%s%s%s\n", |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 554 | out->mode.pixel_clock, |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 555 | extra_info.x_mm, |
| 556 | extra_info.y_mm, |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 557 | out->mode.ha, out->mode.ha + out->mode.hso, |
| 558 | out->mode.ha + out->mode.hso + out->mode.hspw, |
| 559 | out->mode.ha + out->mode.hbl, out->mode.hborder, |
| 560 | out->mode.va, out->mode.va + out->mode.vso, |
| 561 | out->mode.va + out->mode.vso + out->mode.vspw, |
| 562 | out->mode.va + out->mode.vbl, out->mode.vborder, |
| 563 | out->mode.phsync, out->mode.pvsync, |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 564 | extra_info.syncmethod, x[17] & 0x80 ? " interlaced" : "", |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 565 | extra_info.stereo); |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 566 | |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 567 | if (!c->did_detailed_timing) { |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 568 | printk(BIOS_SPEW, "Did detailed timing\n"); |
| 569 | c->did_detailed_timing = 1; |
| 570 | *result_edid = *out; |
| 571 | } |
| 572 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 573 | return 1; |
| 574 | } |
| 575 | |
| 576 | static int |
| 577 | do_checksum(unsigned char *x) |
| 578 | { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 579 | int valid = 0; |
Alexandru Gagniuc | 9d0ae59 | 2014-12-10 16:44:44 -0600 | [diff] [blame] | 580 | printk(BIOS_SPEW, "Checksum: 0x%hhx", x[0x7f]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 581 | { |
| 582 | unsigned char sum = 0; |
| 583 | int i; |
| 584 | for (i = 0; i < 128; i++) |
| 585 | sum += x[i]; |
| 586 | if (sum) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 587 | printk(BIOS_SPEW, " (should be 0x%hhx)", |
| 588 | (unsigned char)(x[0x7f] - sum)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 589 | } else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 590 | valid = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 591 | printk(BIOS_SPEW, " (valid)"); |
| 592 | } |
| 593 | } |
| 594 | printk(BIOS_SPEW, "\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 595 | return valid; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /* CEA extension */ |
| 599 | |
| 600 | static const char * |
| 601 | audio_format(unsigned char x) |
| 602 | { |
| 603 | switch (x) { |
| 604 | case 0: return "RESERVED"; |
| 605 | case 1: return "Linear PCM"; |
| 606 | case 2: return "AC-3"; |
| 607 | case 3: return "MPEG 1 (Layers 1 & 2)"; |
| 608 | case 4: return "MPEG 1 Layer 3 (MP3)"; |
| 609 | case 5: return "MPEG2 (multichannel)"; |
| 610 | case 6: return "AAC"; |
| 611 | case 7: return "DTS"; |
| 612 | case 8: return "ATRAC"; |
| 613 | case 9: return "One Bit Audio"; |
| 614 | case 10: return "Dolby Digital+"; |
| 615 | case 11: return "DTS-HD"; |
| 616 | case 12: return "MAT (MLP)"; |
| 617 | case 13: return "DST"; |
| 618 | case 14: return "WMA Pro"; |
| 619 | case 15: return "RESERVED"; |
| 620 | } |
| 621 | return "BROKEN"; /* can't happen */ |
| 622 | } |
| 623 | |
| 624 | static void |
| 625 | cea_audio_block(unsigned char *x) |
| 626 | { |
| 627 | int i, format; |
| 628 | int length = x[0] & 0x1f; |
| 629 | |
| 630 | if (length % 3) { |
| 631 | printk(BIOS_SPEW, "Broken CEA audio block length %d\n", length); |
| 632 | /* XXX non-conformant */ |
| 633 | return; |
| 634 | } |
| 635 | |
| 636 | for (i = 1; i < length; i += 3) { |
| 637 | format = (x[i] & 0x78) >> 3; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 638 | printk(BIOS_SPEW, " %s, max channels %d\n", |
| 639 | audio_format(format), x[i] & 0x07); |
| 640 | printk(BIOS_SPEW, |
| 641 | " Supported sample rates (kHz):%s%s%s%s%s%s%s\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 642 | (x[i+1] & 0x40) ? " 192" : "", |
| 643 | (x[i+1] & 0x20) ? " 176.4" : "", |
| 644 | (x[i+1] & 0x10) ? " 96" : "", |
| 645 | (x[i+1] & 0x08) ? " 88.2" : "", |
| 646 | (x[i+1] & 0x04) ? " 48" : "", |
| 647 | (x[i+1] & 0x02) ? " 44.1" : "", |
| 648 | (x[i+1] & 0x01) ? " 32" : ""); |
| 649 | if (format == 1) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 650 | printk(BIOS_SPEW, |
| 651 | " Supported sample sizes (bits):%s%s%s\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 652 | (x[2] & 0x04) ? " 24" : "", |
| 653 | (x[2] & 0x02) ? " 20" : "", |
| 654 | (x[2] & 0x01) ? " 16" : ""); |
| 655 | } else if (format <= 8) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 656 | printk(BIOS_SPEW, |
| 657 | " Maximum bit rate: %d kHz\n", x[2] * 8); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 658 | } |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | static void |
| 663 | cea_video_block(unsigned char *x) |
| 664 | { |
| 665 | int i; |
| 666 | int length = x[0] & 0x1f; |
| 667 | |
| 668 | for (i = 1; i < length; i++) |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 669 | printk(BIOS_SPEW, " VIC %02d %s\n", x[i] & 0x7f, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 670 | x[i] & 0x80 ? "(native)" : ""); |
| 671 | } |
| 672 | |
| 673 | static void |
| 674 | cea_hdmi_block(struct edid *out, unsigned char *x) |
| 675 | { |
| 676 | int length = x[0] & 0x1f; |
| 677 | |
Yakir Yang | 85810cc | 2015-10-27 16:17:13 +0800 | [diff] [blame] | 678 | out->hdmi_monitor_detected = 1; |
| 679 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 680 | printk(BIOS_SPEW, " (HDMI)\n"); |
| 681 | printk(BIOS_SPEW, |
| 682 | " Source physical address %d.%d.%d.%d\n", |
| 683 | x[4] >> 4, x[4] & 0x0f, x[5] >> 4, x[5] & 0x0f); |
| 684 | |
| 685 | if (length > 5) { |
| 686 | if (x[6] & 0x80) |
| 687 | printk(BIOS_SPEW, " Supports_AI\n"); |
| 688 | if (x[6] & 0x40) |
| 689 | printk(BIOS_SPEW, " DC_48bit\n"); |
| 690 | if (x[6] & 0x20) |
| 691 | printk(BIOS_SPEW, " DC_36bit\n"); |
| 692 | if (x[6] & 0x10) |
| 693 | printk(BIOS_SPEW, " DC_30bit\n"); |
| 694 | if (x[6] & 0x08) |
| 695 | printk(BIOS_SPEW, " DC_Y444\n"); |
| 696 | /* two reserved */ |
| 697 | if (x[6] & 0x01) |
| 698 | printk(BIOS_SPEW, " DVI_Dual\n"); |
| 699 | } |
| 700 | |
| 701 | if (length > 6) |
| 702 | printk(BIOS_SPEW, " Maximum TMDS clock: %dMHz\n", x[7] * 5); |
| 703 | |
| 704 | /* XXX the walk here is really ugly, and needs to be length-checked */ |
| 705 | if (length > 7) { |
| 706 | int b = 0; |
| 707 | |
| 708 | if (x[8] & 0x80) { |
| 709 | printk(BIOS_SPEW, " Video latency: %d\n", x[9 + b]); |
| 710 | printk(BIOS_SPEW, " Audio latency: %d\n", x[10 + b]); |
| 711 | b += 2; |
| 712 | } |
| 713 | |
| 714 | if (x[8] & 0x40) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 715 | printk(BIOS_SPEW, |
| 716 | " Interlaced video latency: %d\n", x[9 + b]); |
| 717 | printk(BIOS_SPEW, |
| 718 | " Interlaced audio latency: %d\n", |
| 719 | x[10 + b]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 720 | b += 2; |
| 721 | } |
| 722 | |
| 723 | if (x[8] & 0x20) { |
| 724 | int mask = 0, formats = 0; |
| 725 | int len_xx, len_3d; |
| 726 | printk(BIOS_SPEW, " Extended HDMI video details:\n"); |
| 727 | if (x[9 + b] & 0x80) |
| 728 | printk(BIOS_SPEW, " 3D present\n"); |
| 729 | if ((x[9 + b] & 0x60) == 0x20) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 730 | printk(BIOS_SPEW, |
| 731 | " All advertised VICs are 3D-capable\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 732 | formats = 1; |
| 733 | } |
| 734 | if ((x[9 + b] & 0x60) == 0x40) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 735 | printk(BIOS_SPEW, |
| 736 | " 3D-capable-VIC mask present\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 737 | formats = 1; |
| 738 | mask = 1; |
| 739 | } |
| 740 | switch (x[9 + b] & 0x18) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 741 | case 0x00: |
| 742 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 743 | case 0x08: |
| 744 | printk(BIOS_SPEW, " Base EDID image size is aspect ratio\n"); |
| 745 | break; |
| 746 | case 0x10: |
| 747 | printk(BIOS_SPEW, " Base EDID image size is in units of 1cm\n"); |
| 748 | break; |
| 749 | case 0x18: |
| 750 | printk(BIOS_SPEW, " Base EDID image size is in units of 5cm\n"); |
| 751 | break; |
| 752 | } |
| 753 | len_xx = (x[10 + b] & 0xe0) >> 5; |
| 754 | len_3d = (x[10 + b] & 0x1f) >> 0; |
| 755 | b += 2; |
| 756 | |
| 757 | if (len_xx) { |
| 758 | printk(BIOS_SPEW, " Skipping %d bytes that HDMI refuses to publicly" |
| 759 | " document\n", len_xx); |
| 760 | b += len_xx; |
| 761 | } |
| 762 | |
| 763 | if (len_3d) { |
| 764 | if (formats) { |
| 765 | if (x[9 + b] & 0x01) |
| 766 | printk(BIOS_SPEW, " Side-by-side 3D supported\n"); |
| 767 | if (x[10 + b] & 0x40) |
| 768 | printk(BIOS_SPEW, " Top-and-bottom 3D supported\n"); |
| 769 | if (x[10 + b] & 0x01) |
| 770 | printk(BIOS_SPEW, " Frame-packing 3D supported\n"); |
| 771 | b += 2; |
| 772 | } |
| 773 | if (mask) { |
| 774 | int i; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 775 | printk(BIOS_SPEW, |
| 776 | " 3D VIC indices:"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 777 | /* worst bit ordering ever */ |
| 778 | for (i = 0; i < 8; i++) |
| 779 | if (x[10 + b] & (1 << i)) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 780 | printk(BIOS_SPEW, |
| 781 | " %d", i); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 782 | for (i = 0; i < 8; i++) |
| 783 | if (x[9 + b] & (1 << i)) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 784 | printk(BIOS_SPEW, |
| 785 | " %d", i + 8); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 786 | printk(BIOS_SPEW, "\n"); |
| 787 | b += 2; |
| 788 | } |
| 789 | |
| 790 | /* |
| 791 | * XXX list of nibbles: |
| 792 | * 2D_VIC_Order_X |
| 793 | * 3D_Structure_X |
| 794 | * (optionally: 3D_Detail_X and reserved) |
| 795 | */ |
| 796 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 797 | } |
Richard Spiegel | 2fdbe0c | 2018-08-07 08:43:22 -0700 | [diff] [blame] | 798 | /* Tell static analysis we know index b is left unused. */ |
| 799 | (void)b; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 800 | } |
| 801 | } |
| 802 | |
| 803 | static void |
| 804 | cea_block(struct edid *out, unsigned char *x) |
| 805 | { |
| 806 | unsigned int oui; |
| 807 | |
| 808 | switch ((x[0] & 0xe0) >> 5) { |
| 809 | case 0x01: |
| 810 | printk(BIOS_SPEW, " Audio data block\n"); |
| 811 | cea_audio_block(x); |
| 812 | break; |
| 813 | case 0x02: |
| 814 | printk(BIOS_SPEW, " Video data block\n"); |
| 815 | cea_video_block(x); |
| 816 | break; |
| 817 | case 0x03: |
| 818 | /* yes really, endianness lols */ |
| 819 | oui = (x[3] << 16) + (x[2] << 8) + x[1]; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 820 | printk(BIOS_SPEW, " Vendor-specific data block, OUI %06x", |
| 821 | oui); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 822 | if (oui == 0x000c03) |
| 823 | cea_hdmi_block(out, x); |
| 824 | else |
| 825 | printk(BIOS_SPEW, "\n"); |
| 826 | break; |
| 827 | case 0x04: |
| 828 | printk(BIOS_SPEW, " Speaker allocation data block\n"); |
| 829 | break; |
| 830 | case 0x05: |
| 831 | printk(BIOS_SPEW, " VESA DTC data block\n"); |
| 832 | break; |
| 833 | case 0x07: |
| 834 | printk(BIOS_SPEW, " Extended tag: "); |
| 835 | switch (x[1]) { |
| 836 | case 0x00: |
| 837 | printk(BIOS_SPEW, "video capability data block\n"); |
| 838 | break; |
| 839 | case 0x01: |
| 840 | printk(BIOS_SPEW, "vendor-specific video data block\n"); |
| 841 | break; |
| 842 | case 0x02: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 843 | printk(BIOS_SPEW, |
| 844 | "VESA video display device information data block\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 845 | break; |
| 846 | case 0x03: |
| 847 | printk(BIOS_SPEW, "VESA video data block\n"); |
| 848 | break; |
| 849 | case 0x04: |
| 850 | printk(BIOS_SPEW, "HDMI video data block\n"); |
| 851 | break; |
| 852 | case 0x05: |
| 853 | printk(BIOS_SPEW, "Colorimetry data block\n"); |
| 854 | break; |
| 855 | case 0x10: |
| 856 | printk(BIOS_SPEW, "CEA miscellaneous audio fields\n"); |
| 857 | break; |
| 858 | case 0x11: |
| 859 | printk(BIOS_SPEW, "Vendor-specific audio data block\n"); |
| 860 | break; |
| 861 | case 0x12: |
| 862 | printk(BIOS_SPEW, "HDMI audio data block\n"); |
| 863 | break; |
| 864 | default: |
| 865 | if (x[1] >= 6 && x[1] <= 15) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 866 | printk(BIOS_SPEW, |
| 867 | "Reserved video block (%02x)\n", x[1]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 868 | else if (x[1] >= 19 && x[1] <= 31) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 869 | printk(BIOS_SPEW, |
| 870 | "Reserved audio block (%02x)\n", x[1]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 871 | else |
| 872 | printk(BIOS_SPEW, "Unknown (%02x)\n", x[1]); |
| 873 | break; |
| 874 | } |
| 875 | break; |
| 876 | default: |
| 877 | { |
| 878 | int tag = (*x & 0xe0) >> 5; |
| 879 | int length = *x & 0x1f; |
| 880 | printk(BIOS_SPEW, |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 881 | " Unknown tag %d, length %d (raw %02x)\n", |
| 882 | tag, length, *x); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 883 | break; |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | static int |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 889 | parse_cea(struct edid *out, unsigned char *x, struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 890 | { |
| 891 | int ret = 0; |
| 892 | int version = x[1]; |
| 893 | int offset = x[2]; |
| 894 | unsigned char *detailed; |
| 895 | |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 896 | if (version >= 1) |
| 897 | do { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 898 | if (version == 1 && x[3] != 0) |
| 899 | ret = 1; |
| 900 | |
| 901 | if (offset < 4) |
| 902 | break; |
| 903 | |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 904 | if (version < 3) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 905 | printk(BIOS_SPEW, |
| 906 | "%d 8-byte timing descriptors\n", |
| 907 | (offset - 4) / 8); |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 908 | else if (version == 3) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 909 | int i; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 910 | printk(BIOS_SPEW, |
| 911 | "%d bytes of CEA data\n", offset - 4); |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 912 | for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 913 | cea_block(out, x + i); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | if (version >= 2) { |
| 917 | if (x[3] & 0x80) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 918 | printk(BIOS_SPEW, |
| 919 | "Underscans PC formats by default\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 920 | if (x[3] & 0x40) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 921 | printk(BIOS_SPEW, |
| 922 | "Basic audio support\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 923 | if (x[3] & 0x20) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 924 | printk(BIOS_SPEW, |
| 925 | "Supports YCbCr 4:4:4\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 926 | if (x[3] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 927 | printk(BIOS_SPEW, |
| 928 | "Supports YCbCr 4:2:2\n"); |
| 929 | printk(BIOS_SPEW, |
| 930 | "%d native detailed modes\n", |
| 931 | x[3] & 0x0f); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 934 | for (detailed = x + offset; detailed + 18 < x + 127; |
| 935 | detailed += 18) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 936 | if (detailed[0]) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 937 | detailed_block(out, detailed, 1, c); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 938 | } while (0); |
| 939 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 940 | c->has_valid_checksum &= do_checksum(x); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 941 | return ret; |
| 942 | } |
| 943 | |
| 944 | /* generic extension code */ |
| 945 | |
| 946 | static void |
| 947 | extension_version(struct edid *out, unsigned char *x) |
| 948 | { |
| 949 | printk(BIOS_SPEW, "Extension version: %d\n", x[1]); |
| 950 | } |
| 951 | |
| 952 | static int |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 953 | parse_extension(struct edid *out, unsigned char *x, struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 954 | { |
| 955 | int conformant_extension = 0; |
| 956 | printk(BIOS_SPEW, "\n"); |
| 957 | |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 958 | switch (x[0]) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 959 | case 0x02: |
| 960 | printk(BIOS_SPEW, "CEA extension block\n"); |
| 961 | extension_version(out, x); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 962 | conformant_extension = parse_cea(out, x, c); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 963 | break; |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 964 | case 0x10: |
| 965 | printk(BIOS_SPEW, "VTB extension block\n"); |
| 966 | break; |
| 967 | case 0x40: |
| 968 | printk(BIOS_SPEW, "DI extension block\n"); |
| 969 | break; |
| 970 | case 0x50: |
| 971 | printk(BIOS_SPEW, "LS extension block\n"); |
| 972 | break; |
| 973 | case 0x60: |
| 974 | printk(BIOS_SPEW, "DPVL extension block\n"); |
| 975 | break; |
| 976 | case 0xF0: |
| 977 | printk(BIOS_SPEW, "Block map\n"); |
| 978 | break; |
| 979 | case 0xFF: |
| 980 | printk(BIOS_SPEW, "Manufacturer-specific extension block\n"); |
Jacob Garber | e447aec | 2019-03-27 17:23:42 -0600 | [diff] [blame] | 981 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 982 | default: |
| 983 | printk(BIOS_SPEW, "Unknown extension block\n"); |
| 984 | break; |
| 985 | } |
| 986 | |
| 987 | printk(BIOS_SPEW, "\n"); |
| 988 | |
| 989 | return conformant_extension; |
| 990 | } |
| 991 | |
| 992 | static const struct { |
| 993 | int x, y, refresh; |
| 994 | } established_timings[] = { |
| 995 | /* 0x23 bit 7 - 0 */ |
| 996 | {720, 400, 70}, |
| 997 | {720, 400, 88}, |
| 998 | {640, 480, 60}, |
| 999 | {640, 480, 67}, |
| 1000 | {640, 480, 72}, |
| 1001 | {640, 480, 75}, |
| 1002 | {800, 600, 56}, |
| 1003 | {800, 600, 60}, |
| 1004 | /* 0x24 bit 7 - 0 */ |
| 1005 | {800, 600, 72}, |
| 1006 | {800, 600, 75}, |
| 1007 | {832, 624, 75}, |
| 1008 | {1280, 768, 87}, |
| 1009 | {1024, 768, 60}, |
| 1010 | {1024, 768, 70}, |
| 1011 | {1024, 768, 75}, |
| 1012 | {1280, 1024, 75}, |
| 1013 | /* 0x25 bit 7*/ |
| 1014 | {1152, 870, 75}, |
| 1015 | }; |
| 1016 | |
| 1017 | static void print_subsection(const char *name, unsigned char *edid, int start, |
| 1018 | int end) |
| 1019 | { |
| 1020 | int i; |
| 1021 | |
| 1022 | printk(BIOS_SPEW, "%s:", name); |
| 1023 | for (i = strlen(name); i < 15; i++) |
| 1024 | printk(BIOS_SPEW, " "); |
| 1025 | for (i = start; i <= end; i++) |
| 1026 | printk(BIOS_SPEW, " %02x", edid[i]); |
| 1027 | printk(BIOS_SPEW, "\n"); |
| 1028 | } |
| 1029 | |
| 1030 | static void dump_breakdown(unsigned char *edid) |
| 1031 | { |
| 1032 | printk(BIOS_SPEW, "Extracted contents:\n"); |
| 1033 | print_subsection("header", edid, 0, 7); |
| 1034 | print_subsection("serial number", edid, 8, 17); |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 1035 | print_subsection("version", edid, 18, 19); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1036 | print_subsection("basic params", edid, 20, 24); |
| 1037 | print_subsection("chroma info", edid, 25, 34); |
| 1038 | print_subsection("established", edid, 35, 37); |
| 1039 | print_subsection("standard", edid, 38, 53); |
| 1040 | print_subsection("descriptor 1", edid, 54, 71); |
| 1041 | print_subsection("descriptor 2", edid, 72, 89); |
| 1042 | print_subsection("descriptor 3", edid, 90, 107); |
| 1043 | print_subsection("descriptor 4", edid, 108, 125); |
| 1044 | print_subsection("extensions", edid, 126, 126); |
| 1045 | print_subsection("checksum", edid, 127, 127); |
| 1046 | printk(BIOS_SPEW, "\n"); |
| 1047 | } |
| 1048 | |
| 1049 | /* |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1050 | * Lookup table of some well-known modes that can be useful in case the |
| 1051 | * auto-detected mode is unsuitable. |
| 1052 | * ha = hdisplay; va = vdisplay; |
| 1053 | * hbl = htotal - hdisplay; vbl = vtotal - vdisplay; |
| 1054 | * hso = hsync_start - hdsiplay; vso = vsync_start - vdisplay; |
| 1055 | * hspw = hsync_end - hsync_start; vspw = vsync_end - vsync_start; |
| 1056 | */ |
| 1057 | static struct edid_mode known_modes[NUM_KNOWN_MODES] = { |
| 1058 | [EDID_MODE_640x480_60Hz] = { |
Douglas Anderson | 78e226cf | 2015-10-28 09:52:22 -0700 | [diff] [blame] | 1059 | .name = "640x480@60Hz", .pixel_clock = 25200, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1060 | .ha = 640, .hbl = 160, .hso = 16, .hspw = 96, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1061 | .va = 480, .vbl = 45, .vso = 10, .vspw = 2, |
| 1062 | .phsync = '-', .pvsync = '-' }, |
| 1063 | [EDID_MODE_720x480_60Hz] = { |
| 1064 | .name = "720x480@60Hz", .pixel_clock = 27000, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1065 | .ha = 720, .hbl = 138, .hso = 16, .hspw = 62, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1066 | .va = 480, .vbl = 45, .vso = 9, .vspw = 6, |
| 1067 | .phsync = '-', .pvsync = '-' }, |
| 1068 | [EDID_MODE_1280x720_60Hz] = { |
| 1069 | .name = "1280x720@60Hz", .pixel_clock = 74250, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1070 | .ha = 1280, .hbl = 370, .hso = 110, .hspw = 40, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1071 | .va = 720, .vbl = 30, .vso = 5, .vspw = 20, |
| 1072 | .phsync = '+', .pvsync = '+' }, |
| 1073 | [EDID_MODE_1920x1080_60Hz] = { |
| 1074 | .name = "1920x1080@60Hz", .pixel_clock = 148500, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1075 | .ha = 1920, .hbl = 280, .hso = 88, .hspw = 44, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1076 | .va = 1080, .vbl = 45, .vso = 4, .vspw = 5, |
| 1077 | .phsync = '+', .pvsync = '+' }, |
| 1078 | }; |
| 1079 | |
| 1080 | int set_display_mode(struct edid *edid, enum edid_modes mode) |
| 1081 | { |
| 1082 | if (mode == EDID_MODE_AUTO) |
| 1083 | return 0; |
| 1084 | |
| 1085 | if (edid->mode_is_supported[mode]) { |
| 1086 | printk(BIOS_DEBUG, "Forcing mode %s\n", known_modes[mode].name); |
| 1087 | edid->mode = known_modes[mode]; |
| 1088 | return 0; |
| 1089 | } |
| 1090 | |
| 1091 | printk(BIOS_ERR, "Requested display mode not supported.\n"); |
| 1092 | return -1; |
| 1093 | } |
| 1094 | |
| 1095 | /* |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1096 | * Given a raw edid bloc, decode it into a form |
| 1097 | * that other parts of coreboot can use -- mainly |
| 1098 | * graphics bringup functions. The raw block is |
| 1099 | * required to be 128 bytes long, per the standard, |
| 1100 | * but we have no way of checking this minimum length. |
| 1101 | * We accept what we are given. |
| 1102 | */ |
| 1103 | int decode_edid(unsigned char *edid, int size, struct edid *out) |
| 1104 | { |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1105 | int analog, i, j; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1106 | struct edid_context c = { |
| 1107 | .has_valid_cvt = 1, |
| 1108 | .has_valid_dummy_block = 1, |
| 1109 | .has_valid_descriptor_ordering = 1, |
Vince Hsu | 4213b97 | 2014-04-21 17:07:57 +0800 | [diff] [blame] | 1110 | .has_valid_detailed_blocks = 1, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1111 | .has_valid_descriptor_pad = 1, |
| 1112 | .has_valid_range_descriptor = 1, |
| 1113 | .has_valid_max_dotclock = 1, |
| 1114 | .has_valid_string_termination = 1, |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1115 | .conformant = EDID_CONFORMANT, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1116 | }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1117 | |
Jacob Garber | cd23f7f | 2019-03-25 19:53:45 -0600 | [diff] [blame] | 1118 | if (!edid) { |
Jacob Garber | 1855329 | 2019-03-27 12:02:38 -0600 | [diff] [blame] | 1119 | printk(BIOS_ERR, "No EDID found\n"); |
Jacob Garber | cd23f7f | 2019-03-25 19:53:45 -0600 | [diff] [blame] | 1120 | return EDID_ABSENT; |
| 1121 | } |
| 1122 | |
| 1123 | dump_breakdown(edid); |
| 1124 | |
| 1125 | if (memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) { |
Jacob Garber | 1855329 | 2019-03-27 12:02:38 -0600 | [diff] [blame] | 1126 | printk(BIOS_ERR, "No header found\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1127 | return EDID_ABSENT; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1128 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1129 | |
Paul Menzel | 1ced4e6 | 2020-02-15 13:12:04 +0100 | [diff] [blame] | 1130 | memset(out, 0, sizeof(*out)); |
| 1131 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 1132 | if (manufacturer_name(edid + 0x08, out->manufacturer_name)) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1133 | c.manufacturer_name_well_formed = 1; |
| 1134 | |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1135 | extra_info.model = (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)); |
| 1136 | extra_info.serial = (unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1137 | + (edid[0x0E] << 16) + (edid[0x0F] << 24)); |
| 1138 | |
| 1139 | printk(BIOS_SPEW, "Manufacturer: %s Model %x Serial Number %u\n", |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 1140 | out->manufacturer_name, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1141 | (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)), |
| 1142 | (unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
| 1143 | + (edid[0x0E] << 16) + (edid[0x0F] << 24))); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1144 | /* XXX need manufacturer ID table */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1145 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1146 | if (edid[0x10] < 55 || edid[0x10] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1147 | c.has_valid_week = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1148 | if (edid[0x11] > 0x0f) { |
| 1149 | if (edid[0x10] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1150 | c.has_valid_year = 1; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1151 | printk(BIOS_SPEW, |
| 1152 | "Made week %hhd of model year %hhd\n", |
| 1153 | edid[0x10], edid[0x11]); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1154 | extra_info.week = edid[0x10]; |
| 1155 | extra_info.year = edid[0x11]; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1156 | } else { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1157 | /* we know it's at least 2013, when this code |
| 1158 | * was written |
| 1159 | */ |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1160 | if (edid[0x11] + 90 <= 2013) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1161 | c.has_valid_year = 1; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1162 | printk(BIOS_SPEW, |
| 1163 | "Made week %hhd of %d\n", |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1164 | edid[0x10], edid[0x11] + 1990); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1165 | extra_info.week = edid[0x10]; |
| 1166 | extra_info.year = edid[0x11] + 1990; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1167 | } |
| 1168 | } |
| 1169 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1170 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1171 | |
Alexandru Gagniuc | 9d0ae59 | 2014-12-10 16:44:44 -0600 | [diff] [blame] | 1172 | printk(BIOS_SPEW, "EDID version: %hhd.%hhd\n", edid[0x12], edid[0x13]); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1173 | extra_info.version[0] = edid[0x12]; |
| 1174 | extra_info.version[1] = edid[0x13]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1175 | |
| 1176 | if (edid[0x12] == 1) { |
| 1177 | if (edid[0x13] > 4) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1178 | printk(BIOS_SPEW, |
| 1179 | "Claims > 1.4, assuming 1.4 conformance\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1180 | edid[0x13] = 4; |
| 1181 | } |
| 1182 | switch (edid[0x13]) { |
| 1183 | case 4: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1184 | c.claims_one_point_four = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1185 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1186 | case 3: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1187 | c.claims_one_point_three = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1188 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1189 | case 2: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1190 | c.claims_one_point_two = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1191 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1192 | default: |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1193 | c.claims_one_point_oh = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1194 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | /* display section */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1198 | if (edid[0x14] & 0x80) { |
| 1199 | int conformance_mask; |
| 1200 | analog = 0; |
| 1201 | printk(BIOS_SPEW, "Digital display\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1202 | if (c.claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1203 | conformance_mask = 0; |
| 1204 | if ((edid[0x14] & 0x70) == 0x00) |
| 1205 | printk(BIOS_SPEW, "Color depth is undefined\n"); |
| 1206 | else if ((edid[0x14] & 0x70) == 0x70) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1207 | c.nonconformant_digital_display = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1208 | else |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1209 | printk(BIOS_SPEW, |
| 1210 | "%d bits per primary color channel\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1211 | ((edid[0x14] & 0x70) >> 3) + 4); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1212 | out->panel_bits_per_color = ((edid[0x14] & 0x70) >> 3) |
| 1213 | + 4; |
Ronald G. Minnich | 9518b56 | 2013-09-19 16:45:22 -0700 | [diff] [blame] | 1214 | out->panel_bits_per_pixel = 3*out->panel_bits_per_color; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1215 | |
| 1216 | switch (edid[0x14] & 0x0f) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1217 | case 0x00: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1218 | printk(BIOS_SPEW, |
| 1219 | "Digital interface is not defined\n"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1220 | break; |
| 1221 | case 0x01: |
| 1222 | printk(BIOS_SPEW, "DVI interface\n"); |
| 1223 | break; |
| 1224 | case 0x02: |
| 1225 | printk(BIOS_SPEW, "HDMI-a interface\n"); |
| 1226 | break; |
| 1227 | case 0x03: |
| 1228 | printk(BIOS_SPEW, "HDMI-b interface\n"); |
| 1229 | break; |
| 1230 | case 0x04: |
| 1231 | printk(BIOS_SPEW, "MDDI interface\n"); |
| 1232 | break; |
| 1233 | case 0x05: |
| 1234 | printk(BIOS_SPEW, "DisplayPort interface\n"); |
| 1235 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1236 | default: |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1237 | c.nonconformant_digital_display = 1; |
| 1238 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1239 | } |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1240 | extra_info.type = edid[0x14] & 0x0f; |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 1241 | } else if (c.claims_one_point_two) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1242 | conformance_mask = 0x7E; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 1243 | if (edid[0x14] & 0x01) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1244 | printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1245 | } else |
| 1246 | conformance_mask = 0x7F; |
| 1247 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1248 | if (!c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1249 | c.nonconformant_digital_display = edid[0x14] |
| 1250 | & conformance_mask; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1251 | extra_info.nonconformant = c.nonconformant_digital_display; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1252 | } else { |
| 1253 | analog = 1; |
| 1254 | int voltage = (edid[0x14] & 0x60) >> 5; |
| 1255 | int sync = (edid[0x14] & 0x0F); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1256 | extra_info.voltage = voltage; |
| 1257 | extra_info.sync = sync; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1258 | |
| 1259 | printk(BIOS_SPEW, "Analog display, Input voltage level: %s V\n", |
| 1260 | voltage == 3 ? "0.7/0.7" : |
| 1261 | voltage == 2 ? "1.0/0.4" : |
| 1262 | voltage == 1 ? "0.714/0.286" : |
| 1263 | "0.7/0.3"); |
| 1264 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1265 | if (c.claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1266 | if (edid[0x14] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1267 | printk(BIOS_SPEW, |
| 1268 | "Blank-to-black setup/pedestal\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1269 | else |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1270 | printk(BIOS_SPEW, |
| 1271 | "Blank level equals black level\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1272 | } else if (edid[0x14] & 0x10) { |
| 1273 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1274 | * XXX this is just the X text. 1.3 says "if set, |
| 1275 | * display expects a blank-to-black setup or pedestal |
| 1276 | * per appropriate Signal Level Standard". Whatever |
| 1277 | * _that_ means. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1278 | */ |
| 1279 | printk(BIOS_SPEW, "Configurable signal levels\n"); |
| 1280 | } |
| 1281 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1282 | printk(BIOS_SPEW, "Sync: %s%s%s%s\n", |
| 1283 | sync & 0x08 ? "Separate " : "", |
| 1284 | sync & 0x04 ? "Composite " : "", |
| 1285 | sync & 0x02 ? "SyncOnGreen " : "", |
| 1286 | sync & 0x01 ? "Serration " : ""); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
| 1289 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1290 | if (edid[0x15] && edid[0x16]) { |
| 1291 | printk(BIOS_SPEW, "Maximum image size: %d cm x %d cm\n", |
| 1292 | edid[0x15], edid[0x16]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1293 | } else if (c.claims_one_point_four && (edid[0x15] || edid[0x16])) { |
Patrick Georgi | be71ee5d | 2014-12-15 22:52:14 +0100 | [diff] [blame] | 1294 | if (edid[0x15]) { /* edid[0x15] != 0 && edid[0x16] == 0 */ |
| 1295 | unsigned int ratio = 100000/(edid[0x15] + 99); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1296 | printk(BIOS_SPEW, |
| 1297 | "Aspect ratio is %u.%03u (landscape)\n", |
| 1298 | ratio / 1000, ratio % 1000); |
Patrick Georgi | be71ee5d | 2014-12-15 22:52:14 +0100 | [diff] [blame] | 1299 | } else { /* edid[0x15] == 0 && edid[0x16] != 0 */ |
| 1300 | unsigned int ratio = 100000/(edid[0x16] + 99); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1301 | printk(BIOS_SPEW, |
| 1302 | "Aspect ratio is %u.%03u (portrait)\n", |
| 1303 | ratio / 1000, ratio % 1000); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1304 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1305 | } else { |
| 1306 | /* Either or both can be zero for 1.3 and before */ |
| 1307 | printk(BIOS_SPEW, "Image size is variable\n"); |
| 1308 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1309 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1310 | if (edid[0x17] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1311 | if (c.claims_one_point_four) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1312 | printk(BIOS_SPEW, |
| 1313 | "Gamma is defined in an extension block\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1314 | else |
| 1315 | /* XXX Technically 1.3 doesn't say this... */ |
| 1316 | printk(BIOS_SPEW, "Gamma: 1.0\n"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1317 | } else |
| 1318 | printk(BIOS_SPEW, "Gamma: %d%%\n", ((edid[0x17] + 100))); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1319 | printk(BIOS_SPEW, "Check DPMS levels\n"); |
| 1320 | if (edid[0x18] & 0xE0) { |
| 1321 | printk(BIOS_SPEW, "DPMS levels:"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1322 | if (edid[0x18] & 0x80) |
| 1323 | printk(BIOS_SPEW, " Standby"); |
| 1324 | if (edid[0x18] & 0x40) |
| 1325 | printk(BIOS_SPEW, " Suspend"); |
| 1326 | if (edid[0x18] & 0x20) |
| 1327 | printk(BIOS_SPEW, " Off"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1328 | printk(BIOS_SPEW, "\n"); |
| 1329 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1330 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1331 | /* FIXME: this is from 1.4 spec, check earlier */ |
| 1332 | if (analog) { |
| 1333 | switch (edid[0x18] & 0x18) { |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 1334 | case 0x00: |
| 1335 | printk(BIOS_SPEW, "Monochrome or grayscale display\n"); |
| 1336 | break; |
| 1337 | case 0x08: |
| 1338 | printk(BIOS_SPEW, "RGB color display\n"); |
| 1339 | break; |
| 1340 | case 0x10: |
| 1341 | printk(BIOS_SPEW, "Non-RGB color display\n"); |
| 1342 | break; |
| 1343 | case 0x18: |
| 1344 | printk(BIOS_SPEW, "Undefined display color type\n"); |
| 1345 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1346 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1347 | } else { |
| 1348 | printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4"); |
| 1349 | if (edid[0x18] & 0x10) |
| 1350 | printk(BIOS_SPEW, ", YCrCb 4:4:4"); |
| 1351 | if (edid[0x18] & 0x08) |
| 1352 | printk(BIOS_SPEW, ", YCrCb 4:2:2"); |
| 1353 | printk(BIOS_SPEW, "\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1356 | if (edid[0x18] & 0x04) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1357 | printk(BIOS_SPEW, |
| 1358 | "Default (sRGB) color space is primary color space\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1359 | if (edid[0x18] & 0x02) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1360 | printk(BIOS_SPEW, |
| 1361 | "First detailed timing is preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1362 | c.has_preferred_timing = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1363 | } |
| 1364 | if (edid[0x18] & 0x01) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1365 | printk(BIOS_SPEW, |
| 1366 | "Supports GTF timings within operating range\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1367 | |
| 1368 | /* XXX color section */ |
| 1369 | |
| 1370 | printk(BIOS_SPEW, "Established timings supported:\n"); |
| 1371 | /* it's not yet clear we want all this stuff in the edid struct. |
| 1372 | * Let's wait. |
| 1373 | */ |
| 1374 | for (i = 0; i < 17; i++) { |
| 1375 | if (edid[0x23 + i / 8] & (1 << (7 - i % 8))) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1376 | printk(BIOS_SPEW, " %dx%d@%dHz\n", |
| 1377 | established_timings[i].x, |
| 1378 | established_timings[i].y, |
| 1379 | established_timings[i].refresh); |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1380 | |
Douglas Anderson | 9fa0760 | 2015-10-28 10:19:52 -0700 | [diff] [blame] | 1381 | for (j = 0; j < NUM_KNOWN_MODES; j++) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1382 | if (known_modes[j].ha == |
| 1383 | established_timings[i].x |
| 1384 | && known_modes[j].va == |
| 1385 | established_timings[i].y |
| 1386 | && known_modes[j].refresh == |
| 1387 | established_timings[i].refresh) |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1388 | out->mode_is_supported[j] = 1; |
Douglas Anderson | 9fa0760 | 2015-10-28 10:19:52 -0700 | [diff] [blame] | 1389 | } |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1390 | } |
| 1391 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | printk(BIOS_SPEW, "Standard timings supported:\n"); |
| 1395 | for (i = 0; i < 8; i++) { |
| 1396 | uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1]; |
| 1397 | unsigned int x, y = 0, refresh; |
| 1398 | |
| 1399 | if (b1 == 0x01 && b2 == 0x01) |
| 1400 | continue; |
| 1401 | |
| 1402 | if (b1 == 0) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1403 | printk(BIOS_SPEW, |
| 1404 | "non-conformant standard timing (0 horiz)\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1405 | continue; |
| 1406 | } |
| 1407 | x = (b1 + 31) * 8; |
| 1408 | switch ((b2 >> 6) & 0x3) { |
| 1409 | case 0x00: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1410 | if (c.claims_one_point_three) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1411 | y = x * 10 / 16; |
| 1412 | else |
| 1413 | y = x; |
| 1414 | break; |
| 1415 | case 0x01: |
| 1416 | y = x * 3 / 4; |
| 1417 | break; |
| 1418 | case 0x02: |
| 1419 | y = x * 4 / 5; |
| 1420 | break; |
| 1421 | case 0x03: |
| 1422 | y = x * 9 / 16; |
| 1423 | break; |
| 1424 | } |
| 1425 | refresh = 60 + (b2 & 0x3f); |
| 1426 | |
| 1427 | printk(BIOS_SPEW, " %dx%d@%dHz\n", x, y, refresh); |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1428 | for (j = 0; j < NUM_KNOWN_MODES; j++) { |
| 1429 | if (known_modes[j].ha == x && known_modes[j].va == y && |
| 1430 | known_modes[j].refresh == refresh) |
| 1431 | out->mode_is_supported[j] = 1; |
| 1432 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | /* detailed timings */ |
| 1436 | printk(BIOS_SPEW, "Detailed timings\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1437 | for (i = 0; i < 4; i++) { |
| 1438 | c.has_valid_detailed_blocks &= detailed_block( |
| 1439 | out, edid + 0x36 + i * 18, 0, &c); |
Lee Leahy | 342f8d6 | 2017-03-10 15:31:56 -0800 | [diff] [blame] | 1440 | if (i == 0 && c.has_preferred_timing |
| 1441 | && !c.did_detailed_timing) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1442 | /* not really accurate... */ |
| 1443 | c.has_preferred_timing = 0; |
| 1444 | } |
| 1445 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1446 | |
| 1447 | /* check this, 1.4 verification guide says otherwise */ |
| 1448 | if (edid[0x7e]) { |
| 1449 | printk(BIOS_SPEW, "Has %d extension blocks\n", edid[0x7e]); |
| 1450 | /* 2 is impossible because of the block map */ |
| 1451 | if (edid[0x7e] != 2) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1452 | c.has_valid_extension_count = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1453 | } else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1454 | c.has_valid_extension_count = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | printk(BIOS_SPEW, "Checksum\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1458 | c.has_valid_checksum = do_checksum(edid); |
Hung-Te Lin | 7944581 | 2014-04-03 18:35:58 +0800 | [diff] [blame] | 1459 | |
| 1460 | /* EDID v2.0 has a larger blob (256 bytes) and may have some problem in |
| 1461 | * the extension parsing loop below. Since v2.0 was quickly deprecated |
| 1462 | * by v1.3 and we are unlikely to use any EDID 2.0 panels, we ignore |
| 1463 | * that case now and can fix it when we need to use a real 2.0 panel. |
| 1464 | */ |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 1465 | for (i = 128; i < size; i += 128) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1466 | c.nonconformant_extension += |
| 1467 | parse_extension(out, &edid[i], &c); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1468 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1469 | if (c.claims_one_point_four) { |
| 1470 | if (c.nonconformant_digital_display || |
| 1471 | !c.has_valid_string_termination || |
| 1472 | !c.has_valid_descriptor_pad || |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1473 | !c.has_preferred_timing) { |
| 1474 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1475 | printk(BIOS_ERR, |
| 1476 | "EDID block does NOT conform to EDID 1.4!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1477 | } |
| 1478 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1479 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1480 | printk(BIOS_ERR, |
| 1481 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1482 | c.nonconformant_digital_display); |
| 1483 | if (!c.has_valid_string_termination) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1484 | printk(BIOS_ERR, |
| 1485 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1486 | if (!c.has_valid_descriptor_pad) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1487 | printk(BIOS_ERR, |
| 1488 | "\tInvalid descriptor block padding\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1489 | if (!c.has_preferred_timing) |
Hung-Te Lin | 08f6c80 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1490 | printk(BIOS_ERR, "\tMissing preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1491 | } else if (c.claims_one_point_three) { |
| 1492 | if (c.nonconformant_digital_display || |
| 1493 | !c.has_valid_string_termination || |
| 1494 | !c.has_valid_descriptor_pad || |
| 1495 | !c.has_preferred_timing) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1496 | c.conformant = EDID_NOT_CONFORMANT; |
Hung-Te Lin | 076c317 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1497 | } |
| 1498 | /** |
| 1499 | * According to E-EDID (EDIDv1.3), has_name_descriptor and |
| 1500 | * has_range_descriptor are both required. These fields are |
| 1501 | * optional in v1.4. However some v1.3 panels (Ex, B133XTN01.3) |
| 1502 | * don't have them. As a workaround, we only print warning |
| 1503 | * messages. |
| 1504 | */ |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1505 | if (c.conformant == EDID_NOT_CONFORMANT) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1506 | printk(BIOS_ERR, |
| 1507 | "EDID block does NOT conform to EDID 1.3!\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1508 | else if (!c.has_name_descriptor || !c.has_range_descriptor) |
Hung-Te Lin | 076c317 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1509 | printk(BIOS_WARNING, "WARNING: EDID block does NOT " |
| 1510 | "fully conform to EDID 1.3.\n"); |
| 1511 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1512 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1513 | printk(BIOS_ERR, |
| 1514 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1515 | c.nonconformant_digital_display); |
| 1516 | if (!c.has_name_descriptor) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1517 | printk(BIOS_ERR, "\tMissing name descriptor\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1518 | if (!c.has_preferred_timing) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1519 | printk(BIOS_ERR, "\tMissing preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1520 | if (!c.has_range_descriptor) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1521 | printk(BIOS_ERR, "\tMissing monitor ranges\n"); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1522 | /* Might be more than just 1.3 */ |
| 1523 | if (!c.has_valid_descriptor_pad) |
| 1524 | printk(BIOS_ERR, |
| 1525 | "\tInvalid descriptor block padding\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1526 | if (!c.has_valid_string_termination) /* Likewise */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1527 | printk(BIOS_ERR, |
| 1528 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1529 | } else if (c.claims_one_point_two) { |
| 1530 | if (c.nonconformant_digital_display || |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1531 | !c.has_valid_string_termination) { |
| 1532 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1533 | printk(BIOS_ERR, |
| 1534 | "EDID block does NOT conform to EDID 1.2!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1535 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1536 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1537 | printk(BIOS_ERR, |
| 1538 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1539 | c.nonconformant_digital_display); |
| 1540 | if (!c.has_valid_string_termination) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1541 | printk(BIOS_ERR, |
| 1542 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1543 | } else if (c.claims_one_point_oh) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1544 | if (c.seen_non_detailed_descriptor) { |
| 1545 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1546 | printk(BIOS_ERR, |
| 1547 | "EDID block does NOT conform to EDID 1.0!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1548 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1549 | if (c.seen_non_detailed_descriptor) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1550 | printk(BIOS_ERR, |
| 1551 | "\tHas descriptor blocks other than detailed timings\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1552 | } |
| 1553 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1554 | if (c.nonconformant_extension || |
| 1555 | !c.has_valid_checksum || |
| 1556 | !c.has_valid_cvt || |
| 1557 | !c.has_valid_year || |
| 1558 | !c.has_valid_week || |
| 1559 | !c.has_valid_detailed_blocks || |
| 1560 | !c.has_valid_dummy_block || |
| 1561 | !c.has_valid_extension_count || |
| 1562 | !c.has_valid_descriptor_ordering || |
| 1563 | !c.has_valid_range_descriptor || |
| 1564 | !c.manufacturer_name_well_formed) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1565 | c.conformant = EDID_NOT_CONFORMANT; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1566 | printk(BIOS_ERR, "EDID block does not conform at all!\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1567 | if (c.nonconformant_extension) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1568 | printk(BIOS_ERR, |
| 1569 | "\tHas %d nonconformant extension block(s)\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1570 | c.nonconformant_extension); |
| 1571 | if (!c.has_valid_checksum) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1572 | printk(BIOS_ERR, "\tBlock has broken checksum\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1573 | if (!c.has_valid_cvt) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1574 | printk(BIOS_ERR, "\tBroken 3-byte CVT blocks\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1575 | if (!c.has_valid_year) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1576 | printk(BIOS_ERR, "\tBad year of manufacture\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1577 | if (!c.has_valid_week) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1578 | printk(BIOS_ERR, "\tBad week of manufacture\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1579 | if (!c.has_valid_detailed_blocks) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1580 | printk(BIOS_ERR, |
| 1581 | "\tDetailed blocks filled with garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1582 | if (!c.has_valid_dummy_block) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1583 | printk(BIOS_ERR, "\tDummy block filled with garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1584 | if (!c.has_valid_extension_count) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1585 | printk(BIOS_ERR, |
| 1586 | "\tImpossible extension block count\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1587 | if (!c.manufacturer_name_well_formed) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1588 | printk(BIOS_ERR, |
| 1589 | "\tManufacturer name field contains garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1590 | if (!c.has_valid_descriptor_ordering) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1591 | printk(BIOS_ERR, |
| 1592 | "\tInvalid detailed timing descriptor ordering\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1593 | if (!c.has_valid_range_descriptor) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1594 | printk(BIOS_ERR, |
| 1595 | "\tRange descriptor contains garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1596 | if (!c.has_valid_max_dotclock) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1597 | printk(BIOS_ERR, |
| 1598 | "\tEDID 1.4 block does not set max dotclock\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1599 | } |
| 1600 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1601 | if (c.warning_excessive_dotclock_correction) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1602 | printk(BIOS_ERR, |
| 1603 | "Warning: CVT block corrects dotclock by more than 9.75MHz\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1604 | if (c.warning_zero_preferred_refresh) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1605 | printk(BIOS_ERR, |
| 1606 | "Warning: CVT block does not set preferred refresh rate\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1607 | return c.conformant; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1608 | } |
| 1609 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1610 | /* |
| 1611 | * Notes on panel extensions: (TODO, implement me in the code) |
| 1612 | * |
| 1613 | * EPI: http://www.epi-standard.org/fileadmin/spec/EPI_Specification1.0.pdf |
| 1614 | * at offset 0x6c (fourth detailed block): (all other bits reserved) |
| 1615 | * 0x6c: 00 00 00 0e 00 |
| 1616 | * 0x71: bit 6-5: data color mapping (00 conventional/fpdi/vesa, 01 openldi) |
| 1617 | * bit 4-3: pixels per clock (00 1, 01 2, 10 4, 11 reserved) |
| 1618 | * bit 2-0: bits per pixel (000 18, 001 24, 010 30, else reserved) |
| 1619 | * 0x72: bit 5: FPSCLK polarity (0 normal 1 inverted) |
| 1620 | * bit 4: DE polarity (0 high active 1 low active) |
| 1621 | * bit 3-0: interface (0000 LVDS TFT |
| 1622 | * 0001 mono STN 4/8bit |
| 1623 | * 0010 color STN 8/16 bit |
| 1624 | * 0011 18 bit tft |
| 1625 | * 0100 24 bit tft |
| 1626 | * 0101 tmds |
| 1627 | * else reserved) |
| 1628 | * 0x73: bit 1: horizontal display mode (0 normal 1 right/left reverse) |
| 1629 | * bit 0: vertical display mode (0 normal 1 up/down reverse) |
| 1630 | * 0x74: bit 7-4: total poweroff seq delay (0000 vga controller default |
| 1631 | * else time in 10ms (10ms to 150ms)) |
| 1632 | * bit 3-0: total poweron seq delay (as above) |
| 1633 | * 0x75: contrast power on/off seq delay, same as 0x74 |
| 1634 | * 0x76: bit 7: backlight control enable (1 means this field is valid) |
| 1635 | * bit 6: backlight enabled at boot (0 on 1 off) |
| 1636 | * bit 5-0: backlight brightness control steps (0..63) |
| 1637 | * 0x77: bit 7: contrast control, same bit pattern as 0x76 except bit 6 resvd |
| 1638 | * 0x78 - 0x7c: reserved |
| 1639 | * 0x7d: bit 7-4: EPI descriptor major version (1) |
| 1640 | * bit 3-0: EPI descriptor minor version (0) |
| 1641 | * |
| 1642 | * ---- |
| 1643 | * |
| 1644 | * SPWG: http://www.spwg.org/spwg_spec_version3.8_3-14-2007.pdf |
| 1645 | * |
| 1646 | * Since these are "dummy" blocks, terminate with 0a 20 20 20 ... as usual |
| 1647 | * |
| 1648 | * detailed descriptor 3: |
| 1649 | * 0x5a - 0x5e: 00 00 00 fe 00 |
| 1650 | * 0x5f - 0x63: PC maker part number |
| 1651 | * 0x64: LCD supplier revision # |
| 1652 | * 0x65 - 0x6b: manufacturer part number |
| 1653 | * |
| 1654 | * detailed descriptor 4: |
| 1655 | * 0x6c - 0x70: 00 00 00 fe 00 |
| 1656 | * 0x71 - 0x78: smbus nits values (whut) |
| 1657 | * 0x79: number of lvds channels (1 or 2) |
| 1658 | * 0x7A: panel self test (1 if present) |
| 1659 | * and then dummy terminator |
| 1660 | * |
| 1661 | * SPWG also says something strange about the LSB of detailed descriptor 1: |
| 1662 | * "LSB is set to "1" if panel is DE-timing only. H/V can be ignored." |
| 1663 | */ |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1664 | |
| 1665 | /* Set the framebuffer bits-per-pixel, recalculating all dependent values. */ |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 1666 | void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, |
| 1667 | int row_byte_alignment) |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1668 | { |
| 1669 | /* Caller should pass a supported value, everything else is BUG(). */ |
| 1670 | assert(fb_bpp == 32 || fb_bpp == 24 || fb_bpp == 16); |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 1671 | row_byte_alignment = MAX(row_byte_alignment, 1); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1672 | |
| 1673 | edid->framebuffer_bits_per_pixel = fb_bpp; |
| 1674 | edid->bytes_per_line = ALIGN_UP(edid->mode.ha * |
Elyes HAOUAS | 6df3b64 | 2018-11-26 22:53:49 +0100 | [diff] [blame] | 1675 | DIV_ROUND_UP(fb_bpp, 8), row_byte_alignment); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1676 | edid->x_resolution = edid->bytes_per_line / (fb_bpp / 8); |
| 1677 | edid->y_resolution = edid->mode.va; |
| 1678 | } |