| 1 |
// SPDX-License-Identifier: MIT |
| 2 |
/* |
| 3 |
* Copyright 2019-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
| 4 |
* |
| 5 |
* Author: Hans Verkuil <[email protected]> |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "edid-decode.h" |
| 9 |
|
| 10 |
void edid_state::parse_vtb_ext_block(const unsigned char *x) |
| 11 |
{ |
| 12 |
printf(" Version: %u\n", x[1]); |
| 13 |
if (x[1] != 1) |
| 14 |
fail("Invalid version %u.\n", x[1]); |
| 15 |
|
| 16 |
unsigned num_dtd = x[2]; |
| 17 |
unsigned num_cvt = x[3]; |
| 18 |
unsigned num_st = x[4]; |
| 19 |
|
| 20 |
const unsigned char *y = x + 0x7f; |
| 21 |
x += 5; |
| 22 |
if (num_dtd) { |
| 23 |
printf(" Detailed Timing Descriptors:\n"); |
| 24 |
for (unsigned i = 0; i < num_dtd; i++, x += 18) { |
| 25 |
if (x + 18 > y) { |
| 26 |
fail("Not enough bytes remain for more DTDs in the VTB-EXT.\n"); |
| 27 |
return; |
| 28 |
} |
| 29 |
detailed_timings(" ", x, false); |
| 30 |
} |
| 31 |
} |
| 32 |
if (num_cvt) { |
| 33 |
printf(" Coordinated Video Timings:\n"); |
| 34 |
for (unsigned i = 0; i < num_cvt; i++, x += 3) { |
| 35 |
if (x + 3 > y) { |
| 36 |
fail("Not enough bytes remain for more CVTs in the VTB-EXT.\n"); |
| 37 |
return; |
| 38 |
} |
| 39 |
detailed_cvt_descriptor(" ", x, false); |
| 40 |
} |
| 41 |
} |
| 42 |
if (num_st) { |
| 43 |
// Note: the VTB-EXT standard has a mistake in the example EDID |
| 44 |
// that it provides: there the refresh rate (bits 5-0 of the |
| 45 |
// second byte) is set to 60 for 60 Hz, but this should be 0 |
| 46 |
// since the actual refresh rate is the value + 60. |
| 47 |
// |
| 48 |
// The documentation itself is correct, though. |
| 49 |
printf(" Standard Timings:\n"); |
| 50 |
for (unsigned i = 0; i < num_st; i++, x += 2) { |
| 51 |
if (x + 2 > y) { |
| 52 |
fail("Not enough bytes remain for more STs in the VTB-EXT.\n"); |
| 53 |
return; |
| 54 |
} |
| 55 |
print_standard_timing(" ", x[0], x[1], true); |
| 56 |
} |
| 57 |
} |
| 58 |
unused_bytes = y - x; |
| 59 |
if (!memchk(x, unused_bytes)) { |
| 60 |
data_block = "Padding"; |
| 61 |
fail("Contains non-zero bytes.\n"); |
| 62 |
} |
| 63 |
} |