1
2
3
4
5
6
7
8
9
10 #ifndef _CEDRUS_REGS_H_
11 #define _CEDRUS_REGS_H_
12
13 #define SHIFT_AND_MASK_BITS(v, h, l) \
14 (((unsigned long)(v) << (l)) & GENMASK(h, l))
15
16
17
18
19
20
21
22
23
24
25
26 #define VE_ENGINE_DEC_MPEG 0x100
27 #define VE_ENGINE_DEC_H264 0x200
28
29 #define VE_MODE 0x00
30
31 #define VE_MODE_REC_WR_MODE_2MB (0x01 << 20)
32 #define VE_MODE_REC_WR_MODE_1MB (0x00 << 20)
33 #define VE_MODE_DDR_MODE_BW_128 (0x03 << 16)
34 #define VE_MODE_DDR_MODE_BW_256 (0x02 << 16)
35 #define VE_MODE_DISABLED (0x07 << 0)
36 #define VE_MODE_DEC_H265 (0x04 << 0)
37 #define VE_MODE_DEC_H264 (0x01 << 0)
38 #define VE_MODE_DEC_MPEG (0x00 << 0)
39
40 #define VE_PRIMARY_CHROMA_BUF_LEN 0xc4
41 #define VE_PRIMARY_FB_LINE_STRIDE 0xc8
42
43 #define VE_PRIMARY_FB_LINE_STRIDE_CHROMA(s) SHIFT_AND_MASK_BITS(s, 31, 16)
44 #define VE_PRIMARY_FB_LINE_STRIDE_LUMA(s) SHIFT_AND_MASK_BITS(s, 15, 0)
45
46 #define VE_CHROMA_BUF_LEN 0xe8
47
48 #define VE_SECONDARY_OUT_FMT_TILED_32_NV12 (0x00 << 30)
49 #define VE_SECONDARY_OUT_FMT_EXT (0x01 << 30)
50 #define VE_SECONDARY_OUT_FMT_YU12 (0x02 << 30)
51 #define VE_SECONDARY_OUT_FMT_YV12 (0x03 << 30)
52 #define VE_CHROMA_BUF_LEN_SDRT(l) SHIFT_AND_MASK_BITS(l, 27, 0)
53
54 #define VE_PRIMARY_OUT_FMT 0xec
55
56 #define VE_PRIMARY_OUT_FMT_TILED_32_NV12 (0x00 << 4)
57 #define VE_PRIMARY_OUT_FMT_TILED_128_NV12 (0x01 << 4)
58 #define VE_PRIMARY_OUT_FMT_YU12 (0x02 << 4)
59 #define VE_PRIMARY_OUT_FMT_YV12 (0x03 << 4)
60 #define VE_PRIMARY_OUT_FMT_NV12 (0x04 << 4)
61 #define VE_PRIMARY_OUT_FMT_NV21 (0x05 << 4)
62 #define VE_SECONDARY_OUT_FMT_EXT_TILED_32_NV12 (0x00 << 0)
63 #define VE_SECONDARY_OUT_FMT_EXT_TILED_128_NV12 (0x01 << 0)
64 #define VE_SECONDARY_OUT_FMT_EXT_YU12 (0x02 << 0)
65 #define VE_SECONDARY_OUT_FMT_EXT_YV12 (0x03 << 0)
66 #define VE_SECONDARY_OUT_FMT_EXT_NV12 (0x04 << 0)
67 #define VE_SECONDARY_OUT_FMT_EXT_NV21 (0x05 << 0)
68
69 #define VE_VERSION 0xf0
70
71 #define VE_VERSION_SHIFT 16
72
73 #define VE_DEC_MPEG_MP12HDR (VE_ENGINE_DEC_MPEG + 0x00)
74
75 #define VE_DEC_MPEG_MP12HDR_SLICE_TYPE(t) SHIFT_AND_MASK_BITS(t, 30, 28)
76 #define VE_DEC_MPEG_MP12HDR_F_CODE_SHIFT(x, y) (24 - 4 * (y) - 8 * (x))
77 #define VE_DEC_MPEG_MP12HDR_F_CODE(__x, __y, __v) \
78 (((unsigned long)(__v) & GENMASK(3, 0)) << VE_DEC_MPEG_MP12HDR_F_CODE_SHIFT(__x, __y))
79
80 #define VE_DEC_MPEG_MP12HDR_INTRA_DC_PRECISION(p) \
81 SHIFT_AND_MASK_BITS(p, 11, 10)
82 #define VE_DEC_MPEG_MP12HDR_INTRA_PICTURE_STRUCTURE(s) \
83 SHIFT_AND_MASK_BITS(s, 9, 8)
84 #define VE_DEC_MPEG_MP12HDR_TOP_FIELD_FIRST(v) \
85 ((v) ? BIT(7) : 0)
86 #define VE_DEC_MPEG_MP12HDR_FRAME_PRED_FRAME_DCT(v) \
87 ((v) ? BIT(6) : 0)
88 #define VE_DEC_MPEG_MP12HDR_CONCEALMENT_MOTION_VECTORS(v) \
89 ((v) ? BIT(5) : 0)
90 #define VE_DEC_MPEG_MP12HDR_Q_SCALE_TYPE(v) \
91 ((v) ? BIT(4) : 0)
92 #define VE_DEC_MPEG_MP12HDR_INTRA_VLC_FORMAT(v) \
93 ((v) ? BIT(3) : 0)
94 #define VE_DEC_MPEG_MP12HDR_ALTERNATE_SCAN(v) \
95 ((v) ? BIT(2) : 0)
96 #define VE_DEC_MPEG_MP12HDR_FULL_PEL_FORWARD_VECTOR(v) \
97 ((v) ? BIT(1) : 0)
98 #define VE_DEC_MPEG_MP12HDR_FULL_PEL_BACKWARD_VECTOR(v) \
99 ((v) ? BIT(0) : 0)
100
101 #define VE_DEC_MPEG_PICCODEDSIZE (VE_ENGINE_DEC_MPEG + 0x08)
102
103 #define VE_DEC_MPEG_PICCODEDSIZE_WIDTH(w) \
104 SHIFT_AND_MASK_BITS(DIV_ROUND_UP((w), 16), 15, 8)
105 #define VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(h) \
106 SHIFT_AND_MASK_BITS(DIV_ROUND_UP((h), 16), 7, 0)
107
108 #define VE_DEC_MPEG_PICBOUNDSIZE (VE_ENGINE_DEC_MPEG + 0x0c)
109
110 #define VE_DEC_MPEG_PICBOUNDSIZE_WIDTH(w) SHIFT_AND_MASK_BITS(w, 27, 16)
111 #define VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(h) SHIFT_AND_MASK_BITS(h, 11, 0)
112
113 #define VE_DEC_MPEG_MBADDR (VE_ENGINE_DEC_MPEG + 0x10)
114
115 #define VE_DEC_MPEG_MBADDR_X(w) SHIFT_AND_MASK_BITS(w, 15, 8)
116 #define VE_DEC_MPEG_MBADDR_Y(h) SHIFT_AND_MASK_BITS(h, 7, 0)
117
118 #define VE_DEC_MPEG_CTRL (VE_ENGINE_DEC_MPEG + 0x14)
119
120 #define VE_DEC_MPEG_CTRL_MC_CACHE_EN BIT(31)
121 #define VE_DEC_MPEG_CTRL_SW_VLD BIT(27)
122 #define VE_DEC_MPEG_CTRL_SW_IQ_IS BIT(17)
123 #define VE_DEC_MPEG_CTRL_QP_AC_DC_OUT_EN BIT(14)
124 #define VE_DEC_MPEG_CTRL_ROTATE_SCALE_OUT_EN BIT(8)
125 #define VE_DEC_MPEG_CTRL_MC_NO_WRITEBACK BIT(7)
126 #define VE_DEC_MPEG_CTRL_ROTATE_IRQ_EN BIT(6)
127 #define VE_DEC_MPEG_CTRL_VLD_DATA_REQ_IRQ_EN BIT(5)
128 #define VE_DEC_MPEG_CTRL_ERROR_IRQ_EN BIT(4)
129 #define VE_DEC_MPEG_CTRL_FINISH_IRQ_EN BIT(3)
130 #define VE_DEC_MPEG_CTRL_IRQ_MASK \
131 (VE_DEC_MPEG_CTRL_FINISH_IRQ_EN | VE_DEC_MPEG_CTRL_ERROR_IRQ_EN | \
132 VE_DEC_MPEG_CTRL_VLD_DATA_REQ_IRQ_EN)
133
134 #define VE_DEC_MPEG_TRIGGER (VE_ENGINE_DEC_MPEG + 0x18)
135
136 #define VE_DEC_MPEG_TRIGGER_MB_BOUNDARY BIT(31)
137
138 #define VE_DEC_MPEG_TRIGGER_CHROMA_FMT_420 (0x00 << 27)
139 #define VE_DEC_MPEG_TRIGGER_CHROMA_FMT_411 (0x01 << 27)
140 #define VE_DEC_MPEG_TRIGGER_CHROMA_FMT_422 (0x02 << 27)
141 #define VE_DEC_MPEG_TRIGGER_CHROMA_FMT_444 (0x03 << 27)
142 #define VE_DEC_MPEG_TRIGGER_CHROMA_FMT_422T (0x04 << 27)
143
144 #define VE_DEC_MPEG_TRIGGER_MPEG1 (0x01 << 24)
145 #define VE_DEC_MPEG_TRIGGER_MPEG2 (0x02 << 24)
146 #define VE_DEC_MPEG_TRIGGER_JPEG (0x03 << 24)
147 #define VE_DEC_MPEG_TRIGGER_MPEG4 (0x04 << 24)
148 #define VE_DEC_MPEG_TRIGGER_VP62 (0x05 << 24)
149
150 #define VE_DEC_MPEG_TRIGGER_VP62_AC_GET_BITS BIT(7)
151
152 #define VE_DEC_MPEG_TRIGGER_STCD_VC1 (0x02 << 4)
153 #define VE_DEC_MPEG_TRIGGER_STCD_MPEG2 (0x01 << 4)
154 #define VE_DEC_MPEG_TRIGGER_STCD_AVC (0x00 << 4)
155
156 #define VE_DEC_MPEG_TRIGGER_HW_MPEG_VLD (0x0f << 0)
157 #define VE_DEC_MPEG_TRIGGER_HW_JPEG_VLD (0x0e << 0)
158 #define VE_DEC_MPEG_TRIGGER_HW_MB (0x0d << 0)
159 #define VE_DEC_MPEG_TRIGGER_HW_ROTATE (0x0c << 0)
160 #define VE_DEC_MPEG_TRIGGER_HW_VP6_VLD (0x0b << 0)
161 #define VE_DEC_MPEG_TRIGGER_HW_MAF (0x0a << 0)
162 #define VE_DEC_MPEG_TRIGGER_HW_STCD_END (0x09 << 0)
163 #define VE_DEC_MPEG_TRIGGER_HW_STCD_BEGIN (0x08 << 0)
164 #define VE_DEC_MPEG_TRIGGER_SW_MC (0x07 << 0)
165 #define VE_DEC_MPEG_TRIGGER_SW_IQ (0x06 << 0)
166 #define VE_DEC_MPEG_TRIGGER_SW_IDCT (0x05 << 0)
167 #define VE_DEC_MPEG_TRIGGER_SW_SCALE (0x04 << 0)
168 #define VE_DEC_MPEG_TRIGGER_SW_VP6 (0x03 << 0)
169 #define VE_DEC_MPEG_TRIGGER_SW_VP62_AC_GET_BITS (0x02 << 0)
170
171 #define VE_DEC_MPEG_STATUS (VE_ENGINE_DEC_MPEG + 0x1c)
172
173 #define VE_DEC_MPEG_STATUS_START_DETECT_BUSY BIT(27)
174 #define VE_DEC_MPEG_STATUS_VP6_BIT BIT(26)
175 #define VE_DEC_MPEG_STATUS_VP6_BIT_BUSY BIT(25)
176 #define VE_DEC_MPEG_STATUS_MAF_BUSY BIT(23)
177 #define VE_DEC_MPEG_STATUS_VP6_MVP_BUSY BIT(22)
178 #define VE_DEC_MPEG_STATUS_JPEG_BIT_END BIT(21)
179 #define VE_DEC_MPEG_STATUS_JPEG_RESTART_ERROR BIT(20)
180 #define VE_DEC_MPEG_STATUS_JPEG_MARKER BIT(19)
181 #define VE_DEC_MPEG_STATUS_ROTATE_BUSY BIT(18)
182 #define VE_DEC_MPEG_STATUS_DEBLOCKING_BUSY BIT(17)
183 #define VE_DEC_MPEG_STATUS_SCALE_DOWN_BUSY BIT(16)
184 #define VE_DEC_MPEG_STATUS_IQIS_BUF_EMPTY BIT(15)
185 #define VE_DEC_MPEG_STATUS_IDCT_BUF_EMPTY BIT(14)
186 #define VE_DEC_MPEG_STATUS_VE_BUSY BIT(13)
187 #define VE_DEC_MPEG_STATUS_MC_BUSY BIT(12)
188 #define VE_DEC_MPEG_STATUS_IDCT_BUSY BIT(11)
189 #define VE_DEC_MPEG_STATUS_IQIS_BUSY BIT(10)
190 #define VE_DEC_MPEG_STATUS_DCAC_BUSY BIT(9)
191 #define VE_DEC_MPEG_STATUS_VLD_BUSY BIT(8)
192 #define VE_DEC_MPEG_STATUS_ROTATE_SUCCESS BIT(3)
193 #define VE_DEC_MPEG_STATUS_VLD_DATA_REQ BIT(2)
194 #define VE_DEC_MPEG_STATUS_ERROR BIT(1)
195 #define VE_DEC_MPEG_STATUS_SUCCESS BIT(0)
196 #define VE_DEC_MPEG_STATUS_CHECK_MASK \
197 (VE_DEC_MPEG_STATUS_SUCCESS | VE_DEC_MPEG_STATUS_ERROR | \
198 VE_DEC_MPEG_STATUS_VLD_DATA_REQ)
199 #define VE_DEC_MPEG_STATUS_CHECK_ERROR \
200 (VE_DEC_MPEG_STATUS_ERROR | VE_DEC_MPEG_STATUS_VLD_DATA_REQ)
201
202 #define VE_DEC_MPEG_VLD_ADDR (VE_ENGINE_DEC_MPEG + 0x28)
203
204 #define VE_DEC_MPEG_VLD_ADDR_FIRST_PIC_DATA BIT(30)
205 #define VE_DEC_MPEG_VLD_ADDR_LAST_PIC_DATA BIT(29)
206 #define VE_DEC_MPEG_VLD_ADDR_VALID_PIC_DATA BIT(28)
207 #define VE_DEC_MPEG_VLD_ADDR_BASE(a) \
208 ({ \
209 u32 _tmp = (a); \
210 u32 _lo = _tmp & GENMASK(27, 4); \
211 u32 _hi = (_tmp >> 28) & GENMASK(3, 0); \
212 (_lo | _hi); \
213 })
214
215 #define VE_DEC_MPEG_VLD_OFFSET (VE_ENGINE_DEC_MPEG + 0x2c)
216 #define VE_DEC_MPEG_VLD_LEN (VE_ENGINE_DEC_MPEG + 0x30)
217 #define VE_DEC_MPEG_VLD_END_ADDR (VE_ENGINE_DEC_MPEG + 0x34)
218
219 #define VE_DEC_MPEG_REC_LUMA (VE_ENGINE_DEC_MPEG + 0x48)
220 #define VE_DEC_MPEG_REC_CHROMA (VE_ENGINE_DEC_MPEG + 0x4c)
221 #define VE_DEC_MPEG_FWD_REF_LUMA_ADDR (VE_ENGINE_DEC_MPEG + 0x50)
222 #define VE_DEC_MPEG_FWD_REF_CHROMA_ADDR (VE_ENGINE_DEC_MPEG + 0x54)
223 #define VE_DEC_MPEG_BWD_REF_LUMA_ADDR (VE_ENGINE_DEC_MPEG + 0x58)
224 #define VE_DEC_MPEG_BWD_REF_CHROMA_ADDR (VE_ENGINE_DEC_MPEG + 0x5c)
225
226 #define VE_DEC_MPEG_IQMINPUT (VE_ENGINE_DEC_MPEG + 0x80)
227
228 #define VE_DEC_MPEG_IQMINPUT_FLAG_INTRA (0x01 << 14)
229 #define VE_DEC_MPEG_IQMINPUT_FLAG_NON_INTRA (0x00 << 14)
230 #define VE_DEC_MPEG_IQMINPUT_WEIGHT(i, v) \
231 (SHIFT_AND_MASK_BITS(i, 13, 8) | SHIFT_AND_MASK_BITS(v, 7, 0))
232
233 #define VE_DEC_MPEG_ERROR (VE_ENGINE_DEC_MPEG + 0xc4)
234 #define VE_DEC_MPEG_CRTMBADDR (VE_ENGINE_DEC_MPEG + 0xc8)
235 #define VE_DEC_MPEG_ROT_LUMA (VE_ENGINE_DEC_MPEG + 0xcc)
236 #define VE_DEC_MPEG_ROT_CHROMA (VE_ENGINE_DEC_MPEG + 0xd0)
237
238 #define VE_H264_SPS 0x200
239 #define VE_H264_SPS_MBS_ONLY BIT(18)
240 #define VE_H264_SPS_MB_ADAPTIVE_FRAME_FIELD BIT(17)
241 #define VE_H264_SPS_DIRECT_8X8_INFERENCE BIT(16)
242
243 #define VE_H264_PPS 0x204
244 #define VE_H264_PPS_ENTROPY_CODING_MODE BIT(15)
245 #define VE_H264_PPS_WEIGHTED_PRED BIT(4)
246 #define VE_H264_PPS_CONSTRAINED_INTRA_PRED BIT(1)
247 #define VE_H264_PPS_TRANSFORM_8X8_MODE BIT(0)
248
249 #define VE_H264_SHS 0x208
250 #define VE_H264_SHS_FIRST_SLICE_IN_PIC BIT(5)
251 #define VE_H264_SHS_FIELD_PIC BIT(4)
252 #define VE_H264_SHS_BOTTOM_FIELD BIT(3)
253 #define VE_H264_SHS_DIRECT_SPATIAL_MV_PRED BIT(2)
254
255 #define VE_H264_SHS2 0x20c
256 #define VE_H264_SHS2_NUM_REF_IDX_ACTIVE_OVRD BIT(12)
257
258 #define VE_H264_SHS_WP 0x210
259
260 #define VE_H264_SHS_QP 0x21c
261 #define VE_H264_SHS_QP_SCALING_MATRIX_DEFAULT BIT(24)
262
263 #define VE_H264_CTRL 0x220
264 #define VE_H264_CTRL_VLD_DATA_REQ_INT BIT(2)
265 #define VE_H264_CTRL_DECODE_ERR_INT BIT(1)
266 #define VE_H264_CTRL_SLICE_DECODE_INT BIT(0)
267
268 #define VE_H264_CTRL_INT_MASK (VE_H264_CTRL_VLD_DATA_REQ_INT | \
269 VE_H264_CTRL_DECODE_ERR_INT | \
270 VE_H264_CTRL_SLICE_DECODE_INT)
271
272 #define VE_H264_TRIGGER_TYPE 0x224
273 #define VE_H264_TRIGGER_TYPE_AVC_SLICE_DECODE (8 << 0)
274 #define VE_H264_TRIGGER_TYPE_INIT_SWDEC (7 << 0)
275
276 #define VE_H264_STATUS 0x228
277 #define VE_H264_STATUS_VLD_DATA_REQ_INT VE_H264_CTRL_VLD_DATA_REQ_INT
278 #define VE_H264_STATUS_DECODE_ERR_INT VE_H264_CTRL_DECODE_ERR_INT
279 #define VE_H264_STATUS_SLICE_DECODE_INT VE_H264_CTRL_SLICE_DECODE_INT
280
281 #define VE_H264_STATUS_INT_MASK VE_H264_CTRL_INT_MASK
282
283 #define VE_H264_CUR_MB_NUM 0x22c
284
285 #define VE_H264_VLD_ADDR 0x230
286 #define VE_H264_VLD_ADDR_FIRST BIT(30)
287 #define VE_H264_VLD_ADDR_LAST BIT(29)
288 #define VE_H264_VLD_ADDR_VALID BIT(28)
289 #define VE_H264_VLD_ADDR_VAL(x) (((x) & 0x0ffffff0) | ((x) >> 28))
290
291 #define VE_H264_VLD_OFFSET 0x234
292 #define VE_H264_VLD_LEN 0x238
293 #define VE_H264_VLD_END 0x23c
294 #define VE_H264_SDROT_CTRL 0x240
295 #define VE_H264_OUTPUT_FRAME_IDX 0x24c
296 #define VE_H264_EXTRA_BUFFER1 0x250
297 #define VE_H264_EXTRA_BUFFER2 0x254
298 #define VE_H264_BASIC_BITS 0x2dc
299 #define VE_AVC_SRAM_PORT_OFFSET 0x2e0
300 #define VE_AVC_SRAM_PORT_DATA 0x2e4
301
302 #define VE_ISP_INPUT_SIZE 0xa00
303 #define VE_ISP_INPUT_STRIDE 0xa04
304 #define VE_ISP_CTRL 0xa08
305 #define VE_ISP_INPUT_LUMA 0xa78
306 #define VE_ISP_INPUT_CHROMA 0xa7c
307
308 #define VE_AVC_PARAM 0xb04
309 #define VE_AVC_QP 0xb08
310 #define VE_AVC_MOTION_EST 0xb10
311 #define VE_AVC_CTRL 0xb14
312 #define VE_AVC_TRIGGER 0xb18
313 #define VE_AVC_STATUS 0xb1c
314 #define VE_AVC_BASIC_BITS 0xb20
315 #define VE_AVC_UNK_BUF 0xb60
316 #define VE_AVC_VLE_ADDR 0xb80
317 #define VE_AVC_VLE_END 0xb84
318 #define VE_AVC_VLE_OFFSET 0xb88
319 #define VE_AVC_VLE_MAX 0xb8c
320 #define VE_AVC_VLE_LENGTH 0xb90
321 #define VE_AVC_REF_LUMA 0xba0
322 #define VE_AVC_REF_CHROMA 0xba4
323 #define VE_AVC_REC_LUMA 0xbb0
324 #define VE_AVC_REC_CHROMA 0xbb4
325 #define VE_AVC_REF_SLUMA 0xbb8
326 #define VE_AVC_REC_SLUMA 0xbbc
327 #define VE_AVC_MB_INFO 0xbc0
328
329 #endif