summaryrefslogtreecommitdiff
path: root/drivers/media/platform/coda/coda_regs.h
blob: da5bb3212528adde20ec6f7f2d9b474ce8c0100b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * linux/drivers/media/platform/coda/coda_regs.h
 *
 * Copyright (C) 2012 Vista Silicon SL
 *    Javier Martin <javier.martin@vista-silicon.com>
 *    Xavier Duret
 */

#ifndef _REGS_CODA_H_
#define _REGS_CODA_H_

/* HW registers */
#define CODA_REG_BIT_CODE_RUN			0x000
#define		CODA_REG_RUN_ENABLE		(1 << 0)
#define CODA_REG_BIT_CODE_DOWN			0x004
#define		CODA_DOWN_ADDRESS_SET(x)	(((x) & 0xffff) << 16)
#define		CODA_DOWN_DATA_SET(x)		((x) & 0xffff)
#define CODA_REG_BIT_HOST_IN_REQ		0x008
#define CODA_REG_BIT_INT_CLEAR			0x00c
#define		CODA_REG_BIT_INT_CLEAR_SET	0x1
#define CODA_REG_BIT_INT_STATUS		0x010
#define CODA_REG_BIT_CODE_RESET		0x014
#define		CODA_REG_RESET_ENABLE		(1 << 0)
#define CODA_REG_BIT_CUR_PC			0x018
#define CODA9_REG_BIT_SW_RESET			0x024
#define		CODA9_SW_RESET_BPU_CORE   0x008
#define		CODA9_SW_RESET_BPU_BUS    0x010
#define		CODA9_SW_RESET_VCE_CORE   0x020
#define		CODA9_SW_RESET_VCE_BUS    0x040
#define		CODA9_SW_RESET_GDI_CORE   0x080
#define		CODA9_SW_RESET_GDI_BUS    0x100
#define CODA9_REG_BIT_SW_RESET_STATUS		0x034

/* Static SW registers */
#define CODA_REG_BIT_CODE_BUF_ADDR		0x100
#define CODA_REG_BIT_WORK_BUF_ADDR		0x104
#define CODA_REG_BIT_PARA_BUF_ADDR		0x108
#define CODA_REG_BIT_STREAM_CTRL		0x10c
#define		CODA7_STREAM_BUF_PIC_RESET	(1 << 4)
#define		CODADX6_STREAM_BUF_PIC_RESET	(1 << 3)
#define		CODA7_STREAM_BUF_PIC_FLUSH	(1 << 3)
#define		CODADX6_STREAM_BUF_PIC_FLUSH	(1 << 2)
#define		CODA7_STREAM_BUF_DYNALLOC_EN	(1 << 5)
#define		CODADX6_STREAM_BUF_DYNALLOC_EN	(1 << 4)
#define		CODADX6_STREAM_CHKDIS_OFFSET	(1 << 1)
#define		CODA7_STREAM_SEL_64BITS_ENDIAN	(1 << 1)
#define		CODA_STREAM_ENDIAN_SELECT	(1 << 0)
#define CODA_REG_BIT_FRAME_MEM_CTRL		0x110
#define		CODA9_FRAME_ENABLE_BWB		(1 << 12)
#define		CODA9_FRAME_TILED2LINEAR	(1 << 11)
#define		CODA_FRAME_CHROMA_INTERLEAVE	(1 << 2)
#define		CODA_IMAGE_ENDIAN_SELECT	(1 << 0)
#define CODA_REG_BIT_BIT_STREAM_PARAM		0x114
#define		CODA_BIT_STREAM_END_FLAG	(1 << 2)
#define		CODA_BIT_DEC_SEQ_INIT_ESCAPE	(1 << 0)
#define CODA_REG_BIT_TEMP_BUF_ADDR		0x118
#define CODA_REG_BIT_RD_PTR(x)			(0x120 + 8 * (x))
#define CODA_REG_BIT_WR_PTR(x)			(0x124 + 8 * (x))
#define CODA_REG_BIT_FRM_DIS_FLG(x)		(0x150 + 4 * (x))
#define CODADX6_REG_BIT_SEARCH_RAM_BASE_ADDR	0x140
#define CODA7_REG_BIT_AXI_SRAM_USE		0x140
#define		CODA9_USE_HOST_BTP_ENABLE	(1 << 13)
#define		CODA9_USE_HOST_OVL_ENABLE	(1 << 12)
#define		CODA7_USE_HOST_ME_ENABLE	(1 << 11)
#define		CODA9_USE_HOST_DBK_ENABLE	(3 << 10)
#define		CODA7_USE_HOST_OVL_ENABLE	(1 << 10)
#define		CODA7_USE_HOST_DBK_ENABLE	(1 << 9)
#define		CODA9_USE_HOST_IP_ENABLE	(1 << 9)
#define		CODA7_USE_HOST_IP_ENABLE	(1 << 8)
#define		CODA9_USE_HOST_BIT_ENABLE	(1 << 8)
#define		CODA7_USE_HOST_BIT_ENABLE	(1 << 7)
#define		CODA9_USE_BTP_ENABLE		(1 << 5)
#define		CODA7_USE_ME_ENABLE		(1 << 4)
#define		CODA9_USE_OVL_ENABLE		(1 << 4)
#define		CODA7_USE_OVL_ENABLE		(1 << 3)
#define		CODA9_USE_DBK_ENABLE		(3 << 2)
#define		CODA7_USE_DBK_ENABLE		(1 << 2)
#define		CODA7_USE_IP_ENABLE		(1 << 1)
#define		CODA7_USE_BIT_ENABLE		(1 << 0)

#define CODA_REG_BIT_BUSY			0x160
#define		CODA_REG_BIT_BUSY_FLAG		1
#define CODA_REG_BIT_RUN_COMMAND		0x164
#define		CODA_COMMAND_SEQ_INIT		1
#define		CODA_COMMAND_SEQ_END		2
#define		CODA_COMMAND_PIC_RUN		3
#define		CODA_COMMAND_SET_FRAME_BUF	4
#define		CODA_COMMAND_ENCODE_HEADER	5
#define		CODA_COMMAND_ENC_PARA_SET	6
#define		CODA_COMMAND_DEC_PARA_SET	7
#define		CODA_COMMAND_DEC_BUF_FLUSH	8
#define		CODA_COMMAND_RC_CHANGE_PARAMETER 9
#define		CODA_COMMAND_FIRMWARE_GET	0xf
#define CODA_REG_BIT_RUN_INDEX			0x168
#define		CODA_INDEX_SET(x)		((x) & 0x3)
#define CODA_REG_BIT_RUN_COD_STD		0x16c
#define		CODADX6_MODE_DECODE_MP4		0
#define		CODADX6_MODE_ENCODE_MP4		1
#define		CODADX6_MODE_DECODE_H264	2
#define		CODADX6_MODE_ENCODE_H264	3
#define		CODA7_MODE_DECODE_H264		0
#define		CODA7_MODE_DECODE_VC1		1
#define		CODA7_MODE_DECODE_MP2		2
#define		CODA7_MODE_DECODE_MP4		3
#define		CODA7_MODE_DECODE_DV3		3
#define		CODA7_MODE_DECODE_RV		4
#define		CODA7_MODE_DECODE_MJPG		5
#define		CODA7_MODE_ENCODE_H264		8
#define		CODA7_MODE_ENCODE_MP4		11
#define		CODA7_MODE_ENCODE_MJPG		13
#define		CODA9_MODE_DECODE_H264		0
#define		CODA9_MODE_DECODE_VC1		1
#define		CODA9_MODE_DECODE_MP2		2
#define		CODA9_MODE_DECODE_MP4		3
#define		CODA9_MODE_DECODE_DV3		3
#define		CODA9_MODE_DECODE_RV		4
#define		CODA9_MODE_DECODE_AVS		5
#define		CODA9_MODE_DECODE_MJPG		6
#define		CODA9_MODE_DECODE_VPX		7
#define		CODA9_MODE_ENCODE_H264		8
#define		CODA9_MODE_ENCODE_MP4		11
#define		CODA9_MODE_ENCODE_MJPG		13
#define		CODA_MODE_INVALID		0xffff
#define CODA_REG_BIT_INT_ENABLE		0x170
#define		CODA_INT_INTERRUPT_ENABLE	(1 << 3)
#define CODA_REG_BIT_INT_REASON			0x174
#define CODA7_REG_BIT_RUN_AUX_STD		0x178
#define		CODA_MP4_AUX_MPEG4		0
#define		CODA_MP4_AUX_DIVX3		1
#define		CODA_VPX_AUX_THO		0
#define		CODA_VPX_AUX_VP6		1
#define		CODA_VPX_AUX_VP8		2
#define		CODA_H264_AUX_AVC		0
#define		CODA_H264_AUX_MVC		1

/*
 * Commands' mailbox:
 * registers with offsets in the range 0x180-0x1d0
 * have different meaning depending on the command being
 * issued.
 */

/* Decoder Sequence Initialization */
#define CODA_CMD_DEC_SEQ_BB_START		0x180
#define CODA_CMD_DEC_SEQ_BB_SIZE		0x184
#define CODA_CMD_DEC_SEQ_OPTION			0x188
#define		CODA_NO_INT_ENABLE			(1 << 10)
#define		CODA_REORDER_ENABLE			(1 << 1)
#define		CODADX6_QP_REPORT			(1 << 0)
#define		CODA7_MP4_DEBLK_ENABLE			(1 << 0)
#define CODA_CMD_DEC_SEQ_SRC_SIZE		0x18c
#define CODA_CMD_DEC_SEQ_START_BYTE		0x190
#define CODA_CMD_DEC_SEQ_PS_BB_START		0x194
#define CODA_CMD_DEC_SEQ_PS_BB_SIZE		0x198
#define CODA_CMD_DEC_SEQ_JPG_THUMB_EN		0x19c
#define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS		0x19c
#define		CODA_MP4_CLASS_MPEG4			0
#define CODA_CMD_DEC_SEQ_X264_MV_EN		0x19c
#define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE		0x1a0

#define CODA7_RET_DEC_SEQ_ASPECT		0x1b0
#define CODA9_RET_DEC_SEQ_BITRATE		0x1b4
#define CODA_RET_DEC_SEQ_SUCCESS		0x1c0
#define CODA_RET_DEC_SEQ_SRC_FMT		0x1c4 /* SRC_SIZE on CODA7 */
#define CODA_RET_DEC_SEQ_SRC_SIZE		0x1c4
#define CODA_RET_DEC_SEQ_SRC_F_RATE		0x1c8
#define CODA9_RET_DEC_SEQ_ASPECT		0x1c8
#define CODA_RET_DEC_SEQ_FRAME_NEED		0x1cc
#define CODA_RET_DEC_SEQ_FRAME_DELAY		0x1d0
#define CODA_RET_DEC_SEQ_INFO			0x1d4
#define CODA_RET_DEC_SEQ_CROP_LEFT_RIGHT	0x1d8
#define CODA_RET_DEC_SEQ_CROP_TOP_BOTTOM	0x1dc
#define CODA_RET_DEC_SEQ_NEXT_FRAME_NUM		0x1e0
#define CODA_RET_DEC_SEQ_ERR_REASON		0x1e0
#define CODA_RET_DEC_SEQ_FRATE_NR		0x1e4
#define CODA_RET_DEC_SEQ_FRATE_DR		0x1e8
#define CODA_RET_DEC_SEQ_JPG_PARA		0x1e4
#define CODA_RET_DEC_SEQ_JPG_THUMB_IND		0x1e8
#define CODA7_RET_DEC_SEQ_HEADER_REPORT		0x1ec

/* Decoder Picture Run */
#define CODA_CMD_DEC_PIC_ROT_MODE		0x180
#define CODA_CMD_DEC_PIC_ROT_ADDR_Y		0x184
#define CODA9_CMD_DEC_PIC_ROT_INDEX		0x184
#define CODA_CMD_DEC_PIC_ROT_ADDR_CB		0x188
#define CODA9_CMD_DEC_PIC_ROT_ADDR_Y		0x188
#define CODA_CMD_DEC_PIC_ROT_ADDR_CR		0x18c
#define CODA9_CMD_DEC_PIC_ROT_ADDR_CB		0x18c
#define CODA_CMD_DEC_PIC_ROT_STRIDE		0x190
#define CODA9_CMD_DEC_PIC_ROT_ADDR_CR		0x190
#define CODA9_CMD_DEC_PIC_ROT_STRIDE		0x1b8

#define CODA_CMD_DEC_PIC_OPTION			0x194
#define		CODA_PRE_SCAN_EN			(1 << 0)
#define		CODA_PRE_SCAN_MODE_DECODE		(0 << 1)
#define		CODA_PRE_SCAN_MODE_RETURN		(1 << 1)
#define		CODA_IFRAME_SEARCH_EN			(1 << 2)
#define		CODA_SKIP_FRAME_MODE			(0x3 << 3)
#define CODA_CMD_DEC_PIC_SKIP_NUM		0x198
#define CODA_CMD_DEC_PIC_CHUNK_SIZE		0x19c
#define CODA_CMD_DEC_PIC_BB_START		0x1a0
#define CODA_CMD_DEC_PIC_START_BYTE		0x1a4
#define CODA_RET_DEC_PIC_SIZE			0x1bc
#define CODA_RET_DEC_PIC_FRAME_NUM		0x1c0
#define CODA_RET_DEC_PIC_FRAME_IDX		0x1c4
#define CODA_RET_DEC_PIC_ERR_MB			0x1c8
#define CODA_RET_DEC_PIC_TYPE			0x1cc
#define		CODA_PIC_TYPE_MASK			0x7
#define		CODA_PIC_TYPE_MASK_VC1			0x3f
#define		CODA9_PIC_TYPE_FIRST_MASK		(0x7 << 3)
#define		CODA9_PIC_TYPE_IDR_MASK			(0x3 << 6)
#define		CODA7_PIC_TYPE_H264_NPF_MASK		(0x3 << 16)
#define		CODA7_PIC_TYPE_INTERLACED		(1 << 18)
#define CODA_RET_DEC_PIC_POST			0x1d0
#define CODA_RET_DEC_PIC_MVC_REPORT		0x1d0
#define CODA_RET_DEC_PIC_OPTION			0x1d4
#define CODA_RET_DEC_PIC_SUCCESS		0x1d8
#define CODA_RET_DEC_PIC_CUR_IDX		0x1dc
#define CODA_RET_DEC_PIC_CROP_LEFT_RIGHT	0x1e0
#define CODA_RET_DEC_PIC_CROP_TOP_BOTTOM	0x1e4
#define CODA_RET_DEC_PIC_FRAME_NEED		0x1ec

#define CODA9_RET_DEC_PIC_VP8_PIC_REPORT	0x1e8
#define CODA9_RET_DEC_PIC_ASPECT		0x1f0
#define CODA9_RET_DEC_PIC_VP8_SCALE_INFO	0x1f0
#define CODA9_RET_DEC_PIC_FRATE_NR		0x1f4
#define CODA9_RET_DEC_PIC_FRATE_DR		0x1f8

/* Encoder Sequence Initialization */
#define CODA_CMD_ENC_SEQ_BB_START				0x180
#define CODA_CMD_ENC_SEQ_BB_SIZE				0x184
#define CODA_CMD_ENC_SEQ_OPTION				0x188
#define		CODA7_OPTION_AVCINTRA16X16ONLY_OFFSET		9
#define		CODA9_OPTION_MVC_PREFIX_NAL_OFFSET		9
#define		CODA7_OPTION_GAMMA_OFFSET			8
#define		CODA9_OPTION_MVC_PARASET_REFRESH_OFFSET		8
#define		CODA7_OPTION_RCQPMAX_OFFSET			7
#define		CODA9_OPTION_GAMMA_OFFSET			7
#define		CODADX6_OPTION_GAMMA_OFFSET			7
#define		CODA7_OPTION_RCQPMIN_OFFSET			6
#define		CODA9_OPTION_RCQPMAX_OFFSET			6
#define		CODA_OPTION_LIMITQP_OFFSET			6
#define		CODA_OPTION_RCINTRAQP_OFFSET			5
#define		CODA_OPTION_FMO_OFFSET				4
#define		CODA9_OPTION_MVC_INTERVIEW_OFFSET		4
#define		CODA_OPTION_AVC_AUD_OFFSET			2
#define		CODA_OPTION_SLICEREPORT_OFFSET			1
#define CODA_CMD_ENC_SEQ_COD_STD				0x18c
#define		CODA_STD_MPEG4					0
#define		CODA9_STD_H264					0
#define		CODA_STD_H263					1
#define		CODA_STD_H264					2
#define		CODA9_STD_MPEG4					3

#define CODA_CMD_ENC_SEQ_SRC_SIZE				0x190
#define		CODA7_PICWIDTH_OFFSET				16
#define		CODA7_PICWIDTH_MASK				0xffff
#define		CODADX6_PICWIDTH_OFFSET				10
#define		CODADX6_PICWIDTH_MASK				0x3ff
#define		CODA_PICHEIGHT_OFFSET				0
#define		CODADX6_PICHEIGHT_MASK				0x3ff
#define		CODA7_PICHEIGHT_MASK				0xffff
#define CODA_CMD_ENC_SEQ_SRC_F_RATE				0x194
#define		CODA_FRATE_RES_OFFSET				0
#define		CODA_FRATE_RES_MASK				0xffff
#define		CODA_FRATE_DIV_OFFSET				16
#define		CODA_FRATE_DIV_MASK				0xffff
#define CODA_CMD_ENC_SEQ_MP4_PARA				0x198
#define		CODA_MP4PARAM_VERID_OFFSET			6
#define		CODA_MP4PARAM_VERID_MASK			0x01
#define		CODA_MP4PARAM_INTRADCVLCTHR_OFFSET		2
#define		CODA_MP4PARAM_INTRADCVLCTHR_MASK		0x07
#define		CODA_MP4PARAM_REVERSIBLEVLCENABLE_OFFSET	1
#define		CODA_MP4PARAM_REVERSIBLEVLCENABLE_MASK		0x01
#define		CODA_MP4PARAM_DATAPARTITIONENABLE_OFFSET	0
#define		CODA_MP4PARAM_DATAPARTITIONENABLE_MASK		0x01
#define CODA_CMD_ENC_SEQ_263_PARA				0x19c
#define		CODA_263PARAM_ANNEXJENABLE_OFFSET		2
#define		CODA_263PARAM_ANNEXJENABLE_MASK		0x01
#define		CODA_263PARAM_ANNEXKENABLE_OFFSET		1
#define		CODA_263PARAM_ANNEXKENABLE_MASK		0x01
#define		CODA_263PARAM_ANNEXTENABLE_OFFSET		0
#define		CODA_263PARAM_ANNEXTENABLE_MASK		0x01
#define CODA_CMD_ENC_SEQ_264_PARA				0x1a0
#define		CODA_264PARAM_DEBLKFILTEROFFSETBETA_OFFSET	12
#define		CODA_264PARAM_DEBLKFILTEROFFSETBETA_MASK	0x0f
#define		CODA_264PARAM_DEBLKFILTEROFFSETALPHA_OFFSET	8
#define		CODA_264PARAM_DEBLKFILTEROFFSETALPHA_MASK	0x0f
#define		CODA_264PARAM_DISABLEDEBLK_OFFSET		6
#define		CODA_264PARAM_DISABLEDEBLK_MASK		0x03
#define		CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_OFFSET	5
#define		CODA_264PARAM_CONSTRAINEDINTRAPREDFLAG_MASK	0x01
#define		CODA_264PARAM_CHROMAQPOFFSET_OFFSET		0
#define		CODA_264PARAM_CHROMAQPOFFSET_MASK		0x1f
#define CODA_CMD_ENC_SEQ_SLICE_MODE				0x1a4
#define		CODA_SLICING_SIZE_OFFSET			2
#define		CODA_SLICING_SIZE_MASK				0x3fffffff
#define		CODA_SLICING_UNIT_OFFSET			1
#define		CODA_SLICING_UNIT_MASK				0x01
#define		CODA_SLICING_MODE_OFFSET			0
#define		CODA_SLICING_MODE_MASK				0x01
#define CODA_CMD_ENC_SEQ_GOP_SIZE				0x1a8
#define		CODA_GOP_SIZE_OFFSET				0
#define		CODA_GOP_SIZE_MASK				0x3f
#define CODA_CMD_ENC_SEQ_RC_PARA				0x1ac
#define		CODA_RATECONTROL_AUTOSKIP_OFFSET		31
#define		CODA_RATECONTROL_AUTOSKIP_MASK			0x01
#define		CODA_RATECONTROL_INITIALDELAY_OFFSET		16
#define		CODA_RATECONTROL_INITIALDELAY_MASK		0x7fff
#define		CODA_RATECONTROL_BITRATE_OFFSET		1
#define		CODA_RATECONTROL_BITRATE_MASK			0x7fff
#define		CODA_RATECONTROL_ENABLE_OFFSET			0
#define		CODA_RATECONTROL_ENABLE_MASK			0x01
#define CODA_CMD_ENC_SEQ_RC_BUF_SIZE				0x1b0
#define CODA_CMD_ENC_SEQ_INTRA_REFRESH				0x1b4
#define CODADX6_CMD_ENC_SEQ_FMO					0x1b8
#define		CODA_FMOPARAM_TYPE_OFFSET			4
#define		CODA_FMOPARAM_TYPE_MASK				1
#define		CODA_FMOPARAM_SLICENUM_OFFSET			0
#define		CODA_FMOPARAM_SLICENUM_MASK			0x0f
#define CODADX6_CMD_ENC_SEQ_INTRA_QP				0x1bc
#define CODA7_CMD_ENC_SEQ_SEARCH_BASE				0x1b8
#define CODA7_CMD_ENC_SEQ_SEARCH_SIZE				0x1bc
#define CODA7_CMD_ENC_SEQ_INTRA_QP				0x1c4
#define CODA_CMD_ENC_SEQ_RC_QP_MIN_MAX				0x1c8
#define		CODA_QPMIN_OFFSET				8
#define		CODA_QPMIN_MASK					0x3f
#define		CODA_QPMAX_OFFSET				0
#define		CODA_QPMAX_MASK					0x3f
#define CODA_CMD_ENC_SEQ_RC_GAMMA				0x1cc
#define		CODA_GAMMA_OFFSET				0
#define		CODA_GAMMA_MASK					0xffff
#define CODA_CMD_ENC_SEQ_RC_INTERVAL_MODE			0x1d0
#define CODA9_CMD_ENC_SEQ_INTRA_WEIGHT				0x1d4
#define CODA9_CMD_ENC_SEQ_ME_OPTION				0x1d8
#define CODA_RET_ENC_SEQ_SUCCESS				0x1c0

#define CODA_CMD_ENC_SEQ_JPG_PARA				0x198
#define CODA_CMD_ENC_SEQ_JPG_RST_INTERVAL			0x19C
#define CODA_CMD_ENC_SEQ_JPG_THUMB_EN				0x1a0
#define CODA_CMD_ENC_SEQ_JPG_THUMB_SIZE				0x1a4
#define CODA_CMD_ENC_SEQ_JPG_THUMB_OFFSET			0x1a8

/* Encoder Parameter Change */
#define CODA_CMD_ENC_PARAM_CHANGE_ENABLE	0x180
#define		CODA_PARAM_CHANGE_RC_GOP			BIT(0)
#define		CODA_PARAM_CHANGE_RC_INTRA_QP			BIT(1)
#define		CODA_PARAM_CHANGE_RC_BITRATE			BIT(2)
#define		CODA_PARAM_CHANGE_RC_FRAME_RATE			BIT(3)
#define		CODA_PARAM_CHANGE_INTRA_MB_NUM			BIT(4)
#define		CODA_PARAM_CHANGE_SLICE_MODE			BIT(5)
#define		CODA_PARAM_CHANGE_HEC_MODE			BIT(6)
#define CODA_CMD_ENC_PARAM_RC_GOP		0x184
#define CODA_CMD_ENC_PARAM_RC_INTRA_QP		0x188
#define CODA_CMD_ENC_PARAM_RC_BITRATE		0x18c
#define CODA_CMD_ENC_PARAM_RC_FRAME_RATE	0x190
#define CODA_CMD_ENC_PARAM_INTRA_MB_NUM		0x194
#define CODA_CMD_ENC_PARAM_SLICE_MODE		0x198
#define CODA_CMD_ENC_PARAM_HEC_MODE		0x19c
#define CODA_RET_ENC_PARAM_CHANGE_SUCCESS	0x1c0

/* Encoder Picture Run */
#define CODA9_CMD_ENC_PIC_SRC_INDEX		0x180
#define CODA9_CMD_ENC_PIC_SRC_STRIDE		0x184
#define CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC	0x1a4
#define CODA9_CMD_ENC_PIC_SRC_ADDR_Y		0x1a8
#define CODA9_CMD_ENC_PIC_SRC_ADDR_CB		0x1ac
#define CODA9_CMD_ENC_PIC_SRC_ADDR_CR		0x1b0
#define CODA_CMD_ENC_PIC_SRC_ADDR_Y	0x180
#define CODA_CMD_ENC_PIC_SRC_ADDR_CB	0x184
#define CODA_CMD_ENC_PIC_SRC_ADDR_CR	0x188
#define CODA_CMD_ENC_PIC_QS		0x18c
#define CODA_CMD_ENC_PIC_ROT_MODE	0x190
#define		CODA_ROT_MIR_ENABLE				(1 << 4)
#define		CODA_ROT_0					(0x0 << 0)
#define		CODA_ROT_90					(0x1 << 0)
#define		CODA_ROT_180					(0x2 << 0)
#define		CODA_ROT_270					(0x3 << 0)
#define		CODA_MIR_NONE					(0x0 << 2)
#define		CODA_MIR_VER					(0x1 << 2)
#define		CODA_MIR_HOR					(0x2 << 2)
#define		CODA_MIR_VER_HOR				(0x3 << 2)
#define CODA_CMD_ENC_PIC_OPTION		0x194
#define		CODA_FORCE_IPICTURE				BIT(1)
#define		CODA_REPORT_MB_INFO				BIT(3)
#define		CODA_REPORT_MV_INFO				BIT(4)
#define		CODA_REPORT_SLICE_INFO				BIT(5)
#define CODA_CMD_ENC_PIC_BB_START	0x198
#define CODA_CMD_ENC_PIC_BB_SIZE	0x19c
#define CODA_RET_ENC_FRAME_NUM		0x1c0
#define CODA_RET_ENC_PIC_TYPE		0x1c4
#define CODA_RET_ENC_PIC_FRAME_IDX	0x1c8
#define CODA_RET_ENC_PIC_SLICE_NUM	0x1cc
#define CODA_RET_ENC_PIC_FLAG		0x1d0
#define CODA_RET_ENC_PIC_SUCCESS	0x1d8

/* Set Frame Buffer */
#define CODA_CMD_SET_FRAME_BUF_NUM		0x180
#define CODA_CMD_SET_FRAME_BUF_STRIDE		0x184
#define CODA_CMD_SET_FRAME_SLICE_BB_START	0x188
#define CODA_CMD_SET_FRAME_SLICE_BB_SIZE	0x18c
#define CODA9_CMD_SET_FRAME_SUBSAMP_A		0x188
#define CODA9_CMD_SET_FRAME_SUBSAMP_B		0x18c
#define CODA7_CMD_SET_FRAME_AXI_BIT_ADDR	0x190
#define CODA7_CMD_SET_FRAME_AXI_IPACDC_ADDR	0x194
#define CODA7_CMD_SET_FRAME_AXI_DBKY_ADDR	0x198
#define CODA7_CMD_SET_FRAME_AXI_DBKC_ADDR	0x19c
#define CODA7_CMD_SET_FRAME_AXI_OVL_ADDR	0x1a0
#define CODA7_CMD_SET_FRAME_MAX_DEC_SIZE	0x1a4
#define CODA9_CMD_SET_FRAME_AXI_BTP_ADDR	0x1a4
#define CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE	0x1a8
#define CODA9_CMD_SET_FRAME_CACHE_SIZE		0x1a8
#define CODA9_CMD_SET_FRAME_CACHE_CONFIG	0x1ac
#define		CODA9_CACHE_BYPASS_OFFSET		28
#define		CODA9_CACHE_DUALCONF_OFFSET		26
#define		CODA9_CACHE_PAGEMERGE_OFFSET		24
#define		CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET	16
#define		CODA9_CACHE_CB_BUFFER_SIZE_OFFSET	8
#define		CODA9_CACHE_CR_BUFFER_SIZE_OFFSET	0
#define CODA9_CMD_SET_FRAME_SUBSAMP_A_MVC	0x1b0
#define CODA9_CMD_SET_FRAME_SUBSAMP_B_MVC	0x1b4
#define CODA9_CMD_SET_FRAME_DP_BUF_BASE		0x1b0
#define CODA9_CMD_SET_FRAME_DP_BUF_SIZE		0x1b4
#define CODA9_CMD_SET_FRAME_MAX_DEC_SIZE	0x1b8
#define CODA9_CMD_SET_FRAME_DELAY		0x1bc

/* Encoder Header */
#define CODA_CMD_ENC_HEADER_CODE	0x180
#define		CODA_GAMMA_OFFSET	0
#define		CODA_HEADER_H264_SPS	0
#define		CODA_HEADER_H264_PPS	1
#define		CODA_HEADER_MP4V_VOL	0
#define		CODA_HEADER_MP4V_VOS	1
#define		CODA_HEADER_MP4V_VIS	2
#define		CODA9_HEADER_FRAME_CROP	(1 << 3)
#define CODA_CMD_ENC_HEADER_BB_START	0x184
#define CODA_CMD_ENC_HEADER_BB_SIZE	0x188
#define CODA9_CMD_ENC_HEADER_FRAME_CROP_H	0x18c
#define CODA9_CMD_ENC_HEADER_FRAME_CROP_V	0x190

/* Get Version */
#define CODA_CMD_FIRMWARE_VERNUM		0x1c0
#define		CODA_FIRMWARE_PRODUCT(x)	(((x) >> 16) & 0xffff)
#define		CODA_FIRMWARE_MAJOR(x)		(((x) >> 12) & 0x0f)
#define		CODA_FIRMWARE_MINOR(x)		(((x) >> 8) & 0x0f)
#define		CODA_FIRMWARE_RELEASE(x)	((x) & 0xff)
#define		CODA_FIRMWARE_VERNUM(product, major, minor, release)	\
			((product) << 16 | ((major) << 12) |		\
			((minor) << 8) | (release))
#define CODA9_CMD_FIRMWARE_CODE_REV		0x1c4

#define CODA9_GDMA_BASE				0x1000
#define CODA9_GDI_CONTROL			(CODA9_GDMA_BASE + 0x034)
#define CODA9_GDI_PIC_INIT_HOST			(CODA9_GDMA_BASE + 0x038)
#define CODA9_GDI_STATUS			(CODA9_GDMA_BASE + 0x080)
#define CODA9_GDI_WPROT_ERR_CLR			(CODA9_GDMA_BASE + 0x0a0)
#define CODA9_GDI_WPROT_RGN_EN			(CODA9_GDMA_BASE + 0x0ac)

#define CODA9_GDI_BUS_CTRL			(CODA9_GDMA_BASE + 0x0f0)
#define CODA9_GDI_BUS_STATUS			(CODA9_GDMA_BASE + 0x0f4)

#define CODA9_GDI_INFO_CONTROL			(CODA9_GDMA_BASE + 0x400)
#define CODA9_GDI_INFO_PIC_SIZE			(CODA9_GDMA_BASE + 0x404)
#define CODA9_GDI_INFO_BASE_Y			(CODA9_GDMA_BASE + 0x408)
#define CODA9_GDI_INFO_BASE_CB			(CODA9_GDMA_BASE + 0x40c)
#define CODA9_GDI_INFO_BASE_CR			(CODA9_GDMA_BASE + 0x410)

#define CODA9_GDI_XY2_CAS_0			(CODA9_GDMA_BASE + 0x800)
#define CODA9_GDI_XY2_CAS_F			(CODA9_GDMA_BASE + 0x83c)

#define CODA9_GDI_XY2_BA_0			(CODA9_GDMA_BASE + 0x840)
#define CODA9_GDI_XY2_BA_1			(CODA9_GDMA_BASE + 0x844)
#define CODA9_GDI_XY2_BA_2			(CODA9_GDMA_BASE + 0x848)
#define CODA9_GDI_XY2_BA_3			(CODA9_GDMA_BASE + 0x84c)

#define CODA9_GDI_XY2_RAS_0			(CODA9_GDMA_BASE + 0x850)
#define CODA9_GDI_XY2_RAS_F			(CODA9_GDMA_BASE + 0x88c)

#define CODA9_GDI_XY2_RBC_CONFIG		(CODA9_GDMA_BASE + 0x890)
#define		CODA9_XY2RBC_SEPARATE_MAP		BIT(19)
#define		CODA9_XY2RBC_TOP_BOT_SPLIT		BIT(18)
#define		CODA9_XY2RBC_TILED_MAP			BIT(17)
#define		CODA9_XY2RBC_CA_INC_HOR			BIT(16)
#define CODA9_GDI_RBC2_AXI_0			(CODA9_GDMA_BASE + 0x8a0)
#define CODA9_GDI_RBC2_AXI_1F			(CODA9_GDMA_BASE + 0x91c)
#define	CODA9_GDI_TILEDBUF_BASE			(CODA9_GDMA_BASE + 0x920)

#define CODA9_JPEG_BASE				0x3000
#define CODA9_REG_JPEG_PIC_START		(CODA9_JPEG_BASE + 0x000)
#define CODA9_REG_JPEG_PIC_STATUS		(CODA9_JPEG_BASE + 0x004)
#define		CODA9_JPEG_STATUS_OVERFLOW		BIT(3)
#define		CODA9_JPEG_STATUS_BBC_INT		BIT(2)
#define		CODA9_JPEG_STATUS_ERROR			BIT(1)
#define		CODA9_JPEG_STATUS_DONE			BIT(0)
#define CODA9_REG_JPEG_PIC_ERRMB		(CODA9_JPEG_BASE + 0x008)
#define		CODA9_JPEG_ERRMB_RESTART_IDX_MASK	(0xf << 24)
#define		CODA9_JPEG_ERRMB_MCU_POS_X_MASK		(0xfff << 12)
#define		CODA9_JPEG_ERRMB_MCU_POS_Y_MASK		0xfff
#define CODA9_REG_JPEG_PIC_CTRL			(CODA9_JPEG_BASE + 0x010)
#define		CODA9_JPEG_PIC_CTRL_USER_HUFFMAN_EN	BIT(6)
#define		CODA9_JPEG_PIC_CTRL_TC_DIRECTION	BIT(4)
#define		CODA9_JPEG_PIC_CTRL_ENCODER_EN		BIT(3)
#define CODA9_REG_JPEG_PIC_SIZE			(CODA9_JPEG_BASE + 0x014)
#define CODA9_REG_JPEG_MCU_INFO			(CODA9_JPEG_BASE + 0x018)
#define		CODA9_JPEG_MCU_BLOCK_NUM_OFFSET		16
#define		CODA9_JPEG_COMP_NUM_OFFSET		12
#define		CODA9_JPEG_COMP0_INFO_OFFSET		8
#define		CODA9_JPEG_COMP1_INFO_OFFSET		4
#define		CODA9_JPEG_COMP2_INFO_OFFSET		0
#define CODA9_REG_JPEG_ROT_INFO			(CODA9_JPEG_BASE + 0x01c)
#define		CODA9_JPEG_ROT_MIR_ENABLE		BIT(4)
#define		CODA9_JPEG_ROT_MIR_MODE_MASK		0xf
#define CODA9_REG_JPEG_SCL_INFO			(CODA9_JPEG_BASE + 0x020)
#define		CODA9_JPEG_SCL_ENABLE			BIT(4)
#define		CODA9_JPEG_SCL_HOR_MODE_MASK		(0x3 << 2)
#define		CODA9_JPEG_SCL_VER_MODE_MASK		(0x3 << 0)
#define CODA9_REG_JPEG_IF_INFO			(CODA9_JPEG_BASE + 0x024)
#define		CODA9_JPEG_SENS_IF_CLR			BIT(1)
#define		CODA9_JPEG_DISP_IF_CLR			BIT(0)
#define CODA9_REG_JPEG_OP_INFO			(CODA9_JPEG_BASE + 0x02c)
#define		CODA9_JPEG_BUS_REQ_NUM_OFFSET		0
#define		CODA9_JPEG_BUS_REQ_NUM_MASK		0x7
#define CODA9_REG_JPEG_DPB_CONFIG		(CODA9_JPEG_BASE + 0x030)
#define CODA9_REG_JPEG_DPB_BASE00		(CODA9_JPEG_BASE + 0x040)
#define CODA9_REG_JPEG_HUFF_CTRL		(CODA9_JPEG_BASE + 0x080)
#define CODA9_REG_JPEG_HUFF_ADDR		(CODA9_JPEG_BASE + 0x084)
#define CODA9_REG_JPEG_HUFF_DATA		(CODA9_JPEG_BASE + 0x088)
#define CODA9_REG_JPEG_QMAT_CTRL		(CODA9_JPEG_BASE + 0x090)
#define CODA9_REG_JPEG_QMAT_ADDR		(CODA9_JPEG_BASE + 0x094)
#define CODA9_REG_JPEG_QMAT_DATA		(CODA9_JPEG_BASE + 0x098)
#define CODA9_REG_JPEG_RST_INTVAL		(CODA9_JPEG_BASE + 0x0b0)
#define CODA9_REG_JPEG_RST_INDEX		(CODA9_JPEG_BASE + 0x0b4)
#define CODA9_REG_JPEG_RST_COUNT		(CODA9_JPEG_BASE + 0x0b8)
#define CODA9_REG_JPEG_DPCM_DIFF_Y		(CODA9_JPEG_BASE + 0x0f0)
#define CODA9_REG_JPEG_DPCM_DIFF_CB		(CODA9_JPEG_BASE + 0x0f4)
#define CODA9_REG_JPEG_DPCM_DIFF_CR		(CODA9_JPEG_BASE + 0x0f8)
#define CODA9_REG_JPEG_GBU_CTRL			(CODA9_JPEG_BASE + 0x100)
#define CODA9_REG_JPEG_GBU_BT_PTR		(CODA9_JPEG_BASE + 0x110)
#define CODA9_REG_JPEG_GBU_WD_PTR		(CODA9_JPEG_BASE + 0x114)
#define CODA9_REG_JPEG_GBU_TT_CNT		(CODA9_JPEG_BASE + 0x118)
#define CODA9_REG_JPEG_GBU_BBSR			(CODA9_JPEG_BASE + 0x140)
#define CODA9_REG_JPEG_GBU_BBER			(CODA9_JPEG_BASE + 0x144)
#define CODA9_REG_JPEG_GBU_BBIR			(CODA9_JPEG_BASE + 0x148)
#define CODA9_REG_JPEG_GBU_BBHR			(CODA9_JPEG_BASE + 0x14c)
#define CODA9_REG_JPEG_GBU_BCNT			(CODA9_JPEG_BASE + 0x158)
#define CODA9_REG_JPEG_GBU_FF_RPTR		(CODA9_JPEG_BASE + 0x160)
#define CODA9_REG_JPEG_GBU_FF_WPTR		(CODA9_JPEG_BASE + 0x164)
#define CODA9_REG_JPEG_BBC_END_ADDR		(CODA9_JPEG_BASE + 0x208)
#define CODA9_REG_JPEG_BBC_WR_PTR		(CODA9_JPEG_BASE + 0x20c)
#define CODA9_REG_JPEG_BBC_RD_PTR		(CODA9_JPEG_BASE + 0x210)
#define CODA9_REG_JPEG_BBC_EXT_ADDR		(CODA9_JPEG_BASE + 0x214)
#define CODA9_REG_JPEG_BBC_INT_ADDR		(CODA9_JPEG_BASE + 0x218)
#define CODA9_REG_JPEG_BBC_DATA_CNT		(CODA9_JPEG_BASE + 0x21c)
#define CODA9_REG_JPEG_BBC_COMMAND		(CODA9_JPEG_BASE + 0x220)
#define CODA9_REG_JPEG_BBC_BUSY			(CODA9_JPEG_BASE + 0x224)
#define CODA9_REG_JPEG_BBC_CTRL			(CODA9_JPEG_BASE + 0x228)
#define CODA9_REG_JPEG_BBC_CUR_POS		(CODA9_JPEG_BASE + 0x22c)
#define CODA9_REG_JPEG_BBC_BAS_ADDR		(CODA9_JPEG_BASE + 0x230)
#define CODA9_REG_JPEG_BBC_STRM_CTRL		(CODA9_JPEG_BASE + 0x234)
#define CODA9_REG_JPEG_BBC_FLUSH_CMD		(CODA9_JPEG_BASE + 0x238)

#endif