summaryrefslogtreecommitdiff
path: root/tvdump2code.py
diff options
context:
space:
mode:
Diffstat (limited to 'tvdump2code.py')
-rw-r--r--tvdump2code.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/tvdump2code.py b/tvdump2code.py
new file mode 100644
index 0000000..9b73cc0
--- /dev/null
+++ b/tvdump2code.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+import sys
+import re
+
+mode=""
+
+print """#define NV_PRAMDAC_84C 0x0068084c
+#define NV_PRAMDAC_898 0x00680898
+#define NV_PRAMDAC_89C 0x0068089c
+
+#define NV_PRAMDAC_TV_SETUP 0x00680700
+#define NV_PRAMDAC_TV_VBLANK_START 0x00680704
+#define NV_PRAMDAC_TV_VBLANK_END 0x00680708
+#define NV_PRAMDAC_TV_HBLANK_START 0x0068070c
+#define NV_PRAMDAC_TV_HBLANK_END 0x00680710
+#define NV_PRAMDAC_TV_BLANK_COLOR 0x00680714
+#define NV_PRAMDAC_TV_VTOTAL 0x00680720
+#define NV_PRAMDAC_TV_VSYNC_START 0x00680724
+#define NV_PRAMDAC_TV_VSYNC_END 0x00680728
+#define NV_PRAMDAC_TV_HTOTAL 0x0068072c
+#define NV_PRAMDAC_TV_HSYNC_START 0x00680730
+#define NV_PRAMDAC_TV_HSYNC_STOP 0x00680734
+#define NV_PRAMDAC_TV_SYNC_DELAY 0x00680738"""
+
+
+for l in sys.stdin.readlines():
+ if re.match(".*TV encoder register dump.*",l):
+ mode="tvenc"
+ continue
+ elif re.match(".*PTV register dump.*",l):
+ mode="ptv"
+ continue
+ elif re.match(".*CRTC . timings.*",l):
+ mode=""
+ continue
+ elif re.match(".*VGA CRTC. registers.*",l):
+ mode="vgacrtc"
+ continue
+ elif re.match(".*PRAMDAC. registers.*",l):
+ mode="pramdac"
+ i=int(re.match(".*PRAMDAC(.) registers.*",l).group(1))
+ continue
+ elif re.match(".*PCRTC. registers.*",l):
+ mode="pcrtc"
+ i=int(re.match(".*PCRTC(.) registers.*",l).group(1))
+ continue
+ elif re.match(".*(OUTPUT|MISC) registers.*",l):
+ mode="output"
+ continue
+
+ if mode == "":
+ pass
+ elif mode == "tvenc":
+ print re.sub("(.*) *: *(.*)","nv_write_tv_enc(pNv, 0x\\1, 0x\\2);",l)[0:-1]
+ elif mode == "ptv":
+ print re.sub("(.*) *: *(.*)","nv_write_ptv(pNv, 0x\\1, 0x\\2);",l)[0:-1]
+ elif mode == "vgacrtc":
+ if re.match("^CRTC[01]",l):
+ print re.sub("CRTC(.) (.*) *: *(.*)"," NVWriteVgaCrtc(pNv, \\1, 0x\\2, 0x\\3);",l)[0:-1]
+ elif mode == "pramdac":
+ print re.sub("(.*) *: *(.*)"," NVWriteRAMDAC(pNv, %d, \\1, \\2);" % (i),l)[0:-1]
+ elif mode == "pcrtc":
+ print re.sub("(.*) *: *(.*)"," NVWriteCRTC(pNv, %d, \\1, \\2);" % (i),l)[0:-1]
+ elif mode == "output":
+ print re.sub("(.*) *: *(.*)"," NV_WR32(pNv->REGS, \\1, \\2);",l)[0:-1]