aboutsummaryrefslogtreecommitdiffstats
path: root/parse-ls-ext-block.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-11-30 17:01:29 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-11-30 17:01:29 +0100
commitef332ea91c3c1d1f64e637c8527412bcaea2899d (patch)
tree53dd3e1f523d60f3d2e95cba5ac032c91e3c47d7 /parse-ls-ext-block.cpp
parentf6f25c0bb64a18e604a268a3c084b79017e651e0 (diff)
edid-decode: add LS-EXT support
It was fairly easy to add support for this, but I have not seen EDIDs that use this extension 'in the wild'. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'parse-ls-ext-block.cpp')
-rw-r--r--parse-ls-ext-block.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/parse-ls-ext-block.cpp b/parse-ls-ext-block.cpp
new file mode 100644
index 0000000..fe065ac
--- /dev/null
+++ b/parse-ls-ext-block.cpp
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2006-2012 Red Hat, Inc.
+ * Copyright 2018-2019 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
+ *
+ * Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+ */
+
+#include "edid-decode.h"
+
+static void parse_string(const char *name, const unsigned char *x)
+{
+ if (!*x)
+ return;
+ printf(" %s: ", name);
+ hex_block("", x + 1, *x, true, true);
+}
+
+static void parse_string_table(const unsigned char *x)
+{
+ printf(" UTF Type: ");
+ switch (x[0] & 7) {
+ case 0: printf("UTF 8\n"); break;
+ case 1: printf("UTF 16BE\n"); break;
+ case 2: printf("UTF 32BE\n"); break;
+ default:
+ printf("Unknown (0x%02x)\n", x[0] & 7);
+ fail("Unknown UTF Type (0x%02x)\n", x[0] & 7);
+ break;
+ }
+ printf(" Country Code ID (ISO 3166-3): %u\n", ((x[1] & 0x3f) << 8) | x[2]);
+
+ if (x[3] || x[4]) {
+ char name[4];
+
+ name[0] = ((x[3] & 0x7c) >> 2) + '@';
+ name[1] = ((x[3] & 0x03) << 3) + ((x[4] & 0xe0) >> 5) + '@';
+ name[2] = (x[4] & 0x1f) + '@';
+ name[3] = 0;
+ if (name[0] == '@') name[0] = ' ';
+ if (name[1] == '@') name[1] = ' ';
+ if (name[2] == '@') name[2] = ' ';
+ printf(" Language ID: %s\n", name);
+ }
+ x += 5;
+ parse_string("Manufacturer Name", x);
+ x += x[0] + 1;
+ parse_string("Model Name", x);
+ x += x[0] + 1;
+ parse_string("Serial Number", x);
+}
+
+void parse_ls_ext_block(edid_state &state, const unsigned char *x)
+{
+ const unsigned char *orig = x;
+
+ printf("%s Version %u.%u Unicode Version %u.%u.%u\n",
+ state.cur_block.c_str(), x[1], x[2], (x[3] >> 4), x[3] & 0x0f, x[4]);
+ x += 5;
+
+ while (x[0] && x + x[0] < orig + 127) {
+ parse_string_table(x + 1);
+ x += x[0];
+ }
+}

Privacy Policy