Skip to content

Commit 46c15a4

Browse files
linkunfaHans Verkuil
authored andcommitted
media: nuvoton: Add driver for NPCM video capture and encoding engine
Add driver for Video Capture/Differentiation Engine (VCD) and Encoding Compression Engine (ECE) present on Nuvoton NPCM SoCs. As described in the datasheet NPCM750D_DS_Rev_1.0, the VCD can capture frames from digital video input and compare two frames in memory, and then the ECE can compress the frame data into HEXTILE format. This driver implements V4L2 interfaces and provides user controls to support KVM feature, also tested with VNC Viewer ver.6.22.826 and openbmc/obmc-ikvm. Signed-off-by: Marvin Lin <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 1568583 commit 46c15a4

File tree

7 files changed

+2014
-0
lines changed

7 files changed

+2014
-0
lines changed

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,18 @@ F: drivers/rtc/rtc-nct3018y.c
24802480
F: include/dt-bindings/clock/nuvoton,npcm7xx-clock.h
24812481
F: include/dt-bindings/clock/nuvoton,npcm845-clk.h
24822482

2483+
ARM/NUVOTON NPCM VIDEO ENGINE DRIVER
2484+
M: Joseph Liu <[email protected]>
2485+
M: Marvin Lin <[email protected]>
2486+
2487+
L: [email protected] (moderated for non-subscribers)
2488+
S: Maintained
2489+
F: Documentation/devicetree/bindings/media/nuvoton,npcm-ece.yaml
2490+
F: Documentation/devicetree/bindings/media/nuvoton,npcm-vcd.yaml
2491+
F: Documentation/userspace-api/media/drivers/npcm-video.rst
2492+
F: drivers/media/platform/nuvoton/
2493+
F: include/uapi/linux/npcm-video.h
2494+
24832495
ARM/NUVOTON WPCM450 ARCHITECTURE
24842496
M: Jonathan Neuschäfer <[email protected]>
24852497
L: [email protected] (moderated for non-subscribers)

drivers/media/platform/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ source "drivers/media/platform/intel/Kconfig"
7373
source "drivers/media/platform/marvell/Kconfig"
7474
source "drivers/media/platform/mediatek/Kconfig"
7575
source "drivers/media/platform/microchip/Kconfig"
76+
source "drivers/media/platform/nuvoton/Kconfig"
7677
source "drivers/media/platform/nvidia/Kconfig"
7778
source "drivers/media/platform/nxp/Kconfig"
7879
source "drivers/media/platform/qcom/Kconfig"

drivers/media/platform/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ obj-y += intel/
1616
obj-y += marvell/
1717
obj-y += mediatek/
1818
obj-y += microchip/
19+
obj-y += nuvoton/
1920
obj-y += nvidia/
2021
obj-y += nxp/
2122
obj-y += qcom/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
comment "Nuvoton media platform drivers"
4+
5+
config VIDEO_NPCM_VCD_ECE
6+
tristate "Nuvoton NPCM Video Capture/Encode Engine driver"
7+
depends on V4L_PLATFORM_DRIVERS
8+
depends on VIDEO_DEV
9+
select VIDEOBUF2_DMA_CONTIG
10+
help
11+
Support for the Video Capture/Differentiation Engine (VCD) and
12+
Encoding Compression Engine (ECE) present on Nuvoton NPCM SoCs.
13+
The VCD can capture a frame from digital video input and compare
14+
two frames in memory, and then the ECE can compress the frame
15+
data into HEXTILE format.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
obj-$(CONFIG_VIDEO_NPCM_VCD_ECE) += npcm-video.o
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Register definition header for NPCM video driver
4+
*
5+
* Copyright (C) 2022 Nuvoton Technologies
6+
*/
7+
8+
#ifndef _NPCM_REGS_H
9+
#define _NPCM_REGS_H
10+
11+
/* VCD Registers */
12+
#define VCD_DIFF_TBL 0x0000
13+
#define VCD_FBA_ADR 0x8000
14+
#define VCD_FBB_ADR 0x8004
15+
16+
#define VCD_FB_LP 0x8008
17+
#define VCD_FBA_LP GENMASK(15, 0)
18+
#define VCD_FBB_LP GENMASK(31, 16)
19+
20+
#define VCD_CAP_RES 0x800c
21+
#define VCD_CAP_RES_VERT_RES GENMASK(10, 0)
22+
#define VCD_CAP_RES_HOR_RES GENMASK(26, 16)
23+
24+
#define VCD_MODE 0x8014
25+
#define VCD_MODE_VCDE BIT(0)
26+
#define VCD_MODE_CM565 BIT(1)
27+
#define VCD_MODE_IDBC BIT(3)
28+
#define VCD_MODE_KVM_BW_SET BIT(16)
29+
30+
#define VCD_CMD 0x8018
31+
#define VCD_CMD_GO BIT(0)
32+
#define VCD_CMD_RST BIT(1)
33+
#define VCD_CMD_OPERATION GENMASK(6, 4)
34+
#define VCD_CMD_OPERATION_CAPTURE 0
35+
#define VCD_CMD_OPERATION_COMPARE 2
36+
37+
#define VCD_STAT 0x801c
38+
#define VCD_STAT_DONE BIT(0)
39+
#define VCD_STAT_IFOT BIT(2)
40+
#define VCD_STAT_IFOR BIT(3)
41+
#define VCD_STAT_VHT_CHG BIT(5)
42+
#define VCD_STAT_HAC_CHG BIT(8)
43+
#define VCD_STAT_BUSY BIT(30)
44+
#define VCD_STAT_CLEAR 0x3fff
45+
46+
#define VCD_INTE 0x8020
47+
#define VCD_INTE_DONE_IE BIT(0)
48+
#define VCD_INTE_IFOT_IE BIT(2)
49+
#define VCD_INTE_IFOR_IE BIT(3)
50+
#define VCD_INTE_VHT_IE BIT(5)
51+
#define VCD_INTE_HAC_IE BIT(8)
52+
53+
#define VCD_RCHG 0x8028
54+
#define VCD_RCHG_IG_CHG0 GENMASK(2, 0)
55+
#define VCD_RCHG_TIM_PRSCL GENMASK(12, 9)
56+
57+
#define VCD_VER_HI_TIM 0x8044
58+
#define VCD_VER_HI_TIME GENMASK(23, 0)
59+
60+
#define VCD_VER_HI_LST 0x8048
61+
#define VCD_VER_HI_LAST GENMASK(23, 0)
62+
63+
#define VCD_HOR_AC_TIM 0x804c
64+
#define VCD_HOR_AC_TIME GENMASK(13, 0)
65+
66+
#define VCD_HOR_AC_LST 0x8050
67+
#define VCD_HOR_AC_LAST GENMASK(13, 0)
68+
69+
#define VCD_FIFO 0x805c
70+
#define VCD_FIFO_TH 0x100350ff
71+
72+
#define VCD_FB_SIZE 0x500000 /* support up to 1920 x 1200 */
73+
#define VCD_KVM_BW_PCLK 120000000UL
74+
#define VCD_TIMEOUT_US 300000
75+
76+
/* ECE Registers */
77+
#define ECE_DDA_CTRL 0x0000
78+
#define ECE_DDA_CTRL_ECEEN BIT(0)
79+
#define ECE_DDA_CTRL_INTEN BIT(8)
80+
81+
#define ECE_DDA_STS 0x0004
82+
#define ECE_DDA_STS_CDREADY BIT(8)
83+
#define ECE_DDA_STS_ACDRDY BIT(10)
84+
85+
#define ECE_FBR_BA 0x0008
86+
#define ECE_ED_BA 0x000c
87+
#define ECE_RECT_XY 0x0010
88+
89+
#define ECE_RECT_DIMEN 0x0014
90+
#define ECE_RECT_DIMEN_WR GENMASK(10, 0)
91+
#define ECE_RECT_DIMEN_WLTR GENMASK(14, 11)
92+
#define ECE_RECT_DIMEN_HR GENMASK(26, 16)
93+
#define ECE_RECT_DIMEN_HLTR GENMASK(30, 27)
94+
95+
#define ECE_RESOL 0x001c
96+
#define ECE_RESOL_FB_LP_512 0
97+
#define ECE_RESOL_FB_LP_1024 1
98+
#define ECE_RESOL_FB_LP_2048 2
99+
#define ECE_RESOL_FB_LP_2560 3
100+
#define ECE_RESOL_FB_LP_4096 4
101+
102+
#define ECE_HEX_CTRL 0x0040
103+
#define ECE_HEX_CTRL_ENCDIS BIT(0)
104+
#define ECE_HEX_CTRL_ENC_GAP GENMASK(12, 8)
105+
106+
#define ECE_HEX_RECT_OFFSET 0x0048
107+
#define ECE_HEX_RECT_OFFSET_MASK GENMASK(22, 0)
108+
109+
#define ECE_TILE_W 16
110+
#define ECE_TILE_H 16
111+
#define ECE_POLL_TIMEOUT_US 300000
112+
113+
/* GCR Registers */
114+
#define INTCR 0x3c
115+
#define INTCR_GFXIFDIS GENMASK(9, 8)
116+
#define INTCR_DEHS BIT(27)
117+
118+
#define INTCR2 0x60
119+
#define INTCR2_GIRST2 BIT(2)
120+
#define INTCR2_GIHCRST BIT(5)
121+
#define INTCR2_GIVCRST BIT(6)
122+
123+
/* GFXI Register */
124+
#define DISPST 0x00
125+
#define DISPST_HSCROFF BIT(1)
126+
#define DISPST_MGAMODE BIT(7)
127+
128+
#define HVCNTL 0x10
129+
#define HVCNTL_MASK GENMASK(7, 0)
130+
131+
#define HVCNTH 0x14
132+
#define HVCNTH_MASK GENMASK(2, 0)
133+
134+
#define VVCNTL 0x20
135+
#define VVCNTL_MASK GENMASK(7, 0)
136+
137+
#define VVCNTH 0x24
138+
#define VVCNTH_MASK GENMASK(2, 0)
139+
140+
#define GPLLINDIV 0x40
141+
#define GPLLINDIV_MASK GENMASK(5, 0)
142+
#define GPLLINDIV_GPLLFBDV8 BIT(7)
143+
144+
#define GPLLFBDIV 0x44
145+
#define GPLLFBDIV_MASK GENMASK(7, 0)
146+
147+
#define GPLLST 0x48
148+
#define GPLLST_PLLOTDIV1 GENMASK(2, 0)
149+
#define GPLLST_PLLOTDIV2 GENMASK(5, 3)
150+
#define GPLLST_GPLLFBDV109 GENMASK(7, 6)
151+
152+
#endif /* _NPCM_REGS_H */

0 commit comments

Comments
 (0)