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