Skip to content

Commit 61890cc

Browse files
MoudyHomchehab
authored andcommitted
media: platform: mtk-mdp3: add MediaTek MDP3 driver
This patch adds driver for MediaTek's Media Data Path ver.3 (MDP3). It provides the following functions: color transform, format conversion, resize, crop, rotate, flip and additional image quality enhancement. The MDP3 driver is mainly used for Google Chromebook products to import the new architecture to set the HW settings as shown below: User -> V4L2 framework -> MDP3 driver -> SCP (setting calculations) -> MDP3 driver -> CMDQ (GCE driver) -> HW Each modules' related operation control is sited in mtk-mdp3-comp.c Each modules' register table is defined in file with "mdp_reg_" prefix GCE related API, operation control sited in mtk-mdp3-cmdq.c V4L2 m2m device functions are implemented in mtk-mdp3-m2m.c Probe, power, suspend/resume, system level functions are defined in mtk-mdp3-core.c [hverkuil: add 'depends on REMOTEPROC'] Signed-off-by: Ping-Hsun Wu <[email protected]> Signed-off-by: daoyuan huang <[email protected]> Signed-off-by: Moudy Ho <[email protected]> Tested-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 8bbdead commit 61890cc

22 files changed

+4994
-0
lines changed

drivers/media/platform/mediatek/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ source "drivers/media/platform/mediatek/jpeg/Kconfig"
66
source "drivers/media/platform/mediatek/mdp/Kconfig"
77
source "drivers/media/platform/mediatek/vcodec/Kconfig"
88
source "drivers/media/platform/mediatek/vpu/Kconfig"
9+
source "drivers/media/platform/mediatek/mdp3/Kconfig"

drivers/media/platform/mediatek/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ obj-y += jpeg/
33
obj-y += mdp/
44
obj-y += vcodec/
55
obj-y += vpu/
6+
obj-y += mdp3/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
config VIDEO_MEDIATEK_MDP3
3+
tristate "MediaTek MDP v3 driver"
4+
depends on MTK_IOMMU || COMPILE_TEST
5+
depends on VIDEO_DEV
6+
depends on ARCH_MEDIATEK || COMPILE_TEST
7+
depends on HAS_DMA
8+
depends on REMOTEPROC
9+
select VIDEOBUF2_DMA_CONTIG
10+
select V4L2_MEM2MEM_DEV
11+
select MTK_MMSYS
12+
select VIDEO_MEDIATEK_VPU
13+
select MTK_CMDQ
14+
select MTK_SCP
15+
default n
16+
help
17+
It is a v4l2 driver and present in MediaTek MT8183 SoC.
18+
The driver supports scaling and color space conversion.
19+
20+
To compile this driver as a module, choose M here: the
21+
module will be called mtk-mdp3.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
mtk-mdp3-y += mtk-mdp3-core.o mtk-mdp3-vpu.o mtk-mdp3-regs.o
3+
mtk-mdp3-y += mtk-mdp3-m2m.o
4+
mtk-mdp3-y += mtk-mdp3-comp.o mtk-mdp3-cmdq.o
5+
6+
obj-$(CONFIG_VIDEO_MEDIATEK_MDP3) += mtk-mdp3.o
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Ping-Hsun Wu <[email protected]>
5+
*/
6+
7+
#ifndef __MDP_REG_CCORR_H__
8+
#define __MDP_REG_CCORR_H__
9+
10+
#define MDP_CCORR_EN 0x000
11+
#define MDP_CCORR_CFG 0x020
12+
#define MDP_CCORR_SIZE 0x030
13+
14+
/* MASK */
15+
#define MDP_CCORR_EN_MASK 0x00000001
16+
#define MDP_CCORR_CFG_MASK 0x70001317
17+
#define MDP_CCORR_SIZE_MASK 0x1fff1fff
18+
19+
#endif // __MDP_REG_CCORR_H__
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Ping-Hsun Wu <[email protected]>
5+
*/
6+
7+
#ifndef __MDP_REG_RDMA_H__
8+
#define __MDP_REG_RDMA_H__
9+
10+
#define MDP_RDMA_EN 0x000
11+
#define MDP_RDMA_RESET 0x008
12+
#define MDP_RDMA_CON 0x020
13+
#define MDP_RDMA_GMCIF_CON 0x028
14+
#define MDP_RDMA_SRC_CON 0x030
15+
#define MDP_RDMA_MF_BKGD_SIZE_IN_BYTE 0x060
16+
#define MDP_RDMA_MF_BKGD_SIZE_IN_PXL 0x068
17+
#define MDP_RDMA_MF_SRC_SIZE 0x070
18+
#define MDP_RDMA_MF_CLIP_SIZE 0x078
19+
#define MDP_RDMA_MF_OFFSET_1 0x080
20+
#define MDP_RDMA_SF_BKGD_SIZE_IN_BYTE 0x090
21+
#define MDP_RDMA_SRC_END_0 0x100
22+
#define MDP_RDMA_SRC_END_1 0x108
23+
#define MDP_RDMA_SRC_END_2 0x110
24+
#define MDP_RDMA_SRC_OFFSET_0 0x118
25+
#define MDP_RDMA_SRC_OFFSET_1 0x120
26+
#define MDP_RDMA_SRC_OFFSET_2 0x128
27+
#define MDP_RDMA_SRC_OFFSET_0_P 0x148
28+
#define MDP_RDMA_TRANSFORM_0 0x200
29+
#define MDP_RDMA_RESV_DUMMY_0 0x2a0
30+
#define MDP_RDMA_MON_STA_1 0x408
31+
#define MDP_RDMA_SRC_BASE_0 0xf00
32+
#define MDP_RDMA_SRC_BASE_1 0xf08
33+
#define MDP_RDMA_SRC_BASE_2 0xf10
34+
#define MDP_RDMA_UFO_DEC_LENGTH_BASE_Y 0xf20
35+
#define MDP_RDMA_UFO_DEC_LENGTH_BASE_C 0xf28
36+
37+
/* MASK */
38+
#define MDP_RDMA_EN_MASK 0x00000001
39+
#define MDP_RDMA_RESET_MASK 0x00000001
40+
#define MDP_RDMA_CON_MASK 0x00001110
41+
#define MDP_RDMA_GMCIF_CON_MASK 0xfffb3771
42+
#define MDP_RDMA_SRC_CON_MASK 0xf3ffffff
43+
#define MDP_RDMA_MF_BKGD_SIZE_IN_BYTE_MASK 0x001fffff
44+
#define MDP_RDMA_MF_BKGD_SIZE_IN_PXL_MASK 0x001fffff
45+
#define MDP_RDMA_MF_SRC_SIZE_MASK 0x1fff1fff
46+
#define MDP_RDMA_MF_CLIP_SIZE_MASK 0x1fff1fff
47+
#define MDP_RDMA_MF_OFFSET_1_MASK 0x003f001f
48+
#define MDP_RDMA_SF_BKGD_SIZE_IN_BYTE_MASK 0x001fffff
49+
#define MDP_RDMA_SRC_END_0_MASK 0xffffffff
50+
#define MDP_RDMA_SRC_END_1_MASK 0xffffffff
51+
#define MDP_RDMA_SRC_END_2_MASK 0xffffffff
52+
#define MDP_RDMA_SRC_OFFSET_0_MASK 0xffffffff
53+
#define MDP_RDMA_SRC_OFFSET_1_MASK 0xffffffff
54+
#define MDP_RDMA_SRC_OFFSET_2_MASK 0xffffffff
55+
#define MDP_RDMA_SRC_OFFSET_0_P_MASK 0xffffffff
56+
#define MDP_RDMA_TRANSFORM_0_MASK 0xff110777
57+
#define MDP_RDMA_RESV_DUMMY_0_MASK 0xffffffff
58+
#define MDP_RDMA_MON_STA_1_MASK 0xffffffff
59+
#define MDP_RDMA_SRC_BASE_0_MASK 0xffffffff
60+
#define MDP_RDMA_SRC_BASE_1_MASK 0xffffffff
61+
#define MDP_RDMA_SRC_BASE_2_MASK 0xffffffff
62+
#define MDP_RDMA_UFO_DEC_LENGTH_BASE_Y_MASK 0xffffffff
63+
#define MDP_RDMA_UFO_DEC_LENGTH_BASE_C_MASK 0xffffffff
64+
65+
#endif // __MDP_REG_RDMA_H__
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Ping-Hsun Wu <[email protected]>
5+
*/
6+
7+
#ifndef __MDP_REG_RSZ_H__
8+
#define __MDP_REG_RSZ_H__
9+
10+
#define PRZ_ENABLE 0x000
11+
#define PRZ_CONTROL_1 0x004
12+
#define PRZ_CONTROL_2 0x008
13+
#define PRZ_INPUT_IMAGE 0x010
14+
#define PRZ_OUTPUT_IMAGE 0x014
15+
#define PRZ_HORIZONTAL_COEFF_STEP 0x018
16+
#define PRZ_VERTICAL_COEFF_STEP 0x01c
17+
#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET 0x020
18+
#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET 0x024
19+
#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET 0x028
20+
#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET 0x02c
21+
#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET 0x030
22+
#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET 0x034
23+
24+
/* MASK */
25+
#define PRZ_ENABLE_MASK 0x00010001
26+
#define PRZ_CONTROL_1_MASK 0xfffffff3
27+
#define PRZ_CONTROL_2_MASK 0x0ffffaff
28+
#define PRZ_INPUT_IMAGE_MASK 0xffffffff
29+
#define PRZ_OUTPUT_IMAGE_MASK 0xffffffff
30+
#define PRZ_HORIZONTAL_COEFF_STEP_MASK 0x007fffff
31+
#define PRZ_VERTICAL_COEFF_STEP_MASK 0x007fffff
32+
#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET_MASK 0x0000ffff
33+
#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK 0x001fffff
34+
#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET_MASK 0x0000ffff
35+
#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET_MASK 0x001fffff
36+
#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET_MASK 0x0000ffff
37+
#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK 0x001fffff
38+
39+
#endif // __MDP_REG_RSZ_H__
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Ping-Hsun Wu <[email protected]>
5+
*/
6+
7+
#ifndef __MDP_REG_WDMA_H__
8+
#define __MDP_REG_WDMA_H__
9+
10+
#define WDMA_EN 0x008
11+
#define WDMA_RST 0x00c
12+
#define WDMA_CFG 0x014
13+
#define WDMA_SRC_SIZE 0x018
14+
#define WDMA_CLIP_SIZE 0x01c
15+
#define WDMA_CLIP_COORD 0x020
16+
#define WDMA_DST_W_IN_BYTE 0x028
17+
#define WDMA_ALPHA 0x02c
18+
#define WDMA_BUF_CON2 0x03c
19+
#define WDMA_DST_UV_PITCH 0x078
20+
#define WDMA_DST_ADDR_OFFSET 0x080
21+
#define WDMA_DST_U_ADDR_OFFSET 0x084
22+
#define WDMA_DST_V_ADDR_OFFSET 0x088
23+
#define WDMA_FLOW_CTRL_DBG 0x0a0
24+
#define WDMA_DST_ADDR 0xf00
25+
#define WDMA_DST_U_ADDR 0xf04
26+
#define WDMA_DST_V_ADDR 0xf08
27+
28+
/* MASK */
29+
#define WDMA_EN_MASK 0x00000001
30+
#define WDMA_RST_MASK 0x00000001
31+
#define WDMA_CFG_MASK 0xff03bff0
32+
#define WDMA_SRC_SIZE_MASK 0x3fff3fff
33+
#define WDMA_CLIP_SIZE_MASK 0x3fff3fff
34+
#define WDMA_CLIP_COORD_MASK 0x3fff3fff
35+
#define WDMA_DST_W_IN_BYTE_MASK 0x0000ffff
36+
#define WDMA_ALPHA_MASK 0x800000ff
37+
#define WDMA_BUF_CON2_MASK 0xffffffff
38+
#define WDMA_DST_UV_PITCH_MASK 0x0000ffff
39+
#define WDMA_DST_ADDR_OFFSET_MASK 0x0fffffff
40+
#define WDMA_DST_U_ADDR_OFFSET_MASK 0x0fffffff
41+
#define WDMA_DST_V_ADDR_OFFSET_MASK 0x0fffffff
42+
#define WDMA_FLOW_CTRL_DBG_MASK 0x0000f3ff
43+
#define WDMA_DST_ADDR_MASK 0xffffffff
44+
#define WDMA_DST_U_ADDR_MASK 0xffffffff
45+
#define WDMA_DST_V_ADDR_MASK 0xffffffff
46+
47+
#endif // __MDP_REG_WDMA_H__
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Ping-Hsun Wu <[email protected]>
5+
*/
6+
7+
#ifndef __MDP_REG_WROT_H__
8+
#define __MDP_REG_WROT_H__
9+
10+
#define VIDO_CTRL 0x000
11+
#define VIDO_MAIN_BUF_SIZE 0x008
12+
#define VIDO_SOFT_RST 0x010
13+
#define VIDO_SOFT_RST_STAT 0x014
14+
#define VIDO_CROP_OFST 0x020
15+
#define VIDO_TAR_SIZE 0x024
16+
#define VIDO_OFST_ADDR 0x02c
17+
#define VIDO_STRIDE 0x030
18+
#define VIDO_OFST_ADDR_C 0x038
19+
#define VIDO_STRIDE_C 0x03c
20+
#define VIDO_DITHER 0x054
21+
#define VIDO_STRIDE_V 0x06c
22+
#define VIDO_OFST_ADDR_V 0x068
23+
#define VIDO_RSV_1 0x070
24+
#define VIDO_IN_SIZE 0x078
25+
#define VIDO_ROT_EN 0x07c
26+
#define VIDO_FIFO_TEST 0x080
27+
#define VIDO_MAT_CTRL 0x084
28+
#define VIDO_BASE_ADDR 0xf00
29+
#define VIDO_BASE_ADDR_C 0xf04
30+
#define VIDO_BASE_ADDR_V 0xf08
31+
32+
/* MASK */
33+
#define VIDO_CTRL_MASK 0xf530711f
34+
#define VIDO_MAIN_BUF_SIZE_MASK 0x1fff7f77
35+
#define VIDO_SOFT_RST_MASK 0x00000001
36+
#define VIDO_SOFT_RST_STAT_MASK 0x00000001
37+
#define VIDO_TAR_SIZE_MASK 0x1fff1fff
38+
#define VIDO_CROP_OFST_MASK 0x1fff1fff
39+
#define VIDO_OFST_ADDR_MASK 0x0fffffff
40+
#define VIDO_STRIDE_MASK 0x0000ffff
41+
#define VIDO_OFST_ADDR_C_MASK 0x0fffffff
42+
#define VIDO_STRIDE_C_MASK 0x0000ffff
43+
#define VIDO_DITHER_MASK 0xff000001
44+
#define VIDO_STRIDE_V_MASK 0x0000ffff
45+
#define VIDO_OFST_ADDR_V_MASK 0x0fffffff
46+
#define VIDO_RSV_1_MASK 0xffffffff
47+
#define VIDO_IN_SIZE_MASK 0x1fff1fff
48+
#define VIDO_ROT_EN_MASK 0x00000001
49+
#define VIDO_FIFO_TEST_MASK 0x00000fff
50+
#define VIDO_MAT_CTRL_MASK 0x000000f3
51+
#define VIDO_BASE_ADDR_MASK 0xffffffff
52+
#define VIDO_BASE_ADDR_C_MASK 0xffffffff
53+
#define VIDO_BASE_ADDR_V_MASK 0xffffffff
54+
55+
#endif // __MDP_REG_WROT_H__

0 commit comments

Comments
 (0)