162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Register definition file for Samsung MFC V5.1 Interface (FIMV) driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Kamil Debski, Copyright (c) 2010 Samsung Electronics
662306a36Sopenharmony_ci * http://www.samsung.com/
762306a36Sopenharmony_ci*/
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef _REGS_FIMV_H
1062306a36Sopenharmony_ci#define _REGS_FIMV_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/kernel.h>
1362306a36Sopenharmony_ci#include <linux/sizes.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define S5P_FIMV_REG_SIZE	(S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR)
1662306a36Sopenharmony_ci#define S5P_FIMV_REG_COUNT	((S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR) / 4)
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* Number of bits that the buffer address should be shifted for particular
1962306a36Sopenharmony_ci * MFC buffers.  */
2062306a36Sopenharmony_ci#define S5P_FIMV_START_ADDR		0x0000
2162306a36Sopenharmony_ci#define S5P_FIMV_END_ADDR		0xe008
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define S5P_FIMV_SW_RESET		0x0000
2462306a36Sopenharmony_ci#define S5P_FIMV_RISC_HOST_INT		0x0008
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* Command from HOST to RISC */
2762306a36Sopenharmony_ci#define S5P_FIMV_HOST2RISC_CMD		0x0030
2862306a36Sopenharmony_ci#define S5P_FIMV_HOST2RISC_ARG1		0x0034
2962306a36Sopenharmony_ci#define S5P_FIMV_HOST2RISC_ARG2		0x0038
3062306a36Sopenharmony_ci#define S5P_FIMV_HOST2RISC_ARG3		0x003c
3162306a36Sopenharmony_ci#define S5P_FIMV_HOST2RISC_ARG4		0x0040
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Command from RISC to HOST */
3462306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_CMD		0x0044
3562306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_CMD_MASK	0x1FFFF
3662306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_ARG1		0x0048
3762306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_ARG2		0x004c
3862306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_ARG3		0x0050
3962306a36Sopenharmony_ci#define S5P_FIMV_RISC2HOST_ARG4		0x0054
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define S5P_FIMV_FW_VERSION		0x0058
4262306a36Sopenharmony_ci#define S5P_FIMV_SYS_MEM_SZ		0x005c
4362306a36Sopenharmony_ci#define S5P_FIMV_FW_STATUS		0x0080
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* Memory controller register */
4662306a36Sopenharmony_ci#define S5P_FIMV_MC_DRAMBASE_ADR_A	0x0508
4762306a36Sopenharmony_ci#define S5P_FIMV_MC_DRAMBASE_ADR_B	0x050c
4862306a36Sopenharmony_ci#define S5P_FIMV_MC_STATUS		0x0510
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/* Common register */
5162306a36Sopenharmony_ci#define S5P_FIMV_COMMON_BASE_A		0x0600
5262306a36Sopenharmony_ci#define S5P_FIMV_COMMON_BASE_B		0x0700
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/* Decoder */
5562306a36Sopenharmony_ci#define S5P_FIMV_DEC_CHROMA_ADR		(S5P_FIMV_COMMON_BASE_A)
5662306a36Sopenharmony_ci#define S5P_FIMV_DEC_LUMA_ADR		(S5P_FIMV_COMMON_BASE_B)
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* H.264 decoding */
5962306a36Sopenharmony_ci#define S5P_FIMV_H264_VERT_NB_MV_ADR	(S5P_FIMV_COMMON_BASE_A + 0x8c)
6062306a36Sopenharmony_ci					/* vertical neighbor motion vector */
6162306a36Sopenharmony_ci#define S5P_FIMV_H264_NB_IP_ADR		(S5P_FIMV_COMMON_BASE_A + 0x90)
6262306a36Sopenharmony_ci					/* neighbor pixels for intra pred */
6362306a36Sopenharmony_ci#define S5P_FIMV_H264_MV_ADR		(S5P_FIMV_COMMON_BASE_B + 0x80)
6462306a36Sopenharmony_ci					/* H264 motion vector */
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci/* MPEG4 decoding */
6762306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_NB_DCAC_ADR	(S5P_FIMV_COMMON_BASE_A + 0x8c)
6862306a36Sopenharmony_ci					/* neighbor AC/DC coeff. */
6962306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_UP_NB_MV_ADR	(S5P_FIMV_COMMON_BASE_A + 0x90)
7062306a36Sopenharmony_ci					/* upper neighbor motion vector */
7162306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_SA_MV_ADR	(S5P_FIMV_COMMON_BASE_A + 0x94)
7262306a36Sopenharmony_ci					/* subseq. anchor motion vector */
7362306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_OT_LINE_ADR	(S5P_FIMV_COMMON_BASE_A + 0x98)
7462306a36Sopenharmony_ci					/* overlap transform line */
7562306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_SP_ADR		(S5P_FIMV_COMMON_BASE_A + 0xa8)
7662306a36Sopenharmony_ci					/* syntax parser */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/* H.263 decoding */
7962306a36Sopenharmony_ci#define S5P_FIMV_H263_NB_DCAC_ADR	(S5P_FIMV_COMMON_BASE_A + 0x8c)
8062306a36Sopenharmony_ci#define S5P_FIMV_H263_UP_NB_MV_ADR	(S5P_FIMV_COMMON_BASE_A + 0x90)
8162306a36Sopenharmony_ci#define S5P_FIMV_H263_SA_MV_ADR		(S5P_FIMV_COMMON_BASE_A + 0x94)
8262306a36Sopenharmony_ci#define S5P_FIMV_H263_OT_LINE_ADR	(S5P_FIMV_COMMON_BASE_A + 0x98)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* VC-1 decoding */
8562306a36Sopenharmony_ci#define S5P_FIMV_VC1_NB_DCAC_ADR	(S5P_FIMV_COMMON_BASE_A + 0x8c)
8662306a36Sopenharmony_ci#define S5P_FIMV_VC1_UP_NB_MV_ADR	(S5P_FIMV_COMMON_BASE_A + 0x90)
8762306a36Sopenharmony_ci#define S5P_FIMV_VC1_SA_MV_ADR		(S5P_FIMV_COMMON_BASE_A + 0x94)
8862306a36Sopenharmony_ci#define S5P_FIMV_VC1_OT_LINE_ADR	(S5P_FIMV_COMMON_BASE_A + 0x98)
8962306a36Sopenharmony_ci#define S5P_FIMV_VC1_BITPLANE3_ADR	(S5P_FIMV_COMMON_BASE_A + 0x9c)
9062306a36Sopenharmony_ci					/* bitplane3 */
9162306a36Sopenharmony_ci#define S5P_FIMV_VC1_BITPLANE2_ADR	(S5P_FIMV_COMMON_BASE_A + 0xa0)
9262306a36Sopenharmony_ci					/* bitplane2 */
9362306a36Sopenharmony_ci#define S5P_FIMV_VC1_BITPLANE1_ADR	(S5P_FIMV_COMMON_BASE_A + 0xa4)
9462306a36Sopenharmony_ci					/* bitplane1 */
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* Encoder */
9762306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF0_LUMA_ADR	(S5P_FIMV_COMMON_BASE_A + 0x1c)
9862306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF1_LUMA_ADR	(S5P_FIMV_COMMON_BASE_A + 0x20)
9962306a36Sopenharmony_ci					/* reconstructed luma */
10062306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF0_CHROMA_ADR	(S5P_FIMV_COMMON_BASE_B)
10162306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF1_CHROMA_ADR	(S5P_FIMV_COMMON_BASE_B + 0x04)
10262306a36Sopenharmony_ci					/* reconstructed chroma */
10362306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF2_LUMA_ADR	(S5P_FIMV_COMMON_BASE_B + 0x10)
10462306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF2_CHROMA_ADR	(S5P_FIMV_COMMON_BASE_B + 0x08)
10562306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF3_LUMA_ADR	(S5P_FIMV_COMMON_BASE_B + 0x14)
10662306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF3_CHROMA_ADR	(S5P_FIMV_COMMON_BASE_B + 0x0c)
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci/* H.264 encoding */
10962306a36Sopenharmony_ci#define S5P_FIMV_H264_UP_MV_ADR		(S5P_FIMV_COMMON_BASE_A)
11062306a36Sopenharmony_ci					/* upper motion vector */
11162306a36Sopenharmony_ci#define S5P_FIMV_H264_NBOR_INFO_ADR	(S5P_FIMV_COMMON_BASE_A + 0x04)
11262306a36Sopenharmony_ci					/* entropy engine's neighbor info. */
11362306a36Sopenharmony_ci#define S5P_FIMV_H264_UP_INTRA_MD_ADR	(S5P_FIMV_COMMON_BASE_A + 0x08)
11462306a36Sopenharmony_ci					/* upper intra MD */
11562306a36Sopenharmony_ci#define S5P_FIMV_H264_COZERO_FLAG_ADR	(S5P_FIMV_COMMON_BASE_A + 0x10)
11662306a36Sopenharmony_ci					/* direct cozero flag */
11762306a36Sopenharmony_ci#define S5P_FIMV_H264_UP_INTRA_PRED_ADR	(S5P_FIMV_COMMON_BASE_B + 0x40)
11862306a36Sopenharmony_ci					/* upper intra PRED */
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci/* H.263 encoding */
12162306a36Sopenharmony_ci#define S5P_FIMV_H263_UP_MV_ADR		(S5P_FIMV_COMMON_BASE_A)
12262306a36Sopenharmony_ci					/* upper motion vector */
12362306a36Sopenharmony_ci#define S5P_FIMV_H263_ACDC_COEF_ADR	(S5P_FIMV_COMMON_BASE_A + 0x04)
12462306a36Sopenharmony_ci					/* upper Q coeff. */
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci/* MPEG4 encoding */
12762306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_UP_MV_ADR	(S5P_FIMV_COMMON_BASE_A)
12862306a36Sopenharmony_ci					/* upper motion vector */
12962306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_ACDC_COEF_ADR	(S5P_FIMV_COMMON_BASE_A + 0x04)
13062306a36Sopenharmony_ci					/* upper Q coeff. */
13162306a36Sopenharmony_ci#define S5P_FIMV_MPEG4_COZERO_FLAG_ADR	(S5P_FIMV_COMMON_BASE_A + 0x10)
13262306a36Sopenharmony_ci					/* direct cozero flag */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF_B_LUMA_ADR     0x062c /* ref B Luma addr */
13562306a36Sopenharmony_ci#define S5P_FIMV_ENC_REF_B_CHROMA_ADR   0x0630 /* ref B Chroma addr */
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci#define S5P_FIMV_ENC_CUR_LUMA_ADR	0x0718 /* current Luma addr */
13862306a36Sopenharmony_ci#define S5P_FIMV_ENC_CUR_CHROMA_ADR	0x071C /* current Chroma addr */
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci/* Codec common register */
14162306a36Sopenharmony_ci#define S5P_FIMV_ENC_HSIZE_PX		0x0818 /* frame width at encoder */
14262306a36Sopenharmony_ci#define S5P_FIMV_ENC_VSIZE_PX		0x081c /* frame height at encoder */
14362306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE		0x0830 /* profile register */
14462306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_H264_MAIN			0
14562306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_H264_HIGH			1
14662306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_H264_BASELINE		2
14762306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_H264_CONSTRAINED_BASELINE	3
14862306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_MPEG4_SIMPLE		0
14962306a36Sopenharmony_ci#define S5P_FIMV_ENC_PROFILE_MPEG4_ADVANCED_SIMPLE	1
15062306a36Sopenharmony_ci#define S5P_FIMV_ENC_PIC_STRUCT		0x083c /* picture field/frame flag */
15162306a36Sopenharmony_ci#define S5P_FIMV_ENC_LF_CTRL		0x0848 /* loop filter control */
15262306a36Sopenharmony_ci#define S5P_FIMV_ENC_ALPHA_OFF		0x084c /* loop filter alpha offset */
15362306a36Sopenharmony_ci#define S5P_FIMV_ENC_BETA_OFF		0x0850 /* loop filter beta offset */
15462306a36Sopenharmony_ci#define S5P_FIMV_MR_BUSIF_CTRL		0x0854 /* hidden, bus interface ctrl */
15562306a36Sopenharmony_ci#define S5P_FIMV_ENC_PXL_CACHE_CTRL	0x0a00 /* pixel cache control */
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci/* Channel & stream interface register */
15862306a36Sopenharmony_ci#define S5P_FIMV_SI_RTN_CHID		0x2000 /* Return CH inst ID register */
15962306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_INST_ID		0x2040 /* codec instance ID */
16062306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_INST_ID		0x2080 /* codec instance ID */
16162306a36Sopenharmony_ci/* Decoder */
16262306a36Sopenharmony_ci#define S5P_FIMV_SI_VRESOL		0x2004 /* vertical res of decoder */
16362306a36Sopenharmony_ci#define S5P_FIMV_SI_HRESOL		0x2008 /* horizontal res of decoder */
16462306a36Sopenharmony_ci#define S5P_FIMV_SI_BUF_NUMBER		0x200c /* number of frames in the
16562306a36Sopenharmony_ci								decoded pic */
16662306a36Sopenharmony_ci#define S5P_FIMV_SI_DISPLAY_Y_ADR	0x2010 /* luma addr of displayed pic */
16762306a36Sopenharmony_ci#define S5P_FIMV_SI_DISPLAY_C_ADR	0x2014 /* chroma addrof displayed pic */
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci#define S5P_FIMV_SI_CONSUMED_BYTES	0x2018 /* Consumed number of bytes to
17062306a36Sopenharmony_ci							decode a frame */
17162306a36Sopenharmony_ci#define S5P_FIMV_SI_DISPLAY_STATUS	0x201c /* status of decoded picture */
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci#define S5P_FIMV_SI_DECODE_Y_ADR	0x2024 /* luma addr of decoded pic */
17462306a36Sopenharmony_ci#define S5P_FIMV_SI_DECODE_C_ADR	0x2028 /* chroma addrof decoded pic */
17562306a36Sopenharmony_ci#define S5P_FIMV_SI_DECODE_STATUS	0x202c /* status of decoded picture */
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_SB_ST_ADR	0x2044 /* start addr of stream buf */
17862306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_SB_FRM_SIZE	0x2048 /* size of stream buf */
17962306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_DESC_ADR	0x204c /* addr of descriptor buf */
18062306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_CPB_SIZE	0x2058 /* max size of coded pic. buf */
18162306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_DESC_SIZE	0x205c /* max size of descriptor buf */
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_SB_ST_ADR	0x2084 /* start addr of stream buf */
18462306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_SB_FRM_SIZE	0x2088 /* size of stream buf */
18562306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_DESC_ADR	0x208c /* addr of descriptor buf */
18662306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_CPB_SIZE	0x2098 /* max size of coded pic. buf */
18762306a36Sopenharmony_ci#define S5P_FIMV_SI_CH1_DESC_SIZE	0x209c /* max size of descriptor buf */
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci#define S5P_FIMV_CRC_LUMA0		0x2030 /* luma crc data per frame
19062306a36Sopenharmony_ci								(top field) */
19162306a36Sopenharmony_ci#define S5P_FIMV_CRC_CHROMA0		0x2034 /* chroma crc data per frame
19262306a36Sopenharmony_ci								(top field) */
19362306a36Sopenharmony_ci#define S5P_FIMV_CRC_LUMA1		0x2038 /* luma crc data per bottom
19462306a36Sopenharmony_ci								field */
19562306a36Sopenharmony_ci#define S5P_FIMV_CRC_CHROMA1		0x203c /* chroma crc data per bottom
19662306a36Sopenharmony_ci								field */
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/* Display status */
19962306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_DECODING_ONLY		0
20062306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_DECODING_DISPLAY		1
20162306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_DISPLAY_ONLY		2
20262306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_DECODING_EMPTY		3
20362306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK	7
20462306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_PROGRESSIVE			(0<<3)
20562306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_INTERLACE			(1<<3)
20662306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_INTERLACE_MASK		(1<<3)
20762306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_TWO		(0<<4)
20862306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_FOUR		(1<<4)
20962306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_MASK		(1<<4)
21062306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_GENERATED		(1<<5)
21162306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_NOT_GENERATED		(0<<5)
21262306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_CRC_MASK			(1<<5)
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_RESOLUTION_MASK		(3<<4)
21562306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_RESOLUTION_INC		(1<<4)
21662306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_RESOLUTION_DEC		(2<<4)
21762306a36Sopenharmony_ci#define S5P_FIMV_DEC_STATUS_RESOLUTION_SHIFT		4
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci/* Decode frame address */
22062306a36Sopenharmony_ci#define S5P_FIMV_DECODE_Y_ADR			0x2024
22162306a36Sopenharmony_ci#define S5P_FIMV_DECODE_C_ADR			0x2028
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci/* Decoded frame tpe */
22462306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_TYPE		0x2020
22562306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_MASK		7
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_SKIPPED		0
22862306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_I_FRAME		1
22962306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_P_FRAME		2
23062306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_B_FRAME		3
23162306a36Sopenharmony_ci#define S5P_FIMV_DECODE_FRAME_OTHER_FRAME	4
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci/* Sizes of buffers required for decoding */
23462306a36Sopenharmony_ci#define S5P_FIMV_DEC_NB_IP_SIZE			(32 * 1024)
23562306a36Sopenharmony_ci#define S5P_FIMV_DEC_VERT_NB_MV_SIZE		(16 * 1024)
23662306a36Sopenharmony_ci#define S5P_FIMV_DEC_NB_DCAC_SIZE		(16 * 1024)
23762306a36Sopenharmony_ci#define S5P_FIMV_DEC_UPNB_MV_SIZE		(68 * 1024)
23862306a36Sopenharmony_ci#define S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE		(136 * 1024)
23962306a36Sopenharmony_ci#define S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE     (32 * 1024)
24062306a36Sopenharmony_ci#define S5P_FIMV_DEC_VC1_BITPLANE_SIZE		(2 * 1024)
24162306a36Sopenharmony_ci#define S5P_FIMV_DEC_STX_PARSER_SIZE		(68 * 1024)
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci#define S5P_FIMV_DEC_BUF_ALIGN			(8 * 1024)
24462306a36Sopenharmony_ci#define S5P_FIMV_ENC_BUF_ALIGN			(8 * 1024)
24562306a36Sopenharmony_ci#define S5P_FIMV_NV12M_HALIGN			16
24662306a36Sopenharmony_ci#define S5P_FIMV_NV12M_LVALIGN			16
24762306a36Sopenharmony_ci#define S5P_FIMV_NV12M_CVALIGN			8
24862306a36Sopenharmony_ci#define S5P_FIMV_NV12MT_HALIGN			128
24962306a36Sopenharmony_ci#define S5P_FIMV_NV12MT_VALIGN			32
25062306a36Sopenharmony_ci#define S5P_FIMV_NV12M_SALIGN			2048
25162306a36Sopenharmony_ci#define S5P_FIMV_NV12MT_SALIGN			8192
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* Sizes of buffers required for encoding */
25462306a36Sopenharmony_ci#define S5P_FIMV_ENC_UPMV_SIZE		0x10000
25562306a36Sopenharmony_ci#define S5P_FIMV_ENC_COLFLG_SIZE	0x10000
25662306a36Sopenharmony_ci#define S5P_FIMV_ENC_INTRAMD_SIZE	0x10000
25762306a36Sopenharmony_ci#define S5P_FIMV_ENC_INTRAPRED_SIZE	0x4000
25862306a36Sopenharmony_ci#define S5P_FIMV_ENC_NBORINFO_SIZE	0x10000
25962306a36Sopenharmony_ci#define S5P_FIMV_ENC_ACDCCOEF_SIZE	0x10000
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci/* Encoder */
26262306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_STRM_SIZE	0x2004 /* stream size */
26362306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_PIC_CNT		0x2008 /* picture count */
26462306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_WRITE_PTR	0x200c /* write pointer */
26562306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE	0x2010 /* slice type(I/P/B/IDR) */
26662306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_NON_CODED	0
26762306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_I		1
26862306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_P		2
26962306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_B		3
27062306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_SKIPPED	4
27162306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_SLICE_TYPE_OTHERS	5
27262306a36Sopenharmony_ci#define S5P_FIMV_ENCODED_Y_ADDR         0x2014 /* the addr of the encoded
27362306a36Sopenharmony_ci								luma pic */
27462306a36Sopenharmony_ci#define S5P_FIMV_ENCODED_C_ADDR         0x2018 /* the addr of the encoded
27562306a36Sopenharmony_ci								chroma pic */
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH0_SB_ADR	0x2044 /* addr of stream buf */
27862306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH0_SB_SIZE	0x204c /* size of stream buf */
27962306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH0_CUR_Y_ADR	0x2050 /* current Luma addr */
28062306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH0_CUR_C_ADR	0x2054 /* current Chroma addr */
28162306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH0_FRAME_INS	0x2058 /* frame insertion */
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH1_SB_ADR	0x2084 /* addr of stream buf */
28462306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH1_SB_SIZE	0x208c /* size of stream buf */
28562306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH1_CUR_Y_ADR	0x2090 /* current Luma addr */
28662306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH1_CUR_C_ADR	0x2094 /* current Chroma addr */
28762306a36Sopenharmony_ci#define S5P_FIMV_ENC_SI_CH1_FRAME_INS	0x2098 /* frame insertion */
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci#define S5P_FIMV_ENC_PIC_TYPE_CTRL	0xc504 /* pic type level control */
29062306a36Sopenharmony_ci#define S5P_FIMV_ENC_B_RECON_WRITE_ON	0xc508 /* B frame recon write ctrl */
29162306a36Sopenharmony_ci#define S5P_FIMV_ENC_MSLICE_CTRL	0xc50c /* multi slice control */
29262306a36Sopenharmony_ci#define S5P_FIMV_ENC_MSLICE_MB		0xc510 /* MB number in the one slice */
29362306a36Sopenharmony_ci#define S5P_FIMV_ENC_MSLICE_BIT		0xc514 /* bit count for one slice */
29462306a36Sopenharmony_ci#define S5P_FIMV_ENC_CIR_CTRL		0xc518 /* number of intra refresh MB */
29562306a36Sopenharmony_ci#define S5P_FIMV_ENC_MAP_FOR_CUR	0xc51c /* linear or tiled mode */
29662306a36Sopenharmony_ci#define S5P_FIMV_ENC_PADDING_CTRL	0xc520 /* padding control */
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_CONFIG		0xc5a0 /* RC config */
29962306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_BIT_RATE	0xc5a8 /* bit rate */
30062306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_QBOUND		0xc5ac /* max/min QP */
30162306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_RPARA		0xc5b0 /* rate control reaction coeff */
30262306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_MB_CTRL		0xc5b4 /* MB adaptive scaling */
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci/* Encoder for H264 only */
30562306a36Sopenharmony_ci#define S5P_FIMV_ENC_H264_ENTROPY_MODE	0xd004 /* CAVLC or CABAC */
30662306a36Sopenharmony_ci#define S5P_FIMV_ENC_H264_ALPHA_OFF	0xd008 /* loop filter alpha offset */
30762306a36Sopenharmony_ci#define S5P_FIMV_ENC_H264_BETA_OFF	0xd00c /* loop filter beta offset */
30862306a36Sopenharmony_ci#define S5P_FIMV_ENC_H264_NUM_OF_REF	0xd010 /* number of reference for P/B */
30962306a36Sopenharmony_ci#define S5P_FIMV_ENC_H264_TRANS_FLAG	0xd034 /* 8x8 transform flag in PPS &
31062306a36Sopenharmony_ci								high profile */
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci#define S5P_FIMV_ENC_RC_FRAME_RATE	0xd0d0 /* frame rate */
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci/* Encoder for MPEG4 only */
31562306a36Sopenharmony_ci#define S5P_FIMV_ENC_MPEG4_QUART_PXL	0xe008 /* qpel interpolation ctrl */
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci/* Additional */
31862306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_DPB_CONF_CTRL   0x2068 /* DPB Config Control Register */
31962306a36Sopenharmony_ci#define S5P_FIMV_SLICE_INT_MASK		1
32062306a36Sopenharmony_ci#define S5P_FIMV_SLICE_INT_SHIFT	31
32162306a36Sopenharmony_ci#define S5P_FIMV_DDELAY_ENA_SHIFT	30
32262306a36Sopenharmony_ci#define S5P_FIMV_DDELAY_VAL_MASK	0xff
32362306a36Sopenharmony_ci#define S5P_FIMV_DDELAY_VAL_SHIFT	16
32462306a36Sopenharmony_ci#define S5P_FIMV_DPB_COUNT_MASK		0xffff
32562306a36Sopenharmony_ci#define S5P_FIMV_DPB_FLUSH_MASK		1
32662306a36Sopenharmony_ci#define S5P_FIMV_DPB_FLUSH_SHIFT	14
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_RELEASE_BUF     0x2060 /* DPB release buffer register */
33062306a36Sopenharmony_ci#define S5P_FIMV_SI_CH0_HOST_WR_ADR	0x2064 /* address of shared memory */
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci/* Codec numbers  */
33362306a36Sopenharmony_ci#define S5P_FIMV_CODEC_NONE		-1
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci#define S5P_FIMV_CODEC_H264_DEC		0
33662306a36Sopenharmony_ci#define S5P_FIMV_CODEC_VC1_DEC		1
33762306a36Sopenharmony_ci#define S5P_FIMV_CODEC_MPEG4_DEC	2
33862306a36Sopenharmony_ci#define S5P_FIMV_CODEC_MPEG2_DEC	3
33962306a36Sopenharmony_ci#define S5P_FIMV_CODEC_H263_DEC		4
34062306a36Sopenharmony_ci#define S5P_FIMV_CODEC_VC1RCV_DEC	5
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci#define S5P_FIMV_CODEC_H264_ENC		16
34362306a36Sopenharmony_ci#define S5P_FIMV_CODEC_MPEG4_ENC	17
34462306a36Sopenharmony_ci#define S5P_FIMV_CODEC_H263_ENC		18
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci/* Channel Control Register */
34762306a36Sopenharmony_ci#define S5P_FIMV_CH_SEQ_HEADER		1
34862306a36Sopenharmony_ci#define S5P_FIMV_CH_FRAME_START		2
34962306a36Sopenharmony_ci#define S5P_FIMV_CH_LAST_FRAME		3
35062306a36Sopenharmony_ci#define S5P_FIMV_CH_INIT_BUFS		4
35162306a36Sopenharmony_ci#define S5P_FIMV_CH_FRAME_START_REALLOC	5
35262306a36Sopenharmony_ci#define S5P_FIMV_CH_MASK		7
35362306a36Sopenharmony_ci#define S5P_FIMV_CH_SHIFT		16
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci/* Host to RISC command */
35762306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_EMPTY		0
35862306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_OPEN_INSTANCE	1
35962306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_CLOSE_INSTANCE	2
36062306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_SYS_INIT	3
36162306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_FLUSH		4
36262306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_SLEEP		5
36362306a36Sopenharmony_ci#define S5P_FIMV_H2R_CMD_WAKEUP		6
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_EMPTY			0
36662306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET	1
36762306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET	2
36862306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_RSV_RET		3
36962306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_SEQ_DONE_RET		4
37062306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_FRAME_DONE_RET		5
37162306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_SLICE_DONE_RET		6
37262306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_ENC_COMPLETE_RET	7
37362306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_SYS_INIT_RET		8
37462306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_FW_STATUS_RET		9
37562306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_SLEEP_RET		10
37662306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_WAKEUP_RET		11
37762306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_FLUSH_RET		12
37862306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET	15
37962306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_EDFU_INIT_RET		16
38062306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_ERR_RET		32
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci/* Dummy definition for MFCv6 compatibility */
38362306a36Sopenharmony_ci#define S5P_FIMV_CODEC_H264_MVC_DEC		-1
38462306a36Sopenharmony_ci#define S5P_FIMV_R2H_CMD_FIELD_DONE_RET		-1
38562306a36Sopenharmony_ci#define S5P_FIMV_MFC_RESET			-1
38662306a36Sopenharmony_ci#define S5P_FIMV_RISC_ON			-1
38762306a36Sopenharmony_ci#define S5P_FIMV_RISC_BASE_ADDRESS		-1
38862306a36Sopenharmony_ci#define S5P_FIMV_CODEC_VP8_DEC			-1
38962306a36Sopenharmony_ci#define S5P_FIMV_REG_CLEAR_BEGIN		0
39062306a36Sopenharmony_ci#define S5P_FIMV_REG_CLEAR_COUNT		0
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci/* Error handling defines */
39362306a36Sopenharmony_ci#define S5P_FIMV_ERR_NO_VALID_SEQ_HDR		67
39462306a36Sopenharmony_ci#define S5P_FIMV_ERR_INCOMPLETE_FRAME		124
39562306a36Sopenharmony_ci#define S5P_FIMV_ERR_TIMEOUT			140
39662306a36Sopenharmony_ci#define S5P_FIMV_ERR_WARNINGS_START		145
39762306a36Sopenharmony_ci#define S5P_FIMV_ERR_DEC_MASK			0xFFFF
39862306a36Sopenharmony_ci#define S5P_FIMV_ERR_DEC_SHIFT			0
39962306a36Sopenharmony_ci#define S5P_FIMV_ERR_DSPL_MASK			0xFFFF0000
40062306a36Sopenharmony_ci#define S5P_FIMV_ERR_DSPL_SHIFT			16
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ci/* Shared memory registers' offsets */
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ci/* An offset of the start position in the stream when
40562306a36Sopenharmony_ci * the start position is not aligned */
40662306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_INFO_H		0x0020
40762306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_LEFT_MASK		0xFFFF
40862306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_LEFT_SHIFT		0
40962306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_RIGHT_MASK		0xFFFF0000
41062306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_RIGHT_SHIFT	16
41162306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_INFO_V		0x0024
41262306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_TOP_MASK		0xFFFF
41362306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_TOP_SHIFT		0
41462306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_BOTTOM_MASK	0xFFFF0000
41562306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT	16
41662306a36Sopenharmony_ci#define S5P_FIMV_SHARED_SET_FRAME_TAG		0x0004
41762306a36Sopenharmony_ci#define S5P_FIMV_SHARED_GET_FRAME_TAG_TOP	0x0008
41862306a36Sopenharmony_ci#define S5P_FIMV_SHARED_GET_FRAME_TAG_BOT	0x000C
41962306a36Sopenharmony_ci#define S5P_FIMV_SHARED_START_BYTE_NUM		0x0018
42062306a36Sopenharmony_ci#define S5P_FIMV_SHARED_RC_VOP_TIMING		0x0030
42162306a36Sopenharmony_ci#define S5P_FIMV_SHARED_LUMA_DPB_SIZE		0x0064
42262306a36Sopenharmony_ci#define S5P_FIMV_SHARED_CHROMA_DPB_SIZE		0x0068
42362306a36Sopenharmony_ci#define S5P_FIMV_SHARED_MV_SIZE			0x006C
42462306a36Sopenharmony_ci#define S5P_FIMV_SHARED_PIC_TIME_TOP		0x0010
42562306a36Sopenharmony_ci#define S5P_FIMV_SHARED_PIC_TIME_BOTTOM		0x0014
42662306a36Sopenharmony_ci#define S5P_FIMV_SHARED_EXT_ENC_CONTROL		0x0028
42762306a36Sopenharmony_ci#define S5P_FIMV_SHARED_P_B_FRAME_QP		0x0070
42862306a36Sopenharmony_ci#define S5P_FIMV_SHARED_ASPECT_RATIO_IDC	0x0074
42962306a36Sopenharmony_ci#define S5P_FIMV_SHARED_EXTENDED_SAR		0x0078
43062306a36Sopenharmony_ci#define S5P_FIMV_SHARED_H264_I_PERIOD		0x009C
43162306a36Sopenharmony_ci#define S5P_FIMV_SHARED_RC_CONTROL_CONFIG	0x00A0
43262306a36Sopenharmony_ci#define S5P_FIMV_SHARED_DISP_FRAME_TYPE_SHIFT	2
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci/* Offset used by the hardware to store addresses */
43562306a36Sopenharmony_ci#define MFC_OFFSET_SHIFT	11
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci#define FIRMWARE_ALIGN		(128 * SZ_1K)	/* 128KB */
43862306a36Sopenharmony_ci#define MFC_H264_CTX_BUF_SIZE	(600 * SZ_1K)	/* 600KB per H264 instance */
43962306a36Sopenharmony_ci#define MFC_CTX_BUF_SIZE	(10 * SZ_1K)	/* 10KB per instance */
44062306a36Sopenharmony_ci#define DESC_BUF_SIZE		(128 * SZ_1K)	/* 128KB for DESC buffer */
44162306a36Sopenharmony_ci#define SHARED_BUF_SIZE		(8 * SZ_1K)	/* 8KB for shared buffer */
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci#define DEF_CPB_SIZE		(256 * SZ_1K)	/* 256KB */
44462306a36Sopenharmony_ci#define MAX_CPB_SIZE		(4 * SZ_1M)	/* 4MB */
44562306a36Sopenharmony_ci#define MAX_FW_SIZE		(384 * SZ_1K)
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_ci#define MFC_VERSION		0x51
44862306a36Sopenharmony_ci#define MFC_NUM_PORTS		2
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci#define S5P_FIMV_SHARED_FRAME_PACK_SEI_AVAIL    0x16C
45162306a36Sopenharmony_ci#define S5P_FIMV_SHARED_FRAME_PACK_ARRGMENT_ID  0x170
45262306a36Sopenharmony_ci#define S5P_FIMV_SHARED_FRAME_PACK_SEI_INFO     0x174
45362306a36Sopenharmony_ci#define S5P_FIMV_SHARED_FRAME_PACK_GRID_POS     0x178
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci/* Values for resolution change in display status */
45662306a36Sopenharmony_ci#define S5P_FIMV_RES_INCREASE	1
45762306a36Sopenharmony_ci#define S5P_FIMV_RES_DECREASE	2
45862306a36Sopenharmony_ci
45962306a36Sopenharmony_ci#endif /* _REGS_FIMV_H */
460