Debian Codegraph @

utils/edid-decode/parse-eld.cpp

raw
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright 2024 Linaro Ltd. All rights reserved.
4 *
5 * Author: Dmitry Baryshkov <[email protected]>
6 */
7
8 #include <stdio.h>
9
10 #include "edid-decode.h"
11
12 void edid_state::parse_eld_baseline(const unsigned char *x, unsigned size)
13 {
14 unsigned mnl, sad_count, data;
15 unsigned char dummy_sadb[3] = {};
16 char *manufacturer;
17
18 printf("Baseline ELD:\n");
19
20 if (size < 16) {
21 fail("Baseline ELD too short (%d)\n", size);
22 return;
23 }
24
25 mnl = x[0] & 0x1f;
26
27 data = x[0] >> 5;
28 switch (data) {
29 case 0:
30 printf(" no CEA EDID Timing Extension present\n");
31 break;
32 case 1:
33 printf(" CEA EDID 861\n");
34 break;
35 case 2:
36 printf(" CEA EDID 861.A\n");
37 break;
38 case 3:
39 printf(" CEA EDID 861.B/C/D\n");
40 break;
41 default:
42 warn("Unsupported CEA EDID version (%d)\n", data);
43 break;
44 }
45
46 if (x[1] & 1)
47 printf(" HDCP Content Protection is supported\n");
48 if (x[1] & 2)
49 printf(" ACP / ISRC / ISRC2 packets are handled\n");
50
51 data = (x[1] >> 2) & 3;
52 switch (data) {
53 case 0:
54 printf(" HDMI connection\n");
55 break;
56 case 1:
57 printf(" DisplayPort connection\n");
58 break;
59 default:
60 warn(" Unrecognized connection type (%d)\n", data);
61 }
62
63 sad_count = x[1] >> 4;
64
65 if (x[2])
66 printf(" Audio latency: %d ms\n", x[2] * 2);
67 else
68 printf(" No Audio latency information\n");
69
70 printf(" Speaker Allocation:\n");
71 dummy_sadb[0] = x[3];
72 cta_sadb(dummy_sadb, sizeof(dummy_sadb));
73
74 printf(" Port ID:\n");
75 hex_block(" ", x + 0x4, 8);
76
77 manufacturer = manufacturer_name(x + 0x0c);
78 printf(" Manufacturer: %s\n", manufacturer);
79 printf(" Model: %u\n", (unsigned short)(x[0x0e] + (x[0x0f] << 8)));
80
81 if (0x10 + mnl >= size) {
82 fail("Manufacturer name overflow (MNL = %d)\n", mnl);
83 return;
84 }
85
86 printf(" Display Product Name: '%s'\n", extract_string(x + 0x10, mnl, true));
87
88 if (0x10 + mnl + (3 * sad_count) >= size) {
89 fail("Short Audio Descriptors overflow\n");
90 return;
91 }
92
93 if (sad_count != 0) {
94 printf(" Short Audio Descriptors:\n");
95 cta_audio_block(x + 0x10 + mnl, 3 * sad_count);
96 }
97 }