blob: c791275e307b05ea3c5de61259f2f3e535070707 [file] [log] [blame]
Javier Martin186b2502012-07-26 05:53:35 -03001/*
Mauro Carvalho Chehab2c3fb082012-08-14 17:31:16 -03002 * linux/drivers/media/platform/coda/coda_regs.h
Javier Martin186b2502012-07-26 05:53:35 -03003 *
4 * Copyright (C) 2012 Vista Silicon SL
5 * Javier Martin <javier.martin@vista-silicon.com>
6 * Xavier Duret
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#ifndef _REGS_CODA_H_
15#define _REGS_CODA_H_
16
17/* HW registers */
18#define CODA_REG_BIT_CODE_RUN 0x000
19#define CODA_REG_RUN_ENABLE (1 << 0)
20#define CODA_REG_BIT_CODE_DOWN 0x004
21#define CODA_DOWN_ADDRESS_SET(x) (((x) & 0xffff) << 16)
22#define CODA_DOWN_DATA_SET(x) ((x) & 0xffff)
23#define CODA_REG_BIT_HOST_IN_REQ 0x008
24#define CODA_REG_BIT_INT_CLEAR 0x00c
25#define CODA_REG_BIT_INT_CLEAR_SET 0x1
26#define CODA_REG_BIT_INT_STATUS 0x010
27#define CODA_REG_BIT_CODE_RESET 0x014
28#define CODA_REG_RESET_ENABLE (1 << 0)
29#define CODA_REG_BIT_CUR_PC 0x018
Philipp Zabel89548442014-07-11 06:36:17 -030030#define CODA9_REG_BIT_SW_RESET 0x024
31#define CODA9_SW_RESET_BPU_CORE 0x008
32#define CODA9_SW_RESET_BPU_BUS 0x010
33#define CODA9_SW_RESET_VCE_CORE 0x020
34#define CODA9_SW_RESET_VCE_BUS 0x040
35#define CODA9_SW_RESET_GDI_CORE 0x080
36#define CODA9_SW_RESET_GDI_BUS 0x100
37#define CODA9_REG_BIT_SW_RESET_STATUS 0x034
Javier Martin186b2502012-07-26 05:53:35 -030038
39/* Static SW registers */
40#define CODA_REG_BIT_CODE_BUF_ADDR 0x100
41#define CODA_REG_BIT_WORK_BUF_ADDR 0x104
42#define CODA_REG_BIT_PARA_BUF_ADDR 0x108
43#define CODA_REG_BIT_STREAM_CTRL 0x10c
44#define CODA7_STREAM_BUF_PIC_RESET (1 << 4)
45#define CODADX6_STREAM_BUF_PIC_RESET (1 << 3)
46#define CODA7_STREAM_BUF_PIC_FLUSH (1 << 3)
47#define CODADX6_STREAM_BUF_PIC_FLUSH (1 << 2)
48#define CODA7_STREAM_BUF_DYNALLOC_EN (1 << 5)
49#define CODADX6_STREAM_BUF_DYNALLOC_EN (1 << 4)
Philipp Zabel89548442014-07-11 06:36:17 -030050#define CODADX6_STREAM_CHKDIS_OFFSET (1 << 1)
51#define CODA7_STREAM_SEL_64BITS_ENDIAN (1 << 1)
Javier Martin186b2502012-07-26 05:53:35 -030052#define CODA_STREAM_ENDIAN_SELECT (1 << 0)
53#define CODA_REG_BIT_FRAME_MEM_CTRL 0x110
Philipp Zabel89548442014-07-11 06:36:17 -030054#define CODA_FRAME_CHROMA_INTERLEAVE (1 << 2)
Javier Martin186b2502012-07-26 05:53:35 -030055#define CODA_IMAGE_ENDIAN_SELECT (1 << 0)
Philipp Zabel9082a7c2013-06-21 03:55:31 -030056#define CODA_REG_BIT_BIT_STREAM_PARAM 0x114
57#define CODA_BIT_STREAM_END_FLAG (1 << 2)
58#define CODA_BIT_DEC_SEQ_INIT_ESCAPE (1 << 0)
Philipp Zabel5677e3b2013-06-21 03:55:30 -030059#define CODA_REG_BIT_TEMP_BUF_ADDR 0x118
Javier Martin186b2502012-07-26 05:53:35 -030060#define CODA_REG_BIT_RD_PTR(x) (0x120 + 8 * (x))
61#define CODA_REG_BIT_WR_PTR(x) (0x124 + 8 * (x))
Philipp Zabel918c66f2013-06-27 06:59:01 -030062#define CODA_REG_BIT_FRM_DIS_FLG(x) (0x150 + 4 * (x))
Philipp Zabel10436672012-07-02 09:03:55 -030063#define CODADX6_REG_BIT_SEARCH_RAM_BASE_ADDR 0x140
64#define CODA7_REG_BIT_AXI_SRAM_USE 0x140
Philipp Zabel89548442014-07-11 06:36:17 -030065#define CODA9_USE_HOST_BTP_ENABLE (1 << 13)
66#define CODA9_USE_HOST_OVL_ENABLE (1 << 12)
Philipp Zabelc2d22512013-06-21 03:55:28 -030067#define CODA7_USE_HOST_ME_ENABLE (1 << 11)
Philipp Zabel89548442014-07-11 06:36:17 -030068#define CODA9_USE_HOST_DBK_ENABLE (3 << 10)
Philipp Zabelc2d22512013-06-21 03:55:28 -030069#define CODA7_USE_HOST_OVL_ENABLE (1 << 10)
70#define CODA7_USE_HOST_DBK_ENABLE (1 << 9)
Philipp Zabel89548442014-07-11 06:36:17 -030071#define CODA9_USE_HOST_IP_ENABLE (1 << 9)
Philipp Zabelc2d22512013-06-21 03:55:28 -030072#define CODA7_USE_HOST_IP_ENABLE (1 << 8)
Philipp Zabel89548442014-07-11 06:36:17 -030073#define CODA9_USE_HOST_BIT_ENABLE (1 << 8)
Philipp Zabel10436672012-07-02 09:03:55 -030074#define CODA7_USE_HOST_BIT_ENABLE (1 << 7)
Philipp Zabel89548442014-07-11 06:36:17 -030075#define CODA9_USE_BTP_ENABLE (1 << 5)
Philipp Zabel10436672012-07-02 09:03:55 -030076#define CODA7_USE_ME_ENABLE (1 << 4)
Philipp Zabel89548442014-07-11 06:36:17 -030077#define CODA9_USE_OVL_ENABLE (1 << 4)
Philipp Zabelc2d22512013-06-21 03:55:28 -030078#define CODA7_USE_OVL_ENABLE (1 << 3)
Philipp Zabel89548442014-07-11 06:36:17 -030079#define CODA9_USE_DBK_ENABLE (3 << 2)
Philipp Zabelc2d22512013-06-21 03:55:28 -030080#define CODA7_USE_DBK_ENABLE (1 << 2)
81#define CODA7_USE_IP_ENABLE (1 << 1)
82#define CODA7_USE_BIT_ENABLE (1 << 0)
83
Javier Martin186b2502012-07-26 05:53:35 -030084#define CODA_REG_BIT_BUSY 0x160
85#define CODA_REG_BIT_BUSY_FLAG 1
86#define CODA_REG_BIT_RUN_COMMAND 0x164
87#define CODA_COMMAND_SEQ_INIT 1
88#define CODA_COMMAND_SEQ_END 2
89#define CODA_COMMAND_PIC_RUN 3
90#define CODA_COMMAND_SET_FRAME_BUF 4
91#define CODA_COMMAND_ENCODE_HEADER 5
92#define CODA_COMMAND_ENC_PARA_SET 6
93#define CODA_COMMAND_DEC_PARA_SET 7
94#define CODA_COMMAND_DEC_BUF_FLUSH 8
95#define CODA_COMMAND_RC_CHANGE_PARAMETER 9
96#define CODA_COMMAND_FIRMWARE_GET 0xf
97#define CODA_REG_BIT_RUN_INDEX 0x168
98#define CODA_INDEX_SET(x) ((x) & 0x3)
99#define CODA_REG_BIT_RUN_COD_STD 0x16c
100#define CODADX6_MODE_DECODE_MP4 0
101#define CODADX6_MODE_ENCODE_MP4 1
102#define CODADX6_MODE_DECODE_H264 2
103#define CODADX6_MODE_ENCODE_H264 3
104#define CODA7_MODE_DECODE_H264 0
105#define CODA7_MODE_DECODE_VC1 1
106#define CODA7_MODE_DECODE_MP2 2
107#define CODA7_MODE_DECODE_MP4 3
108#define CODA7_MODE_DECODE_DV3 3
109#define CODA7_MODE_DECODE_RV 4
110#define CODA7_MODE_DECODE_MJPG 5
111#define CODA7_MODE_ENCODE_H264 8
112#define CODA7_MODE_ENCODE_MP4 11
113#define CODA7_MODE_ENCODE_MJPG 13
Philipp Zabel89548442014-07-11 06:36:17 -0300114#define CODA9_MODE_DECODE_H264 0
115#define CODA9_MODE_DECODE_VC1 1
116#define CODA9_MODE_DECODE_MP2 2
117#define CODA9_MODE_DECODE_MP4 3
118#define CODA9_MODE_DECODE_DV3 3
119#define CODA9_MODE_DECODE_RV 4
120#define CODA9_MODE_DECODE_AVS 5
121#define CODA9_MODE_DECODE_MJPG 6
122#define CODA9_MODE_DECODE_VPX 7
123#define CODA9_MODE_ENCODE_H264 8
124#define CODA9_MODE_ENCODE_MP4 11
125#define CODA9_MODE_ENCODE_MJPG 13
Javier Martin186b2502012-07-26 05:53:35 -0300126#define CODA_MODE_INVALID 0xffff
127#define CODA_REG_BIT_INT_ENABLE 0x170
128#define CODA_INT_INTERRUPT_ENABLE (1 << 3)
Philipp Zabel918c66f2013-06-27 06:59:01 -0300129#define CODA_REG_BIT_INT_REASON 0x174
Philipp Zabel5677e3b2013-06-21 03:55:30 -0300130#define CODA7_REG_BIT_RUN_AUX_STD 0x178
131#define CODA_MP4_AUX_MPEG4 0
132#define CODA_MP4_AUX_DIVX3 1
133#define CODA_VPX_AUX_THO 0
134#define CODA_VPX_AUX_VP6 1
135#define CODA_VPX_AUX_VP8 2
136#define CODA_H264_AUX_AVC 0
137#define CODA_H264_AUX_MVC 1
Javier Martin186b2502012-07-26 05:53:35 -0300138
139/*
140 * Commands' mailbox:
141 * registers with offsets in the range 0x180-0x1d0
142 * have different meaning depending on the command being
143 * issued.
144 */
145
Philipp Zabel918c66f2013-06-27 06:59:01 -0300146/* Decoder Sequence Initialization */
147#define CODA_CMD_DEC_SEQ_BB_START 0x180
148#define CODA_CMD_DEC_SEQ_BB_SIZE 0x184
149#define CODA_CMD_DEC_SEQ_OPTION 0x188
150#define CODA_REORDER_ENABLE (1 << 1)
151#define CODADX6_QP_REPORT (1 << 0)
152#define CODA7_MP4_DEBLK_ENABLE (1 << 0)
153#define CODA_CMD_DEC_SEQ_SRC_SIZE 0x18c
154#define CODA_CMD_DEC_SEQ_START_BYTE 0x190
155#define CODA_CMD_DEC_SEQ_PS_BB_START 0x194
156#define CODA_CMD_DEC_SEQ_PS_BB_SIZE 0x198
157#define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS 0x19c
158#define CODA_CMD_DEC_SEQ_X264_MV_EN 0x19c
159#define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE 0x1a0
160
161#define CODA7_RET_DEC_SEQ_ASPECT 0x1b0
Philipp Zabel89548442014-07-11 06:36:17 -0300162#define CODA9_RET_DEC_SEQ_BITRATE 0x1b4
Philipp Zabel918c66f2013-06-27 06:59:01 -0300163#define CODA_RET_DEC_SEQ_SUCCESS 0x1c0
164#define CODA_RET_DEC_SEQ_SRC_FMT 0x1c4 /* SRC_SIZE on CODA7 */
165#define CODA_RET_DEC_SEQ_SRC_SIZE 0x1c4
166#define CODA_RET_DEC_SEQ_SRC_F_RATE 0x1c8
167#define CODA9_RET_DEC_SEQ_ASPECT 0x1c8
168#define CODA_RET_DEC_SEQ_FRAME_NEED 0x1cc
169#define CODA_RET_DEC_SEQ_FRAME_DELAY 0x1d0
170#define CODA_RET_DEC_SEQ_INFO 0x1d4
171#define CODA_RET_DEC_SEQ_CROP_LEFT_RIGHT 0x1d8
172#define CODA_RET_DEC_SEQ_CROP_TOP_BOTTOM 0x1dc
173#define CODA_RET_DEC_SEQ_NEXT_FRAME_NUM 0x1e0
174#define CODA_RET_DEC_SEQ_ERR_REASON 0x1e0
175#define CODA_RET_DEC_SEQ_FRATE_NR 0x1e4
176#define CODA_RET_DEC_SEQ_FRATE_DR 0x1e8
177#define CODA_RET_DEC_SEQ_JPG_PARA 0x1e4
178#define CODA_RET_DEC_SEQ_JPG_THUMB_IND 0x1e8
Philipp Zabel89548442014-07-11 06:36:17 -0300179#define CODA9_RET_DEC_SEQ_HEADER_REPORT 0x1ec
Philipp Zabel918c66f2013-06-27 06:59:01 -0300180
181/* Decoder Picture Run */
182#define CODA_CMD_DEC_PIC_ROT_MODE 0x180
183#define CODA_CMD_DEC_PIC_ROT_ADDR_Y 0x184
Philipp Zabel89548442014-07-11 06:36:17 -0300184#define CODA9_CMD_DEC_PIC_ROT_INDEX 0x184
Philipp Zabel918c66f2013-06-27 06:59:01 -0300185#define CODA_CMD_DEC_PIC_ROT_ADDR_CB 0x188
Philipp Zabel89548442014-07-11 06:36:17 -0300186#define CODA9_CMD_DEC_PIC_ROT_ADDR_Y 0x188
Philipp Zabel918c66f2013-06-27 06:59:01 -0300187#define CODA_CMD_DEC_PIC_ROT_ADDR_CR 0x18c
Philipp Zabel89548442014-07-11 06:36:17 -0300188#define CODA9_CMD_DEC_PIC_ROT_ADDR_CB 0x18c
Philipp Zabel918c66f2013-06-27 06:59:01 -0300189#define CODA_CMD_DEC_PIC_ROT_STRIDE 0x190
Philipp Zabel89548442014-07-11 06:36:17 -0300190#define CODA9_CMD_DEC_PIC_ROT_ADDR_CR 0x190
191#define CODA9_CMD_DEC_PIC_ROT_STRIDE 0x1b8
Philipp Zabel918c66f2013-06-27 06:59:01 -0300192
193#define CODA_CMD_DEC_PIC_OPTION 0x194
194#define CODA_PRE_SCAN_EN (1 << 0)
195#define CODA_PRE_SCAN_MODE_DECODE (0 << 1)
196#define CODA_PRE_SCAN_MODE_RETURN (1 << 1)
197#define CODA_IFRAME_SEARCH_EN (1 << 2)
198#define CODA_SKIP_FRAME_MODE (0x3 << 3)
199#define CODA_CMD_DEC_PIC_SKIP_NUM 0x198
200#define CODA_CMD_DEC_PIC_CHUNK_SIZE 0x19c
201#define CODA_CMD_DEC_PIC_BB_START 0x1a0
202#define CODA_CMD_DEC_PIC_START_BYTE 0x1a4
203#define CODA_RET_DEC_PIC_SIZE 0x1bc
204#define CODA_RET_DEC_PIC_FRAME_NUM 0x1c0
205#define CODA_RET_DEC_PIC_FRAME_IDX 0x1c4
206#define CODA_RET_DEC_PIC_ERR_MB 0x1c8
207#define CODA_RET_DEC_PIC_TYPE 0x1cc
208#define CODA_PIC_TYPE_MASK 0x7
209#define CODA_PIC_TYPE_MASK_VC1 0x3f
210#define CODA9_PIC_TYPE_FIRST_MASK (0x7 << 3)
211#define CODA9_PIC_TYPE_IDR_MASK (0x3 << 6)
212#define CODA7_PIC_TYPE_H264_NPF_MASK (0x3 << 16)
213#define CODA7_PIC_TYPE_INTERLACED (1 << 18)
214#define CODA_RET_DEC_PIC_POST 0x1d0
215#define CODA_RET_DEC_PIC_MVC_REPORT 0x1d0
216#define CODA_RET_DEC_PIC_OPTION 0x1d4
217#define CODA_RET_DEC_PIC_SUCCESS 0x1d8
218#define CODA_RET_DEC_PIC_CUR_IDX 0x1dc
219#define CODA_RET_DEC_PIC_CROP_LEFT_RIGHT 0x1e0
220#define CODA_RET_DEC_PIC_CROP_TOP_BOTTOM 0x1e4
221#define CODA_RET_DEC_PIC_FRAME_NEED 0x1ec
222
Philipp Zabel89548442014-07-11 06:36:17 -0300223#define CODA9_RET_DEC_PIC_VP8_PIC_REPORT 0x1e8
224#define CODA9_RET_DEC_PIC_ASPECT 0x1f0
225#define CODA9_RET_DEC_PIC_VP8_SCALE_INFO 0x1f0
226#define CODA9_RET_DEC_PIC_FRATE_NR 0x1f4
227#define CODA9_RET_DEC_PIC_FRATE_DR 0x1f8
228
Javier Martin186b2502012-07-26 05:53:35 -0300229/* Encoder Sequence Initialization */
230#define CODA_CMD_ENC_SEQ_BB_START 0x180
231#define CODA_CMD_ENC_SEQ_BB_SIZE 0x184
232#define CODA_CMD_ENC_SEQ_OPTION 0x188
Philipp Zabel918c66f2013-06-27 06:59:01 -0300233#define CODA7_OPTION_AVCINTRA16X16ONLY_OFFSET 9
Philipp Zabel89548442014-07-11 06:36:17 -0300234#define CODA9_OPTION_MVC_PREFIX_NAL_OFFSET 9
Philipp Zabelfb1fcf12013-05-23 10:42:53 -0300235#define CODA7_OPTION_GAMMA_OFFSET 8
Philipp Zabel89548442014-07-11 06:36:17 -0300236#define CODA9_OPTION_MVC_PARASET_REFRESH_OFFSET 8
Philipp Zabel918c66f2013-06-27 06:59:01 -0300237#define CODA7_OPTION_RCQPMAX_OFFSET 7
Philipp Zabel89548442014-07-11 06:36:17 -0300238#define CODA9_OPTION_GAMMA_OFFSET 7
Philipp Zabelfb1fcf12013-05-23 10:42:53 -0300239#define CODADX6_OPTION_GAMMA_OFFSET 7
Philipp Zabel918c66f2013-06-27 06:59:01 -0300240#define CODA7_OPTION_RCQPMIN_OFFSET 6
Philipp Zabel89548442014-07-11 06:36:17 -0300241#define CODA9_OPTION_RCQPMAX_OFFSET 6
Javier Martin186b2502012-07-26 05:53:35 -0300242#define CODA_OPTION_LIMITQP_OFFSET 6
Javier Martin186b2502012-07-26 05:53:35 -0300243#define CODA_OPTION_RCINTRAQP_OFFSET 5
Javier Martin186b2502012-07-26 05:53:35 -0300244#define CODA_OPTION_FMO_OFFSET 4
Philipp Zabel89548442014-07-11 06:36:17 -0300245#define CODA9_OPTION_MVC_INTERVIEW_OFFSET 4
Philipp Zabel918c66f2013-06-27 06:59:01 -0300246#define CODA_OPTION_AVC_AUD_OFFSET 2
Javier Martin186b2502012-07-26 05:53:35 -0300247#define CODA_OPTION_SLICEREPORT_OFFSET 1
Javier Martin186b2502012-07-26 05:53:35 -0300248#define CODA_CMD_ENC_SEQ_COD_STD 0x18c
249#define CODA_STD_MPEG4 0
Philipp Zabel89548442014-07-11 06:36:17 -0300250#define CODA9_STD_H264 0
Javier Martin186b2502012-07-26 05:53:35 -0300251#define CODA_STD_H263 1
252#define CODA_STD_H264 2
253#define CODA_STD_MJPG 3
Philipp Zabel89548442014-07-11 06:36:17 -0300254#define CODA9_STD_MPEG4 3
255
Javier Martin186b2502012-07-26 05:53:35 -0300256#define CODA_CMD_ENC_SEQ_SRC_SIZE 0x190
257#define CODA7_PICWIDTH_OFFSET 16
258#define CODA7_PICWIDTH_MASK 0xffff
259#define CODADX6_PICWIDTH_OFFSET 10
260#define CODADX6_PICWIDTH_MASK 0x3ff
261#define CODA_PICHEIGHT_OFFSET 0
Philipp Zabelb96904e2013-05-23 10:42:58 -0300262#define CODADX6_PICHEIGHT_MASK 0x3ff
263#define CODA7_PICHEIGHT_MASK 0xffff
Javier Martin186b2502012-07-26 05:53:35 -0300264#define CODA_CMD_ENC_SEQ_SRC_F_RATE 0x194
265#define CODA_CMD_ENC_SEQ_MP4_PARA 0x198
266#define CODA_MP4PARAM_VERID_OFFSET 6
267#define CODA_MP4PARAM_VERID_MASK 0x01
268#define CODA_MP4PARAM_INTRADCVLCTHR_OFFSET 2
269#define CODA_MP4PARAM_INTRADCVLCTHR_MASK 0x07
270#define CODA_MP4PARAM_REVERSIBLEVLCENABLE_OFFSET 1
271#define CODA_MP4PARAM_REVERSIBLEVLCENABLE_MASK 0x01
272#define CODA_MP4PARAM_DATAPARTITIONENABLE_OFFSET 0
273#define CODA_MP4PARAM_DATAPARTITIONENABLE_MASK 0x01
274#define CODA_CMD_ENC_SEQ_263_PARA 0x19c
275#define CODA_263PARAM_ANNEXJENABLE_OFFSET 2
276#define CODA_263PARAM_ANNEXJENABLE_MASK 0x01
277#define CODA_263PARAM_ANNEXKENABLE_OFFSET 1
278#define CODA_263PARAM_ANNEXKENABLE_MASK 0x01
279#define CODA_263PARAM_ANNEXTENABLE_OFFSET 0
280#define CODA_263PARAM_ANNEXTENABLE_MASK 0x01
281#define CODA_CMD_ENC_SEQ_264_PARA 0x1a0
282#define CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET 12
283#define CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK 0x0f
284#define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET 8
285#define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK 0x0f
286#define CODA_264PARAM_DISABLEDEBLK_OFFSET 6
287#define CODA_264PARAM_DISABLEDEBLK_MASK 0x01
288#define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET 5
289#define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK 0x01
290#define CODA_264PARAM_CHROMAQPOFFSET_OFFSET 0
291#define CODA_264PARAM_CHROMAQPOFFSET_MASK 0x1f
292#define CODA_CMD_ENC_SEQ_SLICE_MODE 0x1a4
293#define CODA_SLICING_SIZE_OFFSET 2
294#define CODA_SLICING_SIZE_MASK 0x3fffffff
295#define CODA_SLICING_UNIT_OFFSET 1
296#define CODA_SLICING_UNIT_MASK 0x01
297#define CODA_SLICING_MODE_OFFSET 0
298#define CODA_SLICING_MODE_MASK 0x01
299#define CODA_CMD_ENC_SEQ_GOP_SIZE 0x1a8
300#define CODA_GOP_SIZE_OFFSET 0
301#define CODA_GOP_SIZE_MASK 0x3f
302#define CODA_CMD_ENC_SEQ_RC_PARA 0x1ac
303#define CODA_RATECONTROL_AUTOSKIP_OFFSET 31
304#define CODA_RATECONTROL_AUTOSKIP_MASK 0x01
305#define CODA_RATECONTROL_INITIALDELAY_OFFSET 16
306#define CODA_RATECONTROL_INITIALDELAY_MASK 0x7f
307#define CODA_RATECONTROL_BITRATE_OFFSET 1
308#define CODA_RATECONTROL_BITRATE_MASK 0x7f
309#define CODA_RATECONTROL_ENABLE_OFFSET 0
310#define CODA_RATECONTROL_ENABLE_MASK 0x01
311#define CODA_CMD_ENC_SEQ_RC_BUF_SIZE 0x1b0
312#define CODA_CMD_ENC_SEQ_INTRA_REFRESH 0x1b4
Philipp Zabel10436672012-07-02 09:03:55 -0300313#define CODADX6_CMD_ENC_SEQ_FMO 0x1b8
Javier Martin186b2502012-07-26 05:53:35 -0300314#define CODA_FMOPARAM_TYPE_OFFSET 4
315#define CODA_FMOPARAM_TYPE_MASK 1
316#define CODA_FMOPARAM_SLICENUM_OFFSET 0
317#define CODA_FMOPARAM_SLICENUM_MASK 0x0f
Philipp Zabel918c66f2013-06-27 06:59:01 -0300318#define CODADX6_CMD_ENC_SEQ_INTRA_QP 0x1bc
Philipp Zabel10436672012-07-02 09:03:55 -0300319#define CODA7_CMD_ENC_SEQ_SEARCH_BASE 0x1b8
320#define CODA7_CMD_ENC_SEQ_SEARCH_SIZE 0x1bc
Philipp Zabel918c66f2013-06-27 06:59:01 -0300321#define CODA7_CMD_ENC_SEQ_INTRA_QP 0x1c4
Philipp Zabel89548442014-07-11 06:36:17 -0300322#define CODA_CMD_ENC_SEQ_RC_QP_MIN_MAX 0x1c8
323#define CODA_QPMIN_OFFSET 8
324#define CODA_QPMIN_MASK 0x3f
Javier Martin186b2502012-07-26 05:53:35 -0300325#define CODA_QPMAX_OFFSET 0
326#define CODA_QPMAX_MASK 0x3f
327#define CODA_CMD_ENC_SEQ_RC_GAMMA 0x1cc
328#define CODA_GAMMA_OFFSET 0
329#define CODA_GAMMA_MASK 0xffff
Philipp Zabel89548442014-07-11 06:36:17 -0300330#define CODA_CMD_ENC_SEQ_RC_INTERVAL_MODE 0x1d0
331#define CODA9_CMD_ENC_SEQ_INTRA_WEIGHT 0x1d4
332#define CODA9_CMD_ENC_SEQ_ME_OPTION 0x1d8
Javier Martin186b2502012-07-26 05:53:35 -0300333#define CODA_RET_ENC_SEQ_SUCCESS 0x1c0
334
335/* Encoder Picture Run */
Philipp Zabel89548442014-07-11 06:36:17 -0300336#define CODA9_CMD_ENC_PIC_SRC_INDEX 0x180
337#define CODA9_CMD_ENC_PIC_SRC_STRIDE 0x184
338#define CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC 0x1a4
339#define CODA9_CMD_ENC_PIC_SRC_ADDR_Y 0x1a8
340#define CODA9_CMD_ENC_PIC_SRC_ADDR_CB 0x1ac
341#define CODA9_CMD_ENC_PIC_SRC_ADDR_CR 0x1b0
Javier Martin186b2502012-07-26 05:53:35 -0300342#define CODA_CMD_ENC_PIC_SRC_ADDR_Y 0x180
343#define CODA_CMD_ENC_PIC_SRC_ADDR_CB 0x184
344#define CODA_CMD_ENC_PIC_SRC_ADDR_CR 0x188
345#define CODA_CMD_ENC_PIC_QS 0x18c
346#define CODA_CMD_ENC_PIC_ROT_MODE 0x190
Philipp Zabel8f35c7b2012-07-09 04:25:52 -0300347#define CODA_ROT_MIR_ENABLE (1 << 4)
348#define CODA_ROT_0 (0x0 << 0)
349#define CODA_ROT_90 (0x1 << 0)
350#define CODA_ROT_180 (0x2 << 0)
351#define CODA_ROT_270 (0x3 << 0)
352#define CODA_MIR_NONE (0x0 << 2)
353#define CODA_MIR_VER (0x1 << 2)
354#define CODA_MIR_HOR (0x2 << 2)
355#define CODA_MIR_VER_HOR (0x3 << 2)
Philipp Zabel89548442014-07-11 06:36:17 -0300356#define CODA_CMD_ENC_PIC_OPTION 0x194
357#define CODA_FORCE_IPICTURE BIT(1)
358#define CODA_REPORT_MB_INFO BIT(3)
359#define CODA_REPORT_MV_INFO BIT(4)
360#define CODA_REPORT_SLICE_INFO BIT(5)
Javier Martin186b2502012-07-26 05:53:35 -0300361#define CODA_CMD_ENC_PIC_BB_START 0x198
362#define CODA_CMD_ENC_PIC_BB_SIZE 0x19c
Philipp Zabel918c66f2013-06-27 06:59:01 -0300363#define CODA_RET_ENC_FRAME_NUM 0x1c0
Javier Martin186b2502012-07-26 05:53:35 -0300364#define CODA_RET_ENC_PIC_TYPE 0x1c4
Philipp Zabel918c66f2013-06-27 06:59:01 -0300365#define CODA_RET_ENC_PIC_FRAME_IDX 0x1c8
Javier Martin186b2502012-07-26 05:53:35 -0300366#define CODA_RET_ENC_PIC_SLICE_NUM 0x1cc
367#define CODA_RET_ENC_PIC_FLAG 0x1d0
Philipp Zabel918c66f2013-06-27 06:59:01 -0300368#define CODA_RET_ENC_PIC_SUCCESS 0x1d8
Javier Martin186b2502012-07-26 05:53:35 -0300369
370/* Set Frame Buffer */
Philipp Zabel10436672012-07-02 09:03:55 -0300371#define CODA_CMD_SET_FRAME_BUF_NUM 0x180
372#define CODA_CMD_SET_FRAME_BUF_STRIDE 0x184
Philipp Zabel918c66f2013-06-27 06:59:01 -0300373#define CODA_CMD_SET_FRAME_SLICE_BB_START 0x188
374#define CODA_CMD_SET_FRAME_SLICE_BB_SIZE 0x18c
Philipp Zabel89548442014-07-11 06:36:17 -0300375#define CODA9_CMD_SET_FRAME_SUBSAMP_A 0x188
376#define CODA9_CMD_SET_FRAME_SUBSAMP_B 0x18c
Philipp Zabel10436672012-07-02 09:03:55 -0300377#define CODA7_CMD_SET_FRAME_AXI_BIT_ADDR 0x190
378#define CODA7_CMD_SET_FRAME_AXI_IPACDC_ADDR 0x194
379#define CODA7_CMD_SET_FRAME_AXI_DBKY_ADDR 0x198
380#define CODA7_CMD_SET_FRAME_AXI_DBKC_ADDR 0x19c
381#define CODA7_CMD_SET_FRAME_AXI_OVL_ADDR 0x1a0
Philipp Zabel918c66f2013-06-27 06:59:01 -0300382#define CODA7_CMD_SET_FRAME_MAX_DEC_SIZE 0x1a4
Philipp Zabel89548442014-07-11 06:36:17 -0300383#define CODA9_CMD_SET_FRAME_AXI_BTP_ADDR 0x1a4
Philipp Zabel10436672012-07-02 09:03:55 -0300384#define CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE 0x1a8
Philipp Zabel89548442014-07-11 06:36:17 -0300385#define CODA9_CMD_SET_FRAME_CACHE_SIZE 0x1a8
386#define CODA9_CMD_SET_FRAME_CACHE_CONFIG 0x1ac
387#define CODA9_CACHE_BYPASS_OFFSET 28
388#define CODA9_CACHE_DUALCONF_OFFSET 26
389#define CODA9_CACHE_PAGEMERGE_OFFSET 24
390#define CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET 16
391#define CODA9_CACHE_CB_BUFFER_SIZE_OFFSET 8
392#define CODA9_CACHE_CR_BUFFER_SIZE_OFFSET 0
393#define CODA9_CMD_SET_FRAME_SUBSAMP_A_MVC 0x1b0
394#define CODA9_CMD_SET_FRAME_SUBSAMP_B_MVC 0x1b4
395#define CODA9_CMD_SET_FRAME_DP_BUF_BASE 0x1b0
396#define CODA9_CMD_SET_FRAME_DP_BUF_SIZE 0x1b4
397#define CODA9_CMD_SET_FRAME_MAX_DEC_SIZE 0x1b8
398#define CODA9_CMD_SET_FRAME_DELAY 0x1bc
Javier Martin186b2502012-07-26 05:53:35 -0300399
400/* Encoder Header */
401#define CODA_CMD_ENC_HEADER_CODE 0x180
402#define CODA_GAMMA_OFFSET 0
403#define CODA_HEADER_H264_SPS 0
404#define CODA_HEADER_H264_PPS 1
405#define CODA_HEADER_MP4V_VOL 0
406#define CODA_HEADER_MP4V_VOS 1
407#define CODA_HEADER_MP4V_VIS 2
Philipp Zabel89548442014-07-11 06:36:17 -0300408#define CODA9_HEADER_FRAME_CROP (1 << 3)
Javier Martin186b2502012-07-26 05:53:35 -0300409#define CODA_CMD_ENC_HEADER_BB_START 0x184
410#define CODA_CMD_ENC_HEADER_BB_SIZE 0x188
Philipp Zabel89548442014-07-11 06:36:17 -0300411#define CODA9_CMD_ENC_HEADER_FRAME_CROP_H 0x18c
412#define CODA9_CMD_ENC_HEADER_FRAME_CROP_V 0x190
Javier Martin186b2502012-07-26 05:53:35 -0300413
414/* Get Version */
415#define CODA_CMD_FIRMWARE_VERNUM 0x1c0
416#define CODA_FIRMWARE_PRODUCT(x) (((x) >> 16) & 0xffff)
417#define CODA_FIRMWARE_MAJOR(x) (((x) >> 12) & 0x0f)
418#define CODA_FIRMWARE_MINOR(x) (((x) >> 8) & 0x0f)
419#define CODA_FIRMWARE_RELEASE(x) ((x) & 0xff)
420#define CODA_FIRMWARE_VERNUM(product, major, minor, release) \
421 ((product) << 16 | ((major) << 12) | \
422 ((minor) << 8) | (release))
Philipp Zabel89548442014-07-11 06:36:17 -0300423#define CODA9_CMD_FIRMWARE_CODE_REV 0x1c4
424
425#define CODA9_GDMA_BASE 0x1000
426#define CODA9_GDI_WPROT_ERR_CLR (CODA9_GDMA_BASE + 0x0a0)
427#define CODA9_GDI_WPROT_RGN_EN (CODA9_GDMA_BASE + 0x0ac)
428
429#define CODA9_GDI_BUS_CTRL (CODA9_GDMA_BASE + 0x0f0)
430#define CODA9_GDI_BUS_STATUS (CODA9_GDMA_BASE + 0x0f4)
431
432#define CODA9_GDI_XY2_CAS_0 (CODA9_GDMA_BASE + 0x800)
433#define CODA9_GDI_XY2_CAS_F (CODA9_GDMA_BASE + 0x83c)
434
435#define CODA9_GDI_XY2_BA_0 (CODA9_GDMA_BASE + 0x840)
436#define CODA9_GDI_XY2_BA_1 (CODA9_GDMA_BASE + 0x844)
437#define CODA9_GDI_XY2_BA_2 (CODA9_GDMA_BASE + 0x848)
438#define CODA9_GDI_XY2_BA_3 (CODA9_GDMA_BASE + 0x84c)
439
440#define CODA9_GDI_XY2_RAS_0 (CODA9_GDMA_BASE + 0x850)
441#define CODA9_GDI_XY2_RAS_F (CODA9_GDMA_BASE + 0x88c)
442
443#define CODA9_GDI_XY2_RBC_CONFIG (CODA9_GDMA_BASE + 0x890)
444#define CODA9_GDI_RBC2_AXI_0 (CODA9_GDMA_BASE + 0x8a0)
445#define CODA9_GDI_RBC2_AXI_1F (CODA9_GDMA_BASE + 0x91c)
Javier Martin186b2502012-07-26 05:53:35 -0300446
447#endif