| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <assert.h> |
| 10 |
#include <commonlib/helpers.h> |
| 11 |
#include <console/console.h> |
| 12 |
#include <ctype.h> |
| 13 |
#include <stdbool.h> |
| 14 |
#include <stdint.h> |
| 15 |
#include <string.h> |
| 16 |
#include <edid.h> |
| 17 |
#include <vbe.h> |
| 18 |
|
| 19 |
#include "edid_displayid.h" |
| 20 |
|
| 21 |
struct edid_context { |
| 22 |
int claims_one_point_oh; |
| 23 |
int claims_one_point_two; |
| 24 |
int claims_one_point_three; |
| 25 |
int claims_one_point_four; |
| 26 |
int nonconformant_digital_display; |
| 27 |
int nonconformant_extension; |
| 28 |
int did_detailed_timing; |
| 29 |
int has_name_descriptor; |
| 30 |
int has_range_descriptor; |
| 31 |
int has_preferred_timing; |
| 32 |
int has_valid_checksum; |
| 33 |
int has_valid_cvt; |
| 34 |
int has_valid_dummy_block; |
| 35 |
int has_valid_week; |
| 36 |
int has_valid_year; |
| 37 |
int has_valid_detailed_blocks; |
| 38 |
int has_valid_descriptor_ordering; |
| 39 |
int has_valid_descriptor_pad; |
| 40 |
int has_valid_range_descriptor; |
| 41 |
int has_valid_max_dotclock; |
| 42 |
int has_valid_string_termination; |
| 43 |
int manufacturer_name_well_formed; |
| 44 |
int seen_non_detailed_descriptor; |
| 45 |
int warning_excessive_dotclock_correction; |
| 46 |
int warning_zero_preferred_refresh; |
| 47 |
enum edid_status conformant; |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
static struct { |
| 53 |
unsigned int model; |
| 54 |
unsigned int serial; |
| 55 |
unsigned int year; |
| 56 |
unsigned int week; |
| 57 |
unsigned int version[2]; |
| 58 |
unsigned int nonconformant; |
| 59 |
unsigned int type; |
| 60 |
|
| 61 |
unsigned int x_mm; |
| 62 |
unsigned int y_mm; |
| 63 |
|
| 64 |
unsigned int voltage; |
| 65 |
unsigned int sync; |
| 66 |
|
| 67 |
const char *syncmethod; |
| 68 |
const char *range_class; |
| 69 |
const char *stereo; |
| 70 |
} extra_info; |
| 71 |
|
| 72 |
static struct edid tmp_edid; |
| 73 |
|
| 74 |
static int manufacturer_name(unsigned char *x, char *output) |
| 75 |
{ |
| 76 |
output[0] = ((x[0] & 0x7C) >> 2) + '@'; |
| 77 |
output[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
| 78 |
output[2] = (x[1] & 0x1F) + '@'; |
| 79 |
output[3] = 0; |
| 80 |
|
| 81 |
if (isupper(output[0]) && |
| 82 |
isupper(output[1]) && |
| 83 |
isupper(output[2])) |
| 84 |
return 1; |
| 85 |
|
| 86 |
memset(output, 0, 4); |
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
static int |
| 91 |
detailed_cvt_descriptor(unsigned char *x, int first) |
| 92 |
{ |
| 93 |
const unsigned char empty[3] = { 0, 0, 0 }; |
| 94 |
static const char *names[] = { "50", "60", "75", "85" }; |
| 95 |
int width = 0, height = 0; |
| 96 |
int valid = 1; |
| 97 |
int fifty = 0, sixty = 0, seventyfive = 0, eightyfive = 0, reduced = 0; |
| 98 |
|
| 99 |
if (!first && !memcmp(x, empty, 3)) |
| 100 |
return valid; |
| 101 |
|
| 102 |
height = x[0]; |
| 103 |
height |= (x[1] & 0xf0) << 4; |
| 104 |
height++; |
| 105 |
height *= 2; |
| 106 |
|
| 107 |
switch (x[1] & 0x0c) { |
| 108 |
case 0x00: |
| 109 |
width = (height * 4) / 3; break; |
| 110 |
case 0x04: |
| 111 |
width = (height * 16) / 9; break; |
| 112 |
case 0x08: |
| 113 |
width = (height * 16) / 10; break; |
| 114 |
case 0x0c: |
| 115 |
width = (height * 15) / 9; break; |
| 116 |
} |
| 117 |
|
| 118 |
if (x[1] & 0x03) |
| 119 |
valid = 0; |
| 120 |
if (x[2] & 0x80) |
| 121 |
valid = 0; |
| 122 |
if (!(x[2] & 0x1f)) |
| 123 |
valid = 0; |
| 124 |
|
| 125 |
fifty = (x[2] & 0x10); |
| 126 |
sixty = (x[2] & 0x08); |
| 127 |
seventyfive = (x[2] & 0x04); |
| 128 |
eightyfive = (x[2] & 0x02); |
| 129 |
reduced = (x[2] & 0x01); |
| 130 |
|
| 131 |
if (!valid) { |
| 132 |
printk(BIOS_SPEW, " (broken)\n"); |
| 133 |
} else { |
| 134 |
printk(BIOS_SPEW, |
| 135 |
" %dx%d @ (%s%s%s%s%s) Hz (%s%s preferred)\n", |
| 136 |
width, height, |
| 137 |
fifty ? "50 " : "", |
| 138 |
sixty ? "60 " : "", |
| 139 |
seventyfive ? "75 " : "", |
| 140 |
eightyfive ? "85 " : "", |
| 141 |
reduced ? "60RB " : "", |
| 142 |
names[(x[2] & 0x60) >> 5], |
| 143 |
(((x[2] & 0x60) == 0x20) && reduced) ? "RB" : ""); |
| 144 |
} |
| 145 |
|
| 146 |
return valid; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
static char * |
| 153 |
extract_string(unsigned char *x, int *valid_termination, int len) |
| 154 |
{ |
| 155 |
static char ret[EDID_ASCII_STRING_LENGTH + 1]; |
| 156 |
int i, seen_newline = 0; |
| 157 |
|
| 158 |
memset(ret, 0, sizeof(ret)); |
| 159 |
|
| 160 |
for (i = 0; i < MIN(len, EDID_ASCII_STRING_LENGTH); i++) { |
| 161 |
if (seen_newline) { |
| 162 |
if (x[i] != 0x20) { |
| 163 |
*valid_termination = 0; |
| 164 |
return ret; |
| 165 |
} |
| 166 |
} else if (x[i] == 0x0a) { |
| 167 |
seen_newline = 1; |
| 168 |
} else { |
| 169 |
|
| 170 |
ret[i] = x[i]; |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
return ret; |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
static int |
| 179 |
detailed_block(struct edid *result_edid, unsigned char *x, int in_extension, |
| 180 |
struct edid_context *c) |
| 181 |
{ |
| 182 |
struct edid *out = &tmp_edid; |
| 183 |
int i; |
| 184 |
|
| 185 |
if (console_log_level(BIOS_SPEW)) { |
| 186 |
printk(BIOS_SPEW, "Hex of detail: "); |
| 187 |
for (i = 0; i < 18; i++) |
| 188 |
printk(BIOS_SPEW, "%02x", x[i]); |
| 189 |
printk(BIOS_SPEW, "\n"); |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
*out = *result_edid; |
| 194 |
|
| 195 |
if (x[0] == 0 && x[1] == 0) { |
| 196 |
|
| 197 |
if (x[2] != 0) { |
| 198 |
|
| 199 |
printk(BIOS_SPEW, |
| 200 |
"Monitor descriptor block has byte 2 nonzero (0x%02x)\n", |
| 201 |
x[2]); |
| 202 |
c->has_valid_descriptor_pad = 0; |
| 203 |
} |
| 204 |
if (x[3] != 0xfd && x[4] != 0x00) { |
| 205 |
|
| 206 |
printk(BIOS_SPEW, |
| 207 |
"Monitor descriptor block has byte 4 nonzero (0x%02x)\n", |
| 208 |
x[4]); |
| 209 |
c->has_valid_descriptor_pad = 0; |
| 210 |
} |
| 211 |
|
| 212 |
c->seen_non_detailed_descriptor = 1; |
| 213 |
if (x[3] <= 0xF) { |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
printk(BIOS_SPEW, |
| 221 |
"Manufacturer-specified data, tag %d\n", x[3]); |
| 222 |
return 1; |
| 223 |
} |
| 224 |
switch (x[3]) { |
| 225 |
case 0x10: |
| 226 |
printk(BIOS_SPEW, "Dummy block\n"); |
| 227 |
for (i = 5; i < 18; i++) |
| 228 |
if (x[i] != 0x00) |
| 229 |
c->has_valid_dummy_block = 0; |
| 230 |
return 1; |
| 231 |
case 0xF7: |
| 232 |
|
| 233 |
printk(BIOS_SPEW, "Established timings III\n"); |
| 234 |
return 1; |
| 235 |
case 0xF8: |
| 236 |
{ |
| 237 |
int valid_cvt = 1; |
| 238 |
printk(BIOS_SPEW, "CVT 3-byte code descriptor:\n"); |
| 239 |
if (x[5] != 0x01) { |
| 240 |
c->has_valid_cvt = 0; |
| 241 |
return 0; |
| 242 |
} |
| 243 |
for (i = 0; i < 4; i++) |
| 244 |
valid_cvt &= detailed_cvt_descriptor(x + 6 |
| 245 |
+ (i * 3), (i == 0)); |
| 246 |
c->has_valid_cvt &= valid_cvt; |
| 247 |
return 1; |
| 248 |
} |
| 249 |
case 0xF9: |
| 250 |
|
| 251 |
printk(BIOS_SPEW, "Color management data\n"); |
| 252 |
return 1; |
| 253 |
case 0xFA: |
| 254 |
|
| 255 |
printk(BIOS_SPEW, "More standard timings\n"); |
| 256 |
return 1; |
| 257 |
case 0xFB: |
| 258 |
|
| 259 |
printk(BIOS_SPEW, "Color point\n"); |
| 260 |
return 1; |
| 261 |
case 0xFC: |
| 262 |
printk(BIOS_SPEW, "Monitor name: %s\n", |
| 263 |
extract_string(x + 5, |
| 264 |
&c->has_valid_string_termination, |
| 265 |
EDID_ASCII_STRING_LENGTH)); |
| 266 |
c->has_name_descriptor = 1; |
| 267 |
return 1; |
| 268 |
case 0xFD: |
| 269 |
{ |
| 270 |
int h_max_offset = 0, h_min_offset = 0; |
| 271 |
int v_max_offset = 0, v_min_offset = 0; |
| 272 |
int is_cvt = 0; |
| 273 |
c->has_range_descriptor = 1; |
| 274 |
extra_info.range_class = ""; |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
if (c->claims_one_point_four) { |
| 281 |
if (x[4] & 0x02) { |
| 282 |
v_max_offset = 255; |
| 283 |
if (x[4] & 0x01) |
| 284 |
v_min_offset = 255; |
| 285 |
} |
| 286 |
if (x[4] & 0x04) { |
| 287 |
h_max_offset = 255; |
| 288 |
if (x[4] & 0x03) |
| 289 |
h_min_offset = 255; |
| 290 |
} |
| 291 |
} else if (x[4]) { |
| 292 |
c->has_valid_range_descriptor = 0; |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
switch (x[10]) { |
| 299 |
case 0x00: |
| 300 |
extra_info.range_class = "GTF"; |
| 301 |
break; |
| 302 |
case 0x01: |
| 303 |
extra_info.range_class = "bare limits"; |
| 304 |
if (!c->claims_one_point_four) |
| 305 |
c->has_valid_range_descriptor = 0; |
| 306 |
break; |
| 307 |
case 0x02: |
| 308 |
extra_info.range_class = "GTF with icing"; |
| 309 |
break; |
| 310 |
case 0x04: |
| 311 |
extra_info.range_class = "CVT"; |
| 312 |
is_cvt = 1; |
| 313 |
if (!c->claims_one_point_four) |
| 314 |
c->has_valid_range_descriptor = 0; |
| 315 |
break; |
| 316 |
default: |
| 317 |
c->has_valid_range_descriptor = 0; |
| 318 |
extra_info.range_class = "invalid"; |
| 319 |
break; |
| 320 |
} |
| 321 |
|
| 322 |
if (x[5] + v_min_offset > x[6] + v_max_offset) |
| 323 |
c->has_valid_range_descriptor = 0; |
| 324 |
if (x[7] + h_min_offset > x[8] + h_max_offset) |
| 325 |
c->has_valid_range_descriptor = 0; |
| 326 |
printk(BIOS_SPEW, |
| 327 |
"Monitor ranges (%s): %d-%dHz V, %d-%dkHz H", |
| 328 |
extra_info.range_class, |
| 329 |
x[5] + v_min_offset, x[6] + v_max_offset, |
| 330 |
x[7] + h_min_offset, x[8] + h_max_offset); |
| 331 |
if (x[9]) |
| 332 |
printk(BIOS_SPEW, |
| 333 |
", max dotclock %dMHz\n", x[9] * 10); |
| 334 |
else { |
| 335 |
if (c->claims_one_point_four) |
| 336 |
c->has_valid_max_dotclock = 0; |
| 337 |
printk(BIOS_SPEW, "\n"); |
| 338 |
} |
| 339 |
|
| 340 |
if (is_cvt) { |
| 341 |
int max_h_pixels = 0; |
| 342 |
|
| 343 |
printk(BIOS_SPEW, "CVT version %d.%d\n", |
| 344 |
x[11] & 0xf0 >> 4, x[11] & 0x0f); |
| 345 |
|
| 346 |
if (x[12] & 0xfc) { |
| 347 |
int raw_offset = (x[12] & 0xfc) >> 2; |
| 348 |
printk(BIOS_SPEW, |
| 349 |
"Real max dotclock: %dKHz\n", |
| 350 |
(x[9] * 10000) |
| 351 |
- (raw_offset * 250)); |
| 352 |
if (raw_offset >= 40) |
| 353 |
c->warning_excessive_dotclock_correction = 1; |
| 354 |
} |
| 355 |
|
| 356 |
max_h_pixels = x[12] & 0x03; |
| 357 |
max_h_pixels <<= 8; |
| 358 |
max_h_pixels |= x[13]; |
| 359 |
max_h_pixels *= 8; |
| 360 |
if (max_h_pixels) |
| 361 |
printk(BIOS_SPEW, |
| 362 |
"Max active pixels per line: %d\n", |
| 363 |
max_h_pixels); |
| 364 |
|
| 365 |
printk(BIOS_SPEW, |
| 366 |
"Supported aspect ratios: %s %s %s %s %s\n", |
| 367 |
x[14] & 0x80 ? "4:3" : "", |
| 368 |
x[14] & 0x40 ? "16:9" : "", |
| 369 |
x[14] & 0x20 ? "16:10" : "", |
| 370 |
x[14] & 0x10 ? "5:4" : "", |
| 371 |
x[14] & 0x08 ? "15:9" : ""); |
| 372 |
if (x[14] & 0x07) |
| 373 |
c->has_valid_range_descriptor = 0; |
| 374 |
|
| 375 |
printk(BIOS_SPEW, "Preferred aspect ratio: "); |
| 376 |
switch ((x[15] & 0xe0) >> 5) { |
| 377 |
case 0x00: |
| 378 |
printk(BIOS_SPEW, "4:3"); |
| 379 |
break; |
| 380 |
case 0x01: |
| 381 |
printk(BIOS_SPEW, "16:9"); |
| 382 |
break; |
| 383 |
case 0x02: |
| 384 |
printk(BIOS_SPEW, "16:10"); |
| 385 |
break; |
| 386 |
case 0x03: |
| 387 |
printk(BIOS_SPEW, "5:4"); |
| 388 |
break; |
| 389 |
case 0x04: |
| 390 |
printk(BIOS_SPEW, "15:9"); |
| 391 |
break; |
| 392 |
default: |
| 393 |
printk(BIOS_SPEW, "(broken)"); |
| 394 |
break; |
| 395 |
} |
| 396 |
printk(BIOS_SPEW, "\n"); |
| 397 |
|
| 398 |
if (x[15] & 0x04) |
| 399 |
printk(BIOS_SPEW, |
| 400 |
"Supports CVT standard blanking\n"); |
| 401 |
if (x[15] & 0x10) |
| 402 |
printk(BIOS_SPEW, |
| 403 |
"Supports CVT reduced blanking\n"); |
| 404 |
|
| 405 |
if (x[15] & 0x07) |
| 406 |
c->has_valid_range_descriptor = 0; |
| 407 |
|
| 408 |
if (x[16] & 0xf0) { |
| 409 |
printk(BIOS_SPEW, |
| 410 |
"Supported display scaling:\n"); |
| 411 |
if (x[16] & 0x80) |
| 412 |
printk(BIOS_SPEW, |
| 413 |
" Horizontal shrink\n"); |
| 414 |
if (x[16] & 0x40) |
| 415 |
printk(BIOS_SPEW, |
| 416 |
" Horizontal stretch\n"); |
| 417 |
if (x[16] & 0x20) |
| 418 |
printk(BIOS_SPEW, |
| 419 |
" Vertical shrink\n"); |
| 420 |
if (x[16] & 0x10) |
| 421 |
printk(BIOS_SPEW, |
| 422 |
" Vertical stretch\n"); |
| 423 |
} |
| 424 |
|
| 425 |
if (x[16] & 0x0f) |
| 426 |
c->has_valid_range_descriptor = 0; |
| 427 |
|
| 428 |
if (x[17]) |
| 429 |
printk(BIOS_SPEW, |
| 430 |
"Preferred vertical refresh: %d Hz\n", |
| 431 |
x[17]); |
| 432 |
else |
| 433 |
c->warning_zero_preferred_refresh = 1; |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
return 1; |
| 442 |
} |
| 443 |
case 0xFE: |
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
strcpy(result_edid->ascii_string, extract_string(x + 5, |
| 450 |
&c->has_valid_string_termination, |
| 451 |
EDID_ASCII_STRING_LENGTH)); |
| 452 |
printk(BIOS_SPEW, "ASCII string: %s\n", |
| 453 |
result_edid->ascii_string); |
| 454 |
return 1; |
| 455 |
case 0xFF: |
| 456 |
printk(BIOS_SPEW, "Serial number: %s\n", |
| 457 |
extract_string(x + 5, |
| 458 |
&c->has_valid_string_termination, |
| 459 |
EDID_ASCII_STRING_LENGTH)); |
| 460 |
return 1; |
| 461 |
default: |
| 462 |
printk(BIOS_SPEW, |
| 463 |
"Unknown monitor description type %d\n", |
| 464 |
x[3]); |
| 465 |
return 0; |
| 466 |
} |
| 467 |
} |
| 468 |
|
| 469 |
if (c->seen_non_detailed_descriptor && !in_extension) |
| 470 |
c->has_valid_descriptor_ordering = 0; |
| 471 |
|
| 472 |
|
| 473 |
out->mode.pixel_clock = (x[0] + (x[1] << 8)) * 10; |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000); |
| 489 |
extra_info.x_mm = (x[12] + ((x[14] & 0xF0) << 4)); |
| 490 |
extra_info.y_mm = (x[13] + ((x[14] & 0x0F) << 8)); |
| 491 |
out->mode.ha = (x[2] + ((x[4] & 0xF0) << 4)); |
| 492 |
out->mode.hbl = (x[3] + ((x[4] & 0x0F) << 8)); |
| 493 |
out->mode.hso = (x[8] + ((x[11] & 0xC0) << 2)); |
| 494 |
out->mode.hspw = (x[9] + ((x[11] & 0x30) << 4)); |
| 495 |
out->mode.hborder = x[15]; |
| 496 |
out->mode.va = (x[5] + ((x[7] & 0xF0) << 4)); |
| 497 |
out->mode.vbl = (x[6] + ((x[7] & 0x0F) << 8)); |
| 498 |
out->mode.vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2)); |
| 499 |
out->mode.vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4)); |
| 500 |
out->mode.vborder = x[16]; |
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
if (ENV_X86) |
| 508 |
edid_set_framebuffer_bits_per_pixel(out, 32, 64); |
| 509 |
else |
| 510 |
edid_set_framebuffer_bits_per_pixel(out, 32, 0); |
| 511 |
|
| 512 |
switch ((x[17] & 0x18) >> 3) { |
| 513 |
case 0x00: |
| 514 |
extra_info.syncmethod = " analog composite"; |
| 515 |
break; |
| 516 |
case 0x01: |
| 517 |
extra_info.syncmethod = " bipolar analog composite"; |
| 518 |
break; |
| 519 |
case 0x02: |
| 520 |
extra_info.syncmethod = " digital composite"; |
| 521 |
break; |
| 522 |
case 0x03: |
| 523 |
extra_info.syncmethod = ""; |
| 524 |
break; |
| 525 |
} |
| 526 |
out->mode.pvsync = (x[17] & (1 << 2)) ? '+' : '-'; |
| 527 |
out->mode.phsync = (x[17] & (1 << 1)) ? '+' : '-'; |
| 528 |
switch (x[17] & 0x61) { |
| 529 |
case 0x20: |
| 530 |
extra_info.stereo = "field sequential L/R"; |
| 531 |
break; |
| 532 |
case 0x40: |
| 533 |
extra_info.stereo = "field sequential R/L"; |
| 534 |
break; |
| 535 |
case 0x21: |
| 536 |
extra_info.stereo = "interleaved right even"; |
| 537 |
break; |
| 538 |
case 0x41: |
| 539 |
extra_info.stereo = "interleaved left even"; |
| 540 |
break; |
| 541 |
case 0x60: |
| 542 |
extra_info.stereo = "four way interleaved"; |
| 543 |
break; |
| 544 |
case 0x61: |
| 545 |
extra_info.stereo = "side by side interleaved"; |
| 546 |
break; |
| 547 |
default: |
| 548 |
extra_info.stereo = ""; |
| 549 |
break; |
| 550 |
} |
| 551 |
|
| 552 |
printk(BIOS_SPEW, |
| 553 |
"Detailed mode (IN HEX): Clock %d KHz, %x mm x %x mm\n" |
| 554 |
" %04x %04x %04x %04x hborder %x\n" |
| 555 |
" %04x %04x %04x %04x vborder %x\n" |
| 556 |
" %chsync %cvsync%s%s%s\n", |
| 557 |
out->mode.pixel_clock, |
| 558 |
extra_info.x_mm, |
| 559 |
extra_info.y_mm, |
| 560 |
out->mode.ha, out->mode.ha + out->mode.hso, |
| 561 |
out->mode.ha + out->mode.hso + out->mode.hspw, |
| 562 |
out->mode.ha + out->mode.hbl, out->mode.hborder, |
| 563 |
out->mode.va, out->mode.va + out->mode.vso, |
| 564 |
out->mode.va + out->mode.vso + out->mode.vspw, |
| 565 |
out->mode.va + out->mode.vbl, out->mode.vborder, |
| 566 |
out->mode.phsync, out->mode.pvsync, |
| 567 |
extra_info.syncmethod, x[17] & 0x80 ? " interlaced" : "", |
| 568 |
extra_info.stereo); |
| 569 |
|
| 570 |
if (!c->did_detailed_timing) { |
| 571 |
printk(BIOS_SPEW, "Did detailed timing\n"); |
| 572 |
c->did_detailed_timing = 1; |
| 573 |
*result_edid = *out; |
| 574 |
} |
| 575 |
|
| 576 |
return 1; |
| 577 |
} |
| 578 |
|
| 579 |
static int |
| 580 |
do_checksum(unsigned char *x) |
| 581 |
{ |
| 582 |
int valid = 0; |
| 583 |
printk(BIOS_SPEW, "Checksum: 0x%hhx", x[0x7f]); |
| 584 |
{ |
| 585 |
unsigned char sum = 0; |
| 586 |
int i; |
| 587 |
for (i = 0; i < 128; i++) |
| 588 |
sum += x[i]; |
| 589 |
if (sum) { |
| 590 |
printk(BIOS_SPEW, " (should be 0x%hhx)", |
| 591 |
(unsigned char)(x[0x7f] - sum)); |
| 592 |
} else { |
| 593 |
valid = 1; |
| 594 |
printk(BIOS_SPEW, " (valid)"); |
| 595 |
} |
| 596 |
} |
| 597 |
printk(BIOS_SPEW, "\n"); |
| 598 |
return valid; |
| 599 |
} |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
static const char * |
| 604 |
audio_format(unsigned char x) |
| 605 |
{ |
| 606 |
switch (x) { |
| 607 |
case 0: return "RESERVED"; |
| 608 |
case 1: return "Linear PCM"; |
| 609 |
case 2: return "AC-3"; |
| 610 |
case 3: return "MPEG 1 (Layers 1 & 2)"; |
| 611 |
case 4: return "MPEG 1 Layer 3 (MP3)"; |
| 612 |
case 5: return "MPEG2 (multichannel)"; |
| 613 |
case 6: return "AAC"; |
| 614 |
case 7: return "DTS"; |
| 615 |
case 8: return "ATRAC"; |
| 616 |
case 9: return "One Bit Audio"; |
| 617 |
case 10: return "Dolby Digital+"; |
| 618 |
case 11: return "DTS-HD"; |
| 619 |
case 12: return "MAT (MLP)"; |
| 620 |
case 13: return "DST"; |
| 621 |
case 14: return "WMA Pro"; |
| 622 |
case 15: return "RESERVED"; |
| 623 |
} |
| 624 |
return "BROKEN"; |
| 625 |
} |
| 626 |
|
| 627 |
static void |
| 628 |
cea_audio_block(unsigned char *x) |
| 629 |
{ |
| 630 |
int i, format; |
| 631 |
int length = x[0] & 0x1f; |
| 632 |
|
| 633 |
if (length % 3) { |
| 634 |
printk(BIOS_SPEW, "Broken CEA audio block length %d\n", length); |
| 635 |
|
| 636 |
return; |
| 637 |
} |
| 638 |
|
| 639 |
for (i = 1; i < length; i += 3) { |
| 640 |
format = (x[i] & 0x78) >> 3; |
| 641 |
printk(BIOS_SPEW, " %s, max channels %d\n", |
| 642 |
audio_format(format), x[i] & 0x07); |
| 643 |
printk(BIOS_SPEW, |
| 644 |
" Supported sample rates (kHz):%s%s%s%s%s%s%s\n", |
| 645 |
(x[i+1] & 0x40) ? " 192" : "", |
| 646 |
(x[i+1] & 0x20) ? " 176.4" : "", |
| 647 |
(x[i+1] & 0x10) ? " 96" : "", |
| 648 |
(x[i+1] & 0x08) ? " 88.2" : "", |
| 649 |
(x[i+1] & 0x04) ? " 48" : "", |
| 650 |
(x[i+1] & 0x02) ? " 44.1" : "", |
| 651 |
(x[i+1] & 0x01) ? " 32" : ""); |
| 652 |
if (format == 1) { |
| 653 |
printk(BIOS_SPEW, |
| 654 |
" Supported sample sizes (bits):%s%s%s\n", |
| 655 |
(x[2] & 0x04) ? " 24" : "", |
| 656 |
(x[2] & 0x02) ? " 20" : "", |
| 657 |
(x[2] & 0x01) ? " 16" : ""); |
| 658 |
} else if (format <= 8) { |
| 659 |
printk(BIOS_SPEW, |
| 660 |
" Maximum bit rate: %d kHz\n", x[2] * 8); |
| 661 |
} |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
static void |
| 666 |
cea_video_block(unsigned char *x) |
| 667 |
{ |
| 668 |
int i; |
| 669 |
int length = x[0] & 0x1f; |
| 670 |
|
| 671 |
for (i = 1; i < length; i++) |
| 672 |
printk(BIOS_SPEW, " VIC %02d %s\n", x[i] & 0x7f, |
| 673 |
x[i] & 0x80 ? "(native)" : ""); |
| 674 |
} |
| 675 |
|
| 676 |
static void |
| 677 |
cea_hdmi_block(struct edid *out, unsigned char *x) |
| 678 |
{ |
| 679 |
int length = x[0] & 0x1f; |
| 680 |
|
| 681 |
out->hdmi_monitor_detected = 1; |
| 682 |
|
| 683 |
printk(BIOS_SPEW, " (HDMI)\n"); |
| 684 |
printk(BIOS_SPEW, |
| 685 |
" Source physical address %d.%d.%d.%d\n", |
| 686 |
x[4] >> 4, x[4] & 0x0f, x[5] >> 4, x[5] & 0x0f); |
| 687 |
|
| 688 |
if (length > 5) { |
| 689 |
if (x[6] & 0x80) |
| 690 |
printk(BIOS_SPEW, " Supports_AI\n"); |
| 691 |
if (x[6] & 0x40) |
| 692 |
printk(BIOS_SPEW, " DC_48bit\n"); |
| 693 |
if (x[6] & 0x20) |
| 694 |
printk(BIOS_SPEW, " DC_36bit\n"); |
| 695 |
if (x[6] & 0x10) |
| 696 |
printk(BIOS_SPEW, " DC_30bit\n"); |
| 697 |
if (x[6] & 0x08) |
| 698 |
printk(BIOS_SPEW, " DC_Y444\n"); |
| 699 |
|
| 700 |
if (x[6] & 0x01) |
| 701 |
printk(BIOS_SPEW, " DVI_Dual\n"); |
| 702 |
} |
| 703 |
|
| 704 |
if (length > 6) |
| 705 |
printk(BIOS_SPEW, " Maximum TMDS clock: %dMHz\n", x[7] * 5); |
| 706 |
|
| 707 |
|
| 708 |
if (length > 7) { |
| 709 |
int b = 0; |
| 710 |
|
| 711 |
if (x[8] & 0x80) { |
| 712 |
printk(BIOS_SPEW, " Video latency: %d\n", x[9 + b]); |
| 713 |
printk(BIOS_SPEW, " Audio latency: %d\n", x[10 + b]); |
| 714 |
b += 2; |
| 715 |
} |
| 716 |
|
| 717 |
if (x[8] & 0x40) { |
| 718 |
printk(BIOS_SPEW, |
| 719 |
" Interlaced video latency: %d\n", x[9 + b]); |
| 720 |
printk(BIOS_SPEW, |
| 721 |
" Interlaced audio latency: %d\n", |
| 722 |
x[10 + b]); |
| 723 |
b += 2; |
| 724 |
} |
| 725 |
|
| 726 |
if (x[8] & 0x20) { |
| 727 |
int mask = 0, formats = 0; |
| 728 |
int len_xx, len_3d; |
| 729 |
printk(BIOS_SPEW, " Extended HDMI video details:\n"); |
| 730 |
if (x[9 + b] & 0x80) |
| 731 |
printk(BIOS_SPEW, " 3D present\n"); |
| 732 |
if ((x[9 + b] & 0x60) == 0x20) { |
| 733 |
printk(BIOS_SPEW, |
| 734 |
" All advertised VICs are 3D-capable\n"); |
| 735 |
formats = 1; |
| 736 |
} |
| 737 |
if ((x[9 + b] & 0x60) == 0x40) { |
| 738 |
printk(BIOS_SPEW, |
| 739 |
" 3D-capable-VIC mask present\n"); |
| 740 |
formats = 1; |
| 741 |
mask = 1; |
| 742 |
} |
| 743 |
switch (x[9 + b] & 0x18) { |
| 744 |
case 0x00: |
| 745 |
break; |
| 746 |
case 0x08: |
| 747 |
printk(BIOS_SPEW, " Base EDID image size is aspect ratio\n"); |
| 748 |
break; |
| 749 |
case 0x10: |
| 750 |
printk(BIOS_SPEW, " Base EDID image size is in units of 1cm\n"); |
| 751 |
break; |
| 752 |
case 0x18: |
| 753 |
printk(BIOS_SPEW, " Base EDID image size is in units of 5cm\n"); |
| 754 |
break; |
| 755 |
} |
| 756 |
len_xx = (x[10 + b] & 0xe0) >> 5; |
| 757 |
len_3d = (x[10 + b] & 0x1f) >> 0; |
| 758 |
b += 2; |
| 759 |
|
| 760 |
if (len_xx) { |
| 761 |
printk(BIOS_SPEW, " Skipping %d bytes that HDMI refuses to publicly" |
| 762 |
" document\n", len_xx); |
| 763 |
b += len_xx; |
| 764 |
} |
| 765 |
|
| 766 |
if (len_3d) { |
| 767 |
if (formats) { |
| 768 |
if (x[9 + b] & 0x01) |
| 769 |
printk(BIOS_SPEW, " Side-by-side 3D supported\n"); |
| 770 |
if (x[10 + b] & 0x40) |
| 771 |
printk(BIOS_SPEW, " Top-and-bottom 3D supported\n"); |
| 772 |
if (x[10 + b] & 0x01) |
| 773 |
printk(BIOS_SPEW, " Frame-packing 3D supported\n"); |
| 774 |
b += 2; |
| 775 |
} |
| 776 |
if (mask) { |
| 777 |
int i; |
| 778 |
printk(BIOS_SPEW, |
| 779 |
" 3D VIC indices:"); |
| 780 |
|
| 781 |
for (i = 0; i < 8; i++) |
| 782 |
if (x[10 + b] & (1 << i)) |
| 783 |
printk(BIOS_SPEW, |
| 784 |
" %d", i); |
| 785 |
for (i = 0; i < 8; i++) |
| 786 |
if (x[9 + b] & (1 << i)) |
| 787 |
printk(BIOS_SPEW, |
| 788 |
" %d", i + 8); |
| 789 |
printk(BIOS_SPEW, "\n"); |
| 790 |
b += 2; |
| 791 |
} |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
(void)b; |
| 803 |
} |
| 804 |
} |
| 805 |
|
| 806 |
static void |
| 807 |
cea_block(struct edid *out, unsigned char *x) |
| 808 |
{ |
| 809 |
unsigned int oui; |
| 810 |
|
| 811 |
switch ((x[0] & 0xe0) >> 5) { |
| 812 |
case 0x01: |
| 813 |
printk(BIOS_SPEW, " Audio data block\n"); |
| 814 |
cea_audio_block(x); |
| 815 |
break; |
| 816 |
case 0x02: |
| 817 |
printk(BIOS_SPEW, " Video data block\n"); |
| 818 |
cea_video_block(x); |
| 819 |
break; |
| 820 |
case 0x03: |
| 821 |
|
| 822 |
oui = (x[3] << 16) + (x[2] << 8) + x[1]; |
| 823 |
printk(BIOS_SPEW, " Vendor-specific data block, OUI %06x", |
| 824 |
oui); |
| 825 |
if (oui == 0x000c03) |
| 826 |
cea_hdmi_block(out, x); |
| 827 |
else |
| 828 |
printk(BIOS_SPEW, "\n"); |
| 829 |
break; |
| 830 |
case 0x04: |
| 831 |
printk(BIOS_SPEW, " Speaker allocation data block\n"); |
| 832 |
break; |
| 833 |
case 0x05: |
| 834 |
printk(BIOS_SPEW, " VESA DTC data block\n"); |
| 835 |
break; |
| 836 |
case 0x07: |
| 837 |
printk(BIOS_SPEW, " Extended tag: "); |
| 838 |
switch (x[1]) { |
| 839 |
case 0x00: |
| 840 |
printk(BIOS_SPEW, "video capability data block\n"); |
| 841 |
break; |
| 842 |
case 0x01: |
| 843 |
printk(BIOS_SPEW, "vendor-specific video data block\n"); |
| 844 |
break; |
| 845 |
case 0x02: |
| 846 |
printk(BIOS_SPEW, |
| 847 |
"VESA video display device information data block\n"); |
| 848 |
break; |
| 849 |
case 0x03: |
| 850 |
printk(BIOS_SPEW, "VESA video data block\n"); |
| 851 |
break; |
| 852 |
case 0x04: |
| 853 |
printk(BIOS_SPEW, "HDMI video data block\n"); |
| 854 |
break; |
| 855 |
case 0x05: |
| 856 |
printk(BIOS_SPEW, "Colorimetry data block\n"); |
| 857 |
break; |
| 858 |
case 0x10: |
| 859 |
printk(BIOS_SPEW, "CEA miscellaneous audio fields\n"); |
| 860 |
break; |
| 861 |
case 0x11: |
| 862 |
printk(BIOS_SPEW, "Vendor-specific audio data block\n"); |
| 863 |
break; |
| 864 |
case 0x12: |
| 865 |
printk(BIOS_SPEW, "HDMI audio data block\n"); |
| 866 |
break; |
| 867 |
default: |
| 868 |
if (x[1] >= 6 && x[1] <= 15) |
| 869 |
printk(BIOS_SPEW, |
| 870 |
"Reserved video block (%02x)\n", x[1]); |
| 871 |
else if (x[1] >= 19 && x[1] <= 31) |
| 872 |
printk(BIOS_SPEW, |
| 873 |
"Reserved audio block (%02x)\n", x[1]); |
| 874 |
else |
| 875 |
printk(BIOS_SPEW, "Unknown (%02x)\n", x[1]); |
| 876 |
break; |
| 877 |
} |
| 878 |
break; |
| 879 |
default: |
| 880 |
{ |
| 881 |
int tag = (*x & 0xe0) >> 5; |
| 882 |
int length = *x & 0x1f; |
| 883 |
printk(BIOS_SPEW, |
| 884 |
" Unknown tag %d, length %d (raw %02x)\n", |
| 885 |
tag, length, *x); |
| 886 |
break; |
| 887 |
} |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
static int |
| 892 |
parse_cea(struct edid *out, unsigned char *x, struct edid_context *c) |
| 893 |
{ |
| 894 |
int ret = 0; |
| 895 |
int version = x[1]; |
| 896 |
int offset = x[2]; |
| 897 |
unsigned char *detailed; |
| 898 |
|
| 899 |
if (version >= 1) |
| 900 |
do { |
| 901 |
if (version == 1 && x[3] != 0) |
| 902 |
ret = 1; |
| 903 |
|
| 904 |
if (offset < 4) |
| 905 |
break; |
| 906 |
|
| 907 |
if (version < 3) |
| 908 |
printk(BIOS_SPEW, |
| 909 |
"%d 8-byte timing descriptors\n", |
| 910 |
(offset - 4) / 8); |
| 911 |
else if (version == 3) { |
| 912 |
int i; |
| 913 |
printk(BIOS_SPEW, |
| 914 |
"%d bytes of CEA data\n", offset - 4); |
| 915 |
for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) |
| 916 |
cea_block(out, x + i); |
| 917 |
} |
| 918 |
|
| 919 |
if (version >= 2) { |
| 920 |
if (x[3] & 0x80) |
| 921 |
printk(BIOS_SPEW, |
| 922 |
"Underscans PC formats by default\n"); |
| 923 |
if (x[3] & 0x40) |
| 924 |
printk(BIOS_SPEW, |
| 925 |
"Basic audio support\n"); |
| 926 |
if (x[3] & 0x20) |
| 927 |
printk(BIOS_SPEW, |
| 928 |
"Supports YCbCr 4:4:4\n"); |
| 929 |
if (x[3] & 0x10) |
| 930 |
printk(BIOS_SPEW, |
| 931 |
"Supports YCbCr 4:2:2\n"); |
| 932 |
printk(BIOS_SPEW, |
| 933 |
"%d native detailed modes\n", |
| 934 |
x[3] & 0x0f); |
| 935 |
} |
| 936 |
|
| 937 |
for (detailed = x + offset; detailed + 18 < x + 127; |
| 938 |
detailed += 18) |
| 939 |
if (detailed[0]) |
| 940 |
detailed_block(out, detailed, 1, c); |
| 941 |
} while (0); |
| 942 |
|
| 943 |
c->has_valid_checksum &= do_checksum(x); |
| 944 |
return ret; |
| 945 |
} |
| 946 |
|
| 947 |
|
| 948 |
static const char * const displayid_aspect[] = { |
| 949 |
"1:1", |
| 950 |
"5:4", |
| 951 |
"4:3", |
| 952 |
"15:9", |
| 953 |
"16:9", |
| 954 |
"16:10", |
| 955 |
"64:27", |
| 956 |
"256:135", |
| 957 |
}; |
| 958 |
|
| 959 |
static void displayid_detailed_timing( |
| 960 |
struct displayid_type_7_detailed_timing_desc *desc, |
| 961 |
struct edid *out) |
| 962 |
{ |
| 963 |
unsigned int pixel_clock = (desc->pixel_clock[0] | |
| 964 |
(desc->pixel_clock[1] << 8) | |
| 965 |
(desc->pixel_clock[2] << 16)) + 1; |
| 966 |
|
| 967 |
unsigned int hactive = (desc->hactive[0] | desc->hactive[1] << 8) + 1; |
| 968 |
unsigned int hblank = (desc->hblank[0] | desc->hblank[1] << 8) + 1; |
| 969 |
unsigned int hsync = (desc->hfront_porch[0] | (desc->hfront_porch[1] & 0x7f) << 8) + 1; |
| 970 |
unsigned int hsync_width = (desc->hsync_width[0] | desc->hsync_width[1] << 8) + 1; |
| 971 |
|
| 972 |
unsigned int vactive = (desc->vactive[0] | desc->vactive[1] << 8) + 1; |
| 973 |
unsigned int vblank = (desc->vblank[0] | desc->vblank[1] << 8) + 1; |
| 974 |
unsigned int vsync = (desc->vfront_porch[0] | (desc->vfront_porch[1] & 0x7f) << 8) + 1; |
| 975 |
unsigned int vsync_width = (desc->vsync_width[0] | desc->vsync_width[1] << 8) + 1; |
| 976 |
|
| 977 |
bool hsync_positive = (desc->hfront_porch[1] >> 7) & 0x1; |
| 978 |
bool vsync_positive = (desc->vfront_porch[1] >> 7) & 0x1; |
| 979 |
|
| 980 |
unsigned int aspect = desc->flags & 0xF; |
| 981 |
bool is_preferred = desc->flags & 0x80; |
| 982 |
|
| 983 |
out->mode.pixel_clock = pixel_clock; |
| 984 |
out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000); |
| 985 |
out->mode.ha = hactive; |
| 986 |
out->mode.hbl = hblank; |
| 987 |
out->mode.hso = hsync; |
| 988 |
out->mode.hspw = hsync_width; |
| 989 |
|
| 990 |
out->mode.va = vactive; |
| 991 |
out->mode.vbl = vblank; |
| 992 |
out->mode.vso = vsync; |
| 993 |
out->mode.vspw = vsync_width; |
| 994 |
|
| 995 |
out->mode.phsync = hsync_positive ? '+' : '-'; |
| 996 |
out->mode.pvsync = vsync_positive ? '+' : '-'; |
| 997 |
|
| 998 |
printk(BIOS_SPEW, |
| 999 |
"Detailed mode: clock %d KHz,\n" |
| 1000 |
" ha: %u hso: %u hspw: %u hbl: %u\n" |
| 1001 |
" va: %u vso: %u vspw: %u vbl: %u\n" |
| 1002 |
" %chsync %cvsync (aspect %s%s)\n", |
| 1003 |
out->mode.pixel_clock, |
| 1004 |
out->mode.ha, out->mode.hso, out->mode.hspw, out->mode.hbl, |
| 1005 |
out->mode.va, out->mode.vso, out->mode.vspw, out->mode.vbl, |
| 1006 |
out->mode.phsync, out->mode.pvsync, |
| 1007 |
(aspect >= ARRAY_SIZE(displayid_aspect)) ? "undefined" : displayid_aspect[aspect], |
| 1008 |
is_preferred ? ", preferred" : ""); |
| 1009 |
} |
| 1010 |
|
| 1011 |
static int displayid_type_7_timing_block( |
| 1012 |
struct edid *result_edid, |
| 1013 |
unsigned char *x, |
| 1014 |
struct edid_context *c, |
| 1015 |
int index) |
| 1016 |
{ |
| 1017 |
struct edid tmp; |
| 1018 |
|
| 1019 |
struct displayid_type_7_detailed_timing_block *block; |
| 1020 |
struct displayid_type_7_detailed_timing_desc *desc; |
| 1021 |
int desc_count; |
| 1022 |
|
| 1023 |
block = (struct displayid_type_7_detailed_timing_block *)&x[index]; |
| 1024 |
desc_count = block->header.length / sizeof(*desc); |
| 1025 |
|
| 1026 |
if (block->header.length % sizeof(*desc)) { |
| 1027 |
printk(BIOS_ERR, "%s: the length is not a multiple of %zu\n", |
| 1028 |
__func__, sizeof(*desc)); |
| 1029 |
return 1; |
| 1030 |
} |
| 1031 |
|
| 1032 |
tmp = *result_edid; |
| 1033 |
|
| 1034 |
for (int i = 0; i < desc_count; i++) { |
| 1035 |
desc = &block->descs[i]; |
| 1036 |
displayid_detailed_timing(desc, &tmp); |
| 1037 |
|
| 1038 |
c->did_detailed_timing = 1; |
| 1039 |
if ((desc->flags & 0x80) && !c->has_preferred_timing) { |
| 1040 |
c->has_preferred_timing = 1; |
| 1041 |
*result_edid = tmp; |
| 1042 |
} |
| 1043 |
} |
| 1044 |
|
| 1045 |
return 0; |
| 1046 |
} |
| 1047 |
|
| 1048 |
static int validate_section_header(unsigned char *x, int index) |
| 1049 |
{ |
| 1050 |
int i; |
| 1051 |
size_t section_length; |
| 1052 |
struct displayid_section_header *sh = (struct displayid_section_header *)&x[index]; |
| 1053 |
|
| 1054 |
unsigned char sum = 0; |
| 1055 |
|
| 1056 |
|
| 1057 |
section_length = sizeof(*sh) + sh->length + 1; |
| 1058 |
|
| 1059 |
|
| 1060 |
if (section_length > 128 - 1 - index) |
| 1061 |
return 1; |
| 1062 |
|
| 1063 |
for (i = 0; i < section_length; i++) |
| 1064 |
sum += x[i + index]; |
| 1065 |
|
| 1066 |
if (sum) { |
| 1067 |
printk(BIOS_ERR, "%s: checksum invalid\n", __func__); |
| 1068 |
return 1; |
| 1069 |
} |
| 1070 |
|
| 1071 |
return 0; |
| 1072 |
} |
| 1073 |
|
| 1074 |
static int parse_displayid( |
| 1075 |
struct edid *result_edid, |
| 1076 |
unsigned char *x, |
| 1077 |
struct edid_context *c) |
| 1078 |
{ |
| 1079 |
int ret = 0; |
| 1080 |
int index = 1; |
| 1081 |
|
| 1082 |
struct displayid_section_header *sh = (struct displayid_section_header *)&x[index]; |
| 1083 |
struct displayid_block_header *bh; |
| 1084 |
|
| 1085 |
if (validate_section_header(x, index)) |
| 1086 |
return 1; |
| 1087 |
|
| 1088 |
|
| 1089 |
if (sh->revision != DISPLAY_ID_STRUCTURE_VERSION_20) { |
| 1090 |
printk(BIOS_SPEW, "Unsupported Display ID revison: %x\n", sh->revision); |
| 1091 |
goto validate_checksum; |
| 1092 |
} |
| 1093 |
|
| 1094 |
index += sizeof(*sh); |
| 1095 |
while (index < 1 + sh->length + sizeof(*sh)) { |
| 1096 |
bh = (struct displayid_block_header *)&x[index]; |
| 1097 |
if (index + sizeof(*bh) > sh->length || |
| 1098 |
index + sizeof(*bh) + bh->length > sh->length) |
| 1099 |
break; |
| 1100 |
|
| 1101 |
if (bh->tag == DATA_BLOCK_V2_TYPE_7_DETAILED_TIMING) |
| 1102 |
displayid_type_7_timing_block(result_edid, x, c, index); |
| 1103 |
else |
| 1104 |
printk(BIOS_SPEW, "%s: Unsupported data block tag %x\n", |
| 1105 |
__func__, bh->tag); |
| 1106 |
index += sizeof(*bh) + bh->length; |
| 1107 |
} |
| 1108 |
|
| 1109 |
validate_checksum: |
| 1110 |
c->has_valid_checksum &= do_checksum(x); |
| 1111 |
return ret; |
| 1112 |
} |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
static void |
| 1117 |
extension_version(struct edid *out, unsigned char *x) |
| 1118 |
{ |
| 1119 |
printk(BIOS_SPEW, "Extension version: %d\n", x[1]); |
| 1120 |
} |
| 1121 |
|
| 1122 |
static int |
| 1123 |
parse_extension(struct edid *out, unsigned char *x, struct edid_context *c) |
| 1124 |
{ |
| 1125 |
int conformant_extension = 0; |
| 1126 |
printk(BIOS_SPEW, "\n"); |
| 1127 |
|
| 1128 |
switch (x[0]) { |
| 1129 |
case 0x02: |
| 1130 |
printk(BIOS_SPEW, "CEA extension block\n"); |
| 1131 |
extension_version(out, x); |
| 1132 |
conformant_extension = parse_cea(out, x, c); |
| 1133 |
break; |
| 1134 |
case 0x10: |
| 1135 |
printk(BIOS_SPEW, "VTB extension block\n"); |
| 1136 |
break; |
| 1137 |
case 0x40: |
| 1138 |
printk(BIOS_SPEW, "DI extension block\n"); |
| 1139 |
break; |
| 1140 |
case 0x50: |
| 1141 |
printk(BIOS_SPEW, "LS extension block\n"); |
| 1142 |
break; |
| 1143 |
case 0x60: |
| 1144 |
printk(BIOS_SPEW, "DPVL extension block\n"); |
| 1145 |
break; |
| 1146 |
case 0x70: |
| 1147 |
printk(BIOS_SPEW, "DisplayID extension block\n"); |
| 1148 |
extension_version(out, x); |
| 1149 |
conformant_extension = parse_displayid(out, x, c); |
| 1150 |
break; |
| 1151 |
case 0xF0: |
| 1152 |
printk(BIOS_SPEW, "Block map\n"); |
| 1153 |
break; |
| 1154 |
case 0xFF: |
| 1155 |
printk(BIOS_SPEW, "Manufacturer-specific extension block\n"); |
| 1156 |
break; |
| 1157 |
default: |
| 1158 |
printk(BIOS_SPEW, "Unknown extension block\n"); |
| 1159 |
break; |
| 1160 |
} |
| 1161 |
|
| 1162 |
printk(BIOS_SPEW, "\n"); |
| 1163 |
|
| 1164 |
return conformant_extension; |
| 1165 |
} |
| 1166 |
|
| 1167 |
static const struct { |
| 1168 |
int x, y, refresh; |
| 1169 |
} established_timings[] = { |
| 1170 |
|
| 1171 |
{720, 400, 70}, |
| 1172 |
{720, 400, 88}, |
| 1173 |
{640, 480, 60}, |
| 1174 |
{640, 480, 67}, |
| 1175 |
{640, 480, 72}, |
| 1176 |
{640, 480, 75}, |
| 1177 |
{800, 600, 56}, |
| 1178 |
{800, 600, 60}, |
| 1179 |
|
| 1180 |
{800, 600, 72}, |
| 1181 |
{800, 600, 75}, |
| 1182 |
{832, 624, 75}, |
| 1183 |
{1280, 768, 87}, |
| 1184 |
{1024, 768, 60}, |
| 1185 |
{1024, 768, 70}, |
| 1186 |
{1024, 768, 75}, |
| 1187 |
{1280, 1024, 75}, |
| 1188 |
|
| 1189 |
{1152, 870, 75}, |
| 1190 |
}; |
| 1191 |
|
| 1192 |
static void print_subsection(const char *name, unsigned char *edid, int start, |
| 1193 |
int end) |
| 1194 |
{ |
| 1195 |
int i; |
| 1196 |
|
| 1197 |
printk(BIOS_SPEW, "%s:", name); |
| 1198 |
for (i = strlen(name); i < 15; i++) |
| 1199 |
printk(BIOS_SPEW, " "); |
| 1200 |
for (i = start; i <= end; i++) |
| 1201 |
printk(BIOS_SPEW, " %02x", edid[i]); |
| 1202 |
printk(BIOS_SPEW, "\n"); |
| 1203 |
} |
| 1204 |
|
| 1205 |
static void dump_breakdown(unsigned char *edid) |
| 1206 |
{ |
| 1207 |
printk(BIOS_SPEW, "Extracted contents:\n"); |
| 1208 |
print_subsection("header", edid, 0, 7); |
| 1209 |
print_subsection("serial number", edid, 8, 17); |
| 1210 |
print_subsection("version", edid, 18, 19); |
| 1211 |
print_subsection("basic params", edid, 20, 24); |
| 1212 |
print_subsection("chroma info", edid, 25, 34); |
| 1213 |
print_subsection("established", edid, 35, 37); |
| 1214 |
print_subsection("standard", edid, 38, 53); |
| 1215 |
print_subsection("descriptor 1", edid, 54, 71); |
| 1216 |
print_subsection("descriptor 2", edid, 72, 89); |
| 1217 |
print_subsection("descriptor 3", edid, 90, 107); |
| 1218 |
print_subsection("descriptor 4", edid, 108, 125); |
| 1219 |
print_subsection("extensions", edid, 126, 126); |
| 1220 |
print_subsection("checksum", edid, 127, 127); |
| 1221 |
printk(BIOS_SPEW, "\n"); |
| 1222 |
} |
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
static struct edid_mode known_modes[NUM_KNOWN_MODES] = { |
| 1233 |
[EDID_MODE_640x480_60Hz] = { |
| 1234 |
.name = "640x480@60Hz", .pixel_clock = 25200, .refresh = 60, |
| 1235 |
.ha = 640, .hbl = 160, .hso = 16, .hspw = 96, |
| 1236 |
.va = 480, .vbl = 45, .vso = 10, .vspw = 2, |
| 1237 |
.phsync = '-', .pvsync = '-' }, |
| 1238 |
[EDID_MODE_720x480_60Hz] = { |
| 1239 |
.name = "720x480@60Hz", .pixel_clock = 27000, .refresh = 60, |
| 1240 |
.ha = 720, .hbl = 138, .hso = 16, .hspw = 62, |
| 1241 |
.va = 480, .vbl = 45, .vso = 9, .vspw = 6, |
| 1242 |
.phsync = '-', .pvsync = '-' }, |
| 1243 |
[EDID_MODE_1280x720_60Hz] = { |
| 1244 |
.name = "1280x720@60Hz", .pixel_clock = 74250, .refresh = 60, |
| 1245 |
.ha = 1280, .hbl = 370, .hso = 110, .hspw = 40, |
| 1246 |
.va = 720, .vbl = 30, .vso = 5, .vspw = 20, |
| 1247 |
.phsync = '+', .pvsync = '+' }, |
| 1248 |
[EDID_MODE_1920x1080_60Hz] = { |
| 1249 |
.name = "1920x1080@60Hz", .pixel_clock = 148500, .refresh = 60, |
| 1250 |
.ha = 1920, .hbl = 280, .hso = 88, .hspw = 44, |
| 1251 |
.va = 1080, .vbl = 45, .vso = 4, .vspw = 5, |
| 1252 |
.phsync = '+', .pvsync = '+' }, |
| 1253 |
}; |
| 1254 |
|
| 1255 |
int set_display_mode(struct edid *edid, enum edid_modes mode) |
| 1256 |
{ |
| 1257 |
if (mode == EDID_MODE_AUTO) |
| 1258 |
return 0; |
| 1259 |
|
| 1260 |
if (edid->mode_is_supported[mode]) { |
| 1261 |
printk(BIOS_DEBUG, "Forcing mode %s\n", known_modes[mode].name); |
| 1262 |
edid->mode = known_modes[mode]; |
| 1263 |
return 0; |
| 1264 |
} |
| 1265 |
|
| 1266 |
printk(BIOS_ERR, "Requested display mode not supported.\n"); |
| 1267 |
return -1; |
| 1268 |
} |
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
int decode_edid(unsigned char *edid, int size, struct edid *out) |
| 1279 |
{ |
| 1280 |
int analog, i, j; |
| 1281 |
struct edid_context c = { |
| 1282 |
.has_valid_cvt = 1, |
| 1283 |
.has_valid_dummy_block = 1, |
| 1284 |
.has_valid_descriptor_ordering = 1, |
| 1285 |
.has_valid_detailed_blocks = 1, |
| 1286 |
.has_valid_descriptor_pad = 1, |
| 1287 |
.has_valid_range_descriptor = 1, |
| 1288 |
.has_valid_max_dotclock = 1, |
| 1289 |
.has_valid_string_termination = 1, |
| 1290 |
.conformant = EDID_CONFORMANT, |
| 1291 |
}; |
| 1292 |
|
| 1293 |
if (!edid) { |
| 1294 |
printk(BIOS_ERR, "No EDID found\n"); |
| 1295 |
return EDID_ABSENT; |
| 1296 |
} |
| 1297 |
|
| 1298 |
dump_breakdown(edid); |
| 1299 |
|
| 1300 |
if (memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) { |
| 1301 |
printk(BIOS_ERR, "No header found\n"); |
| 1302 |
return EDID_ABSENT; |
| 1303 |
} |
| 1304 |
|
| 1305 |
memset(out, 0, sizeof(*out)); |
| 1306 |
|
| 1307 |
if (manufacturer_name(edid + 0x08, out->manufacturer_name)) |
| 1308 |
c.manufacturer_name_well_formed = 1; |
| 1309 |
|
| 1310 |
extra_info.model = (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)); |
| 1311 |
extra_info.serial = (unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
| 1312 |
+ (edid[0x0E] << 16) + (edid[0x0F] << 24)); |
| 1313 |
|
| 1314 |
printk(BIOS_SPEW, "Manufacturer: %s Model %x Serial Number %u\n", |
| 1315 |
out->manufacturer_name, |
| 1316 |
(unsigned short)(edid[0x0A] + (edid[0x0B] << 8)), |
| 1317 |
(unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
| 1318 |
+ (edid[0x0E] << 16) + (edid[0x0F] << 24))); |
| 1319 |
|
| 1320 |
|
| 1321 |
if (edid[0x10] < 55 || edid[0x10] == 0xff) { |
| 1322 |
c.has_valid_week = 1; |
| 1323 |
if (edid[0x11] > 0x0f) { |
| 1324 |
if (edid[0x10] == 0xff) { |
| 1325 |
c.has_valid_year = 1; |
| 1326 |
printk(BIOS_SPEW, |
| 1327 |
"Made week %hhd of model year %hhd\n", |
| 1328 |
edid[0x10], edid[0x11]); |
| 1329 |
extra_info.week = edid[0x10]; |
| 1330 |
extra_info.year = edid[0x11]; |
| 1331 |
} else { |
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
if (edid[0x11] + 90 <= 2013) { |
| 1336 |
c.has_valid_year = 1; |
| 1337 |
printk(BIOS_SPEW, |
| 1338 |
"Made week %hhd of %d\n", |
| 1339 |
edid[0x10], edid[0x11] + 1990); |
| 1340 |
extra_info.week = edid[0x10]; |
| 1341 |
extra_info.year = edid[0x11] + 1990; |
| 1342 |
} |
| 1343 |
} |
| 1344 |
} |
| 1345 |
} |
| 1346 |
|
| 1347 |
printk(BIOS_SPEW, "EDID version: %hhd.%hhd\n", edid[0x12], edid[0x13]); |
| 1348 |
extra_info.version[0] = edid[0x12]; |
| 1349 |
extra_info.version[1] = edid[0x13]; |
| 1350 |
|
| 1351 |
if (edid[0x12] == 1) { |
| 1352 |
if (edid[0x13] > 4) { |
| 1353 |
printk(BIOS_SPEW, |
| 1354 |
"Claims > 1.4, assuming 1.4 conformance\n"); |
| 1355 |
edid[0x13] = 4; |
| 1356 |
} |
| 1357 |
switch (edid[0x13]) { |
| 1358 |
case 4: |
| 1359 |
c.claims_one_point_four = 1; |
| 1360 |
__fallthrough; |
| 1361 |
case 3: |
| 1362 |
c.claims_one_point_three = 1; |
| 1363 |
__fallthrough; |
| 1364 |
case 2: |
| 1365 |
c.claims_one_point_two = 1; |
| 1366 |
__fallthrough; |
| 1367 |
default: |
| 1368 |
c.claims_one_point_oh = 1; |
| 1369 |
} |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
if (edid[0x14] & 0x80) { |
| 1374 |
int conformance_mask; |
| 1375 |
analog = 0; |
| 1376 |
printk(BIOS_SPEW, "Digital display\n"); |
| 1377 |
if (c.claims_one_point_four) { |
| 1378 |
conformance_mask = 0; |
| 1379 |
if ((edid[0x14] & 0x70) == 0x00) |
| 1380 |
printk(BIOS_SPEW, "Color depth is undefined\n"); |
| 1381 |
else if ((edid[0x14] & 0x70) == 0x70) |
| 1382 |
c.nonconformant_digital_display = 1; |
| 1383 |
else |
| 1384 |
printk(BIOS_SPEW, |
| 1385 |
"%d bits per primary color channel\n", |
| 1386 |
((edid[0x14] & 0x70) >> 3) + 4); |
| 1387 |
out->panel_bits_per_color = ((edid[0x14] & 0x70) >> 3) |
| 1388 |
+ 4; |
| 1389 |
out->panel_bits_per_pixel = 3*out->panel_bits_per_color; |
| 1390 |
|
| 1391 |
switch (edid[0x14] & 0x0f) { |
| 1392 |
case 0x00: |
| 1393 |
printk(BIOS_SPEW, |
| 1394 |
"Digital interface is not defined\n"); |
| 1395 |
break; |
| 1396 |
case 0x01: |
| 1397 |
printk(BIOS_SPEW, "DVI interface\n"); |
| 1398 |
break; |
| 1399 |
case 0x02: |
| 1400 |
printk(BIOS_SPEW, "HDMI-a interface\n"); |
| 1401 |
break; |
| 1402 |
case 0x03: |
| 1403 |
printk(BIOS_SPEW, "HDMI-b interface\n"); |
| 1404 |
break; |
| 1405 |
case 0x04: |
| 1406 |
printk(BIOS_SPEW, "MDDI interface\n"); |
| 1407 |
break; |
| 1408 |
case 0x05: |
| 1409 |
printk(BIOS_SPEW, "DisplayPort interface\n"); |
| 1410 |
break; |
| 1411 |
default: |
| 1412 |
c.nonconformant_digital_display = 1; |
| 1413 |
break; |
| 1414 |
} |
| 1415 |
extra_info.type = edid[0x14] & 0x0f; |
| 1416 |
} else if (c.claims_one_point_two) { |
| 1417 |
conformance_mask = 0x7E; |
| 1418 |
if (edid[0x14] & 0x01) |
| 1419 |
printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n"); |
| 1420 |
} else |
| 1421 |
conformance_mask = 0x7F; |
| 1422 |
|
| 1423 |
if (!c.nonconformant_digital_display) |
| 1424 |
c.nonconformant_digital_display = edid[0x14] |
| 1425 |
& conformance_mask; |
| 1426 |
extra_info.nonconformant = c.nonconformant_digital_display; |
| 1427 |
} else { |
| 1428 |
analog = 1; |
| 1429 |
int voltage = (edid[0x14] & 0x60) >> 5; |
| 1430 |
int sync = (edid[0x14] & 0x0F); |
| 1431 |
extra_info.voltage = voltage; |
| 1432 |
extra_info.sync = sync; |
| 1433 |
|
| 1434 |
printk(BIOS_SPEW, "Analog display, Input voltage level: %s V\n", |
| 1435 |
voltage == 3 ? "0.7/0.7" : |
| 1436 |
voltage == 2 ? "1.0/0.4" : |
| 1437 |
voltage == 1 ? "0.714/0.286" : |
| 1438 |
"0.7/0.3"); |
| 1439 |
|
| 1440 |
if (c.claims_one_point_four) { |
| 1441 |
if (edid[0x14] & 0x10) |
| 1442 |
printk(BIOS_SPEW, |
| 1443 |
"Blank-to-black setup/pedestal\n"); |
| 1444 |
else |
| 1445 |
printk(BIOS_SPEW, |
| 1446 |
"Blank level equals black level\n"); |
| 1447 |
} else if (edid[0x14] & 0x10) { |
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
printk(BIOS_SPEW, "Configurable signal levels\n"); |
| 1455 |
} |
| 1456 |
|
| 1457 |
printk(BIOS_SPEW, "Sync: %s%s%s%s\n", |
| 1458 |
sync & 0x08 ? "Separate " : "", |
| 1459 |
sync & 0x04 ? "Composite " : "", |
| 1460 |
sync & 0x02 ? "SyncOnGreen " : "", |
| 1461 |
sync & 0x01 ? "Serration " : ""); |
| 1462 |
} |
| 1463 |
|
| 1464 |
|
| 1465 |
if (edid[0x15] && edid[0x16]) { |
| 1466 |
printk(BIOS_SPEW, "Maximum image size: %d cm x %d cm\n", |
| 1467 |
edid[0x15], edid[0x16]); |
| 1468 |
} else if (c.claims_one_point_four && (edid[0x15] || edid[0x16])) { |
| 1469 |
if (edid[0x15]) { |
| 1470 |
unsigned int ratio = 100000/(edid[0x15] + 99); |
| 1471 |
printk(BIOS_SPEW, |
| 1472 |
"Aspect ratio is %u.%03u (landscape)\n", |
| 1473 |
ratio / 1000, ratio % 1000); |
| 1474 |
} else { |
| 1475 |
unsigned int ratio = 100000/(edid[0x16] + 99); |
| 1476 |
printk(BIOS_SPEW, |
| 1477 |
"Aspect ratio is %u.%03u (portrait)\n", |
| 1478 |
ratio / 1000, ratio % 1000); |
| 1479 |
} |
| 1480 |
} else { |
| 1481 |
|
| 1482 |
printk(BIOS_SPEW, "Image size is variable\n"); |
| 1483 |
} |
| 1484 |
|
| 1485 |
if (edid[0x17] == 0xff) { |
| 1486 |
if (c.claims_one_point_four) |
| 1487 |
printk(BIOS_SPEW, |
| 1488 |
"Gamma is defined in an extension block\n"); |
| 1489 |
else |
| 1490 |
|
| 1491 |
printk(BIOS_SPEW, "Gamma: 1.0\n"); |
| 1492 |
} else |
| 1493 |
printk(BIOS_SPEW, "Gamma: %d%%\n", ((edid[0x17] + 100))); |
| 1494 |
printk(BIOS_SPEW, "Check DPMS levels\n"); |
| 1495 |
if (edid[0x18] & 0xE0) { |
| 1496 |
printk(BIOS_SPEW, "DPMS levels:"); |
| 1497 |
if (edid[0x18] & 0x80) |
| 1498 |
printk(BIOS_SPEW, " Standby"); |
| 1499 |
if (edid[0x18] & 0x40) |
| 1500 |
printk(BIOS_SPEW, " Suspend"); |
| 1501 |
if (edid[0x18] & 0x20) |
| 1502 |
printk(BIOS_SPEW, " Off"); |
| 1503 |
printk(BIOS_SPEW, "\n"); |
| 1504 |
} |
| 1505 |
|
| 1506 |
|
| 1507 |
if (analog) { |
| 1508 |
switch (edid[0x18] & 0x18) { |
| 1509 |
case 0x00: |
| 1510 |
printk(BIOS_SPEW, "Monochrome or grayscale display\n"); |
| 1511 |
break; |
| 1512 |
case 0x08: |
| 1513 |
printk(BIOS_SPEW, "RGB color display\n"); |
| 1514 |
break; |
| 1515 |
case 0x10: |
| 1516 |
printk(BIOS_SPEW, "Non-RGB color display\n"); |
| 1517 |
break; |
| 1518 |
case 0x18: |
| 1519 |
printk(BIOS_SPEW, "Undefined display color type\n"); |
| 1520 |
break; |
| 1521 |
} |
| 1522 |
} else { |
| 1523 |
printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4"); |
| 1524 |
if (edid[0x18] & 0x10) |
| 1525 |
printk(BIOS_SPEW, ", YCrCb 4:4:4"); |
| 1526 |
if (edid[0x18] & 0x08) |
| 1527 |
printk(BIOS_SPEW, ", YCrCb 4:2:2"); |
| 1528 |
printk(BIOS_SPEW, "\n"); |
| 1529 |
} |
| 1530 |
|
| 1531 |
if (edid[0x18] & 0x04) |
| 1532 |
printk(BIOS_SPEW, |
| 1533 |
"Default (sRGB) color space is primary color space\n"); |
| 1534 |
if (edid[0x18] & 0x02) { |
| 1535 |
printk(BIOS_SPEW, |
| 1536 |
"First detailed timing is preferred timing\n"); |
| 1537 |
c.has_preferred_timing = 1; |
| 1538 |
} |
| 1539 |
if (edid[0x18] & 0x01) |
| 1540 |
printk(BIOS_SPEW, |
| 1541 |
"Supports GTF timings within operating range\n"); |
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
printk(BIOS_SPEW, "Established timings supported:\n"); |
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
for (i = 0; i < 17; i++) { |
| 1550 |
if (edid[0x23 + i / 8] & (1 << (7 - i % 8))) { |
| 1551 |
printk(BIOS_SPEW, " %dx%d@%dHz\n", |
| 1552 |
established_timings[i].x, |
| 1553 |
established_timings[i].y, |
| 1554 |
established_timings[i].refresh); |
| 1555 |
|
| 1556 |
for (j = 0; j < NUM_KNOWN_MODES; j++) { |
| 1557 |
if (known_modes[j].ha == |
| 1558 |
established_timings[i].x |
| 1559 |
&& known_modes[j].va == |
| 1560 |
established_timings[i].y |
| 1561 |
&& known_modes[j].refresh == |
| 1562 |
established_timings[i].refresh) |
| 1563 |
out->mode_is_supported[j] = 1; |
| 1564 |
} |
| 1565 |
} |
| 1566 |
} |
| 1567 |
|
| 1568 |
printk(BIOS_SPEW, "Standard timings supported:\n"); |
| 1569 |
for (i = 0; i < 8; i++) { |
| 1570 |
uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1]; |
| 1571 |
unsigned int x, y = 0, refresh; |
| 1572 |
|
| 1573 |
if (b1 == 0x01 && b2 == 0x01) |
| 1574 |
continue; |
| 1575 |
|
| 1576 |
if (b1 == 0) { |
| 1577 |
printk(BIOS_SPEW, |
| 1578 |
"non-conformant standard timing (0 horiz)\n"); |
| 1579 |
continue; |
| 1580 |
} |
| 1581 |
x = (b1 + 31) * 8; |
| 1582 |
switch ((b2 >> 6) & 0x3) { |
| 1583 |
case 0x00: |
| 1584 |
if (c.claims_one_point_three) |
| 1585 |
y = x * 10 / 16; |
| 1586 |
else |
| 1587 |
y = x; |
| 1588 |
break; |
| 1589 |
case 0x01: |
| 1590 |
y = x * 3 / 4; |
| 1591 |
break; |
| 1592 |
case 0x02: |
| 1593 |
y = x * 4 / 5; |
| 1594 |
break; |
| 1595 |
case 0x03: |
| 1596 |
y = x * 9 / 16; |
| 1597 |
break; |
| 1598 |
} |
| 1599 |
refresh = 60 + (b2 & 0x3f); |
| 1600 |
|
| 1601 |
printk(BIOS_SPEW, " %dx%d@%dHz\n", x, y, refresh); |
| 1602 |
for (j = 0; j < NUM_KNOWN_MODES; j++) { |
| 1603 |
if (known_modes[j].ha == x && known_modes[j].va == y && |
| 1604 |
known_modes[j].refresh == refresh) |
| 1605 |
out->mode_is_supported[j] = 1; |
| 1606 |
} |
| 1607 |
} |
| 1608 |
|
| 1609 |
|
| 1610 |
printk(BIOS_SPEW, "Detailed timings\n"); |
| 1611 |
for (i = 0; i < 4; i++) { |
| 1612 |
c.has_valid_detailed_blocks &= detailed_block( |
| 1613 |
out, edid + 0x36 + i * 18, 0, &c); |
| 1614 |
if (i == 0 && c.has_preferred_timing |
| 1615 |
&& !c.did_detailed_timing) { |
| 1616 |
|
| 1617 |
c.has_preferred_timing = 0; |
| 1618 |
} |
| 1619 |
} |
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
printk(BIOS_SPEW, "Has %d extension blocks\n", edid[0x7e]); |
| 1627 |
|
| 1628 |
printk(BIOS_SPEW, "Checksum\n"); |
| 1629 |
c.has_valid_checksum = do_checksum(edid); |
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
for (i = 128; i < size; i += 128) |
| 1637 |
c.nonconformant_extension += |
| 1638 |
parse_extension(out, &edid[i], &c); |
| 1639 |
|
| 1640 |
if (c.claims_one_point_four) { |
| 1641 |
if (c.nonconformant_digital_display || |
| 1642 |
!c.has_valid_string_termination || |
| 1643 |
!c.has_valid_descriptor_pad || |
| 1644 |
!c.has_preferred_timing) { |
| 1645 |
c.conformant = EDID_NOT_CONFORMANT; |
| 1646 |
printk(BIOS_ERR, |
| 1647 |
"EDID block does NOT conform to EDID 1.4!\n"); |
| 1648 |
} |
| 1649 |
|
| 1650 |
if (c.nonconformant_digital_display) |
| 1651 |
printk(BIOS_ERR, |
| 1652 |
"\tDigital display field contains garbage: %x\n", |
| 1653 |
c.nonconformant_digital_display); |
| 1654 |
if (!c.has_valid_string_termination) |
| 1655 |
printk(BIOS_ERR, |
| 1656 |
"\tDetailed block string not properly terminated\n"); |
| 1657 |
if (!c.has_valid_descriptor_pad) |
| 1658 |
printk(BIOS_ERR, |
| 1659 |
"\tInvalid descriptor block padding\n"); |
| 1660 |
if (!c.has_preferred_timing) |
| 1661 |
printk(BIOS_ERR, "\tMissing preferred timing\n"); |
| 1662 |
} else if (c.claims_one_point_three) { |
| 1663 |
if (c.nonconformant_digital_display || |
| 1664 |
!c.has_valid_string_termination || |
| 1665 |
!c.has_valid_descriptor_pad || |
| 1666 |
!c.has_preferred_timing) { |
| 1667 |
c.conformant = EDID_NOT_CONFORMANT; |
| 1668 |
} |
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
if (c.conformant == EDID_NOT_CONFORMANT) |
| 1677 |
printk(BIOS_ERR, |
| 1678 |
"EDID block does NOT conform to EDID 1.3!\n"); |
| 1679 |
else if (!c.has_name_descriptor || !c.has_range_descriptor) |
| 1680 |
printk(BIOS_WARNING, "EDID block does NOT " |
| 1681 |
"fully conform to EDID 1.3.\n"); |
| 1682 |
|
| 1683 |
if (c.nonconformant_digital_display) |
| 1684 |
printk(BIOS_ERR, |
| 1685 |
"\tDigital display field contains garbage: %x\n", |
| 1686 |
c.nonconformant_digital_display); |
| 1687 |
if (!c.has_name_descriptor) |
| 1688 |
printk(BIOS_ERR, "\tMissing name descriptor\n"); |
| 1689 |
if (!c.has_preferred_timing) |
| 1690 |
printk(BIOS_ERR, "\tMissing preferred timing\n"); |
| 1691 |
if (!c.has_range_descriptor) |
| 1692 |
printk(BIOS_ERR, "\tMissing monitor ranges\n"); |
| 1693 |
|
| 1694 |
if (!c.has_valid_descriptor_pad) |
| 1695 |
printk(BIOS_ERR, |
| 1696 |
"\tInvalid descriptor block padding\n"); |
| 1697 |
if (!c.has_valid_string_termination) |
| 1698 |
printk(BIOS_ERR, |
| 1699 |
"\tDetailed block string not properly terminated\n"); |
| 1700 |
} else if (c.claims_one_point_two) { |
| 1701 |
if (c.nonconformant_digital_display || |
| 1702 |
!c.has_valid_string_termination) { |
| 1703 |
c.conformant = EDID_NOT_CONFORMANT; |
| 1704 |
printk(BIOS_ERR, |
| 1705 |
"EDID block does NOT conform to EDID 1.2!\n"); |
| 1706 |
} |
| 1707 |
if (c.nonconformant_digital_display) |
| 1708 |
printk(BIOS_ERR, |
| 1709 |
"\tDigital display field contains garbage: %x\n", |
| 1710 |
c.nonconformant_digital_display); |
| 1711 |
if (!c.has_valid_string_termination) |
| 1712 |
printk(BIOS_ERR, |
| 1713 |
"\tDetailed block string not properly terminated\n"); |
| 1714 |
} else if (c.claims_one_point_oh) { |
| 1715 |
if (c.seen_non_detailed_descriptor) { |
| 1716 |
c.conformant = EDID_NOT_CONFORMANT; |
| 1717 |
printk(BIOS_ERR, |
| 1718 |
"EDID block does NOT conform to EDID 1.0!\n"); |
| 1719 |
} |
| 1720 |
if (c.seen_non_detailed_descriptor) |
| 1721 |
printk(BIOS_ERR, |
| 1722 |
"\tHas descriptor blocks other than detailed timings\n"); |
| 1723 |
} |
| 1724 |
|
| 1725 |
if (c.nonconformant_extension || |
| 1726 |
!c.has_valid_checksum || |
| 1727 |
!c.has_valid_cvt || |
| 1728 |
!c.has_valid_year || |
| 1729 |
!c.has_valid_week || |
| 1730 |
!c.has_valid_detailed_blocks || |
| 1731 |
!c.has_valid_dummy_block || |
| 1732 |
!c.has_valid_descriptor_ordering || |
| 1733 |
!c.has_valid_range_descriptor || |
| 1734 |
!c.manufacturer_name_well_formed) { |
| 1735 |
c.conformant = EDID_NOT_CONFORMANT; |
| 1736 |
printk(BIOS_ERR, "EDID block does not conform at all!\n"); |
| 1737 |
if (c.nonconformant_extension) |
| 1738 |
printk(BIOS_ERR, |
| 1739 |
"\tHas %d nonconformant extension block(s)\n", |
| 1740 |
c.nonconformant_extension); |
| 1741 |
if (!c.has_valid_checksum) |
| 1742 |
printk(BIOS_ERR, "\tBlock has broken checksum\n"); |
| 1743 |
if (!c.has_valid_cvt) |
| 1744 |
printk(BIOS_ERR, "\tBroken 3-byte CVT blocks\n"); |
| 1745 |
if (!c.has_valid_year) |
| 1746 |
printk(BIOS_ERR, "\tBad year of manufacture\n"); |
| 1747 |
if (!c.has_valid_week) |
| 1748 |
printk(BIOS_ERR, "\tBad week of manufacture\n"); |
| 1749 |
if (!c.has_valid_detailed_blocks) |
| 1750 |
printk(BIOS_ERR, |
| 1751 |
"\tDetailed blocks filled with garbage\n"); |
| 1752 |
if (!c.has_valid_dummy_block) |
| 1753 |
printk(BIOS_ERR, "\tDummy block filled with garbage\n"); |
| 1754 |
if (!c.manufacturer_name_well_formed) |
| 1755 |
printk(BIOS_ERR, |
| 1756 |
"\tManufacturer name field contains garbage\n"); |
| 1757 |
if (!c.has_valid_descriptor_ordering) |
| 1758 |
printk(BIOS_ERR, |
| 1759 |
"\tInvalid detailed timing descriptor ordering\n"); |
| 1760 |
if (!c.has_valid_range_descriptor) |
| 1761 |
printk(BIOS_ERR, |
| 1762 |
"\tRange descriptor contains garbage\n"); |
| 1763 |
if (!c.has_valid_max_dotclock) |
| 1764 |
printk(BIOS_ERR, |
| 1765 |
"\tEDID 1.4 block does not set max dotclock\n"); |
| 1766 |
} |
| 1767 |
|
| 1768 |
if (c.warning_excessive_dotclock_correction) |
| 1769 |
printk(BIOS_ERR, |
| 1770 |
"Warning: CVT block corrects dotclock by more than 9.75MHz\n"); |
| 1771 |
if (c.warning_zero_preferred_refresh) |
| 1772 |
printk(BIOS_ERR, |
| 1773 |
"Warning: CVT block does not set preferred refresh rate\n"); |
| 1774 |
return c.conformant; |
| 1775 |
} |
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, |
| 1834 |
int row_byte_alignment) |
| 1835 |
{ |
| 1836 |
|
| 1837 |
assert(fb_bpp == 32 || fb_bpp == 24 || fb_bpp == 16); |
| 1838 |
row_byte_alignment = MAX(row_byte_alignment, 1); |
| 1839 |
|
| 1840 |
edid->framebuffer_bits_per_pixel = fb_bpp; |
| 1841 |
edid->bytes_per_line = ALIGN_UP(edid->mode.ha * |
| 1842 |
DIV_ROUND_UP(fb_bpp, 8), row_byte_alignment); |
| 1843 |
edid->x_resolution = edid->bytes_per_line / (fb_bpp / 8); |
| 1844 |
edid->y_resolution = edid->mode.va; |
| 1845 |
} |