Skip to contentSkip to conversation

Add Rockchip RGA V4l2 support

PATCH Superseded Jacob Chen 6 participants 26 messages Jul 15, 2017 – Jul 19, 2017

Subsystems (3)

v2 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Jacob Chen

author
#0 lore raw

v2 cover Add Rockchip RGA V4l2 support

This patch series add a v4l2 m2m drvier for rockchip RGA direct rendering based 2d graphics acceleration module.

change in V2:
- generalize the controls.
- map buffers (10-50 us) in every cmd-run rather than in buffer-import to avoid get_free_pages failed on actively used systems.
- remove status in dt-bindings examples.

Jacob Chen (6):
[media] v4l: add blend modes controls [media] rockchip/rga: v4l2 m2m support
ARM: dts: rockchip: add RGA device node for RK3288
ARM: dts: rockchip: add RGA device node for RK3399
ARM: dts: rockchip: enable RGA for rk3288 devices
dt-bindings: Document the Rockchip RGA bindings

 .../devicetree/bindings/media/rockchip-rga.txt     |  35 +
 arch/arm/boot/dts/rk3288-evb.dtsi                  |   4 +
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi  |   4 +
 arch/arm/boot/dts/rk3288-firefly.dtsi              |   4 +
 arch/arm/boot/dts/rk3288-miqi.dts                  |   4 +
 arch/arm/boot/dts/rk3288-popmetal.dts              |   4 +
 arch/arm/boot/dts/rk3288-tinker.dts                |   4 +
 arch/arm/boot/dts/rk3288.dtsi                      |  13 +
 arch/arm64/boot/dts/rockchip/rk3399.dtsi           |  13 +
 drivers/media/platform/Kconfig                     |  11 +
 drivers/media/platform/Makefile                    |   2 +
 drivers/media/platform/rockchip-rga/Makefile       |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c      | 176 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c       | 456 ++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h       | 434 +++++++++
 drivers/media/platform/rockchip-rga/rga.c          | 979 +++++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h          | 133 +++
 drivers/media/v4l2-core/v4l2-ctrls.c               |  19 +
 include/uapi/linux/v4l2-controls.h                 |  18 +-
 19 files changed, 2315 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/6 v4l: add blend modes controls

At peresent, we don't have a control for Compositing and Blend. All drivers are just doing copies while actually many hardwares supports more functions.

So Adding V4L2 controls for Compositing and Blend, used for for composting streams.

The values are based on porter duff operations.
Defined in below links.
https://developer.xamarin.com/api/type/Android.Graphics.PorterDuff+Mode/

---
 drivers/media/v4l2-core/v4l2-ctrls.c | 19 +++++++++++++++++++
 include/uapi/linux/v4l2-controls.h   | 18 +++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls.c +19 -0
index b9e08e3..8a235fd 100644
@@ -216,6 +216,21 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Private Packet, IVTV Format",
 		NULL
 	};
+	static const char * const blend_modes[] = {
+		"Source",
+		"Source Top",
+		"Source In",
+		"Source Out",
+		"Source Over",
+		"Destination",
+		"Destination Top",
+		"Destination In",
+		"Destination Out",
+		"Destination Over",
+		"Add",
+		"Clear",
+		NULL
+	};
 	static const char * const camera_power_line_frequency[] = {
 		"Disabled",
 		"50 Hz",
@@ -522,6 +537,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return camera_exposure_metering;
 	case V4L2_CID_AUTO_FOCUS_RANGE:
 		return camera_auto_focus_range;
+	case V4L2_CID_BLEND:
+		return blend_modes;
 	case V4L2_CID_COLORFX:
 		return colorfx;
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
@@ -655,6 +672,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:	return "Min Number of Output Buffers";
 	case V4L2_CID_ALPHA_COMPONENT:		return "Alpha Component";
 	case V4L2_CID_COLORFX_CBCR:		return "Color Effects, CbCr";
+	case V4L2_CID_BLEND:			return "Compositing and Blend Modes";
 
 	/* Codec controls */
 	/* The MPEG controls are applicable to all codec controls
@@ -1033,6 +1051,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_STREAM_VBI_FMT:
 	case V4L2_CID_EXPOSURE_AUTO:
 	case V4L2_CID_AUTO_FOCUS_RANGE:
+	case V4L2_CID_BLEND:
 	case V4L2_CID_COLORFX:
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 	case V4L2_CID_TUNE_PREEMPHASIS:
include/uapi/linux/v4l2-controls.h +17 -1
index 0d2e1e0..019fdca 100644
@@ -140,8 +140,24 @@ enum v4l2_colorfx {
 #define V4L2_CID_ALPHA_COMPONENT		(V4L2_CID_BASE+41)
 #define V4L2_CID_COLORFX_CBCR			(V4L2_CID_BASE+42)
 
+#define V4L2_CID_BLEND				(V4L2_CID_BASE+43)
+enum v4l2_blend_mode {
+	V4L2_BLEND_SRC				= 0,
+	V4L2_BLEND_SRCATOP			= 1,
+	V4L2_BLEND_SRCIN			= 2,
+	V4L2_BLEND_SRCOUT			= 3,
+	V4L2_BLEND_SRCOVER			= 4,
+	V4L2_BLEND_DST				= 5,
+	V4L2_BLEND_DSTATOP			= 6,
+	V4L2_BLEND_DSTIN			= 7,
+	V4L2_BLEND_DSTOUT			= 8,
+	V4L2_BLEND_DSTOVER			= 9,
+	V4L2_BLEND_ADD				= 10,
+	V4L2_BLEND_CLEAR			= 11,
+};
+
 /* last CID + 1 */
-#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+43)
+#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+44)
 
 /* USER-class private control IDs */
 
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v2 2/6 rockchip/rga: v4l2 m2m support

In reply to Jacob Chen

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.
- copy
- fast solid color fill
- rotation
- flip
- alpha blending

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

---
 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 ++++++++++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
drivers/media/platform/Kconfig +11 -0
index c9106e1..8199bcf 100644
@@ -411,6 +411,17 @@ config VIDEO_RENESAS_VSP1
 	  To compile this driver as a module, choose M here: the module
 	  will be called vsp1.
 
+config VIDEO_ROCKCHIP_RGA
+	tristate "Rockchip Raster 2d Grapphic Acceleration Unit"
+	depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
+	depends on ARCH_ROCKCHIP || COMPILE_TEST
+	select VIDEOBUF2_DMA_SG
+	select V4L2_MEM2MEM_DEV
+	default n
+	---help---
+	  This is a v4l2 driver for Rockchip SOC RGA2
+	  2d graphics accelerator.
+
 config VIDEO_TI_VPE
 	tristate "TI VPE (Video Processing Engine) driver"
 	depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +2 -0
index 349ddf6..3bf096f 100644
@@ -54,6 +54,8 @@ obj-$(CONFIG_VIDEO_RENESAS_FDP1)	+= rcar_fdp1.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU) 	+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)	+= vsp1/
 
+obj-$(CONFIG_VIDEO_ROCKCHIP_RGA)	+= rockchip-rga/
+
 obj-y	+= omap/
 
 obj-$(CONFIG_VIDEO_AM437X_VPFE)		+= am437x/
drivers/media/platform/rockchip-rga/Makefile new file +3 -0
new file mode 100644
index 0000000..92fe254
@@ -0,0 +1,3 @@
+rockchip-rga-objs := rga.o rga-hw.o rga-buf.o
+
+obj-$(CONFIG_VIDEO_ROCKCHIP_RGA) += rockchip-rga.o
drivers/media/platform/rockchip-rga/rga-buf.c new file +122 -0

122 lines not on this page · raw message

drivers/media/platform/rockchip-rga/rga-hw.c new file +652 -0

652 lines not on this page · raw message

drivers/media/platform/rockchip-rga/rga-hw.h new file +437 -0

437 lines not on this page · raw message

drivers/media/platform/rockchip-rga/rga.c new file +958 -0

958 lines not on this page · raw message

drivers/media/platform/rockchip-rga/rga.h new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#14 lore raw

PATCH v2 3/6 ARM: dts: rockchip: add RGA device node for RK3288

In reply to Jacob Chen

This patch add the RGA dt config of rk3288 SoC.

---
 arch/arm/boot/dts/rk3288.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +13 -0
index 1efc2f2..83d025d 100644
@@ -945,6 +945,19 @@
 		status = "okay";
 	};
 
+	rga: rga at ff920000 {
+		compatible = "rockchip,rk3288-rga";
+		reg = <0xff920000 0x180>;
+		interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>;
+		clock-names = "aclk", "hclk", "sclk";
+		power-domains = <&power RK3288_PD_VIO>;
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_RGA_AXI>, <&cru SRST_RGA_AHB>;
+		reset-names = "core", "axi", "ahb";
+		status = "disabled";
+	};
+
 	vopb: vop at ff930000 {
 		compatible = "rockchip,rk3288-vop";
 		reg = <0xff930000 0x19c>;
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH v2 4/6 ARM: dts: rockchip: add RGA device node for RK3399

In reply to Jacob Chen

This patch add the RGA dt config of RK3399 SoC.

---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +13 -0
index 8e6d1bd..fc33ce5 100644
@@ -1056,6 +1056,19 @@
 		status = "disabled";
 	};
 
+	rga: rga at ff680000 {
+		compatible = "rockchip,rk3399-rga";
+		reg = <0x0 0xff680000 0x0 0x10000>;
+		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH 0>;
+		interrupt-names = "rga";
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA_CORE>;
+		clock-names = "aclk", "hclk", "sclk";
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_A_RGA>, <&cru SRST_H_RGA>;
+		reset-names = "core", "axi", "ahb";
+		power-domains = <&power RK3399_PD_RGA>;
+		status = "disabled";
+	};
+
 	efuse0: efuse at ff690000 {
 		compatible = "rockchip,rk3399-efuse";
 		reg = <0x0 0xff690000 0x0 0x80>;
Signature · 1 line
2.7.4
author
#17 lore raw

PATCH v2 5/6 ARM: dts: rockchip: enable RGA for rk3288 devices

In reply to Jacob Chen
---
 arch/arm/boot/dts/rk3288-evb.dtsi                 | 4 ++++
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-firefly.dtsi             | 4 ++++
 arch/arm/boot/dts/rk3288-miqi.dts                 | 4 ++++
 arch/arm/boot/dts/rk3288-popmetal.dts             | 4 ++++
 arch/arm/boot/dts/rk3288-tinker.dts               | 4 ++++
 6 files changed, 24 insertions(+)
arch/arm/boot/dts/rk3288-evb.dtsi +4 -0
index 4905760..ec12162 100644
@@ -379,6 +379,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &usbphy {
 	status = "okay";
 };
arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi +4 -0
index 8134966..fffa92e2 100644
@@ -283,6 +283,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &tsadc {
 	rockchip,hw-tshut-mode = <0>;
 	rockchip,hw-tshut-polarity = <0>;
arch/arm/boot/dts/rk3288-firefly.dtsi +4 -0
index f520589..74a6ce5 100644
@@ -500,6 +500,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc_18>;
 	status = "okay";
arch/arm/boot/dts/rk3288-miqi.dts +4 -0
index 21326f3..dc5e6bd 100644
@@ -401,6 +401,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc_18>;
 	status = "okay";
arch/arm/boot/dts/rk3288-popmetal.dts +4 -0
index aa1f9ec..362e5aa 100644
@@ -490,6 +490,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &tsadc {
 	rockchip,hw-tshut-mode = <0>;
 	rockchip,hw-tshut-polarity = <0>;
arch/arm/boot/dts/rk3288-tinker.dts +4 -0
index 525b0e5..1a8c149 100644
@@ -460,6 +460,10 @@
 	status = "okay";
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc18_ldo1>;
 	status ="okay";
Signature · 1 line
2.7.4
author
#22 lore raw

PATCH v2 6/6 dt-bindings: Document the Rockchip RGA bindings

In reply to Jacob Chen

Add DT bindings documentation for Rockchip RGA

---
 .../devicetree/bindings/media/rockchip-rga.txt     | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +35 -0
new file mode 100644
index 0000000..966eba0
@@ -0,0 +1,35 @@
+device-tree bindings for rockchip 2D raster graphic acceleration controller (RGA)
+
+RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D
+graphics operations, such as point/line drawing, image scaling, rotation,
+BitBLT, alpha blending and image blur/sharpness.
+
+Required properties:
+- compatible: value should be one of the following
+		"rockchip,rk3228-rga";
+		"rockchip,rk3288-rga";
+		"rockchip,rk3399-rga";
+
+- interrupts: RGA interrupt number.
+
+- clocks: phandle to RGA sclk/hclk/aclk clocks
+
+- clock-names: should be "aclk" "hclk" and "sclk"
+
+- resets: Must contain an entry for each entry in reset-names.
+  See ../reset/reset.txt for details.
+- reset-names: should be "core" "axi" and "ahb"
+
+Example:
+SoC specific DT entry:
+	rga: rga at ff680000 {
+		compatible = "rockchip,rk3399-rga";
+		reg = <0xff680000 0x10000>;
+		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA_CORE>;
+		clock-names = "aclk", "hclk", "sclk";
+
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_A_RGA>, <&cru SRST_H_RGA>;
+		reset-names = "core, "axi", "ahb";
+	};
Signature · 1 line
2.7.4
maintainer
#15 lore raw

Re: [PATCH v2 3/6] ARM: dts: rockchip: add RGA device node for RK3288

In reply to Jacob Chen

Hi Jacob,

Am Samstag, 15. Juli 2017, 14:58:37 CEST schrieb Jacob Chen:

Quoted 4 lines

This patch add the RGA dt config of rk3288 SoC.

from the Signed-off it looks like Yakir was te original author of the patch. So please fix the authorship or drop the top Signed-off by.

Same for other patches like this.

Thanks
Heiko

Quoted 29 lines
---
 arch/arm/boot/dts/rk3288.dtsi | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +13 -0
index 1efc2f2..83d025d 100644
@@ -945,6 +945,19 @@
 		status = "okay";
 	};
 
+	rga: rga at ff920000 {
+		compatible = "rockchip,rk3288-rga";
+		reg = <0xff920000 0x180>;
+		interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>;
+		clock-names = "aclk", "hclk", "sclk";
+		power-domains = <&power RK3288_PD_VIO>;
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_RGA_AXI>, <&cru SRST_RGA_AHB>;
+		reset-names = "core", "axi", "ahb";
+		status = "disabled";
+	};
+
 	vopb: vop at ff930000 {
 		compatible = "rockchip,rk3288-vop";
 		reg = <0xff930000 0x19c>;
#18 lore raw

Re: [PATCH v2 5/6] ARM: dts: rockchip: enable RGA for rk3288 devices

In reply to Jacob Chen

Hi Jacob,

Thank you for the patch.

Quoted 8 lines · On Saturday 15 Jul 2017 14:58:39 Jacob Chen wrote:
---
 arch/arm/boot/dts/rk3288-evb.dtsi                 | 4 ++++
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-firefly.dtsi             | 4 ++++
 arch/arm/boot/dts/rk3288-miqi.dts                 | 4 ++++
 arch/arm/boot/dts/rk3288-popmetal.dts             | 4 ++++
 arch/arm/boot/dts/rk3288-tinker.dts               | 4 ++++

Some boards are missing from this list (Fennec, Phycore, ...) What criteria have you used to decide on which ones to enable the RGA ? That should be explained in the commit message.

Quoted 93 lines
 6 files changed, 24 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-evb.dtsi index 4905760..ec12162 100644

arch/arm/boot/dts/rk3288-evb.dtsi +4 -0
@@ -379,6 +379,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &usbphy {
 	status = "okay";
 };
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi index 8134966..fffa92e2 100644

arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi +4 -0
@@ -283,6 +283,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &tsadc {
 	rockchip,hw-tshut-mode = <0>;
 	rockchip,hw-tshut-polarity = <0>;
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-firefly.dtsi index f520589..74a6ce5 100644

arch/arm/boot/dts/rk3288-firefly.dtsi +4 -0
@@ -500,6 +500,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc_18>;
 	status = "okay";
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-miqi.dts index 21326f3..dc5e6bd 100644

arch/arm/boot/dts/rk3288-miqi.dts +4 -0
@@ -401,6 +401,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc_18>;
 	status = "okay";
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-popmetal.dts index aa1f9ec..362e5aa 100644

arch/arm/boot/dts/rk3288-popmetal.dts +4 -0
@@ -490,6 +490,10 @@
 	};
 };
 
+&rga {
+	status = "okay";
+};
+
 &tsadc {
 	rockchip,hw-tshut-mode = <0>;
 	rockchip,hw-tshut-polarity = <0>;
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-tinker.dts index 525b0e5..1a8c149 100644

arch/arm/boot/dts/rk3288-tinker.dts +4 -0
@@ -460,6 +460,10 @@
 	status = "okay";
 };
 
+&rga {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcc18_ldo1>;
 	status ="okay";
Signature · 3 lines
Regards,

Laurent Pinchart
#23 lore raw

Re: [PATCH v2 6/6] dt-bindings: Document the Rockchip RGA bindings

In reply to Jacob Chen

Hi Jacob,

Thank you for the patch.

Quoted 18 lines · On Saturday 15 Jul 2017 14:58:40 Jacob Chen wrote:

Add DT bindings documentation for Rockchip RGA

---
 .../devicetree/bindings/media/rockchip-rga.txt     | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/media/rockchip-rga.txt new file mode 100644
index 0000000..966eba0

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
@@ -0,0 +1,35 @@
+device-tree bindings for rockchip 2D raster graphic acceleration controller

(RGA)

Documentation/devicetree/bindings/media/rockchip-rga.txt line 3

Quoted 2 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+
+RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D

"Separate" from what ? Do you mean "standalone" ?

Documentation/devicetree/bindings/media/rockchip-rga.txt line 11

Quoted 8 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +8 -0
+graphics operations, such as point/line drawing, image scaling, rotation,
+BitBLT, alpha blending and image blur/sharpness.
+
+Required properties:
+- compatible: value should be one of the following
+		"rockchip,rk3228-rga";
+		"rockchip,rk3288-rga";
+		"rockchip,rk3399-rga";

The driver in patch 2/6 has match entry for rk3328, which is missing from this list.

As the implementation of the driver doesn't seem to discriminate between the four SoCs, wouldn't it make sense to create a generic compatible string on which the driver would match ? You can have both the generic and SoC-specific compatible strings in DT if there are differences between the IP core in those SoCs that might need to be handled later by the driver.

Quoted 1 line

+- interrupts: RGA interrupt number.

This is an "interrupt specifier", not just an "interrupt number" (as you can see in the example below there are three numbers)

Documentation/devicetree/bindings/media/rockchip-rga.txt line 17

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- clocks: phandle to RGA sclk/hclk/aclk clocks
+
+- clock-names: should be "aclk" "hclk" and "sclk"

Nitpicking, there should be a comma after "aclk".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- resets: Must contain an entry for each entry in reset-names.
+  See ../reset/reset.txt for details.
+- reset-names: should be "core" "axi" and "ahb"

And a comma after "core".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 24

Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+
+Example:
+SoC specific DT entry:

s/SoC specific/SoC-specific/

Documentation/devicetree/bindings/media/rockchip-rga.txt line 29

Quoted 5 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +5 -0
+	rga: rga@ff680000 {
+		compatible = "rockchip,rk3399-rga";
+		reg = <0xff680000 0x10000>;
+		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";

The interrupt-names property is not described above. Do you really need it ?

Documentation/devicetree/bindings/media/rockchip-rga.txt

Quoted 1 line
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru 

SCLK_RGA_CORE>;

Documentation/devicetree/bindings/media/rockchip-rga.txt

Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+		clock-names = "aclk", "hclk", "sclk";
+
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_A_RGA>, <&cru 

SRST_H_RGA>;

Quoted 2 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+		reset-names = "core, "axi", "ahb";
+	};
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Re: [PATCH v2 1/6] [media] v4l: add blend modes controls

In reply to Jacob Chen

Hi Jacob,

Thank you for the patch.

Quoted 10 lines · On Saturday 15 Jul 2017 14:58:35 Jacob Chen wrote:

At peresent, we don't have a control for Compositing and Blend. All drivers are just doing copies while actually many hardwares supports more functions.

So Adding V4L2 controls for Compositing and Blend, used for for composting streams.

The values are based on porter duff operations.
Defined in below links.
https://developer.xamarin.com/api/type/Android.Graphics.PorterDuff+Mode/

According to http://ssp.impulsetrain.com/porterduff.html,

"Despite being referred to as alpha blending and despite alpha often being used to model opacity, in concept Porter/Duff is not a way to blend the source and destination shapes. It is way to overlay, combine and trim them as if they were pieces of cardboard."

It then goes on defining blend modes that are a better match for the definition of blend. You might thus want to rename this control.

Quoted 5 lines
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 19 +++++++++++++++++++
 include/uapi/linux/v4l2-controls.h   | 18 +++++++++++++++++-

Controls need to be documented in Documentation/media/uapi/v4l/control.rst or Documentation/media/uapi/v4l/extended-controls.rst.

Quoted 39 lines
 2 files changed, 36 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/media/v4l2-core/v4l2-ctrls.c index b9e08e3..8a235fd 100644

drivers/media/v4l2-core/v4l2-ctrls.c +17 -0
@@ -216,6 +216,21 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"Private Packet, IVTV Format",
 		NULL
 	};
+	static const char * const blend_modes[] = {
+		"Source",
+		"Source Top",
+		"Source In",
+		"Source Out",
+		"Source Over",
+		"Destination",
+		"Destination Top",
+		"Destination In",
+		"Destination Out",
+		"Destination Over",
+		"Add",
+		"Clear",
+		NULL
+	};
 	static const char * const camera_power_line_frequency[] = {
 		"Disabled",
 		"50 Hz",
@@ -522,6 +537,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return camera_exposure_metering;
 	case V4L2_CID_AUTO_FOCUS_RANGE:
 		return camera_auto_focus_range;
+	case V4L2_CID_BLEND:
+		return blend_modes;
 	case V4L2_CID_COLORFX:
 		return colorfx;
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
@@ -655,6 +672,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:	return "Min Number of Output
Quoted 1 line

Buffers"; case V4L2_CID_ALPHA_COMPONENT: return "Alpha

Component";

drivers/media/v4l2-core/v4l2-ctrls.c

Quoted 2 lines
drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
 	case V4L2_CID_COLORFX_CBCR:		return "Color Effects, CbCr";
+	case V4L2_CID_BLEND:			return "Compositing and Blend 

Modes";

Quoted 16 lines
drivers/media/v4l2-core/v4l2-ctrls.c +0 -0
 	/* Codec controls */
 	/* The MPEG controls are applicable to all codec controls
@@ -1033,6 +1051,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum

v4l2_ctrl_type *type, case V4L2_CID_MPEG_STREAM_VBI_FMT:

drivers/media/v4l2-core/v4l2-ctrls.c +1 -0
 	case V4L2_CID_EXPOSURE_AUTO:
 	case V4L2_CID_AUTO_FOCUS_RANGE:
+	case V4L2_CID_BLEND:
 	case V4L2_CID_COLORFX:
 	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
 	case V4L2_CID_TUNE_PREEMPHASIS:
(quoted diff) +0 -0

b/include/uapi/linux/v4l2-controls.h index 0d2e1e0..019fdca 100644

include/uapi/linux/v4l2-controls.h enum v4l2_colorfx { · line 143

Quoted 4 lines
include/uapi/linux/v4l2-controls.h +1 -0
@@ -140,8 +140,24 @@ enum v4l2_colorfx {
 #define V4L2_CID_ALPHA_COMPONENT		(V4L2_CID_BASE+41)
 #define V4L2_CID_COLORFX_CBCR			(V4L2_CID_BASE+42)
 
+#define V4L2_CID_BLEND				(V4L2_CID_BASE+43)

The image processing class (V4L2_CTRL_CLASS_IMAGE_PROC) would seem like a better fit than the base class for this control.

Quoted 20 lines
include/uapi/linux/v4l2-controls.h +16 -1
+enum v4l2_blend_mode {
+	V4L2_BLEND_SRC				= 0,
+	V4L2_BLEND_SRCATOP			= 1,
+	V4L2_BLEND_SRCIN			= 2,
+	V4L2_BLEND_SRCOUT			= 3,
+	V4L2_BLEND_SRCOVER			= 4,
+	V4L2_BLEND_DST				= 5,
+	V4L2_BLEND_DSTATOP			= 6,
+	V4L2_BLEND_DSTIN			= 7,
+	V4L2_BLEND_DSTOUT			= 8,
+	V4L2_BLEND_DSTOVER			= 9,
+	V4L2_BLEND_ADD				= 10,
+	V4L2_BLEND_CLEAR			= 11,
+};
+ 
 /* last CID + 1 */
-#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+43)
+#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+44)
 
 /* USER-class private control IDs */
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Jacob Chen

Hi Jacob,

Thank you for the patch.

Quoted 11 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.
- copy
- fast solid color fill
- rotation
- flip
- alpha blending

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 17 lines
---
 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

Le samedi 15 juillet 2017 ? 12:42 +0300, Laurent Pinchart a ?crit :

Quoted 17 lines

Hi Jacob,

Thank you for the patch.

Quoted 11 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.
- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 3 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process. Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=772766

Quoted 4 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Quoted 28 lines
Quoted 5 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 17 lines
---
 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
#12 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Jacob Chen
coccinelle warnings: (new ones prefixed by >>)

Hi Jacob,

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.12 next-20170714]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jacob-Chen/v4l-add-blend-modes-controls/20170715-214326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next

coccinelle warnings: (new ones prefixed by >>)

>> drivers/media/platform/rockchip-rga/rga-hw.c:124:2-3: Unneeded semicolon

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#13 lore raw

[PATCH] rockchip/rga: fix semicolon.cocci warnings

In reply to Jacob Chen
drivers/media/platform/rockchip-rga/rga-hw.c:124:2-3: Unneeded semicolon

drivers/media/platform/rockchip-rga/rga-hw.c:124:2-3: Unneeded semicolon

Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Fixes 6f3d6aeab3cb ("rockchip/rga: v4l2 m2m support")
CC Jacob Chen <[email protected]>

---

 rga-hw.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/rockchip-rga/rga-hw.c +1 -1
@@ -121,7 +121,7 @@ static struct rga_addr_offset *rga_looku
 		return &offsets->right_top;
 	case RB:
 		return &offsets->right_bottom;
-	};
+	}
 
 	return NULL;
 }
#6 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Personnel

Hi all,

2017-07-16 0:49 GMT+08:00 Personnel <[email protected]>:

Quoted 28 lines

Le samedi 15 juillet 2017 ? 12:42 +0300, Laurent Pinchart a ?crit :

Quoted 17 lines

Hi Jacob,

Thank you for the patch.

Quoted 11 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.
- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 3 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process. Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

Quoted 8 lines

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=772766

We have write a drm RGA driver.
https://patchwork.kernel.org/patch/8630841/

Here are the reasons that why i rewrite it to V4l2 M2M.
1. V4l2 have a better buffer framework. If it use DRM-GEM to handle buffers, there will be much redundant cache flush, and we have to add much hack code to workaround.
2. This driver will be used in rockchip linux project. We mostly use it to scale/colorconvert/rotate/mix video/camera stream.
A V4L2 M2M drvier can be directly used in gstreamer.

The disadvantages of V4l2 M2M API is that it's not stateless. It's inconvenient if user change size frequently, but it's OK, we have not yet need this and I think it's possible to extend. ; )

Quoted 9 lines
Quoted 4 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Yep.

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

It's a 1-level MMU... We use it like a scatter-gather list, It's also the reason why we don't use RGA with DRM API.

Quoted 19 lines
Quoted 19 lines
Quoted 17 lines
---
 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
#19 lore raw

Re: [PATCH v2 5/6] ARM: dts: rockchip: enable RGA for rk3288 devices

In reply to Laurent Pinchart

Hi Laurent,

2017-07-15 17:16 GMT+08:00 Laurent Pinchart <[email protected]>:

Quoted 14 lines

Hi Jacob,

Thank you for the patch.

Quoted 8 lines · On Saturday 15 Jul 2017 14:58:39 Jacob Chen wrote:
---
 arch/arm/boot/dts/rk3288-evb.dtsi                 | 4 ++++
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-firefly.dtsi             | 4 ++++
 arch/arm/boot/dts/rk3288-miqi.dts                 | 4 ++++
 arch/arm/boot/dts/rk3288-popmetal.dts             | 4 ++++
 arch/arm/boot/dts/rk3288-tinker.dts               | 4 ++++
Quoted 4 lines

Some boards are missing from this list (Fennec, Phycore, ...) What criteria have you used to decide on which ones to enable the RGA ? That should be explained in the commit message.

Ok.

I just enable the boards i have tested, because i can't make sure it won't break the other board
because of clocks or power-domains.

Quoted 99 lines
Quoted 83 lines
 6 files changed, 24 insertions(+)
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-evb.dtsi index 4905760..ec12162 100644

arch/arm/boot/dts/rk3288-evb.dtsi +4 -0
@@ -379,6 +379,10 @@
      };
 };
 
+&rga {
+     status = "okay";
+};
+
 &usbphy {
      status = "okay";
 };
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi index 8134966..fffa92e2 100644

arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi +4 -0
@@ -283,6 +283,10 @@
      };
 };
 
+&rga {
+     status = "okay";
+};
+
 &tsadc {
      rockchip,hw-tshut-mode = <0>;
      rockchip,hw-tshut-polarity = <0>;
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-firefly.dtsi index f520589..74a6ce5 100644

arch/arm/boot/dts/rk3288-firefly.dtsi +4 -0
@@ -500,6 +500,10 @@
      };
 };
 
+&rga {
+     status = "okay";
+};
+
 &saradc {
      vref-supply = <&vcc_18>;
      status = "okay";
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-miqi.dts index 21326f3..dc5e6bd 100644

arch/arm/boot/dts/rk3288-miqi.dts +4 -0
@@ -401,6 +401,10 @@
      };
 };
 
+&rga {
+     status = "okay";
+};
+
 &saradc {
      vref-supply = <&vcc_18>;
      status = "okay";
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-popmetal.dts index aa1f9ec..362e5aa 100644

arch/arm/boot/dts/rk3288-popmetal.dts +4 -0
@@ -490,6 +490,10 @@
      };
 };
 
+&rga {
+     status = "okay";
+};
+
 &tsadc {
      rockchip,hw-tshut-mode = <0>;
      rockchip,hw-tshut-polarity = <0>;
(quoted diff) +0 -0

b/arch/arm/boot/dts/rk3288-tinker.dts index 525b0e5..1a8c149 100644

arch/arm/boot/dts/rk3288-tinker.dts line 469

Quoted 10 lines
arch/arm/boot/dts/rk3288-tinker.dts +4 -0
@@ -460,6 +460,10 @@
      status = "okay";
 };
 
+&rga {
+     status = "okay";
+};
+
 &saradc {
      vref-supply = <&vcc18_ldo1>;
      status ="okay";

--
Regards,

Laurent Pinchart

maintainer
#24 lore raw

Re: [PATCH v2 6/6] dt-bindings: Document the Rockchip RGA bindings

In reply to Laurent Pinchart

Hi Laurent,

Am Samstag, 15. Juli 2017, 12:23:12 CEST schrieb Laurent Pinchart:

Quoted 36 lines · On Saturday 15 Jul 2017 14:58:40 Jacob Chen wrote:
Quoted 18 lines

Add DT bindings documentation for Rockchip RGA

---
 .../devicetree/bindings/media/rockchip-rga.txt     | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-rga.txt
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/media/rockchip-rga.txt new file mode 100644
index 0000000..966eba0

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
@@ -0,0 +1,35 @@
+device-tree bindings for rockchip 2D raster graphic acceleration controller

(RGA)

Documentation/devicetree/bindings/media/rockchip-rga.txt line 3

Quoted 2 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+
+RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D

"Separate" from what ? Do you mean "standalone" ?

Documentation/devicetree/bindings/media/rockchip-rga.txt line 11

Quoted 8 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +8 -0
+graphics operations, such as point/line drawing, image scaling, rotation,
+BitBLT, alpha blending and image blur/sharpness.
+
+Required properties:
+- compatible: value should be one of the following
+		"rockchip,rk3228-rga";
+		"rockchip,rk3288-rga";
+		"rockchip,rk3399-rga";

The driver in patch 2/6 has match entry for rk3328, which is missing from this list.

Quoted 5 lines

As the implementation of the driver doesn't seem to discriminate between the four SoCs, wouldn't it make sense to create a generic compatible string on which the driver would match ? You can have both the generic and SoC-specific compatible strings in DT if there are differences between the IP core in those SoCs that might need to be handled later by the driver.

I think the block is named something like RGA2 in some kernel trees, but am not sure if that is an actual name, or someone just added a number.

Quoted 1 line

From short glances at vendor rga-code in the past, it looks like there are

currently 2 basic versions of the in existence I.e. older Rockchip socs (like the rk3188 or so) use something older.

I think everywhere else we do have only (or at least mostly) soc-specifc compatibles, but I guess that is more a question what Rob prefers.

Heiko

Quoted 43 lines
Quoted 1 line

+- interrupts: RGA interrupt number.

This is an "interrupt specifier", not just an "interrupt number" (as you can see in the example below there are three numbers)

Documentation/devicetree/bindings/media/rockchip-rga.txt line 17

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- clocks: phandle to RGA sclk/hclk/aclk clocks
+
+- clock-names: should be "aclk" "hclk" and "sclk"

Nitpicking, there should be a comma after "aclk".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- resets: Must contain an entry for each entry in reset-names.
+  See ../reset/reset.txt for details.
+- reset-names: should be "core" "axi" and "ahb"

And a comma after "core".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 24

Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+
+Example:
+SoC specific DT entry:

s/SoC specific/SoC-specific/

Documentation/devicetree/bindings/media/rockchip-rga.txt line 29

Quoted 5 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +5 -0
+	rga: rga at ff680000 {
+		compatible = "rockchip,rk3399-rga";
+		reg = <0xff680000 0x10000>;
+		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";

The interrupt-names property is not described above. Do you really need it ?

Documentation/devicetree/bindings/media/rockchip-rga.txt

Quoted 1 line
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru 

SCLK_RGA_CORE>;

Documentation/devicetree/bindings/media/rockchip-rga.txt

Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+		clock-names = "aclk", "hclk", "sclk";
+
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_A_RGA>, <&cru 

SRST_H_RGA>;

Quoted 2 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+		reset-names = "core, "axi", "ahb";
+	};
#25 lore raw

Re: [PATCH v2 6/6] dt-bindings: Document the Rockchip RGA bindings

Hi Heiko,

Quoted 48 lines · On Sunday 16 Jul 2017 18:07:58 Heiko Stuebner wrote:

Am Samstag, 15. Juli 2017, 12:23:12 CEST schrieb Laurent Pinchart:

Quoted 40 lines · On Saturday 15 Jul 2017 14:58:40 Jacob Chen wrote:
Quoted 22 lines

Add DT bindings documentation for Rockchip RGA

---

 .../devicetree/bindings/media/rockchip-rga.txt     | 35 +++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/media/rockchip-rga.txt

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/media/rockchip-rga.txt new file mode 100644
index 0000000..966eba0

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
@@ -0,0 +1,35 @@
+device-tree bindings for rockchip 2D raster graphic acceleration

controller (RGA)

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+
+RGA is a separate 2D raster graphic acceleration unit. It accelerates
Quoted 1 line

2D

"Separate" from what ? Do you mean "standalone" ?

Documentation/devicetree/bindings/media/rockchip-rga.txt line 11

Quoted 9 lines

+graphics operations, such as point/line drawing, image scaling, rotation,

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +7 -0
+BitBLT, alpha blending and image blur/sharpness.
+
+Required properties:
+- compatible: value should be one of the following
+		"rockchip,rk3228-rga";
+		"rockchip,rk3288-rga";
+		"rockchip,rk3399-rga";

The driver in patch 2/6 has match entry for rk3328, which is missing from this list.

Quoted 6 lines

As the implementation of the driver doesn't seem to discriminate between the four SoCs, wouldn't it make sense to create a generic compatible string on which the driver would match ? You can have both the generic and SoC-specific compatible strings in DT if there are differences between the IP core in those SoCs that might need to be handled later by the driver.

Quoted 8 lines

I think the block is named something like RGA2 in some kernel trees, but am not sure if that is an actual name, or someone just added a number. From short glances at vendor rga-code in the past, it looks like there are currently 2 basic versions of the in existence I.e. older Rockchip socs (like the rk3188 or so) use something older.

I think everywhere else we do have only (or at least mostly) soc-specifc compatibles, but I guess that is more a question what Rob prefers.

Many SoC vendors use SoC-specific compatible string, often in addition to more generic ones. When a more generic compatible string is available, drivers can match against it, which avoid having to update drivers every time a new SoC integrates the same version of the IP core. The SoC-specific compatible string is still specified in DT, "just in case" we later realize that the IP core integrated in the SoC is slightly different than the other ones and requires specific handling in the driver.

I'm not completely happy with that scheme, as it's really a workaround for defective communication with the hardware team (or possibly defective hardware development...), but that's the best compromise we have so far.

Quoted 42 lines
Quoted 42 lines
Quoted 1 line

+- interrupts: RGA interrupt number.

This is an "interrupt specifier", not just an "interrupt number" (as you can see in the example below there are three numbers)

Documentation/devicetree/bindings/media/rockchip-rga.txt line 17

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- clocks: phandle to RGA sclk/hclk/aclk clocks
+
+- clock-names: should be "aclk" "hclk" and "sclk"

Nitpicking, there should be a comma after "aclk".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +4 -0
+
+- resets: Must contain an entry for each entry in reset-names.
+  See ../reset/reset.txt for details.
+- reset-names: should be "core" "axi" and "ahb"

And a comma after "core".

Documentation/devicetree/bindings/media/rockchip-rga.txt line 24

Quoted 3 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+
+Example:
+SoC specific DT entry:

s/SoC specific/SoC-specific/

Documentation/devicetree/bindings/media/rockchip-rga.txt line 29

Quoted 5 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +5 -0
+	rga: rga@ff680000 {
+		compatible = "rockchip,rk3399-rga";
+		reg = <0xff680000 0x10000>;
+		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "rga";

The interrupt-names property is not described above. Do you really need it ?

Quoted 8 lines
Documentation/devicetree/bindings/media/rockchip-rga.txt new file +1 -0
+		clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru

SCLK_RGA_CORE>;

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +3 -0
+		clock-names = "aclk", "hclk", "sclk";
+
+		resets = <&cru SRST_RGA_CORE>, <&cru SRST_A_RGA>, <&cru

SRST_H_RGA>;

Documentation/devicetree/bindings/media/rockchip-rga.txt new file +2 -0
+		reset-names = "core, "axi", "ahb";
+	};
Signature · 3 lines
Regards,

Laurent Pinchart
#20 lore raw

Re: [PATCH v2 5/6] ARM: dts: rockchip: enable RGA for rk3288 devices

In reply to Jacob Chen

Hi Jacob,

Quoted 12 lines · On Sunday 16 Jul 2017 12:23:02 Jacob Chen wrote:

2017-07-15 17:16 GMT+08:00 Laurent Pinchart:

Quoted 11 lines · On Saturday 15 Jul 2017 14:58:39 Jacob Chen wrote:
Quoted 9 lines

---

 arch/arm/boot/dts/rk3288-evb.dtsi                 | 4 ++++
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-firefly.dtsi             | 4 ++++
 arch/arm/boot/dts/rk3288-miqi.dts                 | 4 ++++
 arch/arm/boot/dts/rk3288-popmetal.dts             | 4 ++++
 arch/arm/boot/dts/rk3288-tinker.dts               | 4 ++++
Quoted 8 lines
Quoted 3 lines

Some boards are missing from this list (Fennec, Phycore, ...) What criteria have you used to decide on which ones to enable the RGA ? That should be explained in the commit message.

Ok.

I just enable the boards i have tested, because i can't make sure it won't break the other board because of clocks or power-domains.

Given the clocks and power domains shouldn't be board-specific, would it make sense to try and get the change tested on the remaining boards ? You could then enable the device in the SoC .dtsi file, which would be much simpler.

Quoted 1 line
Quoted 1 line
Quoted 1 line
 6 files changed, 24 insertions(+)
Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Personnel

Hi Nicolas,

On Saturday 15 Jul 2017 12:49:13 Personnel wrote:

You might want to fix your mailer to use your name :-)

Quoted 15 lines · Laurent Pinchart
Quoted 14 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:
Quoted 12 lines

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.

- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 7 lines
Quoted 3 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process.

GPUs on embedded devices are mem-to-mem, and they're definitely shared between multiple processes :-)

Quoted 11 lines

Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=772766

If we decide that 2D blitters should be supported by V4L2 (and I'm open to get convinced about that), we really need to define a proper API before merging a bunch of drivers that will implement things in slightly different ways, otherwise the future will be very painful.

Among the issues that need to be solved are

- stateful vs. stateless operation (as mentioned by Jacob in this mail thread), a.k.a. the request API

- exposing capabilities to userspace (a single capability flag would be enough only if all blitters expose the same API, which I'm not sure we can assume)

- single input (a.k.a. in-place blitters as you mentioned below) vs. multiple inputs

- API for 2D-accelerated operations other than blitting (filling, point and line drawing, ...)

Quoted 35 lines
Quoted 3 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Quoted 27 lines
Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 18 lines

---

 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Jacob Chen

Hi Jacob,

Quoted 35 lines · On Sunday 16 Jul 2017 12:19:41 Jacob Chen wrote:

2017-07-16 0:49 GMT+08:00 Personnel:

Quoted 26 lines · Laurent Pinchart
Quoted 14 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:
Quoted 4 lines

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

Quoted 8 lines

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.

- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 4 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process. Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

Quoted 7 lines

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=772766

Quoted 7 lines

We have write a drm RGA driver.
https://patchwork.kernel.org/patch/8630841/

Here are the reasons that why i rewrite it to V4l2 M2M.
1. V4l2 have a better buffer framework. If it use DRM-GEM to handle buffers, there will be much redundant cache flush, and we have to add much hack code to workaround.

I'm glad to hear that you find buffer handling easy in V4L2 :-)

Quoted 7 lines

2. This driver will be used in rockchip linux project. We mostly use it to scale/colorconvert/rotate/mix video/camera stream.
A V4L2 M2M drvier can be directly used in gstreamer.

The disadvantages of V4l2 M2M API is that it's not stateless. It's inconvenient if user change size frequently, but it's OK, we have not yet need this and I think it's possible to extend. ;)

CC'ing Alexandre Courbot. Alex, how's the request API going ? :-)

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Yep.

So the device performs bi-directional DMA on the capture queue buffers ? Interesting, does videobuf2 support that properly ?

Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

It's a 1-level MMU... We use it like a scatter-gather list, It's also the reason why we don't use RGA with DRM API.

You might want to explain this in the code, otherwise someone will ask you why you don't implement support for the MMU through the IOMMU API. Calling it scatter-gather would solve that problem, but if the hardware manual calls it an MMU, there's no reason not to use that name in the code.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

---

 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h
Signature · 3 lines
Regards,

Laurent Pinchart
#21 lore raw

Re: [PATCH v2 5/6] ARM: dts: rockchip: enable RGA for rk3288 devices

In reply to Laurent Pinchart

Hi Laurent,

2017-07-17 10:28 GMT+08:00 Laurent Pinchart <[email protected]>:

Quoted 19 lines

Hi Jacob,

Quoted 16 lines · On Sunday 16 Jul 2017 12:23:02 Jacob Chen wrote:

2017-07-15 17:16 GMT+08:00 Laurent Pinchart:

Quoted 14 lines · On Saturday 15 Jul 2017 14:58:39 Jacob Chen wrote:
Quoted 9 lines

---

 arch/arm/boot/dts/rk3288-evb.dtsi                 | 4 ++++
 arch/arm/boot/dts/rk3288-firefly-reload-core.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-firefly.dtsi             | 4 ++++
 arch/arm/boot/dts/rk3288-miqi.dts                 | 4 ++++
 arch/arm/boot/dts/rk3288-popmetal.dts             | 4 ++++
 arch/arm/boot/dts/rk3288-tinker.dts               | 4 ++++

Some boards are missing from this list (Fennec, Phycore, ...) What criteria have you used to decide on which ones to enable the RGA ? That should be explained in the commit message.

Quoted 7 lines
Quoted 4 lines

Ok.

I just enable the boards i have tested, because i can't make sure it won't break the other board because of clocks or power-domains.

Given the clocks and power domains shouldn't be board-specific, would it make sense to try and get the change tested on the remaining boards ? You could

Not all drivers have handle power domains and clocks appropriately, It may triggers bugs,
but since it's a V4l2 driver not DRM driver, i will enable it for all rk3288 boards.
(DRM device will try to probe in very eraly stage and update clocks/power-domains...)

Quoted 2 lines

then enable the device in the SoC .dtsi file, which would be much simpler.

We have many different version RGA drivers in rockchip downstream kernel. To keep consistent, i didn't enable it in .dtsi.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
 6 files changed, 24 insertions(+)

--
Regards,

Laurent Pinchart

#8 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Laurent Pinchart

Hi,

2017-07-17 10:43 GMT+08:00 Laurent Pinchart <[email protected]>:

Quoted 66 lines

Hi Jacob,

Quoted 35 lines · On Sunday 16 Jul 2017 12:19:41 Jacob Chen wrote:

2017-07-16 0:49 GMT+08:00 Personnel:

Quoted 26 lines

Le samedi 15 juillet 2017 ? 12:42 +0300, Laurent Pinchart a ?crit :

Quoted 14 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:
Quoted 4 lines

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

Quoted 8 lines

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.

- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 4 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process. Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

Quoted 7 lines

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=772766

Quoted 7 lines

We have write a drm RGA driver.
https://patchwork.kernel.org/patch/8630841/

Here are the reasons that why i rewrite it to V4l2 M2M.
1. V4l2 have a better buffer framework. If it use DRM-GEM to handle buffers, there will be much redundant cache flush, and we have to add much hack code to workaround.

I'm glad to hear that you find buffer handling easy in V4L2 :-)

Quoted 7 lines

2. This driver will be used in rockchip linux project. We mostly use it to scale/colorconvert/rotate/mix video/camera stream.
A V4L2 M2M drvier can be directly used in gstreamer.

The disadvantages of V4l2 M2M API is that it's not stateless. It's inconvenient if user change size frequently, but it's OK, we have not yet need this and I think it's possible to extend. ;)

CC'ing Alexandre Courbot. Alex, how's the request API going ? :-)

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Quoted 7 lines
Quoted 1 line

Yep.

So the device performs bi-directional DMA on the capture queue buffers ? Interesting, does videobuf2 support that properly ?

From the code, I think V4L2_CAPTURE and V4L2_OUTPUT are handled

in the same way. In my test, it work properly.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 8 lines
Quoted 2 lines

It's a 1-level MMU... We use it like a scatter-gather list, It's also the reason why we don't use RGA with DRM API.

You might want to explain this in the code, otherwise someone will ask you why you don't implement support for the MMU through the IOMMU API. Calling it scatter-gather would solve that problem, but if the hardware manual calls it an MMU, there's no reason not to use that name in the code.

ok, i will add comments

Quoted 24 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines

---

 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h

--
Regards,

Laurent Pinchart

#10 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

In reply to Laurent Pinchart

Le lundi 17 juillet 2017 ? 05:37 +0300, Laurent Pinchart a ?crit :

Quoted 42 lines

Hi Nicolas,

On Saturday 15 Jul 2017 12:49:13 Personnel wrote:

You might want to fix your mailer to use your name :-)

Quoted 15 lines

Le samedi 15 juillet 2017 ? 12:42 +0300, Laurent Pinchart a ?crit :

Quoted 14 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:
Quoted 12 lines

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.

- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 7 lines
Quoted 3 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process.

GPUs on embedded devices are mem-to-mem, and they're definitely shared between multiple processes :-)

Quoted 10 lines

Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

Quoted 6 lines
Quoted 1 line

https://bugzilla.gnome.org/show_bug.cgi?id=772766

If we decide that 2D blitters should be supported by V4L2 (and I'm open to get convinced about that), we really need to define a proper API before merging a bunch of drivers that will implement things in slightly different ways, otherwise the future will be very painful.

Arguably, Jacob is not proposing anything new, as at least one other driver has been merged.

Quoted 5 lines

Among the issues that need to be solved are

- stateful vs. stateless operation (as mentioned by Jacob in this mail thread), a.k.a. the request API

Would it be possible to extend your thought. To me, Request API could enable more use cases but is not strictly required.

Quoted 3 lines

- exposing capabilities to userspace (a single capability flag would be enough only if all blitters expose the same API, which I'm not sure we can assume)

I am just rethinking this. With this patch series, Jacob is trying to generalize the Blit Operation controls (still need a name, blend mode does not work). We can easily make a recommendation to set the default operation to a copy operation (drivers always support that). This way, the node will behave like a converter (scaler, colorspace converter, rotator and/or etc.) Checking the presence of that control, we can clearly and quickly figure-out what this node is about. The capability remains a nice idea, but probably optional.

I totally agree we should document the behaviours and rationals for picking a certain default. The control should maybe become a "menu" too, so each driver can cherry-pick the blit operations they support (using int with min/max requires userspace trial and error, we already did that mistake for encoders profiles and level).

Quoted 3 lines

- single input (a.k.a. in-place blitters as you mentioned below) vs. multiple inputs

I do think the second is something you can build on top of the first by cascading (what we do in the refereed GStreamer element). So far this is applicable to Exynos, IMX6 and now Rockchip (probably more). The "optimal" form for the second case seems like something that will be implemented using much lower level kernel interface, like a GPU programming interface (aka proprietary Adreno C2D API), or through multiple nodes (multiple inputs and outputs). It's seems like the cut between high-end and low-end.

Quoted 3 lines

- API for 2D-accelerated operations other than blitting (filling, point and line drawing, ...)

I doubt such hardware exist in a form that is not bound to the GPU. I'm not ignoring your point, there is a clear overlap between how we integrated GPUs and having this into V4L2.

Quoted 21 lines
Quoted 21 lines
Quoted 4 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Quoted 12 lines
Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 3 lines

---

Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170717/fe4b25c4/attachment.sig>

#11 lore raw

Re: [PATCH v2 2/6] [media] rockchip/rga: v4l2 m2m support

Hi,

2017-07-17 22:45 GMT+08:00 Nicolas Dufresne <[email protected]>:

Quoted 95 lines

Le lundi 17 juillet 2017 ? 05:37 +0300, Laurent Pinchart a ?crit :

Quoted 42 lines

Hi Nicolas,

On Saturday 15 Jul 2017 12:49:13 Personnel wrote:

You might want to fix your mailer to use your name :-)

Quoted 15 lines

Le samedi 15 juillet 2017 ? 12:42 +0300, Laurent Pinchart a ?crit :

Quoted 14 lines · On Saturday 15 Jul 2017 14:58:36 Jacob Chen wrote:
Quoted 12 lines

Rockchip RGA is a separate 2D raster graphic acceleration unit. It accelerates 2D graphics operations, such as point/line drawing, image scaling, rotation, BitBLT, alpha blending and image blur/sharpness.

The drvier is mostly based on s5p-g2d v4l2 m2m driver. And supports various operations from the rendering pipeline.

- copy
- fast solid color fill
- rotation
- flip
- alpha blending

Quoted 7 lines
Quoted 3 lines

I notice that you don't support the drawing operations. How do you plan to support them later through the V4L2 M2M API ? I hate stating the obvious, but wouldn't the DRM API be better fit for a graphic accelerator ?

It could fit, maybe, but it really lacks some framework. Also, DRM is not really meant for M2M operation, and it's also not great for multi- process.

GPUs on embedded devices are mem-to-mem, and they're definitely shared between multiple processes :-)

Quoted 10 lines

Until recently, there was competing drivers for Exynos, both implemented in V4L2 and DRM, for similar rational, all DRM ones are being deprecated/removed.

I think 2D blitters in V4L2 are fine, but they terribly lack something to differentiate them from converters/scalers when looking up the HW list. Could be as simple as a capability flag, if I can suggest. For the reference, the 2D blitter on IMX6 has been used to implement a live video mixer in GStreamer.

Quoted 6 lines
Quoted 1 line

https://bugzilla.gnome.org/show_bug.cgi?id=772766

If we decide that 2D blitters should be supported by V4L2 (and I'm open to get convinced about that), we really need to define a proper API before merging a bunch of drivers that will implement things in slightly different ways, otherwise the future will be very painful.

Arguably, Jacob is not proposing anything new, as at least one other driver has been merged.

Quoted 5 lines

Among the issues that need to be solved are

- stateful vs. stateless operation (as mentioned by Jacob in this mail thread), a.k.a. the request API

Would it be possible to extend your thought. To me, Request API could enable more use cases but is not strictly required.

Quoted 3 lines

- exposing capabilities to userspace (a single capability flag would be enough only if all blitters expose the same API, which I'm not sure we can assume)

I am just rethinking this. With this patch series, Jacob is trying to generalize the Blit Operation controls (still need a name, blend mode does not work). We can easily make a recommendation to set the default operation to a copy operation (drivers always support that). This way, the node will behave like a converter (scaler, colorspace converter, rotator and/or etc.) Checking the presence of that control, we can clearly and quickly figure-out what this node is about. The capability remains a nice idea, but probably optional.

I totally agree we should document the behaviours and rationals for picking a certain default. The control should maybe become a "menu" too, so each driver can cherry-pick the blit operations they support (using int with min/max requires userspace trial and error, we already did that mistake for encoders profiles and level).

Quoted 3 lines

- single input (a.k.a. in-place blitters as you mentioned below) vs. multiple inputs

I do think the second is something you can build on top of the first by cascading (what we do in the refereed GStreamer element). So far this is applicable to Exynos, IMX6 and now Rockchip (probably more). The "optimal" form for the second case seems like something that will be implemented using much lower level kernel interface, like a GPU programming interface (aka proprietary Adreno C2D API), or through multiple nodes (multiple inputs and outputs). It's seems like the cut between high-end and low-end.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

- API for 2D-accelerated operations other than blitting (filling, point and line drawing, ...)

I doubt such hardware exist in a form that is not bound to the GPU. I'm not ignoring your point, there is a clear overlap between how we integrated GPUs and having this into V4L2.

I think stateless and multiple inputs are optional, we don't have to support it right now.
(Though we really need a stateless m2m API, too many hardwares need it, not just 2d blitters, but also internal dsp, image process units.... It would be really great
if people could convert their custom drivers to V4L2. )

Agree that we should have API for more 2D-accelerated operations and capabilities,

What about this?

#define V4L2_CID_2D_MODE

enum v4l2_2d_mode {
        V4L2_2D_MODE_COPY
        V4L2_2D_MODE_FILLING
        V4L2_2D_MODE_PORTERDUFF
        /*
        V4L2_2D_MODE_BITBLT
        V4L2_2D_MODE_ALPHA_BLEND
        other operations.....
        */
}

/* for V4L2_2D_MODE_PORTERDUFF */
#define V4L2_CID_2D_PORTERDUFF_MODE
ATOP
SRC
.....

/* for V4L2_2D_MODE_BITBLT */
#define V4L2_2D_BITBLT_ROP
XOR
OR
AND
NOT
....

#define .......

/* for V4L2_2D_MODE_ALPHA_BLEND */
#define .......
........

/* for V4L2_2D_MODE_FILLING */
V4L2_CID_BG_COLOR
#define .......

We use copy as the default mode for hardware that not support bitblt/alpha blend e.g : some image process units, used for image enhancement/noise reduction (Though BITBLT+copy rop or V4L2_2D_MODE_PORTERDUFF+SRC+MODE = copy)

V4L2_2D_MODE_PORTERDUFF are used to wrap bitblt/alpha-blend.
If driver need a more customizable API, they could implent V4L2_2D_MODE_BITBLT/ V4L2_2D_MODE_ALPHA_BLEND, or they just need implent V4L2_2D_MODE_PORTERDUFF.

Driver return false in ioctl to show capabilities.

Quoted 38 lines
Quoted 38 lines
Quoted 36 lines
Quoted 4 lines

Additionally, V4L2 M2M has one source and one destination. How do you implement alpha blending in that case, which by definition requires at least two sources ?

This type of HW only do in-place blits. When using such a node, the buffer queued on the V4L2_CAPTURE contains the destination image, and the buffer queued on the V4L2_OUTPUT is the source image.

Quoted 27 lines
Quoted 4 lines

The code in rga-hw.c is used to configure regs accroding to operations.

The code in rga-buf.c is used to create private mmu table for RGA. The tables is stored in a list, and be removed when buffer is cleanup.

Looking at the implementation it seems to be a scatter-gather list, not an MMU. Is that right ? Does the hardware documentation refer to it as an MMU ?

Quoted 18 lines

---

 drivers/media/platform/Kconfig                |  11 +
 drivers/media/platform/Makefile               |   2 +
 drivers/media/platform/rockchip-rga/Makefile  |   3 +
 drivers/media/platform/rockchip-rga/rga-buf.c | 122 ++++
 drivers/media/platform/rockchip-rga/rga-hw.c  | 652 ++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga-hw.h  | 437 ++++++++++++
 drivers/media/platform/rockchip-rga/rga.c     | 958 +++++++++++++++++++
 drivers/media/platform/rockchip-rga/rga.h     | 111 +++
 8 files changed, 2296 insertions(+)
 create mode 100644 drivers/media/platform/rockchip-rga/Makefile
 create mode 100644 drivers/media/platform/rockchip-rga/rga-buf.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga-hw.h
 create mode 100644 drivers/media/platform/rockchip-rga/rga.c
 create mode 100644 drivers/media/platform/rockchip-rga/rga.h