edid-decode: add 'silent' arg to data_block_oui()
[edid-decode.git] / parse-vtb-ext-block.cpp
blob15ff0efdfd0389a771d57cde5672f2bfe67b106a
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright 2019-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 * Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
6 */
8 #include "edid-decode.h"
10 void edid_state::parse_vtb_ext_block(const unsigned char *x)
12 printf(" Version: %u\n", x[1]);
13 if (x[1] != 1)
14 fail("Invalid version %u.\n", x[1]);
16 unsigned num_dtd = x[2];
17 unsigned num_cvt = x[3];
18 unsigned num_st = x[4];
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;
29 detailed_timings(" ", x, false);
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;
39 detailed_cvt_descriptor(" ", x, false);
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.
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;
55 print_standard_timing(" ", x[0], x[1], true);
58 unused_bytes = y - x;
59 if (!memchk(x, unused_bytes)) {
60 data_block = "Padding";
61 fail("Contains non-zero bytes.\n");