media: rockchip: Add the rkvdec driver
Subsystems (6)
v2 cover media: rockchip: Add the rkvdec driver
Hello,
This is v2 of the rkvdec driver which was initially posted as part of my RFC adding codec helpers.
For this version, I decided to get rid of the helper stuff which is likely to take some more time to settle. The patchset now contains a proper DT binding doc.
Note that this implementation is likely to be adjusted based on the outcome of the 'scaling matrix order' [1] and 'dynamic resolution changes' [2] discussions, but I thought it'd be worth posting this version to start getting feeback.
Regards,
Boris
[1]https://patchwork.kernel.org/cover/11125207/
[2]https://lkml.org/lkml/2019/9/3/1033
Boris Brezillon (4):
media: vb2: Add a helper to get the vb2 buffer attached to a request
media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
media: rockchip: Add the rkvdec driver
arm64: dts: rockchip: rk3399: Define the rockchip Video Decoder node
.../bindings/media/rockchip,vdec.yaml | 71 ++ arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +- .../media/common/videobuf2/videobuf2-core.c | 23 + drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rockchip/Kconfig | 16 + drivers/staging/media/rockchip/Makefile | 2 + drivers/staging/media/rockchip/vdec/Kconfig | 14 + drivers/staging/media/rockchip/vdec/Makefile | 3 + .../staging/media/rockchip/vdec/rkvdec-h264.c | 960 +++++++++++++++ .../staging/media/rockchip/vdec/rkvdec-regs.h | 306 +++++ drivers/staging/media/rockchip/vdec/rkvdec.c | 1089 +++++++++++++++++ drivers/staging/media/rockchip/vdec/rkvdec.h | 131 ++ include/media/videobuf2-core.h | 11 + 14 files changed, 2642 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yaml create mode 100644 drivers/staging/media/rockchip/Kconfig create mode 100644 drivers/staging/media/rockchip/Makefile create mode 100644 drivers/staging/media/rockchip/vdec/Kconfig create mode 100644 drivers/staging/media/rockchip/vdec/Makefile create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec-h264.c create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec-regs.h create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec.c create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec.h
Signature · 1 line
2.21.0
PATCH v2 1/4 media: vb2: Add a helper to get the vb2 buffer attached to a request
vb2_request_get_buf() returns the N-th buffer attached to a media request.
---
Changes in v2:
* Adjust the kernel doc as suggested by Hans
--- .../media/common/videobuf2/videobuf2-core.c | 23 +++++++++++++++++++ include/media/videobuf2-core.h | 11 +++++++++ 2 files changed, 34 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +23 -0
@@ -1416,6 +1416,29 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) }EXPORT_SYMBOL_GPL (vb2_request_buffer_cnt); +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n) +{ +struct media_request_object *obj; +struct vb2_buffer *buf =NULL ; +unsigned int nbufs =0 ; +unsigned long flags; + +spin_lock_irqsave (&req->lock, flags); +list_for_each_entry (obj, &req->objects, list) { +if (!vb2_request_object_is_buffer (obj) || + nbufs++ < n) +continue ; + + buf = container_of(obj, struct vb2_buffer, req_obj); +break ; + } +spin_unlock_irqrestore (&req->lock, flags); + +return buf; +} +EXPORT_SYMBOL_GPL (vb2_request_get_buf); +int vb2_core_prepare_buf (struct vb2_queue *q,unsigned int index,void *pb) {struct vb2_buffer *vb;
include/media/videobuf2-core.h +11 -0
@@ -1222,4 +1222,15 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj);*/ unsigned int vb2_request_buffer_cnt (struct media_request *req); +/** +* vb2_request_get_buf() - return the buffer at index @idx +* +* @req: the request. +* @n: search for the Nth buffer in the req object list +* +* Return a vb2 buffer or NULL if there's no buffer at the specified position +*/ +struct vb2_buffer *vb2_request_get_buf (struct media_request *req, +unsigned int n); +#endif /* _MEDIA_VIDEOBUF2_CORE_H */
Signature · 1 line
2.21.0
PATCH v2 2/4 media: dt-bindings: rockchip: Document RK3399 Video Decoder bindings
In reply to Boris BrezillonDocument the Rockchip RK3399 Video Decoder bindings.
--- .../bindings/media/rockchip,vdec.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip,vdec.yaml
Documentation/devicetree/bindings/media/rockchip,vdec.yaml new file +71 -0
@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip,vdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip Video Decoder (VDec) Device Tree Bindings + +maintainers: + - Heiko Stuebner <[email protected]> + +description: |- + The Rockchip rk3399 has a stateless Video Decoder that can decodes H.264, + HEVC an VP9 streams. + +properties: + compatible: + const: rockchip,rk3399-vdec + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: The Video Decoder AXI interface clock + - description: The Video Decoder AHB interface clock + - description: The Video Decoded CABAC clock + - description: The Video Decoder core clock + + clock-names: + items: + - const: aclk + - const: iface + - const: cabac + - const: core + + power-domains: + maxItems: 1 + + iommus: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - power-domains + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + vdec: video-codec@ff660000 { + compatible = "rockchip,rk3399-vdec"; + reg = <0x0 0xff660000 0x0 0x400>; + interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>, + <&cru SCLK_VDU_CA>, <&cru SCLK_VDU_CORE>; + clock-names = "aclk", "iface", "cabac", "core"; + power-domains = <&power RK3399_PD_VDU>; + iommus = <&vdec_mmu>; + }; + +...
Signature · 1 line
2.21.0
PATCH v2 3/4 media: rockchip: Add the rkvdec driver
In reply to Boris BrezillonThe rockchip vdec block is a stateless decoder that's able to decode H264, HEVC and VP9 content. This patch only adds H264 support and is making use of the m2m codec helpers.
--- drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rockchip/Kconfig | 16 + drivers/staging/media/rockchip/Makefile | 2 + drivers/staging/media/rockchip/vdec/Kconfig | 14 + drivers/staging/media/rockchip/vdec/Makefile | 3 + .../staging/media/rockchip/vdec/rkvdec-h264.c | 960 +++++++++++++++ .../staging/media/rockchip/vdec/rkvdec-regs.h | 306 +++++ drivers/staging/media/rockchip/vdec/rkvdec.c | 1089 +++++++++++++++++ drivers/staging/media/rockchip/vdec/rkvdec.h | 131 ++ 10 files changed, 2524 insertions(+) create mode 100644 drivers/staging/media/rockchip/Kconfig create mode 100644 drivers/staging/media/rockchip/Makefile create mode 100644 drivers/staging/media/rockchip/vdec/Kconfig create mode 100644 drivers/staging/media/rockchip/vdec/Makefile create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec-h264.c create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec-regs.h create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec.c create mode 100644 drivers/staging/media/rockchip/vdec/rkvdec.h
drivers/staging/media/Kconfig +2 -0
@@ -30,6 +30,8 @@ source "drivers/staging/media/meson/vdec/Kconfig" source "drivers/staging/media/omap4iss/Kconfig" +source "drivers/staging/media/rockchip/Kconfig" + source "drivers/staging/media/sunxi/Kconfig" source "drivers/staging/media/tegra-vde/Kconfig"
drivers/staging/media/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_VIDEO_ALLEGRO_DVT) += allegro-dvt/ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx/ obj-$(CONFIG_VIDEO_MESON_VDEC) += meson/vdec/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ +obj-$(CONFIG_VIDEO_ROCKCHIP) += rockchip/ obj-$(CONFIG_VIDEO_SUNXI) += sunxi/ obj-$(CONFIG_TEGRA_VDE) += tegra-vde/ obj-$(CONFIG_VIDEO_HANTRO) += hantro/
drivers/staging/media/rockchip/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 +config VIDEO_ROCKCHIP + bool "Rockchip Video Devices" + depends on ARCH_ROCKCHIP || COMPILE_TEST + help + If you have a Rockchip SoC based embedding a video codec. + + Note that this option doesn't include new drivers in the + kernel: saying N will just cause Kconfig to skip all the + questions about Allwinner media devices. + +if VIDEO_ROCKCHIP + +source "drivers/staging/media/rockchip/vdec/Kconfig" + +endif
drivers/staging/media/rockchip/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += vdec/
drivers/staging/media/rockchip/vdec/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 +config VIDEO_ROCKCHIP_VDEC + tristate "Rockchip Video Decoder driver" + depends on ARCH_ROCKCHIP || COMPILE_TEST + depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on MEDIA_CONTROLLER_REQUEST_API + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_VMALLOC + select V4L2_MEM2MEM_DEV + help + Support for the Rockchip Video Decoder IP present on Rockchip SoC, + which accelerates video decoding. + To compile this driver as a module, choose M here: the module + will be called hantro-vpu.
drivers/staging/media/rockchip/vdec/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o + +rockchip-vdec-y += rkvdec.o rkvdec-h264.o
drivers/staging/media/rockchip/vdec/rkvdec-h264.c new file +960 -0
960 lines not on this page · raw message
drivers/staging/media/rockchip/vdec/rkvdec-regs.h new file +306 -0
306 lines not on this page · raw message
drivers/staging/media/rockchip/vdec/rkvdec.c new file +1089 -0
1,089 lines not on this page · raw message
drivers/staging/media/rockchip/vdec/rkvdec.h new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v2 4/4 arm64: dts: rockchip: rk3399: Define the rockchip Video Decoder node
In reply to Boris BrezillonRK3399 has a Video decoder, define the node in the dtsi. We also add the missing power-domain in mmu node and enable the block.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +13 -1
@@ -1276,8 +1276,20 @@ interrupt-names = "vdec_mmu"; clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>; clock-names = "aclk", "iface"; + power-domains = <&power RK3399_PD_VDU>; #iommu-cells = <0>; - status = "disabled"; + }; + + vdec: video-codec@ff660000 { + compatible = "rockchip,rk3399-vdec"; + reg = <0x0 0xff660000 0x0 0x400>; + interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "vdpu"; + clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>, + <&cru SCLK_VDU_CA>, <&cru SCLK_VDU_CORE>; + clock-names = "aclk", "iface", "cabac", "core"; + power-domains = <&power RK3399_PD_VDU>; + iommus = <&vdec_mmu>; }; iep_mmu: iommu@ff670800 {
Signature · 1 line
2.21.0