summaryrefslogtreecommitdiff
path: root/flashimg/cpu_hdmi/tmds_decode_table.h.gen
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-15 08:54:45 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-07-08 10:20:41 -0600
commit6fd11a1bf4d1bc4c4919c3381be8d4c476dd4235 (patch)
treed356d5ed2c944d9d15f06cc36a14c8c779a8c4f7 /flashimg/cpu_hdmi/tmds_decode_table.h.gen
parent72b9036dc961d9fe7e0e9deb12e87f121a4d0ccf (diff)
wip: flashimg/cpu_hdmi: Initial version of the TMDS decoder/downscalerlukeshu/vid-hdmi
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})")