1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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})")
|