blob: 460d68dcb2174ef636a1c6efd3170909311e3409 [file] [log] [blame]
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -07001/*
2 * Copyright 2013 Google Inc.
3 * Copyright 2006-2012 Red Hat, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23/* Author: Adam Jackson <ajax@nwnk.net> */
24
25/* this is a pretty robust parser for EDID, and we're tasked with parsing
26 * an arbitrary panel. We will pass it a raw EDID block and a struct which
27 * it must fill in with values. The set of values we need is pretty limited
28 * at present.
29 */
30
31#include <stddef.h>
32#include <console/console.h>
33#include <arch/io.h>
34#include <arch/byteorder.h>
35#include <stdint.h>
36#include <string.h>
37#include <stdlib.h>
38#include <edid.h>
39
40static int claims_one_point_oh = 0;
41static int claims_one_point_two = 0;
42static int claims_one_point_three = 0;
43static int claims_one_point_four = 0;
44static int nonconformant_digital_display = 0;
45static int nonconformant_extension = 0;
46static int did_detailed_timing = 0;
47static int has_name_descriptor = 0;
48static int name_descriptor_terminated = 0;
49static int has_range_descriptor = 0;
50static int has_preferred_timing = 0;
51static int has_valid_checksum = 0;
52static int has_valid_cvt = 1;
53static int has_valid_dummy_block = 1;
54static int has_valid_week = 0;
55static int has_valid_year = 0;
56static int has_valid_detailed_blocks = 0;
57static int has_valid_extension_count = 0;
58static int has_valid_descriptor_ordering = 1;
59static int has_valid_descriptor_pad = 1;
60static int has_valid_range_descriptor = 1;
61static int has_valid_max_dotclock = 1;
62static int has_valid_string_termination = 1;
63static int manufacturer_name_well_formed = 0;
64static int seen_non_detailed_descriptor = 0;
65
66static int warning_excessive_dotclock_correction = 0;
67static int warning_zero_preferred_refresh = 0;
68
69static int conformant = 1;
70
71static char *manufacturer_name(struct edid *out, unsigned char *x)
72{
73 out->manuf_name[0] = ((x[0] & 0x7C) >> 2) + '@';
74 out->manuf_name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@';
75 out->manuf_name[2] = (x[1] & 0x1F) + '@';
76 out->manuf_name[3] = 0;
77
78 if (isupper(out->manuf_name[0]) &&
79 isupper(out->manuf_name[1]) &&
80 isupper(out->manuf_name[2]))
81 manufacturer_name_well_formed = 1;
82
83 return out->manuf_name;
84}
85
86static int
87detailed_cvt_descriptor(struct edid *out, unsigned char *x, int first)
88{
89 const unsigned char empty[3] = { 0, 0, 0 };
90 const char *names[] = { "50", "60", "75", "85" };
91 int width = 0, height = 0;
92 int valid = 1;
93 int fifty = 0, sixty = 0, seventyfive = 0, eightyfive = 0, reduced = 0;
94
95 if (!first && !memcmp(x, empty, 3))
96 return valid;
97
98 height = x[0];
99 height |= (x[1] & 0xf0) << 4;
100 height++;
101 height *= 2;
102
103 switch (x[1] & 0x0c) {
104 case 0x00:
105 width = (height * 4) / 3; break;
106 case 0x04:
107 width = (height * 16) / 9; break;
108 case 0x08:
109 width = (height * 16) / 10; break;
110 case 0x0c:
111 width = (height * 15) / 9; break;
112 }
113
114 if (x[1] & 0x03)
115 valid = 0;
116 if (x[2] & 0x80)
117 valid = 0;
118 if (!(x[2] & 0x1f))
119 valid = 0;
120
121 fifty = (x[2] & 0x10);
122 sixty = (x[2] & 0x08);
123 seventyfive = (x[2] & 0x04);
124 eightyfive = (x[2] & 0x02);
125 reduced = (x[2] & 0x01);
126
127 if (!valid) {
128 printk(BIOS_SPEW, " (broken)\n");
129 } else {
130 printk(BIOS_SPEW, " %dx%d @ ( %s%s%s%s%s) Hz (%s%s preferred)\n",
131 width, height,
132 fifty ? "50 " : "",
133 sixty ? "60 " : "",
134 seventyfive ? "75 " : "",
135 eightyfive ? "85 " : "",
136 reduced ? "60RB " : "",
137 names[(x[2] & 0x60) >> 5],
138 (((x[2] & 0x60) == 0x20) && reduced) ? "RB" : "");
139 }
140
141 return valid;
142}
143
144static int isalnum(char x)
145{
146 if (x >= 'a' && x <= 'z')
147 return 1;
148 if (x >= 'A' && x <= 'Z')
149 return 1;
150 if (x >= '0' && x <= '9')
151 return 1;
152 return 0;
153
154}
155/* extract a string from a detailed subblock, checking for termination */
156static char *
157extract_string(unsigned char *x, int *valid_termination, int len)
158{
159 static char ret[128];
160 int i, seen_newline = 0;
161
162 memset(ret, 0, sizeof(ret));
163
164 for (i = 0; i < len; i++) {
165 if (isalnum(x[i])) {
166 ret[i] = x[i];
167 } else if (!seen_newline) {
168 if (x[i] == 0x0a) {
169 seen_newline = 1;
170 } else {
171 *valid_termination = 0;
172 return ret;
173 }
174 } else {
175 if (x[i] != 0x20) {
176 *valid_termination = 0;
177 return ret;
178 }
179 }
180 }
181
182 return ret;
183}
184
185/* 1 means valid data */
186static int
187detailed_block(struct edid *out, unsigned char *x, int in_extension)
188{
189 static unsigned char name[53];
190 int i;
191#if 1
192 printk(BIOS_SPEW, "Hex of detail: ");
193 for (i = 0; i < 18; i++)
194 printk(BIOS_SPEW, "%02x", x[i]);
195 printk(BIOS_SPEW, "\n");
196#endif
197
198 if (x[0] == 0 && x[1] == 0) {
199 /* Monitor descriptor block, not detailed timing descriptor. */
200 if (x[2] != 0) {
201 /* 1.3, 3.10.3 */
202 printk(BIOS_SPEW, "Monitor descriptor block has byte 2 nonzero (0x%02x)\n",
203 x[2]);
204 has_valid_descriptor_pad = 0;
205 }
206 if (x[3] != 0xfd && x[4] != 0x00) {
207 /* 1.3, 3.10.3 */
208 printk(BIOS_SPEW, "Monitor descriptor block has byte 4 nonzero (0x%02x)\n",
209 x[4]);
210 has_valid_descriptor_pad = 0;
211 }
212
213 seen_non_detailed_descriptor = 1;
214 if (x[3] <= 0xF) {
215 /*
216 * in principle we can decode these, if we know what they are.
217 * 0x0f seems to be common in laptop panels.
218 * 0x0e is used by EPI: http://www.epi-standard.org/
219 */
220 printk(BIOS_SPEW, "Manufacturer-specified data, tag %d\n", x[3]);
221 return 0;
222 }
223 switch (x[3]) {
224 case 0x10:
225 printk(BIOS_SPEW, "Dummy block\n");
226 for (i = 5; i < 18; i++)
227 if (x[i] != 0x00)
228 has_valid_dummy_block = 0;
229 return 0;
230 case 0xF7:
231 /* TODO */
232 printk(BIOS_SPEW, "Established timings III\n");
233 return 0;
234 case 0xF8:
235 {
236 int valid_cvt = 1; /* just this block */
237 printk(BIOS_SPEW, "CVT 3-byte code descriptor:\n");
238 if (x[5] != 0x01) {
239 has_valid_cvt = 0;
240 return 0;
241 }
242 for (i = 0; i < 4; i++)
243 valid_cvt &= detailed_cvt_descriptor(out, x + 6 + (i * 3), (i == 0));
244 has_valid_cvt &= valid_cvt;
245 return 0;
246 }
247 case 0xF9:
248 /* TODO */
249 printk(BIOS_SPEW, "Color management data\n");
250 return 0;
251 case 0xFA:
252 /* TODO */
253 printk(BIOS_SPEW, "More standard timings\n");
254 return 0;
255 case 0xFB:
256 /* TODO */
257 printk(BIOS_SPEW, "Color point\n");
258 return 0;
259 case 0xFC:
260 /* XXX should check for spaces after the \n */
261 /* XXX check: terminated with 0x0A, padded with 0x20 */
262 has_name_descriptor = 1;
263 if (strchr((char *)name, '\n')) return 0;
264 /* avoid strncat
265 strncat((char *)name, (char *)x + 5, 13);
266 */
267 if (strchr((char *)name, '\n') || strchr((char *)x+5, '\n')) {
268 name_descriptor_terminated = 1;
269 /* later.
270 printk(BIOS_SPEW, "Monitor name: %s\n",
271 extract_string(name, &has_valid_string_termination,
272 strlen((char *)name)));
273 */
274 }
275 return 0;
276 case 0xFD:
277 {
278 int h_max_offset = 0, h_min_offset = 0;
279 int v_max_offset = 0, v_min_offset = 0;
280 int is_cvt = 0;
281 has_range_descriptor = 1;
282 out->range_class = "";
283 /*
284 * XXX todo: implement feature flags, vtd blocks
285 * XXX check: ranges are well-formed; block termination if no vtd
286 */
287 if (claims_one_point_four) {
288 if (x[4] & 0x02) {
289 v_max_offset = 255;
290 if (x[4] & 0x01) {
291 v_min_offset = 255;
292 }
293 }
294 if (x[4] & 0x04) {
295 h_max_offset = 255;
296 if (x[4] & 0x03) {
297 h_min_offset = 255;
298 }
299 }
300 } else if (x[4]) {
301 has_valid_range_descriptor = 0;
302 }
303
304 /*
305 * despite the values, this is not a bitfield.
306 */
307 switch (x[10]) {
308 case 0x00: /* default gtf */
309 out->range_class = "GTF";
310 break;
311 case 0x01: /* range limits only */
312 out->range_class = "bare limits";
313 if (!claims_one_point_four)
314 has_valid_range_descriptor = 0;
315 break;
316 case 0x02: /* secondary gtf curve */
317 out->range_class = "GTF with icing";
318 break;
319 case 0x04: /* cvt */
320 out->range_class = "CVT";
321 is_cvt = 1;
322 if (!claims_one_point_four)
323 has_valid_range_descriptor = 0;
324 break;
325 default: /* invalid */
326 has_valid_range_descriptor = 0;
327 out->range_class = "invalid";
328 break;
329 }
330
331 if (x[5] + v_min_offset > x[6] + v_max_offset)
332 has_valid_range_descriptor = 0;
333 if (x[7] + h_min_offset > x[8] + h_max_offset)
334 has_valid_range_descriptor = 0;
335 printk(BIOS_SPEW, "Monitor ranges (%s): %d-%dHz V, %d-%dkHz H",
336 out->range_class,
337 x[5] + v_min_offset, x[6] + v_max_offset,
338 x[7] + h_min_offset, x[8] + h_max_offset);
339 if (x[9])
340 printk(BIOS_SPEW, ", max dotclock %dMHz\n", x[9] * 10);
341 else {
342 if (claims_one_point_four)
343 has_valid_max_dotclock = 0;
344 printk(BIOS_SPEW, "\n");
345 }
346
347 if (is_cvt) {
348 int max_h_pixels = 0;
349
350 printk(BIOS_SPEW, "CVT version %d.%d\n", x[11] & 0xf0 >> 4, x[11] & 0x0f);
351
352 if (x[12] & 0xfc) {
353 int raw_offset = (x[12] & 0xfc) >> 2;
354 printk(BIOS_SPEW, "Real max dotclock: %.2fMHz\n",
355 (x[9] * 10) - (raw_offset * 0.25));
356 if (raw_offset >= 40)
357 warning_excessive_dotclock_correction = 1;
358 }
359
360 max_h_pixels = x[12] & 0x03;
361 max_h_pixels <<= 8;
362 max_h_pixels |= x[13];
363 max_h_pixels *= 8;
364 if (max_h_pixels)
365 printk(BIOS_SPEW, "Max active pixels per line: %d\n", max_h_pixels);
366
367 printk(BIOS_SPEW, "Supported aspect ratios: %s %s %s %s %s\n",
368 x[14] & 0x80 ? "4:3" : "",
369 x[14] & 0x40 ? "16:9" : "",
370 x[14] & 0x20 ? "16:10" : "",
371 x[14] & 0x10 ? "5:4" : "",
372 x[14] & 0x08 ? "15:9" : "");
373 if (x[14] & 0x07)
374 has_valid_range_descriptor = 0;
375
376 printk(BIOS_SPEW, "Preferred aspect ratio: ");
377 switch((x[15] & 0xe0) >> 5) {
378 case 0x00: printk(BIOS_SPEW, "4:3"); break;
379 case 0x01: printk(BIOS_SPEW, "16:9"); break;
380 case 0x02: printk(BIOS_SPEW, "16:10"); break;
381 case 0x03: printk(BIOS_SPEW, "5:4"); break;
382 case 0x04: printk(BIOS_SPEW, "15:9"); break;
383 default: printk(BIOS_SPEW, "(broken)"); break;
384 }
385 printk(BIOS_SPEW, "\n");
386
387 if (x[15] & 0x04)
388 printk(BIOS_SPEW, "Supports CVT standard blanking\n");
389 if (x[15] & 0x10)
390 printk(BIOS_SPEW, "Supports CVT reduced blanking\n");
391
392 if (x[15] & 0x07)
393 has_valid_range_descriptor = 0;
394
395 if (x[16] & 0xf0) {
396 printk(BIOS_SPEW, "Supported display scaling:\n");
397 if (x[16] & 0x80)
398 printk(BIOS_SPEW, " Horizontal shrink\n");
399 if (x[16] & 0x40)
400 printk(BIOS_SPEW, " Horizontal stretch\n");
401 if (x[16] & 0x20)
402 printk(BIOS_SPEW, " Vertical shrink\n");
403 if (x[16] & 0x10)
404 printk(BIOS_SPEW, " Vertical stretch\n");
405 }
406
407 if (x[16] & 0x0f)
408 has_valid_range_descriptor = 0;
409
410 if (x[17])
411 printk(BIOS_SPEW, "Preferred vertical refresh: %d Hz\n", x[17]);
412 else
413 warning_zero_preferred_refresh = 1;
414 }
415
416 /*
417 * Slightly weird to return a global, but I've never seen any
418 * EDID block wth two range descriptors, so it's harmless.
419 */
420 return 0;
421 }
422 case 0xFE:
423 /*
424 * TODO: Two of these in a row, in the third and fourth slots,
425 * seems to be specified by SPWG: http://www.spwg.org/
426 */
427 printk(BIOS_SPEW, "ASCII string: %s\n",
428 extract_string(x + 5, &has_valid_string_termination, 13));
429 return 0;
430 case 0xFF:
431 printk(BIOS_SPEW, "Serial number: %s\n",
432 extract_string(x + 5, &has_valid_string_termination, 13));
433 return 0;
434 default:
435 printk(BIOS_SPEW, "Unknown monitor description type %d\n", x[3]);
436 return 0;
437 }
438 }
439
440 if (seen_non_detailed_descriptor && !in_extension) {
441 has_valid_descriptor_ordering = 0;
442 }
443
444 if (! did_detailed_timing){
445 out->ha = (x[2] + ((x[4] & 0xF0) << 4));
446 out->hbl = (x[3] + ((x[4] & 0x0F) << 8));
447 out->hso = (x[8] + ((x[11] & 0xC0) << 2));
448 out->hspw = (x[9] + ((x[11] & 0x30) << 4));
449 out->hborder = x[15];
450 out->va = (x[5] + ((x[7] & 0xF0) << 4));
451 out->vbl = (x[6] + ((x[7] & 0x0F) << 8));
452 out->vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2));
453 out->vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4));
454 out->vborder = x[16];
455 printk(BIOS_SPEW, "Did detailed timing\n");
456 }
457 did_detailed_timing = 1;
458 switch ((x[17] & 0x18) >> 3) {
459 case 0x00:
460 out->syncmethod = " analog composite";
461 break;
462 case 0x01:
463 out->syncmethod = " bipolar analog composite";
464 break;
465 case 0x02:
466 out->syncmethod = " digital composite";
467 break;
468 case 0x03:
469 out->syncmethod = "";
470 break;
471 }
472 out->pvsync = (x[17] & (1 << 2)) ? '+' : '-';
473 out->phsync = (x[17] & (1 << 1)) ? '+' : '-';
474 switch (x[17] & 0x61) {
475 case 0x20:
476 out->stereo = "field sequential L/R";
477 break;
478 case 0x40:
479 out->stereo = "field sequential R/L";
480 break;
481 case 0x21:
482 out->stereo = "interleaved right even";
483 break;
484 case 0x41:
485 out->stereo = "interleaved left even";
486 break;
487 case 0x60:
488 out->stereo = "four way interleaved";
489 break;
490 case 0x61:
491 out->stereo = "side by side interleaved";
492 break;
493 default:
494 out->stereo = "";
495 break;
496 }
497
498 printk(BIOS_SPEW, "Detailed mode (IN HEX): Clock %d0 KHz, %x mm x %x mm\n"
499 " %04x %04x %04x %04x hborder %x\n"
500 " %04x %04x %04x %04x vborder %x\n"
501 " %chsync %cvsync%s%s %s\n",
502 (x[0] + (x[1] << 8)),
503 (x[12] + ((x[14] & 0xF0) << 4)),
504 (x[13] + ((x[14] & 0x0F) << 8)),
505 out->ha, out->ha + out->hso, out->ha + out->hso + out->hspw,
506 out->ha + out->hbl, out->hborder,
507 out->va, out->va + out->vso, out->va + out->vso + out->vspw,
508 out->va + out->vbl, out->vborder,
509 out->phsync, out->pvsync,
510 out->syncmethod, x[17] & 0x80 ?" interlaced" : "",
511 out->stereo
512 );
513 return 1;
514}
515
516static int
517do_checksum(unsigned char *x)
518{
519 printk(BIOS_SPEW, "Checksum: 0x%hx", x[0x7f]);
520 {
521 unsigned char sum = 0;
522 int i;
523 for (i = 0; i < 128; i++)
524 sum += x[i];
525 if (sum) {
526 printk(BIOS_SPEW, " (should be 0x%hx)", (unsigned char)(x[0x7f] - sum));
527 has_valid_checksum = 0;
528 } else {
529 has_valid_checksum = 1;
530 printk(BIOS_SPEW, " (valid)");
531 }
532 }
533 printk(BIOS_SPEW, "\n");
534 return has_valid_checksum;
535}
536
537/* CEA extension */
538
539static const char *
540audio_format(unsigned char x)
541{
542 switch (x) {
543 case 0: return "RESERVED";
544 case 1: return "Linear PCM";
545 case 2: return "AC-3";
546 case 3: return "MPEG 1 (Layers 1 & 2)";
547 case 4: return "MPEG 1 Layer 3 (MP3)";
548 case 5: return "MPEG2 (multichannel)";
549 case 6: return "AAC";
550 case 7: return "DTS";
551 case 8: return "ATRAC";
552 case 9: return "One Bit Audio";
553 case 10: return "Dolby Digital+";
554 case 11: return "DTS-HD";
555 case 12: return "MAT (MLP)";
556 case 13: return "DST";
557 case 14: return "WMA Pro";
558 case 15: return "RESERVED";
559 }
560 return "BROKEN"; /* can't happen */
561}
562
563static void
564cea_audio_block(unsigned char *x)
565{
566 int i, format;
567 int length = x[0] & 0x1f;
568
569 if (length % 3) {
570 printk(BIOS_SPEW, "Broken CEA audio block length %d\n", length);
571 /* XXX non-conformant */
572 return;
573 }
574
575 for (i = 1; i < length; i += 3) {
576 format = (x[i] & 0x78) >> 3;
577 printk(BIOS_SPEW, " %s, max channels %d\n", audio_format(format),
578 x[i] & 0x07);
579 printk(BIOS_SPEW, " Supported sample rates (kHz):%s%s%s%s%s%s%s\n",
580 (x[i+1] & 0x40) ? " 192" : "",
581 (x[i+1] & 0x20) ? " 176.4" : "",
582 (x[i+1] & 0x10) ? " 96" : "",
583 (x[i+1] & 0x08) ? " 88.2" : "",
584 (x[i+1] & 0x04) ? " 48" : "",
585 (x[i+1] & 0x02) ? " 44.1" : "",
586 (x[i+1] & 0x01) ? " 32" : "");
587 if (format == 1) {
588 printk(BIOS_SPEW, " Supported sample sizes (bits):%s%s%s\n",
589 (x[2] & 0x04) ? " 24" : "",
590 (x[2] & 0x02) ? " 20" : "",
591 (x[2] & 0x01) ? " 16" : "");
592 } else if (format <= 8) {
593 printk(BIOS_SPEW, " Maximum bit rate: %d kHz\n", x[2] * 8);
594 }
595 }
596}
597
598static void
599cea_video_block(unsigned char *x)
600{
601 int i;
602 int length = x[0] & 0x1f;
603
604 for (i = 1; i < length; i++)
605 printk(BIOS_SPEW," VIC %02d %s\n", x[i] & 0x7f,
606 x[i] & 0x80 ? "(native)" : "");
607}
608
609static void
610cea_hdmi_block(struct edid *out, unsigned char *x)
611{
612 int length = x[0] & 0x1f;
613
614 printk(BIOS_SPEW, " (HDMI)\n");
615 printk(BIOS_SPEW,
616 " Source physical address %d.%d.%d.%d\n",
617 x[4] >> 4, x[4] & 0x0f, x[5] >> 4, x[5] & 0x0f);
618
619 if (length > 5) {
620 if (x[6] & 0x80)
621 printk(BIOS_SPEW, " Supports_AI\n");
622 if (x[6] & 0x40)
623 printk(BIOS_SPEW, " DC_48bit\n");
624 if (x[6] & 0x20)
625 printk(BIOS_SPEW, " DC_36bit\n");
626 if (x[6] & 0x10)
627 printk(BIOS_SPEW, " DC_30bit\n");
628 if (x[6] & 0x08)
629 printk(BIOS_SPEW, " DC_Y444\n");
630 /* two reserved */
631 if (x[6] & 0x01)
632 printk(BIOS_SPEW, " DVI_Dual\n");
633 }
634
635 if (length > 6)
636 printk(BIOS_SPEW, " Maximum TMDS clock: %dMHz\n", x[7] * 5);
637
638 /* XXX the walk here is really ugly, and needs to be length-checked */
639 if (length > 7) {
640 int b = 0;
641
642 if (x[8] & 0x80) {
643 printk(BIOS_SPEW, " Video latency: %d\n", x[9 + b]);
644 printk(BIOS_SPEW, " Audio latency: %d\n", x[10 + b]);
645 b += 2;
646 }
647
648 if (x[8] & 0x40) {
649 printk(BIOS_SPEW, " Interlaced video latency: %d\n", x[9 + b]);
650 printk(BIOS_SPEW, " Interlaced audio latency: %d\n", x[10 + b]);
651 b += 2;
652 }
653
654 if (x[8] & 0x20) {
655 int mask = 0, formats = 0;
656 int len_xx, len_3d;
657 printk(BIOS_SPEW, " Extended HDMI video details:\n");
658 if (x[9 + b] & 0x80)
659 printk(BIOS_SPEW, " 3D present\n");
660 if ((x[9 + b] & 0x60) == 0x20) {
661 printk(BIOS_SPEW, " All advertised VICs are 3D-capable\n");
662 formats = 1;
663 }
664 if ((x[9 + b] & 0x60) == 0x40) {
665 printk(BIOS_SPEW, " 3D-capable-VIC mask present\n");
666 formats = 1;
667 mask = 1;
668 }
669 switch (x[9 + b] & 0x18) {
670 case 0x00: break;
671 case 0x08:
672 printk(BIOS_SPEW, " Base EDID image size is aspect ratio\n");
673 break;
674 case 0x10:
675 printk(BIOS_SPEW, " Base EDID image size is in units of 1cm\n");
676 break;
677 case 0x18:
678 printk(BIOS_SPEW, " Base EDID image size is in units of 5cm\n");
679 break;
680 }
681 len_xx = (x[10 + b] & 0xe0) >> 5;
682 len_3d = (x[10 + b] & 0x1f) >> 0;
683 b += 2;
684
685 if (len_xx) {
686 printk(BIOS_SPEW, " Skipping %d bytes that HDMI refuses to publicly"
687 " document\n", len_xx);
688 b += len_xx;
689 }
690
691 if (len_3d) {
692 if (formats) {
693 if (x[9 + b] & 0x01)
694 printk(BIOS_SPEW, " Side-by-side 3D supported\n");
695 if (x[10 + b] & 0x40)
696 printk(BIOS_SPEW, " Top-and-bottom 3D supported\n");
697 if (x[10 + b] & 0x01)
698 printk(BIOS_SPEW, " Frame-packing 3D supported\n");
699 b += 2;
700 }
701 if (mask) {
702 int i;
703 printk(BIOS_SPEW, " 3D VIC indices:");
704 /* worst bit ordering ever */
705 for (i = 0; i < 8; i++)
706 if (x[10 + b] & (1 << i))
707 printk(BIOS_SPEW, " %d", i);
708 for (i = 0; i < 8; i++)
709 if (x[9 + b] & (1 << i))
710 printk(BIOS_SPEW, " %d", i + 8);
711 printk(BIOS_SPEW, "\n");
712 b += 2;
713 }
714
715 /*
716 * XXX list of nibbles:
717 * 2D_VIC_Order_X
718 * 3D_Structure_X
719 * (optionally: 3D_Detail_X and reserved)
720 */
721 }
722
723 }
724 }
725}
726
727static void
728cea_block(struct edid *out, unsigned char *x)
729{
730 unsigned int oui;
731
732 switch ((x[0] & 0xe0) >> 5) {
733 case 0x01:
734 printk(BIOS_SPEW, " Audio data block\n");
735 cea_audio_block(x);
736 break;
737 case 0x02:
738 printk(BIOS_SPEW, " Video data block\n");
739 cea_video_block(x);
740 break;
741 case 0x03:
742 /* yes really, endianness lols */
743 oui = (x[3] << 16) + (x[2] << 8) + x[1];
744 printk(BIOS_SPEW, " Vendor-specific data block, OUI %06x", oui);
745 if (oui == 0x000c03)
746 cea_hdmi_block(out, x);
747 else
748 printk(BIOS_SPEW, "\n");
749 break;
750 case 0x04:
751 printk(BIOS_SPEW, " Speaker allocation data block\n");
752 break;
753 case 0x05:
754 printk(BIOS_SPEW, " VESA DTC data block\n");
755 break;
756 case 0x07:
757 printk(BIOS_SPEW, " Extended tag: ");
758 switch (x[1]) {
759 case 0x00:
760 printk(BIOS_SPEW, "video capability data block\n");
761 break;
762 case 0x01:
763 printk(BIOS_SPEW, "vendor-specific video data block\n");
764 break;
765 case 0x02:
766 printk(BIOS_SPEW, "VESA video display device information data block\n");
767 break;
768 case 0x03:
769 printk(BIOS_SPEW, "VESA video data block\n");
770 break;
771 case 0x04:
772 printk(BIOS_SPEW, "HDMI video data block\n");
773 break;
774 case 0x05:
775 printk(BIOS_SPEW, "Colorimetry data block\n");
776 break;
777 case 0x10:
778 printk(BIOS_SPEW, "CEA miscellaneous audio fields\n");
779 break;
780 case 0x11:
781 printk(BIOS_SPEW, "Vendor-specific audio data block\n");
782 break;
783 case 0x12:
784 printk(BIOS_SPEW, "HDMI audio data block\n");
785 break;
786 default:
787 if (x[1] >= 6 && x[1] <= 15)
788 printk(BIOS_SPEW, "Reserved video block (%02x)\n", x[1]);
789 else if (x[1] >= 19 && x[1] <= 31)
790 printk(BIOS_SPEW, "Reserved audio block (%02x)\n", x[1]);
791 else
792 printk(BIOS_SPEW, "Unknown (%02x)\n", x[1]);
793 break;
794 }
795 break;
796 default:
797 {
798 int tag = (*x & 0xe0) >> 5;
799 int length = *x & 0x1f;
800 printk(BIOS_SPEW,
801 " Unknown tag %d, length %d (raw %02x)\n", tag, length, *x);
802 break;
803 }
804 }
805}
806
807static int
808parse_cea(struct edid *out, unsigned char *x)
809{
810 int ret = 0;
811 int version = x[1];
812 int offset = x[2];
813 unsigned char *detailed;
814
815 if (version >= 1) do {
816 if (version == 1 && x[3] != 0)
817 ret = 1;
818
819 if (offset < 4)
820 break;
821
822 if (version < 3) {
823 printk(BIOS_SPEW, "%d 8-byte timing descriptors\n", (offset - 4) / 8);
824 if (offset - 4 > 0)
825 /* do stuff */ ;
826 } else if (version == 3) {
827 int i;
828 printk(BIOS_SPEW, "%d bytes of CEA data\n", offset - 4);
829 for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) {
830 cea_block(out, x + i);
831 }
832 }
833
834 if (version >= 2) {
835 if (x[3] & 0x80)
836 printk(BIOS_SPEW, "Underscans PC formats by default\n");
837 if (x[3] & 0x40)
838 printk(BIOS_SPEW, "Basic audio support\n");
839 if (x[3] & 0x20)
840 printk(BIOS_SPEW, "Supports YCbCr 4:4:4\n");
841 if (x[3] & 0x10)
842 printk(BIOS_SPEW, "Supports YCbCr 4:2:2\n");
843 printk(BIOS_SPEW, "%d native detailed modes\n", x[3] & 0x0f);
844 }
845
846 for (detailed = x + offset; detailed + 18 < x + 127; detailed += 18)
847 if (detailed[0])
848 detailed_block(out, detailed, 1);
849 } while (0);
850
851 do_checksum(x);
852
853 return ret;
854}
855
856/* generic extension code */
857
858static void
859extension_version(struct edid *out, unsigned char *x)
860{
861 printk(BIOS_SPEW, "Extension version: %d\n", x[1]);
862}
863
864static int
865parse_extension(struct edid *out, unsigned char *x)
866{
867 int conformant_extension = 0;
868 printk(BIOS_SPEW, "\n");
869
870 switch(x[0]) {
871 case 0x02:
872 printk(BIOS_SPEW, "CEA extension block\n");
873 extension_version(out, x);
874 conformant_extension = parse_cea(out, x);
875 break;
876 case 0x10: printk(BIOS_SPEW, "VTB extension block\n"); break;
877 case 0x40: printk(BIOS_SPEW, "DI extension block\n"); break;
878 case 0x50: printk(BIOS_SPEW, "LS extension block\n"); break;
879 case 0x60: printk(BIOS_SPEW, "DPVL extension block\n"); break;
880 case 0xF0: printk(BIOS_SPEW, "Block map\n"); break;
881 case 0xFF: printk(BIOS_SPEW, "Manufacturer-specific extension block\n");
882 default:
883 printk(BIOS_SPEW, "Unknown extension block\n");
884 break;
885 }
886
887 printk(BIOS_SPEW, "\n");
888
889 return conformant_extension;
890}
891
892static const struct {
893 int x, y, refresh;
894} established_timings[] = {
895 /* 0x23 bit 7 - 0 */
896 {720, 400, 70},
897 {720, 400, 88},
898 {640, 480, 60},
899 {640, 480, 67},
900 {640, 480, 72},
901 {640, 480, 75},
902 {800, 600, 56},
903 {800, 600, 60},
904 /* 0x24 bit 7 - 0 */
905 {800, 600, 72},
906 {800, 600, 75},
907 {832, 624, 75},
908 {1280, 768, 87},
909 {1024, 768, 60},
910 {1024, 768, 70},
911 {1024, 768, 75},
912 {1280, 1024, 75},
913 /* 0x25 bit 7*/
914 {1152, 870, 75},
915};
916
917static void print_subsection(const char *name, unsigned char *edid, int start,
918 int end)
919{
920 int i;
921
922 printk(BIOS_SPEW, "%s:", name);
923 for (i = strlen(name); i < 15; i++)
924 printk(BIOS_SPEW, " ");
925 for (i = start; i <= end; i++)
926 printk(BIOS_SPEW, " %02x", edid[i]);
927 printk(BIOS_SPEW, "\n");
928}
929
930static void dump_breakdown(unsigned char *edid)
931{
932 printk(BIOS_SPEW, "Extracted contents:\n");
933 print_subsection("header", edid, 0, 7);
934 print_subsection("serial number", edid, 8, 17);
935 print_subsection("version", edid,18, 19);
936 print_subsection("basic params", edid, 20, 24);
937 print_subsection("chroma info", edid, 25, 34);
938 print_subsection("established", edid, 35, 37);
939 print_subsection("standard", edid, 38, 53);
940 print_subsection("descriptor 1", edid, 54, 71);
941 print_subsection("descriptor 2", edid, 72, 89);
942 print_subsection("descriptor 3", edid, 90, 107);
943 print_subsection("descriptor 4", edid, 108, 125);
944 print_subsection("extensions", edid, 126, 126);
945 print_subsection("checksum", edid, 127, 127);
946 printk(BIOS_SPEW, "\n");
947}
948
949/*
950 * Given a raw edid bloc, decode it into a form
951 * that other parts of coreboot can use -- mainly
952 * graphics bringup functions. The raw block is
953 * required to be 128 bytes long, per the standard,
954 * but we have no way of checking this minimum length.
955 * We accept what we are given.
956 */
957int decode_edid(unsigned char *edid, int size, struct edid *out)
958{
959 int analog, i;
960
961 dump_breakdown(edid);
962
963 if (!edid || memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) {
964 printk(BIOS_SPEW, "No header found\n");
965 return 1;
966 }
967 memset(out, 0, sizeof(*out));
968 manufacturer_name(out, edid + 0x08);
969 out->model = (unsigned short)(edid[0x0A] + (edid[0x0B] << 8));
970 out->serial = (unsigned int)(edid[0x0C] + (edid[0x0D] << 8)
971 + (edid[0x0E] << 16) + (edid[0x0F] << 24));
972
973 printk(BIOS_SPEW, "Manufacturer: %s Model %x Serial Number %u\n",
974 out->manuf_name,
975 (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)),
976 (unsigned int)(edid[0x0C] + (edid[0x0D] << 8)
977 + (edid[0x0E] << 16) + (edid[0x0F] << 24)));
978 /* XXX need manufacturer ID table */
979
980 if (edid[0x10] < 55 || edid[0x10] == 0xff) {
981 has_valid_week = 1;
982 if (edid[0x11] > 0x0f) {
983 if (edid[0x10] == 0xff) {
984 has_valid_year = 1;
985 printk(BIOS_SPEW, "Made week %hd of model year %hd\n", edid[0x10],
986 edid[0x11]);
987 out->week = edid[0x10];
988 out->year = edid[0x11];
989 } else {
990 /* we know it's at least 2013, when this code was written */
991 if (edid[0x11] + 90 <= 2013) {
992 has_valid_year = 1;
993 printk(BIOS_SPEW, "Made week %hd of %hd\n",
994 edid[0x10], edid[0x11] + 1990);
995 out->week = edid[0x10];
996 out->year = edid[0x11] + 1990;
997 }
998 }
999 }
1000 }
1001
1002
1003 printk(BIOS_SPEW, "EDID version: %hd.%hd\n", edid[0x12], edid[0x13]);
1004 out->version[0] = edid[0x12];
1005 out->version[1] = edid[0x13];
1006
1007 if (edid[0x12] == 1) {
1008 if (edid[0x13] > 4) {
1009 printk(BIOS_SPEW, "Claims > 1.4, assuming 1.4 conformance\n");
1010 edid[0x13] = 4;
1011 }
1012 switch (edid[0x13]) {
1013 case 4:
1014 claims_one_point_four = 1;
1015 case 3:
1016 claims_one_point_three = 1;
1017 case 2:
1018 claims_one_point_two = 1;
1019 default:
1020 break;
1021 }
1022 claims_one_point_oh = 1;
1023 }
1024
1025 /* display section */
1026
1027 if (edid[0x14] & 0x80) {
1028 int conformance_mask;
1029 analog = 0;
1030 printk(BIOS_SPEW, "Digital display\n");
1031 if (claims_one_point_four) {
1032 conformance_mask = 0;
1033 if ((edid[0x14] & 0x70) == 0x00)
1034 printk(BIOS_SPEW, "Color depth is undefined\n");
1035 else if ((edid[0x14] & 0x70) == 0x70)
1036 nonconformant_digital_display = 1;
1037 else
1038 printk(BIOS_SPEW, "%d bits per primary color channel\n",
1039 ((edid[0x14] & 0x70) >> 3) + 4);
1040 out->bpp = ((edid[0x14] & 0x70) >> 3) + 4;
1041
1042 switch (edid[0x14] & 0x0f) {
1043 case 0x00: printk(BIOS_SPEW, "Digital interface is not defined\n"); break;
1044 case 0x01: printk(BIOS_SPEW, "DVI interface\n"); break;
1045 case 0x02: printk(BIOS_SPEW, "HDMI-a interface\n"); break;
1046 case 0x03: printk(BIOS_SPEW, "HDMI-b interface\n"); break;
1047 case 0x04: printk(BIOS_SPEW, "MDDI interface\n"); break;
1048 case 0x05: printk(BIOS_SPEW, "DisplayPort interface\n"); break;
1049 default:
1050 nonconformant_digital_display = 1;
1051 }
1052 out->type = edid[0x14] & 0x0f;
1053 } else if (claims_one_point_two) {
1054 conformance_mask = 0x7E;
1055 if (edid[0x14] & 0x01) {
1056 printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n");
1057 }
1058 } else
1059 conformance_mask = 0x7F;
1060
1061 if (!nonconformant_digital_display)
1062 nonconformant_digital_display = edid[0x14] & conformance_mask;
1063 out->nonconformant = nonconformant_digital_display;
1064 } else {
1065 analog = 1;
1066 int voltage = (edid[0x14] & 0x60) >> 5;
1067 int sync = (edid[0x14] & 0x0F);
1068 out->voltage = voltage;
1069 out->sync = sync;
1070
1071 printk(BIOS_SPEW, "Analog display, Input voltage level: %s V\n",
1072 voltage == 3 ? "0.7/0.7" :
1073 voltage == 2 ? "1.0/0.4" :
1074 voltage == 1 ? "0.714/0.286" :
1075 "0.7/0.3");
1076
1077 if (claims_one_point_four) {
1078 if (edid[0x14] & 0x10)
1079 printk(BIOS_SPEW, "Blank-to-black setup/pedestal\n");
1080 else
1081 printk(BIOS_SPEW, "Blank level equals black level\n");
1082 } else if (edid[0x14] & 0x10) {
1083 /*
1084 * XXX this is just the X text. 1.3 says "if set, display expects
1085 * a blank-to-black setup or pedestal per appropriate Signal
1086 * Level Standard". Whatever _that_ means.
1087 */
1088 printk(BIOS_SPEW, "Configurable signal levels\n");
1089 }
1090
1091 printk(BIOS_SPEW, "Sync: %s%s%s%s\n", sync & 0x08 ? "Separate " : "",
1092 sync & 0x04 ? "Composite " : "",
1093 sync & 0x02 ? "SyncOnGreen " : "",
1094 sync & 0x01 ? "Serration " : "");
1095 }
1096
1097
1098 if (edid[0x15] && edid[0x16]) {
1099 printk(BIOS_SPEW, "Maximum image size: %d cm x %d cm\n",
1100 edid[0x15], edid[0x16]);
1101 out->xsize_cm = edid[0x15];
1102 out->ysize_cm = edid[0x16];
1103 } else if (claims_one_point_four && (edid[0x15] || edid[0x16])) {
1104 if (edid[0x15]) {
1105 printk(BIOS_SPEW, "Aspect ratio is %f (landscape)\n",
1106 100.0/(edid[0x16] + 99));
1107 /* truncated to integer %. We try to avoid floating point */
1108 out->aspect_landscape = 10000 /(edid[0x16] + 99);
1109 } else {
1110 printk(BIOS_SPEW, "Aspect ratio is %f (portrait)\n",
1111 100.0/(edid[0x15] + 99));
1112 out->aspect_portrait = 10000 /(edid[0x16] + 99);
1113 }
1114 } else {
1115 /* Either or both can be zero for 1.3 and before */
1116 printk(BIOS_SPEW, "Image size is variable\n");
1117 }
1118
1119 if (edid[0x17] == 0xff) {
1120 if (claims_one_point_four)
1121 printk(BIOS_SPEW, "Gamma is defined in an extension block\n");
1122 else
1123 /* XXX Technically 1.3 doesn't say this... */
1124 printk(BIOS_SPEW, "Gamma: 1.0\n");
1125 } else printk(BIOS_SPEW, "Gamma: %d%%\n", ((edid[0x17] + 100)));
1126 printk(BIOS_SPEW, "Check DPMS levels\n");
1127 if (edid[0x18] & 0xE0) {
1128 printk(BIOS_SPEW, "DPMS levels:");
1129 if (edid[0x18] & 0x80) printk(BIOS_SPEW, " Standby");
1130 if (edid[0x18] & 0x40) printk(BIOS_SPEW, " Suspend");
1131 if (edid[0x18] & 0x20) printk(BIOS_SPEW, " Off");
1132 printk(BIOS_SPEW, "\n");
1133 }
1134
1135/* FIXME: this is from 1.4 spec, check earlier */
1136 if (analog) {
1137 switch (edid[0x18] & 0x18) {
1138 case 0x00: printk(BIOS_SPEW, "Monochrome or grayscale display\n"); break;
1139 case 0x08: printk(BIOS_SPEW, "RGB color display\n"); break;
1140 case 0x10: printk(BIOS_SPEW, "Non-RGB color display\n"); break;
1141 case 0x18: printk(BIOS_SPEW, "Undefined display color type\n");
1142 }
1143 } else {
1144 printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4");
1145 if (edid[0x18] & 0x10)
1146 printk(BIOS_SPEW, ", YCrCb 4:4:4");
1147 if (edid[0x18] & 0x08)
1148 printk(BIOS_SPEW, ", YCrCb 4:2:2");
1149 printk(BIOS_SPEW, "\n");
1150 }
1151
1152 if (edid[0x18] & 0x04)
1153 printk(BIOS_SPEW, "Default (sRGB) color space is primary color space\n");
1154 if (edid[0x18] & 0x02) {
1155 printk(BIOS_SPEW, "First detailed timing is preferred timing\n");
1156 has_preferred_timing = 1;
1157 }
1158 if (edid[0x18] & 0x01)
1159 printk(BIOS_SPEW, "Supports GTF timings within operating range\n");
1160
1161 /* XXX color section */
1162
1163 printk(BIOS_SPEW, "Established timings supported:\n");
1164 /* it's not yet clear we want all this stuff in the edid struct.
1165 * Let's wait.
1166 */
1167 for (i = 0; i < 17; i++) {
1168 if (edid[0x23 + i / 8] & (1 << (7 - i % 8))) {
1169 printk(BIOS_SPEW, " %dx%d@%dHz\n", established_timings[i].x,
1170 established_timings[i].y, established_timings[i].refresh);
1171 }
1172 }
1173
1174 printk(BIOS_SPEW, "Standard timings supported:\n");
1175 for (i = 0; i < 8; i++) {
1176 uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1];
1177 unsigned int x, y, refresh;
1178
1179 if (b1 == 0x01 && b2 == 0x01)
1180 continue;
1181
1182 if (b1 == 0) {
1183 printk(BIOS_SPEW, "non-conformant standard timing (0 horiz)\n");
1184 continue;
1185 }
1186 x = (b1 + 31) * 8;
1187 switch ((b2 >> 6) & 0x3) {
1188 case 0x00:
1189 if (claims_one_point_three)
1190 y = x * 10 / 16;
1191 else
1192 y = x;
1193 break;
1194 case 0x01:
1195 y = x * 3 / 4;
1196 break;
1197 case 0x02:
1198 y = x * 4 / 5;
1199 break;
1200 case 0x03:
1201 y = x * 9 / 16;
1202 break;
1203 }
1204 refresh = 60 + (b2 & 0x3f);
1205
1206 printk(BIOS_SPEW, " %dx%d@%dHz\n", x, y, refresh);
1207 }
1208
1209 /* detailed timings */
1210 printk(BIOS_SPEW, "Detailed timings\n");
1211 has_valid_detailed_blocks = detailed_block(out, edid + 0x36, 0);
1212 if (has_preferred_timing && !did_detailed_timing)
1213 has_preferred_timing = 0; /* not really accurate... */
1214 has_valid_detailed_blocks &= detailed_block(out, edid + 0x48, 0);
1215 has_valid_detailed_blocks &= detailed_block(out, edid + 0x5A, 0);
1216 has_valid_detailed_blocks &= detailed_block(out, edid + 0x6C, 0);
1217
1218 /* check this, 1.4 verification guide says otherwise */
1219 if (edid[0x7e]) {
1220 printk(BIOS_SPEW, "Has %d extension blocks\n", edid[0x7e]);
1221 /* 2 is impossible because of the block map */
1222 if (edid[0x7e] != 2)
1223 has_valid_extension_count = 1;
1224 } else {
1225 has_valid_extension_count = 1;
1226 }
1227
1228 printk(BIOS_SPEW, "Checksum\n");
1229 do_checksum(edid);
1230 for(i = 0; i < size; i += 128)
1231 nonconformant_extension = parse_extension(out, &edid[i]);
1232/*
1233 x = edid;
1234 for (edid_lines /= 8; edid_lines > 1; edid_lines--) {
1235 x += 128;
1236 nonconformant_extension += parse_extension(x);
1237 }
1238*/
1239
1240 if (claims_one_point_three) {
1241 if (nonconformant_digital_display ||
1242 !has_valid_string_termination ||
1243 !has_valid_descriptor_pad ||
1244 !has_name_descriptor ||
1245 !name_descriptor_terminated ||
1246 !has_preferred_timing ||
1247 !has_range_descriptor)
1248 conformant = 0;
1249 if (!conformant)
1250 printk(BIOS_ERR, "EDID block does NOT conform to EDID 1.3!\n");
1251 if (nonconformant_digital_display)
1252 printk(BIOS_ERR, "\tDigital display field contains garbage: %x\n",
1253 nonconformant_digital_display);
1254 if (!has_name_descriptor)
1255 printk(BIOS_ERR, "\tMissing name descriptor\n");
1256 else if (!name_descriptor_terminated)
1257 printk(BIOS_ERR, "\tName descriptor not terminated with a newline\n");
1258 if (!has_preferred_timing)
1259 printk(BIOS_ERR, "\tMissing preferred timing\n");
1260 if (!has_range_descriptor)
1261 printk(BIOS_ERR, "\tMissing monitor ranges\n");
1262 if (!has_valid_descriptor_pad) /* Might be more than just 1.3 */
1263 printk(BIOS_ERR, "\tInvalid descriptor block padding\n");
1264 if (!has_valid_string_termination) /* Likewise */
1265 printk(BIOS_ERR, "\tDetailed block string not properly terminated\n");
1266 } else if (claims_one_point_two) {
1267 if (nonconformant_digital_display ||
1268 (has_name_descriptor && !name_descriptor_terminated))
1269 conformant = 0;
1270 if (!conformant)
1271 printk(BIOS_ERR, "EDID block does NOT conform to EDID 1.2!\n");
1272 if (nonconformant_digital_display)
1273 printk(BIOS_ERR, "\tDigital display field contains garbage: %x\n",
1274 nonconformant_digital_display);
1275 if (has_name_descriptor && !name_descriptor_terminated)
1276 printk(BIOS_ERR, "\tName descriptor not terminated with a newline\n");
1277 } else if (claims_one_point_oh) {
1278 if (seen_non_detailed_descriptor)
1279 conformant = 0;
1280 if (!conformant)
1281 printk(BIOS_ERR, "EDID block does NOT conform to EDID 1.0!\n");
1282 if (seen_non_detailed_descriptor)
1283 printk(BIOS_ERR, "\tHas descriptor blocks other than detailed timings\n");
1284 }
1285
1286 if (nonconformant_extension ||
1287 !has_valid_checksum ||
1288 !has_valid_cvt ||
1289 !has_valid_year ||
1290 !has_valid_week ||
1291 !has_valid_detailed_blocks ||
1292 !has_valid_dummy_block ||
1293 !has_valid_extension_count ||
1294 !has_valid_descriptor_ordering ||
1295 !has_valid_range_descriptor ||
1296 !manufacturer_name_well_formed) {
1297 conformant = 0;
1298 printk(BIOS_ERR, "EDID block does not conform at all!\n");
1299 if (nonconformant_extension)
1300 printk(BIOS_ERR, "\tHas %d nonconformant extension block(s)\n",
1301 nonconformant_extension);
1302 if (!has_valid_checksum)
1303 printk(BIOS_ERR, "\tBlock has broken checksum\n");
1304 if (!has_valid_cvt)
1305 printk(BIOS_ERR, "\tBroken 3-byte CVT blocks\n");
1306 if (!has_valid_year)
1307 printk(BIOS_ERR, "\tBad year of manufacture\n");
1308 if (!has_valid_week)
1309 printk(BIOS_ERR, "\tBad week of manufacture\n");
1310 if (!has_valid_detailed_blocks)
1311 printk(BIOS_ERR, "\tDetailed blocks filled with garbage\n");
1312 if (!has_valid_dummy_block)
1313 printk(BIOS_ERR, "\tDummy block filled with garbage\n");
1314 if (!has_valid_extension_count)
1315 printk(BIOS_ERR, "\tImpossible extension block count\n");
1316 if (!manufacturer_name_well_formed)
1317 printk(BIOS_ERR, "\tManufacturer name field contains garbage\n");
1318 if (!has_valid_descriptor_ordering)
1319 printk(BIOS_ERR, "\tInvalid detailed timing descriptor ordering\n");
1320 if (!has_valid_range_descriptor)
1321 printk(BIOS_ERR, "\tRange descriptor contains garbage\n");
1322 if (!has_valid_max_dotclock)
1323 printk(BIOS_ERR, "\tEDID 1.4 block does not set max dotclock\n");
1324 }
1325
1326 if (warning_excessive_dotclock_correction)
1327 printk(BIOS_ERR,
1328 "Warning: CVT block corrects dotclock by more than 9.75MHz\n");
1329 if (warning_zero_preferred_refresh)
1330 printk(BIOS_ERR,
1331 "Warning: CVT block does not set preferred refresh rate\n");
1332 return !conformant;
1333 }
1334
1335/*
1336 * Notes on panel extensions: (TODO, implement me in the code)
1337 *
1338 * EPI: http://www.epi-standard.org/fileadmin/spec/EPI_Specification1.0.pdf
1339 * at offset 0x6c (fourth detailed block): (all other bits reserved)
1340 * 0x6c: 00 00 00 0e 00
1341 * 0x71: bit 6-5: data color mapping (00 conventional/fpdi/vesa, 01 openldi)
1342 * bit 4-3: pixels per clock (00 1, 01 2, 10 4, 11 reserved)
1343 * bit 2-0: bits per pixel (000 18, 001 24, 010 30, else reserved)
1344 * 0x72: bit 5: FPSCLK polarity (0 normal 1 inverted)
1345 * bit 4: DE polarity (0 high active 1 low active)
1346 * bit 3-0: interface (0000 LVDS TFT
1347 * 0001 mono STN 4/8bit
1348 * 0010 color STN 8/16 bit
1349 * 0011 18 bit tft
1350 * 0100 24 bit tft
1351 * 0101 tmds
1352 * else reserved)
1353 * 0x73: bit 1: horizontal display mode (0 normal 1 right/left reverse)
1354 * bit 0: vertical display mode (0 normal 1 up/down reverse)
1355 * 0x74: bit 7-4: total poweroff seq delay (0000 vga controller default
1356 * else time in 10ms (10ms to 150ms))
1357 * bit 3-0: total poweron seq delay (as above)
1358 * 0x75: contrast power on/off seq delay, same as 0x74
1359 * 0x76: bit 7: backlight control enable (1 means this field is valid)
1360 * bit 6: backlight enabled at boot (0 on 1 off)
1361 * bit 5-0: backlight brightness control steps (0..63)
1362 * 0x77: bit 7: contrast control, same bit pattern as 0x76 except bit 6 resvd
1363 * 0x78 - 0x7c: reserved
1364 * 0x7d: bit 7-4: EPI descriptor major version (1)
1365 * bit 3-0: EPI descriptor minor version (0)
1366 *
1367 * ----
1368 *
1369 * SPWG: http://www.spwg.org/spwg_spec_version3.8_3-14-2007.pdf
1370 *
1371 * Since these are "dummy" blocks, terminate with 0a 20 20 20 ... as usual
1372 *
1373 * detailed descriptor 3:
1374 * 0x5a - 0x5e: 00 00 00 fe 00
1375 * 0x5f - 0x63: PC maker part number
1376 * 0x64: LCD supplier revision #
1377 * 0x65 - 0x6b: manufacturer part number
1378 *
1379 * detailed descriptor 4:
1380 * 0x6c - 0x70: 00 00 00 fe 00
1381 * 0x71 - 0x78: smbus nits values (whut)
1382 * 0x79: number of lvds channels (1 or 2)
1383 * 0x7A: panel self test (1 if present)
1384 * and then dummy terminator
1385 *
1386 * SPWG also says something strange about the LSB of detailed descriptor 1:
1387 * "LSB is set to "1" if panel is DE-timing only. H/V can be ignored."
1388 */