PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / media / platform / coda.h
blob4e32e2edea62005d8ae6c8d20da8bf071d417183
1 /*
2 * linux/drivers/media/platform/coda/coda_regs.h
4 * Copyright (C) 2012 Vista Silicon SL
5 * Javier Martin <javier.martin@vista-silicon.com>
6 * Xavier Duret
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.
14 #ifndef _REGS_CODA_H_
15 #define _REGS_CODA_H_
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
31 /* Static SW registers */
32 #define CODA_REG_BIT_CODE_BUF_ADDR 0x100
33 #define CODA_REG_BIT_WORK_BUF_ADDR 0x104
34 #define CODA_REG_BIT_PARA_BUF_ADDR 0x108
35 #define CODA_REG_BIT_STREAM_CTRL 0x10c
36 #define CODA7_STREAM_BUF_PIC_RESET (1 << 4)
37 #define CODADX6_STREAM_BUF_PIC_RESET (1 << 3)
38 #define CODA7_STREAM_BUF_PIC_FLUSH (1 << 3)
39 #define CODADX6_STREAM_BUF_PIC_FLUSH (1 << 2)
40 #define CODA7_STREAM_BUF_DYNALLOC_EN (1 << 5)
41 #define CODADX6_STREAM_BUF_DYNALLOC_EN (1 << 4)
42 #define CODA_STREAM_CHKDIS_OFFSET (1 << 1)
43 #define CODA_STREAM_ENDIAN_SELECT (1 << 0)
44 #define CODA_REG_BIT_FRAME_MEM_CTRL 0x110
45 #define CODA_IMAGE_ENDIAN_SELECT (1 << 0)
46 #define CODA_REG_BIT_BIT_STREAM_PARAM 0x114
47 #define CODA_BIT_STREAM_END_FLAG (1 << 2)
48 #define CODA_BIT_DEC_SEQ_INIT_ESCAPE (1 << 0)
49 #define CODA_REG_BIT_TEMP_BUF_ADDR 0x118
50 #define CODA_REG_BIT_RD_PTR(x) (0x120 + 8 * (x))
51 #define CODA_REG_BIT_WR_PTR(x) (0x124 + 8 * (x))
52 #define CODA_REG_BIT_FRM_DIS_FLG(x) (0x150 + 4 * (x))
53 #define CODADX6_REG_BIT_SEARCH_RAM_BASE_ADDR 0x140
54 #define CODA7_REG_BIT_AXI_SRAM_USE 0x140
55 #define CODA7_USE_HOST_ME_ENABLE (1 << 11)
56 #define CODA7_USE_HOST_OVL_ENABLE (1 << 10)
57 #define CODA7_USE_HOST_DBK_ENABLE (1 << 9)
58 #define CODA7_USE_HOST_IP_ENABLE (1 << 8)
59 #define CODA7_USE_HOST_BIT_ENABLE (1 << 7)
60 #define CODA7_USE_ME_ENABLE (1 << 4)
61 #define CODA7_USE_OVL_ENABLE (1 << 3)
62 #define CODA7_USE_DBK_ENABLE (1 << 2)
63 #define CODA7_USE_IP_ENABLE (1 << 1)
64 #define CODA7_USE_BIT_ENABLE (1 << 0)
66 #define CODA_REG_BIT_BUSY 0x160
67 #define CODA_REG_BIT_BUSY_FLAG 1
68 #define CODA_REG_BIT_RUN_COMMAND 0x164
69 #define CODA_COMMAND_SEQ_INIT 1
70 #define CODA_COMMAND_SEQ_END 2
71 #define CODA_COMMAND_PIC_RUN 3
72 #define CODA_COMMAND_SET_FRAME_BUF 4
73 #define CODA_COMMAND_ENCODE_HEADER 5
74 #define CODA_COMMAND_ENC_PARA_SET 6
75 #define CODA_COMMAND_DEC_PARA_SET 7
76 #define CODA_COMMAND_DEC_BUF_FLUSH 8
77 #define CODA_COMMAND_RC_CHANGE_PARAMETER 9
78 #define CODA_COMMAND_FIRMWARE_GET 0xf
79 #define CODA_REG_BIT_RUN_INDEX 0x168
80 #define CODA_INDEX_SET(x) ((x) & 0x3)
81 #define CODA_REG_BIT_RUN_COD_STD 0x16c
82 #define CODADX6_MODE_DECODE_MP4 0
83 #define CODADX6_MODE_ENCODE_MP4 1
84 #define CODADX6_MODE_DECODE_H264 2
85 #define CODADX6_MODE_ENCODE_H264 3
86 #define CODA7_MODE_DECODE_H264 0
87 #define CODA7_MODE_DECODE_VC1 1
88 #define CODA7_MODE_DECODE_MP2 2
89 #define CODA7_MODE_DECODE_MP4 3
90 #define CODA7_MODE_DECODE_DV3 3
91 #define CODA7_MODE_DECODE_RV 4
92 #define CODA7_MODE_DECODE_MJPG 5
93 #define CODA7_MODE_ENCODE_H264 8
94 #define CODA7_MODE_ENCODE_MP4 11
95 #define CODA7_MODE_ENCODE_MJPG 13
96 #define CODA_MODE_INVALID 0xffff
97 #define CODA_REG_BIT_INT_ENABLE 0x170
98 #define CODA_INT_INTERRUPT_ENABLE (1 << 3)
99 #define CODA_REG_BIT_INT_REASON 0x174
100 #define CODA7_REG_BIT_RUN_AUX_STD 0x178
101 #define CODA_MP4_AUX_MPEG4 0
102 #define CODA_MP4_AUX_DIVX3 1
103 #define CODA_VPX_AUX_THO 0
104 #define CODA_VPX_AUX_VP6 1
105 #define CODA_VPX_AUX_VP8 2
106 #define CODA_H264_AUX_AVC 0
107 #define CODA_H264_AUX_MVC 1
110 * Commands' mailbox:
111 * registers with offsets in the range 0x180-0x1d0
112 * have different meaning depending on the command being
113 * issued.
116 /* Decoder Sequence Initialization */
117 #define CODA_CMD_DEC_SEQ_BB_START 0x180
118 #define CODA_CMD_DEC_SEQ_BB_SIZE 0x184
119 #define CODA_CMD_DEC_SEQ_OPTION 0x188
120 #define CODA_REORDER_ENABLE (1 << 1)
121 #define CODADX6_QP_REPORT (1 << 0)
122 #define CODA7_MP4_DEBLK_ENABLE (1 << 0)
123 #define CODA_CMD_DEC_SEQ_SRC_SIZE 0x18c
124 #define CODA_CMD_DEC_SEQ_START_BYTE 0x190
125 #define CODA_CMD_DEC_SEQ_PS_BB_START 0x194
126 #define CODA_CMD_DEC_SEQ_PS_BB_SIZE 0x198
127 #define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS 0x19c
128 #define CODA_CMD_DEC_SEQ_X264_MV_EN 0x19c
129 #define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE 0x1a0
131 #define CODA7_RET_DEC_SEQ_ASPECT 0x1b0
132 #define CODA_RET_DEC_SEQ_SUCCESS 0x1c0
133 #define CODA_RET_DEC_SEQ_SRC_FMT 0x1c4 /* SRC_SIZE on CODA7 */
134 #define CODA_RET_DEC_SEQ_SRC_SIZE 0x1c4
135 #define CODA_RET_DEC_SEQ_SRC_F_RATE 0x1c8
136 #define CODA9_RET_DEC_SEQ_ASPECT 0x1c8
137 #define CODA_RET_DEC_SEQ_FRAME_NEED 0x1cc
138 #define CODA_RET_DEC_SEQ_FRAME_DELAY 0x1d0
139 #define CODA_RET_DEC_SEQ_INFO 0x1d4
140 #define CODA_RET_DEC_SEQ_CROP_LEFT_RIGHT 0x1d8
141 #define CODA_RET_DEC_SEQ_CROP_TOP_BOTTOM 0x1dc
142 #define CODA_RET_DEC_SEQ_NEXT_FRAME_NUM 0x1e0
143 #define CODA_RET_DEC_SEQ_ERR_REASON 0x1e0
144 #define CODA_RET_DEC_SEQ_FRATE_NR 0x1e4
145 #define CODA_RET_DEC_SEQ_FRATE_DR 0x1e8
146 #define CODA_RET_DEC_SEQ_JPG_PARA 0x1e4
147 #define CODA_RET_DEC_SEQ_JPG_THUMB_IND 0x1e8
149 /* Decoder Picture Run */
150 #define CODA_CMD_DEC_PIC_ROT_MODE 0x180
151 #define CODA_CMD_DEC_PIC_ROT_ADDR_Y 0x184
152 #define CODA_CMD_DEC_PIC_ROT_ADDR_CB 0x188
153 #define CODA_CMD_DEC_PIC_ROT_ADDR_CR 0x18c
154 #define CODA_CMD_DEC_PIC_ROT_STRIDE 0x190
156 #define CODA_CMD_DEC_PIC_OPTION 0x194
157 #define CODA_PRE_SCAN_EN (1 << 0)
158 #define CODA_PRE_SCAN_MODE_DECODE (0 << 1)
159 #define CODA_PRE_SCAN_MODE_RETURN (1 << 1)
160 #define CODA_IFRAME_SEARCH_EN (1 << 2)
161 #define CODA_SKIP_FRAME_MODE (0x3 << 3)
162 #define CODA_CMD_DEC_PIC_SKIP_NUM 0x198
163 #define CODA_CMD_DEC_PIC_CHUNK_SIZE 0x19c
164 #define CODA_CMD_DEC_PIC_BB_START 0x1a0
165 #define CODA_CMD_DEC_PIC_START_BYTE 0x1a4
166 #define CODA_RET_DEC_PIC_SIZE 0x1bc
167 #define CODA_RET_DEC_PIC_FRAME_NUM 0x1c0
168 #define CODA_RET_DEC_PIC_FRAME_IDX 0x1c4
169 #define CODA_RET_DEC_PIC_ERR_MB 0x1c8
170 #define CODA_RET_DEC_PIC_TYPE 0x1cc
171 #define CODA_PIC_TYPE_MASK 0x7
172 #define CODA_PIC_TYPE_MASK_VC1 0x3f
173 #define CODA9_PIC_TYPE_FIRST_MASK (0x7 << 3)
174 #define CODA9_PIC_TYPE_IDR_MASK (0x3 << 6)
175 #define CODA7_PIC_TYPE_H264_NPF_MASK (0x3 << 16)
176 #define CODA7_PIC_TYPE_INTERLACED (1 << 18)
177 #define CODA_RET_DEC_PIC_POST 0x1d0
178 #define CODA_RET_DEC_PIC_MVC_REPORT 0x1d0
179 #define CODA_RET_DEC_PIC_OPTION 0x1d4
180 #define CODA_RET_DEC_PIC_SUCCESS 0x1d8
181 #define CODA_RET_DEC_PIC_CUR_IDX 0x1dc
182 #define CODA_RET_DEC_PIC_CROP_LEFT_RIGHT 0x1e0
183 #define CODA_RET_DEC_PIC_CROP_TOP_BOTTOM 0x1e4
184 #define CODA_RET_DEC_PIC_FRAME_NEED 0x1ec
186 /* Encoder Sequence Initialization */
187 #define CODA_CMD_ENC_SEQ_BB_START 0x180
188 #define CODA_CMD_ENC_SEQ_BB_SIZE 0x184
189 #define CODA_CMD_ENC_SEQ_OPTION 0x188
190 #define CODA7_OPTION_AVCINTRA16X16ONLY_OFFSET 9
191 #define CODA7_OPTION_GAMMA_OFFSET 8
192 #define CODA7_OPTION_RCQPMAX_OFFSET 7
193 #define CODADX6_OPTION_GAMMA_OFFSET 7
194 #define CODA7_OPTION_RCQPMIN_OFFSET 6
195 #define CODA_OPTION_LIMITQP_OFFSET 6
196 #define CODA_OPTION_RCINTRAQP_OFFSET 5
197 #define CODA_OPTION_FMO_OFFSET 4
198 #define CODA_OPTION_AVC_AUD_OFFSET 2
199 #define CODA_OPTION_SLICEREPORT_OFFSET 1
200 #define CODA_CMD_ENC_SEQ_COD_STD 0x18c
201 #define CODA_STD_MPEG4 0
202 #define CODA_STD_H263 1
203 #define CODA_STD_H264 2
204 #define CODA_STD_MJPG 3
205 #define CODA_CMD_ENC_SEQ_SRC_SIZE 0x190
206 #define CODA7_PICWIDTH_OFFSET 16
207 #define CODA7_PICWIDTH_MASK 0xffff
208 #define CODADX6_PICWIDTH_OFFSET 10
209 #define CODADX6_PICWIDTH_MASK 0x3ff
210 #define CODA_PICHEIGHT_OFFSET 0
211 #define CODADX6_PICHEIGHT_MASK 0x3ff
212 #define CODA7_PICHEIGHT_MASK 0xffff
213 #define CODA_CMD_ENC_SEQ_SRC_F_RATE 0x194
214 #define CODA_CMD_ENC_SEQ_MP4_PARA 0x198
215 #define CODA_MP4PARAM_VERID_OFFSET 6
216 #define CODA_MP4PARAM_VERID_MASK 0x01
217 #define CODA_MP4PARAM_INTRADCVLCTHR_OFFSET 2
218 #define CODA_MP4PARAM_INTRADCVLCTHR_MASK 0x07
219 #define CODA_MP4PARAM_REVERSIBLEVLCENABLE_OFFSET 1
220 #define CODA_MP4PARAM_REVERSIBLEVLCENABLE_MASK 0x01
221 #define CODA_MP4PARAM_DATAPARTITIONENABLE_OFFSET 0
222 #define CODA_MP4PARAM_DATAPARTITIONENABLE_MASK 0x01
223 #define CODA_CMD_ENC_SEQ_263_PARA 0x19c
224 #define CODA_263PARAM_ANNEXJENABLE_OFFSET 2
225 #define CODA_263PARAM_ANNEXJENABLE_MASK 0x01
226 #define CODA_263PARAM_ANNEXKENABLE_OFFSET 1
227 #define CODA_263PARAM_ANNEXKENABLE_MASK 0x01
228 #define CODA_263PARAM_ANNEXTENABLE_OFFSET 0
229 #define CODA_263PARAM_ANNEXTENABLE_MASK 0x01
230 #define CODA_CMD_ENC_SEQ_264_PARA 0x1a0
231 #define CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET 12
232 #define CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK 0x0f
233 #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET 8
234 #define CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK 0x0f
235 #define CODA_264PARAM_DISABLEDEBLK_OFFSET 6
236 #define CODA_264PARAM_DISABLEDEBLK_MASK 0x01
237 #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET 5
238 #define CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK 0x01
239 #define CODA_264PARAM_CHROMAQPOFFSET_OFFSET 0
240 #define CODA_264PARAM_CHROMAQPOFFSET_MASK 0x1f
241 #define CODA_CMD_ENC_SEQ_SLICE_MODE 0x1a4
242 #define CODA_SLICING_SIZE_OFFSET 2
243 #define CODA_SLICING_SIZE_MASK 0x3fffffff
244 #define CODA_SLICING_UNIT_OFFSET 1
245 #define CODA_SLICING_UNIT_MASK 0x01
246 #define CODA_SLICING_MODE_OFFSET 0
247 #define CODA_SLICING_MODE_MASK 0x01
248 #define CODA_CMD_ENC_SEQ_GOP_SIZE 0x1a8
249 #define CODA_GOP_SIZE_OFFSET 0
250 #define CODA_GOP_SIZE_MASK 0x3f
251 #define CODA_CMD_ENC_SEQ_RC_PARA 0x1ac
252 #define CODA_RATECONTROL_AUTOSKIP_OFFSET 31
253 #define CODA_RATECONTROL_AUTOSKIP_MASK 0x01
254 #define CODA_RATECONTROL_INITIALDELAY_OFFSET 16
255 #define CODA_RATECONTROL_INITIALDELAY_MASK 0x7f
256 #define CODA_RATECONTROL_BITRATE_OFFSET 1
257 #define CODA_RATECONTROL_BITRATE_MASK 0x7f
258 #define CODA_RATECONTROL_ENABLE_OFFSET 0
259 #define CODA_RATECONTROL_ENABLE_MASK 0x01
260 #define CODA_CMD_ENC_SEQ_RC_BUF_SIZE 0x1b0
261 #define CODA_CMD_ENC_SEQ_INTRA_REFRESH 0x1b4
262 #define CODADX6_CMD_ENC_SEQ_FMO 0x1b8
263 #define CODA_FMOPARAM_TYPE_OFFSET 4
264 #define CODA_FMOPARAM_TYPE_MASK 1
265 #define CODA_FMOPARAM_SLICENUM_OFFSET 0
266 #define CODA_FMOPARAM_SLICENUM_MASK 0x0f
267 #define CODADX6_CMD_ENC_SEQ_INTRA_QP 0x1bc
268 #define CODA7_CMD_ENC_SEQ_SEARCH_BASE 0x1b8
269 #define CODA7_CMD_ENC_SEQ_SEARCH_SIZE 0x1bc
270 #define CODA7_CMD_ENC_SEQ_INTRA_QP 0x1c4
271 #define CODA_CMD_ENC_SEQ_RC_QP_MAX 0x1c8
272 #define CODA_QPMAX_OFFSET 0
273 #define CODA_QPMAX_MASK 0x3f
274 #define CODA_CMD_ENC_SEQ_RC_GAMMA 0x1cc
275 #define CODA_GAMMA_OFFSET 0
276 #define CODA_GAMMA_MASK 0xffff
277 #define CODA_RET_ENC_SEQ_SUCCESS 0x1c0
279 /* Encoder Picture Run */
280 #define CODA_CMD_ENC_PIC_SRC_ADDR_Y 0x180
281 #define CODA_CMD_ENC_PIC_SRC_ADDR_CB 0x184
282 #define CODA_CMD_ENC_PIC_SRC_ADDR_CR 0x188
283 #define CODA_CMD_ENC_PIC_QS 0x18c
284 #define CODA_CMD_ENC_PIC_ROT_MODE 0x190
285 #define CODA_ROT_MIR_ENABLE (1 << 4)
286 #define CODA_ROT_0 (0x0 << 0)
287 #define CODA_ROT_90 (0x1 << 0)
288 #define CODA_ROT_180 (0x2 << 0)
289 #define CODA_ROT_270 (0x3 << 0)
290 #define CODA_MIR_NONE (0x0 << 2)
291 #define CODA_MIR_VER (0x1 << 2)
292 #define CODA_MIR_HOR (0x2 << 2)
293 #define CODA_MIR_VER_HOR (0x3 << 2)
294 #define CODA_CMD_ENC_PIC_OPTION 0x194
295 #define CODA_CMD_ENC_PIC_BB_START 0x198
296 #define CODA_CMD_ENC_PIC_BB_SIZE 0x19c
297 #define CODA_RET_ENC_FRAME_NUM 0x1c0
298 #define CODA_RET_ENC_PIC_TYPE 0x1c4
299 #define CODA_RET_ENC_PIC_FRAME_IDX 0x1c8
300 #define CODA_RET_ENC_PIC_SLICE_NUM 0x1cc
301 #define CODA_RET_ENC_PIC_FLAG 0x1d0
302 #define CODA_RET_ENC_PIC_SUCCESS 0x1d8
304 /* Set Frame Buffer */
305 #define CODA_CMD_SET_FRAME_BUF_NUM 0x180
306 #define CODA_CMD_SET_FRAME_BUF_STRIDE 0x184
307 #define CODA_CMD_SET_FRAME_SLICE_BB_START 0x188
308 #define CODA_CMD_SET_FRAME_SLICE_BB_SIZE 0x18c
309 #define CODA7_CMD_SET_FRAME_AXI_BIT_ADDR 0x190
310 #define CODA7_CMD_SET_FRAME_AXI_IPACDC_ADDR 0x194
311 #define CODA7_CMD_SET_FRAME_AXI_DBKY_ADDR 0x198
312 #define CODA7_CMD_SET_FRAME_AXI_DBKC_ADDR 0x19c
313 #define CODA7_CMD_SET_FRAME_AXI_OVL_ADDR 0x1a0
314 #define CODA7_CMD_SET_FRAME_MAX_DEC_SIZE 0x1a4
315 #define CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE 0x1a8
317 /* Encoder Header */
318 #define CODA_CMD_ENC_HEADER_CODE 0x180
319 #define CODA_GAMMA_OFFSET 0
320 #define CODA_HEADER_H264_SPS 0
321 #define CODA_HEADER_H264_PPS 1
322 #define CODA_HEADER_MP4V_VOL 0
323 #define CODA_HEADER_MP4V_VOS 1
324 #define CODA_HEADER_MP4V_VIS 2
325 #define CODA_CMD_ENC_HEADER_BB_START 0x184
326 #define CODA_CMD_ENC_HEADER_BB_SIZE 0x188
328 /* Get Version */
329 #define CODA_CMD_FIRMWARE_VERNUM 0x1c0
330 #define CODA_FIRMWARE_PRODUCT(x) (((x) >> 16) & 0xffff)
331 #define CODA_FIRMWARE_MAJOR(x) (((x) >> 12) & 0x0f)
332 #define CODA_FIRMWARE_MINOR(x) (((x) >> 8) & 0x0f)
333 #define CODA_FIRMWARE_RELEASE(x) ((x) & 0xff)
334 #define CODA_FIRMWARE_VERNUM(product, major, minor, release) \
335 ((product) << 16 | ((major) << 12) | \
336 ((minor) << 8) | (release))
338 #endif