From 88129b7ea2a2fdcbe82bb28312c3a1b360314665 Mon Sep 17 00:00:00 2001 From: Asaril Date: Sun, 9 Jan 2022 20:52:33 +0000 Subject: [PATCH] Add dump_regs --- tw8836.py | 607 +++++++++++++++++++++++++++++++++++++++++++++++++ tw88xx.py | 16 +- tw88xx_util.py | 20 +- 3 files changed, 632 insertions(+), 11 deletions(-) diff --git a/tw8836.py b/tw8836.py index ba60eb5..9b4e671 100644 --- a/tw8836.py +++ b/tw8836.py @@ -7,3 +7,610 @@ class TW8836(TW88xx): def __init__(self, i2c: I2CInterface) -> None: super().__init__(i2c) + + REGS = { + 0x000: 'Product ID Code Register (ID)', + 0x002: 'IRQ', + 0x003: 'IMASK', + 0x004: 'Status', + 0x006: 'SRST', + 0x007: 'OUTPUT CTRL I', + 0x008: 'OUTPUT CTRL II', + 0x00F: 'INT0 WRITE PORT', + 0x01F: 'TEST', + 0x040: 'INPUT Control I', + 0x041: 'INPUT Control II', + 0x042: 'INPUT CROP_HI', + 0x043: 'INPUT V CROP Position', + 0x044: 'INPUT V CROP Length LO', + 0x045: 'IINPUT H CROP Position LO', + 0x046: 'INPUT H CROP Length LO', + 0x047: 'BT656 Decoder Control I', + 0x048: 'BT656 Decoder Control II', + 0x04A: 'BT656 Status II', + 0x050: 'DTV Input Control', + 0x051: 'DTV Input Control', + 0x052: 'DTV Input Control', + 0x053: 'DTV Input Format', + 0x054: 'DTV Field Detection Region', + 0x056: 'DTV Vsync Delay', + 0x057: 'Sequential RGB', + 0x05F: 'Test Pattern Generator Control Register', + 0x080: 'GPIO0_EN', + 0x081: 'GPIO1_EN', + 0x082: 'GPIO2_EN', + 0x083: 'GPIO3_EN', + 0x084: 'GPIO4_EN', + 0x085: 'GPIO5_EN', + 0x086: 'GPIO6_EN', + 0x088: 'GPIO0_OE', + 0x089: 'GPIO1_OE', + 0x08A: 'GPIO2_OE', + 0x08B: 'GPIO3_OE', + 0x08C: 'GPIO4_OE', + 0x08D: 'GPIO5_OE', + 0x08E: 'GPIO6_OE', + 0x090: 'GPIO0_OD', + 0x091: 'GPIO1_OD', + 0x092: 'GPIO2_OD', + 0x093: 'GPIO3_OD', + 0x094: 'GPIO4_OD', + 0x095: 'GPIO5_OD', + 0x096: 'GPIO6_OD', + 0x098: 'GPIO0_ID', + 0x099: 'GPIO1_ID', + 0x09A: 'GPIO2_ID', + 0x09B: 'GPIO3_ID', + 0x09C: 'GPIO4_ID', + 0x09D: 'GPIO5_ID', + 0x09E: 'GPIO6_ID', + 0x0A0: 'MBIST Control', + 0x0A1: 'MBIST I', + 0x0A2: 'MBIST II', + 0x0A3: 'MBIST III', + 0x0A4: 'MBIST IV', + 0x0B0: 'Touch Screen Control I', + 0x0B1: 'Touch Screen Control II', + 0x0B2: 'TSC ADC Data Output_HI', + 0x0B3: 'TSC ADC Data Output_LO', + 0x0B4: 'TSC ADC Sample and Clock', + 0x0D4: 'LOPOR Registers', + 0x0D6: 'TCLK AND PWM CNTL', + 0x0D7: 'FPWM3_LO', + 0x0D8: 'DPWM3', + 0x0D9: 'FPWM4_LO', + 0x0DA: 'DPWM4', + 0x0DB: 'FPWM_HI', + 0x0DC: 'FPWM1_LO', + 0x0DD: 'DPWM1', + 0x0DE: 'FPWM2_LO', + 0x0DF: 'DPWM2', + 0x0E0: 'LEDC Control I', + 0x0E1: 'LEDC Sense Control', + 0x0E2: 'LEDC Control II', + 0x0E3: 'LEDC PWM', + 0x0E4: 'LEDC Dim Frequency', + 0x0E5: 'LEDC Dim Control', + 0x0E6: 'LEDC PWMTOP', + 0x0E8: 'DCDC Control I', + 0x0E9: 'DCDC Sense Control', + 0x0EA: 'DCDC Control II', + 0x0EB: 'DCDC PWM', + 0x0EC: 'DCDC PWMTOP', + 0x0ED: 'VCOM-DC OFFSET Control', + 0x0EE: 'VCOM-AC AMP Control', + 0x0F6: 'CLOCK_DIV', + 0x0F7: 'SSPLL', + 0x0F8: 'SSPLL Control Registers', + 0x0F9: 'SSPLL Frequency Control Registers', + 0x0FA: 'SSPLL Frequency Control Registers', + 0x0FB: 'SSPLL Modulation Frequency Control Registers', + 0x0FC: 'SSPLL', + 0x0FD: 'SSPLL Analog Control Registers', + 0x101: 'Chip Status Register (CSTATUS)', + 0x102: 'Input Format (INFORM)', + 0x104: 'HSYNC Delay Control', + 0x105: 'misc video flags', + 0x106: 'Analog Control Register (ACNTL)', + 0x107: 'Cropping Register, High (CROP_HI)', + 0x108: 'Vertical Delay Register, Low (VDELAY_LO)', + 0x109: 'Vertical Active Register, Low (VACTIVE_LO)', + 0x10A: 'Horizontal Delay Register, Low (HDELAY_LO)', + 0x10B: 'Horizontal Active Register, Low (HACTIVE_LO)', + 0x10C: 'Control Register I (CNTRL1)', + 0x10D: 'CC/WSS Control', + 0x110: 'BRIGHTNESS Control Register (BRIGHT)', + 0x111: 'CONTRAST Control Register (CONTRAST)', + 0x112: 'SHARPNESS Control Register I (SHARPNESS)', + 0x113: 'Chroma (U) Gain Register (SAT_U)', + 0x114: 'Chroma (V) Gain Register (SAT_V)', + 0x115: 'Hue Control Register (HUE)', + 0x117: 'Vertical Peaking Control I', + 0x118: 'Coring Control Register (CORING)', + 0x11A: 'CC/EDS Status Register (CC_STATUS)', + 0x11B: 'CC/EDS Data Register (CC_DATA)', + 0x11C: 'Standard Selection (SDT)', + 0x11D: 'Standard Recognition (SDTR)', + 0x11E: 'Component Video Format (CVFMT)', + 0x120: 'Clamping Gain (CLMPG)', + 0x121: 'Individual AGC Gain (IAGC)', + 0x122: 'AGC Gain (AGCGAIN)', + 0x123: 'White Peak Threshold (PEAKWT)', + 0x124: 'Clamp level (CLMPL)', + 0x125: 'Sync Amplitude (SYNCT)', + 0x126: 'Sync Miss Count Register (MISSCNT)', + 0x127: 'Clamp Position Register (PCLAMP)', + 0x128: 'Vertical Control I', + 0x129: 'Vertical Control II', + 0x12A: 'Color Killer Level Control', + 0x12B: 'Comb Filter Control', + 0x12C: 'Luma Delay and HFilter Control', + 0x12D: 'Miscellaneous Control Register I (MISC1)', + 0x12E: 'Miscellaneous Control Register II (MISC2)', + 0x12F: 'Miscellaneous Control III (MISC3)', + 0x131: 'Chip STATUS II (CSTATUS2)', + 0x132: 'H Monitor (HFREF)', + 0x133: 'CLAMP MODE(CLMD)', + 0x134: 'ID Detection Control (NSEN/SSEN/PSEN/WKTH)', + 0x135: 'Clamp Control (CLCNTL)', + 0x140: 'WSS0', + 0x141: 'WSS1', + 0x142: 'WSS2', + 0x1C0: 'LLPLL Input Control Register', + 0x1C1: 'LLPLL Input Detection Register', + 0x1C2: 'LLPLL Control Register', + 0x1C3: 'LLPLL Divider High Register', + 0x1C4: 'LLPLL Divider Low Register', + 0x1C5: 'LLPLL Clock Phase Register', + 0x1C6: 'LLPLL Loop Control Register', + 0x1C7: 'LLPLL VCO Control Register', + 0x1C8: 'LLPLL VCO Control Register', + 0x1C9: 'LLPLL Pre Coast Register', + 0x1CA: 'LLPLL Post Coast Register', + 0x1CB: 'SOG Threshold Register', + 0x1CC: 'Scaler Sync Selection Register', + 0x1CD: 'PLL Initialization Register', + 0x1D0: 'Clamp Gain Control Register', + 0x1D1: 'Y Channel Gain Adjust Register', + 0x1D2: 'C Channel Gain Adjust Register', + 0x1D3: 'V Channel Gain Adjust Register', + 0x1D4: 'Clamp Mode Control Register', + 0x1D5: 'Clamp Start Position Register', + 0x1D6: 'Clamp Stop Position Register', + 0x1D7: 'Clamp Master Location Register', + 0x1D8: 'ADC TEST Register', + 0x1D9: 'Y Clamp Reference Register', + 0x1DA: 'C Clamp Reference Register', + 0x1DB: 'V Clamp Reference Register', + 0x1DC: 'misc video 2', + 0x1E0: 'LLPLL Control Register', + 0x1E1: 'LLPLL Control Register', + 0x1E2: 'ADC Control I', + 0x1E3: 'ADC Control II', + 0x1E4: 'ADC Control III', + 0x1E5: 'ADC Control IV', + 0x1E6: 'ADC Control V', + 0x1E7: 'ADC Control VI', + 0x201: 'General Scaler Control', + 0x202: 'Scaling Offset Control', + 0x203: 'XSCALE_LO', + 0x204: 'XSCALE_HI', + 0x205: 'YSCALE_LO', + 0x206: 'YSCALE_HI', + 0x207: 'PXSCALE', + 0x208: 'PXINC', + 0x209: 'HDSCALE_LO', + 0x20A: 'HDSCALE_HI', + 0x20B: 'HDELAY2', + 0x20C: 'HACTIVE2_LO', + 0x20D: 'LNTT_HI', + 0x20E: 'HPADJ_HI', + 0x20F: 'HPADJ_LO', + 0x210: 'HA_POS', + 0x211: 'HA_LEN_LO', + 0x212: 'HA_LEN_HI', + 0x213: 'HS_POS', + 0x214: 'HS_LEN', + 0x215: 'VA_POS', + 0x216: 'VA_LEN_LO', + 0x217: 'VA_LEN_HI', + 0x218: 'VS_LEN_POS', + 0x219: 'LNTT_LO', + 0x21A: 'DM_TOP', + 0x21B: 'DM_BOT', + 0x21C: 'PANEL_FRUN', + 0x21D: 'HTOTAL_LO', + 0x21E: 'BLANK', + 0x240: 'CSP Control', + 0x241: 'CLP Position', + 0x242: 'CLP Width', + 0x243: 'RCK Control HI', + 0x244: 'RCK Position LO', + 0x245: 'RCK Width LO', + 0x246: 'ROE Control HI', + 0x247: 'ROE Position LO', + 0x248: 'ROE Width LO', + 0x249: 'RSP Control', + 0x24A: 'RSP Position Control', + 0x24B: 'CPL Position Control', + 0x24C: 'CPL Position Control LO', + 0x24D: 'TCON Control I', + 0x24E: 'TCON Control II', + 0x280: 'Image Adjustment Register', + 0x281: 'Image Adjustment Register', + 0x282: 'Image Adjustment Register', + 0x283: 'Image Adjustment Register', + 0x284: 'Image Adjustment Register', + 0x285: 'Image Adjustment Register', + 0x286: 'Image Adjustment Register', + 0x287: 'Image Adjustment Register', + 0x288: 'Image Adjustment Register', + 0x289: 'Image Adjustment Register', + 0x28A: 'Image Adjustment Register', + 0x28B: 'Image Adjustment Register', + 0x28C: 'Image Adjustment Register', + 0x2B0: 'Image Adjustment Register', + 0x2B1: 'Image Adjustment Register', + 0x2B2: 'Image Adjustment Register', + 0x2B6: 'Image Adjustment Register', + 0x2B7: 'Image Adjustment Register', + 0x2BE: 'Image Adjustment Register', + 0x2BF: 'Test Pattern Generator Register', + 0x2E0: 'LCDC Gamma Control Register', + 0x2E1: 'Gamma Table Address Port Register', + 0x2E3: 'Gamma Table Data Port Register', + 0x2E4: 'Dither Option Register', + 0x2F0: 'RGB Level Readout Register', + 0x2F1: 'RGB Level Readout Register', + 0x2F2: 'RGB Level Readout Register', + 0x2F3: 'RGB Level Readout Register', + 0x2F4: 'RGB Level Readout Register', + 0x2F5: 'RGB Level Readout Register', + 0x2F8: '8-bit Panel Interface Register', + 0x2F9: '8-bit Panel Interface Register', + 0x300: 'Font OSD Control Register', + 0x301: 'Status Register', + 0x302: 'Test Register', + 0x303: 'Font OSD Control Register', + 0x304: 'Font OSD Control Register', + 0x305: 'Font OSD Control Register', + 0x306: 'OSD RAM Address Register', + 0x307: 'OSD RAM Data Port Hi Register', + 0x308: 'OSD RAM Data Port Lo Register', + 0x309: 'Font RAM Address Register', + 0x30A: 'Font RAM Data Port', + 0x30B: 'Multi-Color Font Start Position Register', + 0x30C: 'Font OSD Control Register', + 0x30D: 'Character Color Look-up table data port High Byte Register', + 0x30E: 'Character Color Look-up table data port Low Byte Register', + 0x310: 'OSD Window1 Control Register', + 0x311: 'OSD Window1 Control Register', + 0x312: 'OSD Window1 Control Register', + 0x313: 'OSD Window1 Control Register', + 0x314: 'OSD Window1 Control Register', + 0x315: 'OSD Window1 Control Register', + 0x316: 'OSD Window1 Control Register', + 0x317: 'OSD Window1 Control Register', + 0x318: 'OSD Window1 Control Register', + 0x319: 'OSD Window1 Control Register', + 0x31A: 'OSD Window1 Control Register', + 0x31B: 'OSD Window1 Control Register', + 0x31C: 'OSD Window1 Control Register', + 0x31D: 'OSD Window1 Control Register', + 0x31E: 'OSD Window1 Control Register', + 0x31F: 'OSD Window1 Control Register', + 0x320: 'OSD Window2 Control Register', + 0x321: 'OSD Window2 Control Register', + 0x322: 'OSD Window2 Control Register', + 0x323: 'OSD Window2 Control Register', + 0x324: 'OSD Window2 Control Register', + 0x325: 'OSD Window2 Control Register', + 0x326: 'OSD Window2 Control Register', + 0x327: 'OSD Window2 Control Register', + 0x328: 'OSD Window2 Control Register', + 0x329: 'OSD Window2 Control Register', + 0x32A: 'OSD Window2 Control Register', + 0x32B: 'OSD Window2 Control Register', + 0x32C: 'OSD Window2 Control Register', + 0x32D: 'OSD Window2 Control Register', + 0x32E: 'OSD Window2 Control Register', + 0x32F: 'OSD Window2 Control Register', + 0x330: 'OSD Window3 Control Register', + 0x331: 'OSD Window3 Control Register', + 0x332: 'OSD Window3 Control Register', + 0x333: 'OSD Window3 Control Register', + 0x334: 'OSD Window3 Control Register', + 0x335: 'OSD Window3 Control Register', + 0x336: 'OSD Window3 Control Register', + 0x337: 'OSD Window3 Control Register', + 0x338: 'OSD Window3 Control Register', + 0x339: 'OSD Window3 Control Register', + 0x33A: 'OSD Window3 Control Register', + 0x33B: 'OSD Window3 Control Register', + 0x33C: 'OSD Window3 Control Register', + 0x33D: 'OSD Window3 Control Register', + 0x33E: 'OSD Window3 Control Register', + 0x33F: 'OSD Window3 Control Register', + 0x340: 'OSD Window4 Control Register', + 0x341: 'OSD Window4 Control Register', + 0x342: 'OSD Window4 Control Register', + 0x343: 'OSD Window4 Control Register', + 0x344: 'OSD Window4 Control Register', + 0x345: 'OSD Window4 Control Register', + 0x346: 'OSD Window4 Control Register', + 0x347: 'OSD Window4 Control Register', + 0x348: 'OSD Window4 Control Register', + 0x349: 'OSD Window4 Control Register', + 0x34A: 'OSD Window4 Control Register', + 0x34B: 'OSD Window4 Control Register', + 0x34C: 'OSD Window4 Control Register', + 0x34D: 'OSD Window4 Control Register', + 0x34E: 'OSD Window4 Control Register', + 0x34F: 'OSD Window4 Control Register', + 0x350: 'Font OSD Control Register', + 0x351: 'Font OSD Control Register', + 0x352: 'Font OSD Control Register', + 0x353: 'Multi-Color Font Start Position Register', + 0x354: 'Multi-Color Font Start Position Register', + 0x400: 'SPIOSD Control Register', + 0x404: 'SPIOSD RLC Control', + 0x405: 'SPIOSD RLC Configuration', + 0x406: 'SPIOSD RLC Window Select', + 0x40E: 'SPIOSD TIME Adjust Register High Byte', + 0x40F: 'SPIOSD TIME Adjust Register High Byte', + 0x410: '8-Bit SPIOSD Look Up Table Access Control Register', + 0x411: '8 Bit SPIOSD Look Up Table Address [7:0] Register', + 0x412: '8 Bit SPIOSD Look Up Table Data Port [7:0] Register', + 0x420: 'SPIOSD Window 0 Enable Register', + 0x421: 'SPIOSD Window 0 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x422: 'SPIOSD Window 0 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x423: 'SPIOSD Window 0 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x424: 'SPIOSD Window 0 Horizontal/Vertical Length Registers Horizontal/Vertical High Byte Register', + 0x425: 'SPIOSD Window 0 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x426: 'SPIOSD Window 0 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x427: 'SPIOSD Window 0 Buffer Memory Starting Address [23:0] High Byte Register', + 0x428: 'SPIOSD Window 0 Buffer Memory Starting Address [23:0] Mid byte Register', + 0x429: 'SPIOSD Window 0 Buffer Memory Starting Address [23:0] Low Byte Register', + 0x42A: 'SPIOSD Window 0 Buffer Horizontal/Vertical Length [11:0] Registers Horizontal/Vertical High Byte Register', + 0x42B: 'SPIOSD Window 0 Buffer Horizontal/Vertical Length [11:0] Registers Horizontal Low Byte Register', + 0x42C: 'SPIOSD Window 0 Buffer Horizontal/Vertical Length [11:0] Registers Vertical Low Byte Register', + 0x42D: 'SPIOSD Window 0 Image Horizontal/Vertical Start RegistersHorizontal/Vertical High Byte Register', + 0x42E: 'SPIOSD Window 0 Image Horizontal/Vertical Start RegistersLow byte Register', + 0x42F: 'SPIOSD Window 0 Image Horizontal/Vertical Start RegistersLow Byte Register', + 0x430: 'SPIOSD Window 0 Global Alpha Value [6:0] Register', + 0x431: 'SPIOSD Window 0 LUT Pointer Offset Register', + 0x432: 'SPIOSD Window 0 Loop Control RegistersLooping Horizontal Frame Number Register', + 0x433: 'SPIOSD Window 0 Loop Control RegistersLooping Vertical Frame Number Register', + 0x434: 'SPIOSD Window 0 Loop Control RegistersFrame Duration Register', + 0x435: 'SPIOSD Window 0 Loop Enable Register', + 0x436: 'SPIOSD Window 0 Fill Color Register', + 0x440: 'SPIOSD Window 1 Enable Register', + 0x441: 'SPIOSD Window 1 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x442: 'SPIOSD Window 1 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x443: 'SPIOSD Window 1 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x444: 'SPIOSD Window 1 Horizontal/Vertical Length Registers Horizontal/Vertical High Byte Register', + 0x445: 'SPIOSD Window 1 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x446: 'SPIOSD Window 1 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x447: 'SPIOSD Window 1 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x448: 'SPIOSD Window 1 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x449: 'SPIOSD Window 1 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x44A: 'SPIOSD Window 1 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x44A: 'SPIOSD Window 1 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x44B: 'SPIOSD Window 1 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x44C: 'SPIOSD Window 1 Global Alpha Value [6:0] Register', + 0x44D: 'SPIOSD Window 1 LUT Pointer Offset Register', + 0x44E: 'SPIOSD Window 1 Fill Color Register', + 0x450: 'SPIOSD Window 2 Enable Register', + 0x451: 'SPIOSD Window 2 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x452: 'SPIOSD Window 2 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x453: 'SPIOSD Window 2 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x454: 'SPIOSD Window 2 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x455: 'SPIOSD Window 2 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x456: 'SPIOSD Window 2 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x457: 'SPIOSD Window 2 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x458: 'SPIOSD Window 2 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x459: 'SPIOSD Window 2 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x45A: 'SPIOSD Window 2 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x45A: 'SPIOSD Window 2 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x45B: 'SPIOSD Window 2 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x45C: 'SPIOSD Window 2 Global Alpha Value [6:0] Register', + 0x45D: 'SPIOSD Window 2 LUT Pointer Offset Register', + 0x45E: 'SPIOSD Window 2 Fill Color Register', + 0x460: 'SPIOSD Window 3 Enable Register', + 0x461: 'SPIOSD Window 3 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x462: 'SPIOSD Window 3 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x463: 'SPIOSD Window 3 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x464: 'SPIOSD Window 3 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x465: 'SPIOSD Window 3 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x466: 'SPIOSD Window 3 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x467: 'SPIOSD Window 3 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x468: 'SPIOSD Window 3 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x469: 'SPIOSD Window 3 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x46A: 'SPIOSD Window 3 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x46A: 'SPIOSD Window 3 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x46B: 'SPIOSD Window 3 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x46C: 'SPIOSD Window 3 Global Alpha Value [6:0] Register', + 0x46D: 'SPIOSD Window 3 LUT Pointer Offset Register', + 0x46E: 'SPIOSD Window 3 Fill Color Register', + 0x470: 'SPIOSD Window 4 Enable Register', + 0x471: 'SPIOSD Window 4 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x472: 'SPIOSD Window 4 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x473: 'SPIOSD Window 4 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x474: 'SPIOSD Window 4 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x475: 'SPIOSD Window 4 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x476: 'SPIOSD Window 4 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x477: 'SPIOSD Window 4 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x478: 'SPIOSD Window 4 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x479: 'SPIOSD Window 4 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x47A: 'SPIOSD Window 4 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x47A: 'SPIOSD Window 4 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x47B: 'SPIOSD Window 4 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x47C: 'SPIOSD Window 4 Global Alpha Value [6:0] Register', + 0x47D: 'SPIOSD Window 4 LUT Pointer Offset Register', + 0x47E: 'SPIOSD Window 4 Fill Color Register', + 0x480: 'SPIOSD Window 5 Enable Register', + 0x481: 'SPIOSD Window 5 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x482: 'SPIOSD Window 5 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x483: 'SPIOSD Window 5 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x484: 'SPIOSD Window 5 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x485: 'SPIOSD Window 5 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x486: 'SPIOSD Window 5 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x487: 'SPIOSD Window 5 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x488: 'SPIOSD Window 5 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x489: 'SPIOSD Window 5 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x48A: 'SPIOSD Window 5 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x48A: 'SPIOSD Window 5 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x48B: 'SPIOSD Window 5 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x48C: 'SPIOSD Window 5 Global Alpha Value [6:0] Register', + 0x48D: 'SPIOSD Window 5 LUT Pointer Offset Register', + 0x48E: 'SPIOSD Window 5 Fill Color Register', + 0x490: 'SPIOSD Window 6 Enable Register', + 0x491: 'SPIOSD Window 6 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x492: 'SPIOSD Window 6 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x493: 'SPIOSD Window 6 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x494: 'SPIOSD Window 6 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x495: 'SPIOSD Window 6 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x496: 'SPIOSD Window 6 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x497: 'SPIOSD Window 6 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x498: 'SPIOSD Window 6 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x499: 'SPIOSD Window 6 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x49A: 'SPIOSD Window 6 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x49A: 'SPIOSD Window 6 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x49B: 'SPIOSD Window 6 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x49C: 'SPIOSD Window 6 Global Alpha Value [6:0] Register', + 0x49D: 'SPIOSD Window 6 LUT Pointer Offset Register', + 0x49E: 'SPIOSD Window 6 Fill Color Register', + 0x4A0: 'SPIOSD Window 7 Enable Register', + 0x4A1: 'SPIOSD Window 7 Horizontal/Vertical Start Registers Horizontal/Vertical High Byte Register', + 0x4A2: 'SPIOSD Window 7 Horizontal/Vertical Start Registers Horizontal Low Byte Register', + 0x4A3: 'SPIOSD Window 7 Horizontal/Vertical Start Registers Vertical Low Byte Register', + 0x4A4: 'SPIOSD Window 7 Horizontal/Vertical Length Registers Horizontal/ Vertical High Byte Register', + 0x4A5: 'SPIOSD Window 7 Horizontal/Vertical Length Registers Horizontal Low Byte Register', + 0x4A6: 'SPIOSD Window 7 Horizontal/Vertical Length Registers Vertical Low Byte Register', + 0x4A7: 'SPIOSD Window 7 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x4A8: 'SPIOSD Window 7 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x4A9: 'SPIOSD Window 7 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x4AA: 'SPIOSD Window 7 Buffer Memory Starting Address [23:0] Registers Low Byte Bit Register', + 0x4AA: 'SPIOSD Window 7 Buffer Horizontal Length [11:0] Registers High Byte Register', + 0x4AB: 'SPIOSD Window 7 Buffer Horizontal Length [11:0] Registers Low Byte Register', + 0x4AC: 'SPIOSD Window 7 Global Alpha Value [6:0] Register', + 0x4AD: 'SPIOSD Window 7 LUT Pointer Offset Register', + 0x4AE: 'SPIOSD Window 7 Fill Color Register', + 0x4B0: 'SPIOSD Window 8 Enable Register', + 0x4B1: 'SPIOSD Window 8 Horizontal/Vertical Start RegistersHorizontal/Vertical High Byte Register', + 0x4B2: 'SPIOSD Window 8 Horizontal/Vertical Start RegistersHorizontal Low Byte Register', + 0x4B3: 'SPIOSD Window 8 Horizontal/Vertical Start RegistersVertical Low Byte Register', + 0x4B4: 'SPIOSD Window 8 Horizontal/Vertical Length RegistersHorizontal/ Vertical High Byte Register', + 0x4B5: 'SPIOSD Window 8 Horizontal/Vertical Length RegistersHorizontal Low Byte Register', + 0x4B6: 'SPIOSD Window 8 Horizontal/Vertical Length RegistersVertical Low Byte Register', + 0x4B7: 'SPIOSD Window 8 Buffer Memory Starting Address [23:0] Registers High Byte Register', + 0x4B8: 'SPIOSD Window 8 Buffer Memory Starting Address [23:0] Registers Mid Byte Register', + 0x4B9: 'SPIOSD Window 8 Buffer Memory Starting Address [23:0] Registers Low Byte Register', + 0x4BA: 'SPIOSD Window 8 Buffer Horizontal Length [11:0] RegistersHigh Byte Register', + 0x4BB: 'SPIOSD Window 8 Buffer Horizontal Length [11:0] RegistersLow Byte Register', + 0x4BC: 'SPIOSD Window 8 Global Alpha Value [6:0] Register', + 0x4BD: 'SPIOSD Window 8 LUT Pointer Offset Register', + 0x4BE: 'SPIOSD Window 8 Fill Color Register', + 0x4C0: 'SPI Flash Mode Control Register', + 0x4C1: '-- SPI Flash Mode Control Register', + 0x4C3: 'DMA Control Register', + 0x4C4: 'Flash Busy Control Register', + 0x4C5: 'Wait Control Register', + 0x4C6: 'DMA Page Register', + 0x4C7: 'DMA Index Register', + 0x4C8: 'DMA Length Mid Byte Register', + 0x4C9: 'DMA Length Low Byte Register', + 0x4CA: 'DMA Command Buffer1 Register', + 0x4CB: 'DMA Command Buffer2 Register', + 0x4CC: 'DMA Command Buffer3 Register', + 0x4CD: 'DMA Command Buffer4 Register', + 0x4CE: 'DMA Command Buffer5 Register', + 0x4CF: 'Clock Switch wait counter value', + 0x4D0: 'DMA Read/Write Buffer1 Register', + 0x4D1: 'DMA Read/Write Buffer2 Register', + 0x4D2: 'DMA Read/Write Buffer3 Register', + 0x4D3: 'DMA Read/Write Buffer4 Register', + 0x4D4: 'DMA Read/Write Buffer5 Register', + 0x4D5: 'DMA Read/Write Buffer6 Register', + 0x4D6: 'DMA Read/Write Buffer7 Register', + 0x4D7: 'DMA Read/Write Buffer8 Register', + 0x4D8: 'SPI Flash Status Command Register', + 0x4D9: 'SPI Flash Busy Control Register', + 0x4DA: 'DMA Length High Byte Register', + 0x4E0: 'PCLK Control Register', + 0x4E1: 'SPI CLK Control Register', + 0x4E2: 'Timer0 Divider High Byte Register', + 0x4E3: 'Timer0 Divider Low Byte Register', + 0x4E4: 'Timer1 Divider High Byte Register', + 0x4E5: 'Timer1 Divider Low Byte Register', + 0x4E6: 'Timer2 Divider High Byte Register', + 0x4E7: 'Timer2 Divider Low Byte Register', + 0x4E8: 'Timer3 Divider High Byte Register', + 0x4E9: 'Timer3 Divider Low Byte Register', + 0x4EA: 'Timer4 Divider High Byte Register', + 0x4EB: 'Timer4 Divider Low Byte Register', + 0x500: 'Measurement Window Horizontal Start [10:0] High Byte Register', + 0x501: 'Measurement Window Horizontal Start [10:0] Low Byte Register', + 0x502: 'Measurement Window Horizontal Length [11:0] High Byte Register', + 0x503: 'Measurement Window Horizontal Length [11:0] Low Byte Register', + 0x504: 'Measurement Window Vertical Start [10:0] High Byte Register', + 0x505: 'Measurement Window Vertical Start [10:0]Low Byte Register', + 0x506: 'Measurement Window Vertical Length [10:0] High Byte Register', + 0x507: 'Measurement Window Vertical Length [10:0] Low Byte Register', + 0x508: 'Measurement Input Selection, Measurement Start Register', + 0x509: 'Measurement Option, Input Change Detection Register180', + 0x50A: 'Measurement Option Register', + 0x50B: 'Measurement Option Register', + 0x510: 'Phase_G Registers Byte 3 Register ', + 0x511: 'Phase_G Registers Byte 2 Register', + 0x512: 'Phase_G Registers Byte 1 Register', + 0x513: 'Phase_G Registers Byte 0 Register', + 0x514: 'Phase_B Registers Byte 3 Register', + 0x515: 'Phase_B Registers Byte 2 Register', + 0x516: 'Phase_B Registers Byte 1 Register', + 0x517: 'Phase_B Registers Byte 0 Register', + 0x518: 'Phase_R Registers Byte 3 Register', + 0x519: 'Phase_R Registers Byte 2 Register', + 0x51A: 'Phase_R Registers Byte 1 Register', + 0x51B: 'Phase_R Registers Byte 0 Register', + 0x51C: 'Minimum_G Register', + 0x51D: 'Minimum_B Register', + 0x51E: 'Minimum_R Register', + 0x51F: 'Maximum_G Register', + 0x520: 'Maximum_B Register', + 0x521: 'Maximum_R Register', + 0x522: 'Vertical Period Registers High Byte Register', + 0x523: 'Vertical Period Registers Low Byte Register', + 0x524: 'Horizontal Period Registers High Byte Register', + 0x525: 'Horizontal Period Registers Low Byte Register', + 0x526: 'Hsync Rise to Fall Registers High Byte Register', + 0x527: 'Hsync Rise to Fall Registers Low Byte Register', + 0x528: 'Hsync Rise to Horizontal Active End High Byte Register', + 0x529: 'Hsync Rise to Horizontal Active End Low Byte Register', + 0x52A: 'Vsync High Width Registers High Byte Register', + 0x52B: 'Vsync High Width Registers Low Byte Register', + 0x52C: 'Vsync Rise Position Registers High Byte Register', + 0x52D: 'Vsync Rise Position Registers Low Byte Register', + 0x52E: 'Horizontal Active Starting Pixel Position I Registers High Byte Register', + 0x52F: 'Horizontal Active Starting Pixel Position I Registers Low Byte Register', + 0x530: 'Horizontal Active Starting Pixel Position II Registers High Byte Register', + 0x531: 'Horizontal Active Starting Pixel Position II Registers Low Byte Register', + 0x532: 'Horizontal Active Ending Pixel Position I Registers High Byte Register', + 0x533: 'Horizontal Active Ending Pixel Position I Registers Low Byte Register', + 0x534: 'Horizontal Active Ending Pixel Position II Register High Byte Register', + 0x535: 'Horizontal Active Ending Pixel Position II Register Low Byte Register', + 0x536: 'Vertical Active Starting Line I Registers High Byte Register', + 0x537: 'Vertical Active Starting Line I Registers Low Byte Register', + 0x538: 'Vertical Active Starting Line II Registers High Byte Register', + 0x539: 'Vertical Active Starting Line II Registers Low Byte Register', + 0x53A: 'Vertical Active Ending Line I Registers High Byte Register', + 0x53B: 'Vertical Active Ending Line I Registers Low Byte Register', + 0x53C: 'Vertical Active Ending Line II Registers High Byte Register', + 0x53D: 'Vertical Active Ending Line II Registers Low Byte Register', + 0x540: 'Liminance Value Minimum Register', + 0x541: 'Liminance Value Maximum Register', + 0x542: 'Liminance Value Average Register', + 0x543: 'Vertical Period in 27 MHz Registers High Byte Register', + 0x544: 'Vertical Period in 27 MHz Registers Mid Byte Register', + 0x545: 'Vertical Period in 27 MHz Registers Low Byte Register' + } diff --git a/tw88xx.py b/tw88xx.py index ece5c02..dd707a6 100644 --- a/tw88xx.py +++ b/tw88xx.py @@ -74,8 +74,8 @@ class TW88xx: data.append(self.read_reg(TW88xx.Reg.DMA_READWRITE_BUFFER + i)) return bytes(data) - def prepare_flash_read(self, cmd, read_len): - self.write_reg(TW88xx.Reg.DMA_CONTROL, 0x40 + len(cmd)) + def prepare_flash_read(self, cmd_len, read_len): + self.write_reg(TW88xx.Reg.DMA_CONTROL, 0x40 + cmd_len) self.write_reg(TW88xx.Reg.DMA_PAGE, 0x04) self.write_reg(TW88xx.Reg.DMA_INDEX, 0xD0) @@ -84,10 +84,11 @@ class TW88xx: self.write_reg(TW88xx.Reg.DMA_LENGTH_LOW_BYTE, read_len) self.write_reg(TW88xx.Reg.DMA_LENGTH_HIGH_BYTE, 0) + + def do_flash_cmd(self, cmd, read_len): for i in range(len(cmd)): self.write_reg(TW88xx.Reg.DMA_COMMAND_BUFFER + i, cmd[i]) - - def do_flash_cmd(self, read_len): + self.write_reg(TW88xx.Reg.FLASH_BUSY_CONTROL, 0x01) while True: busy = self.read_reg(TW88xx.Reg.FLASH_BUSY_CONTROL) @@ -97,4 +98,9 @@ class TW88xx: data = [] for i in range(read_len): data.append(self.read_reg(TW88xx.Reg.DMA_READWRITE_BUFFER + i)) - return bytes(data) \ No newline at end of file + return bytes(data) + + def dump_regs(self): + for r in self.REGS: + val = self.read_reg(r) + print(f'{r:03x} = {val:02x} ({self.REGS[r]})') \ No newline at end of file diff --git a/tw88xx_util.py b/tw88xx_util.py index 61427bd..a05e559 100644 --- a/tw88xx_util.py +++ b/tw88xx_util.py @@ -5,7 +5,7 @@ parser = argparse.ArgumentParser(description='TW88xx debug utility.') parser.add_argument('command', help='the command to execute', - choices=('dump_flash', 'get_id') + choices=('dump_flash', 'get_id', 'dump_regs') ) parser.add_argument('-f', '--flash_file', help='file to read from / write into' @@ -25,7 +25,7 @@ parser.add_argument('-b', '--bus', ) parser.add_argument('-t', '--type', help='TX88xx type', - choices=('tw8836'), + choices=('tw8836',), default='tw8836' ) @@ -55,16 +55,24 @@ elif args.command == 'dump_flash': # tw88xx.prepare_flash_read(cmd=[0x03, 0x1a, 0x9d, 0x84], read_len=8) tw88xx.execute_flash_cmd(cmd=[0xE9], read_len=0) data = [] - for block_start in range(0x1a9d84, 0x1a9d84+480*480, 8): - block = tw88xx.execute_flash_cmd(cmd=[0x03, (block_start >> 16) & 0xFF, - (block_start >> 8) & 0xFF, block_start & 0xFF], read_len=8, data=[0x5a]*8) + BS=4 + tw88xx.prepare_flash_read(cmd_len = 4, read_len=BS) + for block_start in range(0x1a9d84, 0x1a9d84+480*480, BS): + # block = tw88xx.execute_flash_cmd(, data=[0x5a]*BS) + cmd=[0x03, (block_start >> 16) & 0xFF, (block_start >> 8) & 0xFF, block_start & 0xFF] + block = tw88xx.do_flash_cmd(cmd, read_len=BS) data.extend(block) - print(f'{block_start:06x}: {block.hex()}') + print(f'{(block_start-0x1a9d84) / (480*480)*100:02.4f}% {block_start:06x}: {block.hex()}') print(bytes(data).hex()) + with open(args.flash_file,'wb') as f: + f.write(bytes(data)) # tw88xx.execute_flash_cmd(cmd=[0xB7], read_len=0) # block = tw88xx.execute_flash_cmd(cmd=[0x03, 0x00, 0x00, 0x00], read_len=8) # print(block.hex()) # block = tw88xx.execute_flash_cmd(cmd=[0x03, 0x00, 0x00, 0x08], read_len=8) # print(block.hex()) # tw88xx.execute_flash_cmd(cmd=[0xE9], read_len=0) + +elif args.command == 'dump_regs': + tw88xx.dump_regs()