18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * TW5864 driver - registers description 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2016 Bluecherry, LLC <maintainers@bluecherrydvr.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* According to TW5864_datasheet_0.6d.pdf, tw5864b1-ds.pdf */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* Register Description - Direct Map Space */ 118c2ecf20Sopenharmony_ci/* 0x0000 ~ 0x1ffc - H264 Register Map */ 128c2ecf20Sopenharmony_ci/* [15:0] The Version register for H264 core (Read Only) */ 138c2ecf20Sopenharmony_ci#define TW5864_H264REV 0x0000 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define TW5864_EMU 0x0004 168c2ecf20Sopenharmony_ci/* Define controls in register TW5864_EMU */ 178c2ecf20Sopenharmony_ci/* DDR controller enabled */ 188c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_DDR BIT(0) 198c2ecf20Sopenharmony_ci/* Enable bit for Inter module */ 208c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_ME BIT(1) 218c2ecf20Sopenharmony_ci/* Enable bit for Sensor Interface module */ 228c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_SEN BIT(2) 238c2ecf20Sopenharmony_ci/* Enable bit for Host Burst Access */ 248c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_BHOST BIT(3) 258c2ecf20Sopenharmony_ci/* Enable bit for Loop Filter module */ 268c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_LPF BIT(4) 278c2ecf20Sopenharmony_ci/* Enable bit for PLBK module */ 288c2ecf20Sopenharmony_ci#define TW5864_EMU_EN_PLBK BIT(5) 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * Video Frame mapping in DDR 318c2ecf20Sopenharmony_ci * 00 CIF 328c2ecf20Sopenharmony_ci * 01 D1 338c2ecf20Sopenharmony_ci * 10 Reserved 348c2ecf20Sopenharmony_ci * 11 Reserved 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ci#define TW5864_DSP_FRAME_TYPE (3 << 6) 388c2ecf20Sopenharmony_ci#define TW5864_DSP_FRAME_TYPE_D1 BIT(6) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define TW5864_UNDECLARED_H264REV_PART2 0x0008 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define TW5864_SLICE 0x000c 438c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SLICE */ 448c2ecf20Sopenharmony_ci/* VLC Slice end flag */ 458c2ecf20Sopenharmony_ci#define TW5864_VLC_SLICE_END BIT(0) 468c2ecf20Sopenharmony_ci/* Master Slice End Flag */ 478c2ecf20Sopenharmony_ci#define TW5864_MAS_SLICE_END BIT(4) 488c2ecf20Sopenharmony_ci/* Host to start a new slice Address */ 498c2ecf20Sopenharmony_ci#define TW5864_START_NSLICE BIT(15) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* 528c2ecf20Sopenharmony_ci * [15:0] Two bit for each channel (channel 0 ~ 7). Each two bits are the buffer 538c2ecf20Sopenharmony_ci * pointer for the last encoded frame of the corresponding channel. 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci#define TW5864_ENC_BUF_PTR_REC1 0x0010 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* [5:0] DSP_MB_QP and [15:10] DSP_LPF_OFFSET */ 588c2ecf20Sopenharmony_ci#define TW5864_DSP_QP 0x0018 598c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_QP */ 608c2ecf20Sopenharmony_ci/* [5:0] H264 QP Value for codec */ 618c2ecf20Sopenharmony_ci#define TW5864_DSP_MB_QP 0x003f 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * [15:10] H264 LPF_OFFSET Address 648c2ecf20Sopenharmony_ci * (Default 0) 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci#define TW5864_DSP_LPF_OFFSET 0xfc00 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define TW5864_DSP_CODEC 0x001c 698c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_CODEC */ 708c2ecf20Sopenharmony_ci/* 718c2ecf20Sopenharmony_ci * 0: Encode (TW5864 Default) 728c2ecf20Sopenharmony_ci * 1: Decode 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci#define TW5864_DSP_CODEC_MODE BIT(0) 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * 0->3 4 VLC data buffer in DDR (1M each) 778c2ecf20Sopenharmony_ci * 0->7 8 VLC data buffer in DDR (512k each) 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_ci#define TW5864_VLC_BUF_ID (7 << 2) 808c2ecf20Sopenharmony_ci/* 818c2ecf20Sopenharmony_ci * 0 4CIF in 1 MB 828c2ecf20Sopenharmony_ci * 1 1CIF in 1 MB 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci#define TW5864_CIF_MAP_MD BIT(6) 858c2ecf20Sopenharmony_ci/* 868c2ecf20Sopenharmony_ci * 0 2 falf D1 in 1 MB 878c2ecf20Sopenharmony_ci * 1 1 half D1 in 1 MB 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_ci#define TW5864_HD1_MAP_MD BIT(7) 908c2ecf20Sopenharmony_ci/* VLC Stream valid */ 918c2ecf20Sopenharmony_ci#define TW5864_VLC_VLD BIT(8) 928c2ecf20Sopenharmony_ci/* MV Vector Valid */ 938c2ecf20Sopenharmony_ci#define TW5864_MV_VECT_VLD BIT(9) 948c2ecf20Sopenharmony_ci/* MV Flag Valid */ 958c2ecf20Sopenharmony_ci#define TW5864_MV_FLAG_VLD BIT(10) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN 0x0020 988c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_SEN */ 998c2ecf20Sopenharmony_ci/* Org Buffer Base for Luma (default 0) */ 1008c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_PIC_LU 0x000f 1018c2ecf20Sopenharmony_ci/* Org Buffer Base for Chroma (default 4) */ 1028c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_PIC_CHM 0x00f0 1038c2ecf20Sopenharmony_ci/* Maximum Number of Buffers (default 4) */ 1048c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_PIC_MAX 0x0700 1058c2ecf20Sopenharmony_ci/* 1068c2ecf20Sopenharmony_ci * Original Frame D1 or HD1 switch 1078c2ecf20Sopenharmony_ci * (Default 0) 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_HFULL 0x1000 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_PIC 0x0024 1128c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_REF_PIC */ 1138c2ecf20Sopenharmony_ci/* Ref Buffer Base for Luma (default 0) */ 1148c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_PIC_LU 0x000f 1158c2ecf20Sopenharmony_ci/* Ref Buffer Base for Chroma (default 4) */ 1168c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_PIC_CHM 0x00f0 1178c2ecf20Sopenharmony_ci/* Maximum Number of Buffers (default 4) */ 1188c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_PIC_MAX 0x0700 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci/* [15:0] SEN_EN_CH[n] SENIF original frame capture enable for each channel */ 1218c2ecf20Sopenharmony_ci#define TW5864_SEN_EN_CH 0x0028 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#define TW5864_DSP 0x002c 1248c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP */ 1258c2ecf20Sopenharmony_ci/* The ID for channel selected for encoding operation */ 1268c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_CHN 0x000f 1278c2ecf20Sopenharmony_ci/* See DSP_MB_DELAY below */ 1288c2ecf20Sopenharmony_ci#define TW5864_DSP_MB_WAIT 0x0010 1298c2ecf20Sopenharmony_ci/* 1308c2ecf20Sopenharmony_ci * DSP Chroma Switch 1318c2ecf20Sopenharmony_ci * 0 DDRB 1328c2ecf20Sopenharmony_ci * 1 DDRA 1338c2ecf20Sopenharmony_ci */ 1348c2ecf20Sopenharmony_ci#define TW5864_DSP_CHROM_SW 0x0020 1358c2ecf20Sopenharmony_ci/* VLC Flow Control: 1 for enable */ 1368c2ecf20Sopenharmony_ci#define TW5864_DSP_FLW_CNTL 0x0040 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * If DSP_MB_WAIT == 0, MB delay is DSP_MB_DELAY * 16 1398c2ecf20Sopenharmony_ci * If DSP_MB_DELAY == 1, MB delay is DSP_MB_DELAY * 128 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci#define TW5864_DSP_MB_DELAY 0x0f00 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define TW5864_DDR 0x0030 1448c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DDR */ 1458c2ecf20Sopenharmony_ci/* DDR Single Access Page Number */ 1468c2ecf20Sopenharmony_ci#define TW5864_DDR_PAGE_CNTL 0x00ff 1478c2ecf20Sopenharmony_ci/* DDR-DPR Burst Read Enable */ 1488c2ecf20Sopenharmony_ci#define TW5864_DDR_BRST_EN BIT(13) 1498c2ecf20Sopenharmony_ci/* 1508c2ecf20Sopenharmony_ci * DDR A/B Select as HOST access 1518c2ecf20Sopenharmony_ci * 0 Select DDRA 1528c2ecf20Sopenharmony_ci * 1 Select DDRB 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_ci#define TW5864_DDR_AB_SEL BIT(14) 1558c2ecf20Sopenharmony_ci/* 1568c2ecf20Sopenharmony_ci * DDR Access Mode Select 1578c2ecf20Sopenharmony_ci * 0 Single R/W Access (Host <-> DDR) 1588c2ecf20Sopenharmony_ci * 1 Burst R/W Access (Host <-> DPR) 1598c2ecf20Sopenharmony_ci */ 1608c2ecf20Sopenharmony_ci#define TW5864_DDR_MODE BIT(15) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/* The original frame capture pointer. Two bits for each channel */ 1638c2ecf20Sopenharmony_ci/* SENIF_ORG_FRM_PTR [15:0] */ 1648c2ecf20Sopenharmony_ci#define TW5864_SENIF_ORG_FRM_PTR1 0x0038 1658c2ecf20Sopenharmony_ci/* SENIF_ORG_FRM_PTR [31:16] */ 1668c2ecf20Sopenharmony_ci#define TW5864_SENIF_ORG_FRM_PTR2 0x003c 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_MODE 0x0040 1698c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_SEN_MODE */ 1708c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_MODE_CH0 0x000f 1718c2ecf20Sopenharmony_ci#define TW5864_DSP_SEN_MODE_CH1 0x00f0 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 1748c2ecf20Sopenharmony_ci * [15:0]: ENC_BUF_PTR_REC[31:16] Two bit for each channel (channel 8 ~ 15). 1758c2ecf20Sopenharmony_ci * Each two bits are the buffer pointer for the last encoded frame of a channel 1768c2ecf20Sopenharmony_ci */ 1778c2ecf20Sopenharmony_ci#define TW5864_ENC_BUF_PTR_REC2 0x004c 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* Current MV Flag Status Pointer for Channel n. (Read only) */ 1808c2ecf20Sopenharmony_ci/* 1818c2ecf20Sopenharmony_ci * [1:0] CH0_MV_PTR, ..., [15:14] CH7_MV_PTR 1828c2ecf20Sopenharmony_ci */ 1838c2ecf20Sopenharmony_ci#define TW5864_CH_MV_PTR1 0x0060 1848c2ecf20Sopenharmony_ci/* 1858c2ecf20Sopenharmony_ci * [1:0] CH8_MV_PTR, ..., [15:14] CH15_MV_PTR 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_ci#define TW5864_CH_MV_PTR2 0x0064 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* 1908c2ecf20Sopenharmony_ci * [15:0] Reset Current MV Flag Status Pointer for Channel n (one bit each) 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_ci#define TW5864_RST_MV_PTR 0x0068 1938c2ecf20Sopenharmony_ci#define TW5864_INTERLACING 0x0200 1948c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INTERLACING */ 1958c2ecf20Sopenharmony_ci/* 1968c2ecf20Sopenharmony_ci * Inter_Mode Start. 2-nd bit? A guess. Missing in datasheet. Without this bit 1978c2ecf20Sopenharmony_ci * set, the output video is interlaced (stripy). 1988c2ecf20Sopenharmony_ci */ 1998c2ecf20Sopenharmony_ci#define TW5864_DSP_INTER_ST BIT(1) 2008c2ecf20Sopenharmony_ci/* Deinterlacer Enable */ 2018c2ecf20Sopenharmony_ci#define TW5864_DI_EN BIT(2) 2028c2ecf20Sopenharmony_ci/* 2038c2ecf20Sopenharmony_ci * De-interlacer Mode 2048c2ecf20Sopenharmony_ci * 1 Shuffled frame 2058c2ecf20Sopenharmony_ci * 0 Normal Un-Shuffled Frame 2068c2ecf20Sopenharmony_ci */ 2078c2ecf20Sopenharmony_ci#define TW5864_DI_MD BIT(3) 2088c2ecf20Sopenharmony_ci/* 2098c2ecf20Sopenharmony_ci * Down scale original frame in X direction 2108c2ecf20Sopenharmony_ci * 11: Un-used 2118c2ecf20Sopenharmony_ci * 10: down-sample to 1/4 2128c2ecf20Sopenharmony_ci * 01: down-sample to 1/2 2138c2ecf20Sopenharmony_ci * 00: down-sample disabled 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci#define TW5864_DSP_DWN_X (3 << 4) 2168c2ecf20Sopenharmony_ci/* 2178c2ecf20Sopenharmony_ci * Down scale original frame in Y direction 2188c2ecf20Sopenharmony_ci * 11: Un-used 2198c2ecf20Sopenharmony_ci * 10: down-sample to 1/4 2208c2ecf20Sopenharmony_ci * 01: down-sample to 1/2 2218c2ecf20Sopenharmony_ci * 00: down-sample disabled 2228c2ecf20Sopenharmony_ci */ 2238c2ecf20Sopenharmony_ci#define TW5864_DSP_DWN_Y (3 << 6) 2248c2ecf20Sopenharmony_ci/* 2258c2ecf20Sopenharmony_ci * 1 Dual Stream 2268c2ecf20Sopenharmony_ci * 0 Single Stream 2278c2ecf20Sopenharmony_ci */ 2288c2ecf20Sopenharmony_ci#define TW5864_DUAL_STR BIT(8) 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define TW5864_DSP_REF 0x0204 2318c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_REF */ 2328c2ecf20Sopenharmony_ci/* Number of reference frame (Default 1 for TW5864B) */ 2338c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_FRM 0x000f 2348c2ecf20Sopenharmony_ci/* Window size */ 2358c2ecf20Sopenharmony_ci#define TW5864_DSP_WIN_SIZE 0x02f0 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci#define TW5864_DSP_SKIP 0x0208 2388c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_SKIP */ 2398c2ecf20Sopenharmony_ci/* 2408c2ecf20Sopenharmony_ci * Skip Offset Enable bit 2418c2ecf20Sopenharmony_ci * 0 DSP_SKIP_OFFSET value is not used (default 8) 2428c2ecf20Sopenharmony_ci * 1 DSP_SKIP_OFFSET value is used in HW 2438c2ecf20Sopenharmony_ci */ 2448c2ecf20Sopenharmony_ci#define TW5864_DSP_SKIP_OFEN 0x0080 2458c2ecf20Sopenharmony_ci/* Skip mode cost offset (default 8) */ 2468c2ecf20Sopenharmony_ci#define TW5864_DSP_SKIP_OFFSET 0x007f 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci#define TW5864_MOTION_SEARCH_ETC 0x020c 2498c2ecf20Sopenharmony_ci/* Define controls in register TW5864_MOTION_SEARCH_ETC */ 2508c2ecf20Sopenharmony_ci/* Enable quarter pel search mode */ 2518c2ecf20Sopenharmony_ci#define TW5864_QPEL_EN BIT(0) 2528c2ecf20Sopenharmony_ci/* Enable half pel search mode */ 2538c2ecf20Sopenharmony_ci#define TW5864_HPEL_EN BIT(1) 2548c2ecf20Sopenharmony_ci/* Enable motion search mode */ 2558c2ecf20Sopenharmony_ci#define TW5864_ME_EN BIT(2) 2568c2ecf20Sopenharmony_ci/* Enable Intra mode */ 2578c2ecf20Sopenharmony_ci#define TW5864_INTRA_EN BIT(3) 2588c2ecf20Sopenharmony_ci/* Enable Skip Mode */ 2598c2ecf20Sopenharmony_ci#define TW5864_SKIP_EN BIT(4) 2608c2ecf20Sopenharmony_ci/* Search Option (Default 2"b01) */ 2618c2ecf20Sopenharmony_ci#define TW5864_SRCH_OPT (3 << 5) 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_REC 0x0210 2648c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_ENC_REC */ 2658c2ecf20Sopenharmony_ci/* Reference Buffer Pointer for encoding */ 2668c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_REF_PTR 0x0007 2678c2ecf20Sopenharmony_ci/* Reconstruct Buffer pointer */ 2688c2ecf20Sopenharmony_ci#define TW5864_DSP_REC_BUF_PTR 0x7000 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* [15:0] Lambda Value for H264 */ 2718c2ecf20Sopenharmony_ci#define TW5864_DSP_REF_MVP_LAMBDA 0x0214 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB 0x0218 2748c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DSP_PIC_MAX_MB */ 2758c2ecf20Sopenharmony_ci/* The MB number in Y direction for a frame */ 2768c2ecf20Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB_Y 0x007f 2778c2ecf20Sopenharmony_ci/* The MB number in X direction for a frame */ 2788c2ecf20Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB_X 0x7f00 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci/* The original frame pointer for encoding */ 2818c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_REG 0x021c 2828c2ecf20Sopenharmony_ci/* Mask to use with TW5864_DSP_ENC_ORG_PTR */ 2838c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_MASK 0x7000 2848c2ecf20Sopenharmony_ci/* Number of bits to shift with TW5864_DSP_ENC_ORG_PTR */ 2858c2ecf20Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_SHIFT 12 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci/* DDR base address of OSD rectangle attribute data */ 2888c2ecf20Sopenharmony_ci#define TW5864_DSP_OSD_ATTRI_BASE 0x0220 2898c2ecf20Sopenharmony_ci/* OSD enable bit for each channel */ 2908c2ecf20Sopenharmony_ci#define TW5864_DSP_OSD_ENABLE 0x0228 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci/* 0x0280 ~ 0x029c – Motion Vector for 1st 4x4 Block, e.g., 80 (X), 84 (Y) */ 2938c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC1 0x0280 2948c2ecf20Sopenharmony_ci/* 0x02a0 ~ 0x02bc – Motion Vector for 2nd 4x4 Block, e.g., A0 (X), A4 (Y) */ 2958c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC2 0x02a0 2968c2ecf20Sopenharmony_ci/* 0x02c0 ~ 0x02dc – Motion Vector for 3rd 4x4 Block, e.g., C0 (X), C4 (Y) */ 2978c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC3 0x02c0 2988c2ecf20Sopenharmony_ci/* 0x02e0 ~ 0x02fc – Motion Vector for 4th 4x4 Block, e.g., E0 (X), E4 (Y) */ 2998c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC4 0x02e0 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci/* 3028c2ecf20Sopenharmony_ci * [5:0] 3038c2ecf20Sopenharmony_ci * if (intra16x16_cost < (intra4x4_cost+dsp_i4x4_offset)) 3048c2ecf20Sopenharmony_ci * Intra_mode = intra16x16_mode 3058c2ecf20Sopenharmony_ci * Else 3068c2ecf20Sopenharmony_ci * Intra_mode = intra4x4_mode 3078c2ecf20Sopenharmony_ci */ 3088c2ecf20Sopenharmony_ci#define TW5864_DSP_I4x4_OFFSET 0x040c 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci/* 3118c2ecf20Sopenharmony_ci * [6:4] 3128c2ecf20Sopenharmony_ci * 0x5 Only 4x4 3138c2ecf20Sopenharmony_ci * 0x6 Only 16x16 3148c2ecf20Sopenharmony_ci * 0x7 16x16 & 4x4 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE 0x0410 3178c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_SHIFT 4 3188c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_MASK (7 << 4) 3198c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_4x4 0x5 3208c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_16x16 0x6 3218c2ecf20Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_4x4_AND_16x16 0x7 3228c2ecf20Sopenharmony_ci/* 3238c2ecf20Sopenharmony_ci * [5:0] WEIGHT Factor for I4x4 cost calculation (QP dependent) 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_ci#define TW5864_DSP_I4x4_WEIGHT 0x0414 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci/* 3288c2ecf20Sopenharmony_ci * [7:0] Offset used to affect Intra/ME model decision 3298c2ecf20Sopenharmony_ci * If (me_cost < intra_cost + dsp_resid_mode_offset) 3308c2ecf20Sopenharmony_ci * Pred_Mode = me_mode 3318c2ecf20Sopenharmony_ci * Else 3328c2ecf20Sopenharmony_ci * Pred_mode = intra_mode 3338c2ecf20Sopenharmony_ci */ 3348c2ecf20Sopenharmony_ci#define TW5864_DSP_RESID_MODE_OFFSET 0x0604 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci/* 0x0800 ~ 0x09ff - Quantization TABLE Values */ 3378c2ecf20Sopenharmony_ci#define TW5864_QUAN_TAB 0x0800 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci/* Valid channel value [0; f], frame value [0; 3] */ 3408c2ecf20Sopenharmony_ci#define TW5864_RT_CNTR_CH_FRM(channel, frame) \ 3418c2ecf20Sopenharmony_ci (0x0c00 | (channel << 4) | (frame << 2)) 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#define TW5864_FRAME_BUS1 0x0d00 3448c2ecf20Sopenharmony_ci/* 3458c2ecf20Sopenharmony_ci * 1 Progressive in part A in bus n 3468c2ecf20Sopenharmony_ci * 0 Interlaced in part A in bus n 3478c2ecf20Sopenharmony_ci */ 3488c2ecf20Sopenharmony_ci#define TW5864_PROG_A BIT(0) 3498c2ecf20Sopenharmony_ci/* 3508c2ecf20Sopenharmony_ci * 1 Progressive in part B in bus n 3518c2ecf20Sopenharmony_ci * 0 Interlaced in part B in bus n 3528c2ecf20Sopenharmony_ci */ 3538c2ecf20Sopenharmony_ci#define TW5864_PROG_B BIT(1) 3548c2ecf20Sopenharmony_ci/* 3558c2ecf20Sopenharmony_ci * 1 Frame Mode in bus n 3568c2ecf20Sopenharmony_ci * 0 Field Mode in bus n 3578c2ecf20Sopenharmony_ci */ 3588c2ecf20Sopenharmony_ci#define TW5864_FRAME BIT(2) 3598c2ecf20Sopenharmony_ci/* 3608c2ecf20Sopenharmony_ci * 0 4CIF in bus n 3618c2ecf20Sopenharmony_ci * 1 1D1 + 4 CIF in bus n 3628c2ecf20Sopenharmony_ci * 2 2D1 in bus n 3638c2ecf20Sopenharmony_ci */ 3648c2ecf20Sopenharmony_ci#define TW5864_BUS_D1 (3 << 3) 3658c2ecf20Sopenharmony_ci/* Bus 1 goes in TW5864_FRAME_BUS1 in [4:0] */ 3668c2ecf20Sopenharmony_ci/* Bus 2 goes in TW5864_FRAME_BUS1 in [12:8] */ 3678c2ecf20Sopenharmony_ci#define TW5864_FRAME_BUS2 0x0d04 3688c2ecf20Sopenharmony_ci/* Bus 3 goes in TW5864_FRAME_BUS2 in [4:0] */ 3698c2ecf20Sopenharmony_ci/* Bus 4 goes in TW5864_FRAME_BUS2 in [12:8] */ 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* [15:0] Horizontal Mirror for channel n */ 3728c2ecf20Sopenharmony_ci#define TW5864_SENIF_HOR_MIR 0x0d08 3738c2ecf20Sopenharmony_ci/* [15:0] Vertical Mirror for channel n */ 3748c2ecf20Sopenharmony_ci#define TW5864_SENIF_VER_MIR 0x0d0c 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* 3778c2ecf20Sopenharmony_ci * FRAME_WIDTH_BUSn_A 3788c2ecf20Sopenharmony_ci * 0x15f: 4 CIF 3798c2ecf20Sopenharmony_ci * 0x2cf: 1 D1 + 3 CIF 3808c2ecf20Sopenharmony_ci * 0x2cf: 2 D1 3818c2ecf20Sopenharmony_ci * FRAME_WIDTH_BUSn_B 3828c2ecf20Sopenharmony_ci * 0x15f: 4 CIF 3838c2ecf20Sopenharmony_ci * 0x2cf: 1 D1 + 3 CIF 3848c2ecf20Sopenharmony_ci * 0x2cf: 2 D1 3858c2ecf20Sopenharmony_ci * FRAME_HEIGHT_BUSn_A 3868c2ecf20Sopenharmony_ci * 0x11f: 4CIF (PAL) 3878c2ecf20Sopenharmony_ci * 0x23f: 1D1 + 3CIF (PAL) 3888c2ecf20Sopenharmony_ci * 0x23f: 2 D1 (PAL) 3898c2ecf20Sopenharmony_ci * 0x0ef: 4CIF (NTSC) 3908c2ecf20Sopenharmony_ci * 0x1df: 1D1 + 3CIF (NTSC) 3918c2ecf20Sopenharmony_ci * 0x1df: 2 D1 (NTSC) 3928c2ecf20Sopenharmony_ci * FRAME_HEIGHT_BUSn_B 3938c2ecf20Sopenharmony_ci * 0x11f: 4CIF (PAL) 3948c2ecf20Sopenharmony_ci * 0x23f: 1D1 + 3CIF (PAL) 3958c2ecf20Sopenharmony_ci * 0x23f: 2 D1 (PAL) 3968c2ecf20Sopenharmony_ci * 0x0ef: 4CIF (NTSC) 3978c2ecf20Sopenharmony_ci * 0x1df: 1D1 + 3CIF (NTSC) 3988c2ecf20Sopenharmony_ci * 0x1df: 2 D1 (NTSC) 3998c2ecf20Sopenharmony_ci */ 4008c2ecf20Sopenharmony_ci#define TW5864_FRAME_WIDTH_BUS_A(bus) (0x0d10 + 0x0010 * bus) 4018c2ecf20Sopenharmony_ci#define TW5864_FRAME_WIDTH_BUS_B(bus) (0x0d14 + 0x0010 * bus) 4028c2ecf20Sopenharmony_ci#define TW5864_FRAME_HEIGHT_BUS_A(bus) (0x0d18 + 0x0010 * bus) 4038c2ecf20Sopenharmony_ci#define TW5864_FRAME_HEIGHT_BUS_B(bus) (0x0d1c + 0x0010 * bus) 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci/* 4068c2ecf20Sopenharmony_ci * 1: the bus mapped Channel n Full D1 4078c2ecf20Sopenharmony_ci * 0: the bus mapped Channel n Half D1 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ci#define TW5864_FULL_HALF_FLAG 0x0d50 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci/* 4128c2ecf20Sopenharmony_ci * 0 The bus mapped Channel select partA Mode 4138c2ecf20Sopenharmony_ci * 1 The bus mapped Channel select partB Mode 4148c2ecf20Sopenharmony_ci */ 4158c2ecf20Sopenharmony_ci#define TW5864_FULL_HALF_MODE_SEL 0x0d54 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci#define TW5864_VLC 0x1000 4188c2ecf20Sopenharmony_ci/* Define controls in register TW5864_VLC */ 4198c2ecf20Sopenharmony_ci/* QP Value used by H264 CAVLC */ 4208c2ecf20Sopenharmony_ci#define TW5864_VLC_SLICE_QP 0x003f 4218c2ecf20Sopenharmony_ci/* 4228c2ecf20Sopenharmony_ci * Swap byte order of VLC stream in d-word. 4238c2ecf20Sopenharmony_ci * 1 Normal (VLC output= [31:0]) 4248c2ecf20Sopenharmony_ci * 0 Swap (VLC output={[23:16],[31:24],[7:0], [15:8]}) 4258c2ecf20Sopenharmony_ci */ 4268c2ecf20Sopenharmony_ci#define TW5864_VLC_BYTE_SWP BIT(6) 4278c2ecf20Sopenharmony_ci/* Enable Adding 03 circuit for VLC stream */ 4288c2ecf20Sopenharmony_ci#define TW5864_VLC_ADD03_EN BIT(7) 4298c2ecf20Sopenharmony_ci/* Number of bit for VLC bit Align */ 4308c2ecf20Sopenharmony_ci#define TW5864_VLC_BIT_ALIGN_SHIFT 8 4318c2ecf20Sopenharmony_ci#define TW5864_VLC_BIT_ALIGN_MASK (0x1f << 8) 4328c2ecf20Sopenharmony_ci/* 4338c2ecf20Sopenharmony_ci * Synchronous Interface select for VLC Stream 4348c2ecf20Sopenharmony_ci * 1 CDC_VLCS_MAS read VLC stream 4358c2ecf20Sopenharmony_ci * 0 CPU read VLC stream 4368c2ecf20Sopenharmony_ci */ 4378c2ecf20Sopenharmony_ci#define TW5864_VLC_INF_SEL BIT(13) 4388c2ecf20Sopenharmony_ci/* Enable VLC overflow control */ 4398c2ecf20Sopenharmony_ci#define TW5864_VLC_OVFL_CNTL BIT(14) 4408c2ecf20Sopenharmony_ci/* 4418c2ecf20Sopenharmony_ci * 1 PCI Master Mode 4428c2ecf20Sopenharmony_ci * 0 Non PCI Master Mode 4438c2ecf20Sopenharmony_ci */ 4448c2ecf20Sopenharmony_ci#define TW5864_VLC_PCI_SEL BIT(15) 4458c2ecf20Sopenharmony_ci/* 4468c2ecf20Sopenharmony_ci * 0 Enable Adding 03 to VLC header and stream 4478c2ecf20Sopenharmony_ci * 1 Disable Adding 03 to VLC header of "00000001" 4488c2ecf20Sopenharmony_ci */ 4498c2ecf20Sopenharmony_ci#define TW5864_VLC_A03_DISAB BIT(16) 4508c2ecf20Sopenharmony_ci/* 4518c2ecf20Sopenharmony_ci * Status of VLC stream in DDR (one bit for each buffer) 4528c2ecf20Sopenharmony_ci * 1 VLC is ready in buffer n (HW set) 4538c2ecf20Sopenharmony_ci * 0 VLC is not ready in buffer n (SW clear) 4548c2ecf20Sopenharmony_ci */ 4558c2ecf20Sopenharmony_ci#define TW5864_VLC_BUF_RDY_SHIFT 24 4568c2ecf20Sopenharmony_ci#define TW5864_VLC_BUF_RDY_MASK (0xff << 24) 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci/* Total number of bit in the slice */ 4598c2ecf20Sopenharmony_ci#define TW5864_SLICE_TOTAL_BIT 0x1004 4608c2ecf20Sopenharmony_ci/* Total number of bit in the residue */ 4618c2ecf20Sopenharmony_ci#define TW5864_RES_TOTAL_BIT 0x1008 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci#define TW5864_VLC_BUF 0x100c 4648c2ecf20Sopenharmony_ci/* Define controls in register TW5864_VLC_BUF */ 4658c2ecf20Sopenharmony_ci/* VLC BK0 full status, write ‘1’ to clear */ 4668c2ecf20Sopenharmony_ci#define TW5864_VLC_BK0_FULL BIT(0) 4678c2ecf20Sopenharmony_ci/* VLC BK1 full status, write ‘1’ to clear */ 4688c2ecf20Sopenharmony_ci#define TW5864_VLC_BK1_FULL BIT(1) 4698c2ecf20Sopenharmony_ci/* VLC end slice status, write ‘1’ to clear */ 4708c2ecf20Sopenharmony_ci#define TW5864_VLC_END_SLICE BIT(2) 4718c2ecf20Sopenharmony_ci/* VLC Buffer overflow status, write ‘1’ to clear */ 4728c2ecf20Sopenharmony_ci#define TW5864_DSP_RD_OF BIT(3) 4738c2ecf20Sopenharmony_ci/* VLC string length in either buffer 0 or 1 at end of frame */ 4748c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_LEN_SHIFT 4 4758c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_LEN_MASK (0x1ff << 4) 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci/* [15:0] Total coefficient number in a frame */ 4788c2ecf20Sopenharmony_ci#define TW5864_TOTAL_COEF_NO 0x1010 4798c2ecf20Sopenharmony_ci/* [0] VLC Encoder Interrupt. Write ‘1’ to clear */ 4808c2ecf20Sopenharmony_ci#define TW5864_VLC_DSP_INTR 0x1014 4818c2ecf20Sopenharmony_ci/* [31:0] VLC stream CRC checksum */ 4828c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_CRC 0x1018 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci#define TW5864_VLC_RD 0x101c 4858c2ecf20Sopenharmony_ci/* Define controls in register TW5864_VLC_RD */ 4868c2ecf20Sopenharmony_ci/* 4878c2ecf20Sopenharmony_ci * 1 Read VLC lookup Memory 4888c2ecf20Sopenharmony_ci * 0 Read VLC Stream Memory 4898c2ecf20Sopenharmony_ci */ 4908c2ecf20Sopenharmony_ci#define TW5864_VLC_RD_MEM BIT(0) 4918c2ecf20Sopenharmony_ci/* 4928c2ecf20Sopenharmony_ci * 1 Read VLC Stream Memory in burst mode 4938c2ecf20Sopenharmony_ci * 0 Read VLC Stream Memory in single mode 4948c2ecf20Sopenharmony_ci */ 4958c2ecf20Sopenharmony_ci#define TW5864_VLC_RD_BRST BIT(1) 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci/* 0x2000 ~ 0x2ffc -- H264 Stream Memory Map */ 4988c2ecf20Sopenharmony_ci/* 4998c2ecf20Sopenharmony_ci * A word is 4 bytes. I.e., 5008c2ecf20Sopenharmony_ci * VLC_STREAM_MEM[0] address: 0x2000 5018c2ecf20Sopenharmony_ci * VLC_STREAM_MEM[1] address: 0x2004 5028c2ecf20Sopenharmony_ci * ... 5038c2ecf20Sopenharmony_ci * VLC_STREAM_MEM[3FF] address: 0x2ffc 5048c2ecf20Sopenharmony_ci */ 5058c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_MEM_START 0x2000 5068c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_MEM_MAX_OFFSET 0x3ff 5078c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_MEM(offset) (TW5864_VLC_STREAM_MEM_START + 4 * offset) 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci/* 0x4000 ~ 0x4ffc -- Audio Register Map */ 5108c2ecf20Sopenharmony_ci/* [31:0] config 1ms cnt = Realtime clk/1000 */ 5118c2ecf20Sopenharmony_ci#define TW5864_CFG_1MS_CNT 0x4000 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci#define TW5864_ADPCM 0x4004 5148c2ecf20Sopenharmony_ci/* Define controls in register TW5864_ADPCM */ 5158c2ecf20Sopenharmony_ci/* ADPCM decoder enable */ 5168c2ecf20Sopenharmony_ci#define TW5864_ADPCM_DEC BIT(0) 5178c2ecf20Sopenharmony_ci/* ADPCM input data enable */ 5188c2ecf20Sopenharmony_ci#define TW5864_ADPCM_IN_DATA BIT(1) 5198c2ecf20Sopenharmony_ci/* ADPCM encoder enable */ 5208c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC BIT(2) 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci#define TW5864_AUD 0x4008 5238c2ecf20Sopenharmony_ci/* Define controls in register TW5864_AUD */ 5248c2ecf20Sopenharmony_ci/* Record path PCM Audio enable bit for each channel */ 5258c2ecf20Sopenharmony_ci#define TW5864_AUD_ORG_CH_EN 0x00ff 5268c2ecf20Sopenharmony_ci/* Speaker path PCM Audio Enable */ 5278c2ecf20Sopenharmony_ci#define TW5864_SPK_ORG_EN BIT(16) 5288c2ecf20Sopenharmony_ci/* 5298c2ecf20Sopenharmony_ci * 0 16bit 5308c2ecf20Sopenharmony_ci * 1 8bit 5318c2ecf20Sopenharmony_ci */ 5328c2ecf20Sopenharmony_ci#define TW5864_AD_BIT_MODE BIT(17) 5338c2ecf20Sopenharmony_ci#define TW5864_AUD_TYPE_SHIFT 18 5348c2ecf20Sopenharmony_ci/* 5358c2ecf20Sopenharmony_ci * 0 PCM 5368c2ecf20Sopenharmony_ci * 3 ADPCM 5378c2ecf20Sopenharmony_ci */ 5388c2ecf20Sopenharmony_ci#define TW5864_AUD_TYPE (0xf << 18) 5398c2ecf20Sopenharmony_ci#define TW5864_AUD_SAMPLE_RATE_SHIFT 22 5408c2ecf20Sopenharmony_ci/* 5418c2ecf20Sopenharmony_ci * 0 8K 5428c2ecf20Sopenharmony_ci * 1 16K 5438c2ecf20Sopenharmony_ci */ 5448c2ecf20Sopenharmony_ci#define TW5864_AUD_SAMPLE_RATE (3 << 22) 5458c2ecf20Sopenharmony_ci/* Channel ID used to select audio channel (0 to 16) for loopback */ 5468c2ecf20Sopenharmony_ci#define TW5864_TESTLOOP_CHID_SHIFT 24 5478c2ecf20Sopenharmony_ci#define TW5864_TESTLOOP_CHID (0x1f << 24) 5488c2ecf20Sopenharmony_ci/* Enable AD Loopback Test */ 5498c2ecf20Sopenharmony_ci#define TW5864_TEST_ADLOOP_EN BIT(30) 5508c2ecf20Sopenharmony_ci/* 5518c2ecf20Sopenharmony_ci * 0 Asynchronous Mode or PCI target mode 5528c2ecf20Sopenharmony_ci * 1 PCI Initiator Mode 5538c2ecf20Sopenharmony_ci */ 5548c2ecf20Sopenharmony_ci#define TW5864_AUD_MODE BIT(31) 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci#define TW5864_AUD_ADPCM 0x400c 5578c2ecf20Sopenharmony_ci/* Define controls in register TW5864_AUD_ADPCM */ 5588c2ecf20Sopenharmony_ci/* Record path ADPCM audio channel enable, one bit for each */ 5598c2ecf20Sopenharmony_ci#define TW5864_AUD_ADPCM_CH_EN 0x00ff 5608c2ecf20Sopenharmony_ci/* Speaker path ADPCM audio channel enable */ 5618c2ecf20Sopenharmony_ci#define TW5864_SPK_ADPCM_EN BIT(16) 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci#define TW5864_PC_BLOCK_ADPCM_RD_NO 0x4018 5648c2ecf20Sopenharmony_ci#define TW5864_PC_BLOCK_ADPCM_RD_NO_MASK 0x1f 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci/* 5678c2ecf20Sopenharmony_ci * For ADPCM_ENC_WR_PTR, ADPCM_ENC_RD_PTR (see below): 5688c2ecf20Sopenharmony_ci * Bit[2:0] ch0 5698c2ecf20Sopenharmony_ci * Bit[5:3] ch1 5708c2ecf20Sopenharmony_ci * Bit[8:6] ch2 5718c2ecf20Sopenharmony_ci * Bit[11:9] ch3 5728c2ecf20Sopenharmony_ci * Bit[14:12] ch4 5738c2ecf20Sopenharmony_ci * Bit[17:15] ch5 5748c2ecf20Sopenharmony_ci * Bit[20:18] ch6 5758c2ecf20Sopenharmony_ci * Bit[23:21] ch7 5768c2ecf20Sopenharmony_ci * Bit[26:24] ch8 5778c2ecf20Sopenharmony_ci * Bit[29:27] ch9 5788c2ecf20Sopenharmony_ci * Bit[32:30] ch10 5798c2ecf20Sopenharmony_ci * Bit[35:33] ch11 5808c2ecf20Sopenharmony_ci * Bit[38:36] ch12 5818c2ecf20Sopenharmony_ci * Bit[41:39] ch13 5828c2ecf20Sopenharmony_ci * Bit[44:42] ch14 5838c2ecf20Sopenharmony_ci * Bit[47:45] ch15 5848c2ecf20Sopenharmony_ci * Bit[50:48] ch16 5858c2ecf20Sopenharmony_ci */ 5868c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_XX_MASK 0x3fff 5878c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_XX_PTR2_SHIFT 30 5888c2ecf20Sopenharmony_ci/* ADPCM_ENC_WR_PTR[29:0] */ 5898c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_WR_PTR1 0x401c 5908c2ecf20Sopenharmony_ci/* ADPCM_ENC_WR_PTR[50:30] */ 5918c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_WR_PTR2 0x4020 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci/* ADPCM_ENC_RD_PTR[29:0] */ 5948c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_RD_PTR1 0x4024 5958c2ecf20Sopenharmony_ci/* ADPCM_ENC_RD_PTR[50:30] */ 5968c2ecf20Sopenharmony_ci#define TW5864_ADPCM_ENC_RD_PTR2 0x4028 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci/* [3:0] rd ch0, [7:4] rd ch1, [11:8] wr ch0, [15:12] wr ch1 */ 5998c2ecf20Sopenharmony_ci#define TW5864_ADPCM_DEC_RD_WR_PTR 0x402c 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci/* 6028c2ecf20Sopenharmony_ci * For TW5864_AD_ORIG_WR_PTR, TW5864_AD_ORIG_RD_PTR: 6038c2ecf20Sopenharmony_ci * Bit[3:0] ch0 6048c2ecf20Sopenharmony_ci * Bit[7:4] ch1 6058c2ecf20Sopenharmony_ci * Bit[11:8] ch2 6068c2ecf20Sopenharmony_ci * Bit[15:12] ch3 6078c2ecf20Sopenharmony_ci * Bit[19:16] ch4 6088c2ecf20Sopenharmony_ci * Bit[23:20] ch5 6098c2ecf20Sopenharmony_ci * Bit[27:24] ch6 6108c2ecf20Sopenharmony_ci * Bit[31:28] ch7 6118c2ecf20Sopenharmony_ci * Bit[35:32] ch8 6128c2ecf20Sopenharmony_ci * Bit[39:36] ch9 6138c2ecf20Sopenharmony_ci * Bit[43:40] ch10 6148c2ecf20Sopenharmony_ci * Bit[47:44] ch11 6158c2ecf20Sopenharmony_ci * Bit[51:48] ch12 6168c2ecf20Sopenharmony_ci * Bit[55:52] ch13 6178c2ecf20Sopenharmony_ci * Bit[59:56] ch14 6188c2ecf20Sopenharmony_ci * Bit[63:60] ch15 6198c2ecf20Sopenharmony_ci * Bit[67:64] ch16 6208c2ecf20Sopenharmony_ci */ 6218c2ecf20Sopenharmony_ci/* AD_ORIG_WR_PTR[31:0] */ 6228c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR1 0x4030 6238c2ecf20Sopenharmony_ci/* AD_ORIG_WR_PTR[63:32] */ 6248c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR2 0x4034 6258c2ecf20Sopenharmony_ci/* AD_ORIG_WR_PTR[67:64] */ 6268c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR3 0x4038 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci/* AD_ORIG_RD_PTR[31:0] */ 6298c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR1 0x403c 6308c2ecf20Sopenharmony_ci/* AD_ORIG_RD_PTR[63:32] */ 6318c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR2 0x4040 6328c2ecf20Sopenharmony_ci/* AD_ORIG_RD_PTR[67:64] */ 6338c2ecf20Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR3 0x4044 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci#define TW5864_PC_BLOCK_ORIG_RD_NO 0x4048 6368c2ecf20Sopenharmony_ci#define TW5864_PC_BLOCK_ORIG_RD_NO_MASK 0x1f 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci#define TW5864_PCI_AUD 0x404c 6398c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PCI_AUD */ 6408c2ecf20Sopenharmony_ci/* 6418c2ecf20Sopenharmony_ci * The register is applicable to PCI initiator mode only. Used to select PCM(0) 6428c2ecf20Sopenharmony_ci * or ADPCM(1) audio data sent to PC. One bit for each channel 6438c2ecf20Sopenharmony_ci */ 6448c2ecf20Sopenharmony_ci#define TW5864_PCI_DATA_SEL 0xffff 6458c2ecf20Sopenharmony_ci/* 6468c2ecf20Sopenharmony_ci * Audio flow control mode selection bit. 6478c2ecf20Sopenharmony_ci * 0 Flow control disabled. TW5864 continuously sends audio frame to PC 6488c2ecf20Sopenharmony_ci * (initiator mode) 6498c2ecf20Sopenharmony_ci * 1 Flow control enabled 6508c2ecf20Sopenharmony_ci */ 6518c2ecf20Sopenharmony_ci#define TW5864_PCI_FLOW_EN BIT(16) 6528c2ecf20Sopenharmony_ci/* 6538c2ecf20Sopenharmony_ci * When PCI_FLOW_EN is set, PCI need to toggle this bit to send an audio frame 6548c2ecf20Sopenharmony_ci * to PC. One toggle to send one frame. 6558c2ecf20Sopenharmony_ci */ 6568c2ecf20Sopenharmony_ci#define TW5864_PCI_AUD_FRM_EN BIT(17) 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci/* [1:0] CS valid to data valid CLK cycles when writing operation */ 6598c2ecf20Sopenharmony_ci#define TW5864_CS2DAT_CNT 0x8000 6608c2ecf20Sopenharmony_ci/* [2:0] Data valid signal width by system clock cycles */ 6618c2ecf20Sopenharmony_ci#define TW5864_DATA_VLD_WIDTH 0x8004 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci#define TW5864_SYNC 0x8008 6648c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYNC */ 6658c2ecf20Sopenharmony_ci/* 6668c2ecf20Sopenharmony_ci * 0 vlc stream to syncrous port 6678c2ecf20Sopenharmony_ci * 1 vlc stream to ddr buffers 6688c2ecf20Sopenharmony_ci */ 6698c2ecf20Sopenharmony_ci#define TW5864_SYNC_CFG BIT(7) 6708c2ecf20Sopenharmony_ci/* 6718c2ecf20Sopenharmony_ci * 0 SYNC Address sampled on Rising edge 6728c2ecf20Sopenharmony_ci * 1 SYNC Address sampled on Falling edge 6738c2ecf20Sopenharmony_ci */ 6748c2ecf20Sopenharmony_ci#define TW5864_SYNC_ADR_EDGE BIT(0) 6758c2ecf20Sopenharmony_ci#define TW5864_VLC_STR_DELAY_SHIFT 1 6768c2ecf20Sopenharmony_ci/* 6778c2ecf20Sopenharmony_ci * 0 No system delay 6788c2ecf20Sopenharmony_ci * 1 One system clock delay 6798c2ecf20Sopenharmony_ci * 2 Two system clock delay 6808c2ecf20Sopenharmony_ci * 3 Three system clock delay 6818c2ecf20Sopenharmony_ci */ 6828c2ecf20Sopenharmony_ci#define TW5864_VLC_STR_DELAY (3 << 1) 6838c2ecf20Sopenharmony_ci/* 6848c2ecf20Sopenharmony_ci * 0 Rising edge output 6858c2ecf20Sopenharmony_ci * 1 Falling edge output 6868c2ecf20Sopenharmony_ci */ 6878c2ecf20Sopenharmony_ci#define TW5864_VLC_OUT_EDGE BIT(3) 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci/* 6908c2ecf20Sopenharmony_ci * [1:0] 6918c2ecf20Sopenharmony_ci * 2’b00 phase set to 180 degree 6928c2ecf20Sopenharmony_ci * 2’b01 phase set to 270 degree 6938c2ecf20Sopenharmony_ci * 2’b10 phase set to 0 degree 6948c2ecf20Sopenharmony_ci * 2’b11 phase set to 90 degree 6958c2ecf20Sopenharmony_ci */ 6968c2ecf20Sopenharmony_ci#define TW5864_I2C_PHASE_CFG 0x800c 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci/* 6998c2ecf20Sopenharmony_ci * The system / DDR clock (166 MHz) is generated with an on-chip system clock 7008c2ecf20Sopenharmony_ci * PLL (SYSPLL) using input crystal clock of 27 MHz. The system clock PLL 7018c2ecf20Sopenharmony_ci * frequency is controlled with the following equation. 7028c2ecf20Sopenharmony_ci * CLK_OUT = CLK_IN * (M+1) / ((N+1) * P) 7038c2ecf20Sopenharmony_ci * SYSPLL_M M parameter 7048c2ecf20Sopenharmony_ci * SYSPLL_N N parameter 7058c2ecf20Sopenharmony_ci * SYSPLL_P P parameter 7068c2ecf20Sopenharmony_ci */ 7078c2ecf20Sopenharmony_ci/* SYSPLL_M[7:0] */ 7088c2ecf20Sopenharmony_ci#define TW5864_SYSPLL1 0x8018 7098c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYSPLL1 */ 7108c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_M_LOW 0x00ff 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci/* [2:0]: SYSPLL_M[10:8], [7:3]: SYSPLL_N[4:0] */ 7138c2ecf20Sopenharmony_ci#define TW5864_SYSPLL2 0x8019 7148c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYSPLL2 */ 7158c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_M_HI 0x07 7168c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_N_LOW_SHIFT 3 7178c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_N_LOW (0x1f << 3) 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci/* 7208c2ecf20Sopenharmony_ci * [1:0]: SYSPLL_N[6:5], [3:2]: SYSPLL_P, [4]: SYSPLL_IREF, [7:5]: SYSPLL_CP_SEL 7218c2ecf20Sopenharmony_ci */ 7228c2ecf20Sopenharmony_ci#define TW5864_SYSPLL3 0x8020 7238c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYSPLL3 */ 7248c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_N_HI 0x03 7258c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_P_SHIFT 2 7268c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_P (0x03 << 2) 7278c2ecf20Sopenharmony_ci/* 7288c2ecf20Sopenharmony_ci * SYSPLL bias current control 7298c2ecf20Sopenharmony_ci * 0 Lower current (default) 7308c2ecf20Sopenharmony_ci * 1 30% higher current 7318c2ecf20Sopenharmony_ci */ 7328c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_IREF BIT(4) 7338c2ecf20Sopenharmony_ci/* 7348c2ecf20Sopenharmony_ci * SYSPLL charge pump current selection 7358c2ecf20Sopenharmony_ci * 0 1,5 uA 7368c2ecf20Sopenharmony_ci * 1 4 uA 7378c2ecf20Sopenharmony_ci * 2 9 uA 7388c2ecf20Sopenharmony_ci * 3 19 uA 7398c2ecf20Sopenharmony_ci * 4 39 uA 7408c2ecf20Sopenharmony_ci * 5 79 uA 7418c2ecf20Sopenharmony_ci * 6 159 uA 7428c2ecf20Sopenharmony_ci * 7 319 uA 7438c2ecf20Sopenharmony_ci */ 7448c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_CP_SEL_SHIFT 5 7458c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_CP_SEL (0x07 << 5) 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci/* 7488c2ecf20Sopenharmony_ci * [1:0]: SYSPLL_VCO, [3:2]: SYSPLL_LP_X8, [5:4]: SYSPLL_ICP_SEL, 7498c2ecf20Sopenharmony_ci * [6]: SYSPLL_LPF_5PF, [7]: SYSPLL_ED_SEL 7508c2ecf20Sopenharmony_ci */ 7518c2ecf20Sopenharmony_ci#define TW5864_SYSPLL4 0x8021 7528c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYSPLL4 */ 7538c2ecf20Sopenharmony_ci/* 7548c2ecf20Sopenharmony_ci * SYSPLL_VCO VCO Range selection 7558c2ecf20Sopenharmony_ci * 00 5 ~ 75 MHz 7568c2ecf20Sopenharmony_ci * 01 50 ~ 140 MHz 7578c2ecf20Sopenharmony_ci * 10 110 ~ 320 MHz 7588c2ecf20Sopenharmony_ci * 11 270 ~ 700 MHz 7598c2ecf20Sopenharmony_ci */ 7608c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_VCO 0x03 7618c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_LP_X8_SHIFT 2 7628c2ecf20Sopenharmony_ci/* 7638c2ecf20Sopenharmony_ci * Loop resister 7648c2ecf20Sopenharmony_ci * 0 38.5K ohms 7658c2ecf20Sopenharmony_ci * 1 6.6K ohms (default) 7668c2ecf20Sopenharmony_ci * 2 2.2K ohms 7678c2ecf20Sopenharmony_ci * 3 1.1K ohms 7688c2ecf20Sopenharmony_ci */ 7698c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_LP_X8 (0x03 << 2) 7708c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_ICP_SEL_SHIFT 4 7718c2ecf20Sopenharmony_ci/* 7728c2ecf20Sopenharmony_ci * PLL charge pump fine tune 7738c2ecf20Sopenharmony_ci * 00 x1 (default) 7748c2ecf20Sopenharmony_ci * 01 x1/2 7758c2ecf20Sopenharmony_ci * 10 x1/7 7768c2ecf20Sopenharmony_ci * 11 x1/8 7778c2ecf20Sopenharmony_ci */ 7788c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_ICP_SEL (0x03 << 4) 7798c2ecf20Sopenharmony_ci/* 7808c2ecf20Sopenharmony_ci * PLL low pass filter phase margin adjustment 7818c2ecf20Sopenharmony_ci * 0 no 5pF (default) 7828c2ecf20Sopenharmony_ci * 1 5pF added 7838c2ecf20Sopenharmony_ci */ 7848c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_LPF_5PF BIT(6) 7858c2ecf20Sopenharmony_ci/* 7868c2ecf20Sopenharmony_ci * PFD select edge for detection 7878c2ecf20Sopenharmony_ci * 0 Falling edge (default) 7888c2ecf20Sopenharmony_ci * 1 Rising edge 7898c2ecf20Sopenharmony_ci */ 7908c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_ED_SEL BIT(7) 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci/* [0]: SYSPLL_RST, [4]: SYSPLL_PD */ 7938c2ecf20Sopenharmony_ci#define TW5864_SYSPLL5 0x8024 7948c2ecf20Sopenharmony_ci/* Define controls in register TW5864_SYSPLL5 */ 7958c2ecf20Sopenharmony_ci/* Reset SYSPLL */ 7968c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_RST BIT(0) 7978c2ecf20Sopenharmony_ci/* Power down SYSPLL */ 7988c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_PD BIT(4) 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci#define TW5864_PLL_CFG 0x801c 8018c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PLL_CFG */ 8028c2ecf20Sopenharmony_ci/* 8038c2ecf20Sopenharmony_ci * Issue Soft Reset from Async Host Interface / PCI Interface clock domain. 8048c2ecf20Sopenharmony_ci * Become valid after sync to the xtal clock domain. This bit is set only if 8058c2ecf20Sopenharmony_ci * LOAD register bit is also set to 1. 8068c2ecf20Sopenharmony_ci */ 8078c2ecf20Sopenharmony_ci#define TW5864_SRST BIT(0) 8088c2ecf20Sopenharmony_ci/* 8098c2ecf20Sopenharmony_ci * Issue SYSPLL (166 MHz) configuration latch from Async host interface / PCI 8108c2ecf20Sopenharmony_ci * Interface clock domain. The configuration setting becomes effective only if 8118c2ecf20Sopenharmony_ci * LOAD register bit is also set to 1. 8128c2ecf20Sopenharmony_ci */ 8138c2ecf20Sopenharmony_ci#define TW5864_SYSPLL_CFG BIT(2) 8148c2ecf20Sopenharmony_ci/* 8158c2ecf20Sopenharmony_ci * Issue SPLL (108 MHz) configuration load from Async host interface / PCI 8168c2ecf20Sopenharmony_ci * Interface clock domain. The configuration setting becomes effective only if 8178c2ecf20Sopenharmony_ci * the LOAD register bit is also set to 1. 8188c2ecf20Sopenharmony_ci */ 8198c2ecf20Sopenharmony_ci#define TW5864_SPLL_CFG BIT(4) 8208c2ecf20Sopenharmony_ci/* 8218c2ecf20Sopenharmony_ci * Set this bit to latch the SRST, SYSPLL_CFG, SPLL_CFG setting into the xtal 8228c2ecf20Sopenharmony_ci * clock domain to restart the PLL. This bit is self cleared. 8238c2ecf20Sopenharmony_ci */ 8248c2ecf20Sopenharmony_ci#define TW5864_LOAD BIT(3) 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci/* SPLL_IREF, SPLL_LPX4, SPLL_CPX4, SPLL_PD, SPLL_DBG */ 8278c2ecf20Sopenharmony_ci#define TW5864_SPLL 0x8028 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_ci/* 0x8800 ~ 0x88fc -- Interrupt Register Map */ 8308c2ecf20Sopenharmony_ci/* 8318c2ecf20Sopenharmony_ci * Trigger mode of interrupt source 0 ~ 15 8328c2ecf20Sopenharmony_ci * 1 Edge trigger mode 8338c2ecf20Sopenharmony_ci * 0 Level trigger mode 8348c2ecf20Sopenharmony_ci */ 8358c2ecf20Sopenharmony_ci#define TW5864_TRIGGER_MODE_L 0x8800 8368c2ecf20Sopenharmony_ci/* Trigger mode of interrupt source 16 ~ 31 */ 8378c2ecf20Sopenharmony_ci#define TW5864_TRIGGER_MODE_H 0x8804 8388c2ecf20Sopenharmony_ci/* Enable of interrupt source 0 ~ 15 */ 8398c2ecf20Sopenharmony_ci#define TW5864_INTR_ENABLE_L 0x8808 8408c2ecf20Sopenharmony_ci/* Enable of interrupt source 16 ~ 31 */ 8418c2ecf20Sopenharmony_ci#define TW5864_INTR_ENABLE_H 0x880c 8428c2ecf20Sopenharmony_ci/* Clear interrupt command of interrupt source 0 ~ 15 */ 8438c2ecf20Sopenharmony_ci#define TW5864_INTR_CLR_L 0x8810 8448c2ecf20Sopenharmony_ci/* Clear interrupt command of interrupt source 16 ~ 31 */ 8458c2ecf20Sopenharmony_ci#define TW5864_INTR_CLR_H 0x8814 8468c2ecf20Sopenharmony_ci/* 8478c2ecf20Sopenharmony_ci * Assertion of interrupt source 0 ~ 15 8488c2ecf20Sopenharmony_ci * 1 High level or pos-edge is assertion 8498c2ecf20Sopenharmony_ci * 0 Low level or neg-edge is assertion 8508c2ecf20Sopenharmony_ci */ 8518c2ecf20Sopenharmony_ci#define TW5864_INTR_ASSERT_L 0x8818 8528c2ecf20Sopenharmony_ci/* Assertion of interrupt source 16 ~ 31 */ 8538c2ecf20Sopenharmony_ci#define TW5864_INTR_ASSERT_H 0x881c 8548c2ecf20Sopenharmony_ci/* 8558c2ecf20Sopenharmony_ci * Output level of interrupt 8568c2ecf20Sopenharmony_ci * 1 Interrupt output is high assertion 8578c2ecf20Sopenharmony_ci * 0 Interrupt output is low assertion 8588c2ecf20Sopenharmony_ci */ 8598c2ecf20Sopenharmony_ci#define TW5864_INTR_OUT_LEVEL 0x8820 8608c2ecf20Sopenharmony_ci/* 8618c2ecf20Sopenharmony_ci * Status of interrupt source 0 ~ 15 8628c2ecf20Sopenharmony_ci * Bit[0]: VLC 4k RAM interrupt 8638c2ecf20Sopenharmony_ci * Bit[1]: BURST DDR RAM interrupt 8648c2ecf20Sopenharmony_ci * Bit[2]: MV DSP interrupt 8658c2ecf20Sopenharmony_ci * Bit[3]: video lost interrupt 8668c2ecf20Sopenharmony_ci * Bit[4]: gpio 0 interrupt 8678c2ecf20Sopenharmony_ci * Bit[5]: gpio 1 interrupt 8688c2ecf20Sopenharmony_ci * Bit[6]: gpio 2 interrupt 8698c2ecf20Sopenharmony_ci * Bit[7]: gpio 3 interrupt 8708c2ecf20Sopenharmony_ci * Bit[8]: gpio 4 interrupt 8718c2ecf20Sopenharmony_ci * Bit[9]: gpio 5 interrupt 8728c2ecf20Sopenharmony_ci * Bit[10]: gpio 6 interrupt 8738c2ecf20Sopenharmony_ci * Bit[11]: gpio 7 interrupt 8748c2ecf20Sopenharmony_ci * Bit[12]: JPEG interrupt 8758c2ecf20Sopenharmony_ci * Bit[13:15]: Reserved 8768c2ecf20Sopenharmony_ci */ 8778c2ecf20Sopenharmony_ci#define TW5864_INTR_STATUS_L 0x8838 8788c2ecf20Sopenharmony_ci/* 8798c2ecf20Sopenharmony_ci * Status of interrupt source 16 ~ 31 8808c2ecf20Sopenharmony_ci * Bit[0]: Reserved 8818c2ecf20Sopenharmony_ci * Bit[1]: VLC done interrupt 8828c2ecf20Sopenharmony_ci * Bit[2]: Reserved 8838c2ecf20Sopenharmony_ci * Bit[3]: AD Vsync interrupt 8848c2ecf20Sopenharmony_ci * Bit[4]: Preview eof interrupt 8858c2ecf20Sopenharmony_ci * Bit[5]: Preview overflow interrupt 8868c2ecf20Sopenharmony_ci * Bit[6]: Timer interrupt 8878c2ecf20Sopenharmony_ci * Bit[7]: Reserved 8888c2ecf20Sopenharmony_ci * Bit[8]: Audio eof interrupt 8898c2ecf20Sopenharmony_ci * Bit[9]: I2C done interrupt 8908c2ecf20Sopenharmony_ci * Bit[10]: AD interrupt 8918c2ecf20Sopenharmony_ci * Bit[11:15]: Reserved 8928c2ecf20Sopenharmony_ci */ 8938c2ecf20Sopenharmony_ci#define TW5864_INTR_STATUS_H 0x883c 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_ci/* Defines of interrupt bits, united for both low and high word registers */ 8968c2ecf20Sopenharmony_ci#define TW5864_INTR_VLC_RAM BIT(0) 8978c2ecf20Sopenharmony_ci#define TW5864_INTR_BURST BIT(1) 8988c2ecf20Sopenharmony_ci#define TW5864_INTR_MV_DSP BIT(2) 8998c2ecf20Sopenharmony_ci#define TW5864_INTR_VIN_LOST BIT(3) 9008c2ecf20Sopenharmony_ci/* n belongs to [0; 7] */ 9018c2ecf20Sopenharmony_ci#define TW5864_INTR_GPIO(n) (1 << (4 + n)) 9028c2ecf20Sopenharmony_ci#define TW5864_INTR_JPEG BIT(12) 9038c2ecf20Sopenharmony_ci#define TW5864_INTR_VLC_DONE BIT(17) 9048c2ecf20Sopenharmony_ci#define TW5864_INTR_AD_VSYNC BIT(19) 9058c2ecf20Sopenharmony_ci#define TW5864_INTR_PV_EOF BIT(20) 9068c2ecf20Sopenharmony_ci#define TW5864_INTR_PV_OVERFLOW BIT(21) 9078c2ecf20Sopenharmony_ci#define TW5864_INTR_TIMER BIT(22) 9088c2ecf20Sopenharmony_ci#define TW5864_INTR_AUD_EOF BIT(24) 9098c2ecf20Sopenharmony_ci#define TW5864_INTR_I2C_DONE BIT(25) 9108c2ecf20Sopenharmony_ci#define TW5864_INTR_AD BIT(26) 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* 0x9000 ~ 0x920c -- Video Capture (VIF) Register Map */ 9138c2ecf20Sopenharmony_ci/* 9148c2ecf20Sopenharmony_ci * H264EN_CH_STATUS[n] Status of Vsync synchronized H264EN_CH_EN (Read Only) 9158c2ecf20Sopenharmony_ci * 1 Channel Enabled 9168c2ecf20Sopenharmony_ci * 0 Channel Disabled 9178c2ecf20Sopenharmony_ci */ 9188c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_STATUS 0x9000 9198c2ecf20Sopenharmony_ci/* 9208c2ecf20Sopenharmony_ci * [15:0] H264EN_CH_EN[n] H264 Encoding Path Enable for channel 9218c2ecf20Sopenharmony_ci * 1 Channel Enabled 9228c2ecf20Sopenharmony_ci * 0 Channel Disabled 9238c2ecf20Sopenharmony_ci */ 9248c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_EN 0x9004 9258c2ecf20Sopenharmony_ci/* 9268c2ecf20Sopenharmony_ci * H264EN_CH_DNS[n] H264 Encoding Path Downscale Video Decoder Input for 9278c2ecf20Sopenharmony_ci * channel n 9288c2ecf20Sopenharmony_ci * 1 Downscale Y to 1/2 9298c2ecf20Sopenharmony_ci * 0 Does not downscale 9308c2ecf20Sopenharmony_ci */ 9318c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_DNS 0x9008 9328c2ecf20Sopenharmony_ci/* 9338c2ecf20Sopenharmony_ci * H264EN_CH_PROG[n] H264 Encoding Path channel n is progressive 9348c2ecf20Sopenharmony_ci * 1 Progressive (Not valid for TW5864) 9358c2ecf20Sopenharmony_ci * 0 Interlaced (TW5864 default) 9368c2ecf20Sopenharmony_ci */ 9378c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_PROG 0x900c 9388c2ecf20Sopenharmony_ci/* 9398c2ecf20Sopenharmony_ci * [3:0] H264EN_BUS_MAX_CH[n] 9408c2ecf20Sopenharmony_ci * H264 Encoding Path maximum number of channel on BUS n 9418c2ecf20Sopenharmony_ci * 0 Max 4 channels 9428c2ecf20Sopenharmony_ci * 1 Max 2 channels 9438c2ecf20Sopenharmony_ci */ 9448c2ecf20Sopenharmony_ci#define TW5864_H264EN_BUS_MAX_CH 0x9010 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci/* 9478c2ecf20Sopenharmony_ci * H264EN_RATE_MAX_LINE_n H264 Encoding path Rate Mapping Maximum Line Number 9488c2ecf20Sopenharmony_ci * on Bus n 9498c2ecf20Sopenharmony_ci */ 9508c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_EVEN 0x1f 9518c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_ODD_SHIFT 5 9528c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_ODD (0x1f << 5) 9538c2ecf20Sopenharmony_ci/* 9548c2ecf20Sopenharmony_ci * [4:0] H264EN_RATE_MAX_LINE_0 9558c2ecf20Sopenharmony_ci * [9:5] H264EN_RATE_MAX_LINE_1 9568c2ecf20Sopenharmony_ci */ 9578c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_REG1 0x9014 9588c2ecf20Sopenharmony_ci/* 9598c2ecf20Sopenharmony_ci * [4:0] H264EN_RATE_MAX_LINE_2 9608c2ecf20Sopenharmony_ci * [9:5] H264EN_RATE_MAX_LINE_3 9618c2ecf20Sopenharmony_ci */ 9628c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_REG2 0x9018 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci/* 9658c2ecf20Sopenharmony_ci * H264EN_CHn_FMT H264 Encoding Path Format configuration of Channel n 9668c2ecf20Sopenharmony_ci * 00 D1 (For D1 and hD1 frame) 9678c2ecf20Sopenharmony_ci * 01 (Reserved) 9688c2ecf20Sopenharmony_ci * 10 (Reserved) 9698c2ecf20Sopenharmony_ci * 11 D1 with 1/2 size in X (for CIF frame) 9708c2ecf20Sopenharmony_ci * Note: To be used with 0x9008 register to configure the frame size 9718c2ecf20Sopenharmony_ci */ 9728c2ecf20Sopenharmony_ci/* 9738c2ecf20Sopenharmony_ci * [1:0]: H264EN_CH0_FMT, 9748c2ecf20Sopenharmony_ci * ..., [15:14]: H264EN_CH7_FMT 9758c2ecf20Sopenharmony_ci */ 9768c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_FMT_REG1 0x9020 9778c2ecf20Sopenharmony_ci/* 9788c2ecf20Sopenharmony_ci * [1:0]: H264EN_CH8_FMT (?), 9798c2ecf20Sopenharmony_ci * ..., [15:14]: H264EN_CH15_FMT (?) 9808c2ecf20Sopenharmony_ci */ 9818c2ecf20Sopenharmony_ci#define TW5864_H264EN_CH_FMT_REG2 0x9024 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci/* 9848c2ecf20Sopenharmony_ci * H264EN_RATE_CNTL_BUSm_CHn H264 Encoding Path BUS m Rate Control for Channel n 9858c2ecf20Sopenharmony_ci */ 9868c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_CNTL_LO_WORD(bus, channel) \ 9878c2ecf20Sopenharmony_ci (0x9100 + bus * 0x20 + channel * 0x08) 9888c2ecf20Sopenharmony_ci#define TW5864_H264EN_RATE_CNTL_HI_WORD(bus, channel) \ 9898c2ecf20Sopenharmony_ci (0x9104 + bus * 0x20 + channel * 0x08) 9908c2ecf20Sopenharmony_ci 9918c2ecf20Sopenharmony_ci/* 9928c2ecf20Sopenharmony_ci * H264EN_BUSm_MAP_CHn The 16-to-1 MUX configuration register for each encoding 9938c2ecf20Sopenharmony_ci * channel (total of 16 channels). Four bits for each channel. 9948c2ecf20Sopenharmony_ci */ 9958c2ecf20Sopenharmony_ci#define TW5864_H264EN_BUS0_MAP 0x9200 9968c2ecf20Sopenharmony_ci#define TW5864_H264EN_BUS1_MAP 0x9204 9978c2ecf20Sopenharmony_ci#define TW5864_H264EN_BUS2_MAP 0x9208 9988c2ecf20Sopenharmony_ci#define TW5864_H264EN_BUS3_MAP 0x920c 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_ci/* This register is not defined in datasheet, but used in reference driver */ 10018c2ecf20Sopenharmony_ci#define TW5864_UNDECLARED_ERROR_FLAGS_0x9218 0x9218 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_ci#define TW5864_GPIO1 0x9800 10048c2ecf20Sopenharmony_ci#define TW5864_GPIO2 0x9804 10058c2ecf20Sopenharmony_ci/* Define controls in registers TW5864_GPIO1, TW5864_GPIO2 */ 10068c2ecf20Sopenharmony_ci/* GPIO DATA of Group n */ 10078c2ecf20Sopenharmony_ci#define TW5864_GPIO_DATA 0x00ff 10088c2ecf20Sopenharmony_ci#define TW5864_GPIO_OEN_SHIFT 8 10098c2ecf20Sopenharmony_ci/* GPIO Output Enable of Group n */ 10108c2ecf20Sopenharmony_ci#define TW5864_GPIO_OEN (0xff << 8) 10118c2ecf20Sopenharmony_ci 10128c2ecf20Sopenharmony_ci/* 0xa000 ~ 0xa8ff – DDR Controller Register Map */ 10138c2ecf20Sopenharmony_ci/* DDR Controller A */ 10148c2ecf20Sopenharmony_ci/* 10158c2ecf20Sopenharmony_ci * [2:0] Data valid counter after read command to DDR. This is the delay value 10168c2ecf20Sopenharmony_ci * to show how many cycles the data will be back from DDR after we issue a read 10178c2ecf20Sopenharmony_ci * command. 10188c2ecf20Sopenharmony_ci */ 10198c2ecf20Sopenharmony_ci#define TW5864_RD_ACK_VLD_MUX 0xa000 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_ci#define TW5864_DDR_PERIODS 0xa004 10228c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DDR_PERIODS */ 10238c2ecf20Sopenharmony_ci/* 10248c2ecf20Sopenharmony_ci * Tras value, the minimum cycle of active to precharge command period, 10258c2ecf20Sopenharmony_ci * default is 7 10268c2ecf20Sopenharmony_ci */ 10278c2ecf20Sopenharmony_ci#define TW5864_TRAS_CNT_MAX 0x000f 10288c2ecf20Sopenharmony_ci/* 10298c2ecf20Sopenharmony_ci * Trfc value, the minimum cycle of refresh to active or refresh command period, 10308c2ecf20Sopenharmony_ci * default is 4"hf 10318c2ecf20Sopenharmony_ci */ 10328c2ecf20Sopenharmony_ci#define TW5864_RFC_CNT_MAX_SHIFT 8 10338c2ecf20Sopenharmony_ci#define TW5864_RFC_CNT_MAX (0x0f << 8) 10348c2ecf20Sopenharmony_ci/* 10358c2ecf20Sopenharmony_ci * Trcd value, the minimum cycle of active to internal read/write command 10368c2ecf20Sopenharmony_ci * period, default is 4"h2 10378c2ecf20Sopenharmony_ci */ 10388c2ecf20Sopenharmony_ci#define TW5864_TCD_CNT_MAX_SHIFT 4 10398c2ecf20Sopenharmony_ci#define TW5864_TCD_CNT_MAX (0x0f << 4) 10408c2ecf20Sopenharmony_ci/* Twr value, write recovery time, default is 4"h3 */ 10418c2ecf20Sopenharmony_ci#define TW5864_TWR_CNT_MAX_SHIFT 12 10428c2ecf20Sopenharmony_ci#define TW5864_TWR_CNT_MAX (0x0f << 12) 10438c2ecf20Sopenharmony_ci 10448c2ecf20Sopenharmony_ci/* 10458c2ecf20Sopenharmony_ci * [2:0] CAS latency, the delay cycle between internal read command and the 10468c2ecf20Sopenharmony_ci * availability of the first bit of output data, default is 3 10478c2ecf20Sopenharmony_ci */ 10488c2ecf20Sopenharmony_ci#define TW5864_CAS_LATENCY 0xa008 10498c2ecf20Sopenharmony_ci/* 10508c2ecf20Sopenharmony_ci * [15:0] Maximum average periodic refresh, the value is based on the current 10518c2ecf20Sopenharmony_ci * frequency to match 7.8mcs 10528c2ecf20Sopenharmony_ci */ 10538c2ecf20Sopenharmony_ci#define TW5864_DDR_REF_CNTR_MAX 0xa00c 10548c2ecf20Sopenharmony_ci/* 10558c2ecf20Sopenharmony_ci * DDR_ON_CHIP_MAP [1:0] 10568c2ecf20Sopenharmony_ci * 0 256M DDR on board 10578c2ecf20Sopenharmony_ci * 1 512M DDR on board 10588c2ecf20Sopenharmony_ci * 2 1G DDR on board 10598c2ecf20Sopenharmony_ci * DDR_ON_CHIP_MAP [2] 10608c2ecf20Sopenharmony_ci * 0 Only one DDR chip 10618c2ecf20Sopenharmony_ci * 1 Two DDR chips 10628c2ecf20Sopenharmony_ci */ 10638c2ecf20Sopenharmony_ci#define TW5864_DDR_ON_CHIP_MAP 0xa01c 10648c2ecf20Sopenharmony_ci#define TW5864_DDR_SELFTEST_MODE 0xa020 10658c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DDR_SELFTEST_MODE */ 10668c2ecf20Sopenharmony_ci/* 10678c2ecf20Sopenharmony_ci * 0 Common read/write mode 10688c2ecf20Sopenharmony_ci * 1 DDR self-test mode 10698c2ecf20Sopenharmony_ci */ 10708c2ecf20Sopenharmony_ci#define TW5864_MASTER_MODE BIT(0) 10718c2ecf20Sopenharmony_ci/* 10728c2ecf20Sopenharmony_ci * 0 DDR self-test single read/write 10738c2ecf20Sopenharmony_ci * 1 DDR self-test burst read/write 10748c2ecf20Sopenharmony_ci */ 10758c2ecf20Sopenharmony_ci#define TW5864_SINGLE_PROC BIT(1) 10768c2ecf20Sopenharmony_ci/* 10778c2ecf20Sopenharmony_ci * 0 DDR self-test write command 10788c2ecf20Sopenharmony_ci * 1 DDR self-test read command 10798c2ecf20Sopenharmony_ci */ 10808c2ecf20Sopenharmony_ci#define TW5864_WRITE_FLAG BIT(2) 10818c2ecf20Sopenharmony_ci#define TW5864_DATA_MODE_SHIFT 4 10828c2ecf20Sopenharmony_ci/* 10838c2ecf20Sopenharmony_ci * 0 write 32'haaaa5555 to DDR 10848c2ecf20Sopenharmony_ci * 1 write 32'hffffffff to DDR 10858c2ecf20Sopenharmony_ci * 2 write 32'hha5a55a5a to DDR 10868c2ecf20Sopenharmony_ci * 3 write increasing data to DDR 10878c2ecf20Sopenharmony_ci */ 10888c2ecf20Sopenharmony_ci#define TW5864_DATA_MODE (0x3 << 4) 10898c2ecf20Sopenharmony_ci 10908c2ecf20Sopenharmony_ci/* [7:0] The maximum data of one burst in DDR self-test mode */ 10918c2ecf20Sopenharmony_ci#define TW5864_BURST_CNTR_MAX 0xa024 10928c2ecf20Sopenharmony_ci/* [15:0] The maximum burst counter (bit 15~0) in DDR self-test mode */ 10938c2ecf20Sopenharmony_ci#define TW5864_DDR_PROC_CNTR_MAX_L 0xa028 10948c2ecf20Sopenharmony_ci/* The maximum burst counter (bit 31~16) in DDR self-test mode */ 10958c2ecf20Sopenharmony_ci#define TW5864_DDR_PROC_CNTR_MAX_H 0xa02c 10968c2ecf20Sopenharmony_ci/* [0]: Start one DDR self-test */ 10978c2ecf20Sopenharmony_ci#define TW5864_DDR_SELF_TEST_CMD 0xa030 10988c2ecf20Sopenharmony_ci/* The maximum error counter (bit 15 ~ 0) in DDR self-test */ 10998c2ecf20Sopenharmony_ci#define TW5864_ERR_CNTR_L 0xa034 11008c2ecf20Sopenharmony_ci 11018c2ecf20Sopenharmony_ci#define TW5864_ERR_CNTR_H_AND_FLAG 0xa038 11028c2ecf20Sopenharmony_ci/* Define controls in register TW5864_ERR_CNTR_H_AND_FLAG */ 11038c2ecf20Sopenharmony_ci/* The maximum error counter (bit 30 ~ 16) in DDR self-test */ 11048c2ecf20Sopenharmony_ci#define TW5864_ERR_CNTR_H_MASK 0x3fff 11058c2ecf20Sopenharmony_ci/* DDR self-test end flag */ 11068c2ecf20Sopenharmony_ci#define TW5864_END_FLAG 0x8000 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_ci/* 11098c2ecf20Sopenharmony_ci * DDR Controller B: same as 0xa000 ~ 0xa038, but add TW5864_DDR_B_OFFSET to all 11108c2ecf20Sopenharmony_ci * addresses 11118c2ecf20Sopenharmony_ci */ 11128c2ecf20Sopenharmony_ci#define TW5864_DDR_B_OFFSET 0x0800 11138c2ecf20Sopenharmony_ci 11148c2ecf20Sopenharmony_ci/* 0xb004 ~ 0xb018 – HW version/ARB12 Register Map */ 11158c2ecf20Sopenharmony_ci/* [15:0] Default is C013 */ 11168c2ecf20Sopenharmony_ci#define TW5864_HW_VERSION 0xb004 11178c2ecf20Sopenharmony_ci 11188c2ecf20Sopenharmony_ci#define TW5864_REQS_ENABLE 0xb010 11198c2ecf20Sopenharmony_ci/* Define controls in register TW5864_REQS_ENABLE */ 11208c2ecf20Sopenharmony_ci/* Audio data in to DDR enable (default 1) */ 11218c2ecf20Sopenharmony_ci#define TW5864_AUD_DATA_IN_ENB BIT(0) 11228c2ecf20Sopenharmony_ci/* Audio encode request to DDR enable (default 1) */ 11238c2ecf20Sopenharmony_ci#define TW5864_AUD_ENC_REQ_ENB BIT(1) 11248c2ecf20Sopenharmony_ci/* Audio decode request0 to DDR enable (default 1) */ 11258c2ecf20Sopenharmony_ci#define TW5864_AUD_DEC_REQ0_ENB BIT(2) 11268c2ecf20Sopenharmony_ci/* Audio decode request1 to DDR enable (default 1) */ 11278c2ecf20Sopenharmony_ci#define TW5864_AUD_DEC_REQ1_ENB BIT(3) 11288c2ecf20Sopenharmony_ci/* VLC stream request to DDR enable (default 1) */ 11298c2ecf20Sopenharmony_ci#define TW5864_VLC_STRM_REQ_ENB BIT(4) 11308c2ecf20Sopenharmony_ci/* H264 MV request to DDR enable (default 1) */ 11318c2ecf20Sopenharmony_ci#define TW5864_DVM_MV_REQ_ENB BIT(5) 11328c2ecf20Sopenharmony_ci/* mux_core MVD request to DDR enable (default 1) */ 11338c2ecf20Sopenharmony_ci#define TW5864_MVD_REQ_ENB BIT(6) 11348c2ecf20Sopenharmony_ci/* mux_core MVD temp data request to DDR enable (default 1) */ 11358c2ecf20Sopenharmony_ci#define TW5864_MVD_TMP_REQ_ENB BIT(7) 11368c2ecf20Sopenharmony_ci/* JPEG request to DDR enable (default 1) */ 11378c2ecf20Sopenharmony_ci#define TW5864_JPEG_REQ_ENB BIT(8) 11388c2ecf20Sopenharmony_ci/* mv_flag request to DDR enable (default 1) */ 11398c2ecf20Sopenharmony_ci#define TW5864_MV_FLAG_REQ_ENB BIT(9) 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_ci#define TW5864_ARB12 0xb018 11428c2ecf20Sopenharmony_ci/* Define controls in register TW5864_ARB12 */ 11438c2ecf20Sopenharmony_ci/* ARB12 Enable (default 1) */ 11448c2ecf20Sopenharmony_ci#define TW5864_ARB12_ENB BIT(15) 11458c2ecf20Sopenharmony_ci/* ARB12 maximum value of time out counter (default 15"h1FF) */ 11468c2ecf20Sopenharmony_ci#define TW5864_ARB12_TIME_OUT_CNT 0x7fff 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci/* 0xb800 ~ 0xb80c -- Indirect Access Register Map */ 11498c2ecf20Sopenharmony_ci/* 11508c2ecf20Sopenharmony_ci * Spec says: 11518c2ecf20Sopenharmony_ci * In order to access the indirect register space, the following procedure is 11528c2ecf20Sopenharmony_ci * followed. 11538c2ecf20Sopenharmony_ci * But reference driver implementation, and current driver, too, does it 11548c2ecf20Sopenharmony_ci * differently. 11558c2ecf20Sopenharmony_ci * 11568c2ecf20Sopenharmony_ci * Write Registers: 11578c2ecf20Sopenharmony_ci * (1) Write IND_DATA at 0xb804 ~ 0xb807 11588c2ecf20Sopenharmony_ci * (2) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 11598c2ecf20Sopenharmony_ci * (3) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "1", ENABLE to "1" 11608c2ecf20Sopenharmony_ci * Read Registers: 11618c2ecf20Sopenharmony_ci * (1) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 11628c2ecf20Sopenharmony_ci * (2) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "0", ENABLE to "1" 11638c2ecf20Sopenharmony_ci * (3) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 11648c2ecf20Sopenharmony_ci * (4) Read IND_DATA from 0xb804 ~ 0xb807 11658c2ecf20Sopenharmony_ci */ 11668c2ecf20Sopenharmony_ci#define TW5864_IND_CTL 0xb800 11678c2ecf20Sopenharmony_ci/* Define controls in register TW5864_IND_CTL */ 11688c2ecf20Sopenharmony_ci/* Address used to access indirect register space */ 11698c2ecf20Sopenharmony_ci#define TW5864_IND_ADDR 0x0000ffff 11708c2ecf20Sopenharmony_ci/* Wait until this bit is "0" before using indirect access */ 11718c2ecf20Sopenharmony_ci#define TW5864_BUSY BIT(31) 11728c2ecf20Sopenharmony_ci/* Activate the indirect access. This bit is self cleared */ 11738c2ecf20Sopenharmony_ci#define TW5864_ENABLE BIT(25) 11748c2ecf20Sopenharmony_ci/* Read/Write command */ 11758c2ecf20Sopenharmony_ci#define TW5864_RW BIT(24) 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci/* [31:0] Data used to read/write indirect register space */ 11788c2ecf20Sopenharmony_ci#define TW5864_IND_DATA 0xb804 11798c2ecf20Sopenharmony_ci 11808c2ecf20Sopenharmony_ci/* 0xc000 ~ 0xc7fc -- Preview Register Map */ 11818c2ecf20Sopenharmony_ci/* Mostly skipped this section. */ 11828c2ecf20Sopenharmony_ci/* 11838c2ecf20Sopenharmony_ci * [15:0] Status of Vsync Synchronized PCI_PV_CH_EN (Read Only) 11848c2ecf20Sopenharmony_ci * 1 Channel Enabled 11858c2ecf20Sopenharmony_ci * 0 Channel Disabled 11868c2ecf20Sopenharmony_ci */ 11878c2ecf20Sopenharmony_ci#define TW5864_PCI_PV_CH_STATUS 0xc000 11888c2ecf20Sopenharmony_ci/* 11898c2ecf20Sopenharmony_ci * [15:0] PCI Preview Path Enable for channel n 11908c2ecf20Sopenharmony_ci * 1 Channel Enable 11918c2ecf20Sopenharmony_ci * 0 Channel Disable 11928c2ecf20Sopenharmony_ci */ 11938c2ecf20Sopenharmony_ci#define TW5864_PCI_PV_CH_EN 0xc004 11948c2ecf20Sopenharmony_ci 11958c2ecf20Sopenharmony_ci/* 0xc800 ~ 0xc804 -- JPEG Capture Register Map */ 11968c2ecf20Sopenharmony_ci/* Skipped. */ 11978c2ecf20Sopenharmony_ci/* 0xd000 ~ 0xd0fc -- JPEG Control Register Map */ 11988c2ecf20Sopenharmony_ci/* Skipped. */ 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_ci/* 0xe000 ~ 0xfc04 – Motion Vector Register Map */ 12018c2ecf20Sopenharmony_ci 12028c2ecf20Sopenharmony_ci/* ME Motion Vector data (Four Byte Each) 0xe000 ~ 0xe7fc */ 12038c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC_START 0xe000 12048c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC_MAX_OFFSET 0x1ff 12058c2ecf20Sopenharmony_ci#define TW5864_ME_MV_VEC(offset) (TW5864_ME_MV_VEC_START + 4 * offset) 12068c2ecf20Sopenharmony_ci 12078c2ecf20Sopenharmony_ci#define TW5864_MV 0xfc00 12088c2ecf20Sopenharmony_ci/* Define controls in register TW5864_MV */ 12098c2ecf20Sopenharmony_ci/* mv bank0 full status , write "1" to clear */ 12108c2ecf20Sopenharmony_ci#define TW5864_MV_BK0_FULL BIT(0) 12118c2ecf20Sopenharmony_ci/* mv bank1 full status , write "1" to clear */ 12128c2ecf20Sopenharmony_ci#define TW5864_MV_BK1_FULL BIT(1) 12138c2ecf20Sopenharmony_ci/* slice end status; write "1" to clear */ 12148c2ecf20Sopenharmony_ci#define TW5864_MV_EOF BIT(2) 12158c2ecf20Sopenharmony_ci/* mv encode interrupt status; write "1" to clear */ 12168c2ecf20Sopenharmony_ci#define TW5864_MV_DSP_INTR BIT(3) 12178c2ecf20Sopenharmony_ci/* mv write memory overflow, write "1" to clear */ 12188c2ecf20Sopenharmony_ci#define TW5864_DSP_WR_OF BIT(4) 12198c2ecf20Sopenharmony_ci#define TW5864_MV_LEN_SHIFT 5 12208c2ecf20Sopenharmony_ci/* mv stream length */ 12218c2ecf20Sopenharmony_ci#define TW5864_MV_LEN (0xff << 5) 12228c2ecf20Sopenharmony_ci/* The configured status bit written into bit 15 of 0xfc04 */ 12238c2ecf20Sopenharmony_ci#define TW5864_MPI_DDR_SEL BIT(13) 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci#define TW5864_MPI_DDR_SEL_REG 0xfc04 12268c2ecf20Sopenharmony_ci/* Define controls in register TW5864_MPI_DDR_SEL_REG */ 12278c2ecf20Sopenharmony_ci/* 12288c2ecf20Sopenharmony_ci * SW configure register 12298c2ecf20Sopenharmony_ci * 0 MV is saved in internal DPR 12308c2ecf20Sopenharmony_ci * 1 MV is saved in DDR 12318c2ecf20Sopenharmony_ci */ 12328c2ecf20Sopenharmony_ci#define TW5864_MPI_DDR_SEL2 BIT(15) 12338c2ecf20Sopenharmony_ci 12348c2ecf20Sopenharmony_ci/* 0x18000 ~ 0x181fc – PCI Master/Slave Control Map */ 12358c2ecf20Sopenharmony_ci#define TW5864_PCI_INTR_STATUS 0x18000 12368c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PCI_INTR_STATUS */ 12378c2ecf20Sopenharmony_ci/* vlc done */ 12388c2ecf20Sopenharmony_ci#define TW5864_VLC_DONE_INTR BIT(1) 12398c2ecf20Sopenharmony_ci/* ad vsync */ 12408c2ecf20Sopenharmony_ci#define TW5864_AD_VSYNC_INTR BIT(3) 12418c2ecf20Sopenharmony_ci/* preview eof */ 12428c2ecf20Sopenharmony_ci#define TW5864_PREV_EOF_INTR BIT(4) 12438c2ecf20Sopenharmony_ci/* preview overflow interrupt */ 12448c2ecf20Sopenharmony_ci#define TW5864_PREV_OVERFLOW_INTR BIT(5) 12458c2ecf20Sopenharmony_ci/* timer interrupt */ 12468c2ecf20Sopenharmony_ci#define TW5864_TIMER_INTR BIT(6) 12478c2ecf20Sopenharmony_ci/* audio eof */ 12488c2ecf20Sopenharmony_ci#define TW5864_AUDIO_EOF_INTR BIT(8) 12498c2ecf20Sopenharmony_ci/* IIC done */ 12508c2ecf20Sopenharmony_ci#define TW5864_IIC_DONE_INTR BIT(24) 12518c2ecf20Sopenharmony_ci/* ad interrupt (e.g.: video lost, video format changed) */ 12528c2ecf20Sopenharmony_ci#define TW5864_AD_INTR_REG BIT(25) 12538c2ecf20Sopenharmony_ci 12548c2ecf20Sopenharmony_ci#define TW5864_PCI_INTR_CTL 0x18004 12558c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PCI_INTR_CTL */ 12568c2ecf20Sopenharmony_ci/* master enable */ 12578c2ecf20Sopenharmony_ci#define TW5864_PCI_MAST_ENB BIT(0) 12588c2ecf20Sopenharmony_ci/* mvd&vlc master enable */ 12598c2ecf20Sopenharmony_ci#define TW5864_MVD_VLC_MAST_ENB 0x06 12608c2ecf20Sopenharmony_ci/* (Need to set 0 in TW5864A) */ 12618c2ecf20Sopenharmony_ci#define TW5864_AD_MAST_ENB BIT(3) 12628c2ecf20Sopenharmony_ci/* preview master enable */ 12638c2ecf20Sopenharmony_ci#define TW5864_PREV_MAST_ENB BIT(4) 12648c2ecf20Sopenharmony_ci/* preview overflow enable */ 12658c2ecf20Sopenharmony_ci#define TW5864_PREV_OVERFLOW_ENB BIT(5) 12668c2ecf20Sopenharmony_ci/* timer interrupt enable */ 12678c2ecf20Sopenharmony_ci#define TW5864_TIMER_INTR_ENB BIT(6) 12688c2ecf20Sopenharmony_ci/* JPEG master (push mode) enable */ 12698c2ecf20Sopenharmony_ci#define TW5864_JPEG_MAST_ENB BIT(7) 12708c2ecf20Sopenharmony_ci#define TW5864_AU_MAST_ENB_CHN_SHIFT 8 12718c2ecf20Sopenharmony_ci/* audio master channel enable */ 12728c2ecf20Sopenharmony_ci#define TW5864_AU_MAST_ENB_CHN (0xffff << 8) 12738c2ecf20Sopenharmony_ci/* IIC interrupt enable */ 12748c2ecf20Sopenharmony_ci#define TW5864_IIC_INTR_ENB BIT(24) 12758c2ecf20Sopenharmony_ci/* ad interrupt enable */ 12768c2ecf20Sopenharmony_ci#define TW5864_AD_INTR_ENB BIT(25) 12778c2ecf20Sopenharmony_ci/* target burst enable */ 12788c2ecf20Sopenharmony_ci#define TW5864_PCI_TAR_BURST_ENB BIT(26) 12798c2ecf20Sopenharmony_ci/* vlc stream burst enable */ 12808c2ecf20Sopenharmony_ci#define TW5864_PCI_VLC_BURST_ENB BIT(27) 12818c2ecf20Sopenharmony_ci/* ddr burst enable (1 enable, and must set DDR_BRST_EN) */ 12828c2ecf20Sopenharmony_ci#define TW5864_PCI_DDR_BURST_ENB BIT(28) 12838c2ecf20Sopenharmony_ci 12848c2ecf20Sopenharmony_ci/* 12858c2ecf20Sopenharmony_ci * Because preview and audio have 16 channels separately, so using this 12868c2ecf20Sopenharmony_ci * registers to indicate interrupt status for every channels. This is secondary 12878c2ecf20Sopenharmony_ci * interrupt status register. OR operating of the PREV_INTR_REG is 12888c2ecf20Sopenharmony_ci * PREV_EOF_INTR, OR operating of the AU_INTR_REG bits is AUDIO_EOF_INTR 12898c2ecf20Sopenharmony_ci */ 12908c2ecf20Sopenharmony_ci#define TW5864_PREV_AND_AU_INTR 0x18008 12918c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PREV_AND_AU_INTR */ 12928c2ecf20Sopenharmony_ci/* preview eof interrupt flag */ 12938c2ecf20Sopenharmony_ci#define TW5864_PREV_INTR_REG 0x0000ffff 12948c2ecf20Sopenharmony_ci#define TW5864_AU_INTR_REG_SHIFT 16 12958c2ecf20Sopenharmony_ci/* audio eof interrupt flag */ 12968c2ecf20Sopenharmony_ci#define TW5864_AU_INTR_REG (0xffff << 16) 12978c2ecf20Sopenharmony_ci 12988c2ecf20Sopenharmony_ci#define TW5864_MASTER_ENB_REG 0x1800c 12998c2ecf20Sopenharmony_ci/* Define controls in register TW5864_MASTER_ENB_REG */ 13008c2ecf20Sopenharmony_ci/* master enable */ 13018c2ecf20Sopenharmony_ci#define TW5864_PCI_VLC_INTR_ENB BIT(1) 13028c2ecf20Sopenharmony_ci/* mvd and vlc master enable */ 13038c2ecf20Sopenharmony_ci#define TW5864_PCI_PREV_INTR_ENB BIT(4) 13048c2ecf20Sopenharmony_ci/* ad vsync master enable */ 13058c2ecf20Sopenharmony_ci#define TW5864_PCI_PREV_OF_INTR_ENB BIT(5) 13068c2ecf20Sopenharmony_ci/* jpeg master enable */ 13078c2ecf20Sopenharmony_ci#define TW5864_PCI_JPEG_INTR_ENB BIT(7) 13088c2ecf20Sopenharmony_ci/* preview master enable */ 13098c2ecf20Sopenharmony_ci#define TW5864_PCI_AUD_INTR_ENB BIT(8) 13108c2ecf20Sopenharmony_ci 13118c2ecf20Sopenharmony_ci/* 13128c2ecf20Sopenharmony_ci * Every channel of preview and audio have ping-pong buffers in system memory, 13138c2ecf20Sopenharmony_ci * this register is the buffer flag to notify software which buffer is been 13148c2ecf20Sopenharmony_ci * operated. 13158c2ecf20Sopenharmony_ci */ 13168c2ecf20Sopenharmony_ci#define TW5864_PREV_AND_AU_BUF_FLAG 0x18010 13178c2ecf20Sopenharmony_ci/* Define controls in register TW5864_PREV_AND_AU_BUF_FLAG */ 13188c2ecf20Sopenharmony_ci/* preview buffer A/B flag */ 13198c2ecf20Sopenharmony_ci#define TW5864_PREV_BUF_FLAG 0xffff 13208c2ecf20Sopenharmony_ci#define TW5864_AUDIO_BUF_FLAG_SHIFT 16 13218c2ecf20Sopenharmony_ci/* audio buffer A/B flag */ 13228c2ecf20Sopenharmony_ci#define TW5864_AUDIO_BUF_FLAG (0xffff << 16) 13238c2ecf20Sopenharmony_ci 13248c2ecf20Sopenharmony_ci#define TW5864_IIC 0x18014 13258c2ecf20Sopenharmony_ci/* Define controls in register TW5864_IIC */ 13268c2ecf20Sopenharmony_ci/* register data */ 13278c2ecf20Sopenharmony_ci#define TW5864_IIC_DATA 0x00ff 13288c2ecf20Sopenharmony_ci#define TW5864_IIC_REG_ADDR_SHIFT 8 13298c2ecf20Sopenharmony_ci/* register addr */ 13308c2ecf20Sopenharmony_ci#define TW5864_IIC_REG_ADDR (0xff << 8) 13318c2ecf20Sopenharmony_ci/* rd/wr flag rd=1,wr=0 */ 13328c2ecf20Sopenharmony_ci#define TW5864_IIC_RW BIT(16) 13338c2ecf20Sopenharmony_ci#define TW5864_IIC_DEV_ADDR_SHIFT 17 13348c2ecf20Sopenharmony_ci/* device addr */ 13358c2ecf20Sopenharmony_ci#define TW5864_IIC_DEV_ADDR (0x7f << 17) 13368c2ecf20Sopenharmony_ci/* 13378c2ecf20Sopenharmony_ci * iic done, software kick off one time iic transaction through setting this 13388c2ecf20Sopenharmony_ci * bit to 1. Then poll this bit, value 1 indicate iic transaction have 13398c2ecf20Sopenharmony_ci * completed, if read, valid data have been stored in iic_data 13408c2ecf20Sopenharmony_ci */ 13418c2ecf20Sopenharmony_ci#define TW5864_IIC_DONE BIT(24) 13428c2ecf20Sopenharmony_ci 13438c2ecf20Sopenharmony_ci#define TW5864_RST_AND_IF_INFO 0x18018 13448c2ecf20Sopenharmony_ci/* Define controls in register TW5864_RST_AND_IF_INFO */ 13458c2ecf20Sopenharmony_ci/* application software soft reset */ 13468c2ecf20Sopenharmony_ci#define TW5864_APP_SOFT_RST BIT(0) 13478c2ecf20Sopenharmony_ci#define TW5864_PCI_INF_VERSION_SHIFT 16 13488c2ecf20Sopenharmony_ci/* PCI interface version, read only */ 13498c2ecf20Sopenharmony_ci#define TW5864_PCI_INF_VERSION (0xffff << 16) 13508c2ecf20Sopenharmony_ci 13518c2ecf20Sopenharmony_ci/* vlc stream crc value, it is calculated in pci module */ 13528c2ecf20Sopenharmony_ci#define TW5864_VLC_CRC_REG 0x1801c 13538c2ecf20Sopenharmony_ci/* 13548c2ecf20Sopenharmony_ci * vlc max length, it is defined by software based on software assign memory 13558c2ecf20Sopenharmony_ci * space for vlc 13568c2ecf20Sopenharmony_ci */ 13578c2ecf20Sopenharmony_ci#define TW5864_VLC_MAX_LENGTH 0x18020 13588c2ecf20Sopenharmony_ci/* vlc length of one frame */ 13598c2ecf20Sopenharmony_ci#define TW5864_VLC_LENGTH 0x18024 13608c2ecf20Sopenharmony_ci/* vlc original crc value */ 13618c2ecf20Sopenharmony_ci#define TW5864_VLC_INTRA_CRC_I_REG 0x18028 13628c2ecf20Sopenharmony_ci/* vlc original crc value */ 13638c2ecf20Sopenharmony_ci#define TW5864_VLC_INTRA_CRC_O_REG 0x1802c 13648c2ecf20Sopenharmony_ci/* mv stream crc value, it is calculated in pci module */ 13658c2ecf20Sopenharmony_ci#define TW5864_VLC_PAR_CRC_REG 0x18030 13668c2ecf20Sopenharmony_ci/* mv length */ 13678c2ecf20Sopenharmony_ci#define TW5864_VLC_PAR_LENGTH_REG 0x18034 13688c2ecf20Sopenharmony_ci/* mv original crc value */ 13698c2ecf20Sopenharmony_ci#define TW5864_VLC_PAR_I_REG 0x18038 13708c2ecf20Sopenharmony_ci/* mv original crc value */ 13718c2ecf20Sopenharmony_ci#define TW5864_VLC_PAR_O_REG 0x1803c 13728c2ecf20Sopenharmony_ci 13738c2ecf20Sopenharmony_ci/* 13748c2ecf20Sopenharmony_ci * Configuration register for 9[or 10] CIFs or 1D1+15QCIF Preview mode. 13758c2ecf20Sopenharmony_ci * PREV_PCI_ENB_CHN[0] Enable 9th preview channel (9CIF prev) or 1D1 channel in 13768c2ecf20Sopenharmony_ci * (1D1+15QCIF prev) 13778c2ecf20Sopenharmony_ci * PREV_PCI_ENB_CHN[1] Enable 10th preview channel 13788c2ecf20Sopenharmony_ci */ 13798c2ecf20Sopenharmony_ci#define TW5864_PREV_PCI_ENB_CHN 0x18040 13808c2ecf20Sopenharmony_ci/* Description skipped. */ 13818c2ecf20Sopenharmony_ci#define TW5864_PREV_FRAME_FORMAT_IN 0x18044 13828c2ecf20Sopenharmony_ci/* IIC enable */ 13838c2ecf20Sopenharmony_ci#define TW5864_IIC_ENB 0x18048 13848c2ecf20Sopenharmony_ci/* 13858c2ecf20Sopenharmony_ci * Timer interrupt interval 13868c2ecf20Sopenharmony_ci * 0 1ms 13878c2ecf20Sopenharmony_ci * 1 2ms 13888c2ecf20Sopenharmony_ci * 2 4ms 13898c2ecf20Sopenharmony_ci * 3 8ms 13908c2ecf20Sopenharmony_ci */ 13918c2ecf20Sopenharmony_ci#define TW5864_PCI_INTTM_SCALE 0x1804c 13928c2ecf20Sopenharmony_ci 13938c2ecf20Sopenharmony_ci/* 13948c2ecf20Sopenharmony_ci * The above register is pci base address registers. Application software will 13958c2ecf20Sopenharmony_ci * initialize them to tell chip where the corresponding stream will be dumped 13968c2ecf20Sopenharmony_ci * to. Application software will select appropriate base address interval based 13978c2ecf20Sopenharmony_ci * on the stream length. 13988c2ecf20Sopenharmony_ci */ 13998c2ecf20Sopenharmony_ci/* VLC stream base address */ 14008c2ecf20Sopenharmony_ci#define TW5864_VLC_STREAM_BASE_ADDR 0x18080 14018c2ecf20Sopenharmony_ci/* MV stream base address */ 14028c2ecf20Sopenharmony_ci#define TW5864_MV_STREAM_BASE_ADDR 0x18084 14038c2ecf20Sopenharmony_ci/* 0x180a0 – 0x180bc: audio burst base address. Skipped. */ 14048c2ecf20Sopenharmony_ci/* 0x180c0 ~ 0x180dc – JPEG Push Mode Buffer Base Address. Skipped. */ 14058c2ecf20Sopenharmony_ci/* 0x18100 – 0x1817c: preview burst base address. Skipped. */ 14068c2ecf20Sopenharmony_ci 14078c2ecf20Sopenharmony_ci/* 0x80000 ~ 0x87fff -- DDR Burst RW Register Map */ 14088c2ecf20Sopenharmony_ci#define TW5864_DDR_CTL 0x80000 14098c2ecf20Sopenharmony_ci/* Define controls in register TW5864_DDR_CTL */ 14108c2ecf20Sopenharmony_ci#define TW5864_BRST_LENGTH_SHIFT 2 14118c2ecf20Sopenharmony_ci/* Length of 32-bit data burst */ 14128c2ecf20Sopenharmony_ci#define TW5864_BRST_LENGTH (0x3fff << 2) 14138c2ecf20Sopenharmony_ci/* 14148c2ecf20Sopenharmony_ci * Burst Read/Write 14158c2ecf20Sopenharmony_ci * 0 Read Burst from DDR 14168c2ecf20Sopenharmony_ci * 1 Write Burst to DDR 14178c2ecf20Sopenharmony_ci */ 14188c2ecf20Sopenharmony_ci#define TW5864_BRST_RW BIT(16) 14198c2ecf20Sopenharmony_ci/* Begin a new DDR Burst. This bit is self cleared */ 14208c2ecf20Sopenharmony_ci#define TW5864_NEW_BRST_CMD BIT(17) 14218c2ecf20Sopenharmony_ci/* DDR Burst End Flag */ 14228c2ecf20Sopenharmony_ci#define TW5864_BRST_END BIT(24) 14238c2ecf20Sopenharmony_ci/* Enable Error Interrupt for Single DDR Access */ 14248c2ecf20Sopenharmony_ci#define TW5864_SING_ERR_INTR BIT(25) 14258c2ecf20Sopenharmony_ci/* Enable Error Interrupt for Burst DDR Access */ 14268c2ecf20Sopenharmony_ci#define TW5864_BRST_ERR_INTR BIT(26) 14278c2ecf20Sopenharmony_ci/* Enable Interrupt for End of DDR Burst Access */ 14288c2ecf20Sopenharmony_ci#define TW5864_BRST_END_INTR BIT(27) 14298c2ecf20Sopenharmony_ci/* DDR Single Access Error Flag */ 14308c2ecf20Sopenharmony_ci#define TW5864_SINGLE_ERR BIT(28) 14318c2ecf20Sopenharmony_ci/* DDR Single Access Busy Flag */ 14328c2ecf20Sopenharmony_ci#define TW5864_SINGLE_BUSY BIT(29) 14338c2ecf20Sopenharmony_ci/* DDR Burst Access Error Flag */ 14348c2ecf20Sopenharmony_ci#define TW5864_BRST_ERR BIT(30) 14358c2ecf20Sopenharmony_ci/* DDR Burst Access Busy Flag */ 14368c2ecf20Sopenharmony_ci#define TW5864_BRST_BUSY BIT(31) 14378c2ecf20Sopenharmony_ci 14388c2ecf20Sopenharmony_ci/* [27:0] DDR Access Address. Bit [1:0] has to be 0 */ 14398c2ecf20Sopenharmony_ci#define TW5864_DDR_ADDR 0x80004 14408c2ecf20Sopenharmony_ci/* DDR Access Internal Buffer Address. Bit [1:0] has to be 0 */ 14418c2ecf20Sopenharmony_ci#define TW5864_DPR_BUF_ADDR 0x80008 14428c2ecf20Sopenharmony_ci/* SRAM Buffer MPI Access Space. Totally 16 KB */ 14438c2ecf20Sopenharmony_ci#define TW5864_DPR_BUF_START 0x84000 14448c2ecf20Sopenharmony_ci/* 0x84000 - 0x87ffc */ 14458c2ecf20Sopenharmony_ci#define TW5864_DPR_BUF_SIZE 0x4000 14468c2ecf20Sopenharmony_ci 14478c2ecf20Sopenharmony_ci/* Indirect Map Space */ 14488c2ecf20Sopenharmony_ci/* 14498c2ecf20Sopenharmony_ci * The indirect space is accessed through 0xb800 ~ 0xb807 registers in direct 14508c2ecf20Sopenharmony_ci * access space 14518c2ecf20Sopenharmony_ci */ 14528c2ecf20Sopenharmony_ci/* Analog Video / Audio Decoder / Encoder */ 14538c2ecf20Sopenharmony_ci/* Allowed channel values: [0; 3] */ 14548c2ecf20Sopenharmony_ci/* Read-only register */ 14558c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0(channel) (0x000 + channel * 0x010) 14568c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_0 */ 14578c2ecf20Sopenharmony_ci/* 14588c2ecf20Sopenharmony_ci * 1 Video not present. (sync is not detected in number of consecutive line 14598c2ecf20Sopenharmony_ci * periods specified by MISSCNT register) 14608c2ecf20Sopenharmony_ci * 0 Video detected. 14618c2ecf20Sopenharmony_ci */ 14628c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_VDLOSS BIT(7) 14638c2ecf20Sopenharmony_ci/* 14648c2ecf20Sopenharmony_ci * 1 Horizontal sync PLL is locked to the incoming video source. 14658c2ecf20Sopenharmony_ci * 0 Horizontal sync PLL is not locked. 14668c2ecf20Sopenharmony_ci */ 14678c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_HLOCK BIT(6) 14688c2ecf20Sopenharmony_ci/* 14698c2ecf20Sopenharmony_ci * 1 Sub-carrier PLL is locked to the incoming video source. 14708c2ecf20Sopenharmony_ci * 0 Sub-carrier PLL is not locked. 14718c2ecf20Sopenharmony_ci */ 14728c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_SLOCK BIT(5) 14738c2ecf20Sopenharmony_ci/* 14748c2ecf20Sopenharmony_ci * 1 Even field is being decoded. 14758c2ecf20Sopenharmony_ci * 0 Odd field is being decoded. 14768c2ecf20Sopenharmony_ci */ 14778c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_FLD BIT(4) 14788c2ecf20Sopenharmony_ci/* 14798c2ecf20Sopenharmony_ci * 1 Vertical logic is locked to the incoming video source. 14808c2ecf20Sopenharmony_ci * 0 Vertical logic is not locked. 14818c2ecf20Sopenharmony_ci */ 14828c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_VLOCK BIT(3) 14838c2ecf20Sopenharmony_ci/* 14848c2ecf20Sopenharmony_ci * 1 No color burst signal detected. 14858c2ecf20Sopenharmony_ci * 0 Color burst signal detected. 14868c2ecf20Sopenharmony_ci */ 14878c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_MONO BIT(1) 14888c2ecf20Sopenharmony_ci/* 14898c2ecf20Sopenharmony_ci * 0 60Hz source detected 14908c2ecf20Sopenharmony_ci * 1 50Hz source detected 14918c2ecf20Sopenharmony_ci * The actual vertical scanning frequency depends on the current standard 14928c2ecf20Sopenharmony_ci * invoked. 14938c2ecf20Sopenharmony_ci */ 14948c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_0_DET50 BIT(0) 14958c2ecf20Sopenharmony_ci 14968c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1(channel) (0x001 + channel * 0x010) 14978c2ecf20Sopenharmony_ci/* VCR signal indicator. Read-only. */ 14988c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_VCR BIT(7) 14998c2ecf20Sopenharmony_ci/* Weak signal indicator 2. Read-only. */ 15008c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_WKAIR BIT(6) 15018c2ecf20Sopenharmony_ci/* Weak signal indicator controlled by WKTH. Read-only. */ 15028c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_WKAIR1 BIT(5) 15038c2ecf20Sopenharmony_ci/* 15048c2ecf20Sopenharmony_ci * 1 = Standard signal 15058c2ecf20Sopenharmony_ci * 0 = Non-standard signal 15068c2ecf20Sopenharmony_ci * Read-only 15078c2ecf20Sopenharmony_ci */ 15088c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_VSTD BIT(4) 15098c2ecf20Sopenharmony_ci/* 15108c2ecf20Sopenharmony_ci * 1 = Non-interlaced signal 15118c2ecf20Sopenharmony_ci * 0 = interlaced signal 15128c2ecf20Sopenharmony_ci * Read-only 15138c2ecf20Sopenharmony_ci */ 15148c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_NINTL BIT(3) 15158c2ecf20Sopenharmony_ci/* 15168c2ecf20Sopenharmony_ci * Vertical Sharpness Control. Writable. 15178c2ecf20Sopenharmony_ci * 0 = None (default) 15188c2ecf20Sopenharmony_ci * 7 = Highest 15198c2ecf20Sopenharmony_ci * **Note: VSHP must be set to ‘0’ if COMB = 0 15208c2ecf20Sopenharmony_ci */ 15218c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_1_VSHP 0x07 15228c2ecf20Sopenharmony_ci 15238c2ecf20Sopenharmony_ci/* HDELAY_XY[7:0] */ 15248c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_2_HDELAY_XY_LO(channel) (0x002 + channel * 0x010) 15258c2ecf20Sopenharmony_ci/* HACTIVE_XY[7:0] */ 15268c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_3_HACTIVE_XY_LO(channel) (0x003 + channel * 0x010) 15278c2ecf20Sopenharmony_ci/* VDELAY_XY[7:0] */ 15288c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_4_VDELAY_XY_LO(channel) (0x004 + channel * 0x010) 15298c2ecf20Sopenharmony_ci/* VACTIVE_XY[7:0] */ 15308c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_5_VACTIVE_XY_LO(channel) (0x005 + channel * 0x010) 15318c2ecf20Sopenharmony_ci 15328c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6(channel) (0x006 + channel * 0x010) 15338c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_6 */ 15348c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6_HDELAY_XY_HI 0x03 15358c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6_HACTIVE_XY_HI_SHIFT 2 15368c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6_HACTIVE_XY_HI (0x03 << 2) 15378c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6_VDELAY_XY_HI BIT(4) 15388c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_6_VACTIVE_XY_HI BIT(5) 15398c2ecf20Sopenharmony_ci 15408c2ecf20Sopenharmony_ci/* 15418c2ecf20Sopenharmony_ci * HDELAY_XY This 10bit register defines the starting location of horizontal 15428c2ecf20Sopenharmony_ci * active pixel for display / record path. A unit is 1 pixel. The default value 15438c2ecf20Sopenharmony_ci * is 0x00f for NTSC and 0x00a for PAL. 15448c2ecf20Sopenharmony_ci * 15458c2ecf20Sopenharmony_ci * HACTIVE_XY This 10bit register defines the number of horizontal active pixel 15468c2ecf20Sopenharmony_ci * for display / record path. A unit is 1 pixel. The default value is decimal 15478c2ecf20Sopenharmony_ci * 720. 15488c2ecf20Sopenharmony_ci * 15498c2ecf20Sopenharmony_ci * VDELAY_XY This 9bit register defines the starting location of vertical 15508c2ecf20Sopenharmony_ci * active for display / record path. A unit is 1 line. The default value is 15518c2ecf20Sopenharmony_ci * decimal 6. 15528c2ecf20Sopenharmony_ci * 15538c2ecf20Sopenharmony_ci * VACTIVE_XY This 9bit register defines the number of vertical active lines 15548c2ecf20Sopenharmony_ci * for display / record path. A unit is 1 line. The default value is decimal 15558c2ecf20Sopenharmony_ci * 240. 15568c2ecf20Sopenharmony_ci */ 15578c2ecf20Sopenharmony_ci 15588c2ecf20Sopenharmony_ci/* HUE These bits control the color hue as 2's complement number. They have 15598c2ecf20Sopenharmony_ci * value from +36o (7Fh) to -36o (80h) with an increment of 2.8o. The 2 LSB has 15608c2ecf20Sopenharmony_ci * no effect. The positive value gives greenish tone and negative value gives 15618c2ecf20Sopenharmony_ci * purplish tone. The default value is 0o (00h). This is effective only on NTSC 15628c2ecf20Sopenharmony_ci * system. The default is 00h. 15638c2ecf20Sopenharmony_ci */ 15648c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_7_HUE(channel) (0x007 + channel * 0x010) 15658c2ecf20Sopenharmony_ci 15668c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_8(channel) (0x008 + channel * 0x010) 15678c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_8 */ 15688c2ecf20Sopenharmony_ci/* 15698c2ecf20Sopenharmony_ci * This bit controls the center frequency of the peaking filter. 15708c2ecf20Sopenharmony_ci * The corresponding gain adjustment is HFLT. 15718c2ecf20Sopenharmony_ci * 0 Low 15728c2ecf20Sopenharmony_ci * 1 center 15738c2ecf20Sopenharmony_ci */ 15748c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_8_SCURVE BIT(7) 15758c2ecf20Sopenharmony_ci/* CTI level selection. The default is 1. 15768c2ecf20Sopenharmony_ci * 0 None 15778c2ecf20Sopenharmony_ci * 3 Highest 15788c2ecf20Sopenharmony_ci */ 15798c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_8_CTI_SHIFT 4 15808c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_8_CTI (0x03 << 4) 15818c2ecf20Sopenharmony_ci 15828c2ecf20Sopenharmony_ci/* 15838c2ecf20Sopenharmony_ci * These bits control the amount of sharpness enhancement on the luminance 15848c2ecf20Sopenharmony_ci * signals. There are 16 levels of control with "0" having no effect on the 15858c2ecf20Sopenharmony_ci * output image. 1 through 15 provides sharpness enhancement with "F" being the 15868c2ecf20Sopenharmony_ci * strongest. The default is 1. 15878c2ecf20Sopenharmony_ci */ 15888c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_8_SHARPNESS 0x0f 15898c2ecf20Sopenharmony_ci 15908c2ecf20Sopenharmony_ci/* 15918c2ecf20Sopenharmony_ci * These bits control the luminance contrast gain. A value of 100 (64h) has a 15928c2ecf20Sopenharmony_ci * gain of 1. The range adjustment is from 0% to 255% at 1% per step. The 15938c2ecf20Sopenharmony_ci * default is 64h. 15948c2ecf20Sopenharmony_ci */ 15958c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_9_CNTRST(channel) (0x009 + channel * 0x010) 15968c2ecf20Sopenharmony_ci 15978c2ecf20Sopenharmony_ci/* 15988c2ecf20Sopenharmony_ci * These bits control the brightness. They have value of –128 to 127 in 2's 15998c2ecf20Sopenharmony_ci * complement form. Positive value increases brightness. A value 0 has no 16008c2ecf20Sopenharmony_ci * effect on the data. The default is 00h. 16018c2ecf20Sopenharmony_ci */ 16028c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_A_BRIGHT(channel) (0x00a + channel * 0x010) 16038c2ecf20Sopenharmony_ci 16048c2ecf20Sopenharmony_ci/* 16058c2ecf20Sopenharmony_ci * These bits control the digital gain adjustment to the U (or Cb) component of 16068c2ecf20Sopenharmony_ci * the digital video signal. The color saturation can be adjusted by adjusting 16078c2ecf20Sopenharmony_ci * the U and V color gain components by the same amount in the normal 16088c2ecf20Sopenharmony_ci * situation. The U and V can also be adjusted independently to provide greater 16098c2ecf20Sopenharmony_ci * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 16108c2ecf20Sopenharmony_ci * gain of 100%. The default is 80h. 16118c2ecf20Sopenharmony_ci */ 16128c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_B_SAT_U(channel) (0x00b + channel * 0x010) 16138c2ecf20Sopenharmony_ci 16148c2ecf20Sopenharmony_ci/* 16158c2ecf20Sopenharmony_ci * These bits control the digital gain adjustment to the V (or Cr) component of 16168c2ecf20Sopenharmony_ci * the digital video signal. The color saturation can be adjusted by adjusting 16178c2ecf20Sopenharmony_ci * the U and V color gain components by the same amount in the normal 16188c2ecf20Sopenharmony_ci * situation. The U and V can also be adjusted independently to provide greater 16198c2ecf20Sopenharmony_ci * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 16208c2ecf20Sopenharmony_ci * gain of 100%. The default is 80h. 16218c2ecf20Sopenharmony_ci */ 16228c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_C_SAT_V(channel) (0x00c + channel * 0x010) 16238c2ecf20Sopenharmony_ci 16248c2ecf20Sopenharmony_ci/* Read-only */ 16258c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_D(channel) (0x00d + channel * 0x010) 16268c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_D */ 16278c2ecf20Sopenharmony_ci/* Macrovision color stripe detection may be un-reliable */ 16288c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_D_CSBAD BIT(3) 16298c2ecf20Sopenharmony_ci/* Macrovision AGC pulse detected */ 16308c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_D_MCVSN BIT(2) 16318c2ecf20Sopenharmony_ci/* Macrovision color stripe protection burst detected */ 16328c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_D_CSTRIPE BIT(1) 16338c2ecf20Sopenharmony_ci/* 16348c2ecf20Sopenharmony_ci * This bit is valid only when color stripe protection is detected, i.e. if 16358c2ecf20Sopenharmony_ci * CSTRIPE=1, 16368c2ecf20Sopenharmony_ci * 1 Type 2 color stripe protection 16378c2ecf20Sopenharmony_ci * 0 Type 3 color stripe protection 16388c2ecf20Sopenharmony_ci */ 16398c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_D_CTYPE2 BIT(0) 16408c2ecf20Sopenharmony_ci 16418c2ecf20Sopenharmony_ci/* Read-only */ 16428c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E(channel) (0x00e + channel * 0x010) 16438c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_E */ 16448c2ecf20Sopenharmony_ci/* 16458c2ecf20Sopenharmony_ci * Read-only. 16468c2ecf20Sopenharmony_ci * 0 Idle 16478c2ecf20Sopenharmony_ci * 1 Detection in progress 16488c2ecf20Sopenharmony_ci */ 16498c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E_DETSTUS BIT(7) 16508c2ecf20Sopenharmony_ci/* 16518c2ecf20Sopenharmony_ci * STDNOW Current standard invoked 16528c2ecf20Sopenharmony_ci * 0 NTSC (M) 16538c2ecf20Sopenharmony_ci * 1 PAL (B, D, G, H, I) 16548c2ecf20Sopenharmony_ci * 2 SECAM 16558c2ecf20Sopenharmony_ci * 3 NTSC4.43 16568c2ecf20Sopenharmony_ci * 4 PAL (M) 16578c2ecf20Sopenharmony_ci * 5 PAL (CN) 16588c2ecf20Sopenharmony_ci * 6 PAL 60 16598c2ecf20Sopenharmony_ci * 7 Not valid 16608c2ecf20Sopenharmony_ci */ 16618c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E_STDNOW_SHIFT 4 16628c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E_STDNOW (0x07 << 4) 16638c2ecf20Sopenharmony_ci 16648c2ecf20Sopenharmony_ci/* 16658c2ecf20Sopenharmony_ci * 1 Disable the shadow registers 16668c2ecf20Sopenharmony_ci * 0 Enable VACTIVE and HDELAY shadow registers value depending on STANDARD. 16678c2ecf20Sopenharmony_ci * (Default) 16688c2ecf20Sopenharmony_ci */ 16698c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E_ATREG BIT(3) 16708c2ecf20Sopenharmony_ci/* 16718c2ecf20Sopenharmony_ci * STANDARD Standard selection 16728c2ecf20Sopenharmony_ci * 0 NTSC (M) 16738c2ecf20Sopenharmony_ci * 1 PAL (B, D, G, H, I) 16748c2ecf20Sopenharmony_ci * 2 SECAM 16758c2ecf20Sopenharmony_ci * 3 NTSC4.43 16768c2ecf20Sopenharmony_ci * 4 PAL (M) 16778c2ecf20Sopenharmony_ci * 5 PAL (CN) 16788c2ecf20Sopenharmony_ci * 6 PAL 60 16798c2ecf20Sopenharmony_ci * 7 Auto detection (Default) 16808c2ecf20Sopenharmony_ci */ 16818c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_E_STANDARD 0x07 16828c2ecf20Sopenharmony_ci 16838c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F(channel) (0x00f + channel * 0x010) 16848c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_F */ 16858c2ecf20Sopenharmony_ci/* 16868c2ecf20Sopenharmony_ci * 1 Writing 1 to this bit will manually initiate the auto format detection 16878c2ecf20Sopenharmony_ci * process. This bit is a self-clearing bit 16888c2ecf20Sopenharmony_ci * 0 Manual initiation of auto format detection is done. (Default) 16898c2ecf20Sopenharmony_ci */ 16908c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_ATSTART BIT(7) 16918c2ecf20Sopenharmony_ci/* Enable recognition of PAL60 (Default) */ 16928c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_PAL60EN BIT(6) 16938c2ecf20Sopenharmony_ci/* Enable recognition of PAL (CN). (Default) */ 16948c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALCNEN BIT(5) 16958c2ecf20Sopenharmony_ci/* Enable recognition of PAL (M). (Default) */ 16968c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALMEN BIT(4) 16978c2ecf20Sopenharmony_ci/* Enable recognition of NTSC 4.43. (Default) */ 16988c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_NTSC44EN BIT(3) 16998c2ecf20Sopenharmony_ci/* Enable recognition of SECAM. (Default) */ 17008c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_SECAMEN BIT(2) 17018c2ecf20Sopenharmony_ci/* Enable recognition of PAL (B, D, G, H, I). (Default) */ 17028c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALBEN BIT(1) 17038c2ecf20Sopenharmony_ci/* Enable recognition of NTSC (M). (Default) */ 17048c2ecf20Sopenharmony_ci#define TW5864_INDIR_VIN_F_NTSCEN BIT(0) 17058c2ecf20Sopenharmony_ci 17068c2ecf20Sopenharmony_ci/* Some registers skipped. */ 17078c2ecf20Sopenharmony_ci 17088c2ecf20Sopenharmony_ci/* Use falling edge to sample VD1-VD4 from 54 MHz to 108 MHz */ 17098c2ecf20Sopenharmony_ci#define TW5864_INDIR_VD_108_POL 0x041 17108c2ecf20Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_VD12 BIT(0) 17118c2ecf20Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_VD34 BIT(1) 17128c2ecf20Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_BOTH \ 17138c2ecf20Sopenharmony_ci (TW5864_INDIR_VD_108_POL_VD12 | TW5864_INDIR_VD_108_POL_VD34) 17148c2ecf20Sopenharmony_ci 17158c2ecf20Sopenharmony_ci/* Some registers skipped. */ 17168c2ecf20Sopenharmony_ci 17178c2ecf20Sopenharmony_ci/* 17188c2ecf20Sopenharmony_ci * Audio Input ADC gain control 17198c2ecf20Sopenharmony_ci * 0 0.25 17208c2ecf20Sopenharmony_ci * 1 0.31 17218c2ecf20Sopenharmony_ci * 2 0.38 17228c2ecf20Sopenharmony_ci * 3 0.44 17238c2ecf20Sopenharmony_ci * 4 0.50 17248c2ecf20Sopenharmony_ci * 5 0.63 17258c2ecf20Sopenharmony_ci * 6 0.75 17268c2ecf20Sopenharmony_ci * 7 0.88 17278c2ecf20Sopenharmony_ci * 8 1.00 (default) 17288c2ecf20Sopenharmony_ci * 9 1.25 17298c2ecf20Sopenharmony_ci * 10 1.50 17308c2ecf20Sopenharmony_ci * 11 1.75 17318c2ecf20Sopenharmony_ci * 12 2.00 17328c2ecf20Sopenharmony_ci * 13 2.25 17338c2ecf20Sopenharmony_ci * 14 2.50 17348c2ecf20Sopenharmony_ci * 15 2.75 17358c2ecf20Sopenharmony_ci */ 17368c2ecf20Sopenharmony_ci/* [3:0] channel 0, [7:4] channel 1 */ 17378c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIGAIN1 0x060 17388c2ecf20Sopenharmony_ci/* [3:0] channel 2, [7:4] channel 3 */ 17398c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIGAIN2 0x061 17408c2ecf20Sopenharmony_ci 17418c2ecf20Sopenharmony_ci/* Some registers skipped */ 17428c2ecf20Sopenharmony_ci 17438c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x06D 0x06d 17448c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x06D */ 17458c2ecf20Sopenharmony_ci/* 17468c2ecf20Sopenharmony_ci * LAWMD Select u-Law/A-Law/PCM/SB data output format on ADATR and ADATM pin. 17478c2ecf20Sopenharmony_ci * 0 PCM output (default) 17488c2ecf20Sopenharmony_ci * 1 SB (Signed MSB bit in PCM data is inverted) output 17498c2ecf20Sopenharmony_ci * 2 u-Law output 17508c2ecf20Sopenharmony_ci * 3 A-Law output 17518c2ecf20Sopenharmony_ci */ 17528c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_LAWMD_SHIFT 6 17538c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_LAWMD (0x03 << 6) 17548c2ecf20Sopenharmony_ci/* 17558c2ecf20Sopenharmony_ci * Disable the mixing ratio value for all audio. 17568c2ecf20Sopenharmony_ci * 0 Apply individual mixing ratio value for each audio (default) 17578c2ecf20Sopenharmony_ci * 1 Apply nominal value for all audio commonly 17588c2ecf20Sopenharmony_ci */ 17598c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_MIX_DERATIO BIT(5) 17608c2ecf20Sopenharmony_ci/* 17618c2ecf20Sopenharmony_ci * Enable the mute function for audio channel AINn when n is 0 to 3. It effects 17628c2ecf20Sopenharmony_ci * only for mixing. When n = 4, it enable the mute function of the playback 17638c2ecf20Sopenharmony_ci * audio input. It effects only for single chip or the last stage chip 17648c2ecf20Sopenharmony_ci * 0 Normal 17658c2ecf20Sopenharmony_ci * 1 Muted (default) 17668c2ecf20Sopenharmony_ci */ 17678c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_MIX_MUTE 0x1f 17688c2ecf20Sopenharmony_ci 17698c2ecf20Sopenharmony_ci/* Some registers skipped */ 17708c2ecf20Sopenharmony_ci 17718c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3 0x0e3 17728c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x0E3 */ 17738c2ecf20Sopenharmony_ci/* 17748c2ecf20Sopenharmony_ci * ADATP signal is coming from external ADPCM decoder, instead of on-chip ADPCM 17758c2ecf20Sopenharmony_ci * decoder 17768c2ecf20Sopenharmony_ci */ 17778c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_EXT_ADATP BIT(7) 17788c2ecf20Sopenharmony_ci/* ACLKP output signal polarity inverse */ 17798c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKPPOLO BIT(6) 17808c2ecf20Sopenharmony_ci/* 17818c2ecf20Sopenharmony_ci * ACLKR input signal polarity inverse. 17828c2ecf20Sopenharmony_ci * 0 Not inversed (Default) 17838c2ecf20Sopenharmony_ci * 1 Inversed 17848c2ecf20Sopenharmony_ci */ 17858c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKRPOL BIT(5) 17868c2ecf20Sopenharmony_ci/* 17878c2ecf20Sopenharmony_ci * ACLKP input signal polarity inverse. 17888c2ecf20Sopenharmony_ci * 0 Not inversed (Default) 17898c2ecf20Sopenharmony_ci * 1 Inversed 17908c2ecf20Sopenharmony_ci */ 17918c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKPPOLI BIT(4) 17928c2ecf20Sopenharmony_ci/* 17938c2ecf20Sopenharmony_ci * ACKI [21:0] control automatic set up with AFMD registers 17948c2ecf20Sopenharmony_ci * This mode is only effective when ACLKRMASTER=1 17958c2ecf20Sopenharmony_ci * 0 ACKI [21:0] registers set up ACKI control 17968c2ecf20Sopenharmony_ci * 1 ACKI control is automatically set up by AFMD register values 17978c2ecf20Sopenharmony_ci */ 17988c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_AFAUTO BIT(3) 17998c2ecf20Sopenharmony_ci/* 18008c2ecf20Sopenharmony_ci * AFAUTO control mode 18018c2ecf20Sopenharmony_ci * 0 8kHz setting (Default) 18028c2ecf20Sopenharmony_ci * 1 16kHz setting 18038c2ecf20Sopenharmony_ci * 2 32kHz setting 18048c2ecf20Sopenharmony_ci * 3 44.1kHz setting 18058c2ecf20Sopenharmony_ci * 4 48kHz setting 18068c2ecf20Sopenharmony_ci */ 18078c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_AFMD 0x07 18088c2ecf20Sopenharmony_ci 18098c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4 0x0e4 18108c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x0ED */ 18118c2ecf20Sopenharmony_ci/* 18128c2ecf20Sopenharmony_ci * 8bit I2S Record output mode. 18138c2ecf20Sopenharmony_ci * 0 L/R half length separated output (Default). 18148c2ecf20Sopenharmony_ci * 1 One continuous packed output equal to DSP output format. 18158c2ecf20Sopenharmony_ci */ 18168c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_I2S8MODE BIT(7) 18178c2ecf20Sopenharmony_ci/* 18188c2ecf20Sopenharmony_ci * Audio Clock Master ACLKR output wave format. 18198c2ecf20Sopenharmony_ci * 0 High periods is one 27MHz clock period (default). 18208c2ecf20Sopenharmony_ci * 1 Almost duty 50-50% clock output on ACLKR pin. If this mode is selected, two 18218c2ecf20Sopenharmony_ci * times bigger number value need to be set up on the ACKI register. If 18228c2ecf20Sopenharmony_ci * AFAUTO=1, ACKI control is automatically set up even if MASCKMD=1. 18238c2ecf20Sopenharmony_ci */ 18248c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_MASCKMD BIT(6) 18258c2ecf20Sopenharmony_ci/* Playback ACLKP/ASYNP/ADATP input data MSB-LSB swapping */ 18268c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_PBINSWAP BIT(5) 18278c2ecf20Sopenharmony_ci/* 18288c2ecf20Sopenharmony_ci * ASYNR input signal delay. 18298c2ecf20Sopenharmony_ci * 0 No delay 18308c2ecf20Sopenharmony_ci * 1 Add one 27MHz period delay in ASYNR signal input 18318c2ecf20Sopenharmony_ci */ 18328c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ASYNRDLY BIT(4) 18338c2ecf20Sopenharmony_ci/* 18348c2ecf20Sopenharmony_ci * ASYNP input signal delay. 18358c2ecf20Sopenharmony_ci * 0 no delay 18368c2ecf20Sopenharmony_ci * 1 add one 27MHz period delay in ASYNP signal input 18378c2ecf20Sopenharmony_ci */ 18388c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ASYNPDLY BIT(3) 18398c2ecf20Sopenharmony_ci/* 18408c2ecf20Sopenharmony_ci * ADATP input data delay by one ACLKP clock. 18418c2ecf20Sopenharmony_ci * 0 No delay (Default). This is for I2S type 1T delay input interface. 18428c2ecf20Sopenharmony_ci * 1 Add 1 ACLKP clock delay in ADATP input data. This is for left-justified 18438c2ecf20Sopenharmony_ci * type 0T delay input interface. 18448c2ecf20Sopenharmony_ci */ 18458c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ADATPDLY BIT(2) 18468c2ecf20Sopenharmony_ci/* 18478c2ecf20Sopenharmony_ci * Select u-Law/A-Law/PCM/SB data input format on ADATP pin. 18488c2ecf20Sopenharmony_ci * 0 PCM input (Default) 18498c2ecf20Sopenharmony_ci * 1 SB (Signed MSB bit in PCM data is inverted) input 18508c2ecf20Sopenharmony_ci * 2 u-Law input 18518c2ecf20Sopenharmony_ci * 3 A-Law input 18528c2ecf20Sopenharmony_ci */ 18538c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_INLAWMD 0x03 18548c2ecf20Sopenharmony_ci 18558c2ecf20Sopenharmony_ci/* 18568c2ecf20Sopenharmony_ci * Enable state register updating and interrupt request of audio AIN5 detection 18578c2ecf20Sopenharmony_ci * for each input 18588c2ecf20Sopenharmony_ci */ 18598c2ecf20Sopenharmony_ci#define TW5864_INDIR_AIN_A5DETENA 0x0e5 18608c2ecf20Sopenharmony_ci 18618c2ecf20Sopenharmony_ci/* Some registers skipped */ 18628c2ecf20Sopenharmony_ci 18638c2ecf20Sopenharmony_ci/* 18648c2ecf20Sopenharmony_ci * [7:3]: DEV_ID The TW5864 product ID code is 01000 18658c2ecf20Sopenharmony_ci * [2:0]: REV_ID The revision number is 0h 18668c2ecf20Sopenharmony_ci */ 18678c2ecf20Sopenharmony_ci#define TW5864_INDIR_ID 0x0fe 18688c2ecf20Sopenharmony_ci 18698c2ecf20Sopenharmony_ci#define TW5864_INDIR_IN_PIC_WIDTH(channel) (0x200 + 4 * channel) 18708c2ecf20Sopenharmony_ci#define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel) 18718c2ecf20Sopenharmony_ci#define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel) 18728c2ecf20Sopenharmony_ci#define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel) 18738c2ecf20Sopenharmony_ci 18748c2ecf20Sopenharmony_ci/* Some registers skipped */ 18758c2ecf20Sopenharmony_ci 18768c2ecf20Sopenharmony_ci#define TW5864_INDIR_CROP_ETC 0x260 18778c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_CROP_ETC */ 18788c2ecf20Sopenharmony_ci/* Enable cropping from 720 to 704 */ 18798c2ecf20Sopenharmony_ci#define TW5864_INDIR_CROP_ETC_CROP_EN 0x4 18808c2ecf20Sopenharmony_ci 18818c2ecf20Sopenharmony_ci/* 18828c2ecf20Sopenharmony_ci * Interrupt status register from the front-end. Write "1" to each bit to clear 18838c2ecf20Sopenharmony_ci * the interrupt 18848c2ecf20Sopenharmony_ci * 15:0 Motion detection interrupt for channel 0 ~ 15 18858c2ecf20Sopenharmony_ci * 31:16 Night detection interrupt for channel 0 ~ 15 18868c2ecf20Sopenharmony_ci * 47:32 Blind detection interrupt for channel 0 ~ 15 18878c2ecf20Sopenharmony_ci * 63:48 No video interrupt for channel 0 ~ 15 18888c2ecf20Sopenharmony_ci * 79:64 Line mode underflow interrupt for channel 0 ~ 15 18898c2ecf20Sopenharmony_ci * 95:80 Line mode overflow interrupt for channel 0 ~ 15 18908c2ecf20Sopenharmony_ci */ 18918c2ecf20Sopenharmony_ci/* 0x2d0~0x2d7: [63:0] bits */ 18928c2ecf20Sopenharmony_ci#define TW5864_INDIR_INTERRUPT1 0x2d0 18938c2ecf20Sopenharmony_ci/* 0x2e0~0x2e3: [95:64] bits */ 18948c2ecf20Sopenharmony_ci#define TW5864_INDIR_INTERRUPT2 0x2e0 18958c2ecf20Sopenharmony_ci 18968c2ecf20Sopenharmony_ci/* 18978c2ecf20Sopenharmony_ci * Interrupt mask register for interrupts in 0x2d0 ~ 0x2d7 18988c2ecf20Sopenharmony_ci * 15:0 Motion detection interrupt for channel 0 ~ 15 18998c2ecf20Sopenharmony_ci * 31:16 Night detection interrupt for channel 0 ~ 15 19008c2ecf20Sopenharmony_ci * 47:32 Blind detection interrupt for channel 0 ~ 15 19018c2ecf20Sopenharmony_ci * 63:48 No video interrupt for channel 0 ~ 15 19028c2ecf20Sopenharmony_ci * 79:64 Line mode underflow interrupt for channel 0 ~ 15 19038c2ecf20Sopenharmony_ci * 95:80 Line mode overflow interrupt for channel 0 ~ 15 19048c2ecf20Sopenharmony_ci */ 19058c2ecf20Sopenharmony_ci/* 0x2d8~0x2df: [63:0] bits */ 19068c2ecf20Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_MASK1 0x2d8 19078c2ecf20Sopenharmony_ci/* 0x2e8~0x2eb: [95:64] bits */ 19088c2ecf20Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_MASK2 0x2e8 19098c2ecf20Sopenharmony_ci 19108c2ecf20Sopenharmony_ci/* [11:0]: Interrupt summary register for interrupts & interrupt mask from in 19118c2ecf20Sopenharmony_ci * 0x2d0 ~ 0x2d7 and 0x2d8 ~ 0x2df 19128c2ecf20Sopenharmony_ci * bit 0: interrupt occurs in 0x2d0 & 0x2d8 19138c2ecf20Sopenharmony_ci * bit 1: interrupt occurs in 0x2d1 & 0x2d9 19148c2ecf20Sopenharmony_ci * bit 2: interrupt occurs in 0x2d2 & 0x2da 19158c2ecf20Sopenharmony_ci * bit 3: interrupt occurs in 0x2d3 & 0x2db 19168c2ecf20Sopenharmony_ci * bit 4: interrupt occurs in 0x2d4 & 0x2dc 19178c2ecf20Sopenharmony_ci * bit 5: interrupt occurs in 0x2d5 & 0x2dd 19188c2ecf20Sopenharmony_ci * bit 6: interrupt occurs in 0x2d6 & 0x2de 19198c2ecf20Sopenharmony_ci * bit 7: interrupt occurs in 0x2d7 & 0x2df 19208c2ecf20Sopenharmony_ci * bit 8: interrupt occurs in 0x2e0 & 0x2e8 19218c2ecf20Sopenharmony_ci * bit 9: interrupt occurs in 0x2e1 & 0x2e9 19228c2ecf20Sopenharmony_ci * bit 10: interrupt occurs in 0x2e2 & 0x2ea 19238c2ecf20Sopenharmony_ci * bit 11: interrupt occurs in 0x2e3 & 0x2eb 19248c2ecf20Sopenharmony_ci */ 19258c2ecf20Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_SUMMARY 0x2f0 19268c2ecf20Sopenharmony_ci 19278c2ecf20Sopenharmony_ci/* Motion / Blind / Night Detection */ 19288c2ecf20Sopenharmony_ci/* valid value for channel is [0:15] */ 19298c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0(channel) (0x300 + channel * 0x08) 19308c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL0 */ 19318c2ecf20Sopenharmony_ci/* 19328c2ecf20Sopenharmony_ci * Disable the motion and blind detection. 19338c2ecf20Sopenharmony_ci * 0 Enable motion and blind detection (default) 19348c2ecf20Sopenharmony_ci * 1 Disable motion and blind detection 19358c2ecf20Sopenharmony_ci */ 19368c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_DIS BIT(5) 19378c2ecf20Sopenharmony_ci/* 19388c2ecf20Sopenharmony_ci * Request to start motion detection on manual trigger mode 19398c2ecf20Sopenharmony_ci * 0 None Operation (default) 19408c2ecf20Sopenharmony_ci * 1 Request to start motion detection 19418c2ecf20Sopenharmony_ci */ 19428c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_STRB BIT(3) 19438c2ecf20Sopenharmony_ci/* 19448c2ecf20Sopenharmony_ci * Select the trigger mode of motion detection 19458c2ecf20Sopenharmony_ci * 0 Automatic trigger mode of motion detection (default) 19468c2ecf20Sopenharmony_ci * 1 Manual trigger mode for motion detection 19478c2ecf20Sopenharmony_ci */ 19488c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_STRB_EN BIT(2) 19498c2ecf20Sopenharmony_ci/* 19508c2ecf20Sopenharmony_ci * Define the threshold of cell for blind detection. 19518c2ecf20Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 19528c2ecf20Sopenharmony_ci * : : 19538c2ecf20Sopenharmony_ci * 3 High threshold (Less sensitive) 19548c2ecf20Sopenharmony_ci */ 19558c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_BD_CELSENS 0x03 19568c2ecf20Sopenharmony_ci 19578c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1(channel) (0x301 + channel * 0x08) 19588c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL1 */ 19598c2ecf20Sopenharmony_ci/* 19608c2ecf20Sopenharmony_ci * Control the temporal sensitivity of motion detector. 19618c2ecf20Sopenharmony_ci * 0 More Sensitive (default) 19628c2ecf20Sopenharmony_ci * : : 19638c2ecf20Sopenharmony_ci * 15 Less Sensitive 19648c2ecf20Sopenharmony_ci */ 19658c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS_SHIFT 4 19668c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS (0x0f << 4) 19678c2ecf20Sopenharmony_ci/* 19688c2ecf20Sopenharmony_ci * Adjust the horizontal starting position for motion detection 19698c2ecf20Sopenharmony_ci * 0 0 pixel (default) 19708c2ecf20Sopenharmony_ci * : : 19718c2ecf20Sopenharmony_ci * 15 15 pixels 19728c2ecf20Sopenharmony_ci */ 19738c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_PIXEL_OS 0x0f 19748c2ecf20Sopenharmony_ci 19758c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2(channel) (0x302 + channel * 0x08) 19768c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL2 */ 19778c2ecf20Sopenharmony_ci/* 19788c2ecf20Sopenharmony_ci * Control the updating time of reference field for motion detection. 19798c2ecf20Sopenharmony_ci * 0 Update reference field every field (default) 19808c2ecf20Sopenharmony_ci * 1 Update reference field according to MD_SPEED 19818c2ecf20Sopenharmony_ci */ 19828c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_REFFLD BIT(7) 19838c2ecf20Sopenharmony_ci/* 19848c2ecf20Sopenharmony_ci * Select the field for motion detection. 19858c2ecf20Sopenharmony_ci * 0 Detecting motion for only odd field (default) 19868c2ecf20Sopenharmony_ci * 1 Detecting motion for only even field 19878c2ecf20Sopenharmony_ci * 2 Detecting motion for any field 19888c2ecf20Sopenharmony_ci * 3 Detecting motion for both odd and even field 19898c2ecf20Sopenharmony_ci */ 19908c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_FIELD_SHIFT 5 19918c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_FIELD (0x03 << 5) 19928c2ecf20Sopenharmony_ci/* 19938c2ecf20Sopenharmony_ci * Control the level sensitivity of motion detector. 19948c2ecf20Sopenharmony_ci * 0 More sensitive (default) 19958c2ecf20Sopenharmony_ci * : : 19968c2ecf20Sopenharmony_ci * 15 Less sensitive 19978c2ecf20Sopenharmony_ci */ 19988c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_LVSENS 0x1f 19998c2ecf20Sopenharmony_ci 20008c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3(channel) (0x303 + channel * 0x08) 20018c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL3 */ 20028c2ecf20Sopenharmony_ci/* 20038c2ecf20Sopenharmony_ci * Define the threshold of sub-cell number for motion detection. 20048c2ecf20Sopenharmony_ci * 0 Motion is detected if 1 sub-cell has motion (More sensitive) (default) 20058c2ecf20Sopenharmony_ci * 1 Motion is detected if 2 sub-cells have motion 20068c2ecf20Sopenharmony_ci * 2 Motion is detected if 3 sub-cells have motion 20078c2ecf20Sopenharmony_ci * 3 Motion is detected if 4 sub-cells have motion (Less sensitive) 20088c2ecf20Sopenharmony_ci */ 20098c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS_SHIFT 6 20108c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS (0x03 << 6) 20118c2ecf20Sopenharmony_ci/* 20128c2ecf20Sopenharmony_ci * Control the velocity of motion detector. 20138c2ecf20Sopenharmony_ci * Large value is suitable for slow motion detection. 20148c2ecf20Sopenharmony_ci * In MD_DUAL_EN = 1, MD_SPEED should be limited to 0 ~ 31. 20158c2ecf20Sopenharmony_ci * 0 1 field intervals (default) 20168c2ecf20Sopenharmony_ci * 1 2 field intervals 20178c2ecf20Sopenharmony_ci * : : 20188c2ecf20Sopenharmony_ci * 61 62 field intervals 20198c2ecf20Sopenharmony_ci * 62 63 field intervals 20208c2ecf20Sopenharmony_ci * 63 Not supported 20218c2ecf20Sopenharmony_ci */ 20228c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_SPEED 0x3f 20238c2ecf20Sopenharmony_ci 20248c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4(channel) (0x304 + channel * 0x08) 20258c2ecf20Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL4 */ 20268c2ecf20Sopenharmony_ci/* 20278c2ecf20Sopenharmony_ci * Control the spatial sensitivity of motion detector. 20288c2ecf20Sopenharmony_ci * 0 More Sensitive (default) 20298c2ecf20Sopenharmony_ci * : : 20308c2ecf20Sopenharmony_ci * 15 Less Sensitive 20318c2ecf20Sopenharmony_ci */ 20328c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS_SHIFT 4 20338c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS (0x0f << 4) 20348c2ecf20Sopenharmony_ci/* 20358c2ecf20Sopenharmony_ci * Define the threshold of level for blind detection. 20368c2ecf20Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 20378c2ecf20Sopenharmony_ci * : : 20388c2ecf20Sopenharmony_ci * 15 High threshold (Less sensitive) 20398c2ecf20Sopenharmony_ci */ 20408c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_BD_LVSENS 0x0f 20418c2ecf20Sopenharmony_ci 20428c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5(channel) (0x305 + channel * 0x08) 20438c2ecf20Sopenharmony_ci/* 20448c2ecf20Sopenharmony_ci * Define the threshold of temporal sensitivity for night detection. 20458c2ecf20Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 20468c2ecf20Sopenharmony_ci * : : 20478c2ecf20Sopenharmony_ci * 15 High threshold (Less sensitive) 20488c2ecf20Sopenharmony_ci */ 20498c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS_SHIFT 4 20508c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS (0x0f << 4) 20518c2ecf20Sopenharmony_ci/* 20528c2ecf20Sopenharmony_ci * Define the threshold of level for night detection. 20538c2ecf20Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 20548c2ecf20Sopenharmony_ci * : : 20558c2ecf20Sopenharmony_ci * 3 High threshold (Less sensitive) 20568c2ecf20Sopenharmony_ci */ 20578c2ecf20Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_LVSENS 0x0f 20588c2ecf20Sopenharmony_ci 20598c2ecf20Sopenharmony_ci/* 20608c2ecf20Sopenharmony_ci * [11:0] The base address of the motion detection buffer. This address is in 20618c2ecf20Sopenharmony_ci * unit of 64K bytes. The generated DDR address will be {MD_BASE_ADDR, 20628c2ecf20Sopenharmony_ci * 16"h0000}. The default value should be 12"h000 20638c2ecf20Sopenharmony_ci */ 20648c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_BASE_ADDR 0x380 20658c2ecf20Sopenharmony_ci 20668c2ecf20Sopenharmony_ci/* 20678c2ecf20Sopenharmony_ci * This controls the channel of the motion detection result shown in register 20688c2ecf20Sopenharmony_ci * 0x3a0 ~ 0x3b7. Before reading back motion result, always set this first. 20698c2ecf20Sopenharmony_ci */ 20708c2ecf20Sopenharmony_ci#define TW5864_INDIR_RGR_MOTION_SEL 0x382 20718c2ecf20Sopenharmony_ci 20728c2ecf20Sopenharmony_ci/* [15:0] MD strobe has been performed at channel n (read only) */ 20738c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_STRB 0x386 20748c2ecf20Sopenharmony_ci/* NO_VIDEO Detected from channel n (read only) */ 20758c2ecf20Sopenharmony_ci#define TW5864_INDIR_NOVID_DET 0x388 20768c2ecf20Sopenharmony_ci/* Motion Detected from channel n (read only) */ 20778c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_DET 0x38a 20788c2ecf20Sopenharmony_ci/* Blind Detected from channel n (read only) */ 20798c2ecf20Sopenharmony_ci#define TW5864_INDIR_BD_DET 0x38c 20808c2ecf20Sopenharmony_ci/* Night Detected from channel n (read only) */ 20818c2ecf20Sopenharmony_ci#define TW5864_INDIR_ND_DET 0x38e 20828c2ecf20Sopenharmony_ci 20838c2ecf20Sopenharmony_ci/* 192 bit motion flag of the channel specified by RGR_MOTION_SEL in 0x382 */ 20848c2ecf20Sopenharmony_ci#define TW5864_INDIR_MOTION_FLAG 0x3a0 20858c2ecf20Sopenharmony_ci#define TW5864_INDIR_MOTION_FLAG_BYTE_COUNT 24 20868c2ecf20Sopenharmony_ci 20878c2ecf20Sopenharmony_ci/* 20888c2ecf20Sopenharmony_ci * [9:0] The motion cell count of a specific channel selected by 0x382. This is 20898c2ecf20Sopenharmony_ci * for DI purpose 20908c2ecf20Sopenharmony_ci */ 20918c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_DI_CNT 0x3b8 20928c2ecf20Sopenharmony_ci/* The motion detection cell sensitivity for DI purpose */ 20938c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_DI_CELLSENS 0x3ba 20948c2ecf20Sopenharmony_ci/* The motion detection threshold level for DI purpose */ 20958c2ecf20Sopenharmony_ci#define TW5864_INDIR_MD_DI_LVSENS 0x3bb 20968c2ecf20Sopenharmony_ci 20978c2ecf20Sopenharmony_ci/* 192 bit motion mask of the channel specified by MASK_CH_SEL in 0x3fe */ 20988c2ecf20Sopenharmony_ci#define TW5864_INDIR_MOTION_MASK 0x3e0 20998c2ecf20Sopenharmony_ci#define TW5864_INDIR_MOTION_MASK_BYTE_COUNT 24 21008c2ecf20Sopenharmony_ci 21018c2ecf20Sopenharmony_ci/* [4:0] The channel selection to access masks in 0x3e0 ~ 0x3f7 */ 21028c2ecf20Sopenharmony_ci#define TW5864_INDIR_MASK_CH_SEL 0x3fe 21038c2ecf20Sopenharmony_ci 21048c2ecf20Sopenharmony_ci/* Clock PLL / Analog IP Control */ 21058c2ecf20Sopenharmony_ci/* Some registers skipped */ 21068c2ecf20Sopenharmony_ci 21078c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_DQS_SEL0 0xee6 21088c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_DQS_SEL1 0xee7 21098c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_CLK90_SEL 0xee8 21108c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_TEST_SEL_AND_TAP_S 0xee9 21118c2ecf20Sopenharmony_ci 21128c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_DQS_SEL0 0xeeb 21138c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_DQS_SEL1 0xeec 21148c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_CLK90_SEL 0xeed 21158c2ecf20Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_TEST_SEL_AND_TAP_S 0xeee 21168c2ecf20Sopenharmony_ci 21178c2ecf20Sopenharmony_ci#define TW5864_INDIR_RESET 0xef0 21188c2ecf20Sopenharmony_ci#define TW5864_INDIR_RESET_VD BIT(7) 21198c2ecf20Sopenharmony_ci#define TW5864_INDIR_RESET_DLL BIT(6) 21208c2ecf20Sopenharmony_ci#define TW5864_INDIR_RESET_MUX_CORE BIT(5) 21218c2ecf20Sopenharmony_ci 21228c2ecf20Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL 0xefd 21238c2ecf20Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL_PV(channel) BIT(channel) 21248c2ecf20Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL_VD(channel) BIT(channel + 4) 21258c2ecf20Sopenharmony_ci 21268c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL 0xefe 21278c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_VD_SHIFT 0 21288c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_VD_MASK 0x3 21298c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV_SHIFT 2 21308c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV_MASK (0x3 << 2) 21318c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV2_SHIFT 4 21328c2ecf20Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV2_MASK (0x3 << 4) 2133