162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * TW5864 driver - registers description 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2016 Bluecherry, LLC <maintainers@bluecherrydvr.com> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci/* According to TW5864_datasheet_0.6d.pdf, tw5864b1-ds.pdf */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* Register Description - Direct Map Space */ 1162306a36Sopenharmony_ci/* 0x0000 ~ 0x1ffc - H264 Register Map */ 1262306a36Sopenharmony_ci/* [15:0] The Version register for H264 core (Read Only) */ 1362306a36Sopenharmony_ci#define TW5864_H264REV 0x0000 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#define TW5864_EMU 0x0004 1662306a36Sopenharmony_ci/* Define controls in register TW5864_EMU */ 1762306a36Sopenharmony_ci/* DDR controller enabled */ 1862306a36Sopenharmony_ci#define TW5864_EMU_EN_DDR BIT(0) 1962306a36Sopenharmony_ci/* Enable bit for Inter module */ 2062306a36Sopenharmony_ci#define TW5864_EMU_EN_ME BIT(1) 2162306a36Sopenharmony_ci/* Enable bit for Sensor Interface module */ 2262306a36Sopenharmony_ci#define TW5864_EMU_EN_SEN BIT(2) 2362306a36Sopenharmony_ci/* Enable bit for Host Burst Access */ 2462306a36Sopenharmony_ci#define TW5864_EMU_EN_BHOST BIT(3) 2562306a36Sopenharmony_ci/* Enable bit for Loop Filter module */ 2662306a36Sopenharmony_ci#define TW5864_EMU_EN_LPF BIT(4) 2762306a36Sopenharmony_ci/* Enable bit for PLBK module */ 2862306a36Sopenharmony_ci#define TW5864_EMU_EN_PLBK BIT(5) 2962306a36Sopenharmony_ci/* 3062306a36Sopenharmony_ci * Video Frame mapping in DDR 3162306a36Sopenharmony_ci * 00 CIF 3262306a36Sopenharmony_ci * 01 D1 3362306a36Sopenharmony_ci * 10 Reserved 3462306a36Sopenharmony_ci * 11 Reserved 3562306a36Sopenharmony_ci * 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_ci#define TW5864_DSP_FRAME_TYPE (3 << 6) 3862306a36Sopenharmony_ci#define TW5864_DSP_FRAME_TYPE_D1 BIT(6) 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#define TW5864_UNDECLARED_H264REV_PART2 0x0008 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define TW5864_SLICE 0x000c 4362306a36Sopenharmony_ci/* Define controls in register TW5864_SLICE */ 4462306a36Sopenharmony_ci/* VLC Slice end flag */ 4562306a36Sopenharmony_ci#define TW5864_VLC_SLICE_END BIT(0) 4662306a36Sopenharmony_ci/* Master Slice End Flag */ 4762306a36Sopenharmony_ci#define TW5864_MAS_SLICE_END BIT(4) 4862306a36Sopenharmony_ci/* Host to start a new slice Address */ 4962306a36Sopenharmony_ci#define TW5864_START_NSLICE BIT(15) 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* 5262306a36Sopenharmony_ci * [15:0] Two bit for each channel (channel 0 ~ 7). Each two bits are the buffer 5362306a36Sopenharmony_ci * pointer for the last encoded frame of the corresponding channel. 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ci#define TW5864_ENC_BUF_PTR_REC1 0x0010 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* [5:0] DSP_MB_QP and [15:10] DSP_LPF_OFFSET */ 5862306a36Sopenharmony_ci#define TW5864_DSP_QP 0x0018 5962306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_QP */ 6062306a36Sopenharmony_ci/* [5:0] H264 QP Value for codec */ 6162306a36Sopenharmony_ci#define TW5864_DSP_MB_QP 0x003f 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * [15:10] H264 LPF_OFFSET Address 6462306a36Sopenharmony_ci * (Default 0) 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_ci#define TW5864_DSP_LPF_OFFSET 0xfc00 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define TW5864_DSP_CODEC 0x001c 6962306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_CODEC */ 7062306a36Sopenharmony_ci/* 7162306a36Sopenharmony_ci * 0: Encode (TW5864 Default) 7262306a36Sopenharmony_ci * 1: Decode 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#define TW5864_DSP_CODEC_MODE BIT(0) 7562306a36Sopenharmony_ci/* 7662306a36Sopenharmony_ci * 0->3 4 VLC data buffer in DDR (1M each) 7762306a36Sopenharmony_ci * 0->7 8 VLC data buffer in DDR (512k each) 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci#define TW5864_VLC_BUF_ID (7 << 2) 8062306a36Sopenharmony_ci/* 8162306a36Sopenharmony_ci * 0 4CIF in 1 MB 8262306a36Sopenharmony_ci * 1 1CIF in 1 MB 8362306a36Sopenharmony_ci */ 8462306a36Sopenharmony_ci#define TW5864_CIF_MAP_MD BIT(6) 8562306a36Sopenharmony_ci/* 8662306a36Sopenharmony_ci * 0 2 falf D1 in 1 MB 8762306a36Sopenharmony_ci * 1 1 half D1 in 1 MB 8862306a36Sopenharmony_ci */ 8962306a36Sopenharmony_ci#define TW5864_HD1_MAP_MD BIT(7) 9062306a36Sopenharmony_ci/* VLC Stream valid */ 9162306a36Sopenharmony_ci#define TW5864_VLC_VLD BIT(8) 9262306a36Sopenharmony_ci/* MV Vector Valid */ 9362306a36Sopenharmony_ci#define TW5864_MV_VECT_VLD BIT(9) 9462306a36Sopenharmony_ci/* MV Flag Valid */ 9562306a36Sopenharmony_ci#define TW5864_MV_FLAG_VLD BIT(10) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define TW5864_DSP_SEN 0x0020 9862306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_SEN */ 9962306a36Sopenharmony_ci/* Org Buffer Base for Luma (default 0) */ 10062306a36Sopenharmony_ci#define TW5864_DSP_SEN_PIC_LU 0x000f 10162306a36Sopenharmony_ci/* Org Buffer Base for Chroma (default 4) */ 10262306a36Sopenharmony_ci#define TW5864_DSP_SEN_PIC_CHM 0x00f0 10362306a36Sopenharmony_ci/* Maximum Number of Buffers (default 4) */ 10462306a36Sopenharmony_ci#define TW5864_DSP_SEN_PIC_MAX 0x0700 10562306a36Sopenharmony_ci/* 10662306a36Sopenharmony_ci * Original Frame D1 or HD1 switch 10762306a36Sopenharmony_ci * (Default 0) 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci#define TW5864_DSP_SEN_HFULL 0x1000 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define TW5864_DSP_REF_PIC 0x0024 11262306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_REF_PIC */ 11362306a36Sopenharmony_ci/* Ref Buffer Base for Luma (default 0) */ 11462306a36Sopenharmony_ci#define TW5864_DSP_REF_PIC_LU 0x000f 11562306a36Sopenharmony_ci/* Ref Buffer Base for Chroma (default 4) */ 11662306a36Sopenharmony_ci#define TW5864_DSP_REF_PIC_CHM 0x00f0 11762306a36Sopenharmony_ci/* Maximum Number of Buffers (default 4) */ 11862306a36Sopenharmony_ci#define TW5864_DSP_REF_PIC_MAX 0x0700 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* [15:0] SEN_EN_CH[n] SENIF original frame capture enable for each channel */ 12162306a36Sopenharmony_ci#define TW5864_SEN_EN_CH 0x0028 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci#define TW5864_DSP 0x002c 12462306a36Sopenharmony_ci/* Define controls in register TW5864_DSP */ 12562306a36Sopenharmony_ci/* The ID for channel selected for encoding operation */ 12662306a36Sopenharmony_ci#define TW5864_DSP_ENC_CHN 0x000f 12762306a36Sopenharmony_ci/* See DSP_MB_DELAY below */ 12862306a36Sopenharmony_ci#define TW5864_DSP_MB_WAIT 0x0010 12962306a36Sopenharmony_ci/* 13062306a36Sopenharmony_ci * DSP Chroma Switch 13162306a36Sopenharmony_ci * 0 DDRB 13262306a36Sopenharmony_ci * 1 DDRA 13362306a36Sopenharmony_ci */ 13462306a36Sopenharmony_ci#define TW5864_DSP_CHROM_SW 0x0020 13562306a36Sopenharmony_ci/* VLC Flow Control: 1 for enable */ 13662306a36Sopenharmony_ci#define TW5864_DSP_FLW_CNTL 0x0040 13762306a36Sopenharmony_ci/* 13862306a36Sopenharmony_ci * If DSP_MB_WAIT == 0, MB delay is DSP_MB_DELAY * 16 13962306a36Sopenharmony_ci * If DSP_MB_DELAY == 1, MB delay is DSP_MB_DELAY * 128 14062306a36Sopenharmony_ci */ 14162306a36Sopenharmony_ci#define TW5864_DSP_MB_DELAY 0x0f00 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci#define TW5864_DDR 0x0030 14462306a36Sopenharmony_ci/* Define controls in register TW5864_DDR */ 14562306a36Sopenharmony_ci/* DDR Single Access Page Number */ 14662306a36Sopenharmony_ci#define TW5864_DDR_PAGE_CNTL 0x00ff 14762306a36Sopenharmony_ci/* DDR-DPR Burst Read Enable */ 14862306a36Sopenharmony_ci#define TW5864_DDR_BRST_EN BIT(13) 14962306a36Sopenharmony_ci/* 15062306a36Sopenharmony_ci * DDR A/B Select as HOST access 15162306a36Sopenharmony_ci * 0 Select DDRA 15262306a36Sopenharmony_ci * 1 Select DDRB 15362306a36Sopenharmony_ci */ 15462306a36Sopenharmony_ci#define TW5864_DDR_AB_SEL BIT(14) 15562306a36Sopenharmony_ci/* 15662306a36Sopenharmony_ci * DDR Access Mode Select 15762306a36Sopenharmony_ci * 0 Single R/W Access (Host <-> DDR) 15862306a36Sopenharmony_ci * 1 Burst R/W Access (Host <-> DPR) 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_ci#define TW5864_DDR_MODE BIT(15) 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci/* The original frame capture pointer. Two bits for each channel */ 16362306a36Sopenharmony_ci/* SENIF_ORG_FRM_PTR [15:0] */ 16462306a36Sopenharmony_ci#define TW5864_SENIF_ORG_FRM_PTR1 0x0038 16562306a36Sopenharmony_ci/* SENIF_ORG_FRM_PTR [31:16] */ 16662306a36Sopenharmony_ci#define TW5864_SENIF_ORG_FRM_PTR2 0x003c 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci#define TW5864_DSP_SEN_MODE 0x0040 16962306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_SEN_MODE */ 17062306a36Sopenharmony_ci#define TW5864_DSP_SEN_MODE_CH0 0x000f 17162306a36Sopenharmony_ci#define TW5864_DSP_SEN_MODE_CH1 0x00f0 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* 17462306a36Sopenharmony_ci * [15:0]: ENC_BUF_PTR_REC[31:16] Two bit for each channel (channel 8 ~ 15). 17562306a36Sopenharmony_ci * Each two bits are the buffer pointer for the last encoded frame of a channel 17662306a36Sopenharmony_ci */ 17762306a36Sopenharmony_ci#define TW5864_ENC_BUF_PTR_REC2 0x004c 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* Current MV Flag Status Pointer for Channel n. (Read only) */ 18062306a36Sopenharmony_ci/* 18162306a36Sopenharmony_ci * [1:0] CH0_MV_PTR, ..., [15:14] CH7_MV_PTR 18262306a36Sopenharmony_ci */ 18362306a36Sopenharmony_ci#define TW5864_CH_MV_PTR1 0x0060 18462306a36Sopenharmony_ci/* 18562306a36Sopenharmony_ci * [1:0] CH8_MV_PTR, ..., [15:14] CH15_MV_PTR 18662306a36Sopenharmony_ci */ 18762306a36Sopenharmony_ci#define TW5864_CH_MV_PTR2 0x0064 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci/* 19062306a36Sopenharmony_ci * [15:0] Reset Current MV Flag Status Pointer for Channel n (one bit each) 19162306a36Sopenharmony_ci */ 19262306a36Sopenharmony_ci#define TW5864_RST_MV_PTR 0x0068 19362306a36Sopenharmony_ci#define TW5864_INTERLACING 0x0200 19462306a36Sopenharmony_ci/* Define controls in register TW5864_INTERLACING */ 19562306a36Sopenharmony_ci/* 19662306a36Sopenharmony_ci * Inter_Mode Start. 2-nd bit? A guess. Missing in datasheet. Without this bit 19762306a36Sopenharmony_ci * set, the output video is interlaced (stripy). 19862306a36Sopenharmony_ci */ 19962306a36Sopenharmony_ci#define TW5864_DSP_INTER_ST BIT(1) 20062306a36Sopenharmony_ci/* Deinterlacer Enable */ 20162306a36Sopenharmony_ci#define TW5864_DI_EN BIT(2) 20262306a36Sopenharmony_ci/* 20362306a36Sopenharmony_ci * De-interlacer Mode 20462306a36Sopenharmony_ci * 1 Shuffled frame 20562306a36Sopenharmony_ci * 0 Normal Un-Shuffled Frame 20662306a36Sopenharmony_ci */ 20762306a36Sopenharmony_ci#define TW5864_DI_MD BIT(3) 20862306a36Sopenharmony_ci/* 20962306a36Sopenharmony_ci * Down scale original frame in X direction 21062306a36Sopenharmony_ci * 11: Un-used 21162306a36Sopenharmony_ci * 10: down-sample to 1/4 21262306a36Sopenharmony_ci * 01: down-sample to 1/2 21362306a36Sopenharmony_ci * 00: down-sample disabled 21462306a36Sopenharmony_ci */ 21562306a36Sopenharmony_ci#define TW5864_DSP_DWN_X (3 << 4) 21662306a36Sopenharmony_ci/* 21762306a36Sopenharmony_ci * Down scale original frame in Y direction 21862306a36Sopenharmony_ci * 11: Un-used 21962306a36Sopenharmony_ci * 10: down-sample to 1/4 22062306a36Sopenharmony_ci * 01: down-sample to 1/2 22162306a36Sopenharmony_ci * 00: down-sample disabled 22262306a36Sopenharmony_ci */ 22362306a36Sopenharmony_ci#define TW5864_DSP_DWN_Y (3 << 6) 22462306a36Sopenharmony_ci/* 22562306a36Sopenharmony_ci * 1 Dual Stream 22662306a36Sopenharmony_ci * 0 Single Stream 22762306a36Sopenharmony_ci */ 22862306a36Sopenharmony_ci#define TW5864_DUAL_STR BIT(8) 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define TW5864_DSP_REF 0x0204 23162306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_REF */ 23262306a36Sopenharmony_ci/* Number of reference frame (Default 1 for TW5864B) */ 23362306a36Sopenharmony_ci#define TW5864_DSP_REF_FRM 0x000f 23462306a36Sopenharmony_ci/* Window size */ 23562306a36Sopenharmony_ci#define TW5864_DSP_WIN_SIZE 0x02f0 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci#define TW5864_DSP_SKIP 0x0208 23862306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_SKIP */ 23962306a36Sopenharmony_ci/* 24062306a36Sopenharmony_ci * Skip Offset Enable bit 24162306a36Sopenharmony_ci * 0 DSP_SKIP_OFFSET value is not used (default 8) 24262306a36Sopenharmony_ci * 1 DSP_SKIP_OFFSET value is used in HW 24362306a36Sopenharmony_ci */ 24462306a36Sopenharmony_ci#define TW5864_DSP_SKIP_OFEN 0x0080 24562306a36Sopenharmony_ci/* Skip mode cost offset (default 8) */ 24662306a36Sopenharmony_ci#define TW5864_DSP_SKIP_OFFSET 0x007f 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci#define TW5864_MOTION_SEARCH_ETC 0x020c 24962306a36Sopenharmony_ci/* Define controls in register TW5864_MOTION_SEARCH_ETC */ 25062306a36Sopenharmony_ci/* Enable quarter pel search mode */ 25162306a36Sopenharmony_ci#define TW5864_QPEL_EN BIT(0) 25262306a36Sopenharmony_ci/* Enable half pel search mode */ 25362306a36Sopenharmony_ci#define TW5864_HPEL_EN BIT(1) 25462306a36Sopenharmony_ci/* Enable motion search mode */ 25562306a36Sopenharmony_ci#define TW5864_ME_EN BIT(2) 25662306a36Sopenharmony_ci/* Enable Intra mode */ 25762306a36Sopenharmony_ci#define TW5864_INTRA_EN BIT(3) 25862306a36Sopenharmony_ci/* Enable Skip Mode */ 25962306a36Sopenharmony_ci#define TW5864_SKIP_EN BIT(4) 26062306a36Sopenharmony_ci/* Search Option (Default 2"b01) */ 26162306a36Sopenharmony_ci#define TW5864_SRCH_OPT (3 << 5) 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci#define TW5864_DSP_ENC_REC 0x0210 26462306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_ENC_REC */ 26562306a36Sopenharmony_ci/* Reference Buffer Pointer for encoding */ 26662306a36Sopenharmony_ci#define TW5864_DSP_ENC_REF_PTR 0x0007 26762306a36Sopenharmony_ci/* Reconstruct Buffer pointer */ 26862306a36Sopenharmony_ci#define TW5864_DSP_REC_BUF_PTR 0x7000 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci/* [15:0] Lambda Value for H264 */ 27162306a36Sopenharmony_ci#define TW5864_DSP_REF_MVP_LAMBDA 0x0214 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB 0x0218 27462306a36Sopenharmony_ci/* Define controls in register TW5864_DSP_PIC_MAX_MB */ 27562306a36Sopenharmony_ci/* The MB number in Y direction for a frame */ 27662306a36Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB_Y 0x007f 27762306a36Sopenharmony_ci/* The MB number in X direction for a frame */ 27862306a36Sopenharmony_ci#define TW5864_DSP_PIC_MAX_MB_X 0x7f00 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci/* The original frame pointer for encoding */ 28162306a36Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_REG 0x021c 28262306a36Sopenharmony_ci/* Mask to use with TW5864_DSP_ENC_ORG_PTR */ 28362306a36Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_MASK 0x7000 28462306a36Sopenharmony_ci/* Number of bits to shift with TW5864_DSP_ENC_ORG_PTR */ 28562306a36Sopenharmony_ci#define TW5864_DSP_ENC_ORG_PTR_SHIFT 12 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci/* DDR base address of OSD rectangle attribute data */ 28862306a36Sopenharmony_ci#define TW5864_DSP_OSD_ATTRI_BASE 0x0220 28962306a36Sopenharmony_ci/* OSD enable bit for each channel */ 29062306a36Sopenharmony_ci#define TW5864_DSP_OSD_ENABLE 0x0228 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci/* 0x0280 ~ 0x029c - Motion Vector for 1st 4x4 Block, e.g., 80 (X), 84 (Y) */ 29362306a36Sopenharmony_ci#define TW5864_ME_MV_VEC1 0x0280 29462306a36Sopenharmony_ci/* 0x02a0 ~ 0x02bc - Motion Vector for 2nd 4x4 Block, e.g., A0 (X), A4 (Y) */ 29562306a36Sopenharmony_ci#define TW5864_ME_MV_VEC2 0x02a0 29662306a36Sopenharmony_ci/* 0x02c0 ~ 0x02dc - Motion Vector for 3rd 4x4 Block, e.g., C0 (X), C4 (Y) */ 29762306a36Sopenharmony_ci#define TW5864_ME_MV_VEC3 0x02c0 29862306a36Sopenharmony_ci/* 0x02e0 ~ 0x02fc - Motion Vector for 4th 4x4 Block, e.g., E0 (X), E4 (Y) */ 29962306a36Sopenharmony_ci#define TW5864_ME_MV_VEC4 0x02e0 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci/* 30262306a36Sopenharmony_ci * [5:0] 30362306a36Sopenharmony_ci * if (intra16x16_cost < (intra4x4_cost+dsp_i4x4_offset)) 30462306a36Sopenharmony_ci * Intra_mode = intra16x16_mode 30562306a36Sopenharmony_ci * Else 30662306a36Sopenharmony_ci * Intra_mode = intra4x4_mode 30762306a36Sopenharmony_ci */ 30862306a36Sopenharmony_ci#define TW5864_DSP_I4x4_OFFSET 0x040c 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci/* 31162306a36Sopenharmony_ci * [6:4] 31262306a36Sopenharmony_ci * 0x5 Only 4x4 31362306a36Sopenharmony_ci * 0x6 Only 16x16 31462306a36Sopenharmony_ci * 0x7 16x16 & 4x4 31562306a36Sopenharmony_ci */ 31662306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE 0x0410 31762306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_SHIFT 4 31862306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_MASK (7 << 4) 31962306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_4x4 0x5 32062306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_16x16 0x6 32162306a36Sopenharmony_ci#define TW5864_DSP_INTRA_MODE_4x4_AND_16x16 0x7 32262306a36Sopenharmony_ci/* 32362306a36Sopenharmony_ci * [5:0] WEIGHT Factor for I4x4 cost calculation (QP dependent) 32462306a36Sopenharmony_ci */ 32562306a36Sopenharmony_ci#define TW5864_DSP_I4x4_WEIGHT 0x0414 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* 32862306a36Sopenharmony_ci * [7:0] Offset used to affect Intra/ME model decision 32962306a36Sopenharmony_ci * If (me_cost < intra_cost + dsp_resid_mode_offset) 33062306a36Sopenharmony_ci * Pred_Mode = me_mode 33162306a36Sopenharmony_ci * Else 33262306a36Sopenharmony_ci * Pred_mode = intra_mode 33362306a36Sopenharmony_ci */ 33462306a36Sopenharmony_ci#define TW5864_DSP_RESID_MODE_OFFSET 0x0604 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci/* 0x0800 ~ 0x09ff - Quantization TABLE Values */ 33762306a36Sopenharmony_ci#define TW5864_QUAN_TAB 0x0800 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci/* Valid channel value [0; f], frame value [0; 3] */ 34062306a36Sopenharmony_ci#define TW5864_RT_CNTR_CH_FRM(channel, frame) \ 34162306a36Sopenharmony_ci (0x0c00 | (channel << 4) | (frame << 2)) 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci#define TW5864_FRAME_BUS1 0x0d00 34462306a36Sopenharmony_ci/* 34562306a36Sopenharmony_ci * 1 Progressive in part A in bus n 34662306a36Sopenharmony_ci * 0 Interlaced in part A in bus n 34762306a36Sopenharmony_ci */ 34862306a36Sopenharmony_ci#define TW5864_PROG_A BIT(0) 34962306a36Sopenharmony_ci/* 35062306a36Sopenharmony_ci * 1 Progressive in part B in bus n 35162306a36Sopenharmony_ci * 0 Interlaced in part B in bus n 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_ci#define TW5864_PROG_B BIT(1) 35462306a36Sopenharmony_ci/* 35562306a36Sopenharmony_ci * 1 Frame Mode in bus n 35662306a36Sopenharmony_ci * 0 Field Mode in bus n 35762306a36Sopenharmony_ci */ 35862306a36Sopenharmony_ci#define TW5864_FRAME BIT(2) 35962306a36Sopenharmony_ci/* 36062306a36Sopenharmony_ci * 0 4CIF in bus n 36162306a36Sopenharmony_ci * 1 1D1 + 4 CIF in bus n 36262306a36Sopenharmony_ci * 2 2D1 in bus n 36362306a36Sopenharmony_ci */ 36462306a36Sopenharmony_ci#define TW5864_BUS_D1 (3 << 3) 36562306a36Sopenharmony_ci/* Bus 1 goes in TW5864_FRAME_BUS1 in [4:0] */ 36662306a36Sopenharmony_ci/* Bus 2 goes in TW5864_FRAME_BUS1 in [12:8] */ 36762306a36Sopenharmony_ci#define TW5864_FRAME_BUS2 0x0d04 36862306a36Sopenharmony_ci/* Bus 3 goes in TW5864_FRAME_BUS2 in [4:0] */ 36962306a36Sopenharmony_ci/* Bus 4 goes in TW5864_FRAME_BUS2 in [12:8] */ 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci/* [15:0] Horizontal Mirror for channel n */ 37262306a36Sopenharmony_ci#define TW5864_SENIF_HOR_MIR 0x0d08 37362306a36Sopenharmony_ci/* [15:0] Vertical Mirror for channel n */ 37462306a36Sopenharmony_ci#define TW5864_SENIF_VER_MIR 0x0d0c 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci/* 37762306a36Sopenharmony_ci * FRAME_WIDTH_BUSn_A 37862306a36Sopenharmony_ci * 0x15f: 4 CIF 37962306a36Sopenharmony_ci * 0x2cf: 1 D1 + 3 CIF 38062306a36Sopenharmony_ci * 0x2cf: 2 D1 38162306a36Sopenharmony_ci * FRAME_WIDTH_BUSn_B 38262306a36Sopenharmony_ci * 0x15f: 4 CIF 38362306a36Sopenharmony_ci * 0x2cf: 1 D1 + 3 CIF 38462306a36Sopenharmony_ci * 0x2cf: 2 D1 38562306a36Sopenharmony_ci * FRAME_HEIGHT_BUSn_A 38662306a36Sopenharmony_ci * 0x11f: 4CIF (PAL) 38762306a36Sopenharmony_ci * 0x23f: 1D1 + 3CIF (PAL) 38862306a36Sopenharmony_ci * 0x23f: 2 D1 (PAL) 38962306a36Sopenharmony_ci * 0x0ef: 4CIF (NTSC) 39062306a36Sopenharmony_ci * 0x1df: 1D1 + 3CIF (NTSC) 39162306a36Sopenharmony_ci * 0x1df: 2 D1 (NTSC) 39262306a36Sopenharmony_ci * FRAME_HEIGHT_BUSn_B 39362306a36Sopenharmony_ci * 0x11f: 4CIF (PAL) 39462306a36Sopenharmony_ci * 0x23f: 1D1 + 3CIF (PAL) 39562306a36Sopenharmony_ci * 0x23f: 2 D1 (PAL) 39662306a36Sopenharmony_ci * 0x0ef: 4CIF (NTSC) 39762306a36Sopenharmony_ci * 0x1df: 1D1 + 3CIF (NTSC) 39862306a36Sopenharmony_ci * 0x1df: 2 D1 (NTSC) 39962306a36Sopenharmony_ci */ 40062306a36Sopenharmony_ci#define TW5864_FRAME_WIDTH_BUS_A(bus) (0x0d10 + 0x0010 * bus) 40162306a36Sopenharmony_ci#define TW5864_FRAME_WIDTH_BUS_B(bus) (0x0d14 + 0x0010 * bus) 40262306a36Sopenharmony_ci#define TW5864_FRAME_HEIGHT_BUS_A(bus) (0x0d18 + 0x0010 * bus) 40362306a36Sopenharmony_ci#define TW5864_FRAME_HEIGHT_BUS_B(bus) (0x0d1c + 0x0010 * bus) 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci/* 40662306a36Sopenharmony_ci * 1: the bus mapped Channel n Full D1 40762306a36Sopenharmony_ci * 0: the bus mapped Channel n Half D1 40862306a36Sopenharmony_ci */ 40962306a36Sopenharmony_ci#define TW5864_FULL_HALF_FLAG 0x0d50 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci/* 41262306a36Sopenharmony_ci * 0 The bus mapped Channel select partA Mode 41362306a36Sopenharmony_ci * 1 The bus mapped Channel select partB Mode 41462306a36Sopenharmony_ci */ 41562306a36Sopenharmony_ci#define TW5864_FULL_HALF_MODE_SEL 0x0d54 41662306a36Sopenharmony_ci 41762306a36Sopenharmony_ci#define TW5864_VLC 0x1000 41862306a36Sopenharmony_ci/* Define controls in register TW5864_VLC */ 41962306a36Sopenharmony_ci/* QP Value used by H264 CAVLC */ 42062306a36Sopenharmony_ci#define TW5864_VLC_SLICE_QP 0x003f 42162306a36Sopenharmony_ci/* 42262306a36Sopenharmony_ci * Swap byte order of VLC stream in d-word. 42362306a36Sopenharmony_ci * 1 Normal (VLC output= [31:0]) 42462306a36Sopenharmony_ci * 0 Swap (VLC output={[23:16],[31:24],[7:0], [15:8]}) 42562306a36Sopenharmony_ci */ 42662306a36Sopenharmony_ci#define TW5864_VLC_BYTE_SWP BIT(6) 42762306a36Sopenharmony_ci/* Enable Adding 03 circuit for VLC stream */ 42862306a36Sopenharmony_ci#define TW5864_VLC_ADD03_EN BIT(7) 42962306a36Sopenharmony_ci/* Number of bit for VLC bit Align */ 43062306a36Sopenharmony_ci#define TW5864_VLC_BIT_ALIGN_SHIFT 8 43162306a36Sopenharmony_ci#define TW5864_VLC_BIT_ALIGN_MASK (0x1f << 8) 43262306a36Sopenharmony_ci/* 43362306a36Sopenharmony_ci * Synchronous Interface select for VLC Stream 43462306a36Sopenharmony_ci * 1 CDC_VLCS_MAS read VLC stream 43562306a36Sopenharmony_ci * 0 CPU read VLC stream 43662306a36Sopenharmony_ci */ 43762306a36Sopenharmony_ci#define TW5864_VLC_INF_SEL BIT(13) 43862306a36Sopenharmony_ci/* Enable VLC overflow control */ 43962306a36Sopenharmony_ci#define TW5864_VLC_OVFL_CNTL BIT(14) 44062306a36Sopenharmony_ci/* 44162306a36Sopenharmony_ci * 1 PCI Master Mode 44262306a36Sopenharmony_ci * 0 Non PCI Master Mode 44362306a36Sopenharmony_ci */ 44462306a36Sopenharmony_ci#define TW5864_VLC_PCI_SEL BIT(15) 44562306a36Sopenharmony_ci/* 44662306a36Sopenharmony_ci * 0 Enable Adding 03 to VLC header and stream 44762306a36Sopenharmony_ci * 1 Disable Adding 03 to VLC header of "00000001" 44862306a36Sopenharmony_ci */ 44962306a36Sopenharmony_ci#define TW5864_VLC_A03_DISAB BIT(16) 45062306a36Sopenharmony_ci/* 45162306a36Sopenharmony_ci * Status of VLC stream in DDR (one bit for each buffer) 45262306a36Sopenharmony_ci * 1 VLC is ready in buffer n (HW set) 45362306a36Sopenharmony_ci * 0 VLC is not ready in buffer n (SW clear) 45462306a36Sopenharmony_ci */ 45562306a36Sopenharmony_ci#define TW5864_VLC_BUF_RDY_SHIFT 24 45662306a36Sopenharmony_ci#define TW5864_VLC_BUF_RDY_MASK (0xff << 24) 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci/* Total number of bit in the slice */ 45962306a36Sopenharmony_ci#define TW5864_SLICE_TOTAL_BIT 0x1004 46062306a36Sopenharmony_ci/* Total number of bit in the residue */ 46162306a36Sopenharmony_ci#define TW5864_RES_TOTAL_BIT 0x1008 46262306a36Sopenharmony_ci 46362306a36Sopenharmony_ci#define TW5864_VLC_BUF 0x100c 46462306a36Sopenharmony_ci/* Define controls in register TW5864_VLC_BUF */ 46562306a36Sopenharmony_ci/* VLC BK0 full status, write '1' to clear */ 46662306a36Sopenharmony_ci#define TW5864_VLC_BK0_FULL BIT(0) 46762306a36Sopenharmony_ci/* VLC BK1 full status, write '1' to clear */ 46862306a36Sopenharmony_ci#define TW5864_VLC_BK1_FULL BIT(1) 46962306a36Sopenharmony_ci/* VLC end slice status, write '1' to clear */ 47062306a36Sopenharmony_ci#define TW5864_VLC_END_SLICE BIT(2) 47162306a36Sopenharmony_ci/* VLC Buffer overflow status, write '1' to clear */ 47262306a36Sopenharmony_ci#define TW5864_DSP_RD_OF BIT(3) 47362306a36Sopenharmony_ci/* VLC string length in either buffer 0 or 1 at end of frame */ 47462306a36Sopenharmony_ci#define TW5864_VLC_STREAM_LEN_SHIFT 4 47562306a36Sopenharmony_ci#define TW5864_VLC_STREAM_LEN_MASK (0x1ff << 4) 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_ci/* [15:0] Total coefficient number in a frame */ 47862306a36Sopenharmony_ci#define TW5864_TOTAL_COEF_NO 0x1010 47962306a36Sopenharmony_ci/* [0] VLC Encoder Interrupt. Write '1' to clear */ 48062306a36Sopenharmony_ci#define TW5864_VLC_DSP_INTR 0x1014 48162306a36Sopenharmony_ci/* [31:0] VLC stream CRC checksum */ 48262306a36Sopenharmony_ci#define TW5864_VLC_STREAM_CRC 0x1018 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci#define TW5864_VLC_RD 0x101c 48562306a36Sopenharmony_ci/* Define controls in register TW5864_VLC_RD */ 48662306a36Sopenharmony_ci/* 48762306a36Sopenharmony_ci * 1 Read VLC lookup Memory 48862306a36Sopenharmony_ci * 0 Read VLC Stream Memory 48962306a36Sopenharmony_ci */ 49062306a36Sopenharmony_ci#define TW5864_VLC_RD_MEM BIT(0) 49162306a36Sopenharmony_ci/* 49262306a36Sopenharmony_ci * 1 Read VLC Stream Memory in burst mode 49362306a36Sopenharmony_ci * 0 Read VLC Stream Memory in single mode 49462306a36Sopenharmony_ci */ 49562306a36Sopenharmony_ci#define TW5864_VLC_RD_BRST BIT(1) 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci/* 0x2000 ~ 0x2ffc - H264 Stream Memory Map */ 49862306a36Sopenharmony_ci/* 49962306a36Sopenharmony_ci * A word is 4 bytes. I.e., 50062306a36Sopenharmony_ci * VLC_STREAM_MEM[0] address: 0x2000 50162306a36Sopenharmony_ci * VLC_STREAM_MEM[1] address: 0x2004 50262306a36Sopenharmony_ci * ... 50362306a36Sopenharmony_ci * VLC_STREAM_MEM[3FF] address: 0x2ffc 50462306a36Sopenharmony_ci */ 50562306a36Sopenharmony_ci#define TW5864_VLC_STREAM_MEM_START 0x2000 50662306a36Sopenharmony_ci#define TW5864_VLC_STREAM_MEM_MAX_OFFSET 0x3ff 50762306a36Sopenharmony_ci#define TW5864_VLC_STREAM_MEM(offset) (TW5864_VLC_STREAM_MEM_START + 4 * offset) 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci/* 0x4000 ~ 0x4ffc - Audio Register Map */ 51062306a36Sopenharmony_ci/* [31:0] config 1ms cnt = Realtime clk/1000 */ 51162306a36Sopenharmony_ci#define TW5864_CFG_1MS_CNT 0x4000 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci#define TW5864_ADPCM 0x4004 51462306a36Sopenharmony_ci/* Define controls in register TW5864_ADPCM */ 51562306a36Sopenharmony_ci/* ADPCM decoder enable */ 51662306a36Sopenharmony_ci#define TW5864_ADPCM_DEC BIT(0) 51762306a36Sopenharmony_ci/* ADPCM input data enable */ 51862306a36Sopenharmony_ci#define TW5864_ADPCM_IN_DATA BIT(1) 51962306a36Sopenharmony_ci/* ADPCM encoder enable */ 52062306a36Sopenharmony_ci#define TW5864_ADPCM_ENC BIT(2) 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_ci#define TW5864_AUD 0x4008 52362306a36Sopenharmony_ci/* Define controls in register TW5864_AUD */ 52462306a36Sopenharmony_ci/* Record path PCM Audio enable bit for each channel */ 52562306a36Sopenharmony_ci#define TW5864_AUD_ORG_CH_EN 0x00ff 52662306a36Sopenharmony_ci/* Speaker path PCM Audio Enable */ 52762306a36Sopenharmony_ci#define TW5864_SPK_ORG_EN BIT(16) 52862306a36Sopenharmony_ci/* 52962306a36Sopenharmony_ci * 0 16bit 53062306a36Sopenharmony_ci * 1 8bit 53162306a36Sopenharmony_ci */ 53262306a36Sopenharmony_ci#define TW5864_AD_BIT_MODE BIT(17) 53362306a36Sopenharmony_ci#define TW5864_AUD_TYPE_SHIFT 18 53462306a36Sopenharmony_ci/* 53562306a36Sopenharmony_ci * 0 PCM 53662306a36Sopenharmony_ci * 3 ADPCM 53762306a36Sopenharmony_ci */ 53862306a36Sopenharmony_ci#define TW5864_AUD_TYPE (0xf << 18) 53962306a36Sopenharmony_ci#define TW5864_AUD_SAMPLE_RATE_SHIFT 22 54062306a36Sopenharmony_ci/* 54162306a36Sopenharmony_ci * 0 8K 54262306a36Sopenharmony_ci * 1 16K 54362306a36Sopenharmony_ci */ 54462306a36Sopenharmony_ci#define TW5864_AUD_SAMPLE_RATE (3 << 22) 54562306a36Sopenharmony_ci/* Channel ID used to select audio channel (0 to 16) for loopback */ 54662306a36Sopenharmony_ci#define TW5864_TESTLOOP_CHID_SHIFT 24 54762306a36Sopenharmony_ci#define TW5864_TESTLOOP_CHID (0x1f << 24) 54862306a36Sopenharmony_ci/* Enable AD Loopback Test */ 54962306a36Sopenharmony_ci#define TW5864_TEST_ADLOOP_EN BIT(30) 55062306a36Sopenharmony_ci/* 55162306a36Sopenharmony_ci * 0 Asynchronous Mode or PCI target mode 55262306a36Sopenharmony_ci * 1 PCI Initiator Mode 55362306a36Sopenharmony_ci */ 55462306a36Sopenharmony_ci#define TW5864_AUD_MODE BIT(31) 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_ci#define TW5864_AUD_ADPCM 0x400c 55762306a36Sopenharmony_ci/* Define controls in register TW5864_AUD_ADPCM */ 55862306a36Sopenharmony_ci/* Record path ADPCM audio channel enable, one bit for each */ 55962306a36Sopenharmony_ci#define TW5864_AUD_ADPCM_CH_EN 0x00ff 56062306a36Sopenharmony_ci/* Speaker path ADPCM audio channel enable */ 56162306a36Sopenharmony_ci#define TW5864_SPK_ADPCM_EN BIT(16) 56262306a36Sopenharmony_ci 56362306a36Sopenharmony_ci#define TW5864_PC_BLOCK_ADPCM_RD_NO 0x4018 56462306a36Sopenharmony_ci#define TW5864_PC_BLOCK_ADPCM_RD_NO_MASK 0x1f 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_ci/* 56762306a36Sopenharmony_ci * For ADPCM_ENC_WR_PTR, ADPCM_ENC_RD_PTR (see below): 56862306a36Sopenharmony_ci * Bit[2:0] ch0 56962306a36Sopenharmony_ci * Bit[5:3] ch1 57062306a36Sopenharmony_ci * Bit[8:6] ch2 57162306a36Sopenharmony_ci * Bit[11:9] ch3 57262306a36Sopenharmony_ci * Bit[14:12] ch4 57362306a36Sopenharmony_ci * Bit[17:15] ch5 57462306a36Sopenharmony_ci * Bit[20:18] ch6 57562306a36Sopenharmony_ci * Bit[23:21] ch7 57662306a36Sopenharmony_ci * Bit[26:24] ch8 57762306a36Sopenharmony_ci * Bit[29:27] ch9 57862306a36Sopenharmony_ci * Bit[32:30] ch10 57962306a36Sopenharmony_ci * Bit[35:33] ch11 58062306a36Sopenharmony_ci * Bit[38:36] ch12 58162306a36Sopenharmony_ci * Bit[41:39] ch13 58262306a36Sopenharmony_ci * Bit[44:42] ch14 58362306a36Sopenharmony_ci * Bit[47:45] ch15 58462306a36Sopenharmony_ci * Bit[50:48] ch16 58562306a36Sopenharmony_ci */ 58662306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_XX_MASK 0x3fff 58762306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_XX_PTR2_SHIFT 30 58862306a36Sopenharmony_ci/* ADPCM_ENC_WR_PTR[29:0] */ 58962306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_WR_PTR1 0x401c 59062306a36Sopenharmony_ci/* ADPCM_ENC_WR_PTR[50:30] */ 59162306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_WR_PTR2 0x4020 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ci/* ADPCM_ENC_RD_PTR[29:0] */ 59462306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_RD_PTR1 0x4024 59562306a36Sopenharmony_ci/* ADPCM_ENC_RD_PTR[50:30] */ 59662306a36Sopenharmony_ci#define TW5864_ADPCM_ENC_RD_PTR2 0x4028 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci/* [3:0] rd ch0, [7:4] rd ch1, [11:8] wr ch0, [15:12] wr ch1 */ 59962306a36Sopenharmony_ci#define TW5864_ADPCM_DEC_RD_WR_PTR 0x402c 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci/* 60262306a36Sopenharmony_ci * For TW5864_AD_ORIG_WR_PTR, TW5864_AD_ORIG_RD_PTR: 60362306a36Sopenharmony_ci * Bit[3:0] ch0 60462306a36Sopenharmony_ci * Bit[7:4] ch1 60562306a36Sopenharmony_ci * Bit[11:8] ch2 60662306a36Sopenharmony_ci * Bit[15:12] ch3 60762306a36Sopenharmony_ci * Bit[19:16] ch4 60862306a36Sopenharmony_ci * Bit[23:20] ch5 60962306a36Sopenharmony_ci * Bit[27:24] ch6 61062306a36Sopenharmony_ci * Bit[31:28] ch7 61162306a36Sopenharmony_ci * Bit[35:32] ch8 61262306a36Sopenharmony_ci * Bit[39:36] ch9 61362306a36Sopenharmony_ci * Bit[43:40] ch10 61462306a36Sopenharmony_ci * Bit[47:44] ch11 61562306a36Sopenharmony_ci * Bit[51:48] ch12 61662306a36Sopenharmony_ci * Bit[55:52] ch13 61762306a36Sopenharmony_ci * Bit[59:56] ch14 61862306a36Sopenharmony_ci * Bit[63:60] ch15 61962306a36Sopenharmony_ci * Bit[67:64] ch16 62062306a36Sopenharmony_ci */ 62162306a36Sopenharmony_ci/* AD_ORIG_WR_PTR[31:0] */ 62262306a36Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR1 0x4030 62362306a36Sopenharmony_ci/* AD_ORIG_WR_PTR[63:32] */ 62462306a36Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR2 0x4034 62562306a36Sopenharmony_ci/* AD_ORIG_WR_PTR[67:64] */ 62662306a36Sopenharmony_ci#define TW5864_AD_ORIG_WR_PTR3 0x4038 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci/* AD_ORIG_RD_PTR[31:0] */ 62962306a36Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR1 0x403c 63062306a36Sopenharmony_ci/* AD_ORIG_RD_PTR[63:32] */ 63162306a36Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR2 0x4040 63262306a36Sopenharmony_ci/* AD_ORIG_RD_PTR[67:64] */ 63362306a36Sopenharmony_ci#define TW5864_AD_ORIG_RD_PTR3 0x4044 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ci#define TW5864_PC_BLOCK_ORIG_RD_NO 0x4048 63662306a36Sopenharmony_ci#define TW5864_PC_BLOCK_ORIG_RD_NO_MASK 0x1f 63762306a36Sopenharmony_ci 63862306a36Sopenharmony_ci#define TW5864_PCI_AUD 0x404c 63962306a36Sopenharmony_ci/* Define controls in register TW5864_PCI_AUD */ 64062306a36Sopenharmony_ci/* 64162306a36Sopenharmony_ci * The register is applicable to PCI initiator mode only. Used to select PCM(0) 64262306a36Sopenharmony_ci * or ADPCM(1) audio data sent to PC. One bit for each channel 64362306a36Sopenharmony_ci */ 64462306a36Sopenharmony_ci#define TW5864_PCI_DATA_SEL 0xffff 64562306a36Sopenharmony_ci/* 64662306a36Sopenharmony_ci * Audio flow control mode selection bit. 64762306a36Sopenharmony_ci * 0 Flow control disabled. TW5864 continuously sends audio frame to PC 64862306a36Sopenharmony_ci * (initiator mode) 64962306a36Sopenharmony_ci * 1 Flow control enabled 65062306a36Sopenharmony_ci */ 65162306a36Sopenharmony_ci#define TW5864_PCI_FLOW_EN BIT(16) 65262306a36Sopenharmony_ci/* 65362306a36Sopenharmony_ci * When PCI_FLOW_EN is set, PCI need to toggle this bit to send an audio frame 65462306a36Sopenharmony_ci * to PC. One toggle to send one frame. 65562306a36Sopenharmony_ci */ 65662306a36Sopenharmony_ci#define TW5864_PCI_AUD_FRM_EN BIT(17) 65762306a36Sopenharmony_ci 65862306a36Sopenharmony_ci/* [1:0] CS valid to data valid CLK cycles when writing operation */ 65962306a36Sopenharmony_ci#define TW5864_CS2DAT_CNT 0x8000 66062306a36Sopenharmony_ci/* [2:0] Data valid signal width by system clock cycles */ 66162306a36Sopenharmony_ci#define TW5864_DATA_VLD_WIDTH 0x8004 66262306a36Sopenharmony_ci 66362306a36Sopenharmony_ci#define TW5864_SYNC 0x8008 66462306a36Sopenharmony_ci/* Define controls in register TW5864_SYNC */ 66562306a36Sopenharmony_ci/* 66662306a36Sopenharmony_ci * 0 vlc stream to synchronous port 66762306a36Sopenharmony_ci * 1 vlc stream to ddr buffers 66862306a36Sopenharmony_ci */ 66962306a36Sopenharmony_ci#define TW5864_SYNC_CFG BIT(7) 67062306a36Sopenharmony_ci/* 67162306a36Sopenharmony_ci * 0 SYNC Address sampled on Rising edge 67262306a36Sopenharmony_ci * 1 SYNC Address sampled on Falling edge 67362306a36Sopenharmony_ci */ 67462306a36Sopenharmony_ci#define TW5864_SYNC_ADR_EDGE BIT(0) 67562306a36Sopenharmony_ci#define TW5864_VLC_STR_DELAY_SHIFT 1 67662306a36Sopenharmony_ci/* 67762306a36Sopenharmony_ci * 0 No system delay 67862306a36Sopenharmony_ci * 1 One system clock delay 67962306a36Sopenharmony_ci * 2 Two system clock delay 68062306a36Sopenharmony_ci * 3 Three system clock delay 68162306a36Sopenharmony_ci */ 68262306a36Sopenharmony_ci#define TW5864_VLC_STR_DELAY (3 << 1) 68362306a36Sopenharmony_ci/* 68462306a36Sopenharmony_ci * 0 Rising edge output 68562306a36Sopenharmony_ci * 1 Falling edge output 68662306a36Sopenharmony_ci */ 68762306a36Sopenharmony_ci#define TW5864_VLC_OUT_EDGE BIT(3) 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_ci/* 69062306a36Sopenharmony_ci * [1:0] 69162306a36Sopenharmony_ci * 2'b00 phase set to 180 degree 69262306a36Sopenharmony_ci * 2'b01 phase set to 270 degree 69362306a36Sopenharmony_ci * 2'b10 phase set to 0 degree 69462306a36Sopenharmony_ci * 2'b11 phase set to 90 degree 69562306a36Sopenharmony_ci */ 69662306a36Sopenharmony_ci#define TW5864_I2C_PHASE_CFG 0x800c 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_ci/* 69962306a36Sopenharmony_ci * The system / DDR clock (166 MHz) is generated with an on-chip system clock 70062306a36Sopenharmony_ci * PLL (SYSPLL) using input crystal clock of 27 MHz. The system clock PLL 70162306a36Sopenharmony_ci * frequency is controlled with the following equation. 70262306a36Sopenharmony_ci * CLK_OUT = CLK_IN * (M+1) / ((N+1) * P) 70362306a36Sopenharmony_ci * SYSPLL_M M parameter 70462306a36Sopenharmony_ci * SYSPLL_N N parameter 70562306a36Sopenharmony_ci * SYSPLL_P P parameter 70662306a36Sopenharmony_ci */ 70762306a36Sopenharmony_ci/* SYSPLL_M[7:0] */ 70862306a36Sopenharmony_ci#define TW5864_SYSPLL1 0x8018 70962306a36Sopenharmony_ci/* Define controls in register TW5864_SYSPLL1 */ 71062306a36Sopenharmony_ci#define TW5864_SYSPLL_M_LOW 0x00ff 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci/* [2:0]: SYSPLL_M[10:8], [7:3]: SYSPLL_N[4:0] */ 71362306a36Sopenharmony_ci#define TW5864_SYSPLL2 0x8019 71462306a36Sopenharmony_ci/* Define controls in register TW5864_SYSPLL2 */ 71562306a36Sopenharmony_ci#define TW5864_SYSPLL_M_HI 0x07 71662306a36Sopenharmony_ci#define TW5864_SYSPLL_N_LOW_SHIFT 3 71762306a36Sopenharmony_ci#define TW5864_SYSPLL_N_LOW (0x1f << 3) 71862306a36Sopenharmony_ci 71962306a36Sopenharmony_ci/* 72062306a36Sopenharmony_ci * [1:0]: SYSPLL_N[6:5], [3:2]: SYSPLL_P, [4]: SYSPLL_IREF, [7:5]: SYSPLL_CP_SEL 72162306a36Sopenharmony_ci */ 72262306a36Sopenharmony_ci#define TW5864_SYSPLL3 0x8020 72362306a36Sopenharmony_ci/* Define controls in register TW5864_SYSPLL3 */ 72462306a36Sopenharmony_ci#define TW5864_SYSPLL_N_HI 0x03 72562306a36Sopenharmony_ci#define TW5864_SYSPLL_P_SHIFT 2 72662306a36Sopenharmony_ci#define TW5864_SYSPLL_P (0x03 << 2) 72762306a36Sopenharmony_ci/* 72862306a36Sopenharmony_ci * SYSPLL bias current control 72962306a36Sopenharmony_ci * 0 Lower current (default) 73062306a36Sopenharmony_ci * 1 30% higher current 73162306a36Sopenharmony_ci */ 73262306a36Sopenharmony_ci#define TW5864_SYSPLL_IREF BIT(4) 73362306a36Sopenharmony_ci/* 73462306a36Sopenharmony_ci * SYSPLL charge pump current selection 73562306a36Sopenharmony_ci * 0 1,5 uA 73662306a36Sopenharmony_ci * 1 4 uA 73762306a36Sopenharmony_ci * 2 9 uA 73862306a36Sopenharmony_ci * 3 19 uA 73962306a36Sopenharmony_ci * 4 39 uA 74062306a36Sopenharmony_ci * 5 79 uA 74162306a36Sopenharmony_ci * 6 159 uA 74262306a36Sopenharmony_ci * 7 319 uA 74362306a36Sopenharmony_ci */ 74462306a36Sopenharmony_ci#define TW5864_SYSPLL_CP_SEL_SHIFT 5 74562306a36Sopenharmony_ci#define TW5864_SYSPLL_CP_SEL (0x07 << 5) 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_ci/* 74862306a36Sopenharmony_ci * [1:0]: SYSPLL_VCO, [3:2]: SYSPLL_LP_X8, [5:4]: SYSPLL_ICP_SEL, 74962306a36Sopenharmony_ci * [6]: SYSPLL_LPF_5PF, [7]: SYSPLL_ED_SEL 75062306a36Sopenharmony_ci */ 75162306a36Sopenharmony_ci#define TW5864_SYSPLL4 0x8021 75262306a36Sopenharmony_ci/* Define controls in register TW5864_SYSPLL4 */ 75362306a36Sopenharmony_ci/* 75462306a36Sopenharmony_ci * SYSPLL_VCO VCO Range selection 75562306a36Sopenharmony_ci * 00 5 ~ 75 MHz 75662306a36Sopenharmony_ci * 01 50 ~ 140 MHz 75762306a36Sopenharmony_ci * 10 110 ~ 320 MHz 75862306a36Sopenharmony_ci * 11 270 ~ 700 MHz 75962306a36Sopenharmony_ci */ 76062306a36Sopenharmony_ci#define TW5864_SYSPLL_VCO 0x03 76162306a36Sopenharmony_ci#define TW5864_SYSPLL_LP_X8_SHIFT 2 76262306a36Sopenharmony_ci/* 76362306a36Sopenharmony_ci * Loop resister 76462306a36Sopenharmony_ci * 0 38.5K ohms 76562306a36Sopenharmony_ci * 1 6.6K ohms (default) 76662306a36Sopenharmony_ci * 2 2.2K ohms 76762306a36Sopenharmony_ci * 3 1.1K ohms 76862306a36Sopenharmony_ci */ 76962306a36Sopenharmony_ci#define TW5864_SYSPLL_LP_X8 (0x03 << 2) 77062306a36Sopenharmony_ci#define TW5864_SYSPLL_ICP_SEL_SHIFT 4 77162306a36Sopenharmony_ci/* 77262306a36Sopenharmony_ci * PLL charge pump fine tune 77362306a36Sopenharmony_ci * 00 x1 (default) 77462306a36Sopenharmony_ci * 01 x1/2 77562306a36Sopenharmony_ci * 10 x1/7 77662306a36Sopenharmony_ci * 11 x1/8 77762306a36Sopenharmony_ci */ 77862306a36Sopenharmony_ci#define TW5864_SYSPLL_ICP_SEL (0x03 << 4) 77962306a36Sopenharmony_ci/* 78062306a36Sopenharmony_ci * PLL low pass filter phase margin adjustment 78162306a36Sopenharmony_ci * 0 no 5pF (default) 78262306a36Sopenharmony_ci * 1 5pF added 78362306a36Sopenharmony_ci */ 78462306a36Sopenharmony_ci#define TW5864_SYSPLL_LPF_5PF BIT(6) 78562306a36Sopenharmony_ci/* 78662306a36Sopenharmony_ci * PFD select edge for detection 78762306a36Sopenharmony_ci * 0 Falling edge (default) 78862306a36Sopenharmony_ci * 1 Rising edge 78962306a36Sopenharmony_ci */ 79062306a36Sopenharmony_ci#define TW5864_SYSPLL_ED_SEL BIT(7) 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_ci/* [0]: SYSPLL_RST, [4]: SYSPLL_PD */ 79362306a36Sopenharmony_ci#define TW5864_SYSPLL5 0x8024 79462306a36Sopenharmony_ci/* Define controls in register TW5864_SYSPLL5 */ 79562306a36Sopenharmony_ci/* Reset SYSPLL */ 79662306a36Sopenharmony_ci#define TW5864_SYSPLL_RST BIT(0) 79762306a36Sopenharmony_ci/* Power down SYSPLL */ 79862306a36Sopenharmony_ci#define TW5864_SYSPLL_PD BIT(4) 79962306a36Sopenharmony_ci 80062306a36Sopenharmony_ci#define TW5864_PLL_CFG 0x801c 80162306a36Sopenharmony_ci/* Define controls in register TW5864_PLL_CFG */ 80262306a36Sopenharmony_ci/* 80362306a36Sopenharmony_ci * Issue Soft Reset from Async Host Interface / PCI Interface clock domain. 80462306a36Sopenharmony_ci * Become valid after sync to the xtal clock domain. This bit is set only if 80562306a36Sopenharmony_ci * LOAD register bit is also set to 1. 80662306a36Sopenharmony_ci */ 80762306a36Sopenharmony_ci#define TW5864_SRST BIT(0) 80862306a36Sopenharmony_ci/* 80962306a36Sopenharmony_ci * Issue SYSPLL (166 MHz) configuration latch from Async host interface / PCI 81062306a36Sopenharmony_ci * Interface clock domain. The configuration setting becomes effective only if 81162306a36Sopenharmony_ci * LOAD register bit is also set to 1. 81262306a36Sopenharmony_ci */ 81362306a36Sopenharmony_ci#define TW5864_SYSPLL_CFG BIT(2) 81462306a36Sopenharmony_ci/* 81562306a36Sopenharmony_ci * Issue SPLL (108 MHz) configuration load from Async host interface / PCI 81662306a36Sopenharmony_ci * Interface clock domain. The configuration setting becomes effective only if 81762306a36Sopenharmony_ci * the LOAD register bit is also set to 1. 81862306a36Sopenharmony_ci */ 81962306a36Sopenharmony_ci#define TW5864_SPLL_CFG BIT(4) 82062306a36Sopenharmony_ci/* 82162306a36Sopenharmony_ci * Set this bit to latch the SRST, SYSPLL_CFG, SPLL_CFG setting into the xtal 82262306a36Sopenharmony_ci * clock domain to restart the PLL. This bit is self cleared. 82362306a36Sopenharmony_ci */ 82462306a36Sopenharmony_ci#define TW5864_LOAD BIT(3) 82562306a36Sopenharmony_ci 82662306a36Sopenharmony_ci/* SPLL_IREF, SPLL_LPX4, SPLL_CPX4, SPLL_PD, SPLL_DBG */ 82762306a36Sopenharmony_ci#define TW5864_SPLL 0x8028 82862306a36Sopenharmony_ci 82962306a36Sopenharmony_ci/* 0x8800 ~ 0x88fc - Interrupt Register Map */ 83062306a36Sopenharmony_ci/* 83162306a36Sopenharmony_ci * Trigger mode of interrupt source 0 ~ 15 83262306a36Sopenharmony_ci * 1 Edge trigger mode 83362306a36Sopenharmony_ci * 0 Level trigger mode 83462306a36Sopenharmony_ci */ 83562306a36Sopenharmony_ci#define TW5864_TRIGGER_MODE_L 0x8800 83662306a36Sopenharmony_ci/* Trigger mode of interrupt source 16 ~ 31 */ 83762306a36Sopenharmony_ci#define TW5864_TRIGGER_MODE_H 0x8804 83862306a36Sopenharmony_ci/* Enable of interrupt source 0 ~ 15 */ 83962306a36Sopenharmony_ci#define TW5864_INTR_ENABLE_L 0x8808 84062306a36Sopenharmony_ci/* Enable of interrupt source 16 ~ 31 */ 84162306a36Sopenharmony_ci#define TW5864_INTR_ENABLE_H 0x880c 84262306a36Sopenharmony_ci/* Clear interrupt command of interrupt source 0 ~ 15 */ 84362306a36Sopenharmony_ci#define TW5864_INTR_CLR_L 0x8810 84462306a36Sopenharmony_ci/* Clear interrupt command of interrupt source 16 ~ 31 */ 84562306a36Sopenharmony_ci#define TW5864_INTR_CLR_H 0x8814 84662306a36Sopenharmony_ci/* 84762306a36Sopenharmony_ci * Assertion of interrupt source 0 ~ 15 84862306a36Sopenharmony_ci * 1 High level or pos-edge is assertion 84962306a36Sopenharmony_ci * 0 Low level or neg-edge is assertion 85062306a36Sopenharmony_ci */ 85162306a36Sopenharmony_ci#define TW5864_INTR_ASSERT_L 0x8818 85262306a36Sopenharmony_ci/* Assertion of interrupt source 16 ~ 31 */ 85362306a36Sopenharmony_ci#define TW5864_INTR_ASSERT_H 0x881c 85462306a36Sopenharmony_ci/* 85562306a36Sopenharmony_ci * Output level of interrupt 85662306a36Sopenharmony_ci * 1 Interrupt output is high assertion 85762306a36Sopenharmony_ci * 0 Interrupt output is low assertion 85862306a36Sopenharmony_ci */ 85962306a36Sopenharmony_ci#define TW5864_INTR_OUT_LEVEL 0x8820 86062306a36Sopenharmony_ci/* 86162306a36Sopenharmony_ci * Status of interrupt source 0 ~ 15 86262306a36Sopenharmony_ci * Bit[0]: VLC 4k RAM interrupt 86362306a36Sopenharmony_ci * Bit[1]: BURST DDR RAM interrupt 86462306a36Sopenharmony_ci * Bit[2]: MV DSP interrupt 86562306a36Sopenharmony_ci * Bit[3]: video lost interrupt 86662306a36Sopenharmony_ci * Bit[4]: gpio 0 interrupt 86762306a36Sopenharmony_ci * Bit[5]: gpio 1 interrupt 86862306a36Sopenharmony_ci * Bit[6]: gpio 2 interrupt 86962306a36Sopenharmony_ci * Bit[7]: gpio 3 interrupt 87062306a36Sopenharmony_ci * Bit[8]: gpio 4 interrupt 87162306a36Sopenharmony_ci * Bit[9]: gpio 5 interrupt 87262306a36Sopenharmony_ci * Bit[10]: gpio 6 interrupt 87362306a36Sopenharmony_ci * Bit[11]: gpio 7 interrupt 87462306a36Sopenharmony_ci * Bit[12]: JPEG interrupt 87562306a36Sopenharmony_ci * Bit[13:15]: Reserved 87662306a36Sopenharmony_ci */ 87762306a36Sopenharmony_ci#define TW5864_INTR_STATUS_L 0x8838 87862306a36Sopenharmony_ci/* 87962306a36Sopenharmony_ci * Status of interrupt source 16 ~ 31 88062306a36Sopenharmony_ci * Bit[0]: Reserved 88162306a36Sopenharmony_ci * Bit[1]: VLC done interrupt 88262306a36Sopenharmony_ci * Bit[2]: Reserved 88362306a36Sopenharmony_ci * Bit[3]: AD Vsync interrupt 88462306a36Sopenharmony_ci * Bit[4]: Preview eof interrupt 88562306a36Sopenharmony_ci * Bit[5]: Preview overflow interrupt 88662306a36Sopenharmony_ci * Bit[6]: Timer interrupt 88762306a36Sopenharmony_ci * Bit[7]: Reserved 88862306a36Sopenharmony_ci * Bit[8]: Audio eof interrupt 88962306a36Sopenharmony_ci * Bit[9]: I2C done interrupt 89062306a36Sopenharmony_ci * Bit[10]: AD interrupt 89162306a36Sopenharmony_ci * Bit[11:15]: Reserved 89262306a36Sopenharmony_ci */ 89362306a36Sopenharmony_ci#define TW5864_INTR_STATUS_H 0x883c 89462306a36Sopenharmony_ci 89562306a36Sopenharmony_ci/* Defines of interrupt bits, united for both low and high word registers */ 89662306a36Sopenharmony_ci#define TW5864_INTR_VLC_RAM BIT(0) 89762306a36Sopenharmony_ci#define TW5864_INTR_BURST BIT(1) 89862306a36Sopenharmony_ci#define TW5864_INTR_MV_DSP BIT(2) 89962306a36Sopenharmony_ci#define TW5864_INTR_VIN_LOST BIT(3) 90062306a36Sopenharmony_ci/* n belongs to [0; 7] */ 90162306a36Sopenharmony_ci#define TW5864_INTR_GPIO(n) (1 << (4 + n)) 90262306a36Sopenharmony_ci#define TW5864_INTR_JPEG BIT(12) 90362306a36Sopenharmony_ci#define TW5864_INTR_VLC_DONE BIT(17) 90462306a36Sopenharmony_ci#define TW5864_INTR_AD_VSYNC BIT(19) 90562306a36Sopenharmony_ci#define TW5864_INTR_PV_EOF BIT(20) 90662306a36Sopenharmony_ci#define TW5864_INTR_PV_OVERFLOW BIT(21) 90762306a36Sopenharmony_ci#define TW5864_INTR_TIMER BIT(22) 90862306a36Sopenharmony_ci#define TW5864_INTR_AUD_EOF BIT(24) 90962306a36Sopenharmony_ci#define TW5864_INTR_I2C_DONE BIT(25) 91062306a36Sopenharmony_ci#define TW5864_INTR_AD BIT(26) 91162306a36Sopenharmony_ci 91262306a36Sopenharmony_ci/* 0x9000 ~ 0x920c - Video Capture (VIF) Register Map */ 91362306a36Sopenharmony_ci/* 91462306a36Sopenharmony_ci * H264EN_CH_STATUS[n] Status of Vsync synchronized H264EN_CH_EN (Read Only) 91562306a36Sopenharmony_ci * 1 Channel Enabled 91662306a36Sopenharmony_ci * 0 Channel Disabled 91762306a36Sopenharmony_ci */ 91862306a36Sopenharmony_ci#define TW5864_H264EN_CH_STATUS 0x9000 91962306a36Sopenharmony_ci/* 92062306a36Sopenharmony_ci * [15:0] H264EN_CH_EN[n] H264 Encoding Path Enable for channel 92162306a36Sopenharmony_ci * 1 Channel Enabled 92262306a36Sopenharmony_ci * 0 Channel Disabled 92362306a36Sopenharmony_ci */ 92462306a36Sopenharmony_ci#define TW5864_H264EN_CH_EN 0x9004 92562306a36Sopenharmony_ci/* 92662306a36Sopenharmony_ci * H264EN_CH_DNS[n] H264 Encoding Path Downscale Video Decoder Input for 92762306a36Sopenharmony_ci * channel n 92862306a36Sopenharmony_ci * 1 Downscale Y to 1/2 92962306a36Sopenharmony_ci * 0 Does not downscale 93062306a36Sopenharmony_ci */ 93162306a36Sopenharmony_ci#define TW5864_H264EN_CH_DNS 0x9008 93262306a36Sopenharmony_ci/* 93362306a36Sopenharmony_ci * H264EN_CH_PROG[n] H264 Encoding Path channel n is progressive 93462306a36Sopenharmony_ci * 1 Progressive (Not valid for TW5864) 93562306a36Sopenharmony_ci * 0 Interlaced (TW5864 default) 93662306a36Sopenharmony_ci */ 93762306a36Sopenharmony_ci#define TW5864_H264EN_CH_PROG 0x900c 93862306a36Sopenharmony_ci/* 93962306a36Sopenharmony_ci * [3:0] H264EN_BUS_MAX_CH[n] 94062306a36Sopenharmony_ci * H264 Encoding Path maximum number of channel on BUS n 94162306a36Sopenharmony_ci * 0 Max 4 channels 94262306a36Sopenharmony_ci * 1 Max 2 channels 94362306a36Sopenharmony_ci */ 94462306a36Sopenharmony_ci#define TW5864_H264EN_BUS_MAX_CH 0x9010 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci/* 94762306a36Sopenharmony_ci * H264EN_RATE_MAX_LINE_n H264 Encoding path Rate Mapping Maximum Line Number 94862306a36Sopenharmony_ci * on Bus n 94962306a36Sopenharmony_ci */ 95062306a36Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_EVEN 0x1f 95162306a36Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_ODD_SHIFT 5 95262306a36Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_ODD (0x1f << 5) 95362306a36Sopenharmony_ci/* 95462306a36Sopenharmony_ci * [4:0] H264EN_RATE_MAX_LINE_0 95562306a36Sopenharmony_ci * [9:5] H264EN_RATE_MAX_LINE_1 95662306a36Sopenharmony_ci */ 95762306a36Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_REG1 0x9014 95862306a36Sopenharmony_ci/* 95962306a36Sopenharmony_ci * [4:0] H264EN_RATE_MAX_LINE_2 96062306a36Sopenharmony_ci * [9:5] H264EN_RATE_MAX_LINE_3 96162306a36Sopenharmony_ci */ 96262306a36Sopenharmony_ci#define TW5864_H264EN_RATE_MAX_LINE_REG2 0x9018 96362306a36Sopenharmony_ci 96462306a36Sopenharmony_ci/* 96562306a36Sopenharmony_ci * H264EN_CHn_FMT H264 Encoding Path Format configuration of Channel n 96662306a36Sopenharmony_ci * 00 D1 (For D1 and hD1 frame) 96762306a36Sopenharmony_ci * 01 (Reserved) 96862306a36Sopenharmony_ci * 10 (Reserved) 96962306a36Sopenharmony_ci * 11 D1 with 1/2 size in X (for CIF frame) 97062306a36Sopenharmony_ci * Note: To be used with 0x9008 register to configure the frame size 97162306a36Sopenharmony_ci */ 97262306a36Sopenharmony_ci/* 97362306a36Sopenharmony_ci * [1:0]: H264EN_CH0_FMT, 97462306a36Sopenharmony_ci * ..., [15:14]: H264EN_CH7_FMT 97562306a36Sopenharmony_ci */ 97662306a36Sopenharmony_ci#define TW5864_H264EN_CH_FMT_REG1 0x9020 97762306a36Sopenharmony_ci/* 97862306a36Sopenharmony_ci * [1:0]: H264EN_CH8_FMT (?), 97962306a36Sopenharmony_ci * ..., [15:14]: H264EN_CH15_FMT (?) 98062306a36Sopenharmony_ci */ 98162306a36Sopenharmony_ci#define TW5864_H264EN_CH_FMT_REG2 0x9024 98262306a36Sopenharmony_ci 98362306a36Sopenharmony_ci/* 98462306a36Sopenharmony_ci * H264EN_RATE_CNTL_BUSm_CHn H264 Encoding Path BUS m Rate Control for Channel n 98562306a36Sopenharmony_ci */ 98662306a36Sopenharmony_ci#define TW5864_H264EN_RATE_CNTL_LO_WORD(bus, channel) \ 98762306a36Sopenharmony_ci (0x9100 + bus * 0x20 + channel * 0x08) 98862306a36Sopenharmony_ci#define TW5864_H264EN_RATE_CNTL_HI_WORD(bus, channel) \ 98962306a36Sopenharmony_ci (0x9104 + bus * 0x20 + channel * 0x08) 99062306a36Sopenharmony_ci 99162306a36Sopenharmony_ci/* 99262306a36Sopenharmony_ci * H264EN_BUSm_MAP_CHn The 16-to-1 MUX configuration register for each encoding 99362306a36Sopenharmony_ci * channel (total of 16 channels). Four bits for each channel. 99462306a36Sopenharmony_ci */ 99562306a36Sopenharmony_ci#define TW5864_H264EN_BUS0_MAP 0x9200 99662306a36Sopenharmony_ci#define TW5864_H264EN_BUS1_MAP 0x9204 99762306a36Sopenharmony_ci#define TW5864_H264EN_BUS2_MAP 0x9208 99862306a36Sopenharmony_ci#define TW5864_H264EN_BUS3_MAP 0x920c 99962306a36Sopenharmony_ci 100062306a36Sopenharmony_ci/* This register is not defined in datasheet, but used in reference driver */ 100162306a36Sopenharmony_ci#define TW5864_UNDECLARED_ERROR_FLAGS_0x9218 0x9218 100262306a36Sopenharmony_ci 100362306a36Sopenharmony_ci#define TW5864_GPIO1 0x9800 100462306a36Sopenharmony_ci#define TW5864_GPIO2 0x9804 100562306a36Sopenharmony_ci/* Define controls in registers TW5864_GPIO1, TW5864_GPIO2 */ 100662306a36Sopenharmony_ci/* GPIO DATA of Group n */ 100762306a36Sopenharmony_ci#define TW5864_GPIO_DATA 0x00ff 100862306a36Sopenharmony_ci#define TW5864_GPIO_OEN_SHIFT 8 100962306a36Sopenharmony_ci/* GPIO Output Enable of Group n */ 101062306a36Sopenharmony_ci#define TW5864_GPIO_OEN (0xff << 8) 101162306a36Sopenharmony_ci 101262306a36Sopenharmony_ci/* 0xa000 ~ 0xa8ff - DDR Controller Register Map */ 101362306a36Sopenharmony_ci/* DDR Controller A */ 101462306a36Sopenharmony_ci/* 101562306a36Sopenharmony_ci * [2:0] Data valid counter after read command to DDR. This is the delay value 101662306a36Sopenharmony_ci * to show how many cycles the data will be back from DDR after we issue a read 101762306a36Sopenharmony_ci * command. 101862306a36Sopenharmony_ci */ 101962306a36Sopenharmony_ci#define TW5864_RD_ACK_VLD_MUX 0xa000 102062306a36Sopenharmony_ci 102162306a36Sopenharmony_ci#define TW5864_DDR_PERIODS 0xa004 102262306a36Sopenharmony_ci/* Define controls in register TW5864_DDR_PERIODS */ 102362306a36Sopenharmony_ci/* 102462306a36Sopenharmony_ci * Tras value, the minimum cycle of active to precharge command period, 102562306a36Sopenharmony_ci * default is 7 102662306a36Sopenharmony_ci */ 102762306a36Sopenharmony_ci#define TW5864_TRAS_CNT_MAX 0x000f 102862306a36Sopenharmony_ci/* 102962306a36Sopenharmony_ci * Trfc value, the minimum cycle of refresh to active or refresh command period, 103062306a36Sopenharmony_ci * default is 4"hf 103162306a36Sopenharmony_ci */ 103262306a36Sopenharmony_ci#define TW5864_RFC_CNT_MAX_SHIFT 8 103362306a36Sopenharmony_ci#define TW5864_RFC_CNT_MAX (0x0f << 8) 103462306a36Sopenharmony_ci/* 103562306a36Sopenharmony_ci * Trcd value, the minimum cycle of active to internal read/write command 103662306a36Sopenharmony_ci * period, default is 4"h2 103762306a36Sopenharmony_ci */ 103862306a36Sopenharmony_ci#define TW5864_TCD_CNT_MAX_SHIFT 4 103962306a36Sopenharmony_ci#define TW5864_TCD_CNT_MAX (0x0f << 4) 104062306a36Sopenharmony_ci/* Twr value, write recovery time, default is 4"h3 */ 104162306a36Sopenharmony_ci#define TW5864_TWR_CNT_MAX_SHIFT 12 104262306a36Sopenharmony_ci#define TW5864_TWR_CNT_MAX (0x0f << 12) 104362306a36Sopenharmony_ci 104462306a36Sopenharmony_ci/* 104562306a36Sopenharmony_ci * [2:0] CAS latency, the delay cycle between internal read command and the 104662306a36Sopenharmony_ci * availability of the first bit of output data, default is 3 104762306a36Sopenharmony_ci */ 104862306a36Sopenharmony_ci#define TW5864_CAS_LATENCY 0xa008 104962306a36Sopenharmony_ci/* 105062306a36Sopenharmony_ci * [15:0] Maximum average periodic refresh, the value is based on the current 105162306a36Sopenharmony_ci * frequency to match 7.8mcs 105262306a36Sopenharmony_ci */ 105362306a36Sopenharmony_ci#define TW5864_DDR_REF_CNTR_MAX 0xa00c 105462306a36Sopenharmony_ci/* 105562306a36Sopenharmony_ci * DDR_ON_CHIP_MAP [1:0] 105662306a36Sopenharmony_ci * 0 256M DDR on board 105762306a36Sopenharmony_ci * 1 512M DDR on board 105862306a36Sopenharmony_ci * 2 1G DDR on board 105962306a36Sopenharmony_ci * DDR_ON_CHIP_MAP [2] 106062306a36Sopenharmony_ci * 0 Only one DDR chip 106162306a36Sopenharmony_ci * 1 Two DDR chips 106262306a36Sopenharmony_ci */ 106362306a36Sopenharmony_ci#define TW5864_DDR_ON_CHIP_MAP 0xa01c 106462306a36Sopenharmony_ci#define TW5864_DDR_SELFTEST_MODE 0xa020 106562306a36Sopenharmony_ci/* Define controls in register TW5864_DDR_SELFTEST_MODE */ 106662306a36Sopenharmony_ci/* 106762306a36Sopenharmony_ci * 0 Common read/write mode 106862306a36Sopenharmony_ci * 1 DDR self-test mode 106962306a36Sopenharmony_ci */ 107062306a36Sopenharmony_ci#define TW5864_MASTER_MODE BIT(0) 107162306a36Sopenharmony_ci/* 107262306a36Sopenharmony_ci * 0 DDR self-test single read/write 107362306a36Sopenharmony_ci * 1 DDR self-test burst read/write 107462306a36Sopenharmony_ci */ 107562306a36Sopenharmony_ci#define TW5864_SINGLE_PROC BIT(1) 107662306a36Sopenharmony_ci/* 107762306a36Sopenharmony_ci * 0 DDR self-test write command 107862306a36Sopenharmony_ci * 1 DDR self-test read command 107962306a36Sopenharmony_ci */ 108062306a36Sopenharmony_ci#define TW5864_WRITE_FLAG BIT(2) 108162306a36Sopenharmony_ci#define TW5864_DATA_MODE_SHIFT 4 108262306a36Sopenharmony_ci/* 108362306a36Sopenharmony_ci * 0 write 32'haaaa5555 to DDR 108462306a36Sopenharmony_ci * 1 write 32'hffffffff to DDR 108562306a36Sopenharmony_ci * 2 write 32'hha5a55a5a to DDR 108662306a36Sopenharmony_ci * 3 write increasing data to DDR 108762306a36Sopenharmony_ci */ 108862306a36Sopenharmony_ci#define TW5864_DATA_MODE (0x3 << 4) 108962306a36Sopenharmony_ci 109062306a36Sopenharmony_ci/* [7:0] The maximum data of one burst in DDR self-test mode */ 109162306a36Sopenharmony_ci#define TW5864_BURST_CNTR_MAX 0xa024 109262306a36Sopenharmony_ci/* [15:0] The maximum burst counter (bit 15~0) in DDR self-test mode */ 109362306a36Sopenharmony_ci#define TW5864_DDR_PROC_CNTR_MAX_L 0xa028 109462306a36Sopenharmony_ci/* The maximum burst counter (bit 31~16) in DDR self-test mode */ 109562306a36Sopenharmony_ci#define TW5864_DDR_PROC_CNTR_MAX_H 0xa02c 109662306a36Sopenharmony_ci/* [0]: Start one DDR self-test */ 109762306a36Sopenharmony_ci#define TW5864_DDR_SELF_TEST_CMD 0xa030 109862306a36Sopenharmony_ci/* The maximum error counter (bit 15 ~ 0) in DDR self-test */ 109962306a36Sopenharmony_ci#define TW5864_ERR_CNTR_L 0xa034 110062306a36Sopenharmony_ci 110162306a36Sopenharmony_ci#define TW5864_ERR_CNTR_H_AND_FLAG 0xa038 110262306a36Sopenharmony_ci/* Define controls in register TW5864_ERR_CNTR_H_AND_FLAG */ 110362306a36Sopenharmony_ci/* The maximum error counter (bit 30 ~ 16) in DDR self-test */ 110462306a36Sopenharmony_ci#define TW5864_ERR_CNTR_H_MASK 0x3fff 110562306a36Sopenharmony_ci/* DDR self-test end flag */ 110662306a36Sopenharmony_ci#define TW5864_END_FLAG 0x8000 110762306a36Sopenharmony_ci 110862306a36Sopenharmony_ci/* 110962306a36Sopenharmony_ci * DDR Controller B: same as 0xa000 ~ 0xa038, but add TW5864_DDR_B_OFFSET to all 111062306a36Sopenharmony_ci * addresses 111162306a36Sopenharmony_ci */ 111262306a36Sopenharmony_ci#define TW5864_DDR_B_OFFSET 0x0800 111362306a36Sopenharmony_ci 111462306a36Sopenharmony_ci/* 0xb004 ~ 0xb018 - HW version/ARB12 Register Map */ 111562306a36Sopenharmony_ci/* [15:0] Default is C013 */ 111662306a36Sopenharmony_ci#define TW5864_HW_VERSION 0xb004 111762306a36Sopenharmony_ci 111862306a36Sopenharmony_ci#define TW5864_REQS_ENABLE 0xb010 111962306a36Sopenharmony_ci/* Define controls in register TW5864_REQS_ENABLE */ 112062306a36Sopenharmony_ci/* Audio data in to DDR enable (default 1) */ 112162306a36Sopenharmony_ci#define TW5864_AUD_DATA_IN_ENB BIT(0) 112262306a36Sopenharmony_ci/* Audio encode request to DDR enable (default 1) */ 112362306a36Sopenharmony_ci#define TW5864_AUD_ENC_REQ_ENB BIT(1) 112462306a36Sopenharmony_ci/* Audio decode request0 to DDR enable (default 1) */ 112562306a36Sopenharmony_ci#define TW5864_AUD_DEC_REQ0_ENB BIT(2) 112662306a36Sopenharmony_ci/* Audio decode request1 to DDR enable (default 1) */ 112762306a36Sopenharmony_ci#define TW5864_AUD_DEC_REQ1_ENB BIT(3) 112862306a36Sopenharmony_ci/* VLC stream request to DDR enable (default 1) */ 112962306a36Sopenharmony_ci#define TW5864_VLC_STRM_REQ_ENB BIT(4) 113062306a36Sopenharmony_ci/* H264 MV request to DDR enable (default 1) */ 113162306a36Sopenharmony_ci#define TW5864_DVM_MV_REQ_ENB BIT(5) 113262306a36Sopenharmony_ci/* mux_core MVD request to DDR enable (default 1) */ 113362306a36Sopenharmony_ci#define TW5864_MVD_REQ_ENB BIT(6) 113462306a36Sopenharmony_ci/* mux_core MVD temp data request to DDR enable (default 1) */ 113562306a36Sopenharmony_ci#define TW5864_MVD_TMP_REQ_ENB BIT(7) 113662306a36Sopenharmony_ci/* JPEG request to DDR enable (default 1) */ 113762306a36Sopenharmony_ci#define TW5864_JPEG_REQ_ENB BIT(8) 113862306a36Sopenharmony_ci/* mv_flag request to DDR enable (default 1) */ 113962306a36Sopenharmony_ci#define TW5864_MV_FLAG_REQ_ENB BIT(9) 114062306a36Sopenharmony_ci 114162306a36Sopenharmony_ci#define TW5864_ARB12 0xb018 114262306a36Sopenharmony_ci/* Define controls in register TW5864_ARB12 */ 114362306a36Sopenharmony_ci/* ARB12 Enable (default 1) */ 114462306a36Sopenharmony_ci#define TW5864_ARB12_ENB BIT(15) 114562306a36Sopenharmony_ci/* ARB12 maximum value of time out counter (default 15"h1FF) */ 114662306a36Sopenharmony_ci#define TW5864_ARB12_TIME_OUT_CNT 0x7fff 114762306a36Sopenharmony_ci 114862306a36Sopenharmony_ci/* 0xb800 ~ 0xb80c - Indirect Access Register Map */ 114962306a36Sopenharmony_ci/* 115062306a36Sopenharmony_ci * Spec says: 115162306a36Sopenharmony_ci * In order to access the indirect register space, the following procedure is 115262306a36Sopenharmony_ci * followed. 115362306a36Sopenharmony_ci * But reference driver implementation, and current driver, too, does it 115462306a36Sopenharmony_ci * differently. 115562306a36Sopenharmony_ci * 115662306a36Sopenharmony_ci * Write Registers: 115762306a36Sopenharmony_ci * (1) Write IND_DATA at 0xb804 ~ 0xb807 115862306a36Sopenharmony_ci * (2) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 115962306a36Sopenharmony_ci * (3) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "1", ENABLE to "1" 116062306a36Sopenharmony_ci * Read Registers: 116162306a36Sopenharmony_ci * (1) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 116262306a36Sopenharmony_ci * (2) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "0", ENABLE to "1" 116362306a36Sopenharmony_ci * (3) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 116462306a36Sopenharmony_ci * (4) Read IND_DATA from 0xb804 ~ 0xb807 116562306a36Sopenharmony_ci */ 116662306a36Sopenharmony_ci#define TW5864_IND_CTL 0xb800 116762306a36Sopenharmony_ci/* Define controls in register TW5864_IND_CTL */ 116862306a36Sopenharmony_ci/* Address used to access indirect register space */ 116962306a36Sopenharmony_ci#define TW5864_IND_ADDR 0x0000ffff 117062306a36Sopenharmony_ci/* Wait until this bit is "0" before using indirect access */ 117162306a36Sopenharmony_ci#define TW5864_BUSY BIT(31) 117262306a36Sopenharmony_ci/* Activate the indirect access. This bit is self cleared */ 117362306a36Sopenharmony_ci#define TW5864_ENABLE BIT(25) 117462306a36Sopenharmony_ci/* Read/Write command */ 117562306a36Sopenharmony_ci#define TW5864_RW BIT(24) 117662306a36Sopenharmony_ci 117762306a36Sopenharmony_ci/* [31:0] Data used to read/write indirect register space */ 117862306a36Sopenharmony_ci#define TW5864_IND_DATA 0xb804 117962306a36Sopenharmony_ci 118062306a36Sopenharmony_ci/* 0xc000 ~ 0xc7fc - Preview Register Map */ 118162306a36Sopenharmony_ci/* Mostly skipped this section. */ 118262306a36Sopenharmony_ci/* 118362306a36Sopenharmony_ci * [15:0] Status of Vsync Synchronized PCI_PV_CH_EN (Read Only) 118462306a36Sopenharmony_ci * 1 Channel Enabled 118562306a36Sopenharmony_ci * 0 Channel Disabled 118662306a36Sopenharmony_ci */ 118762306a36Sopenharmony_ci#define TW5864_PCI_PV_CH_STATUS 0xc000 118862306a36Sopenharmony_ci/* 118962306a36Sopenharmony_ci * [15:0] PCI Preview Path Enable for channel n 119062306a36Sopenharmony_ci * 1 Channel Enable 119162306a36Sopenharmony_ci * 0 Channel Disable 119262306a36Sopenharmony_ci */ 119362306a36Sopenharmony_ci#define TW5864_PCI_PV_CH_EN 0xc004 119462306a36Sopenharmony_ci 119562306a36Sopenharmony_ci/* 0xc800 ~ 0xc804 - JPEG Capture Register Map */ 119662306a36Sopenharmony_ci/* Skipped. */ 119762306a36Sopenharmony_ci/* 0xd000 ~ 0xd0fc - JPEG Control Register Map */ 119862306a36Sopenharmony_ci/* Skipped. */ 119962306a36Sopenharmony_ci 120062306a36Sopenharmony_ci/* 0xe000 ~ 0xfc04 - Motion Vector Register Map */ 120162306a36Sopenharmony_ci 120262306a36Sopenharmony_ci/* ME Motion Vector data (Four Byte Each) 0xe000 ~ 0xe7fc */ 120362306a36Sopenharmony_ci#define TW5864_ME_MV_VEC_START 0xe000 120462306a36Sopenharmony_ci#define TW5864_ME_MV_VEC_MAX_OFFSET 0x1ff 120562306a36Sopenharmony_ci#define TW5864_ME_MV_VEC(offset) (TW5864_ME_MV_VEC_START + 4 * offset) 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ci#define TW5864_MV 0xfc00 120862306a36Sopenharmony_ci/* Define controls in register TW5864_MV */ 120962306a36Sopenharmony_ci/* mv bank0 full status , write "1" to clear */ 121062306a36Sopenharmony_ci#define TW5864_MV_BK0_FULL BIT(0) 121162306a36Sopenharmony_ci/* mv bank1 full status , write "1" to clear */ 121262306a36Sopenharmony_ci#define TW5864_MV_BK1_FULL BIT(1) 121362306a36Sopenharmony_ci/* slice end status; write "1" to clear */ 121462306a36Sopenharmony_ci#define TW5864_MV_EOF BIT(2) 121562306a36Sopenharmony_ci/* mv encode interrupt status; write "1" to clear */ 121662306a36Sopenharmony_ci#define TW5864_MV_DSP_INTR BIT(3) 121762306a36Sopenharmony_ci/* mv write memory overflow, write "1" to clear */ 121862306a36Sopenharmony_ci#define TW5864_DSP_WR_OF BIT(4) 121962306a36Sopenharmony_ci#define TW5864_MV_LEN_SHIFT 5 122062306a36Sopenharmony_ci/* mv stream length */ 122162306a36Sopenharmony_ci#define TW5864_MV_LEN (0xff << 5) 122262306a36Sopenharmony_ci/* The configured status bit written into bit 15 of 0xfc04 */ 122362306a36Sopenharmony_ci#define TW5864_MPI_DDR_SEL BIT(13) 122462306a36Sopenharmony_ci 122562306a36Sopenharmony_ci#define TW5864_MPI_DDR_SEL_REG 0xfc04 122662306a36Sopenharmony_ci/* Define controls in register TW5864_MPI_DDR_SEL_REG */ 122762306a36Sopenharmony_ci/* 122862306a36Sopenharmony_ci * SW configure register 122962306a36Sopenharmony_ci * 0 MV is saved in internal DPR 123062306a36Sopenharmony_ci * 1 MV is saved in DDR 123162306a36Sopenharmony_ci */ 123262306a36Sopenharmony_ci#define TW5864_MPI_DDR_SEL2 BIT(15) 123362306a36Sopenharmony_ci 123462306a36Sopenharmony_ci/* 0x18000 ~ 0x181fc - PCI Master/Slave Control Map */ 123562306a36Sopenharmony_ci#define TW5864_PCI_INTR_STATUS 0x18000 123662306a36Sopenharmony_ci/* Define controls in register TW5864_PCI_INTR_STATUS */ 123762306a36Sopenharmony_ci/* vlc done */ 123862306a36Sopenharmony_ci#define TW5864_VLC_DONE_INTR BIT(1) 123962306a36Sopenharmony_ci/* ad vsync */ 124062306a36Sopenharmony_ci#define TW5864_AD_VSYNC_INTR BIT(3) 124162306a36Sopenharmony_ci/* preview eof */ 124262306a36Sopenharmony_ci#define TW5864_PREV_EOF_INTR BIT(4) 124362306a36Sopenharmony_ci/* preview overflow interrupt */ 124462306a36Sopenharmony_ci#define TW5864_PREV_OVERFLOW_INTR BIT(5) 124562306a36Sopenharmony_ci/* timer interrupt */ 124662306a36Sopenharmony_ci#define TW5864_TIMER_INTR BIT(6) 124762306a36Sopenharmony_ci/* audio eof */ 124862306a36Sopenharmony_ci#define TW5864_AUDIO_EOF_INTR BIT(8) 124962306a36Sopenharmony_ci/* IIC done */ 125062306a36Sopenharmony_ci#define TW5864_IIC_DONE_INTR BIT(24) 125162306a36Sopenharmony_ci/* ad interrupt (e.g.: video lost, video format changed) */ 125262306a36Sopenharmony_ci#define TW5864_AD_INTR_REG BIT(25) 125362306a36Sopenharmony_ci 125462306a36Sopenharmony_ci#define TW5864_PCI_INTR_CTL 0x18004 125562306a36Sopenharmony_ci/* Define controls in register TW5864_PCI_INTR_CTL */ 125662306a36Sopenharmony_ci/* master enable */ 125762306a36Sopenharmony_ci#define TW5864_PCI_MAST_ENB BIT(0) 125862306a36Sopenharmony_ci/* mvd&vlc master enable */ 125962306a36Sopenharmony_ci#define TW5864_MVD_VLC_MAST_ENB 0x06 126062306a36Sopenharmony_ci/* (Need to set 0 in TW5864A) */ 126162306a36Sopenharmony_ci#define TW5864_AD_MAST_ENB BIT(3) 126262306a36Sopenharmony_ci/* preview master enable */ 126362306a36Sopenharmony_ci#define TW5864_PREV_MAST_ENB BIT(4) 126462306a36Sopenharmony_ci/* preview overflow enable */ 126562306a36Sopenharmony_ci#define TW5864_PREV_OVERFLOW_ENB BIT(5) 126662306a36Sopenharmony_ci/* timer interrupt enable */ 126762306a36Sopenharmony_ci#define TW5864_TIMER_INTR_ENB BIT(6) 126862306a36Sopenharmony_ci/* JPEG master (push mode) enable */ 126962306a36Sopenharmony_ci#define TW5864_JPEG_MAST_ENB BIT(7) 127062306a36Sopenharmony_ci#define TW5864_AU_MAST_ENB_CHN_SHIFT 8 127162306a36Sopenharmony_ci/* audio master channel enable */ 127262306a36Sopenharmony_ci#define TW5864_AU_MAST_ENB_CHN (0xffff << 8) 127362306a36Sopenharmony_ci/* IIC interrupt enable */ 127462306a36Sopenharmony_ci#define TW5864_IIC_INTR_ENB BIT(24) 127562306a36Sopenharmony_ci/* ad interrupt enable */ 127662306a36Sopenharmony_ci#define TW5864_AD_INTR_ENB BIT(25) 127762306a36Sopenharmony_ci/* target burst enable */ 127862306a36Sopenharmony_ci#define TW5864_PCI_TAR_BURST_ENB BIT(26) 127962306a36Sopenharmony_ci/* vlc stream burst enable */ 128062306a36Sopenharmony_ci#define TW5864_PCI_VLC_BURST_ENB BIT(27) 128162306a36Sopenharmony_ci/* ddr burst enable (1 enable, and must set DDR_BRST_EN) */ 128262306a36Sopenharmony_ci#define TW5864_PCI_DDR_BURST_ENB BIT(28) 128362306a36Sopenharmony_ci 128462306a36Sopenharmony_ci/* 128562306a36Sopenharmony_ci * Because preview and audio have 16 channels separately, so using this 128662306a36Sopenharmony_ci * registers to indicate interrupt status for every channels. This is secondary 128762306a36Sopenharmony_ci * interrupt status register. OR operating of the PREV_INTR_REG is 128862306a36Sopenharmony_ci * PREV_EOF_INTR, OR operating of the AU_INTR_REG bits is AUDIO_EOF_INTR 128962306a36Sopenharmony_ci */ 129062306a36Sopenharmony_ci#define TW5864_PREV_AND_AU_INTR 0x18008 129162306a36Sopenharmony_ci/* Define controls in register TW5864_PREV_AND_AU_INTR */ 129262306a36Sopenharmony_ci/* preview eof interrupt flag */ 129362306a36Sopenharmony_ci#define TW5864_PREV_INTR_REG 0x0000ffff 129462306a36Sopenharmony_ci#define TW5864_AU_INTR_REG_SHIFT 16 129562306a36Sopenharmony_ci/* audio eof interrupt flag */ 129662306a36Sopenharmony_ci#define TW5864_AU_INTR_REG (0xffff << 16) 129762306a36Sopenharmony_ci 129862306a36Sopenharmony_ci#define TW5864_MASTER_ENB_REG 0x1800c 129962306a36Sopenharmony_ci/* Define controls in register TW5864_MASTER_ENB_REG */ 130062306a36Sopenharmony_ci/* master enable */ 130162306a36Sopenharmony_ci#define TW5864_PCI_VLC_INTR_ENB BIT(1) 130262306a36Sopenharmony_ci/* mvd and vlc master enable */ 130362306a36Sopenharmony_ci#define TW5864_PCI_PREV_INTR_ENB BIT(4) 130462306a36Sopenharmony_ci/* ad vsync master enable */ 130562306a36Sopenharmony_ci#define TW5864_PCI_PREV_OF_INTR_ENB BIT(5) 130662306a36Sopenharmony_ci/* jpeg master enable */ 130762306a36Sopenharmony_ci#define TW5864_PCI_JPEG_INTR_ENB BIT(7) 130862306a36Sopenharmony_ci/* preview master enable */ 130962306a36Sopenharmony_ci#define TW5864_PCI_AUD_INTR_ENB BIT(8) 131062306a36Sopenharmony_ci 131162306a36Sopenharmony_ci/* 131262306a36Sopenharmony_ci * Every channel of preview and audio have ping-pong buffers in system memory, 131362306a36Sopenharmony_ci * this register is the buffer flag to notify software which buffer is been 131462306a36Sopenharmony_ci * operated. 131562306a36Sopenharmony_ci */ 131662306a36Sopenharmony_ci#define TW5864_PREV_AND_AU_BUF_FLAG 0x18010 131762306a36Sopenharmony_ci/* Define controls in register TW5864_PREV_AND_AU_BUF_FLAG */ 131862306a36Sopenharmony_ci/* preview buffer A/B flag */ 131962306a36Sopenharmony_ci#define TW5864_PREV_BUF_FLAG 0xffff 132062306a36Sopenharmony_ci#define TW5864_AUDIO_BUF_FLAG_SHIFT 16 132162306a36Sopenharmony_ci/* audio buffer A/B flag */ 132262306a36Sopenharmony_ci#define TW5864_AUDIO_BUF_FLAG (0xffff << 16) 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ci#define TW5864_IIC 0x18014 132562306a36Sopenharmony_ci/* Define controls in register TW5864_IIC */ 132662306a36Sopenharmony_ci/* register data */ 132762306a36Sopenharmony_ci#define TW5864_IIC_DATA 0x00ff 132862306a36Sopenharmony_ci#define TW5864_IIC_REG_ADDR_SHIFT 8 132962306a36Sopenharmony_ci/* register addr */ 133062306a36Sopenharmony_ci#define TW5864_IIC_REG_ADDR (0xff << 8) 133162306a36Sopenharmony_ci/* rd/wr flag rd=1,wr=0 */ 133262306a36Sopenharmony_ci#define TW5864_IIC_RW BIT(16) 133362306a36Sopenharmony_ci#define TW5864_IIC_DEV_ADDR_SHIFT 17 133462306a36Sopenharmony_ci/* device addr */ 133562306a36Sopenharmony_ci#define TW5864_IIC_DEV_ADDR (0x7f << 17) 133662306a36Sopenharmony_ci/* 133762306a36Sopenharmony_ci * iic done, software kick off one time iic transaction through setting this 133862306a36Sopenharmony_ci * bit to 1. Then poll this bit, value 1 indicate iic transaction have 133962306a36Sopenharmony_ci * completed, if read, valid data have been stored in iic_data 134062306a36Sopenharmony_ci */ 134162306a36Sopenharmony_ci#define TW5864_IIC_DONE BIT(24) 134262306a36Sopenharmony_ci 134362306a36Sopenharmony_ci#define TW5864_RST_AND_IF_INFO 0x18018 134462306a36Sopenharmony_ci/* Define controls in register TW5864_RST_AND_IF_INFO */ 134562306a36Sopenharmony_ci/* application software soft reset */ 134662306a36Sopenharmony_ci#define TW5864_APP_SOFT_RST BIT(0) 134762306a36Sopenharmony_ci#define TW5864_PCI_INF_VERSION_SHIFT 16 134862306a36Sopenharmony_ci/* PCI interface version, read only */ 134962306a36Sopenharmony_ci#define TW5864_PCI_INF_VERSION (0xffff << 16) 135062306a36Sopenharmony_ci 135162306a36Sopenharmony_ci/* vlc stream crc value, it is calculated in pci module */ 135262306a36Sopenharmony_ci#define TW5864_VLC_CRC_REG 0x1801c 135362306a36Sopenharmony_ci/* 135462306a36Sopenharmony_ci * vlc max length, it is defined by software based on software assign memory 135562306a36Sopenharmony_ci * space for vlc 135662306a36Sopenharmony_ci */ 135762306a36Sopenharmony_ci#define TW5864_VLC_MAX_LENGTH 0x18020 135862306a36Sopenharmony_ci/* vlc length of one frame */ 135962306a36Sopenharmony_ci#define TW5864_VLC_LENGTH 0x18024 136062306a36Sopenharmony_ci/* vlc original crc value */ 136162306a36Sopenharmony_ci#define TW5864_VLC_INTRA_CRC_I_REG 0x18028 136262306a36Sopenharmony_ci/* vlc original crc value */ 136362306a36Sopenharmony_ci#define TW5864_VLC_INTRA_CRC_O_REG 0x1802c 136462306a36Sopenharmony_ci/* mv stream crc value, it is calculated in pci module */ 136562306a36Sopenharmony_ci#define TW5864_VLC_PAR_CRC_REG 0x18030 136662306a36Sopenharmony_ci/* mv length */ 136762306a36Sopenharmony_ci#define TW5864_VLC_PAR_LENGTH_REG 0x18034 136862306a36Sopenharmony_ci/* mv original crc value */ 136962306a36Sopenharmony_ci#define TW5864_VLC_PAR_I_REG 0x18038 137062306a36Sopenharmony_ci/* mv original crc value */ 137162306a36Sopenharmony_ci#define TW5864_VLC_PAR_O_REG 0x1803c 137262306a36Sopenharmony_ci 137362306a36Sopenharmony_ci/* 137462306a36Sopenharmony_ci * Configuration register for 9[or 10] CIFs or 1D1+15QCIF Preview mode. 137562306a36Sopenharmony_ci * PREV_PCI_ENB_CHN[0] Enable 9th preview channel (9CIF prev) or 1D1 channel in 137662306a36Sopenharmony_ci * (1D1+15QCIF prev) 137762306a36Sopenharmony_ci * PREV_PCI_ENB_CHN[1] Enable 10th preview channel 137862306a36Sopenharmony_ci */ 137962306a36Sopenharmony_ci#define TW5864_PREV_PCI_ENB_CHN 0x18040 138062306a36Sopenharmony_ci/* Description skipped. */ 138162306a36Sopenharmony_ci#define TW5864_PREV_FRAME_FORMAT_IN 0x18044 138262306a36Sopenharmony_ci/* IIC enable */ 138362306a36Sopenharmony_ci#define TW5864_IIC_ENB 0x18048 138462306a36Sopenharmony_ci/* 138562306a36Sopenharmony_ci * Timer interrupt interval 138662306a36Sopenharmony_ci * 0 1ms 138762306a36Sopenharmony_ci * 1 2ms 138862306a36Sopenharmony_ci * 2 4ms 138962306a36Sopenharmony_ci * 3 8ms 139062306a36Sopenharmony_ci */ 139162306a36Sopenharmony_ci#define TW5864_PCI_INTTM_SCALE 0x1804c 139262306a36Sopenharmony_ci 139362306a36Sopenharmony_ci/* 139462306a36Sopenharmony_ci * The above register is pci base address registers. Application software will 139562306a36Sopenharmony_ci * initialize them to tell chip where the corresponding stream will be dumped 139662306a36Sopenharmony_ci * to. Application software will select appropriate base address interval based 139762306a36Sopenharmony_ci * on the stream length. 139862306a36Sopenharmony_ci */ 139962306a36Sopenharmony_ci/* VLC stream base address */ 140062306a36Sopenharmony_ci#define TW5864_VLC_STREAM_BASE_ADDR 0x18080 140162306a36Sopenharmony_ci/* MV stream base address */ 140262306a36Sopenharmony_ci#define TW5864_MV_STREAM_BASE_ADDR 0x18084 140362306a36Sopenharmony_ci/* 0x180a0 ~ 0x180bc: audio burst base address. Skipped. */ 140462306a36Sopenharmony_ci/* 0x180c0 ~ 0x180dc: JPEG Push Mode Buffer Base Address. Skipped. */ 140562306a36Sopenharmony_ci/* 0x18100 ~ 0x1817c: preview burst base address. Skipped. */ 140662306a36Sopenharmony_ci 140762306a36Sopenharmony_ci/* 0x80000 ~ 0x87fff - DDR Burst RW Register Map */ 140862306a36Sopenharmony_ci#define TW5864_DDR_CTL 0x80000 140962306a36Sopenharmony_ci/* Define controls in register TW5864_DDR_CTL */ 141062306a36Sopenharmony_ci#define TW5864_BRST_LENGTH_SHIFT 2 141162306a36Sopenharmony_ci/* Length of 32-bit data burst */ 141262306a36Sopenharmony_ci#define TW5864_BRST_LENGTH (0x3fff << 2) 141362306a36Sopenharmony_ci/* 141462306a36Sopenharmony_ci * Burst Read/Write 141562306a36Sopenharmony_ci * 0 Read Burst from DDR 141662306a36Sopenharmony_ci * 1 Write Burst to DDR 141762306a36Sopenharmony_ci */ 141862306a36Sopenharmony_ci#define TW5864_BRST_RW BIT(16) 141962306a36Sopenharmony_ci/* Begin a new DDR Burst. This bit is self cleared */ 142062306a36Sopenharmony_ci#define TW5864_NEW_BRST_CMD BIT(17) 142162306a36Sopenharmony_ci/* DDR Burst End Flag */ 142262306a36Sopenharmony_ci#define TW5864_BRST_END BIT(24) 142362306a36Sopenharmony_ci/* Enable Error Interrupt for Single DDR Access */ 142462306a36Sopenharmony_ci#define TW5864_SING_ERR_INTR BIT(25) 142562306a36Sopenharmony_ci/* Enable Error Interrupt for Burst DDR Access */ 142662306a36Sopenharmony_ci#define TW5864_BRST_ERR_INTR BIT(26) 142762306a36Sopenharmony_ci/* Enable Interrupt for End of DDR Burst Access */ 142862306a36Sopenharmony_ci#define TW5864_BRST_END_INTR BIT(27) 142962306a36Sopenharmony_ci/* DDR Single Access Error Flag */ 143062306a36Sopenharmony_ci#define TW5864_SINGLE_ERR BIT(28) 143162306a36Sopenharmony_ci/* DDR Single Access Busy Flag */ 143262306a36Sopenharmony_ci#define TW5864_SINGLE_BUSY BIT(29) 143362306a36Sopenharmony_ci/* DDR Burst Access Error Flag */ 143462306a36Sopenharmony_ci#define TW5864_BRST_ERR BIT(30) 143562306a36Sopenharmony_ci/* DDR Burst Access Busy Flag */ 143662306a36Sopenharmony_ci#define TW5864_BRST_BUSY BIT(31) 143762306a36Sopenharmony_ci 143862306a36Sopenharmony_ci/* [27:0] DDR Access Address. Bit [1:0] has to be 0 */ 143962306a36Sopenharmony_ci#define TW5864_DDR_ADDR 0x80004 144062306a36Sopenharmony_ci/* DDR Access Internal Buffer Address. Bit [1:0] has to be 0 */ 144162306a36Sopenharmony_ci#define TW5864_DPR_BUF_ADDR 0x80008 144262306a36Sopenharmony_ci/* SRAM Buffer MPI Access Space. Totally 16 KB */ 144362306a36Sopenharmony_ci#define TW5864_DPR_BUF_START 0x84000 144462306a36Sopenharmony_ci/* 0x84000 - 0x87ffc */ 144562306a36Sopenharmony_ci#define TW5864_DPR_BUF_SIZE 0x4000 144662306a36Sopenharmony_ci 144762306a36Sopenharmony_ci/* Indirect Map Space */ 144862306a36Sopenharmony_ci/* 144962306a36Sopenharmony_ci * The indirect space is accessed through 0xb800 ~ 0xb807 registers in direct 145062306a36Sopenharmony_ci * access space 145162306a36Sopenharmony_ci */ 145262306a36Sopenharmony_ci/* Analog Video / Audio Decoder / Encoder */ 145362306a36Sopenharmony_ci/* Allowed channel values: [0; 3] */ 145462306a36Sopenharmony_ci/* Read-only register */ 145562306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0(channel) (0x000 + channel * 0x010) 145662306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_0 */ 145762306a36Sopenharmony_ci/* 145862306a36Sopenharmony_ci * 1 Video not present. (sync is not detected in number of consecutive line 145962306a36Sopenharmony_ci * periods specified by MISSCNT register) 146062306a36Sopenharmony_ci * 0 Video detected. 146162306a36Sopenharmony_ci */ 146262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_VDLOSS BIT(7) 146362306a36Sopenharmony_ci/* 146462306a36Sopenharmony_ci * 1 Horizontal sync PLL is locked to the incoming video source. 146562306a36Sopenharmony_ci * 0 Horizontal sync PLL is not locked. 146662306a36Sopenharmony_ci */ 146762306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_HLOCK BIT(6) 146862306a36Sopenharmony_ci/* 146962306a36Sopenharmony_ci * 1 Sub-carrier PLL is locked to the incoming video source. 147062306a36Sopenharmony_ci * 0 Sub-carrier PLL is not locked. 147162306a36Sopenharmony_ci */ 147262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_SLOCK BIT(5) 147362306a36Sopenharmony_ci/* 147462306a36Sopenharmony_ci * 1 Even field is being decoded. 147562306a36Sopenharmony_ci * 0 Odd field is being decoded. 147662306a36Sopenharmony_ci */ 147762306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_FLD BIT(4) 147862306a36Sopenharmony_ci/* 147962306a36Sopenharmony_ci * 1 Vertical logic is locked to the incoming video source. 148062306a36Sopenharmony_ci * 0 Vertical logic is not locked. 148162306a36Sopenharmony_ci */ 148262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_VLOCK BIT(3) 148362306a36Sopenharmony_ci/* 148462306a36Sopenharmony_ci * 1 No color burst signal detected. 148562306a36Sopenharmony_ci * 0 Color burst signal detected. 148662306a36Sopenharmony_ci */ 148762306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_MONO BIT(1) 148862306a36Sopenharmony_ci/* 148962306a36Sopenharmony_ci * 0 60Hz source detected 149062306a36Sopenharmony_ci * 1 50Hz source detected 149162306a36Sopenharmony_ci * The actual vertical scanning frequency depends on the current standard 149262306a36Sopenharmony_ci * invoked. 149362306a36Sopenharmony_ci */ 149462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_0_DET50 BIT(0) 149562306a36Sopenharmony_ci 149662306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1(channel) (0x001 + channel * 0x010) 149762306a36Sopenharmony_ci/* VCR signal indicator. Read-only. */ 149862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_VCR BIT(7) 149962306a36Sopenharmony_ci/* Weak signal indicator 2. Read-only. */ 150062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_WKAIR BIT(6) 150162306a36Sopenharmony_ci/* Weak signal indicator controlled by WKTH. Read-only. */ 150262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_WKAIR1 BIT(5) 150362306a36Sopenharmony_ci/* 150462306a36Sopenharmony_ci * 1 = Standard signal 150562306a36Sopenharmony_ci * 0 = Non-standard signal 150662306a36Sopenharmony_ci * Read-only 150762306a36Sopenharmony_ci */ 150862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_VSTD BIT(4) 150962306a36Sopenharmony_ci/* 151062306a36Sopenharmony_ci * 1 = Non-interlaced signal 151162306a36Sopenharmony_ci * 0 = interlaced signal 151262306a36Sopenharmony_ci * Read-only 151362306a36Sopenharmony_ci */ 151462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_NINTL BIT(3) 151562306a36Sopenharmony_ci/* 151662306a36Sopenharmony_ci * Vertical Sharpness Control. Writable. 151762306a36Sopenharmony_ci * 0 = None (default) 151862306a36Sopenharmony_ci * 7 = Highest 151962306a36Sopenharmony_ci * **Note: VSHP must be set to '0' if COMB = 0 152062306a36Sopenharmony_ci */ 152162306a36Sopenharmony_ci#define TW5864_INDIR_VIN_1_VSHP 0x07 152262306a36Sopenharmony_ci 152362306a36Sopenharmony_ci/* HDELAY_XY[7:0] */ 152462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_2_HDELAY_XY_LO(channel) (0x002 + channel * 0x010) 152562306a36Sopenharmony_ci/* HACTIVE_XY[7:0] */ 152662306a36Sopenharmony_ci#define TW5864_INDIR_VIN_3_HACTIVE_XY_LO(channel) (0x003 + channel * 0x010) 152762306a36Sopenharmony_ci/* VDELAY_XY[7:0] */ 152862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_4_VDELAY_XY_LO(channel) (0x004 + channel * 0x010) 152962306a36Sopenharmony_ci/* VACTIVE_XY[7:0] */ 153062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_5_VACTIVE_XY_LO(channel) (0x005 + channel * 0x010) 153162306a36Sopenharmony_ci 153262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6(channel) (0x006 + channel * 0x010) 153362306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_6 */ 153462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6_HDELAY_XY_HI 0x03 153562306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6_HACTIVE_XY_HI_SHIFT 2 153662306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6_HACTIVE_XY_HI (0x03 << 2) 153762306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6_VDELAY_XY_HI BIT(4) 153862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_6_VACTIVE_XY_HI BIT(5) 153962306a36Sopenharmony_ci 154062306a36Sopenharmony_ci/* 154162306a36Sopenharmony_ci * HDELAY_XY This 10bit register defines the starting location of horizontal 154262306a36Sopenharmony_ci * active pixel for display / record path. A unit is 1 pixel. The default value 154362306a36Sopenharmony_ci * is 0x00f for NTSC and 0x00a for PAL. 154462306a36Sopenharmony_ci * 154562306a36Sopenharmony_ci * HACTIVE_XY This 10bit register defines the number of horizontal active pixel 154662306a36Sopenharmony_ci * for display / record path. A unit is 1 pixel. The default value is decimal 154762306a36Sopenharmony_ci * 720. 154862306a36Sopenharmony_ci * 154962306a36Sopenharmony_ci * VDELAY_XY This 9bit register defines the starting location of vertical 155062306a36Sopenharmony_ci * active for display / record path. A unit is 1 line. The default value is 155162306a36Sopenharmony_ci * decimal 6. 155262306a36Sopenharmony_ci * 155362306a36Sopenharmony_ci * VACTIVE_XY This 9bit register defines the number of vertical active lines 155462306a36Sopenharmony_ci * for display / record path. A unit is 1 line. The default value is decimal 155562306a36Sopenharmony_ci * 240. 155662306a36Sopenharmony_ci */ 155762306a36Sopenharmony_ci 155862306a36Sopenharmony_ci/* HUE These bits control the color hue as 2's complement number. They have 155962306a36Sopenharmony_ci * value from +36o (7Fh) to -36o (80h) with an increment of 2.8o. The 2 LSB has 156062306a36Sopenharmony_ci * no effect. The positive value gives greenish tone and negative value gives 156162306a36Sopenharmony_ci * purplish tone. The default value is 0o (00h). This is effective only on NTSC 156262306a36Sopenharmony_ci * system. The default is 00h. 156362306a36Sopenharmony_ci */ 156462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_7_HUE(channel) (0x007 + channel * 0x010) 156562306a36Sopenharmony_ci 156662306a36Sopenharmony_ci#define TW5864_INDIR_VIN_8(channel) (0x008 + channel * 0x010) 156762306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_8 */ 156862306a36Sopenharmony_ci/* 156962306a36Sopenharmony_ci * This bit controls the center frequency of the peaking filter. 157062306a36Sopenharmony_ci * The corresponding gain adjustment is HFLT. 157162306a36Sopenharmony_ci * 0 Low 157262306a36Sopenharmony_ci * 1 center 157362306a36Sopenharmony_ci */ 157462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_8_SCURVE BIT(7) 157562306a36Sopenharmony_ci/* CTI level selection. The default is 1. 157662306a36Sopenharmony_ci * 0 None 157762306a36Sopenharmony_ci * 3 Highest 157862306a36Sopenharmony_ci */ 157962306a36Sopenharmony_ci#define TW5864_INDIR_VIN_8_CTI_SHIFT 4 158062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_8_CTI (0x03 << 4) 158162306a36Sopenharmony_ci 158262306a36Sopenharmony_ci/* 158362306a36Sopenharmony_ci * These bits control the amount of sharpness enhancement on the luminance 158462306a36Sopenharmony_ci * signals. There are 16 levels of control with "0" having no effect on the 158562306a36Sopenharmony_ci * output image. 1 through 15 provides sharpness enhancement with "F" being the 158662306a36Sopenharmony_ci * strongest. The default is 1. 158762306a36Sopenharmony_ci */ 158862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_8_SHARPNESS 0x0f 158962306a36Sopenharmony_ci 159062306a36Sopenharmony_ci/* 159162306a36Sopenharmony_ci * These bits control the luminance contrast gain. A value of 100 (64h) has a 159262306a36Sopenharmony_ci * gain of 1. The range adjustment is from 0% to 255% at 1% per step. The 159362306a36Sopenharmony_ci * default is 64h. 159462306a36Sopenharmony_ci */ 159562306a36Sopenharmony_ci#define TW5864_INDIR_VIN_9_CNTRST(channel) (0x009 + channel * 0x010) 159662306a36Sopenharmony_ci 159762306a36Sopenharmony_ci/* 159862306a36Sopenharmony_ci * These bits control the brightness. They have value of -128 to 127 in 2's 159962306a36Sopenharmony_ci * complement form. Positive value increases brightness. A value 0 has no 160062306a36Sopenharmony_ci * effect on the data. The default is 00h. 160162306a36Sopenharmony_ci */ 160262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_A_BRIGHT(channel) (0x00a + channel * 0x010) 160362306a36Sopenharmony_ci 160462306a36Sopenharmony_ci/* 160562306a36Sopenharmony_ci * These bits control the digital gain adjustment to the U (or Cb) component of 160662306a36Sopenharmony_ci * the digital video signal. The color saturation can be adjusted by adjusting 160762306a36Sopenharmony_ci * the U and V color gain components by the same amount in the normal 160862306a36Sopenharmony_ci * situation. The U and V can also be adjusted independently to provide greater 160962306a36Sopenharmony_ci * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 161062306a36Sopenharmony_ci * gain of 100%. The default is 80h. 161162306a36Sopenharmony_ci */ 161262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_B_SAT_U(channel) (0x00b + channel * 0x010) 161362306a36Sopenharmony_ci 161462306a36Sopenharmony_ci/* 161562306a36Sopenharmony_ci * These bits control the digital gain adjustment to the V (or Cr) component of 161662306a36Sopenharmony_ci * the digital video signal. The color saturation can be adjusted by adjusting 161762306a36Sopenharmony_ci * the U and V color gain components by the same amount in the normal 161862306a36Sopenharmony_ci * situation. The U and V can also be adjusted independently to provide greater 161962306a36Sopenharmony_ci * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 162062306a36Sopenharmony_ci * gain of 100%. The default is 80h. 162162306a36Sopenharmony_ci */ 162262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_C_SAT_V(channel) (0x00c + channel * 0x010) 162362306a36Sopenharmony_ci 162462306a36Sopenharmony_ci/* Read-only */ 162562306a36Sopenharmony_ci#define TW5864_INDIR_VIN_D(channel) (0x00d + channel * 0x010) 162662306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_D */ 162762306a36Sopenharmony_ci/* Macrovision color stripe detection may be un-reliable */ 162862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_D_CSBAD BIT(3) 162962306a36Sopenharmony_ci/* Macrovision AGC pulse detected */ 163062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_D_MCVSN BIT(2) 163162306a36Sopenharmony_ci/* Macrovision color stripe protection burst detected */ 163262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_D_CSTRIPE BIT(1) 163362306a36Sopenharmony_ci/* 163462306a36Sopenharmony_ci * This bit is valid only when color stripe protection is detected, i.e. if 163562306a36Sopenharmony_ci * CSTRIPE=1, 163662306a36Sopenharmony_ci * 1 Type 2 color stripe protection 163762306a36Sopenharmony_ci * 0 Type 3 color stripe protection 163862306a36Sopenharmony_ci */ 163962306a36Sopenharmony_ci#define TW5864_INDIR_VIN_D_CTYPE2 BIT(0) 164062306a36Sopenharmony_ci 164162306a36Sopenharmony_ci/* Read-only */ 164262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E(channel) (0x00e + channel * 0x010) 164362306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_E */ 164462306a36Sopenharmony_ci/* 164562306a36Sopenharmony_ci * Read-only. 164662306a36Sopenharmony_ci * 0 Idle 164762306a36Sopenharmony_ci * 1 Detection in progress 164862306a36Sopenharmony_ci */ 164962306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E_DETSTUS BIT(7) 165062306a36Sopenharmony_ci/* 165162306a36Sopenharmony_ci * STDNOW Current standard invoked 165262306a36Sopenharmony_ci * 0 NTSC (M) 165362306a36Sopenharmony_ci * 1 PAL (B, D, G, H, I) 165462306a36Sopenharmony_ci * 2 SECAM 165562306a36Sopenharmony_ci * 3 NTSC4.43 165662306a36Sopenharmony_ci * 4 PAL (M) 165762306a36Sopenharmony_ci * 5 PAL (CN) 165862306a36Sopenharmony_ci * 6 PAL 60 165962306a36Sopenharmony_ci * 7 Not valid 166062306a36Sopenharmony_ci */ 166162306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E_STDNOW_SHIFT 4 166262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E_STDNOW (0x07 << 4) 166362306a36Sopenharmony_ci 166462306a36Sopenharmony_ci/* 166562306a36Sopenharmony_ci * 1 Disable the shadow registers 166662306a36Sopenharmony_ci * 0 Enable VACTIVE and HDELAY shadow registers value depending on STANDARD. 166762306a36Sopenharmony_ci * (Default) 166862306a36Sopenharmony_ci */ 166962306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E_ATREG BIT(3) 167062306a36Sopenharmony_ci/* 167162306a36Sopenharmony_ci * STANDARD Standard selection 167262306a36Sopenharmony_ci * 0 NTSC (M) 167362306a36Sopenharmony_ci * 1 PAL (B, D, G, H, I) 167462306a36Sopenharmony_ci * 2 SECAM 167562306a36Sopenharmony_ci * 3 NTSC4.43 167662306a36Sopenharmony_ci * 4 PAL (M) 167762306a36Sopenharmony_ci * 5 PAL (CN) 167862306a36Sopenharmony_ci * 6 PAL 60 167962306a36Sopenharmony_ci * 7 Auto detection (Default) 168062306a36Sopenharmony_ci */ 168162306a36Sopenharmony_ci#define TW5864_INDIR_VIN_E_STANDARD 0x07 168262306a36Sopenharmony_ci 168362306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F(channel) (0x00f + channel * 0x010) 168462306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_VIN_F */ 168562306a36Sopenharmony_ci/* 168662306a36Sopenharmony_ci * 1 Writing 1 to this bit will manually initiate the auto format detection 168762306a36Sopenharmony_ci * process. This bit is a self-clearing bit 168862306a36Sopenharmony_ci * 0 Manual initiation of auto format detection is done. (Default) 168962306a36Sopenharmony_ci */ 169062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_ATSTART BIT(7) 169162306a36Sopenharmony_ci/* Enable recognition of PAL60 (Default) */ 169262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_PAL60EN BIT(6) 169362306a36Sopenharmony_ci/* Enable recognition of PAL (CN). (Default) */ 169462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALCNEN BIT(5) 169562306a36Sopenharmony_ci/* Enable recognition of PAL (M). (Default) */ 169662306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALMEN BIT(4) 169762306a36Sopenharmony_ci/* Enable recognition of NTSC 4.43. (Default) */ 169862306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_NTSC44EN BIT(3) 169962306a36Sopenharmony_ci/* Enable recognition of SECAM. (Default) */ 170062306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_SECAMEN BIT(2) 170162306a36Sopenharmony_ci/* Enable recognition of PAL (B, D, G, H, I). (Default) */ 170262306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_PALBEN BIT(1) 170362306a36Sopenharmony_ci/* Enable recognition of NTSC (M). (Default) */ 170462306a36Sopenharmony_ci#define TW5864_INDIR_VIN_F_NTSCEN BIT(0) 170562306a36Sopenharmony_ci 170662306a36Sopenharmony_ci/* Some registers skipped. */ 170762306a36Sopenharmony_ci 170862306a36Sopenharmony_ci/* Use falling edge to sample VD1-VD4 from 54 MHz to 108 MHz */ 170962306a36Sopenharmony_ci#define TW5864_INDIR_VD_108_POL 0x041 171062306a36Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_VD12 BIT(0) 171162306a36Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_VD34 BIT(1) 171262306a36Sopenharmony_ci#define TW5864_INDIR_VD_108_POL_BOTH \ 171362306a36Sopenharmony_ci (TW5864_INDIR_VD_108_POL_VD12 | TW5864_INDIR_VD_108_POL_VD34) 171462306a36Sopenharmony_ci 171562306a36Sopenharmony_ci/* Some registers skipped. */ 171662306a36Sopenharmony_ci 171762306a36Sopenharmony_ci/* 171862306a36Sopenharmony_ci * Audio Input ADC gain control 171962306a36Sopenharmony_ci * 0 0.25 172062306a36Sopenharmony_ci * 1 0.31 172162306a36Sopenharmony_ci * 2 0.38 172262306a36Sopenharmony_ci * 3 0.44 172362306a36Sopenharmony_ci * 4 0.50 172462306a36Sopenharmony_ci * 5 0.63 172562306a36Sopenharmony_ci * 6 0.75 172662306a36Sopenharmony_ci * 7 0.88 172762306a36Sopenharmony_ci * 8 1.00 (default) 172862306a36Sopenharmony_ci * 9 1.25 172962306a36Sopenharmony_ci * 10 1.50 173062306a36Sopenharmony_ci * 11 1.75 173162306a36Sopenharmony_ci * 12 2.00 173262306a36Sopenharmony_ci * 13 2.25 173362306a36Sopenharmony_ci * 14 2.50 173462306a36Sopenharmony_ci * 15 2.75 173562306a36Sopenharmony_ci */ 173662306a36Sopenharmony_ci/* [3:0] channel 0, [7:4] channel 1 */ 173762306a36Sopenharmony_ci#define TW5864_INDIR_AIGAIN1 0x060 173862306a36Sopenharmony_ci/* [3:0] channel 2, [7:4] channel 3 */ 173962306a36Sopenharmony_ci#define TW5864_INDIR_AIGAIN2 0x061 174062306a36Sopenharmony_ci 174162306a36Sopenharmony_ci/* Some registers skipped */ 174262306a36Sopenharmony_ci 174362306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x06D 0x06d 174462306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x06D */ 174562306a36Sopenharmony_ci/* 174662306a36Sopenharmony_ci * LAWMD Select u-Law/A-Law/PCM/SB data output format on ADATR and ADATM pin. 174762306a36Sopenharmony_ci * 0 PCM output (default) 174862306a36Sopenharmony_ci * 1 SB (Signed MSB bit in PCM data is inverted) output 174962306a36Sopenharmony_ci * 2 u-Law output 175062306a36Sopenharmony_ci * 3 A-Law output 175162306a36Sopenharmony_ci */ 175262306a36Sopenharmony_ci#define TW5864_INDIR_AIN_LAWMD_SHIFT 6 175362306a36Sopenharmony_ci#define TW5864_INDIR_AIN_LAWMD (0x03 << 6) 175462306a36Sopenharmony_ci/* 175562306a36Sopenharmony_ci * Disable the mixing ratio value for all audio. 175662306a36Sopenharmony_ci * 0 Apply individual mixing ratio value for each audio (default) 175762306a36Sopenharmony_ci * 1 Apply nominal value for all audio commonly 175862306a36Sopenharmony_ci */ 175962306a36Sopenharmony_ci#define TW5864_INDIR_AIN_MIX_DERATIO BIT(5) 176062306a36Sopenharmony_ci/* 176162306a36Sopenharmony_ci * Enable the mute function for audio channel AINn when n is 0 to 3. It effects 176262306a36Sopenharmony_ci * only for mixing. When n = 4, it enable the mute function of the playback 176362306a36Sopenharmony_ci * audio input. It effects only for single chip or the last stage chip 176462306a36Sopenharmony_ci * 0 Normal 176562306a36Sopenharmony_ci * 1 Muted (default) 176662306a36Sopenharmony_ci */ 176762306a36Sopenharmony_ci#define TW5864_INDIR_AIN_MIX_MUTE 0x1f 176862306a36Sopenharmony_ci 176962306a36Sopenharmony_ci/* Some registers skipped */ 177062306a36Sopenharmony_ci 177162306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3 0x0e3 177262306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x0E3 */ 177362306a36Sopenharmony_ci/* 177462306a36Sopenharmony_ci * ADATP signal is coming from external ADPCM decoder, instead of on-chip ADPCM 177562306a36Sopenharmony_ci * decoder 177662306a36Sopenharmony_ci */ 177762306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_EXT_ADATP BIT(7) 177862306a36Sopenharmony_ci/* ACLKP output signal polarity inverse */ 177962306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKPPOLO BIT(6) 178062306a36Sopenharmony_ci/* 178162306a36Sopenharmony_ci * ACLKR input signal polarity inverse. 178262306a36Sopenharmony_ci * 0 Not inversed (Default) 178362306a36Sopenharmony_ci * 1 Inversed 178462306a36Sopenharmony_ci */ 178562306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKRPOL BIT(5) 178662306a36Sopenharmony_ci/* 178762306a36Sopenharmony_ci * ACLKP input signal polarity inverse. 178862306a36Sopenharmony_ci * 0 Not inversed (Default) 178962306a36Sopenharmony_ci * 1 Inversed 179062306a36Sopenharmony_ci */ 179162306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_ACLKPPOLI BIT(4) 179262306a36Sopenharmony_ci/* 179362306a36Sopenharmony_ci * ACKI [21:0] control automatic set up with AFMD registers 179462306a36Sopenharmony_ci * This mode is only effective when ACLKRMASTER=1 179562306a36Sopenharmony_ci * 0 ACKI [21:0] registers set up ACKI control 179662306a36Sopenharmony_ci * 1 ACKI control is automatically set up by AFMD register values 179762306a36Sopenharmony_ci */ 179862306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_AFAUTO BIT(3) 179962306a36Sopenharmony_ci/* 180062306a36Sopenharmony_ci * AFAUTO control mode 180162306a36Sopenharmony_ci * 0 8kHz setting (Default) 180262306a36Sopenharmony_ci * 1 16kHz setting 180362306a36Sopenharmony_ci * 2 32kHz setting 180462306a36Sopenharmony_ci * 3 44.1kHz setting 180562306a36Sopenharmony_ci * 4 48kHz setting 180662306a36Sopenharmony_ci */ 180762306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E3_AFMD 0x07 180862306a36Sopenharmony_ci 180962306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4 0x0e4 181062306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_AIN_0x0ED */ 181162306a36Sopenharmony_ci/* 181262306a36Sopenharmony_ci * 8bit I2S Record output mode. 181362306a36Sopenharmony_ci * 0 L/R half length separated output (Default). 181462306a36Sopenharmony_ci * 1 One continuous packed output equal to DSP output format. 181562306a36Sopenharmony_ci */ 181662306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_I2S8MODE BIT(7) 181762306a36Sopenharmony_ci/* 181862306a36Sopenharmony_ci * Audio Clock Master ACLKR output wave format. 181962306a36Sopenharmony_ci * 0 High periods is one 27MHz clock period (default). 182062306a36Sopenharmony_ci * 1 Almost duty 50-50% clock output on ACLKR pin. If this mode is selected, two 182162306a36Sopenharmony_ci * times bigger number value need to be set up on the ACKI register. If 182262306a36Sopenharmony_ci * AFAUTO=1, ACKI control is automatically set up even if MASCKMD=1. 182362306a36Sopenharmony_ci */ 182462306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_MASCKMD BIT(6) 182562306a36Sopenharmony_ci/* Playback ACLKP/ASYNP/ADATP input data MSB-LSB swapping */ 182662306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_PBINSWAP BIT(5) 182762306a36Sopenharmony_ci/* 182862306a36Sopenharmony_ci * ASYNR input signal delay. 182962306a36Sopenharmony_ci * 0 No delay 183062306a36Sopenharmony_ci * 1 Add one 27MHz period delay in ASYNR signal input 183162306a36Sopenharmony_ci */ 183262306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ASYNRDLY BIT(4) 183362306a36Sopenharmony_ci/* 183462306a36Sopenharmony_ci * ASYNP input signal delay. 183562306a36Sopenharmony_ci * 0 no delay 183662306a36Sopenharmony_ci * 1 add one 27MHz period delay in ASYNP signal input 183762306a36Sopenharmony_ci */ 183862306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ASYNPDLY BIT(3) 183962306a36Sopenharmony_ci/* 184062306a36Sopenharmony_ci * ADATP input data delay by one ACLKP clock. 184162306a36Sopenharmony_ci * 0 No delay (Default). This is for I2S type 1T delay input interface. 184262306a36Sopenharmony_ci * 1 Add 1 ACLKP clock delay in ADATP input data. This is for left-justified 184362306a36Sopenharmony_ci * type 0T delay input interface. 184462306a36Sopenharmony_ci */ 184562306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_ADATPDLY BIT(2) 184662306a36Sopenharmony_ci/* 184762306a36Sopenharmony_ci * Select u-Law/A-Law/PCM/SB data input format on ADATP pin. 184862306a36Sopenharmony_ci * 0 PCM input (Default) 184962306a36Sopenharmony_ci * 1 SB (Signed MSB bit in PCM data is inverted) input 185062306a36Sopenharmony_ci * 2 u-Law input 185162306a36Sopenharmony_ci * 3 A-Law input 185262306a36Sopenharmony_ci */ 185362306a36Sopenharmony_ci#define TW5864_INDIR_AIN_0x0E4_INLAWMD 0x03 185462306a36Sopenharmony_ci 185562306a36Sopenharmony_ci/* 185662306a36Sopenharmony_ci * Enable state register updating and interrupt request of audio AIN5 detection 185762306a36Sopenharmony_ci * for each input 185862306a36Sopenharmony_ci */ 185962306a36Sopenharmony_ci#define TW5864_INDIR_AIN_A5DETENA 0x0e5 186062306a36Sopenharmony_ci 186162306a36Sopenharmony_ci/* Some registers skipped */ 186262306a36Sopenharmony_ci 186362306a36Sopenharmony_ci/* 186462306a36Sopenharmony_ci * [7:3]: DEV_ID The TW5864 product ID code is 01000 186562306a36Sopenharmony_ci * [2:0]: REV_ID The revision number is 0h 186662306a36Sopenharmony_ci */ 186762306a36Sopenharmony_ci#define TW5864_INDIR_ID 0x0fe 186862306a36Sopenharmony_ci 186962306a36Sopenharmony_ci#define TW5864_INDIR_IN_PIC_WIDTH(channel) (0x200 + 4 * channel) 187062306a36Sopenharmony_ci#define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel) 187162306a36Sopenharmony_ci#define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel) 187262306a36Sopenharmony_ci#define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel) 187362306a36Sopenharmony_ci 187462306a36Sopenharmony_ci/* Some registers skipped */ 187562306a36Sopenharmony_ci 187662306a36Sopenharmony_ci#define TW5864_INDIR_CROP_ETC 0x260 187762306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_CROP_ETC */ 187862306a36Sopenharmony_ci/* Enable cropping from 720 to 704 */ 187962306a36Sopenharmony_ci#define TW5864_INDIR_CROP_ETC_CROP_EN 0x4 188062306a36Sopenharmony_ci 188162306a36Sopenharmony_ci/* 188262306a36Sopenharmony_ci * Interrupt status register from the front-end. Write "1" to each bit to clear 188362306a36Sopenharmony_ci * the interrupt 188462306a36Sopenharmony_ci * 15:0 Motion detection interrupt for channel 0 ~ 15 188562306a36Sopenharmony_ci * 31:16 Night detection interrupt for channel 0 ~ 15 188662306a36Sopenharmony_ci * 47:32 Blind detection interrupt for channel 0 ~ 15 188762306a36Sopenharmony_ci * 63:48 No video interrupt for channel 0 ~ 15 188862306a36Sopenharmony_ci * 79:64 Line mode underflow interrupt for channel 0 ~ 15 188962306a36Sopenharmony_ci * 95:80 Line mode overflow interrupt for channel 0 ~ 15 189062306a36Sopenharmony_ci */ 189162306a36Sopenharmony_ci/* 0x2d0~0x2d7: [63:0] bits */ 189262306a36Sopenharmony_ci#define TW5864_INDIR_INTERRUPT1 0x2d0 189362306a36Sopenharmony_ci/* 0x2e0~0x2e3: [95:64] bits */ 189462306a36Sopenharmony_ci#define TW5864_INDIR_INTERRUPT2 0x2e0 189562306a36Sopenharmony_ci 189662306a36Sopenharmony_ci/* 189762306a36Sopenharmony_ci * Interrupt mask register for interrupts in 0x2d0 ~ 0x2d7 189862306a36Sopenharmony_ci * 15:0 Motion detection interrupt for channel 0 ~ 15 189962306a36Sopenharmony_ci * 31:16 Night detection interrupt for channel 0 ~ 15 190062306a36Sopenharmony_ci * 47:32 Blind detection interrupt for channel 0 ~ 15 190162306a36Sopenharmony_ci * 63:48 No video interrupt for channel 0 ~ 15 190262306a36Sopenharmony_ci * 79:64 Line mode underflow interrupt for channel 0 ~ 15 190362306a36Sopenharmony_ci * 95:80 Line mode overflow interrupt for channel 0 ~ 15 190462306a36Sopenharmony_ci */ 190562306a36Sopenharmony_ci/* 0x2d8~0x2df: [63:0] bits */ 190662306a36Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_MASK1 0x2d8 190762306a36Sopenharmony_ci/* 0x2e8~0x2eb: [95:64] bits */ 190862306a36Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_MASK2 0x2e8 190962306a36Sopenharmony_ci 191062306a36Sopenharmony_ci/* [11:0]: Interrupt summary register for interrupts & interrupt mask from in 191162306a36Sopenharmony_ci * 0x2d0 ~ 0x2d7 and 0x2d8 ~ 0x2df 191262306a36Sopenharmony_ci * bit 0: interrupt occurs in 0x2d0 & 0x2d8 191362306a36Sopenharmony_ci * bit 1: interrupt occurs in 0x2d1 & 0x2d9 191462306a36Sopenharmony_ci * bit 2: interrupt occurs in 0x2d2 & 0x2da 191562306a36Sopenharmony_ci * bit 3: interrupt occurs in 0x2d3 & 0x2db 191662306a36Sopenharmony_ci * bit 4: interrupt occurs in 0x2d4 & 0x2dc 191762306a36Sopenharmony_ci * bit 5: interrupt occurs in 0x2d5 & 0x2dd 191862306a36Sopenharmony_ci * bit 6: interrupt occurs in 0x2d6 & 0x2de 191962306a36Sopenharmony_ci * bit 7: interrupt occurs in 0x2d7 & 0x2df 192062306a36Sopenharmony_ci * bit 8: interrupt occurs in 0x2e0 & 0x2e8 192162306a36Sopenharmony_ci * bit 9: interrupt occurs in 0x2e1 & 0x2e9 192262306a36Sopenharmony_ci * bit 10: interrupt occurs in 0x2e2 & 0x2ea 192362306a36Sopenharmony_ci * bit 11: interrupt occurs in 0x2e3 & 0x2eb 192462306a36Sopenharmony_ci */ 192562306a36Sopenharmony_ci#define TW5864_INDIR_INTERRUPT_SUMMARY 0x2f0 192662306a36Sopenharmony_ci 192762306a36Sopenharmony_ci/* Motion / Blind / Night Detection */ 192862306a36Sopenharmony_ci/* valid value for channel is [0:15] */ 192962306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0(channel) (0x300 + channel * 0x08) 193062306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL0 */ 193162306a36Sopenharmony_ci/* 193262306a36Sopenharmony_ci * Disable the motion and blind detection. 193362306a36Sopenharmony_ci * 0 Enable motion and blind detection (default) 193462306a36Sopenharmony_ci * 1 Disable motion and blind detection 193562306a36Sopenharmony_ci */ 193662306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_DIS BIT(5) 193762306a36Sopenharmony_ci/* 193862306a36Sopenharmony_ci * Request to start motion detection on manual trigger mode 193962306a36Sopenharmony_ci * 0 None Operation (default) 194062306a36Sopenharmony_ci * 1 Request to start motion detection 194162306a36Sopenharmony_ci */ 194262306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_STRB BIT(3) 194362306a36Sopenharmony_ci/* 194462306a36Sopenharmony_ci * Select the trigger mode of motion detection 194562306a36Sopenharmony_ci * 0 Automatic trigger mode of motion detection (default) 194662306a36Sopenharmony_ci * 1 Manual trigger mode for motion detection 194762306a36Sopenharmony_ci */ 194862306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_MD_STRB_EN BIT(2) 194962306a36Sopenharmony_ci/* 195062306a36Sopenharmony_ci * Define the threshold of cell for blind detection. 195162306a36Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 195262306a36Sopenharmony_ci * : : 195362306a36Sopenharmony_ci * 3 High threshold (Less sensitive) 195462306a36Sopenharmony_ci */ 195562306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL0_BD_CELSENS 0x03 195662306a36Sopenharmony_ci 195762306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1(channel) (0x301 + channel * 0x08) 195862306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL1 */ 195962306a36Sopenharmony_ci/* 196062306a36Sopenharmony_ci * Control the temporal sensitivity of motion detector. 196162306a36Sopenharmony_ci * 0 More Sensitive (default) 196262306a36Sopenharmony_ci * : : 196362306a36Sopenharmony_ci * 15 Less Sensitive 196462306a36Sopenharmony_ci */ 196562306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS_SHIFT 4 196662306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS (0x0f << 4) 196762306a36Sopenharmony_ci/* 196862306a36Sopenharmony_ci * Adjust the horizontal starting position for motion detection 196962306a36Sopenharmony_ci * 0 0 pixel (default) 197062306a36Sopenharmony_ci * : : 197162306a36Sopenharmony_ci * 15 15 pixels 197262306a36Sopenharmony_ci */ 197362306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL1_MD_PIXEL_OS 0x0f 197462306a36Sopenharmony_ci 197562306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2(channel) (0x302 + channel * 0x08) 197662306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL2 */ 197762306a36Sopenharmony_ci/* 197862306a36Sopenharmony_ci * Control the updating time of reference field for motion detection. 197962306a36Sopenharmony_ci * 0 Update reference field every field (default) 198062306a36Sopenharmony_ci * 1 Update reference field according to MD_SPEED 198162306a36Sopenharmony_ci */ 198262306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_REFFLD BIT(7) 198362306a36Sopenharmony_ci/* 198462306a36Sopenharmony_ci * Select the field for motion detection. 198562306a36Sopenharmony_ci * 0 Detecting motion for only odd field (default) 198662306a36Sopenharmony_ci * 1 Detecting motion for only even field 198762306a36Sopenharmony_ci * 2 Detecting motion for any field 198862306a36Sopenharmony_ci * 3 Detecting motion for both odd and even field 198962306a36Sopenharmony_ci */ 199062306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_FIELD_SHIFT 5 199162306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_FIELD (0x03 << 5) 199262306a36Sopenharmony_ci/* 199362306a36Sopenharmony_ci * Control the level sensitivity of motion detector. 199462306a36Sopenharmony_ci * 0 More sensitive (default) 199562306a36Sopenharmony_ci * : : 199662306a36Sopenharmony_ci * 15 Less sensitive 199762306a36Sopenharmony_ci */ 199862306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL2_MD_LVSENS 0x1f 199962306a36Sopenharmony_ci 200062306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3(channel) (0x303 + channel * 0x08) 200162306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL3 */ 200262306a36Sopenharmony_ci/* 200362306a36Sopenharmony_ci * Define the threshold of sub-cell number for motion detection. 200462306a36Sopenharmony_ci * 0 Motion is detected if 1 sub-cell has motion (More sensitive) (default) 200562306a36Sopenharmony_ci * 1 Motion is detected if 2 sub-cells have motion 200662306a36Sopenharmony_ci * 2 Motion is detected if 3 sub-cells have motion 200762306a36Sopenharmony_ci * 3 Motion is detected if 4 sub-cells have motion (Less sensitive) 200862306a36Sopenharmony_ci */ 200962306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS_SHIFT 6 201062306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS (0x03 << 6) 201162306a36Sopenharmony_ci/* 201262306a36Sopenharmony_ci * Control the velocity of motion detector. 201362306a36Sopenharmony_ci * Large value is suitable for slow motion detection. 201462306a36Sopenharmony_ci * In MD_DUAL_EN = 1, MD_SPEED should be limited to 0 ~ 31. 201562306a36Sopenharmony_ci * 0 1 field intervals (default) 201662306a36Sopenharmony_ci * 1 2 field intervals 201762306a36Sopenharmony_ci * : : 201862306a36Sopenharmony_ci * 61 62 field intervals 201962306a36Sopenharmony_ci * 62 63 field intervals 202062306a36Sopenharmony_ci * 63 Not supported 202162306a36Sopenharmony_ci */ 202262306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL3_MD_SPEED 0x3f 202362306a36Sopenharmony_ci 202462306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4(channel) (0x304 + channel * 0x08) 202562306a36Sopenharmony_ci/* Define controls in register TW5864_INDIR_DETECTION_CTL4 */ 202662306a36Sopenharmony_ci/* 202762306a36Sopenharmony_ci * Control the spatial sensitivity of motion detector. 202862306a36Sopenharmony_ci * 0 More Sensitive (default) 202962306a36Sopenharmony_ci * : : 203062306a36Sopenharmony_ci * 15 Less Sensitive 203162306a36Sopenharmony_ci */ 203262306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS_SHIFT 4 203362306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS (0x0f << 4) 203462306a36Sopenharmony_ci/* 203562306a36Sopenharmony_ci * Define the threshold of level for blind detection. 203662306a36Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 203762306a36Sopenharmony_ci * : : 203862306a36Sopenharmony_ci * 15 High threshold (Less sensitive) 203962306a36Sopenharmony_ci */ 204062306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL4_BD_LVSENS 0x0f 204162306a36Sopenharmony_ci 204262306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5(channel) (0x305 + channel * 0x08) 204362306a36Sopenharmony_ci/* 204462306a36Sopenharmony_ci * Define the threshold of temporal sensitivity for night detection. 204562306a36Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 204662306a36Sopenharmony_ci * : : 204762306a36Sopenharmony_ci * 15 High threshold (Less sensitive) 204862306a36Sopenharmony_ci */ 204962306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS_SHIFT 4 205062306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS (0x0f << 4) 205162306a36Sopenharmony_ci/* 205262306a36Sopenharmony_ci * Define the threshold of level for night detection. 205362306a36Sopenharmony_ci * 0 Low threshold (More sensitive) (default) 205462306a36Sopenharmony_ci * : : 205562306a36Sopenharmony_ci * 3 High threshold (Less sensitive) 205662306a36Sopenharmony_ci */ 205762306a36Sopenharmony_ci#define TW5864_INDIR_DETECTION_CTL5_ND_LVSENS 0x0f 205862306a36Sopenharmony_ci 205962306a36Sopenharmony_ci/* 206062306a36Sopenharmony_ci * [11:0] The base address of the motion detection buffer. This address is in 206162306a36Sopenharmony_ci * unit of 64K bytes. The generated DDR address will be {MD_BASE_ADDR, 206262306a36Sopenharmony_ci * 16"h0000}. The default value should be 12"h000 206362306a36Sopenharmony_ci */ 206462306a36Sopenharmony_ci#define TW5864_INDIR_MD_BASE_ADDR 0x380 206562306a36Sopenharmony_ci 206662306a36Sopenharmony_ci/* 206762306a36Sopenharmony_ci * This controls the channel of the motion detection result shown in register 206862306a36Sopenharmony_ci * 0x3a0 ~ 0x3b7. Before reading back motion result, always set this first. 206962306a36Sopenharmony_ci */ 207062306a36Sopenharmony_ci#define TW5864_INDIR_RGR_MOTION_SEL 0x382 207162306a36Sopenharmony_ci 207262306a36Sopenharmony_ci/* [15:0] MD strobe has been performed at channel n (read only) */ 207362306a36Sopenharmony_ci#define TW5864_INDIR_MD_STRB 0x386 207462306a36Sopenharmony_ci/* NO_VIDEO Detected from channel n (read only) */ 207562306a36Sopenharmony_ci#define TW5864_INDIR_NOVID_DET 0x388 207662306a36Sopenharmony_ci/* Motion Detected from channel n (read only) */ 207762306a36Sopenharmony_ci#define TW5864_INDIR_MD_DET 0x38a 207862306a36Sopenharmony_ci/* Blind Detected from channel n (read only) */ 207962306a36Sopenharmony_ci#define TW5864_INDIR_BD_DET 0x38c 208062306a36Sopenharmony_ci/* Night Detected from channel n (read only) */ 208162306a36Sopenharmony_ci#define TW5864_INDIR_ND_DET 0x38e 208262306a36Sopenharmony_ci 208362306a36Sopenharmony_ci/* 192 bit motion flag of the channel specified by RGR_MOTION_SEL in 0x382 */ 208462306a36Sopenharmony_ci#define TW5864_INDIR_MOTION_FLAG 0x3a0 208562306a36Sopenharmony_ci#define TW5864_INDIR_MOTION_FLAG_BYTE_COUNT 24 208662306a36Sopenharmony_ci 208762306a36Sopenharmony_ci/* 208862306a36Sopenharmony_ci * [9:0] The motion cell count of a specific channel selected by 0x382. This is 208962306a36Sopenharmony_ci * for DI purpose 209062306a36Sopenharmony_ci */ 209162306a36Sopenharmony_ci#define TW5864_INDIR_MD_DI_CNT 0x3b8 209262306a36Sopenharmony_ci/* The motion detection cell sensitivity for DI purpose */ 209362306a36Sopenharmony_ci#define TW5864_INDIR_MD_DI_CELLSENS 0x3ba 209462306a36Sopenharmony_ci/* The motion detection threshold level for DI purpose */ 209562306a36Sopenharmony_ci#define TW5864_INDIR_MD_DI_LVSENS 0x3bb 209662306a36Sopenharmony_ci 209762306a36Sopenharmony_ci/* 192 bit motion mask of the channel specified by MASK_CH_SEL in 0x3fe */ 209862306a36Sopenharmony_ci#define TW5864_INDIR_MOTION_MASK 0x3e0 209962306a36Sopenharmony_ci#define TW5864_INDIR_MOTION_MASK_BYTE_COUNT 24 210062306a36Sopenharmony_ci 210162306a36Sopenharmony_ci/* [4:0] The channel selection to access masks in 0x3e0 ~ 0x3f7 */ 210262306a36Sopenharmony_ci#define TW5864_INDIR_MASK_CH_SEL 0x3fe 210362306a36Sopenharmony_ci 210462306a36Sopenharmony_ci/* Clock PLL / Analog IP Control */ 210562306a36Sopenharmony_ci/* Some registers skipped */ 210662306a36Sopenharmony_ci 210762306a36Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_DQS_SEL0 0xee6 210862306a36Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_DQS_SEL1 0xee7 210962306a36Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_CLK90_SEL 0xee8 211062306a36Sopenharmony_ci#define TW5864_INDIR_DDRA_DLL_TEST_SEL_AND_TAP_S 0xee9 211162306a36Sopenharmony_ci 211262306a36Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_DQS_SEL0 0xeeb 211362306a36Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_DQS_SEL1 0xeec 211462306a36Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_CLK90_SEL 0xeed 211562306a36Sopenharmony_ci#define TW5864_INDIR_DDRB_DLL_TEST_SEL_AND_TAP_S 0xeee 211662306a36Sopenharmony_ci 211762306a36Sopenharmony_ci#define TW5864_INDIR_RESET 0xef0 211862306a36Sopenharmony_ci#define TW5864_INDIR_RESET_VD BIT(7) 211962306a36Sopenharmony_ci#define TW5864_INDIR_RESET_DLL BIT(6) 212062306a36Sopenharmony_ci#define TW5864_INDIR_RESET_MUX_CORE BIT(5) 212162306a36Sopenharmony_ci 212262306a36Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL 0xefd 212362306a36Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL_PV(channel) BIT(channel) 212462306a36Sopenharmony_ci#define TW5864_INDIR_PV_VD_CK_POL_VD(channel) BIT(channel + 4) 212562306a36Sopenharmony_ci 212662306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL 0xefe 212762306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_VD_SHIFT 0 212862306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_VD_MASK 0x3 212962306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV_SHIFT 2 213062306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV_MASK (0x3 << 2) 213162306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV2_SHIFT 4 213262306a36Sopenharmony_ci#define TW5864_INDIR_CLK0_SEL_PV2_MASK (0x3 << 4) 2133