summaryrefslogtreecommitdiff
path: root/flashimg/cpu_hdmi/tmds_decode_table.h.gen
diff options
context:
space:
mode:
Diffstat (limited to 'flashimg/cpu_hdmi/tmds_decode_table.h.gen')
-rwxr-xr-xflashimg/cpu_hdmi/tmds_decode_table.h.gen39
1 files changed, 39 insertions, 0 deletions
diff --git a/flashimg/cpu_hdmi/tmds_decode_table.h.gen b/flashimg/cpu_hdmi/tmds_decode_table.h.gen
new file mode 100755
index 0000000..f3b330f
--- /dev/null
+++ b/flashimg/cpu_hdmi/tmds_decode_table.h.gen
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+# flashimg/cpu_hdmi/tmds_decode_table.h.gen - Generate a table for TMDS decoding
+#
+# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+import sys
+
+print(f"// Generated by `{' '.join(sys.argv)}`. DO NOT EDIT!")
+for enc in range(1 << 10):
+ D = [bool((enc >> (9 - i)) & 1) for i in range(10)]
+ # Algorithm from DVI 1.0 Figure 3-6
+ if D[9]:
+ for i in range(8):
+ D[i] = not D[i]
+ if D[8]:
+ Q = [
+ D[0],
+ D[1] != D[0],
+ D[2] != D[1],
+ D[3] != D[2],
+ D[4] != D[3],
+ D[5] != D[4],
+ D[6] != D[5],
+ D[7] != D[6],
+ ]
+ else:
+ Q = [
+ D[0],
+ D[1] == D[0],
+ D[2] == D[1],
+ D[3] == D[2],
+ D[4] == D[3],
+ D[5] == D[4],
+ D[6] == D[5],
+ D[7] == D[6],
+ ]
+ s = "".join("1" if b else "0" for b in Q)
+ print(f"X(0b{s})")