Skip to contentSkip to conversation

media: Introduce Allwinner H3 deinterlace driver

PATCH Superseded Jernej Skrabec 3 participants 11 messages Oct 16, 2019 – Oct 17, 2019

Subsystems (5)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover media: Introduce Allwinner H3 deinterlace driver

Starting with H3, Allwinner began to include standalone deinterlace core in multimedia oriented SoCs. This patch series introduces support for it. Note that new SoCs, like H6, have radically different (updated) deinterlace core, which will need a new driver.

v4l2-compliance report:
v4l2-compliance SHA: dece02f862f38d8f866230ca9f1015cb93ddfac4, 32 bits

Compliance test for sun8i-di device /dev/video0:

Driver Info:

        Driver name      : sun8i-di
        Card type        : sun8i-di
        Bus info         : platform:sun8i-di
        Driver version   : 5.3.0
        Capabilities     : 0x84208000

Video Memory-to-Memory
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04208000
Video Memory-to-Memory
Streaming
Extended Pix Format

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for sun8i-di device /dev/video0: 44, Succeeded: 44, Failed: 0, Warnings: 0

Please take a look.

Best regards,
Jernej

Changes from v2:
- added acked-by and review-by tags
- fixed schema path in H3 deinterlace binding
- moved busy check after format args check

Changes from v1:
- updated Maxime's e-mail in DT binding
- removed "items" for single item in DT binding
- implemented power management
- replaced regmap with direct io access
- set exclusive clock rate
- renamed DEINTERLACE_FRM_CTRL_COEF_CTRL to DEINTERLACE_FRM_CTRL_COEF_ACCESS

Jernej Skrabec (6):
dt-bindings: bus: sunxi: Add H3 MBUS compatible
clk: sunxi-ng: h3: Export MBUS clock
ARM: dts: sunxi: h3/h5: Add MBUS controller node
dt-bindings: media: Add Allwinner H3 Deinterlace binding
media: sun4i: Add H3 deinterlace driver
dts: arm: sun8i: h3: Enable deinterlace unit

 .../bindings/arm/sunxi/sunxi-mbus.txt         |    1 +
 .../media/allwinner,sun8i-h3-deinterlace.yaml |   75 ++
 MAINTAINERS                                   |    7 +
 arch/arm/boot/dts/sun8i-h3.dtsi               |   13 +
 arch/arm/boot/dts/sunxi-h3-h5.dtsi            |    9 +
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h           |    4 -
 drivers/media/platform/sunxi/Kconfig          |    1 +
 drivers/media/platform/sunxi/Makefile         |    1 +
 drivers/media/platform/sunxi/sun8i-di/Kconfig |   11 +
 .../media/platform/sunxi/sun8i-di/Makefile    |    2 +
 .../media/platform/sunxi/sun8i-di/sun8i-di.c  | 1020 +++++++++++++++++
 .../media/platform/sunxi/sun8i-di/sun8i-di.h  |  237 ++++
 include/dt-bindings/clock/sun8i-h3-ccu.h      |    2 +-
 13 files changed, 1378 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-h3-deinterlace.yaml
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Kconfig
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Makefile
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.h
Signature · 1 line
2.23.0
#1 lore raw

PATCH v3 1/6 dt-bindings: bus: sunxi: Add H3 MBUS compatible

Allwinner H3 SoC also contains MBUS controller.

Add compatible for it.

---
 Documentation/devicetree/bindings/arm/sunxi/sunxi-mbus.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/arm/sunxi/sunxi-mbus.txt +1 -0
index 1464a4713553..2005bb486705 100644
@@ -8,6 +8,7 @@ bus.
 Required properties:
  - compatible: Must be one of:
 	- allwinner,sun5i-a13-mbus
+	- allwinner,sun8i-h3-mbus
  - reg: Offset and length of the register set for the controller
  - clocks: phandle to the clock driving the controller
  - dma-ranges: See section 2.3.9 of the DeviceTree Specification
Signature · 1 line
2.23.0
#2 lore raw

PATCH v3 2/6 clk: sunxi-ng: h3: Export MBUS clock

In reply to Jernej Skrabec

MBUS clock will be referenced in MBUS controller node.

Export it.

---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.h      | 4 ----
 include/dt-bindings/clock/sun8i-h3-ccu.h | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-h3.h +0 -4
index b6e2680ef354..d8c38447e11b 100644
@@ -48,10 +48,6 @@
 
 /* Some more module clocks are exported */
 
-#define CLK_MBUS		113
-
-/* And the GPU module clock is exported */
-
 #define CLK_NUMBER_H3		(CLK_GPU + 1)
 #define CLK_NUMBER_H5		(CLK_BUS_SCR1 + 1)
 
include/dt-bindings/clock/sun8i-h3-ccu.h +1 -1
index c5f7e9a70968..30d2d15373a2 100644
@@ -143,7 +143,7 @@
 #define CLK_AVS			110
 #define CLK_HDMI		111
 #define CLK_HDMI_DDC		112
-
+#define CLK_MBUS		113
 #define CLK_GPU			114
 
 /* New clocks imported in H5 */
Signature · 1 line
2.23.0
#3 lore raw

PATCH v3 3/6 ARM: dts: sunxi: h3/h5: Add MBUS controller node

In reply to Jernej Skrabec

Both, H3 and H5, contain MBUS, which is the bus used by DMA devices to access system memory.

MBUS controller is responsible for arbitration between channels based on set priority and can do some other things as well, like report bandwidth used. It also maps RAM region to different address than CPU.

---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sunxi-h3-h5.dtsi +9 -0
index 107eeafad20a..66bee3bea633 100644
@@ -109,6 +109,7 @@
 		compatible = "simple-bus";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		dma-ranges;
 		ranges;
 
 		display_clocks: clock@1000000 {
@@ -544,6 +545,14 @@
 			};
 		};
 
+		mbus: dram-controller@1c62000 {
+			compatible = "allwinner,sun8i-h3-mbus";
+			reg = <0x01c62000 0x1000>;
+			clocks = <&ccu 113>;
+			dma-ranges = <0x00000000 0x40000000 0xc0000000>;
+			#interconnect-cells = <1>;
+		};
+
 		spi0: spi@1c68000 {
 			compatible = "allwinner,sun8i-h3-spi";
 			reg = <0x01c68000 0x1000>;
Signature · 1 line
2.23.0
#4 lore raw

PATCH v3 4/6 dt-bindings: media: Add Allwinner H3 Deinterlace binding

In reply to Jernej Skrabec

Allwinner H3 Deinterlace core is used for deinterlacing interlaced video content. Core can also be found on some later SoCs, like H5 and R40.

---
 .../media/allwinner,sun8i-h3-deinterlace.yaml | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-h3-deinterlace.yaml
Documentation/devicetree/bindings/media/allwinner,sun8i-h3-deinterlace.yaml new file +75 -0
new file mode 100644
index 000000000000..2d27643340ac
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/allwinner,sun8i-h3-deinterlace.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner H3 Deinterlace Device Tree Bindings
+
+maintainers:
+  - Chen-Yu Tsai <[email protected]>
+  - Maxime Ripard <[email protected]>
+
+description: |-
+  The Allwinner H3 and later has a deinterlace core used for
+  deinterlacing interlaced video content.
+
+properties:
+  compatible:
+    const: allwinner,sun8i-h3-deinterlace
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Deinterlace interface clock
+      - description: Deinterlace module clock
+      - description: Deinterlace DRAM clock
+
+  clock-names:
+    items:
+      - const: bus
+      - const: mod
+      - const: ram
+
+  resets:
+    maxItems: 1
+
+  interconnects:
+    maxItems: 1
+
+  interconnect-names:
+    const: dma-mem
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/sun8i-h3-ccu.h>
+    #include <dt-bindings/reset/sun8i-h3-ccu.h>
+
+    deinterlace: deinterlace@1400000 {
+        compatible = "allwinner,sun8i-h3-deinterlace";
+        reg = <0x01400000 0x20000>;
+        clocks = <&ccu CLK_BUS_DEINTERLACE>,
+                 <&ccu CLK_DEINTERLACE>,
+                 <&ccu CLK_DRAM_DEINTERLACE>;
+        clock-names = "bus", "mod", "ram";
+        resets = <&ccu RST_BUS_DEINTERLACE>;
+        interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
+        interconnects = <&mbus 9>;
+        interconnect-names = "dma-mem";
+    };
+
+...
Signature · 1 line
2.23.0
#5 lore raw

PATCH v3 5/6 media: sun4i: Add H3 deinterlace driver

In reply to Jernej Skrabec

Allwinner H3 SoC contains deinterlace unit, which has several modes of operation - bypass, weave, bob and mixed (advanced) mode. I don't know how mixed mode works, but according to Allwinner it gives best results, so they use it exclusively. Currently this mode is also hardcoded here.

For each interleaved frame queued, this driver produces 2 deinterlaced frames. Deinterlaced frames are based on 2 consequtive output buffers, except for the first 2, where same output buffer is given to peripheral as current and previous.

There is no documentation for this core, so register layout and fixed values were taken from BSP driver.

I'm not sure if maximum size of the image unit is capable to process is governed by size of "flag" buffers, frequency or it really is some HW limitation. Currently driver can process full HD image in ~15ms (7.5ms for each capture buffer), which allows to process 1920x1080@60i video smoothly in real time.

---
 MAINTAINERS                                   |    7 +
 drivers/media/platform/sunxi/Kconfig          |    1 +
 drivers/media/platform/sunxi/Makefile         |    1 +
 drivers/media/platform/sunxi/sun8i-di/Kconfig |   11 +
 .../media/platform/sunxi/sun8i-di/Makefile    |    2 +
 .../media/platform/sunxi/sun8i-di/sun8i-di.c  | 1020 +++++++++++++++++
 .../media/platform/sunxi/sun8i-di/sun8i-di.h  |  237 ++++
 7 files changed, 1279 insertions(+)
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Kconfig
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Makefile
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.h
MAINTAINERS +7 -0
index c7b48525822a..c375455125fb 100644
@@ -4646,6 +4646,13 @@ M:	"Maciej W. Rozycki" <[email protected]>
 S:	Maintained
 F:	drivers/net/fddi/defxx.*
 
+DEINTERLACE DRIVERS FOR ALLWINNER H3
+M:	Jernej Skrabec <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/sunxi/sun8i-di/
+
 DELL SMBIOS DRIVER
 M:	Pali Rohár <[email protected]>
 M:	Mario Limonciello <[email protected]>
drivers/media/platform/sunxi/Kconfig +1 -0
index 71808e93ac2e..d7a5621bf327 100644
@@ -1,2 +1,3 @@
 source "drivers/media/platform/sunxi/sun4i-csi/Kconfig"
 source "drivers/media/platform/sunxi/sun6i-csi/Kconfig"
+source "drivers/media/platform/sunxi/sun8i-di/Kconfig"
drivers/media/platform/sunxi/Makefile +1 -0
index a05127529006..3878cb4efdc2 100644
@@ -1,2 +1,3 @@
 obj-y		+= sun4i-csi/
 obj-y		+= sun6i-csi/
+obj-y		+= sun8i-di/
drivers/media/platform/sunxi/sun8i-di/Kconfig new file +11 -0
new file mode 100644
index 000000000000..dbd77a61e3b3
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIDEO_SUN8I_DEINTERLACE
+	tristate "Allwinner Deinterlace driver"
+	depends on VIDEO_DEV && VIDEO_V4L2
+	depends on HAS_DMA
+	depends on OF
+	depends on PM
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	help
+	   Support for the Allwinner Deinterlace unit found on some SoCs.
drivers/media/platform/sunxi/sun8i-di/Makefile new file +2 -0
new file mode 100644
index 000000000000..109f7e5442b7
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VIDEO_SUN8I_DEINTERLACE) += sun8i-di.o
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c new file +1020 -0

1,020 lines not on this page · raw message

drivers/media/platform/sunxi/sun8i-di/sun8i-di.h new file +237 -0

237 lines not on this page · raw message

Signature · 1 line
2.23.0
#6 lore raw

Re: [PATCH v3 5/6] media: sun4i: Add H3 deinterlace driver

Quoted 57 lines · Jernej Skrabec

Allwinner H3 SoC contains deinterlace unit, which has several modes of operation - bypass, weave, bob and mixed (advanced) mode. I don't know how mixed mode works, but according to Allwinner it gives best results, so they use it exclusively. Currently this mode is also hardcoded here.

For each interleaved frame queued, this driver produces 2 deinterlaced frames. Deinterlaced frames are based on 2 consequtive output buffers, except for the first 2, where same output buffer is given to peripheral as current and previous.

There is no documentation for this core, so register layout and fixed values were taken from BSP driver.

I'm not sure if maximum size of the image unit is capable to process is governed by size of "flag" buffers, frequency or it really is some HW limitation. Currently driver can process full HD image in ~15ms (7.5ms for each capture buffer), which allows to process 1920x1080@60i video smoothly in real time.

---
 MAINTAINERS                                   |    7 +
 drivers/media/platform/sunxi/Kconfig          |    1 +
 drivers/media/platform/sunxi/Makefile         |    1 +
 drivers/media/platform/sunxi/sun8i-di/Kconfig |   11 +
 .../media/platform/sunxi/sun8i-di/Makefile    |    2 +
 .../media/platform/sunxi/sun8i-di/sun8i-di.c  | 1020 +++++++++++++++++
 .../media/platform/sunxi/sun8i-di/sun8i-di.h  |  237 ++++
 7 files changed, 1279 insertions(+)
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Kconfig
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Makefile
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.h
MAINTAINERS +7 -0
index c7b48525822a..c375455125fb 100644
@@ -4646,6 +4646,13 @@ M:	"Maciej W. Rozycki" <[email protected]>
 S:	Maintained
 F:	drivers/net/fddi/defxx.*
 
+DEINTERLACE DRIVERS FOR ALLWINNER H3
+M:	Jernej Skrabec <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/sunxi/sun8i-di/
+
 DELL SMBIOS DRIVER
 M:	Pali Rohár <[email protected]>
 M:	Mario Limonciello <[email protected]>
drivers/media/platform/sunxi/Kconfig +0 -0
index 71808e93ac2e..d7a5621bf327 100644

drivers/media/platform/sunxi/Kconfig line 3

Quoted 3 lines
drivers/media/platform/sunxi/Kconfig +1 -0
@@ -1,2 +1,3 @@
 source "drivers/media/platform/sunxi/sun4i-csi/Kconfig"
 source "drivers/media/platform/sunxi/sun6i-csi/Kconfig"
+source "drivers/media/platform/sunxi/sun8i-di/Kconfig"

This is a m2m driver, so this belongs in drivers/media/platform/Kconfig in the Memory-to-memory section.

Quoted 15 lines
drivers/media/platform/sunxi/Makefile +1 -0
index a05127529006..3878cb4efdc2 100644
@@ -1,2 +1,3 @@
 obj-y		+= sun4i-csi/
 obj-y		+= sun6i-csi/
+obj-y		+= sun8i-di/
drivers/media/platform/sunxi/sun8i-di/Kconfig new file +1 -0
new file mode 100644
index 000000000000..dbd77a61e3b3
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only

drivers/media/platform/sunxi/sun8i-di/Kconfig line 11

Quoted 10 lines
drivers/media/platform/sunxi/sun8i-di/Kconfig new file +10 -0
+config VIDEO_SUN8I_DEINTERLACE
+	tristate "Allwinner Deinterlace driver"
+	depends on VIDEO_DEV && VIDEO_V4L2
+	depends on HAS_DMA
+	depends on OF
+	depends on PM
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	help
+	   Support for the Allwinner Deinterlace unit found on some SoCs.

Shouldn't this depend on ARCH_SUNXI || COMPILE_TEST? And also on COMMON_CLK?

Regards,

Hans

#7 lore raw

Re: [PATCH v3 5/6] media: sun4i: Add H3 deinterlace driver

Dne četrtek, 17. oktober 2019 ob 09:51:28 CEST je Hans Verkuil napisal(a):

Quoted 95 lines · Jernej Skrabec
Quoted 62 lines

Allwinner H3 SoC contains deinterlace unit, which has several modes of operation - bypass, weave, bob and mixed (advanced) mode. I don't know how mixed mode works, but according to Allwinner it gives best results, so they use it exclusively. Currently this mode is also hardcoded here.

For each interleaved frame queued, this driver produces 2 deinterlaced frames. Deinterlaced frames are based on 2 consequtive output buffers, except for the first 2, where same output buffer is given to peripheral as current and previous.

There is no documentation for this core, so register layout and fixed values were taken from BSP driver.

I'm not sure if maximum size of the image unit is capable to process is governed by size of "flag" buffers, frequency or it really is some HW limitation. Currently driver can process full HD image in ~15ms (7.5ms for each capture buffer), which allows to process 1920x1080@60i video smoothly in real time.

---

 MAINTAINERS                                   |    7 +
 drivers/media/platform/sunxi/Kconfig          |    1 +
 drivers/media/platform/sunxi/Makefile         |    1 +
 drivers/media/platform/sunxi/sun8i-di/Kconfig |   11 +
 .../media/platform/sunxi/sun8i-di/Makefile    |    2 +
 .../media/platform/sunxi/sun8i-di/sun8i-di.c  | 1020 +++++++++++++++++
 .../media/platform/sunxi/sun8i-di/sun8i-di.h  |  237 ++++
 7 files changed, 1279 insertions(+)
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Kconfig
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/Makefile
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
 create mode 100644 drivers/media/platform/sunxi/sun8i-di/sun8i-di.h
MAINTAINERS +7 -0
index c7b48525822a..c375455125fb 100644
@@ -4646,6 +4646,13 @@ M:	"Maciej W. Rozycki" <[email protected]>
 
 S:	Maintained
 F:	drivers/net/fddi/defxx.*
 
+DEINTERLACE DRIVERS FOR ALLWINNER H3
+M:	Jernej Skrabec <[email protected]>
+L:	[email protected]
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/platform/sunxi/sun8i-di/
+
 
 DELL SMBIOS DRIVER

M: Pali Rohár <[email protected]>
M: Mario Limonciello <[email protected]>

(quoted diff) +0 -0

b/drivers/media/platform/sunxi/Kconfig index 71808e93ac2e..d7a5621bf327 100644

drivers/media/platform/sunxi/Kconfig line 3

Quoted 5 lines
drivers/media/platform/sunxi/Kconfig +1 -0
@@ -1,2 +1,3 @@
 
 source "drivers/media/platform/sunxi/sun4i-csi/Kconfig"
 source "drivers/media/platform/sunxi/sun6i-csi/Kconfig"
 
+source "drivers/media/platform/sunxi/sun8i-di/Kconfig"

This is a m2m driver, so this belongs in drivers/media/platform/Kconfig in the Memory-to-memory section.

Quoted 23 lines
(quoted diff) +0 -0

b/drivers/media/platform/sunxi/Makefile index a05127529006..3878cb4efdc2 100644

drivers/media/platform/sunxi/Makefile +1 -0
@@ -1,2 +1,3 @@
 
 obj-y		+= sun4i-csi/
 obj-y		+= sun6i-csi/
 
+obj-y		+= sun8i-di/
(quoted diff) +0 -0

b/drivers/media/platform/sunxi/sun8i-di/Kconfig new file mode 100644 index 000000000000..dbd77a61e3b3

drivers/media/platform/sunxi/sun8i-di/Kconfig new file +6 -0
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIDEO_SUN8I_DEINTERLACE
+	tristate "Allwinner Deinterlace driver"
+	depends on VIDEO_DEV && VIDEO_V4L2
+	depends on HAS_DMA
+	depends on OF
Quoted 8 lines

drivers/media/platform/sunxi/sun8i-di/Kconfig line 11

Quoted 5 lines
drivers/media/platform/sunxi/sun8i-di/Kconfig new file +5 -0
+	depends on PM
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	help
+	   Support for the Allwinner Deinterlace unit found on some SoCs.

Shouldn't this depend on ARCH_SUNXI || COMPILE_TEST? And also on COMMON_CLK?

Yes to both. Also I don't see a reason why it would depend on HAS_DMA, so I will remove that.

Best regards,
Jernej

Quoted 4 lines

Regards,

Hans

Acked-by on v3 5/6
#8 lore raw

Re: [PATCH v3 5/6] media: sun4i: Add H3 deinterlace driver

In reply to Jernej Skrabec

Hi,

I have a small comment that can definitely be addressed in a subsequent patch

Quoted 19 lines · Jernej Skrabec
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c new file +19 -0
+	dev->bus_clk = devm_clk_get(dev->dev, "bus");
+	if (IS_ERR(dev->bus_clk)) {
+		dev_err(dev->dev, "Failed to get bus clock\n");
+
+		return PTR_ERR(dev->bus_clk);
+	}
+
+	dev->mod_clk = devm_clk_get(dev->dev, "mod");
+	if (IS_ERR(dev->mod_clk)) {
+		dev_err(dev->dev, "Failed to get mod clock\n");
+
+		return PTR_ERR(dev->mod_clk);
+	}
+
+	dev->ram_clk = devm_clk_get(dev->dev, "ram");
+	if (IS_ERR(dev->ram_clk)) {
+		dev_err(dev->dev, "Failed to get ram clock\n");
+
+		return PTR_ERR(dev->ram_clk);

drivers/media/platform/sunxi/sun8i-di/sun8i-di.c line 871

Quoted 10 lines
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c new file +10 -0
+	}
+
+	dev->rstc = devm_reset_control_get(dev->dev, NULL);
+	if (IS_ERR(dev->rstc)) {
+		dev_err(dev->dev, "Failed to get reset control\n");
+
+		return PTR_ERR(dev->rstc);
+	}
+
+	clk_set_rate_exclusive(dev->mod_clk, 300000000);

clk_set_rate_exclusive puts a pretty big constraint on the clock tree, and we shouldn't really enforce it if the device is unused.

I guess we should move it to the runtime_pm resume hook (with the put_exclusive call in suspend).

Otherwise, that patch is

Maxime

#9 lore raw

Re: [PATCH v3 5/6] media: sun4i: Add H3 deinterlace driver

Dne četrtek, 17. oktober 2019 ob 11:28:00 CEST je Maxime Ripard napisal(a):

Quoted 29 lines

Hi,

I have a small comment that can definitely be addressed in a subsequent patch

Quoted 24 lines · Jernej Skrabec
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c new file +24 -0
+	dev->bus_clk = devm_clk_get(dev->dev, "bus");
+	if (IS_ERR(dev->bus_clk)) {
+		dev_err(dev->dev, "Failed to get bus clock\n");
+
+		return PTR_ERR(dev->bus_clk);
+	}
+
+	dev->mod_clk = devm_clk_get(dev->dev, "mod");
+	if (IS_ERR(dev->mod_clk)) {
+		dev_err(dev->dev, "Failed to get mod clock\n");
+
+		return PTR_ERR(dev->mod_clk);
+	}
+
+	dev->ram_clk = devm_clk_get(dev->dev, "ram");
+	if (IS_ERR(dev->ram_clk)) {
+		dev_err(dev->dev, "Failed to get ram clock\n");
+
+		return PTR_ERR(dev->ram_clk);
+	}
+
+	dev->rstc = devm_reset_control_get(dev->dev, NULL);
+	if (IS_ERR(dev->rstc)) {
+		dev_err(dev->dev, "Failed to get reset control\n");
Quoted 8 lines

drivers/media/platform/sunxi/sun8i-di/sun8i-di.c line 871

Quoted 5 lines
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c new file +5 -0
+
+		return PTR_ERR(dev->rstc);
+	}
+
+	clk_set_rate_exclusive(dev->mod_clk, 300000000);

clk_set_rate_exclusive puts a pretty big constraint on the clock tree, and we shouldn't really enforce it if the device is unused.

That is true in general, but as I said before, that is not really an issue for H3. Deinterlace clock default parent is peripheral clock, which is fixed to 600 MHz and doesn't change.

Quoted 3 lines

I guess we should move it to the runtime_pm resume hook (with the put_exclusive call in suspend).

Ok, I'll move it in case that this deinterlace core is used on other SoCs with non-fixed parent clock.

Quoted 3 lines

Otherwise, that patch is

Thanks!

Best regards,
Jernej

#10 lore raw

PATCH v3 6/6 dts: arm: sun8i: h3: Enable deinterlace unit

In reply to Jernej Skrabec

Allwinner H3 SoC contains deinterlace unit, which can be used in combination with VPU unit to decode and process interlaced videos.

Add a node for it.

---
 arch/arm/boot/dts/sun8i-h3.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/sun8i-h3.dtsi +13 -0
index e37c30e811d3..7a59c57d2114 100644
@@ -120,6 +120,19 @@
 	};
 
 	soc {
+		deinterlace: deinterlace@1400000 {
+			compatible = "allwinner,sun8i-h3-deinterlace";
+			reg = <0x01400000 0x20000>;
+			clocks = <&ccu CLK_BUS_DEINTERLACE>,
+				 <&ccu CLK_DEINTERLACE>,
+				 <&ccu CLK_DRAM_DEINTERLACE>;
+			clock-names = "bus", "mod", "ram";
+			resets = <&ccu RST_BUS_DEINTERLACE>;
+			interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
+			interconnects = <&mbus 9>;
+			interconnect-names = "dma-mem";
+		};
+
 		syscon: system-control@1c00000 {
 			compatible = "allwinner,sun8i-h3-system-control";
 			reg = <0x01c00000 0x1000>;
Signature · 1 line
2.23.0