1c942fddfSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 234d1324eSAndrey Utkin /* 334d1324eSAndrey Utkin * TW5864 driver - registers description 434d1324eSAndrey Utkin * 534d1324eSAndrey Utkin * Copyright (C) 2016 Bluecherry, LLC <maintainers@bluecherrydvr.com> 634d1324eSAndrey Utkin */ 734d1324eSAndrey Utkin 834d1324eSAndrey Utkin /* According to TW5864_datasheet_0.6d.pdf, tw5864b1-ds.pdf */ 934d1324eSAndrey Utkin 1034d1324eSAndrey Utkin /* Register Description - Direct Map Space */ 1134d1324eSAndrey Utkin /* 0x0000 ~ 0x1ffc - H264 Register Map */ 1234d1324eSAndrey Utkin /* [15:0] The Version register for H264 core (Read Only) */ 1334d1324eSAndrey Utkin #define TW5864_H264REV 0x0000 1434d1324eSAndrey Utkin 1534d1324eSAndrey Utkin #define TW5864_EMU 0x0004 1634d1324eSAndrey Utkin /* Define controls in register TW5864_EMU */ 1734d1324eSAndrey Utkin /* DDR controller enabled */ 1834d1324eSAndrey Utkin #define TW5864_EMU_EN_DDR BIT(0) 1934d1324eSAndrey Utkin /* Enable bit for Inter module */ 2034d1324eSAndrey Utkin #define TW5864_EMU_EN_ME BIT(1) 2134d1324eSAndrey Utkin /* Enable bit for Sensor Interface module */ 2234d1324eSAndrey Utkin #define TW5864_EMU_EN_SEN BIT(2) 2334d1324eSAndrey Utkin /* Enable bit for Host Burst Access */ 2434d1324eSAndrey Utkin #define TW5864_EMU_EN_BHOST BIT(3) 2534d1324eSAndrey Utkin /* Enable bit for Loop Filter module */ 2634d1324eSAndrey Utkin #define TW5864_EMU_EN_LPF BIT(4) 2734d1324eSAndrey Utkin /* Enable bit for PLBK module */ 2834d1324eSAndrey Utkin #define TW5864_EMU_EN_PLBK BIT(5) 2934d1324eSAndrey Utkin /* 3034d1324eSAndrey Utkin * Video Frame mapping in DDR 3134d1324eSAndrey Utkin * 00 CIF 3234d1324eSAndrey Utkin * 01 D1 3334d1324eSAndrey Utkin * 10 Reserved 3434d1324eSAndrey Utkin * 11 Reserved 3534d1324eSAndrey Utkin * 3634d1324eSAndrey Utkin */ 3734d1324eSAndrey Utkin #define TW5864_DSP_FRAME_TYPE (3 << 6) 3834d1324eSAndrey Utkin #define TW5864_DSP_FRAME_TYPE_D1 BIT(6) 3934d1324eSAndrey Utkin 4034d1324eSAndrey Utkin #define TW5864_UNDECLARED_H264REV_PART2 0x0008 4134d1324eSAndrey Utkin 4234d1324eSAndrey Utkin #define TW5864_SLICE 0x000c 4334d1324eSAndrey Utkin /* Define controls in register TW5864_SLICE */ 4434d1324eSAndrey Utkin /* VLC Slice end flag */ 4534d1324eSAndrey Utkin #define TW5864_VLC_SLICE_END BIT(0) 4634d1324eSAndrey Utkin /* Master Slice End Flag */ 4734d1324eSAndrey Utkin #define TW5864_MAS_SLICE_END BIT(4) 4834d1324eSAndrey Utkin /* Host to start a new slice Address */ 4934d1324eSAndrey Utkin #define TW5864_START_NSLICE BIT(15) 5034d1324eSAndrey Utkin 5134d1324eSAndrey Utkin /* 5234d1324eSAndrey Utkin * [15:0] Two bit for each channel (channel 0 ~ 7). Each two bits are the buffer 5334d1324eSAndrey Utkin * pointer for the last encoded frame of the corresponding channel. 5434d1324eSAndrey Utkin */ 5534d1324eSAndrey Utkin #define TW5864_ENC_BUF_PTR_REC1 0x0010 5634d1324eSAndrey Utkin 5734d1324eSAndrey Utkin /* [5:0] DSP_MB_QP and [15:10] DSP_LPF_OFFSET */ 5834d1324eSAndrey Utkin #define TW5864_DSP_QP 0x0018 5934d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_QP */ 6034d1324eSAndrey Utkin /* [5:0] H264 QP Value for codec */ 6134d1324eSAndrey Utkin #define TW5864_DSP_MB_QP 0x003f 6234d1324eSAndrey Utkin /* 6334d1324eSAndrey Utkin * [15:10] H264 LPF_OFFSET Address 6434d1324eSAndrey Utkin * (Default 0) 6534d1324eSAndrey Utkin */ 6634d1324eSAndrey Utkin #define TW5864_DSP_LPF_OFFSET 0xfc00 6734d1324eSAndrey Utkin 6834d1324eSAndrey Utkin #define TW5864_DSP_CODEC 0x001c 6934d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_CODEC */ 7034d1324eSAndrey Utkin /* 7134d1324eSAndrey Utkin * 0: Encode (TW5864 Default) 7234d1324eSAndrey Utkin * 1: Decode 7334d1324eSAndrey Utkin */ 7434d1324eSAndrey Utkin #define TW5864_DSP_CODEC_MODE BIT(0) 7534d1324eSAndrey Utkin /* 7634d1324eSAndrey Utkin * 0->3 4 VLC data buffer in DDR (1M each) 7734d1324eSAndrey Utkin * 0->7 8 VLC data buffer in DDR (512k each) 7834d1324eSAndrey Utkin */ 7934d1324eSAndrey Utkin #define TW5864_VLC_BUF_ID (7 << 2) 8034d1324eSAndrey Utkin /* 8134d1324eSAndrey Utkin * 0 4CIF in 1 MB 8234d1324eSAndrey Utkin * 1 1CIF in 1 MB 8334d1324eSAndrey Utkin */ 8434d1324eSAndrey Utkin #define TW5864_CIF_MAP_MD BIT(6) 8534d1324eSAndrey Utkin /* 8634d1324eSAndrey Utkin * 0 2 falf D1 in 1 MB 8734d1324eSAndrey Utkin * 1 1 half D1 in 1 MB 8834d1324eSAndrey Utkin */ 8934d1324eSAndrey Utkin #define TW5864_HD1_MAP_MD BIT(7) 9034d1324eSAndrey Utkin /* VLC Stream valid */ 9134d1324eSAndrey Utkin #define TW5864_VLC_VLD BIT(8) 9234d1324eSAndrey Utkin /* MV Vector Valid */ 9334d1324eSAndrey Utkin #define TW5864_MV_VECT_VLD BIT(9) 9434d1324eSAndrey Utkin /* MV Flag Valid */ 9534d1324eSAndrey Utkin #define TW5864_MV_FLAG_VLD BIT(10) 9634d1324eSAndrey Utkin 9734d1324eSAndrey Utkin #define TW5864_DSP_SEN 0x0020 9834d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_SEN */ 9934d1324eSAndrey Utkin /* Org Buffer Base for Luma (default 0) */ 10034d1324eSAndrey Utkin #define TW5864_DSP_SEN_PIC_LU 0x000f 10134d1324eSAndrey Utkin /* Org Buffer Base for Chroma (default 4) */ 10234d1324eSAndrey Utkin #define TW5864_DSP_SEN_PIC_CHM 0x00f0 10334d1324eSAndrey Utkin /* Maximum Number of Buffers (default 4) */ 10434d1324eSAndrey Utkin #define TW5864_DSP_SEN_PIC_MAX 0x0700 10534d1324eSAndrey Utkin /* 10634d1324eSAndrey Utkin * Original Frame D1 or HD1 switch 10734d1324eSAndrey Utkin * (Default 0) 10834d1324eSAndrey Utkin */ 10934d1324eSAndrey Utkin #define TW5864_DSP_SEN_HFULL 0x1000 11034d1324eSAndrey Utkin 11134d1324eSAndrey Utkin #define TW5864_DSP_REF_PIC 0x0024 11234d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_REF_PIC */ 11334d1324eSAndrey Utkin /* Ref Buffer Base for Luma (default 0) */ 11434d1324eSAndrey Utkin #define TW5864_DSP_REF_PIC_LU 0x000f 11534d1324eSAndrey Utkin /* Ref Buffer Base for Chroma (default 4) */ 11634d1324eSAndrey Utkin #define TW5864_DSP_REF_PIC_CHM 0x00f0 11734d1324eSAndrey Utkin /* Maximum Number of Buffers (default 4) */ 11834d1324eSAndrey Utkin #define TW5864_DSP_REF_PIC_MAX 0x0700 11934d1324eSAndrey Utkin 12034d1324eSAndrey Utkin /* [15:0] SEN_EN_CH[n] SENIF original frame capture enable for each channel */ 12134d1324eSAndrey Utkin #define TW5864_SEN_EN_CH 0x0028 12234d1324eSAndrey Utkin 12334d1324eSAndrey Utkin #define TW5864_DSP 0x002c 12434d1324eSAndrey Utkin /* Define controls in register TW5864_DSP */ 12534d1324eSAndrey Utkin /* The ID for channel selected for encoding operation */ 12634d1324eSAndrey Utkin #define TW5864_DSP_ENC_CHN 0x000f 12734d1324eSAndrey Utkin /* See DSP_MB_DELAY below */ 12834d1324eSAndrey Utkin #define TW5864_DSP_MB_WAIT 0x0010 12934d1324eSAndrey Utkin /* 13034d1324eSAndrey Utkin * DSP Chroma Switch 13134d1324eSAndrey Utkin * 0 DDRB 13234d1324eSAndrey Utkin * 1 DDRA 13334d1324eSAndrey Utkin */ 13434d1324eSAndrey Utkin #define TW5864_DSP_CHROM_SW 0x0020 13534d1324eSAndrey Utkin /* VLC Flow Control: 1 for enable */ 13634d1324eSAndrey Utkin #define TW5864_DSP_FLW_CNTL 0x0040 13734d1324eSAndrey Utkin /* 13834d1324eSAndrey Utkin * If DSP_MB_WAIT == 0, MB delay is DSP_MB_DELAY * 16 13934d1324eSAndrey Utkin * If DSP_MB_DELAY == 1, MB delay is DSP_MB_DELAY * 128 14034d1324eSAndrey Utkin */ 14134d1324eSAndrey Utkin #define TW5864_DSP_MB_DELAY 0x0f00 14234d1324eSAndrey Utkin 14334d1324eSAndrey Utkin #define TW5864_DDR 0x0030 14434d1324eSAndrey Utkin /* Define controls in register TW5864_DDR */ 14534d1324eSAndrey Utkin /* DDR Single Access Page Number */ 14634d1324eSAndrey Utkin #define TW5864_DDR_PAGE_CNTL 0x00ff 14734d1324eSAndrey Utkin /* DDR-DPR Burst Read Enable */ 14834d1324eSAndrey Utkin #define TW5864_DDR_BRST_EN BIT(13) 14934d1324eSAndrey Utkin /* 15034d1324eSAndrey Utkin * DDR A/B Select as HOST access 15134d1324eSAndrey Utkin * 0 Select DDRA 15234d1324eSAndrey Utkin * 1 Select DDRB 15334d1324eSAndrey Utkin */ 15434d1324eSAndrey Utkin #define TW5864_DDR_AB_SEL BIT(14) 15534d1324eSAndrey Utkin /* 15634d1324eSAndrey Utkin * DDR Access Mode Select 15734d1324eSAndrey Utkin * 0 Single R/W Access (Host <-> DDR) 15834d1324eSAndrey Utkin * 1 Burst R/W Access (Host <-> DPR) 15934d1324eSAndrey Utkin */ 16034d1324eSAndrey Utkin #define TW5864_DDR_MODE BIT(15) 16134d1324eSAndrey Utkin 16234d1324eSAndrey Utkin /* The original frame capture pointer. Two bits for each channel */ 16334d1324eSAndrey Utkin /* SENIF_ORG_FRM_PTR [15:0] */ 16434d1324eSAndrey Utkin #define TW5864_SENIF_ORG_FRM_PTR1 0x0038 16534d1324eSAndrey Utkin /* SENIF_ORG_FRM_PTR [31:16] */ 16634d1324eSAndrey Utkin #define TW5864_SENIF_ORG_FRM_PTR2 0x003c 16734d1324eSAndrey Utkin 16834d1324eSAndrey Utkin #define TW5864_DSP_SEN_MODE 0x0040 16934d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_SEN_MODE */ 17034d1324eSAndrey Utkin #define TW5864_DSP_SEN_MODE_CH0 0x000f 17134d1324eSAndrey Utkin #define TW5864_DSP_SEN_MODE_CH1 0x00f0 17234d1324eSAndrey Utkin 17334d1324eSAndrey Utkin /* 17434d1324eSAndrey Utkin * [15:0]: ENC_BUF_PTR_REC[31:16] Two bit for each channel (channel 8 ~ 15). 17534d1324eSAndrey Utkin * Each two bits are the buffer pointer for the last encoded frame of a channel 17634d1324eSAndrey Utkin */ 17734d1324eSAndrey Utkin #define TW5864_ENC_BUF_PTR_REC2 0x004c 17834d1324eSAndrey Utkin 17934d1324eSAndrey Utkin /* Current MV Flag Status Pointer for Channel n. (Read only) */ 18034d1324eSAndrey Utkin /* 18134d1324eSAndrey Utkin * [1:0] CH0_MV_PTR, ..., [15:14] CH7_MV_PTR 18234d1324eSAndrey Utkin */ 18334d1324eSAndrey Utkin #define TW5864_CH_MV_PTR1 0x0060 18434d1324eSAndrey Utkin /* 18534d1324eSAndrey Utkin * [1:0] CH8_MV_PTR, ..., [15:14] CH15_MV_PTR 18634d1324eSAndrey Utkin */ 18734d1324eSAndrey Utkin #define TW5864_CH_MV_PTR2 0x0064 18834d1324eSAndrey Utkin 18934d1324eSAndrey Utkin /* 19034d1324eSAndrey Utkin * [15:0] Reset Current MV Flag Status Pointer for Channel n (one bit each) 19134d1324eSAndrey Utkin */ 19234d1324eSAndrey Utkin #define TW5864_RST_MV_PTR 0x0068 19334d1324eSAndrey Utkin #define TW5864_INTERLACING 0x0200 19434d1324eSAndrey Utkin /* Define controls in register TW5864_INTERLACING */ 19534d1324eSAndrey Utkin /* 19634d1324eSAndrey Utkin * Inter_Mode Start. 2-nd bit? A guess. Missing in datasheet. Without this bit 19734d1324eSAndrey Utkin * set, the output video is interlaced (stripy). 19834d1324eSAndrey Utkin */ 19934d1324eSAndrey Utkin #define TW5864_DSP_INTER_ST BIT(1) 20034d1324eSAndrey Utkin /* Deinterlacer Enable */ 20134d1324eSAndrey Utkin #define TW5864_DI_EN BIT(2) 20234d1324eSAndrey Utkin /* 20334d1324eSAndrey Utkin * De-interlacer Mode 20434d1324eSAndrey Utkin * 1 Shuffled frame 20534d1324eSAndrey Utkin * 0 Normal Un-Shuffled Frame 20634d1324eSAndrey Utkin */ 20734d1324eSAndrey Utkin #define TW5864_DI_MD BIT(3) 20834d1324eSAndrey Utkin /* 20934d1324eSAndrey Utkin * Down scale original frame in X direction 21034d1324eSAndrey Utkin * 11: Un-used 21134d1324eSAndrey Utkin * 10: down-sample to 1/4 21234d1324eSAndrey Utkin * 01: down-sample to 1/2 21334d1324eSAndrey Utkin * 00: down-sample disabled 21434d1324eSAndrey Utkin */ 21534d1324eSAndrey Utkin #define TW5864_DSP_DWN_X (3 << 4) 21634d1324eSAndrey Utkin /* 21734d1324eSAndrey Utkin * Down scale original frame in Y direction 21834d1324eSAndrey Utkin * 11: Un-used 21934d1324eSAndrey Utkin * 10: down-sample to 1/4 22034d1324eSAndrey Utkin * 01: down-sample to 1/2 22134d1324eSAndrey Utkin * 00: down-sample disabled 22234d1324eSAndrey Utkin */ 22334d1324eSAndrey Utkin #define TW5864_DSP_DWN_Y (3 << 6) 22434d1324eSAndrey Utkin /* 22534d1324eSAndrey Utkin * 1 Dual Stream 22634d1324eSAndrey Utkin * 0 Single Stream 22734d1324eSAndrey Utkin */ 22834d1324eSAndrey Utkin #define TW5864_DUAL_STR BIT(8) 22934d1324eSAndrey Utkin 23034d1324eSAndrey Utkin #define TW5864_DSP_REF 0x0204 23134d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_REF */ 23234d1324eSAndrey Utkin /* Number of reference frame (Default 1 for TW5864B) */ 23334d1324eSAndrey Utkin #define TW5864_DSP_REF_FRM 0x000f 23434d1324eSAndrey Utkin /* Window size */ 23534d1324eSAndrey Utkin #define TW5864_DSP_WIN_SIZE 0x02f0 23634d1324eSAndrey Utkin 23734d1324eSAndrey Utkin #define TW5864_DSP_SKIP 0x0208 23834d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_SKIP */ 23934d1324eSAndrey Utkin /* 24034d1324eSAndrey Utkin * Skip Offset Enable bit 24134d1324eSAndrey Utkin * 0 DSP_SKIP_OFFSET value is not used (default 8) 24234d1324eSAndrey Utkin * 1 DSP_SKIP_OFFSET value is used in HW 24334d1324eSAndrey Utkin */ 24434d1324eSAndrey Utkin #define TW5864_DSP_SKIP_OFEN 0x0080 24534d1324eSAndrey Utkin /* Skip mode cost offset (default 8) */ 24634d1324eSAndrey Utkin #define TW5864_DSP_SKIP_OFFSET 0x007f 24734d1324eSAndrey Utkin 24834d1324eSAndrey Utkin #define TW5864_MOTION_SEARCH_ETC 0x020c 24934d1324eSAndrey Utkin /* Define controls in register TW5864_MOTION_SEARCH_ETC */ 25034d1324eSAndrey Utkin /* Enable quarter pel search mode */ 25134d1324eSAndrey Utkin #define TW5864_QPEL_EN BIT(0) 25234d1324eSAndrey Utkin /* Enable half pel search mode */ 25334d1324eSAndrey Utkin #define TW5864_HPEL_EN BIT(1) 25434d1324eSAndrey Utkin /* Enable motion search mode */ 25534d1324eSAndrey Utkin #define TW5864_ME_EN BIT(2) 25634d1324eSAndrey Utkin /* Enable Intra mode */ 25734d1324eSAndrey Utkin #define TW5864_INTRA_EN BIT(3) 25834d1324eSAndrey Utkin /* Enable Skip Mode */ 25934d1324eSAndrey Utkin #define TW5864_SKIP_EN BIT(4) 26034d1324eSAndrey Utkin /* Search Option (Default 2"b01) */ 26134d1324eSAndrey Utkin #define TW5864_SRCH_OPT (3 << 5) 26234d1324eSAndrey Utkin 26334d1324eSAndrey Utkin #define TW5864_DSP_ENC_REC 0x0210 26434d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_ENC_REC */ 26534d1324eSAndrey Utkin /* Reference Buffer Pointer for encoding */ 26634d1324eSAndrey Utkin #define TW5864_DSP_ENC_REF_PTR 0x0007 26734d1324eSAndrey Utkin /* Reconstruct Buffer pointer */ 26834d1324eSAndrey Utkin #define TW5864_DSP_REC_BUF_PTR 0x7000 26934d1324eSAndrey Utkin 27034d1324eSAndrey Utkin /* [15:0] Lambda Value for H264 */ 27134d1324eSAndrey Utkin #define TW5864_DSP_REF_MVP_LAMBDA 0x0214 27234d1324eSAndrey Utkin 27334d1324eSAndrey Utkin #define TW5864_DSP_PIC_MAX_MB 0x0218 27434d1324eSAndrey Utkin /* Define controls in register TW5864_DSP_PIC_MAX_MB */ 27534d1324eSAndrey Utkin /* The MB number in Y direction for a frame */ 27634d1324eSAndrey Utkin #define TW5864_DSP_PIC_MAX_MB_Y 0x007f 27734d1324eSAndrey Utkin /* The MB number in X direction for a frame */ 27834d1324eSAndrey Utkin #define TW5864_DSP_PIC_MAX_MB_X 0x7f00 27934d1324eSAndrey Utkin 28034d1324eSAndrey Utkin /* The original frame pointer for encoding */ 28134d1324eSAndrey Utkin #define TW5864_DSP_ENC_ORG_PTR_REG 0x021c 28234d1324eSAndrey Utkin /* Mask to use with TW5864_DSP_ENC_ORG_PTR */ 28334d1324eSAndrey Utkin #define TW5864_DSP_ENC_ORG_PTR_MASK 0x7000 28434d1324eSAndrey Utkin /* Number of bits to shift with TW5864_DSP_ENC_ORG_PTR */ 28534d1324eSAndrey Utkin #define TW5864_DSP_ENC_ORG_PTR_SHIFT 12 28634d1324eSAndrey Utkin 28734d1324eSAndrey Utkin /* DDR base address of OSD rectangle attribute data */ 28834d1324eSAndrey Utkin #define TW5864_DSP_OSD_ATTRI_BASE 0x0220 28934d1324eSAndrey Utkin /* OSD enable bit for each channel */ 29034d1324eSAndrey Utkin #define TW5864_DSP_OSD_ENABLE 0x0228 29134d1324eSAndrey Utkin 2925b448065SMauro Carvalho Chehab /* 0x0280 ~ 0x029c - Motion Vector for 1st 4x4 Block, e.g., 80 (X), 84 (Y) */ 29334d1324eSAndrey Utkin #define TW5864_ME_MV_VEC1 0x0280 2945b448065SMauro Carvalho Chehab /* 0x02a0 ~ 0x02bc - Motion Vector for 2nd 4x4 Block, e.g., A0 (X), A4 (Y) */ 29534d1324eSAndrey Utkin #define TW5864_ME_MV_VEC2 0x02a0 2965b448065SMauro Carvalho Chehab /* 0x02c0 ~ 0x02dc - Motion Vector for 3rd 4x4 Block, e.g., C0 (X), C4 (Y) */ 29734d1324eSAndrey Utkin #define TW5864_ME_MV_VEC3 0x02c0 2985b448065SMauro Carvalho Chehab /* 0x02e0 ~ 0x02fc - Motion Vector for 4th 4x4 Block, e.g., E0 (X), E4 (Y) */ 29934d1324eSAndrey Utkin #define TW5864_ME_MV_VEC4 0x02e0 30034d1324eSAndrey Utkin 30134d1324eSAndrey Utkin /* 30234d1324eSAndrey Utkin * [5:0] 30334d1324eSAndrey Utkin * if (intra16x16_cost < (intra4x4_cost+dsp_i4x4_offset)) 30434d1324eSAndrey Utkin * Intra_mode = intra16x16_mode 30534d1324eSAndrey Utkin * Else 30634d1324eSAndrey Utkin * Intra_mode = intra4x4_mode 30734d1324eSAndrey Utkin */ 30834d1324eSAndrey Utkin #define TW5864_DSP_I4x4_OFFSET 0x040c 30934d1324eSAndrey Utkin 31034d1324eSAndrey Utkin /* 31134d1324eSAndrey Utkin * [6:4] 31234d1324eSAndrey Utkin * 0x5 Only 4x4 31334d1324eSAndrey Utkin * 0x6 Only 16x16 31434d1324eSAndrey Utkin * 0x7 16x16 & 4x4 31534d1324eSAndrey Utkin */ 31634d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE 0x0410 31734d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE_SHIFT 4 31834d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE_MASK (7 << 4) 31934d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE_4x4 0x5 32034d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE_16x16 0x6 32134d1324eSAndrey Utkin #define TW5864_DSP_INTRA_MODE_4x4_AND_16x16 0x7 32234d1324eSAndrey Utkin /* 32334d1324eSAndrey Utkin * [5:0] WEIGHT Factor for I4x4 cost calculation (QP dependent) 32434d1324eSAndrey Utkin */ 32534d1324eSAndrey Utkin #define TW5864_DSP_I4x4_WEIGHT 0x0414 32634d1324eSAndrey Utkin 32734d1324eSAndrey Utkin /* 32834d1324eSAndrey Utkin * [7:0] Offset used to affect Intra/ME model decision 32934d1324eSAndrey Utkin * If (me_cost < intra_cost + dsp_resid_mode_offset) 33034d1324eSAndrey Utkin * Pred_Mode = me_mode 33134d1324eSAndrey Utkin * Else 33234d1324eSAndrey Utkin * Pred_mode = intra_mode 33334d1324eSAndrey Utkin */ 33434d1324eSAndrey Utkin #define TW5864_DSP_RESID_MODE_OFFSET 0x0604 33534d1324eSAndrey Utkin 33634d1324eSAndrey Utkin /* 0x0800 ~ 0x09ff - Quantization TABLE Values */ 33734d1324eSAndrey Utkin #define TW5864_QUAN_TAB 0x0800 33834d1324eSAndrey Utkin 33934d1324eSAndrey Utkin /* Valid channel value [0; f], frame value [0; 3] */ 34034d1324eSAndrey Utkin #define TW5864_RT_CNTR_CH_FRM(channel, frame) \ 34134d1324eSAndrey Utkin (0x0c00 | (channel << 4) | (frame << 2)) 34234d1324eSAndrey Utkin 34334d1324eSAndrey Utkin #define TW5864_FRAME_BUS1 0x0d00 34434d1324eSAndrey Utkin /* 34534d1324eSAndrey Utkin * 1 Progressive in part A in bus n 34634d1324eSAndrey Utkin * 0 Interlaced in part A in bus n 34734d1324eSAndrey Utkin */ 34834d1324eSAndrey Utkin #define TW5864_PROG_A BIT(0) 34934d1324eSAndrey Utkin /* 35034d1324eSAndrey Utkin * 1 Progressive in part B in bus n 35134d1324eSAndrey Utkin * 0 Interlaced in part B in bus n 35234d1324eSAndrey Utkin */ 35334d1324eSAndrey Utkin #define TW5864_PROG_B BIT(1) 35434d1324eSAndrey Utkin /* 35534d1324eSAndrey Utkin * 1 Frame Mode in bus n 35634d1324eSAndrey Utkin * 0 Field Mode in bus n 35734d1324eSAndrey Utkin */ 35834d1324eSAndrey Utkin #define TW5864_FRAME BIT(2) 35934d1324eSAndrey Utkin /* 36034d1324eSAndrey Utkin * 0 4CIF in bus n 36134d1324eSAndrey Utkin * 1 1D1 + 4 CIF in bus n 36234d1324eSAndrey Utkin * 2 2D1 in bus n 36334d1324eSAndrey Utkin */ 36434d1324eSAndrey Utkin #define TW5864_BUS_D1 (3 << 3) 36534d1324eSAndrey Utkin /* Bus 1 goes in TW5864_FRAME_BUS1 in [4:0] */ 36634d1324eSAndrey Utkin /* Bus 2 goes in TW5864_FRAME_BUS1 in [12:8] */ 36734d1324eSAndrey Utkin #define TW5864_FRAME_BUS2 0x0d04 36834d1324eSAndrey Utkin /* Bus 3 goes in TW5864_FRAME_BUS2 in [4:0] */ 36934d1324eSAndrey Utkin /* Bus 4 goes in TW5864_FRAME_BUS2 in [12:8] */ 37034d1324eSAndrey Utkin 37134d1324eSAndrey Utkin /* [15:0] Horizontal Mirror for channel n */ 37234d1324eSAndrey Utkin #define TW5864_SENIF_HOR_MIR 0x0d08 37334d1324eSAndrey Utkin /* [15:0] Vertical Mirror for channel n */ 37434d1324eSAndrey Utkin #define TW5864_SENIF_VER_MIR 0x0d0c 37534d1324eSAndrey Utkin 37634d1324eSAndrey Utkin /* 37734d1324eSAndrey Utkin * FRAME_WIDTH_BUSn_A 37834d1324eSAndrey Utkin * 0x15f: 4 CIF 37934d1324eSAndrey Utkin * 0x2cf: 1 D1 + 3 CIF 38034d1324eSAndrey Utkin * 0x2cf: 2 D1 38134d1324eSAndrey Utkin * FRAME_WIDTH_BUSn_B 38234d1324eSAndrey Utkin * 0x15f: 4 CIF 38334d1324eSAndrey Utkin * 0x2cf: 1 D1 + 3 CIF 38434d1324eSAndrey Utkin * 0x2cf: 2 D1 38534d1324eSAndrey Utkin * FRAME_HEIGHT_BUSn_A 38634d1324eSAndrey Utkin * 0x11f: 4CIF (PAL) 38734d1324eSAndrey Utkin * 0x23f: 1D1 + 3CIF (PAL) 38834d1324eSAndrey Utkin * 0x23f: 2 D1 (PAL) 38934d1324eSAndrey Utkin * 0x0ef: 4CIF (NTSC) 39034d1324eSAndrey Utkin * 0x1df: 1D1 + 3CIF (NTSC) 39134d1324eSAndrey Utkin * 0x1df: 2 D1 (NTSC) 39234d1324eSAndrey Utkin * FRAME_HEIGHT_BUSn_B 39334d1324eSAndrey Utkin * 0x11f: 4CIF (PAL) 39434d1324eSAndrey Utkin * 0x23f: 1D1 + 3CIF (PAL) 39534d1324eSAndrey Utkin * 0x23f: 2 D1 (PAL) 39634d1324eSAndrey Utkin * 0x0ef: 4CIF (NTSC) 39734d1324eSAndrey Utkin * 0x1df: 1D1 + 3CIF (NTSC) 39834d1324eSAndrey Utkin * 0x1df: 2 D1 (NTSC) 39934d1324eSAndrey Utkin */ 40034d1324eSAndrey Utkin #define TW5864_FRAME_WIDTH_BUS_A(bus) (0x0d10 + 0x0010 * bus) 40134d1324eSAndrey Utkin #define TW5864_FRAME_WIDTH_BUS_B(bus) (0x0d14 + 0x0010 * bus) 40234d1324eSAndrey Utkin #define TW5864_FRAME_HEIGHT_BUS_A(bus) (0x0d18 + 0x0010 * bus) 40334d1324eSAndrey Utkin #define TW5864_FRAME_HEIGHT_BUS_B(bus) (0x0d1c + 0x0010 * bus) 40434d1324eSAndrey Utkin 40534d1324eSAndrey Utkin /* 40634d1324eSAndrey Utkin * 1: the bus mapped Channel n Full D1 40734d1324eSAndrey Utkin * 0: the bus mapped Channel n Half D1 40834d1324eSAndrey Utkin */ 40934d1324eSAndrey Utkin #define TW5864_FULL_HALF_FLAG 0x0d50 41034d1324eSAndrey Utkin 41134d1324eSAndrey Utkin /* 41234d1324eSAndrey Utkin * 0 The bus mapped Channel select partA Mode 41334d1324eSAndrey Utkin * 1 The bus mapped Channel select partB Mode 41434d1324eSAndrey Utkin */ 41534d1324eSAndrey Utkin #define TW5864_FULL_HALF_MODE_SEL 0x0d54 41634d1324eSAndrey Utkin 41734d1324eSAndrey Utkin #define TW5864_VLC 0x1000 41834d1324eSAndrey Utkin /* Define controls in register TW5864_VLC */ 41934d1324eSAndrey Utkin /* QP Value used by H264 CAVLC */ 42034d1324eSAndrey Utkin #define TW5864_VLC_SLICE_QP 0x003f 42134d1324eSAndrey Utkin /* 42234d1324eSAndrey Utkin * Swap byte order of VLC stream in d-word. 42334d1324eSAndrey Utkin * 1 Normal (VLC output= [31:0]) 42434d1324eSAndrey Utkin * 0 Swap (VLC output={[23:16],[31:24],[7:0], [15:8]}) 42534d1324eSAndrey Utkin */ 42634d1324eSAndrey Utkin #define TW5864_VLC_BYTE_SWP BIT(6) 42734d1324eSAndrey Utkin /* Enable Adding 03 circuit for VLC stream */ 42834d1324eSAndrey Utkin #define TW5864_VLC_ADD03_EN BIT(7) 42934d1324eSAndrey Utkin /* Number of bit for VLC bit Align */ 43034d1324eSAndrey Utkin #define TW5864_VLC_BIT_ALIGN_SHIFT 8 43134d1324eSAndrey Utkin #define TW5864_VLC_BIT_ALIGN_MASK (0x1f << 8) 43234d1324eSAndrey Utkin /* 43334d1324eSAndrey Utkin * Synchronous Interface select for VLC Stream 43434d1324eSAndrey Utkin * 1 CDC_VLCS_MAS read VLC stream 43534d1324eSAndrey Utkin * 0 CPU read VLC stream 43634d1324eSAndrey Utkin */ 43734d1324eSAndrey Utkin #define TW5864_VLC_INF_SEL BIT(13) 43834d1324eSAndrey Utkin /* Enable VLC overflow control */ 43934d1324eSAndrey Utkin #define TW5864_VLC_OVFL_CNTL BIT(14) 44034d1324eSAndrey Utkin /* 44134d1324eSAndrey Utkin * 1 PCI Master Mode 44234d1324eSAndrey Utkin * 0 Non PCI Master Mode 44334d1324eSAndrey Utkin */ 44434d1324eSAndrey Utkin #define TW5864_VLC_PCI_SEL BIT(15) 44534d1324eSAndrey Utkin /* 44634d1324eSAndrey Utkin * 0 Enable Adding 03 to VLC header and stream 44734d1324eSAndrey Utkin * 1 Disable Adding 03 to VLC header of "00000001" 44834d1324eSAndrey Utkin */ 44934d1324eSAndrey Utkin #define TW5864_VLC_A03_DISAB BIT(16) 45034d1324eSAndrey Utkin /* 45134d1324eSAndrey Utkin * Status of VLC stream in DDR (one bit for each buffer) 45234d1324eSAndrey Utkin * 1 VLC is ready in buffer n (HW set) 45334d1324eSAndrey Utkin * 0 VLC is not ready in buffer n (SW clear) 45434d1324eSAndrey Utkin */ 45534d1324eSAndrey Utkin #define TW5864_VLC_BUF_RDY_SHIFT 24 45634d1324eSAndrey Utkin #define TW5864_VLC_BUF_RDY_MASK (0xff << 24) 45734d1324eSAndrey Utkin 45834d1324eSAndrey Utkin /* Total number of bit in the slice */ 45934d1324eSAndrey Utkin #define TW5864_SLICE_TOTAL_BIT 0x1004 46034d1324eSAndrey Utkin /* Total number of bit in the residue */ 46134d1324eSAndrey Utkin #define TW5864_RES_TOTAL_BIT 0x1008 46234d1324eSAndrey Utkin 46334d1324eSAndrey Utkin #define TW5864_VLC_BUF 0x100c 46434d1324eSAndrey Utkin /* Define controls in register TW5864_VLC_BUF */ 4655b448065SMauro Carvalho Chehab /* VLC BK0 full status, write '1' to clear */ 46634d1324eSAndrey Utkin #define TW5864_VLC_BK0_FULL BIT(0) 4675b448065SMauro Carvalho Chehab /* VLC BK1 full status, write '1' to clear */ 46834d1324eSAndrey Utkin #define TW5864_VLC_BK1_FULL BIT(1) 4695b448065SMauro Carvalho Chehab /* VLC end slice status, write '1' to clear */ 47034d1324eSAndrey Utkin #define TW5864_VLC_END_SLICE BIT(2) 4715b448065SMauro Carvalho Chehab /* VLC Buffer overflow status, write '1' to clear */ 47234d1324eSAndrey Utkin #define TW5864_DSP_RD_OF BIT(3) 47334d1324eSAndrey Utkin /* VLC string length in either buffer 0 or 1 at end of frame */ 47434d1324eSAndrey Utkin #define TW5864_VLC_STREAM_LEN_SHIFT 4 47534d1324eSAndrey Utkin #define TW5864_VLC_STREAM_LEN_MASK (0x1ff << 4) 47634d1324eSAndrey Utkin 47734d1324eSAndrey Utkin /* [15:0] Total coefficient number in a frame */ 47834d1324eSAndrey Utkin #define TW5864_TOTAL_COEF_NO 0x1010 4795b448065SMauro Carvalho Chehab /* [0] VLC Encoder Interrupt. Write '1' to clear */ 48034d1324eSAndrey Utkin #define TW5864_VLC_DSP_INTR 0x1014 48134d1324eSAndrey Utkin /* [31:0] VLC stream CRC checksum */ 48234d1324eSAndrey Utkin #define TW5864_VLC_STREAM_CRC 0x1018 48334d1324eSAndrey Utkin 48434d1324eSAndrey Utkin #define TW5864_VLC_RD 0x101c 48534d1324eSAndrey Utkin /* Define controls in register TW5864_VLC_RD */ 48634d1324eSAndrey Utkin /* 48734d1324eSAndrey Utkin * 1 Read VLC lookup Memory 48834d1324eSAndrey Utkin * 0 Read VLC Stream Memory 48934d1324eSAndrey Utkin */ 49034d1324eSAndrey Utkin #define TW5864_VLC_RD_MEM BIT(0) 49134d1324eSAndrey Utkin /* 49234d1324eSAndrey Utkin * 1 Read VLC Stream Memory in burst mode 49334d1324eSAndrey Utkin * 0 Read VLC Stream Memory in single mode 49434d1324eSAndrey Utkin */ 49534d1324eSAndrey Utkin #define TW5864_VLC_RD_BRST BIT(1) 49634d1324eSAndrey Utkin 4975b448065SMauro Carvalho Chehab /* 0x2000 ~ 0x2ffc - H264 Stream Memory Map */ 49834d1324eSAndrey Utkin /* 49934d1324eSAndrey Utkin * A word is 4 bytes. I.e., 50034d1324eSAndrey Utkin * VLC_STREAM_MEM[0] address: 0x2000 50134d1324eSAndrey Utkin * VLC_STREAM_MEM[1] address: 0x2004 50234d1324eSAndrey Utkin * ... 50334d1324eSAndrey Utkin * VLC_STREAM_MEM[3FF] address: 0x2ffc 50434d1324eSAndrey Utkin */ 50534d1324eSAndrey Utkin #define TW5864_VLC_STREAM_MEM_START 0x2000 50634d1324eSAndrey Utkin #define TW5864_VLC_STREAM_MEM_MAX_OFFSET 0x3ff 50734d1324eSAndrey Utkin #define TW5864_VLC_STREAM_MEM(offset) (TW5864_VLC_STREAM_MEM_START + 4 * offset) 50834d1324eSAndrey Utkin 5095b448065SMauro Carvalho Chehab /* 0x4000 ~ 0x4ffc - Audio Register Map */ 51034d1324eSAndrey Utkin /* [31:0] config 1ms cnt = Realtime clk/1000 */ 51134d1324eSAndrey Utkin #define TW5864_CFG_1MS_CNT 0x4000 51234d1324eSAndrey Utkin 51334d1324eSAndrey Utkin #define TW5864_ADPCM 0x4004 51434d1324eSAndrey Utkin /* Define controls in register TW5864_ADPCM */ 51534d1324eSAndrey Utkin /* ADPCM decoder enable */ 51634d1324eSAndrey Utkin #define TW5864_ADPCM_DEC BIT(0) 51734d1324eSAndrey Utkin /* ADPCM input data enable */ 51834d1324eSAndrey Utkin #define TW5864_ADPCM_IN_DATA BIT(1) 51934d1324eSAndrey Utkin /* ADPCM encoder enable */ 52034d1324eSAndrey Utkin #define TW5864_ADPCM_ENC BIT(2) 52134d1324eSAndrey Utkin 52234d1324eSAndrey Utkin #define TW5864_AUD 0x4008 52334d1324eSAndrey Utkin /* Define controls in register TW5864_AUD */ 52434d1324eSAndrey Utkin /* Record path PCM Audio enable bit for each channel */ 52534d1324eSAndrey Utkin #define TW5864_AUD_ORG_CH_EN 0x00ff 52634d1324eSAndrey Utkin /* Speaker path PCM Audio Enable */ 52734d1324eSAndrey Utkin #define TW5864_SPK_ORG_EN BIT(16) 52834d1324eSAndrey Utkin /* 52934d1324eSAndrey Utkin * 0 16bit 53034d1324eSAndrey Utkin * 1 8bit 53134d1324eSAndrey Utkin */ 53234d1324eSAndrey Utkin #define TW5864_AD_BIT_MODE BIT(17) 53334d1324eSAndrey Utkin #define TW5864_AUD_TYPE_SHIFT 18 53434d1324eSAndrey Utkin /* 53534d1324eSAndrey Utkin * 0 PCM 53634d1324eSAndrey Utkin * 3 ADPCM 53734d1324eSAndrey Utkin */ 53834d1324eSAndrey Utkin #define TW5864_AUD_TYPE (0xf << 18) 53934d1324eSAndrey Utkin #define TW5864_AUD_SAMPLE_RATE_SHIFT 22 54034d1324eSAndrey Utkin /* 54134d1324eSAndrey Utkin * 0 8K 54234d1324eSAndrey Utkin * 1 16K 54334d1324eSAndrey Utkin */ 54434d1324eSAndrey Utkin #define TW5864_AUD_SAMPLE_RATE (3 << 22) 54534d1324eSAndrey Utkin /* Channel ID used to select audio channel (0 to 16) for loopback */ 54634d1324eSAndrey Utkin #define TW5864_TESTLOOP_CHID_SHIFT 24 54734d1324eSAndrey Utkin #define TW5864_TESTLOOP_CHID (0x1f << 24) 54834d1324eSAndrey Utkin /* Enable AD Loopback Test */ 54934d1324eSAndrey Utkin #define TW5864_TEST_ADLOOP_EN BIT(30) 55034d1324eSAndrey Utkin /* 55134d1324eSAndrey Utkin * 0 Asynchronous Mode or PCI target mode 55234d1324eSAndrey Utkin * 1 PCI Initiator Mode 55334d1324eSAndrey Utkin */ 55434d1324eSAndrey Utkin #define TW5864_AUD_MODE BIT(31) 55534d1324eSAndrey Utkin 55634d1324eSAndrey Utkin #define TW5864_AUD_ADPCM 0x400c 55734d1324eSAndrey Utkin /* Define controls in register TW5864_AUD_ADPCM */ 55834d1324eSAndrey Utkin /* Record path ADPCM audio channel enable, one bit for each */ 55934d1324eSAndrey Utkin #define TW5864_AUD_ADPCM_CH_EN 0x00ff 56034d1324eSAndrey Utkin /* Speaker path ADPCM audio channel enable */ 56134d1324eSAndrey Utkin #define TW5864_SPK_ADPCM_EN BIT(16) 56234d1324eSAndrey Utkin 56334d1324eSAndrey Utkin #define TW5864_PC_BLOCK_ADPCM_RD_NO 0x4018 56434d1324eSAndrey Utkin #define TW5864_PC_BLOCK_ADPCM_RD_NO_MASK 0x1f 56534d1324eSAndrey Utkin 56634d1324eSAndrey Utkin /* 56734d1324eSAndrey Utkin * For ADPCM_ENC_WR_PTR, ADPCM_ENC_RD_PTR (see below): 56834d1324eSAndrey Utkin * Bit[2:0] ch0 56934d1324eSAndrey Utkin * Bit[5:3] ch1 57034d1324eSAndrey Utkin * Bit[8:6] ch2 57134d1324eSAndrey Utkin * Bit[11:9] ch3 57234d1324eSAndrey Utkin * Bit[14:12] ch4 57334d1324eSAndrey Utkin * Bit[17:15] ch5 57434d1324eSAndrey Utkin * Bit[20:18] ch6 57534d1324eSAndrey Utkin * Bit[23:21] ch7 57634d1324eSAndrey Utkin * Bit[26:24] ch8 57734d1324eSAndrey Utkin * Bit[29:27] ch9 57834d1324eSAndrey Utkin * Bit[32:30] ch10 57934d1324eSAndrey Utkin * Bit[35:33] ch11 58034d1324eSAndrey Utkin * Bit[38:36] ch12 58134d1324eSAndrey Utkin * Bit[41:39] ch13 58234d1324eSAndrey Utkin * Bit[44:42] ch14 58334d1324eSAndrey Utkin * Bit[47:45] ch15 58434d1324eSAndrey Utkin * Bit[50:48] ch16 58534d1324eSAndrey Utkin */ 58634d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_XX_MASK 0x3fff 58734d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_XX_PTR2_SHIFT 30 58834d1324eSAndrey Utkin /* ADPCM_ENC_WR_PTR[29:0] */ 58934d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_WR_PTR1 0x401c 59034d1324eSAndrey Utkin /* ADPCM_ENC_WR_PTR[50:30] */ 59134d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_WR_PTR2 0x4020 59234d1324eSAndrey Utkin 59334d1324eSAndrey Utkin /* ADPCM_ENC_RD_PTR[29:0] */ 59434d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_RD_PTR1 0x4024 59534d1324eSAndrey Utkin /* ADPCM_ENC_RD_PTR[50:30] */ 59634d1324eSAndrey Utkin #define TW5864_ADPCM_ENC_RD_PTR2 0x4028 59734d1324eSAndrey Utkin 59834d1324eSAndrey Utkin /* [3:0] rd ch0, [7:4] rd ch1, [11:8] wr ch0, [15:12] wr ch1 */ 59934d1324eSAndrey Utkin #define TW5864_ADPCM_DEC_RD_WR_PTR 0x402c 60034d1324eSAndrey Utkin 60134d1324eSAndrey Utkin /* 60234d1324eSAndrey Utkin * For TW5864_AD_ORIG_WR_PTR, TW5864_AD_ORIG_RD_PTR: 60334d1324eSAndrey Utkin * Bit[3:0] ch0 60434d1324eSAndrey Utkin * Bit[7:4] ch1 60534d1324eSAndrey Utkin * Bit[11:8] ch2 60634d1324eSAndrey Utkin * Bit[15:12] ch3 60734d1324eSAndrey Utkin * Bit[19:16] ch4 60834d1324eSAndrey Utkin * Bit[23:20] ch5 60934d1324eSAndrey Utkin * Bit[27:24] ch6 61034d1324eSAndrey Utkin * Bit[31:28] ch7 61134d1324eSAndrey Utkin * Bit[35:32] ch8 61234d1324eSAndrey Utkin * Bit[39:36] ch9 61334d1324eSAndrey Utkin * Bit[43:40] ch10 61434d1324eSAndrey Utkin * Bit[47:44] ch11 61534d1324eSAndrey Utkin * Bit[51:48] ch12 61634d1324eSAndrey Utkin * Bit[55:52] ch13 61734d1324eSAndrey Utkin * Bit[59:56] ch14 61834d1324eSAndrey Utkin * Bit[63:60] ch15 61934d1324eSAndrey Utkin * Bit[67:64] ch16 62034d1324eSAndrey Utkin */ 62134d1324eSAndrey Utkin /* AD_ORIG_WR_PTR[31:0] */ 62234d1324eSAndrey Utkin #define TW5864_AD_ORIG_WR_PTR1 0x4030 62334d1324eSAndrey Utkin /* AD_ORIG_WR_PTR[63:32] */ 62434d1324eSAndrey Utkin #define TW5864_AD_ORIG_WR_PTR2 0x4034 62534d1324eSAndrey Utkin /* AD_ORIG_WR_PTR[67:64] */ 62634d1324eSAndrey Utkin #define TW5864_AD_ORIG_WR_PTR3 0x4038 62734d1324eSAndrey Utkin 62834d1324eSAndrey Utkin /* AD_ORIG_RD_PTR[31:0] */ 62934d1324eSAndrey Utkin #define TW5864_AD_ORIG_RD_PTR1 0x403c 63034d1324eSAndrey Utkin /* AD_ORIG_RD_PTR[63:32] */ 63134d1324eSAndrey Utkin #define TW5864_AD_ORIG_RD_PTR2 0x4040 63234d1324eSAndrey Utkin /* AD_ORIG_RD_PTR[67:64] */ 63334d1324eSAndrey Utkin #define TW5864_AD_ORIG_RD_PTR3 0x4044 63434d1324eSAndrey Utkin 63534d1324eSAndrey Utkin #define TW5864_PC_BLOCK_ORIG_RD_NO 0x4048 63634d1324eSAndrey Utkin #define TW5864_PC_BLOCK_ORIG_RD_NO_MASK 0x1f 63734d1324eSAndrey Utkin 63834d1324eSAndrey Utkin #define TW5864_PCI_AUD 0x404c 63934d1324eSAndrey Utkin /* Define controls in register TW5864_PCI_AUD */ 64034d1324eSAndrey Utkin /* 64134d1324eSAndrey Utkin * The register is applicable to PCI initiator mode only. Used to select PCM(0) 64234d1324eSAndrey Utkin * or ADPCM(1) audio data sent to PC. One bit for each channel 64334d1324eSAndrey Utkin */ 64434d1324eSAndrey Utkin #define TW5864_PCI_DATA_SEL 0xffff 64534d1324eSAndrey Utkin /* 64634d1324eSAndrey Utkin * Audio flow control mode selection bit. 64734d1324eSAndrey Utkin * 0 Flow control disabled. TW5864 continuously sends audio frame to PC 64834d1324eSAndrey Utkin * (initiator mode) 64934d1324eSAndrey Utkin * 1 Flow control enabled 65034d1324eSAndrey Utkin */ 65134d1324eSAndrey Utkin #define TW5864_PCI_FLOW_EN BIT(16) 65234d1324eSAndrey Utkin /* 65334d1324eSAndrey Utkin * When PCI_FLOW_EN is set, PCI need to toggle this bit to send an audio frame 65434d1324eSAndrey Utkin * to PC. One toggle to send one frame. 65534d1324eSAndrey Utkin */ 65634d1324eSAndrey Utkin #define TW5864_PCI_AUD_FRM_EN BIT(17) 65734d1324eSAndrey Utkin 65834d1324eSAndrey Utkin /* [1:0] CS valid to data valid CLK cycles when writing operation */ 65934d1324eSAndrey Utkin #define TW5864_CS2DAT_CNT 0x8000 66034d1324eSAndrey Utkin /* [2:0] Data valid signal width by system clock cycles */ 66134d1324eSAndrey Utkin #define TW5864_DATA_VLD_WIDTH 0x8004 66234d1324eSAndrey Utkin 66334d1324eSAndrey Utkin #define TW5864_SYNC 0x8008 66434d1324eSAndrey Utkin /* Define controls in register TW5864_SYNC */ 66534d1324eSAndrey Utkin /* 666*e481ff3fSHerman * 0 vlc stream to synchronous port 66734d1324eSAndrey Utkin * 1 vlc stream to ddr buffers 66834d1324eSAndrey Utkin */ 66934d1324eSAndrey Utkin #define TW5864_SYNC_CFG BIT(7) 67034d1324eSAndrey Utkin /* 67134d1324eSAndrey Utkin * 0 SYNC Address sampled on Rising edge 67234d1324eSAndrey Utkin * 1 SYNC Address sampled on Falling edge 67334d1324eSAndrey Utkin */ 67434d1324eSAndrey Utkin #define TW5864_SYNC_ADR_EDGE BIT(0) 67534d1324eSAndrey Utkin #define TW5864_VLC_STR_DELAY_SHIFT 1 67634d1324eSAndrey Utkin /* 67734d1324eSAndrey Utkin * 0 No system delay 67834d1324eSAndrey Utkin * 1 One system clock delay 67934d1324eSAndrey Utkin * 2 Two system clock delay 68034d1324eSAndrey Utkin * 3 Three system clock delay 68134d1324eSAndrey Utkin */ 68234d1324eSAndrey Utkin #define TW5864_VLC_STR_DELAY (3 << 1) 68334d1324eSAndrey Utkin /* 68434d1324eSAndrey Utkin * 0 Rising edge output 68534d1324eSAndrey Utkin * 1 Falling edge output 68634d1324eSAndrey Utkin */ 68734d1324eSAndrey Utkin #define TW5864_VLC_OUT_EDGE BIT(3) 68834d1324eSAndrey Utkin 68934d1324eSAndrey Utkin /* 69034d1324eSAndrey Utkin * [1:0] 6915b448065SMauro Carvalho Chehab * 2'b00 phase set to 180 degree 6925b448065SMauro Carvalho Chehab * 2'b01 phase set to 270 degree 6935b448065SMauro Carvalho Chehab * 2'b10 phase set to 0 degree 6945b448065SMauro Carvalho Chehab * 2'b11 phase set to 90 degree 69534d1324eSAndrey Utkin */ 69634d1324eSAndrey Utkin #define TW5864_I2C_PHASE_CFG 0x800c 69734d1324eSAndrey Utkin 69834d1324eSAndrey Utkin /* 69934d1324eSAndrey Utkin * The system / DDR clock (166 MHz) is generated with an on-chip system clock 70034d1324eSAndrey Utkin * PLL (SYSPLL) using input crystal clock of 27 MHz. The system clock PLL 70134d1324eSAndrey Utkin * frequency is controlled with the following equation. 70234d1324eSAndrey Utkin * CLK_OUT = CLK_IN * (M+1) / ((N+1) * P) 70334d1324eSAndrey Utkin * SYSPLL_M M parameter 70434d1324eSAndrey Utkin * SYSPLL_N N parameter 70534d1324eSAndrey Utkin * SYSPLL_P P parameter 70634d1324eSAndrey Utkin */ 70734d1324eSAndrey Utkin /* SYSPLL_M[7:0] */ 70834d1324eSAndrey Utkin #define TW5864_SYSPLL1 0x8018 70934d1324eSAndrey Utkin /* Define controls in register TW5864_SYSPLL1 */ 71034d1324eSAndrey Utkin #define TW5864_SYSPLL_M_LOW 0x00ff 71134d1324eSAndrey Utkin 71234d1324eSAndrey Utkin /* [2:0]: SYSPLL_M[10:8], [7:3]: SYSPLL_N[4:0] */ 71334d1324eSAndrey Utkin #define TW5864_SYSPLL2 0x8019 71434d1324eSAndrey Utkin /* Define controls in register TW5864_SYSPLL2 */ 71534d1324eSAndrey Utkin #define TW5864_SYSPLL_M_HI 0x07 71634d1324eSAndrey Utkin #define TW5864_SYSPLL_N_LOW_SHIFT 3 71734d1324eSAndrey Utkin #define TW5864_SYSPLL_N_LOW (0x1f << 3) 71834d1324eSAndrey Utkin 71934d1324eSAndrey Utkin /* 72034d1324eSAndrey Utkin * [1:0]: SYSPLL_N[6:5], [3:2]: SYSPLL_P, [4]: SYSPLL_IREF, [7:5]: SYSPLL_CP_SEL 72134d1324eSAndrey Utkin */ 72234d1324eSAndrey Utkin #define TW5864_SYSPLL3 0x8020 72334d1324eSAndrey Utkin /* Define controls in register TW5864_SYSPLL3 */ 72434d1324eSAndrey Utkin #define TW5864_SYSPLL_N_HI 0x03 72534d1324eSAndrey Utkin #define TW5864_SYSPLL_P_SHIFT 2 72634d1324eSAndrey Utkin #define TW5864_SYSPLL_P (0x03 << 2) 72734d1324eSAndrey Utkin /* 72834d1324eSAndrey Utkin * SYSPLL bias current control 72934d1324eSAndrey Utkin * 0 Lower current (default) 73034d1324eSAndrey Utkin * 1 30% higher current 73134d1324eSAndrey Utkin */ 73234d1324eSAndrey Utkin #define TW5864_SYSPLL_IREF BIT(4) 73334d1324eSAndrey Utkin /* 73434d1324eSAndrey Utkin * SYSPLL charge pump current selection 73534d1324eSAndrey Utkin * 0 1,5 uA 73634d1324eSAndrey Utkin * 1 4 uA 73734d1324eSAndrey Utkin * 2 9 uA 73834d1324eSAndrey Utkin * 3 19 uA 73934d1324eSAndrey Utkin * 4 39 uA 74034d1324eSAndrey Utkin * 5 79 uA 74134d1324eSAndrey Utkin * 6 159 uA 74234d1324eSAndrey Utkin * 7 319 uA 74334d1324eSAndrey Utkin */ 74434d1324eSAndrey Utkin #define TW5864_SYSPLL_CP_SEL_SHIFT 5 74534d1324eSAndrey Utkin #define TW5864_SYSPLL_CP_SEL (0x07 << 5) 74634d1324eSAndrey Utkin 74734d1324eSAndrey Utkin /* 74834d1324eSAndrey Utkin * [1:0]: SYSPLL_VCO, [3:2]: SYSPLL_LP_X8, [5:4]: SYSPLL_ICP_SEL, 74934d1324eSAndrey Utkin * [6]: SYSPLL_LPF_5PF, [7]: SYSPLL_ED_SEL 75034d1324eSAndrey Utkin */ 75134d1324eSAndrey Utkin #define TW5864_SYSPLL4 0x8021 75234d1324eSAndrey Utkin /* Define controls in register TW5864_SYSPLL4 */ 75334d1324eSAndrey Utkin /* 75434d1324eSAndrey Utkin * SYSPLL_VCO VCO Range selection 75534d1324eSAndrey Utkin * 00 5 ~ 75 MHz 75634d1324eSAndrey Utkin * 01 50 ~ 140 MHz 75734d1324eSAndrey Utkin * 10 110 ~ 320 MHz 75834d1324eSAndrey Utkin * 11 270 ~ 700 MHz 75934d1324eSAndrey Utkin */ 76034d1324eSAndrey Utkin #define TW5864_SYSPLL_VCO 0x03 76134d1324eSAndrey Utkin #define TW5864_SYSPLL_LP_X8_SHIFT 2 76234d1324eSAndrey Utkin /* 76334d1324eSAndrey Utkin * Loop resister 76434d1324eSAndrey Utkin * 0 38.5K ohms 76534d1324eSAndrey Utkin * 1 6.6K ohms (default) 76634d1324eSAndrey Utkin * 2 2.2K ohms 76734d1324eSAndrey Utkin * 3 1.1K ohms 76834d1324eSAndrey Utkin */ 76934d1324eSAndrey Utkin #define TW5864_SYSPLL_LP_X8 (0x03 << 2) 77034d1324eSAndrey Utkin #define TW5864_SYSPLL_ICP_SEL_SHIFT 4 77134d1324eSAndrey Utkin /* 77234d1324eSAndrey Utkin * PLL charge pump fine tune 77334d1324eSAndrey Utkin * 00 x1 (default) 77434d1324eSAndrey Utkin * 01 x1/2 77534d1324eSAndrey Utkin * 10 x1/7 77634d1324eSAndrey Utkin * 11 x1/8 77734d1324eSAndrey Utkin */ 77834d1324eSAndrey Utkin #define TW5864_SYSPLL_ICP_SEL (0x03 << 4) 77934d1324eSAndrey Utkin /* 78034d1324eSAndrey Utkin * PLL low pass filter phase margin adjustment 78134d1324eSAndrey Utkin * 0 no 5pF (default) 78234d1324eSAndrey Utkin * 1 5pF added 78334d1324eSAndrey Utkin */ 78434d1324eSAndrey Utkin #define TW5864_SYSPLL_LPF_5PF BIT(6) 78534d1324eSAndrey Utkin /* 78634d1324eSAndrey Utkin * PFD select edge for detection 78734d1324eSAndrey Utkin * 0 Falling edge (default) 78834d1324eSAndrey Utkin * 1 Rising edge 78934d1324eSAndrey Utkin */ 79034d1324eSAndrey Utkin #define TW5864_SYSPLL_ED_SEL BIT(7) 79134d1324eSAndrey Utkin 79234d1324eSAndrey Utkin /* [0]: SYSPLL_RST, [4]: SYSPLL_PD */ 79334d1324eSAndrey Utkin #define TW5864_SYSPLL5 0x8024 79434d1324eSAndrey Utkin /* Define controls in register TW5864_SYSPLL5 */ 79534d1324eSAndrey Utkin /* Reset SYSPLL */ 79634d1324eSAndrey Utkin #define TW5864_SYSPLL_RST BIT(0) 79734d1324eSAndrey Utkin /* Power down SYSPLL */ 79834d1324eSAndrey Utkin #define TW5864_SYSPLL_PD BIT(4) 79934d1324eSAndrey Utkin 80034d1324eSAndrey Utkin #define TW5864_PLL_CFG 0x801c 80134d1324eSAndrey Utkin /* Define controls in register TW5864_PLL_CFG */ 80234d1324eSAndrey Utkin /* 80334d1324eSAndrey Utkin * Issue Soft Reset from Async Host Interface / PCI Interface clock domain. 80434d1324eSAndrey Utkin * Become valid after sync to the xtal clock domain. This bit is set only if 80534d1324eSAndrey Utkin * LOAD register bit is also set to 1. 80634d1324eSAndrey Utkin */ 80734d1324eSAndrey Utkin #define TW5864_SRST BIT(0) 80834d1324eSAndrey Utkin /* 80934d1324eSAndrey Utkin * Issue SYSPLL (166 MHz) configuration latch from Async host interface / PCI 81034d1324eSAndrey Utkin * Interface clock domain. The configuration setting becomes effective only if 81134d1324eSAndrey Utkin * LOAD register bit is also set to 1. 81234d1324eSAndrey Utkin */ 81334d1324eSAndrey Utkin #define TW5864_SYSPLL_CFG BIT(2) 81434d1324eSAndrey Utkin /* 81534d1324eSAndrey Utkin * Issue SPLL (108 MHz) configuration load from Async host interface / PCI 81634d1324eSAndrey Utkin * Interface clock domain. The configuration setting becomes effective only if 81734d1324eSAndrey Utkin * the LOAD register bit is also set to 1. 81834d1324eSAndrey Utkin */ 81934d1324eSAndrey Utkin #define TW5864_SPLL_CFG BIT(4) 82034d1324eSAndrey Utkin /* 82134d1324eSAndrey Utkin * Set this bit to latch the SRST, SYSPLL_CFG, SPLL_CFG setting into the xtal 82234d1324eSAndrey Utkin * clock domain to restart the PLL. This bit is self cleared. 82334d1324eSAndrey Utkin */ 82434d1324eSAndrey Utkin #define TW5864_LOAD BIT(3) 82534d1324eSAndrey Utkin 82634d1324eSAndrey Utkin /* SPLL_IREF, SPLL_LPX4, SPLL_CPX4, SPLL_PD, SPLL_DBG */ 82734d1324eSAndrey Utkin #define TW5864_SPLL 0x8028 82834d1324eSAndrey Utkin 8295b448065SMauro Carvalho Chehab /* 0x8800 ~ 0x88fc - Interrupt Register Map */ 83034d1324eSAndrey Utkin /* 83134d1324eSAndrey Utkin * Trigger mode of interrupt source 0 ~ 15 83234d1324eSAndrey Utkin * 1 Edge trigger mode 83334d1324eSAndrey Utkin * 0 Level trigger mode 83434d1324eSAndrey Utkin */ 83534d1324eSAndrey Utkin #define TW5864_TRIGGER_MODE_L 0x8800 83634d1324eSAndrey Utkin /* Trigger mode of interrupt source 16 ~ 31 */ 83734d1324eSAndrey Utkin #define TW5864_TRIGGER_MODE_H 0x8804 83834d1324eSAndrey Utkin /* Enable of interrupt source 0 ~ 15 */ 83934d1324eSAndrey Utkin #define TW5864_INTR_ENABLE_L 0x8808 84034d1324eSAndrey Utkin /* Enable of interrupt source 16 ~ 31 */ 84134d1324eSAndrey Utkin #define TW5864_INTR_ENABLE_H 0x880c 84234d1324eSAndrey Utkin /* Clear interrupt command of interrupt source 0 ~ 15 */ 84334d1324eSAndrey Utkin #define TW5864_INTR_CLR_L 0x8810 84434d1324eSAndrey Utkin /* Clear interrupt command of interrupt source 16 ~ 31 */ 84534d1324eSAndrey Utkin #define TW5864_INTR_CLR_H 0x8814 84634d1324eSAndrey Utkin /* 84734d1324eSAndrey Utkin * Assertion of interrupt source 0 ~ 15 84834d1324eSAndrey Utkin * 1 High level or pos-edge is assertion 84934d1324eSAndrey Utkin * 0 Low level or neg-edge is assertion 85034d1324eSAndrey Utkin */ 85134d1324eSAndrey Utkin #define TW5864_INTR_ASSERT_L 0x8818 85234d1324eSAndrey Utkin /* Assertion of interrupt source 16 ~ 31 */ 85334d1324eSAndrey Utkin #define TW5864_INTR_ASSERT_H 0x881c 85434d1324eSAndrey Utkin /* 85534d1324eSAndrey Utkin * Output level of interrupt 85634d1324eSAndrey Utkin * 1 Interrupt output is high assertion 85734d1324eSAndrey Utkin * 0 Interrupt output is low assertion 85834d1324eSAndrey Utkin */ 85934d1324eSAndrey Utkin #define TW5864_INTR_OUT_LEVEL 0x8820 86034d1324eSAndrey Utkin /* 86134d1324eSAndrey Utkin * Status of interrupt source 0 ~ 15 86234d1324eSAndrey Utkin * Bit[0]: VLC 4k RAM interrupt 86334d1324eSAndrey Utkin * Bit[1]: BURST DDR RAM interrupt 86434d1324eSAndrey Utkin * Bit[2]: MV DSP interrupt 86534d1324eSAndrey Utkin * Bit[3]: video lost interrupt 86634d1324eSAndrey Utkin * Bit[4]: gpio 0 interrupt 86734d1324eSAndrey Utkin * Bit[5]: gpio 1 interrupt 86834d1324eSAndrey Utkin * Bit[6]: gpio 2 interrupt 86934d1324eSAndrey Utkin * Bit[7]: gpio 3 interrupt 87034d1324eSAndrey Utkin * Bit[8]: gpio 4 interrupt 87134d1324eSAndrey Utkin * Bit[9]: gpio 5 interrupt 87234d1324eSAndrey Utkin * Bit[10]: gpio 6 interrupt 87334d1324eSAndrey Utkin * Bit[11]: gpio 7 interrupt 87434d1324eSAndrey Utkin * Bit[12]: JPEG interrupt 87534d1324eSAndrey Utkin * Bit[13:15]: Reserved 87634d1324eSAndrey Utkin */ 87734d1324eSAndrey Utkin #define TW5864_INTR_STATUS_L 0x8838 87834d1324eSAndrey Utkin /* 87934d1324eSAndrey Utkin * Status of interrupt source 16 ~ 31 88034d1324eSAndrey Utkin * Bit[0]: Reserved 88134d1324eSAndrey Utkin * Bit[1]: VLC done interrupt 88234d1324eSAndrey Utkin * Bit[2]: Reserved 88334d1324eSAndrey Utkin * Bit[3]: AD Vsync interrupt 88434d1324eSAndrey Utkin * Bit[4]: Preview eof interrupt 88534d1324eSAndrey Utkin * Bit[5]: Preview overflow interrupt 88634d1324eSAndrey Utkin * Bit[6]: Timer interrupt 88734d1324eSAndrey Utkin * Bit[7]: Reserved 88834d1324eSAndrey Utkin * Bit[8]: Audio eof interrupt 88934d1324eSAndrey Utkin * Bit[9]: I2C done interrupt 89034d1324eSAndrey Utkin * Bit[10]: AD interrupt 89134d1324eSAndrey Utkin * Bit[11:15]: Reserved 89234d1324eSAndrey Utkin */ 89334d1324eSAndrey Utkin #define TW5864_INTR_STATUS_H 0x883c 89434d1324eSAndrey Utkin 89534d1324eSAndrey Utkin /* Defines of interrupt bits, united for both low and high word registers */ 89634d1324eSAndrey Utkin #define TW5864_INTR_VLC_RAM BIT(0) 89734d1324eSAndrey Utkin #define TW5864_INTR_BURST BIT(1) 89834d1324eSAndrey Utkin #define TW5864_INTR_MV_DSP BIT(2) 89934d1324eSAndrey Utkin #define TW5864_INTR_VIN_LOST BIT(3) 90034d1324eSAndrey Utkin /* n belongs to [0; 7] */ 90134d1324eSAndrey Utkin #define TW5864_INTR_GPIO(n) (1 << (4 + n)) 90234d1324eSAndrey Utkin #define TW5864_INTR_JPEG BIT(12) 90334d1324eSAndrey Utkin #define TW5864_INTR_VLC_DONE BIT(17) 90434d1324eSAndrey Utkin #define TW5864_INTR_AD_VSYNC BIT(19) 90534d1324eSAndrey Utkin #define TW5864_INTR_PV_EOF BIT(20) 90634d1324eSAndrey Utkin #define TW5864_INTR_PV_OVERFLOW BIT(21) 90734d1324eSAndrey Utkin #define TW5864_INTR_TIMER BIT(22) 90834d1324eSAndrey Utkin #define TW5864_INTR_AUD_EOF BIT(24) 90934d1324eSAndrey Utkin #define TW5864_INTR_I2C_DONE BIT(25) 91034d1324eSAndrey Utkin #define TW5864_INTR_AD BIT(26) 91134d1324eSAndrey Utkin 9125b448065SMauro Carvalho Chehab /* 0x9000 ~ 0x920c - Video Capture (VIF) Register Map */ 91334d1324eSAndrey Utkin /* 91434d1324eSAndrey Utkin * H264EN_CH_STATUS[n] Status of Vsync synchronized H264EN_CH_EN (Read Only) 91534d1324eSAndrey Utkin * 1 Channel Enabled 91634d1324eSAndrey Utkin * 0 Channel Disabled 91734d1324eSAndrey Utkin */ 91834d1324eSAndrey Utkin #define TW5864_H264EN_CH_STATUS 0x9000 91934d1324eSAndrey Utkin /* 92034d1324eSAndrey Utkin * [15:0] H264EN_CH_EN[n] H264 Encoding Path Enable for channel 92134d1324eSAndrey Utkin * 1 Channel Enabled 92234d1324eSAndrey Utkin * 0 Channel Disabled 92334d1324eSAndrey Utkin */ 92434d1324eSAndrey Utkin #define TW5864_H264EN_CH_EN 0x9004 92534d1324eSAndrey Utkin /* 92634d1324eSAndrey Utkin * H264EN_CH_DNS[n] H264 Encoding Path Downscale Video Decoder Input for 92734d1324eSAndrey Utkin * channel n 92834d1324eSAndrey Utkin * 1 Downscale Y to 1/2 92934d1324eSAndrey Utkin * 0 Does not downscale 93034d1324eSAndrey Utkin */ 93134d1324eSAndrey Utkin #define TW5864_H264EN_CH_DNS 0x9008 93234d1324eSAndrey Utkin /* 93334d1324eSAndrey Utkin * H264EN_CH_PROG[n] H264 Encoding Path channel n is progressive 93434d1324eSAndrey Utkin * 1 Progressive (Not valid for TW5864) 93534d1324eSAndrey Utkin * 0 Interlaced (TW5864 default) 93634d1324eSAndrey Utkin */ 93734d1324eSAndrey Utkin #define TW5864_H264EN_CH_PROG 0x900c 93834d1324eSAndrey Utkin /* 93934d1324eSAndrey Utkin * [3:0] H264EN_BUS_MAX_CH[n] 94034d1324eSAndrey Utkin * H264 Encoding Path maximum number of channel on BUS n 94134d1324eSAndrey Utkin * 0 Max 4 channels 94234d1324eSAndrey Utkin * 1 Max 2 channels 94334d1324eSAndrey Utkin */ 94434d1324eSAndrey Utkin #define TW5864_H264EN_BUS_MAX_CH 0x9010 94534d1324eSAndrey Utkin 94634d1324eSAndrey Utkin /* 94734d1324eSAndrey Utkin * H264EN_RATE_MAX_LINE_n H264 Encoding path Rate Mapping Maximum Line Number 94834d1324eSAndrey Utkin * on Bus n 94934d1324eSAndrey Utkin */ 95034d1324eSAndrey Utkin #define TW5864_H264EN_RATE_MAX_LINE_EVEN 0x1f 95134d1324eSAndrey Utkin #define TW5864_H264EN_RATE_MAX_LINE_ODD_SHIFT 5 95234d1324eSAndrey Utkin #define TW5864_H264EN_RATE_MAX_LINE_ODD (0x1f << 5) 95334d1324eSAndrey Utkin /* 95434d1324eSAndrey Utkin * [4:0] H264EN_RATE_MAX_LINE_0 95534d1324eSAndrey Utkin * [9:5] H264EN_RATE_MAX_LINE_1 95634d1324eSAndrey Utkin */ 95734d1324eSAndrey Utkin #define TW5864_H264EN_RATE_MAX_LINE_REG1 0x9014 95834d1324eSAndrey Utkin /* 95934d1324eSAndrey Utkin * [4:0] H264EN_RATE_MAX_LINE_2 96034d1324eSAndrey Utkin * [9:5] H264EN_RATE_MAX_LINE_3 96134d1324eSAndrey Utkin */ 96234d1324eSAndrey Utkin #define TW5864_H264EN_RATE_MAX_LINE_REG2 0x9018 96334d1324eSAndrey Utkin 96434d1324eSAndrey Utkin /* 96534d1324eSAndrey Utkin * H264EN_CHn_FMT H264 Encoding Path Format configuration of Channel n 96634d1324eSAndrey Utkin * 00 D1 (For D1 and hD1 frame) 96734d1324eSAndrey Utkin * 01 (Reserved) 96834d1324eSAndrey Utkin * 10 (Reserved) 96934d1324eSAndrey Utkin * 11 D1 with 1/2 size in X (for CIF frame) 97034d1324eSAndrey Utkin * Note: To be used with 0x9008 register to configure the frame size 97134d1324eSAndrey Utkin */ 97234d1324eSAndrey Utkin /* 97334d1324eSAndrey Utkin * [1:0]: H264EN_CH0_FMT, 97434d1324eSAndrey Utkin * ..., [15:14]: H264EN_CH7_FMT 97534d1324eSAndrey Utkin */ 97634d1324eSAndrey Utkin #define TW5864_H264EN_CH_FMT_REG1 0x9020 97734d1324eSAndrey Utkin /* 97834d1324eSAndrey Utkin * [1:0]: H264EN_CH8_FMT (?), 97934d1324eSAndrey Utkin * ..., [15:14]: H264EN_CH15_FMT (?) 98034d1324eSAndrey Utkin */ 98134d1324eSAndrey Utkin #define TW5864_H264EN_CH_FMT_REG2 0x9024 98234d1324eSAndrey Utkin 98334d1324eSAndrey Utkin /* 98434d1324eSAndrey Utkin * H264EN_RATE_CNTL_BUSm_CHn H264 Encoding Path BUS m Rate Control for Channel n 98534d1324eSAndrey Utkin */ 98634d1324eSAndrey Utkin #define TW5864_H264EN_RATE_CNTL_LO_WORD(bus, channel) \ 98734d1324eSAndrey Utkin (0x9100 + bus * 0x20 + channel * 0x08) 98834d1324eSAndrey Utkin #define TW5864_H264EN_RATE_CNTL_HI_WORD(bus, channel) \ 98934d1324eSAndrey Utkin (0x9104 + bus * 0x20 + channel * 0x08) 99034d1324eSAndrey Utkin 99134d1324eSAndrey Utkin /* 99234d1324eSAndrey Utkin * H264EN_BUSm_MAP_CHn The 16-to-1 MUX configuration register for each encoding 99334d1324eSAndrey Utkin * channel (total of 16 channels). Four bits for each channel. 99434d1324eSAndrey Utkin */ 99534d1324eSAndrey Utkin #define TW5864_H264EN_BUS0_MAP 0x9200 99634d1324eSAndrey Utkin #define TW5864_H264EN_BUS1_MAP 0x9204 99734d1324eSAndrey Utkin #define TW5864_H264EN_BUS2_MAP 0x9208 99834d1324eSAndrey Utkin #define TW5864_H264EN_BUS3_MAP 0x920c 99934d1324eSAndrey Utkin 100034d1324eSAndrey Utkin /* This register is not defined in datasheet, but used in reference driver */ 100134d1324eSAndrey Utkin #define TW5864_UNDECLARED_ERROR_FLAGS_0x9218 0x9218 100234d1324eSAndrey Utkin 100334d1324eSAndrey Utkin #define TW5864_GPIO1 0x9800 100434d1324eSAndrey Utkin #define TW5864_GPIO2 0x9804 100534d1324eSAndrey Utkin /* Define controls in registers TW5864_GPIO1, TW5864_GPIO2 */ 100634d1324eSAndrey Utkin /* GPIO DATA of Group n */ 100734d1324eSAndrey Utkin #define TW5864_GPIO_DATA 0x00ff 100834d1324eSAndrey Utkin #define TW5864_GPIO_OEN_SHIFT 8 100934d1324eSAndrey Utkin /* GPIO Output Enable of Group n */ 101034d1324eSAndrey Utkin #define TW5864_GPIO_OEN (0xff << 8) 101134d1324eSAndrey Utkin 10125b448065SMauro Carvalho Chehab /* 0xa000 ~ 0xa8ff - DDR Controller Register Map */ 101334d1324eSAndrey Utkin /* DDR Controller A */ 101434d1324eSAndrey Utkin /* 101534d1324eSAndrey Utkin * [2:0] Data valid counter after read command to DDR. This is the delay value 101634d1324eSAndrey Utkin * to show how many cycles the data will be back from DDR after we issue a read 101734d1324eSAndrey Utkin * command. 101834d1324eSAndrey Utkin */ 101934d1324eSAndrey Utkin #define TW5864_RD_ACK_VLD_MUX 0xa000 102034d1324eSAndrey Utkin 102134d1324eSAndrey Utkin #define TW5864_DDR_PERIODS 0xa004 102234d1324eSAndrey Utkin /* Define controls in register TW5864_DDR_PERIODS */ 102334d1324eSAndrey Utkin /* 102434d1324eSAndrey Utkin * Tras value, the minimum cycle of active to precharge command period, 102534d1324eSAndrey Utkin * default is 7 102634d1324eSAndrey Utkin */ 102734d1324eSAndrey Utkin #define TW5864_TRAS_CNT_MAX 0x000f 102834d1324eSAndrey Utkin /* 102934d1324eSAndrey Utkin * Trfc value, the minimum cycle of refresh to active or refresh command period, 103034d1324eSAndrey Utkin * default is 4"hf 103134d1324eSAndrey Utkin */ 103234d1324eSAndrey Utkin #define TW5864_RFC_CNT_MAX_SHIFT 8 103334d1324eSAndrey Utkin #define TW5864_RFC_CNT_MAX (0x0f << 8) 103434d1324eSAndrey Utkin /* 103534d1324eSAndrey Utkin * Trcd value, the minimum cycle of active to internal read/write command 103634d1324eSAndrey Utkin * period, default is 4"h2 103734d1324eSAndrey Utkin */ 103834d1324eSAndrey Utkin #define TW5864_TCD_CNT_MAX_SHIFT 4 103934d1324eSAndrey Utkin #define TW5864_TCD_CNT_MAX (0x0f << 4) 104034d1324eSAndrey Utkin /* Twr value, write recovery time, default is 4"h3 */ 104134d1324eSAndrey Utkin #define TW5864_TWR_CNT_MAX_SHIFT 12 104234d1324eSAndrey Utkin #define TW5864_TWR_CNT_MAX (0x0f << 12) 104334d1324eSAndrey Utkin 104434d1324eSAndrey Utkin /* 104534d1324eSAndrey Utkin * [2:0] CAS latency, the delay cycle between internal read command and the 104634d1324eSAndrey Utkin * availability of the first bit of output data, default is 3 104734d1324eSAndrey Utkin */ 104834d1324eSAndrey Utkin #define TW5864_CAS_LATENCY 0xa008 104934d1324eSAndrey Utkin /* 105034d1324eSAndrey Utkin * [15:0] Maximum average periodic refresh, the value is based on the current 105134d1324eSAndrey Utkin * frequency to match 7.8mcs 105234d1324eSAndrey Utkin */ 105334d1324eSAndrey Utkin #define TW5864_DDR_REF_CNTR_MAX 0xa00c 105434d1324eSAndrey Utkin /* 105534d1324eSAndrey Utkin * DDR_ON_CHIP_MAP [1:0] 105634d1324eSAndrey Utkin * 0 256M DDR on board 105734d1324eSAndrey Utkin * 1 512M DDR on board 105834d1324eSAndrey Utkin * 2 1G DDR on board 105934d1324eSAndrey Utkin * DDR_ON_CHIP_MAP [2] 106034d1324eSAndrey Utkin * 0 Only one DDR chip 106134d1324eSAndrey Utkin * 1 Two DDR chips 106234d1324eSAndrey Utkin */ 106334d1324eSAndrey Utkin #define TW5864_DDR_ON_CHIP_MAP 0xa01c 106434d1324eSAndrey Utkin #define TW5864_DDR_SELFTEST_MODE 0xa020 106534d1324eSAndrey Utkin /* Define controls in register TW5864_DDR_SELFTEST_MODE */ 106634d1324eSAndrey Utkin /* 106734d1324eSAndrey Utkin * 0 Common read/write mode 106834d1324eSAndrey Utkin * 1 DDR self-test mode 106934d1324eSAndrey Utkin */ 107034d1324eSAndrey Utkin #define TW5864_MASTER_MODE BIT(0) 107134d1324eSAndrey Utkin /* 107234d1324eSAndrey Utkin * 0 DDR self-test single read/write 107334d1324eSAndrey Utkin * 1 DDR self-test burst read/write 107434d1324eSAndrey Utkin */ 107534d1324eSAndrey Utkin #define TW5864_SINGLE_PROC BIT(1) 107634d1324eSAndrey Utkin /* 107734d1324eSAndrey Utkin * 0 DDR self-test write command 107834d1324eSAndrey Utkin * 1 DDR self-test read command 107934d1324eSAndrey Utkin */ 108034d1324eSAndrey Utkin #define TW5864_WRITE_FLAG BIT(2) 108134d1324eSAndrey Utkin #define TW5864_DATA_MODE_SHIFT 4 108234d1324eSAndrey Utkin /* 108334d1324eSAndrey Utkin * 0 write 32'haaaa5555 to DDR 108434d1324eSAndrey Utkin * 1 write 32'hffffffff to DDR 108534d1324eSAndrey Utkin * 2 write 32'hha5a55a5a to DDR 108634d1324eSAndrey Utkin * 3 write increasing data to DDR 108734d1324eSAndrey Utkin */ 108834d1324eSAndrey Utkin #define TW5864_DATA_MODE (0x3 << 4) 108934d1324eSAndrey Utkin 109034d1324eSAndrey Utkin /* [7:0] The maximum data of one burst in DDR self-test mode */ 109134d1324eSAndrey Utkin #define TW5864_BURST_CNTR_MAX 0xa024 109234d1324eSAndrey Utkin /* [15:0] The maximum burst counter (bit 15~0) in DDR self-test mode */ 109334d1324eSAndrey Utkin #define TW5864_DDR_PROC_CNTR_MAX_L 0xa028 109434d1324eSAndrey Utkin /* The maximum burst counter (bit 31~16) in DDR self-test mode */ 109534d1324eSAndrey Utkin #define TW5864_DDR_PROC_CNTR_MAX_H 0xa02c 109634d1324eSAndrey Utkin /* [0]: Start one DDR self-test */ 109734d1324eSAndrey Utkin #define TW5864_DDR_SELF_TEST_CMD 0xa030 109834d1324eSAndrey Utkin /* The maximum error counter (bit 15 ~ 0) in DDR self-test */ 109934d1324eSAndrey Utkin #define TW5864_ERR_CNTR_L 0xa034 110034d1324eSAndrey Utkin 110134d1324eSAndrey Utkin #define TW5864_ERR_CNTR_H_AND_FLAG 0xa038 110234d1324eSAndrey Utkin /* Define controls in register TW5864_ERR_CNTR_H_AND_FLAG */ 110334d1324eSAndrey Utkin /* The maximum error counter (bit 30 ~ 16) in DDR self-test */ 110434d1324eSAndrey Utkin #define TW5864_ERR_CNTR_H_MASK 0x3fff 110534d1324eSAndrey Utkin /* DDR self-test end flag */ 110634d1324eSAndrey Utkin #define TW5864_END_FLAG 0x8000 110734d1324eSAndrey Utkin 110834d1324eSAndrey Utkin /* 110934d1324eSAndrey Utkin * DDR Controller B: same as 0xa000 ~ 0xa038, but add TW5864_DDR_B_OFFSET to all 111034d1324eSAndrey Utkin * addresses 111134d1324eSAndrey Utkin */ 111234d1324eSAndrey Utkin #define TW5864_DDR_B_OFFSET 0x0800 111334d1324eSAndrey Utkin 11145b448065SMauro Carvalho Chehab /* 0xb004 ~ 0xb018 - HW version/ARB12 Register Map */ 111534d1324eSAndrey Utkin /* [15:0] Default is C013 */ 111634d1324eSAndrey Utkin #define TW5864_HW_VERSION 0xb004 111734d1324eSAndrey Utkin 111834d1324eSAndrey Utkin #define TW5864_REQS_ENABLE 0xb010 111934d1324eSAndrey Utkin /* Define controls in register TW5864_REQS_ENABLE */ 112034d1324eSAndrey Utkin /* Audio data in to DDR enable (default 1) */ 112134d1324eSAndrey Utkin #define TW5864_AUD_DATA_IN_ENB BIT(0) 112234d1324eSAndrey Utkin /* Audio encode request to DDR enable (default 1) */ 112334d1324eSAndrey Utkin #define TW5864_AUD_ENC_REQ_ENB BIT(1) 112434d1324eSAndrey Utkin /* Audio decode request0 to DDR enable (default 1) */ 112534d1324eSAndrey Utkin #define TW5864_AUD_DEC_REQ0_ENB BIT(2) 112634d1324eSAndrey Utkin /* Audio decode request1 to DDR enable (default 1) */ 112734d1324eSAndrey Utkin #define TW5864_AUD_DEC_REQ1_ENB BIT(3) 112834d1324eSAndrey Utkin /* VLC stream request to DDR enable (default 1) */ 112934d1324eSAndrey Utkin #define TW5864_VLC_STRM_REQ_ENB BIT(4) 113034d1324eSAndrey Utkin /* H264 MV request to DDR enable (default 1) */ 113134d1324eSAndrey Utkin #define TW5864_DVM_MV_REQ_ENB BIT(5) 113234d1324eSAndrey Utkin /* mux_core MVD request to DDR enable (default 1) */ 113334d1324eSAndrey Utkin #define TW5864_MVD_REQ_ENB BIT(6) 113434d1324eSAndrey Utkin /* mux_core MVD temp data request to DDR enable (default 1) */ 113534d1324eSAndrey Utkin #define TW5864_MVD_TMP_REQ_ENB BIT(7) 113634d1324eSAndrey Utkin /* JPEG request to DDR enable (default 1) */ 113734d1324eSAndrey Utkin #define TW5864_JPEG_REQ_ENB BIT(8) 113834d1324eSAndrey Utkin /* mv_flag request to DDR enable (default 1) */ 113934d1324eSAndrey Utkin #define TW5864_MV_FLAG_REQ_ENB BIT(9) 114034d1324eSAndrey Utkin 114134d1324eSAndrey Utkin #define TW5864_ARB12 0xb018 114234d1324eSAndrey Utkin /* Define controls in register TW5864_ARB12 */ 114334d1324eSAndrey Utkin /* ARB12 Enable (default 1) */ 114434d1324eSAndrey Utkin #define TW5864_ARB12_ENB BIT(15) 114534d1324eSAndrey Utkin /* ARB12 maximum value of time out counter (default 15"h1FF) */ 114634d1324eSAndrey Utkin #define TW5864_ARB12_TIME_OUT_CNT 0x7fff 114734d1324eSAndrey Utkin 11485b448065SMauro Carvalho Chehab /* 0xb800 ~ 0xb80c - Indirect Access Register Map */ 114934d1324eSAndrey Utkin /* 115034d1324eSAndrey Utkin * Spec says: 115134d1324eSAndrey Utkin * In order to access the indirect register space, the following procedure is 115234d1324eSAndrey Utkin * followed. 115334d1324eSAndrey Utkin * But reference driver implementation, and current driver, too, does it 115434d1324eSAndrey Utkin * differently. 115534d1324eSAndrey Utkin * 115634d1324eSAndrey Utkin * Write Registers: 115734d1324eSAndrey Utkin * (1) Write IND_DATA at 0xb804 ~ 0xb807 115834d1324eSAndrey Utkin * (2) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 115934d1324eSAndrey Utkin * (3) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "1", ENABLE to "1" 116034d1324eSAndrey Utkin * Read Registers: 116134d1324eSAndrey Utkin * (1) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 116234d1324eSAndrey Utkin * (2) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "0", ENABLE to "1" 116334d1324eSAndrey Utkin * (3) Read BUSY flag from 0xb803. Wait until BUSY signal is 0. 116434d1324eSAndrey Utkin * (4) Read IND_DATA from 0xb804 ~ 0xb807 116534d1324eSAndrey Utkin */ 116634d1324eSAndrey Utkin #define TW5864_IND_CTL 0xb800 116734d1324eSAndrey Utkin /* Define controls in register TW5864_IND_CTL */ 116834d1324eSAndrey Utkin /* Address used to access indirect register space */ 116934d1324eSAndrey Utkin #define TW5864_IND_ADDR 0x0000ffff 117034d1324eSAndrey Utkin /* Wait until this bit is "0" before using indirect access */ 117134d1324eSAndrey Utkin #define TW5864_BUSY BIT(31) 117234d1324eSAndrey Utkin /* Activate the indirect access. This bit is self cleared */ 117334d1324eSAndrey Utkin #define TW5864_ENABLE BIT(25) 117434d1324eSAndrey Utkin /* Read/Write command */ 117534d1324eSAndrey Utkin #define TW5864_RW BIT(24) 117634d1324eSAndrey Utkin 117734d1324eSAndrey Utkin /* [31:0] Data used to read/write indirect register space */ 117834d1324eSAndrey Utkin #define TW5864_IND_DATA 0xb804 117934d1324eSAndrey Utkin 11805b448065SMauro Carvalho Chehab /* 0xc000 ~ 0xc7fc - Preview Register Map */ 118134d1324eSAndrey Utkin /* Mostly skipped this section. */ 118234d1324eSAndrey Utkin /* 118334d1324eSAndrey Utkin * [15:0] Status of Vsync Synchronized PCI_PV_CH_EN (Read Only) 118434d1324eSAndrey Utkin * 1 Channel Enabled 118534d1324eSAndrey Utkin * 0 Channel Disabled 118634d1324eSAndrey Utkin */ 118734d1324eSAndrey Utkin #define TW5864_PCI_PV_CH_STATUS 0xc000 118834d1324eSAndrey Utkin /* 118934d1324eSAndrey Utkin * [15:0] PCI Preview Path Enable for channel n 119034d1324eSAndrey Utkin * 1 Channel Enable 119134d1324eSAndrey Utkin * 0 Channel Disable 119234d1324eSAndrey Utkin */ 119334d1324eSAndrey Utkin #define TW5864_PCI_PV_CH_EN 0xc004 119434d1324eSAndrey Utkin 11955b448065SMauro Carvalho Chehab /* 0xc800 ~ 0xc804 - JPEG Capture Register Map */ 119634d1324eSAndrey Utkin /* Skipped. */ 11975b448065SMauro Carvalho Chehab /* 0xd000 ~ 0xd0fc - JPEG Control Register Map */ 119834d1324eSAndrey Utkin /* Skipped. */ 119934d1324eSAndrey Utkin 12005b448065SMauro Carvalho Chehab /* 0xe000 ~ 0xfc04 - Motion Vector Register Map */ 120134d1324eSAndrey Utkin 120234d1324eSAndrey Utkin /* ME Motion Vector data (Four Byte Each) 0xe000 ~ 0xe7fc */ 120334d1324eSAndrey Utkin #define TW5864_ME_MV_VEC_START 0xe000 120434d1324eSAndrey Utkin #define TW5864_ME_MV_VEC_MAX_OFFSET 0x1ff 120534d1324eSAndrey Utkin #define TW5864_ME_MV_VEC(offset) (TW5864_ME_MV_VEC_START + 4 * offset) 120634d1324eSAndrey Utkin 120734d1324eSAndrey Utkin #define TW5864_MV 0xfc00 120834d1324eSAndrey Utkin /* Define controls in register TW5864_MV */ 120934d1324eSAndrey Utkin /* mv bank0 full status , write "1" to clear */ 121034d1324eSAndrey Utkin #define TW5864_MV_BK0_FULL BIT(0) 121134d1324eSAndrey Utkin /* mv bank1 full status , write "1" to clear */ 121234d1324eSAndrey Utkin #define TW5864_MV_BK1_FULL BIT(1) 121334d1324eSAndrey Utkin /* slice end status; write "1" to clear */ 121434d1324eSAndrey Utkin #define TW5864_MV_EOF BIT(2) 121534d1324eSAndrey Utkin /* mv encode interrupt status; write "1" to clear */ 121634d1324eSAndrey Utkin #define TW5864_MV_DSP_INTR BIT(3) 121734d1324eSAndrey Utkin /* mv write memory overflow, write "1" to clear */ 121834d1324eSAndrey Utkin #define TW5864_DSP_WR_OF BIT(4) 121934d1324eSAndrey Utkin #define TW5864_MV_LEN_SHIFT 5 122034d1324eSAndrey Utkin /* mv stream length */ 122134d1324eSAndrey Utkin #define TW5864_MV_LEN (0xff << 5) 122234d1324eSAndrey Utkin /* The configured status bit written into bit 15 of 0xfc04 */ 122334d1324eSAndrey Utkin #define TW5864_MPI_DDR_SEL BIT(13) 122434d1324eSAndrey Utkin 122534d1324eSAndrey Utkin #define TW5864_MPI_DDR_SEL_REG 0xfc04 122634d1324eSAndrey Utkin /* Define controls in register TW5864_MPI_DDR_SEL_REG */ 122734d1324eSAndrey Utkin /* 122834d1324eSAndrey Utkin * SW configure register 122934d1324eSAndrey Utkin * 0 MV is saved in internal DPR 123034d1324eSAndrey Utkin * 1 MV is saved in DDR 123134d1324eSAndrey Utkin */ 123234d1324eSAndrey Utkin #define TW5864_MPI_DDR_SEL2 BIT(15) 123334d1324eSAndrey Utkin 12345b448065SMauro Carvalho Chehab /* 0x18000 ~ 0x181fc - PCI Master/Slave Control Map */ 123534d1324eSAndrey Utkin #define TW5864_PCI_INTR_STATUS 0x18000 123634d1324eSAndrey Utkin /* Define controls in register TW5864_PCI_INTR_STATUS */ 123734d1324eSAndrey Utkin /* vlc done */ 123834d1324eSAndrey Utkin #define TW5864_VLC_DONE_INTR BIT(1) 123934d1324eSAndrey Utkin /* ad vsync */ 124034d1324eSAndrey Utkin #define TW5864_AD_VSYNC_INTR BIT(3) 124134d1324eSAndrey Utkin /* preview eof */ 124234d1324eSAndrey Utkin #define TW5864_PREV_EOF_INTR BIT(4) 124334d1324eSAndrey Utkin /* preview overflow interrupt */ 124434d1324eSAndrey Utkin #define TW5864_PREV_OVERFLOW_INTR BIT(5) 124534d1324eSAndrey Utkin /* timer interrupt */ 124634d1324eSAndrey Utkin #define TW5864_TIMER_INTR BIT(6) 124734d1324eSAndrey Utkin /* audio eof */ 124834d1324eSAndrey Utkin #define TW5864_AUDIO_EOF_INTR BIT(8) 124934d1324eSAndrey Utkin /* IIC done */ 125034d1324eSAndrey Utkin #define TW5864_IIC_DONE_INTR BIT(24) 125134d1324eSAndrey Utkin /* ad interrupt (e.g.: video lost, video format changed) */ 125234d1324eSAndrey Utkin #define TW5864_AD_INTR_REG BIT(25) 125334d1324eSAndrey Utkin 125434d1324eSAndrey Utkin #define TW5864_PCI_INTR_CTL 0x18004 125534d1324eSAndrey Utkin /* Define controls in register TW5864_PCI_INTR_CTL */ 125634d1324eSAndrey Utkin /* master enable */ 125734d1324eSAndrey Utkin #define TW5864_PCI_MAST_ENB BIT(0) 125834d1324eSAndrey Utkin /* mvd&vlc master enable */ 125934d1324eSAndrey Utkin #define TW5864_MVD_VLC_MAST_ENB 0x06 126034d1324eSAndrey Utkin /* (Need to set 0 in TW5864A) */ 126134d1324eSAndrey Utkin #define TW5864_AD_MAST_ENB BIT(3) 126234d1324eSAndrey Utkin /* preview master enable */ 126334d1324eSAndrey Utkin #define TW5864_PREV_MAST_ENB BIT(4) 126434d1324eSAndrey Utkin /* preview overflow enable */ 126534d1324eSAndrey Utkin #define TW5864_PREV_OVERFLOW_ENB BIT(5) 126634d1324eSAndrey Utkin /* timer interrupt enable */ 126734d1324eSAndrey Utkin #define TW5864_TIMER_INTR_ENB BIT(6) 126834d1324eSAndrey Utkin /* JPEG master (push mode) enable */ 126934d1324eSAndrey Utkin #define TW5864_JPEG_MAST_ENB BIT(7) 127034d1324eSAndrey Utkin #define TW5864_AU_MAST_ENB_CHN_SHIFT 8 127134d1324eSAndrey Utkin /* audio master channel enable */ 127234d1324eSAndrey Utkin #define TW5864_AU_MAST_ENB_CHN (0xffff << 8) 127334d1324eSAndrey Utkin /* IIC interrupt enable */ 127434d1324eSAndrey Utkin #define TW5864_IIC_INTR_ENB BIT(24) 127534d1324eSAndrey Utkin /* ad interrupt enable */ 127634d1324eSAndrey Utkin #define TW5864_AD_INTR_ENB BIT(25) 127734d1324eSAndrey Utkin /* target burst enable */ 127834d1324eSAndrey Utkin #define TW5864_PCI_TAR_BURST_ENB BIT(26) 127934d1324eSAndrey Utkin /* vlc stream burst enable */ 128034d1324eSAndrey Utkin #define TW5864_PCI_VLC_BURST_ENB BIT(27) 128134d1324eSAndrey Utkin /* ddr burst enable (1 enable, and must set DDR_BRST_EN) */ 128234d1324eSAndrey Utkin #define TW5864_PCI_DDR_BURST_ENB BIT(28) 128334d1324eSAndrey Utkin 128434d1324eSAndrey Utkin /* 128534d1324eSAndrey Utkin * Because preview and audio have 16 channels separately, so using this 128634d1324eSAndrey Utkin * registers to indicate interrupt status for every channels. This is secondary 128734d1324eSAndrey Utkin * interrupt status register. OR operating of the PREV_INTR_REG is 128834d1324eSAndrey Utkin * PREV_EOF_INTR, OR operating of the AU_INTR_REG bits is AUDIO_EOF_INTR 128934d1324eSAndrey Utkin */ 129034d1324eSAndrey Utkin #define TW5864_PREV_AND_AU_INTR 0x18008 129134d1324eSAndrey Utkin /* Define controls in register TW5864_PREV_AND_AU_INTR */ 129234d1324eSAndrey Utkin /* preview eof interrupt flag */ 129334d1324eSAndrey Utkin #define TW5864_PREV_INTR_REG 0x0000ffff 129434d1324eSAndrey Utkin #define TW5864_AU_INTR_REG_SHIFT 16 129534d1324eSAndrey Utkin /* audio eof interrupt flag */ 129634d1324eSAndrey Utkin #define TW5864_AU_INTR_REG (0xffff << 16) 129734d1324eSAndrey Utkin 129834d1324eSAndrey Utkin #define TW5864_MASTER_ENB_REG 0x1800c 129934d1324eSAndrey Utkin /* Define controls in register TW5864_MASTER_ENB_REG */ 130034d1324eSAndrey Utkin /* master enable */ 130134d1324eSAndrey Utkin #define TW5864_PCI_VLC_INTR_ENB BIT(1) 130234d1324eSAndrey Utkin /* mvd and vlc master enable */ 130334d1324eSAndrey Utkin #define TW5864_PCI_PREV_INTR_ENB BIT(4) 130434d1324eSAndrey Utkin /* ad vsync master enable */ 130534d1324eSAndrey Utkin #define TW5864_PCI_PREV_OF_INTR_ENB BIT(5) 130634d1324eSAndrey Utkin /* jpeg master enable */ 130734d1324eSAndrey Utkin #define TW5864_PCI_JPEG_INTR_ENB BIT(7) 130834d1324eSAndrey Utkin /* preview master enable */ 130934d1324eSAndrey Utkin #define TW5864_PCI_AUD_INTR_ENB BIT(8) 131034d1324eSAndrey Utkin 131134d1324eSAndrey Utkin /* 131234d1324eSAndrey Utkin * Every channel of preview and audio have ping-pong buffers in system memory, 131334d1324eSAndrey Utkin * this register is the buffer flag to notify software which buffer is been 131434d1324eSAndrey Utkin * operated. 131534d1324eSAndrey Utkin */ 131634d1324eSAndrey Utkin #define TW5864_PREV_AND_AU_BUF_FLAG 0x18010 131734d1324eSAndrey Utkin /* Define controls in register TW5864_PREV_AND_AU_BUF_FLAG */ 131834d1324eSAndrey Utkin /* preview buffer A/B flag */ 131934d1324eSAndrey Utkin #define TW5864_PREV_BUF_FLAG 0xffff 132034d1324eSAndrey Utkin #define TW5864_AUDIO_BUF_FLAG_SHIFT 16 132134d1324eSAndrey Utkin /* audio buffer A/B flag */ 132234d1324eSAndrey Utkin #define TW5864_AUDIO_BUF_FLAG (0xffff << 16) 132334d1324eSAndrey Utkin 132434d1324eSAndrey Utkin #define TW5864_IIC 0x18014 132534d1324eSAndrey Utkin /* Define controls in register TW5864_IIC */ 132634d1324eSAndrey Utkin /* register data */ 132734d1324eSAndrey Utkin #define TW5864_IIC_DATA 0x00ff 132834d1324eSAndrey Utkin #define TW5864_IIC_REG_ADDR_SHIFT 8 132934d1324eSAndrey Utkin /* register addr */ 133034d1324eSAndrey Utkin #define TW5864_IIC_REG_ADDR (0xff << 8) 133134d1324eSAndrey Utkin /* rd/wr flag rd=1,wr=0 */ 133234d1324eSAndrey Utkin #define TW5864_IIC_RW BIT(16) 133334d1324eSAndrey Utkin #define TW5864_IIC_DEV_ADDR_SHIFT 17 133434d1324eSAndrey Utkin /* device addr */ 133534d1324eSAndrey Utkin #define TW5864_IIC_DEV_ADDR (0x7f << 17) 133634d1324eSAndrey Utkin /* 133734d1324eSAndrey Utkin * iic done, software kick off one time iic transaction through setting this 133834d1324eSAndrey Utkin * bit to 1. Then poll this bit, value 1 indicate iic transaction have 133934d1324eSAndrey Utkin * completed, if read, valid data have been stored in iic_data 134034d1324eSAndrey Utkin */ 134134d1324eSAndrey Utkin #define TW5864_IIC_DONE BIT(24) 134234d1324eSAndrey Utkin 134334d1324eSAndrey Utkin #define TW5864_RST_AND_IF_INFO 0x18018 134434d1324eSAndrey Utkin /* Define controls in register TW5864_RST_AND_IF_INFO */ 134534d1324eSAndrey Utkin /* application software soft reset */ 134634d1324eSAndrey Utkin #define TW5864_APP_SOFT_RST BIT(0) 134734d1324eSAndrey Utkin #define TW5864_PCI_INF_VERSION_SHIFT 16 134834d1324eSAndrey Utkin /* PCI interface version, read only */ 134934d1324eSAndrey Utkin #define TW5864_PCI_INF_VERSION (0xffff << 16) 135034d1324eSAndrey Utkin 135134d1324eSAndrey Utkin /* vlc stream crc value, it is calculated in pci module */ 135234d1324eSAndrey Utkin #define TW5864_VLC_CRC_REG 0x1801c 135334d1324eSAndrey Utkin /* 135434d1324eSAndrey Utkin * vlc max length, it is defined by software based on software assign memory 135534d1324eSAndrey Utkin * space for vlc 135634d1324eSAndrey Utkin */ 135734d1324eSAndrey Utkin #define TW5864_VLC_MAX_LENGTH 0x18020 135834d1324eSAndrey Utkin /* vlc length of one frame */ 135934d1324eSAndrey Utkin #define TW5864_VLC_LENGTH 0x18024 136034d1324eSAndrey Utkin /* vlc original crc value */ 136134d1324eSAndrey Utkin #define TW5864_VLC_INTRA_CRC_I_REG 0x18028 136234d1324eSAndrey Utkin /* vlc original crc value */ 136334d1324eSAndrey Utkin #define TW5864_VLC_INTRA_CRC_O_REG 0x1802c 136434d1324eSAndrey Utkin /* mv stream crc value, it is calculated in pci module */ 136534d1324eSAndrey Utkin #define TW5864_VLC_PAR_CRC_REG 0x18030 136634d1324eSAndrey Utkin /* mv length */ 136734d1324eSAndrey Utkin #define TW5864_VLC_PAR_LENGTH_REG 0x18034 136834d1324eSAndrey Utkin /* mv original crc value */ 136934d1324eSAndrey Utkin #define TW5864_VLC_PAR_I_REG 0x18038 137034d1324eSAndrey Utkin /* mv original crc value */ 137134d1324eSAndrey Utkin #define TW5864_VLC_PAR_O_REG 0x1803c 137234d1324eSAndrey Utkin 137334d1324eSAndrey Utkin /* 137434d1324eSAndrey Utkin * Configuration register for 9[or 10] CIFs or 1D1+15QCIF Preview mode. 137534d1324eSAndrey Utkin * PREV_PCI_ENB_CHN[0] Enable 9th preview channel (9CIF prev) or 1D1 channel in 137634d1324eSAndrey Utkin * (1D1+15QCIF prev) 137734d1324eSAndrey Utkin * PREV_PCI_ENB_CHN[1] Enable 10th preview channel 137834d1324eSAndrey Utkin */ 137934d1324eSAndrey Utkin #define TW5864_PREV_PCI_ENB_CHN 0x18040 138034d1324eSAndrey Utkin /* Description skipped. */ 138134d1324eSAndrey Utkin #define TW5864_PREV_FRAME_FORMAT_IN 0x18044 138234d1324eSAndrey Utkin /* IIC enable */ 138334d1324eSAndrey Utkin #define TW5864_IIC_ENB 0x18048 138434d1324eSAndrey Utkin /* 138534d1324eSAndrey Utkin * Timer interrupt interval 138634d1324eSAndrey Utkin * 0 1ms 138734d1324eSAndrey Utkin * 1 2ms 138834d1324eSAndrey Utkin * 2 4ms 138934d1324eSAndrey Utkin * 3 8ms 139034d1324eSAndrey Utkin */ 139134d1324eSAndrey Utkin #define TW5864_PCI_INTTM_SCALE 0x1804c 139234d1324eSAndrey Utkin 139334d1324eSAndrey Utkin /* 139434d1324eSAndrey Utkin * The above register is pci base address registers. Application software will 139534d1324eSAndrey Utkin * initialize them to tell chip where the corresponding stream will be dumped 139634d1324eSAndrey Utkin * to. Application software will select appropriate base address interval based 139734d1324eSAndrey Utkin * on the stream length. 139834d1324eSAndrey Utkin */ 139934d1324eSAndrey Utkin /* VLC stream base address */ 140034d1324eSAndrey Utkin #define TW5864_VLC_STREAM_BASE_ADDR 0x18080 140134d1324eSAndrey Utkin /* MV stream base address */ 140234d1324eSAndrey Utkin #define TW5864_MV_STREAM_BASE_ADDR 0x18084 14035b448065SMauro Carvalho Chehab /* 0x180a0 ~ 0x180bc: audio burst base address. Skipped. */ 14045b448065SMauro Carvalho Chehab /* 0x180c0 ~ 0x180dc: JPEG Push Mode Buffer Base Address. Skipped. */ 14055b448065SMauro Carvalho Chehab /* 0x18100 ~ 0x1817c: preview burst base address. Skipped. */ 140634d1324eSAndrey Utkin 14075b448065SMauro Carvalho Chehab /* 0x80000 ~ 0x87fff - DDR Burst RW Register Map */ 140834d1324eSAndrey Utkin #define TW5864_DDR_CTL 0x80000 140934d1324eSAndrey Utkin /* Define controls in register TW5864_DDR_CTL */ 141034d1324eSAndrey Utkin #define TW5864_BRST_LENGTH_SHIFT 2 141134d1324eSAndrey Utkin /* Length of 32-bit data burst */ 141234d1324eSAndrey Utkin #define TW5864_BRST_LENGTH (0x3fff << 2) 141334d1324eSAndrey Utkin /* 141434d1324eSAndrey Utkin * Burst Read/Write 141534d1324eSAndrey Utkin * 0 Read Burst from DDR 141634d1324eSAndrey Utkin * 1 Write Burst to DDR 141734d1324eSAndrey Utkin */ 141834d1324eSAndrey Utkin #define TW5864_BRST_RW BIT(16) 141934d1324eSAndrey Utkin /* Begin a new DDR Burst. This bit is self cleared */ 142034d1324eSAndrey Utkin #define TW5864_NEW_BRST_CMD BIT(17) 142134d1324eSAndrey Utkin /* DDR Burst End Flag */ 142234d1324eSAndrey Utkin #define TW5864_BRST_END BIT(24) 142334d1324eSAndrey Utkin /* Enable Error Interrupt for Single DDR Access */ 142434d1324eSAndrey Utkin #define TW5864_SING_ERR_INTR BIT(25) 142534d1324eSAndrey Utkin /* Enable Error Interrupt for Burst DDR Access */ 142634d1324eSAndrey Utkin #define TW5864_BRST_ERR_INTR BIT(26) 142734d1324eSAndrey Utkin /* Enable Interrupt for End of DDR Burst Access */ 142834d1324eSAndrey Utkin #define TW5864_BRST_END_INTR BIT(27) 142934d1324eSAndrey Utkin /* DDR Single Access Error Flag */ 143034d1324eSAndrey Utkin #define TW5864_SINGLE_ERR BIT(28) 143134d1324eSAndrey Utkin /* DDR Single Access Busy Flag */ 143234d1324eSAndrey Utkin #define TW5864_SINGLE_BUSY BIT(29) 143334d1324eSAndrey Utkin /* DDR Burst Access Error Flag */ 143434d1324eSAndrey Utkin #define TW5864_BRST_ERR BIT(30) 143534d1324eSAndrey Utkin /* DDR Burst Access Busy Flag */ 143634d1324eSAndrey Utkin #define TW5864_BRST_BUSY BIT(31) 143734d1324eSAndrey Utkin 143834d1324eSAndrey Utkin /* [27:0] DDR Access Address. Bit [1:0] has to be 0 */ 143934d1324eSAndrey Utkin #define TW5864_DDR_ADDR 0x80004 144034d1324eSAndrey Utkin /* DDR Access Internal Buffer Address. Bit [1:0] has to be 0 */ 144134d1324eSAndrey Utkin #define TW5864_DPR_BUF_ADDR 0x80008 144234d1324eSAndrey Utkin /* SRAM Buffer MPI Access Space. Totally 16 KB */ 144334d1324eSAndrey Utkin #define TW5864_DPR_BUF_START 0x84000 144434d1324eSAndrey Utkin /* 0x84000 - 0x87ffc */ 144534d1324eSAndrey Utkin #define TW5864_DPR_BUF_SIZE 0x4000 144634d1324eSAndrey Utkin 144734d1324eSAndrey Utkin /* Indirect Map Space */ 144834d1324eSAndrey Utkin /* 144934d1324eSAndrey Utkin * The indirect space is accessed through 0xb800 ~ 0xb807 registers in direct 145034d1324eSAndrey Utkin * access space 145134d1324eSAndrey Utkin */ 145234d1324eSAndrey Utkin /* Analog Video / Audio Decoder / Encoder */ 145334d1324eSAndrey Utkin /* Allowed channel values: [0; 3] */ 145434d1324eSAndrey Utkin /* Read-only register */ 145534d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0(channel) (0x000 + channel * 0x010) 145634d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_0 */ 145734d1324eSAndrey Utkin /* 145834d1324eSAndrey Utkin * 1 Video not present. (sync is not detected in number of consecutive line 145934d1324eSAndrey Utkin * periods specified by MISSCNT register) 146034d1324eSAndrey Utkin * 0 Video detected. 146134d1324eSAndrey Utkin */ 146234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_VDLOSS BIT(7) 146334d1324eSAndrey Utkin /* 146434d1324eSAndrey Utkin * 1 Horizontal sync PLL is locked to the incoming video source. 146534d1324eSAndrey Utkin * 0 Horizontal sync PLL is not locked. 146634d1324eSAndrey Utkin */ 146734d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_HLOCK BIT(6) 146834d1324eSAndrey Utkin /* 146934d1324eSAndrey Utkin * 1 Sub-carrier PLL is locked to the incoming video source. 147034d1324eSAndrey Utkin * 0 Sub-carrier PLL is not locked. 147134d1324eSAndrey Utkin */ 147234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_SLOCK BIT(5) 147334d1324eSAndrey Utkin /* 147434d1324eSAndrey Utkin * 1 Even field is being decoded. 147534d1324eSAndrey Utkin * 0 Odd field is being decoded. 147634d1324eSAndrey Utkin */ 147734d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_FLD BIT(4) 147834d1324eSAndrey Utkin /* 147934d1324eSAndrey Utkin * 1 Vertical logic is locked to the incoming video source. 148034d1324eSAndrey Utkin * 0 Vertical logic is not locked. 148134d1324eSAndrey Utkin */ 148234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_VLOCK BIT(3) 148334d1324eSAndrey Utkin /* 148434d1324eSAndrey Utkin * 1 No color burst signal detected. 148534d1324eSAndrey Utkin * 0 Color burst signal detected. 148634d1324eSAndrey Utkin */ 148734d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_MONO BIT(1) 148834d1324eSAndrey Utkin /* 148934d1324eSAndrey Utkin * 0 60Hz source detected 149034d1324eSAndrey Utkin * 1 50Hz source detected 149134d1324eSAndrey Utkin * The actual vertical scanning frequency depends on the current standard 149234d1324eSAndrey Utkin * invoked. 149334d1324eSAndrey Utkin */ 149434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_0_DET50 BIT(0) 149534d1324eSAndrey Utkin 149634d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1(channel) (0x001 + channel * 0x010) 149734d1324eSAndrey Utkin /* VCR signal indicator. Read-only. */ 149834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_VCR BIT(7) 149934d1324eSAndrey Utkin /* Weak signal indicator 2. Read-only. */ 150034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_WKAIR BIT(6) 150134d1324eSAndrey Utkin /* Weak signal indicator controlled by WKTH. Read-only. */ 150234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_WKAIR1 BIT(5) 150334d1324eSAndrey Utkin /* 150434d1324eSAndrey Utkin * 1 = Standard signal 150534d1324eSAndrey Utkin * 0 = Non-standard signal 150634d1324eSAndrey Utkin * Read-only 150734d1324eSAndrey Utkin */ 150834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_VSTD BIT(4) 150934d1324eSAndrey Utkin /* 151034d1324eSAndrey Utkin * 1 = Non-interlaced signal 151134d1324eSAndrey Utkin * 0 = interlaced signal 151234d1324eSAndrey Utkin * Read-only 151334d1324eSAndrey Utkin */ 151434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_NINTL BIT(3) 151534d1324eSAndrey Utkin /* 151634d1324eSAndrey Utkin * Vertical Sharpness Control. Writable. 151734d1324eSAndrey Utkin * 0 = None (default) 151834d1324eSAndrey Utkin * 7 = Highest 15195b448065SMauro Carvalho Chehab * **Note: VSHP must be set to '0' if COMB = 0 152034d1324eSAndrey Utkin */ 152134d1324eSAndrey Utkin #define TW5864_INDIR_VIN_1_VSHP 0x07 152234d1324eSAndrey Utkin 152334d1324eSAndrey Utkin /* HDELAY_XY[7:0] */ 152434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_2_HDELAY_XY_LO(channel) (0x002 + channel * 0x010) 152534d1324eSAndrey Utkin /* HACTIVE_XY[7:0] */ 152634d1324eSAndrey Utkin #define TW5864_INDIR_VIN_3_HACTIVE_XY_LO(channel) (0x003 + channel * 0x010) 152734d1324eSAndrey Utkin /* VDELAY_XY[7:0] */ 152834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_4_VDELAY_XY_LO(channel) (0x004 + channel * 0x010) 152934d1324eSAndrey Utkin /* VACTIVE_XY[7:0] */ 153034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_5_VACTIVE_XY_LO(channel) (0x005 + channel * 0x010) 153134d1324eSAndrey Utkin 153234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6(channel) (0x006 + channel * 0x010) 153334d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_6 */ 153434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6_HDELAY_XY_HI 0x03 153534d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6_HACTIVE_XY_HI_SHIFT 2 153634d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6_HACTIVE_XY_HI (0x03 << 2) 153734d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6_VDELAY_XY_HI BIT(4) 153834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_6_VACTIVE_XY_HI BIT(5) 153934d1324eSAndrey Utkin 154034d1324eSAndrey Utkin /* 154134d1324eSAndrey Utkin * HDELAY_XY This 10bit register defines the starting location of horizontal 154234d1324eSAndrey Utkin * active pixel for display / record path. A unit is 1 pixel. The default value 154334d1324eSAndrey Utkin * is 0x00f for NTSC and 0x00a for PAL. 154434d1324eSAndrey Utkin * 154534d1324eSAndrey Utkin * HACTIVE_XY This 10bit register defines the number of horizontal active pixel 154634d1324eSAndrey Utkin * for display / record path. A unit is 1 pixel. The default value is decimal 154734d1324eSAndrey Utkin * 720. 154834d1324eSAndrey Utkin * 154934d1324eSAndrey Utkin * VDELAY_XY This 9bit register defines the starting location of vertical 155034d1324eSAndrey Utkin * active for display / record path. A unit is 1 line. The default value is 155134d1324eSAndrey Utkin * decimal 6. 155234d1324eSAndrey Utkin * 155334d1324eSAndrey Utkin * VACTIVE_XY This 9bit register defines the number of vertical active lines 155434d1324eSAndrey Utkin * for display / record path. A unit is 1 line. The default value is decimal 155534d1324eSAndrey Utkin * 240. 155634d1324eSAndrey Utkin */ 155734d1324eSAndrey Utkin 155834d1324eSAndrey Utkin /* HUE These bits control the color hue as 2's complement number. They have 155934d1324eSAndrey Utkin * value from +36o (7Fh) to -36o (80h) with an increment of 2.8o. The 2 LSB has 156034d1324eSAndrey Utkin * no effect. The positive value gives greenish tone and negative value gives 156134d1324eSAndrey Utkin * purplish tone. The default value is 0o (00h). This is effective only on NTSC 156234d1324eSAndrey Utkin * system. The default is 00h. 156334d1324eSAndrey Utkin */ 156434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_7_HUE(channel) (0x007 + channel * 0x010) 156534d1324eSAndrey Utkin 156634d1324eSAndrey Utkin #define TW5864_INDIR_VIN_8(channel) (0x008 + channel * 0x010) 156734d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_8 */ 156834d1324eSAndrey Utkin /* 156934d1324eSAndrey Utkin * This bit controls the center frequency of the peaking filter. 157034d1324eSAndrey Utkin * The corresponding gain adjustment is HFLT. 157134d1324eSAndrey Utkin * 0 Low 157234d1324eSAndrey Utkin * 1 center 157334d1324eSAndrey Utkin */ 157434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_8_SCURVE BIT(7) 157534d1324eSAndrey Utkin /* CTI level selection. The default is 1. 157634d1324eSAndrey Utkin * 0 None 157734d1324eSAndrey Utkin * 3 Highest 157834d1324eSAndrey Utkin */ 157934d1324eSAndrey Utkin #define TW5864_INDIR_VIN_8_CTI_SHIFT 4 158034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_8_CTI (0x03 << 4) 158134d1324eSAndrey Utkin 158234d1324eSAndrey Utkin /* 158334d1324eSAndrey Utkin * These bits control the amount of sharpness enhancement on the luminance 158434d1324eSAndrey Utkin * signals. There are 16 levels of control with "0" having no effect on the 158534d1324eSAndrey Utkin * output image. 1 through 15 provides sharpness enhancement with "F" being the 158634d1324eSAndrey Utkin * strongest. The default is 1. 158734d1324eSAndrey Utkin */ 158834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_8_SHARPNESS 0x0f 158934d1324eSAndrey Utkin 159034d1324eSAndrey Utkin /* 159134d1324eSAndrey Utkin * These bits control the luminance contrast gain. A value of 100 (64h) has a 159234d1324eSAndrey Utkin * gain of 1. The range adjustment is from 0% to 255% at 1% per step. The 159334d1324eSAndrey Utkin * default is 64h. 159434d1324eSAndrey Utkin */ 159534d1324eSAndrey Utkin #define TW5864_INDIR_VIN_9_CNTRST(channel) (0x009 + channel * 0x010) 159634d1324eSAndrey Utkin 159734d1324eSAndrey Utkin /* 15985b448065SMauro Carvalho Chehab * These bits control the brightness. They have value of -128 to 127 in 2's 159934d1324eSAndrey Utkin * complement form. Positive value increases brightness. A value 0 has no 160034d1324eSAndrey Utkin * effect on the data. The default is 00h. 160134d1324eSAndrey Utkin */ 160234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_A_BRIGHT(channel) (0x00a + channel * 0x010) 160334d1324eSAndrey Utkin 160434d1324eSAndrey Utkin /* 160534d1324eSAndrey Utkin * These bits control the digital gain adjustment to the U (or Cb) component of 160634d1324eSAndrey Utkin * the digital video signal. The color saturation can be adjusted by adjusting 160734d1324eSAndrey Utkin * the U and V color gain components by the same amount in the normal 160834d1324eSAndrey Utkin * situation. The U and V can also be adjusted independently to provide greater 160934d1324eSAndrey Utkin * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 161034d1324eSAndrey Utkin * gain of 100%. The default is 80h. 161134d1324eSAndrey Utkin */ 161234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_B_SAT_U(channel) (0x00b + channel * 0x010) 161334d1324eSAndrey Utkin 161434d1324eSAndrey Utkin /* 161534d1324eSAndrey Utkin * These bits control the digital gain adjustment to the V (or Cr) component of 161634d1324eSAndrey Utkin * the digital video signal. The color saturation can be adjusted by adjusting 161734d1324eSAndrey Utkin * the U and V color gain components by the same amount in the normal 161834d1324eSAndrey Utkin * situation. The U and V can also be adjusted independently to provide greater 161934d1324eSAndrey Utkin * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has 162034d1324eSAndrey Utkin * gain of 100%. The default is 80h. 162134d1324eSAndrey Utkin */ 162234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_C_SAT_V(channel) (0x00c + channel * 0x010) 162334d1324eSAndrey Utkin 162434d1324eSAndrey Utkin /* Read-only */ 162534d1324eSAndrey Utkin #define TW5864_INDIR_VIN_D(channel) (0x00d + channel * 0x010) 162634d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_D */ 162734d1324eSAndrey Utkin /* Macrovision color stripe detection may be un-reliable */ 162834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_D_CSBAD BIT(3) 162934d1324eSAndrey Utkin /* Macrovision AGC pulse detected */ 163034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_D_MCVSN BIT(2) 163134d1324eSAndrey Utkin /* Macrovision color stripe protection burst detected */ 163234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_D_CSTRIPE BIT(1) 163334d1324eSAndrey Utkin /* 163434d1324eSAndrey Utkin * This bit is valid only when color stripe protection is detected, i.e. if 163534d1324eSAndrey Utkin * CSTRIPE=1, 163634d1324eSAndrey Utkin * 1 Type 2 color stripe protection 163734d1324eSAndrey Utkin * 0 Type 3 color stripe protection 163834d1324eSAndrey Utkin */ 163934d1324eSAndrey Utkin #define TW5864_INDIR_VIN_D_CTYPE2 BIT(0) 164034d1324eSAndrey Utkin 164134d1324eSAndrey Utkin /* Read-only */ 164234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E(channel) (0x00e + channel * 0x010) 164334d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_E */ 164434d1324eSAndrey Utkin /* 164534d1324eSAndrey Utkin * Read-only. 164634d1324eSAndrey Utkin * 0 Idle 164734d1324eSAndrey Utkin * 1 Detection in progress 164834d1324eSAndrey Utkin */ 164934d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E_DETSTUS BIT(7) 165034d1324eSAndrey Utkin /* 165134d1324eSAndrey Utkin * STDNOW Current standard invoked 165234d1324eSAndrey Utkin * 0 NTSC (M) 165334d1324eSAndrey Utkin * 1 PAL (B, D, G, H, I) 165434d1324eSAndrey Utkin * 2 SECAM 165534d1324eSAndrey Utkin * 3 NTSC4.43 165634d1324eSAndrey Utkin * 4 PAL (M) 165734d1324eSAndrey Utkin * 5 PAL (CN) 165834d1324eSAndrey Utkin * 6 PAL 60 165934d1324eSAndrey Utkin * 7 Not valid 166034d1324eSAndrey Utkin */ 166134d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E_STDNOW_SHIFT 4 166234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E_STDNOW (0x07 << 4) 166334d1324eSAndrey Utkin 166434d1324eSAndrey Utkin /* 166534d1324eSAndrey Utkin * 1 Disable the shadow registers 166634d1324eSAndrey Utkin * 0 Enable VACTIVE and HDELAY shadow registers value depending on STANDARD. 166734d1324eSAndrey Utkin * (Default) 166834d1324eSAndrey Utkin */ 166934d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E_ATREG BIT(3) 167034d1324eSAndrey Utkin /* 167134d1324eSAndrey Utkin * STANDARD Standard selection 167234d1324eSAndrey Utkin * 0 NTSC (M) 167334d1324eSAndrey Utkin * 1 PAL (B, D, G, H, I) 167434d1324eSAndrey Utkin * 2 SECAM 167534d1324eSAndrey Utkin * 3 NTSC4.43 167634d1324eSAndrey Utkin * 4 PAL (M) 167734d1324eSAndrey Utkin * 5 PAL (CN) 167834d1324eSAndrey Utkin * 6 PAL 60 167934d1324eSAndrey Utkin * 7 Auto detection (Default) 168034d1324eSAndrey Utkin */ 168134d1324eSAndrey Utkin #define TW5864_INDIR_VIN_E_STANDARD 0x07 168234d1324eSAndrey Utkin 168334d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F(channel) (0x00f + channel * 0x010) 168434d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_VIN_F */ 168534d1324eSAndrey Utkin /* 168634d1324eSAndrey Utkin * 1 Writing 1 to this bit will manually initiate the auto format detection 168734d1324eSAndrey Utkin * process. This bit is a self-clearing bit 168834d1324eSAndrey Utkin * 0 Manual initiation of auto format detection is done. (Default) 168934d1324eSAndrey Utkin */ 169034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_ATSTART BIT(7) 169134d1324eSAndrey Utkin /* Enable recognition of PAL60 (Default) */ 169234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_PAL60EN BIT(6) 169334d1324eSAndrey Utkin /* Enable recognition of PAL (CN). (Default) */ 169434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_PALCNEN BIT(5) 169534d1324eSAndrey Utkin /* Enable recognition of PAL (M). (Default) */ 169634d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_PALMEN BIT(4) 169734d1324eSAndrey Utkin /* Enable recognition of NTSC 4.43. (Default) */ 169834d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_NTSC44EN BIT(3) 169934d1324eSAndrey Utkin /* Enable recognition of SECAM. (Default) */ 170034d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_SECAMEN BIT(2) 170134d1324eSAndrey Utkin /* Enable recognition of PAL (B, D, G, H, I). (Default) */ 170234d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_PALBEN BIT(1) 170334d1324eSAndrey Utkin /* Enable recognition of NTSC (M). (Default) */ 170434d1324eSAndrey Utkin #define TW5864_INDIR_VIN_F_NTSCEN BIT(0) 170534d1324eSAndrey Utkin 170634d1324eSAndrey Utkin /* Some registers skipped. */ 170734d1324eSAndrey Utkin 170834d1324eSAndrey Utkin /* Use falling edge to sample VD1-VD4 from 54 MHz to 108 MHz */ 170934d1324eSAndrey Utkin #define TW5864_INDIR_VD_108_POL 0x041 171034d1324eSAndrey Utkin #define TW5864_INDIR_VD_108_POL_VD12 BIT(0) 171134d1324eSAndrey Utkin #define TW5864_INDIR_VD_108_POL_VD34 BIT(1) 171234d1324eSAndrey Utkin #define TW5864_INDIR_VD_108_POL_BOTH \ 171334d1324eSAndrey Utkin (TW5864_INDIR_VD_108_POL_VD12 | TW5864_INDIR_VD_108_POL_VD34) 171434d1324eSAndrey Utkin 171534d1324eSAndrey Utkin /* Some registers skipped. */ 171634d1324eSAndrey Utkin 171734d1324eSAndrey Utkin /* 171834d1324eSAndrey Utkin * Audio Input ADC gain control 171934d1324eSAndrey Utkin * 0 0.25 172034d1324eSAndrey Utkin * 1 0.31 172134d1324eSAndrey Utkin * 2 0.38 172234d1324eSAndrey Utkin * 3 0.44 172334d1324eSAndrey Utkin * 4 0.50 172434d1324eSAndrey Utkin * 5 0.63 172534d1324eSAndrey Utkin * 6 0.75 172634d1324eSAndrey Utkin * 7 0.88 172734d1324eSAndrey Utkin * 8 1.00 (default) 172834d1324eSAndrey Utkin * 9 1.25 172934d1324eSAndrey Utkin * 10 1.50 173034d1324eSAndrey Utkin * 11 1.75 173134d1324eSAndrey Utkin * 12 2.00 173234d1324eSAndrey Utkin * 13 2.25 173334d1324eSAndrey Utkin * 14 2.50 173434d1324eSAndrey Utkin * 15 2.75 173534d1324eSAndrey Utkin */ 173634d1324eSAndrey Utkin /* [3:0] channel 0, [7:4] channel 1 */ 173734d1324eSAndrey Utkin #define TW5864_INDIR_AIGAIN1 0x060 173834d1324eSAndrey Utkin /* [3:0] channel 2, [7:4] channel 3 */ 173934d1324eSAndrey Utkin #define TW5864_INDIR_AIGAIN2 0x061 174034d1324eSAndrey Utkin 174134d1324eSAndrey Utkin /* Some registers skipped */ 174234d1324eSAndrey Utkin 174334d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x06D 0x06d 174434d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_AIN_0x06D */ 174534d1324eSAndrey Utkin /* 174634d1324eSAndrey Utkin * LAWMD Select u-Law/A-Law/PCM/SB data output format on ADATR and ADATM pin. 174734d1324eSAndrey Utkin * 0 PCM output (default) 174834d1324eSAndrey Utkin * 1 SB (Signed MSB bit in PCM data is inverted) output 174934d1324eSAndrey Utkin * 2 u-Law output 175034d1324eSAndrey Utkin * 3 A-Law output 175134d1324eSAndrey Utkin */ 175234d1324eSAndrey Utkin #define TW5864_INDIR_AIN_LAWMD_SHIFT 6 175334d1324eSAndrey Utkin #define TW5864_INDIR_AIN_LAWMD (0x03 << 6) 175434d1324eSAndrey Utkin /* 175534d1324eSAndrey Utkin * Disable the mixing ratio value for all audio. 175634d1324eSAndrey Utkin * 0 Apply individual mixing ratio value for each audio (default) 175734d1324eSAndrey Utkin * 1 Apply nominal value for all audio commonly 175834d1324eSAndrey Utkin */ 175934d1324eSAndrey Utkin #define TW5864_INDIR_AIN_MIX_DERATIO BIT(5) 176034d1324eSAndrey Utkin /* 176134d1324eSAndrey Utkin * Enable the mute function for audio channel AINn when n is 0 to 3. It effects 176234d1324eSAndrey Utkin * only for mixing. When n = 4, it enable the mute function of the playback 176334d1324eSAndrey Utkin * audio input. It effects only for single chip or the last stage chip 176434d1324eSAndrey Utkin * 0 Normal 176534d1324eSAndrey Utkin * 1 Muted (default) 176634d1324eSAndrey Utkin */ 176734d1324eSAndrey Utkin #define TW5864_INDIR_AIN_MIX_MUTE 0x1f 176834d1324eSAndrey Utkin 176934d1324eSAndrey Utkin /* Some registers skipped */ 177034d1324eSAndrey Utkin 177134d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3 0x0e3 177234d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_AIN_0x0E3 */ 177334d1324eSAndrey Utkin /* 177434d1324eSAndrey Utkin * ADATP signal is coming from external ADPCM decoder, instead of on-chip ADPCM 177534d1324eSAndrey Utkin * decoder 177634d1324eSAndrey Utkin */ 177734d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_EXT_ADATP BIT(7) 177834d1324eSAndrey Utkin /* ACLKP output signal polarity inverse */ 177934d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_ACLKPPOLO BIT(6) 178034d1324eSAndrey Utkin /* 178134d1324eSAndrey Utkin * ACLKR input signal polarity inverse. 178234d1324eSAndrey Utkin * 0 Not inversed (Default) 178334d1324eSAndrey Utkin * 1 Inversed 178434d1324eSAndrey Utkin */ 178534d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_ACLKRPOL BIT(5) 178634d1324eSAndrey Utkin /* 178734d1324eSAndrey Utkin * ACLKP input signal polarity inverse. 178834d1324eSAndrey Utkin * 0 Not inversed (Default) 178934d1324eSAndrey Utkin * 1 Inversed 179034d1324eSAndrey Utkin */ 179134d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_ACLKPPOLI BIT(4) 179234d1324eSAndrey Utkin /* 179334d1324eSAndrey Utkin * ACKI [21:0] control automatic set up with AFMD registers 179434d1324eSAndrey Utkin * This mode is only effective when ACLKRMASTER=1 179534d1324eSAndrey Utkin * 0 ACKI [21:0] registers set up ACKI control 179634d1324eSAndrey Utkin * 1 ACKI control is automatically set up by AFMD register values 179734d1324eSAndrey Utkin */ 179834d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_AFAUTO BIT(3) 179934d1324eSAndrey Utkin /* 180034d1324eSAndrey Utkin * AFAUTO control mode 180134d1324eSAndrey Utkin * 0 8kHz setting (Default) 180234d1324eSAndrey Utkin * 1 16kHz setting 180334d1324eSAndrey Utkin * 2 32kHz setting 180434d1324eSAndrey Utkin * 3 44.1kHz setting 180534d1324eSAndrey Utkin * 4 48kHz setting 180634d1324eSAndrey Utkin */ 180734d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E3_AFMD 0x07 180834d1324eSAndrey Utkin 180934d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4 0x0e4 181034d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_AIN_0x0ED */ 181134d1324eSAndrey Utkin /* 181234d1324eSAndrey Utkin * 8bit I2S Record output mode. 181334d1324eSAndrey Utkin * 0 L/R half length separated output (Default). 181434d1324eSAndrey Utkin * 1 One continuous packed output equal to DSP output format. 181534d1324eSAndrey Utkin */ 181634d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_I2S8MODE BIT(7) 181734d1324eSAndrey Utkin /* 181834d1324eSAndrey Utkin * Audio Clock Master ACLKR output wave format. 181934d1324eSAndrey Utkin * 0 High periods is one 27MHz clock period (default). 182034d1324eSAndrey Utkin * 1 Almost duty 50-50% clock output on ACLKR pin. If this mode is selected, two 182134d1324eSAndrey Utkin * times bigger number value need to be set up on the ACKI register. If 182234d1324eSAndrey Utkin * AFAUTO=1, ACKI control is automatically set up even if MASCKMD=1. 182334d1324eSAndrey Utkin */ 182434d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_MASCKMD BIT(6) 182534d1324eSAndrey Utkin /* Playback ACLKP/ASYNP/ADATP input data MSB-LSB swapping */ 182634d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_PBINSWAP BIT(5) 182734d1324eSAndrey Utkin /* 182834d1324eSAndrey Utkin * ASYNR input signal delay. 182934d1324eSAndrey Utkin * 0 No delay 183034d1324eSAndrey Utkin * 1 Add one 27MHz period delay in ASYNR signal input 183134d1324eSAndrey Utkin */ 183234d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_ASYNRDLY BIT(4) 183334d1324eSAndrey Utkin /* 183434d1324eSAndrey Utkin * ASYNP input signal delay. 183534d1324eSAndrey Utkin * 0 no delay 183634d1324eSAndrey Utkin * 1 add one 27MHz period delay in ASYNP signal input 183734d1324eSAndrey Utkin */ 183834d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_ASYNPDLY BIT(3) 183934d1324eSAndrey Utkin /* 184034d1324eSAndrey Utkin * ADATP input data delay by one ACLKP clock. 184134d1324eSAndrey Utkin * 0 No delay (Default). This is for I2S type 1T delay input interface. 184234d1324eSAndrey Utkin * 1 Add 1 ACLKP clock delay in ADATP input data. This is for left-justified 184334d1324eSAndrey Utkin * type 0T delay input interface. 184434d1324eSAndrey Utkin */ 184534d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_ADATPDLY BIT(2) 184634d1324eSAndrey Utkin /* 184734d1324eSAndrey Utkin * Select u-Law/A-Law/PCM/SB data input format on ADATP pin. 184834d1324eSAndrey Utkin * 0 PCM input (Default) 184934d1324eSAndrey Utkin * 1 SB (Signed MSB bit in PCM data is inverted) input 185034d1324eSAndrey Utkin * 2 u-Law input 185134d1324eSAndrey Utkin * 3 A-Law input 185234d1324eSAndrey Utkin */ 185334d1324eSAndrey Utkin #define TW5864_INDIR_AIN_0x0E4_INLAWMD 0x03 185434d1324eSAndrey Utkin 185534d1324eSAndrey Utkin /* 185634d1324eSAndrey Utkin * Enable state register updating and interrupt request of audio AIN5 detection 185734d1324eSAndrey Utkin * for each input 185834d1324eSAndrey Utkin */ 185934d1324eSAndrey Utkin #define TW5864_INDIR_AIN_A5DETENA 0x0e5 186034d1324eSAndrey Utkin 186134d1324eSAndrey Utkin /* Some registers skipped */ 186234d1324eSAndrey Utkin 186334d1324eSAndrey Utkin /* 186434d1324eSAndrey Utkin * [7:3]: DEV_ID The TW5864 product ID code is 01000 186534d1324eSAndrey Utkin * [2:0]: REV_ID The revision number is 0h 186634d1324eSAndrey Utkin */ 186734d1324eSAndrey Utkin #define TW5864_INDIR_ID 0x0fe 186834d1324eSAndrey Utkin 186934d1324eSAndrey Utkin #define TW5864_INDIR_IN_PIC_WIDTH(channel) (0x200 + 4 * channel) 187034d1324eSAndrey Utkin #define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel) 187134d1324eSAndrey Utkin #define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel) 187234d1324eSAndrey Utkin #define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel) 18736dfcd296SAndrey Utkin 18746dfcd296SAndrey Utkin /* Some registers skipped */ 18756dfcd296SAndrey Utkin 18766dfcd296SAndrey Utkin #define TW5864_INDIR_CROP_ETC 0x260 18776dfcd296SAndrey Utkin /* Define controls in register TW5864_INDIR_CROP_ETC */ 18786dfcd296SAndrey Utkin /* Enable cropping from 720 to 704 */ 18796dfcd296SAndrey Utkin #define TW5864_INDIR_CROP_ETC_CROP_EN 0x4 18806dfcd296SAndrey Utkin 188134d1324eSAndrey Utkin /* 188234d1324eSAndrey Utkin * Interrupt status register from the front-end. Write "1" to each bit to clear 188334d1324eSAndrey Utkin * the interrupt 188434d1324eSAndrey Utkin * 15:0 Motion detection interrupt for channel 0 ~ 15 188534d1324eSAndrey Utkin * 31:16 Night detection interrupt for channel 0 ~ 15 188634d1324eSAndrey Utkin * 47:32 Blind detection interrupt for channel 0 ~ 15 188734d1324eSAndrey Utkin * 63:48 No video interrupt for channel 0 ~ 15 188834d1324eSAndrey Utkin * 79:64 Line mode underflow interrupt for channel 0 ~ 15 188934d1324eSAndrey Utkin * 95:80 Line mode overflow interrupt for channel 0 ~ 15 189034d1324eSAndrey Utkin */ 189134d1324eSAndrey Utkin /* 0x2d0~0x2d7: [63:0] bits */ 189234d1324eSAndrey Utkin #define TW5864_INDIR_INTERRUPT1 0x2d0 189334d1324eSAndrey Utkin /* 0x2e0~0x2e3: [95:64] bits */ 189434d1324eSAndrey Utkin #define TW5864_INDIR_INTERRUPT2 0x2e0 189534d1324eSAndrey Utkin 189634d1324eSAndrey Utkin /* 189734d1324eSAndrey Utkin * Interrupt mask register for interrupts in 0x2d0 ~ 0x2d7 189834d1324eSAndrey Utkin * 15:0 Motion detection interrupt for channel 0 ~ 15 189934d1324eSAndrey Utkin * 31:16 Night detection interrupt for channel 0 ~ 15 190034d1324eSAndrey Utkin * 47:32 Blind detection interrupt for channel 0 ~ 15 190134d1324eSAndrey Utkin * 63:48 No video interrupt for channel 0 ~ 15 190234d1324eSAndrey Utkin * 79:64 Line mode underflow interrupt for channel 0 ~ 15 190334d1324eSAndrey Utkin * 95:80 Line mode overflow interrupt for channel 0 ~ 15 190434d1324eSAndrey Utkin */ 190534d1324eSAndrey Utkin /* 0x2d8~0x2df: [63:0] bits */ 190634d1324eSAndrey Utkin #define TW5864_INDIR_INTERRUPT_MASK1 0x2d8 190734d1324eSAndrey Utkin /* 0x2e8~0x2eb: [95:64] bits */ 190834d1324eSAndrey Utkin #define TW5864_INDIR_INTERRUPT_MASK2 0x2e8 190934d1324eSAndrey Utkin 191034d1324eSAndrey Utkin /* [11:0]: Interrupt summary register for interrupts & interrupt mask from in 191134d1324eSAndrey Utkin * 0x2d0 ~ 0x2d7 and 0x2d8 ~ 0x2df 191234d1324eSAndrey Utkin * bit 0: interrupt occurs in 0x2d0 & 0x2d8 191334d1324eSAndrey Utkin * bit 1: interrupt occurs in 0x2d1 & 0x2d9 191434d1324eSAndrey Utkin * bit 2: interrupt occurs in 0x2d2 & 0x2da 191534d1324eSAndrey Utkin * bit 3: interrupt occurs in 0x2d3 & 0x2db 191634d1324eSAndrey Utkin * bit 4: interrupt occurs in 0x2d4 & 0x2dc 191734d1324eSAndrey Utkin * bit 5: interrupt occurs in 0x2d5 & 0x2dd 191834d1324eSAndrey Utkin * bit 6: interrupt occurs in 0x2d6 & 0x2de 191934d1324eSAndrey Utkin * bit 7: interrupt occurs in 0x2d7 & 0x2df 192034d1324eSAndrey Utkin * bit 8: interrupt occurs in 0x2e0 & 0x2e8 192134d1324eSAndrey Utkin * bit 9: interrupt occurs in 0x2e1 & 0x2e9 192234d1324eSAndrey Utkin * bit 10: interrupt occurs in 0x2e2 & 0x2ea 192334d1324eSAndrey Utkin * bit 11: interrupt occurs in 0x2e3 & 0x2eb 192434d1324eSAndrey Utkin */ 192534d1324eSAndrey Utkin #define TW5864_INDIR_INTERRUPT_SUMMARY 0x2f0 192634d1324eSAndrey Utkin 192734d1324eSAndrey Utkin /* Motion / Blind / Night Detection */ 192834d1324eSAndrey Utkin /* valid value for channel is [0:15] */ 192934d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL0(channel) (0x300 + channel * 0x08) 193034d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_DETECTION_CTL0 */ 193134d1324eSAndrey Utkin /* 193234d1324eSAndrey Utkin * Disable the motion and blind detection. 193334d1324eSAndrey Utkin * 0 Enable motion and blind detection (default) 193434d1324eSAndrey Utkin * 1 Disable motion and blind detection 193534d1324eSAndrey Utkin */ 193634d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL0_MD_DIS BIT(5) 193734d1324eSAndrey Utkin /* 193834d1324eSAndrey Utkin * Request to start motion detection on manual trigger mode 193934d1324eSAndrey Utkin * 0 None Operation (default) 194034d1324eSAndrey Utkin * 1 Request to start motion detection 194134d1324eSAndrey Utkin */ 194234d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL0_MD_STRB BIT(3) 194334d1324eSAndrey Utkin /* 194434d1324eSAndrey Utkin * Select the trigger mode of motion detection 194534d1324eSAndrey Utkin * 0 Automatic trigger mode of motion detection (default) 194634d1324eSAndrey Utkin * 1 Manual trigger mode for motion detection 194734d1324eSAndrey Utkin */ 194834d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL0_MD_STRB_EN BIT(2) 194934d1324eSAndrey Utkin /* 195034d1324eSAndrey Utkin * Define the threshold of cell for blind detection. 195134d1324eSAndrey Utkin * 0 Low threshold (More sensitive) (default) 195234d1324eSAndrey Utkin * : : 195334d1324eSAndrey Utkin * 3 High threshold (Less sensitive) 195434d1324eSAndrey Utkin */ 195534d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL0_BD_CELSENS 0x03 195634d1324eSAndrey Utkin 195734d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL1(channel) (0x301 + channel * 0x08) 195834d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_DETECTION_CTL1 */ 195934d1324eSAndrey Utkin /* 196034d1324eSAndrey Utkin * Control the temporal sensitivity of motion detector. 196134d1324eSAndrey Utkin * 0 More Sensitive (default) 196234d1324eSAndrey Utkin * : : 196334d1324eSAndrey Utkin * 15 Less Sensitive 196434d1324eSAndrey Utkin */ 196534d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS_SHIFT 4 196634d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS (0x0f << 4) 196734d1324eSAndrey Utkin /* 196834d1324eSAndrey Utkin * Adjust the horizontal starting position for motion detection 196934d1324eSAndrey Utkin * 0 0 pixel (default) 197034d1324eSAndrey Utkin * : : 197134d1324eSAndrey Utkin * 15 15 pixels 197234d1324eSAndrey Utkin */ 197334d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL1_MD_PIXEL_OS 0x0f 197434d1324eSAndrey Utkin 197534d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL2(channel) (0x302 + channel * 0x08) 197634d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_DETECTION_CTL2 */ 197734d1324eSAndrey Utkin /* 197834d1324eSAndrey Utkin * Control the updating time of reference field for motion detection. 197934d1324eSAndrey Utkin * 0 Update reference field every field (default) 198034d1324eSAndrey Utkin * 1 Update reference field according to MD_SPEED 198134d1324eSAndrey Utkin */ 198234d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL2_MD_REFFLD BIT(7) 198334d1324eSAndrey Utkin /* 198434d1324eSAndrey Utkin * Select the field for motion detection. 198534d1324eSAndrey Utkin * 0 Detecting motion for only odd field (default) 198634d1324eSAndrey Utkin * 1 Detecting motion for only even field 198734d1324eSAndrey Utkin * 2 Detecting motion for any field 198834d1324eSAndrey Utkin * 3 Detecting motion for both odd and even field 198934d1324eSAndrey Utkin */ 199034d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL2_MD_FIELD_SHIFT 5 199134d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL2_MD_FIELD (0x03 << 5) 199234d1324eSAndrey Utkin /* 199334d1324eSAndrey Utkin * Control the level sensitivity of motion detector. 199434d1324eSAndrey Utkin * 0 More sensitive (default) 199534d1324eSAndrey Utkin * : : 199634d1324eSAndrey Utkin * 15 Less sensitive 199734d1324eSAndrey Utkin */ 199834d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL2_MD_LVSENS 0x1f 199934d1324eSAndrey Utkin 200034d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL3(channel) (0x303 + channel * 0x08) 200134d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_DETECTION_CTL3 */ 200234d1324eSAndrey Utkin /* 200334d1324eSAndrey Utkin * Define the threshold of sub-cell number for motion detection. 200434d1324eSAndrey Utkin * 0 Motion is detected if 1 sub-cell has motion (More sensitive) (default) 200534d1324eSAndrey Utkin * 1 Motion is detected if 2 sub-cells have motion 200634d1324eSAndrey Utkin * 2 Motion is detected if 3 sub-cells have motion 200734d1324eSAndrey Utkin * 3 Motion is detected if 4 sub-cells have motion (Less sensitive) 200834d1324eSAndrey Utkin */ 200934d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS_SHIFT 6 201034d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS (0x03 << 6) 201134d1324eSAndrey Utkin /* 201234d1324eSAndrey Utkin * Control the velocity of motion detector. 201334d1324eSAndrey Utkin * Large value is suitable for slow motion detection. 201434d1324eSAndrey Utkin * In MD_DUAL_EN = 1, MD_SPEED should be limited to 0 ~ 31. 201534d1324eSAndrey Utkin * 0 1 field intervals (default) 201634d1324eSAndrey Utkin * 1 2 field intervals 201734d1324eSAndrey Utkin * : : 201834d1324eSAndrey Utkin * 61 62 field intervals 201934d1324eSAndrey Utkin * 62 63 field intervals 202034d1324eSAndrey Utkin * 63 Not supported 202134d1324eSAndrey Utkin */ 202234d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL3_MD_SPEED 0x3f 202334d1324eSAndrey Utkin 202434d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL4(channel) (0x304 + channel * 0x08) 202534d1324eSAndrey Utkin /* Define controls in register TW5864_INDIR_DETECTION_CTL4 */ 202634d1324eSAndrey Utkin /* 202734d1324eSAndrey Utkin * Control the spatial sensitivity of motion detector. 202834d1324eSAndrey Utkin * 0 More Sensitive (default) 202934d1324eSAndrey Utkin * : : 203034d1324eSAndrey Utkin * 15 Less Sensitive 203134d1324eSAndrey Utkin */ 203234d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS_SHIFT 4 203334d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS (0x0f << 4) 203434d1324eSAndrey Utkin /* 203534d1324eSAndrey Utkin * Define the threshold of level for blind detection. 203634d1324eSAndrey Utkin * 0 Low threshold (More sensitive) (default) 203734d1324eSAndrey Utkin * : : 203834d1324eSAndrey Utkin * 15 High threshold (Less sensitive) 203934d1324eSAndrey Utkin */ 204034d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL4_BD_LVSENS 0x0f 204134d1324eSAndrey Utkin 204234d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL5(channel) (0x305 + channel * 0x08) 204334d1324eSAndrey Utkin /* 204434d1324eSAndrey Utkin * Define the threshold of temporal sensitivity for night detection. 204534d1324eSAndrey Utkin * 0 Low threshold (More sensitive) (default) 204634d1324eSAndrey Utkin * : : 204734d1324eSAndrey Utkin * 15 High threshold (Less sensitive) 204834d1324eSAndrey Utkin */ 204934d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS_SHIFT 4 205034d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS (0x0f << 4) 205134d1324eSAndrey Utkin /* 205234d1324eSAndrey Utkin * Define the threshold of level for night detection. 205334d1324eSAndrey Utkin * 0 Low threshold (More sensitive) (default) 205434d1324eSAndrey Utkin * : : 205534d1324eSAndrey Utkin * 3 High threshold (Less sensitive) 205634d1324eSAndrey Utkin */ 205734d1324eSAndrey Utkin #define TW5864_INDIR_DETECTION_CTL5_ND_LVSENS 0x0f 205834d1324eSAndrey Utkin 205934d1324eSAndrey Utkin /* 206034d1324eSAndrey Utkin * [11:0] The base address of the motion detection buffer. This address is in 206134d1324eSAndrey Utkin * unit of 64K bytes. The generated DDR address will be {MD_BASE_ADDR, 206234d1324eSAndrey Utkin * 16"h0000}. The default value should be 12"h000 206334d1324eSAndrey Utkin */ 206434d1324eSAndrey Utkin #define TW5864_INDIR_MD_BASE_ADDR 0x380 206534d1324eSAndrey Utkin 206634d1324eSAndrey Utkin /* 206734d1324eSAndrey Utkin * This controls the channel of the motion detection result shown in register 206834d1324eSAndrey Utkin * 0x3a0 ~ 0x3b7. Before reading back motion result, always set this first. 206934d1324eSAndrey Utkin */ 207034d1324eSAndrey Utkin #define TW5864_INDIR_RGR_MOTION_SEL 0x382 207134d1324eSAndrey Utkin 207234d1324eSAndrey Utkin /* [15:0] MD strobe has been performed at channel n (read only) */ 207334d1324eSAndrey Utkin #define TW5864_INDIR_MD_STRB 0x386 207434d1324eSAndrey Utkin /* NO_VIDEO Detected from channel n (read only) */ 207534d1324eSAndrey Utkin #define TW5864_INDIR_NOVID_DET 0x388 207634d1324eSAndrey Utkin /* Motion Detected from channel n (read only) */ 207734d1324eSAndrey Utkin #define TW5864_INDIR_MD_DET 0x38a 207834d1324eSAndrey Utkin /* Blind Detected from channel n (read only) */ 207934d1324eSAndrey Utkin #define TW5864_INDIR_BD_DET 0x38c 208034d1324eSAndrey Utkin /* Night Detected from channel n (read only) */ 208134d1324eSAndrey Utkin #define TW5864_INDIR_ND_DET 0x38e 208234d1324eSAndrey Utkin 208334d1324eSAndrey Utkin /* 192 bit motion flag of the channel specified by RGR_MOTION_SEL in 0x382 */ 208434d1324eSAndrey Utkin #define TW5864_INDIR_MOTION_FLAG 0x3a0 208534d1324eSAndrey Utkin #define TW5864_INDIR_MOTION_FLAG_BYTE_COUNT 24 208634d1324eSAndrey Utkin 208734d1324eSAndrey Utkin /* 208834d1324eSAndrey Utkin * [9:0] The motion cell count of a specific channel selected by 0x382. This is 208934d1324eSAndrey Utkin * for DI purpose 209034d1324eSAndrey Utkin */ 209134d1324eSAndrey Utkin #define TW5864_INDIR_MD_DI_CNT 0x3b8 209234d1324eSAndrey Utkin /* The motion detection cell sensitivity for DI purpose */ 209334d1324eSAndrey Utkin #define TW5864_INDIR_MD_DI_CELLSENS 0x3ba 209434d1324eSAndrey Utkin /* The motion detection threshold level for DI purpose */ 209534d1324eSAndrey Utkin #define TW5864_INDIR_MD_DI_LVSENS 0x3bb 209634d1324eSAndrey Utkin 209734d1324eSAndrey Utkin /* 192 bit motion mask of the channel specified by MASK_CH_SEL in 0x3fe */ 209834d1324eSAndrey Utkin #define TW5864_INDIR_MOTION_MASK 0x3e0 209934d1324eSAndrey Utkin #define TW5864_INDIR_MOTION_MASK_BYTE_COUNT 24 210034d1324eSAndrey Utkin 210134d1324eSAndrey Utkin /* [4:0] The channel selection to access masks in 0x3e0 ~ 0x3f7 */ 210234d1324eSAndrey Utkin #define TW5864_INDIR_MASK_CH_SEL 0x3fe 210334d1324eSAndrey Utkin 210434d1324eSAndrey Utkin /* Clock PLL / Analog IP Control */ 210534d1324eSAndrey Utkin /* Some registers skipped */ 210634d1324eSAndrey Utkin 210734d1324eSAndrey Utkin #define TW5864_INDIR_DDRA_DLL_DQS_SEL0 0xee6 210834d1324eSAndrey Utkin #define TW5864_INDIR_DDRA_DLL_DQS_SEL1 0xee7 210934d1324eSAndrey Utkin #define TW5864_INDIR_DDRA_DLL_CLK90_SEL 0xee8 211034d1324eSAndrey Utkin #define TW5864_INDIR_DDRA_DLL_TEST_SEL_AND_TAP_S 0xee9 211134d1324eSAndrey Utkin 211234d1324eSAndrey Utkin #define TW5864_INDIR_DDRB_DLL_DQS_SEL0 0xeeb 211334d1324eSAndrey Utkin #define TW5864_INDIR_DDRB_DLL_DQS_SEL1 0xeec 211434d1324eSAndrey Utkin #define TW5864_INDIR_DDRB_DLL_CLK90_SEL 0xeed 211534d1324eSAndrey Utkin #define TW5864_INDIR_DDRB_DLL_TEST_SEL_AND_TAP_S 0xeee 211634d1324eSAndrey Utkin 211734d1324eSAndrey Utkin #define TW5864_INDIR_RESET 0xef0 211834d1324eSAndrey Utkin #define TW5864_INDIR_RESET_VD BIT(7) 211934d1324eSAndrey Utkin #define TW5864_INDIR_RESET_DLL BIT(6) 212034d1324eSAndrey Utkin #define TW5864_INDIR_RESET_MUX_CORE BIT(5) 212134d1324eSAndrey Utkin 212234d1324eSAndrey Utkin #define TW5864_INDIR_PV_VD_CK_POL 0xefd 212334d1324eSAndrey Utkin #define TW5864_INDIR_PV_VD_CK_POL_PV(channel) BIT(channel) 212434d1324eSAndrey Utkin #define TW5864_INDIR_PV_VD_CK_POL_VD(channel) BIT(channel + 4) 212534d1324eSAndrey Utkin 212634d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL 0xefe 212734d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_VD_SHIFT 0 212834d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_VD_MASK 0x3 212934d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_PV_SHIFT 2 213034d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_PV_MASK (0x3 << 2) 213134d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_PV2_SHIFT 4 213234d1324eSAndrey Utkin #define TW5864_INDIR_CLK0_SEL_PV2_MASK (0x3 << 4) 2133