Re: [PATCH v9 3/3] media: add Rockchip VPU JPEG encoder driver

2018-11-21 Thread Hans Verkuil
On 11/20/2018 10:20 PM, Ezequiel Garcia wrote:
> Add a mem2mem driver for the VPU available on Rockchip SoCs.
> Currently only JPEG encoding is supported, for RK3399 and RK3288
> platforms.
> 
> Signed-off-by: Ezequiel Garcia 
> ---
>  MAINTAINERS   |   7 +
>  drivers/staging/media/Kconfig |   2 +
>  drivers/staging/media/Makefile|   1 +
>  drivers/staging/media/rockchip/vpu/Kconfig|  14 +
>  drivers/staging/media/rockchip/vpu/Makefile   |  10 +
>  drivers/staging/media/rockchip/vpu/TODO   |   6 +
>  .../media/rockchip/vpu/rk3288_vpu_hw.c| 118 +++
>  .../rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c | 133 
>  .../media/rockchip/vpu/rk3288_vpu_regs.h  | 442 +++
>  .../media/rockchip/vpu/rk3399_vpu_hw.c| 118 +++
>  .../rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c | 160 
>  .../media/rockchip/vpu/rk3399_vpu_regs.h  | 600 +++
>  .../staging/media/rockchip/vpu/rockchip_vpu.h | 237 ++
>  .../media/rockchip/vpu/rockchip_vpu_common.h  |  29 +
>  .../media/rockchip/vpu/rockchip_vpu_drv.c | 535 +
>  .../media/rockchip/vpu/rockchip_vpu_enc.c | 702 ++
>  .../media/rockchip/vpu/rockchip_vpu_hw.h  |  58 ++
>  .../media/rockchip/vpu/rockchip_vpu_jpeg.c| 289 +++
>  .../media/rockchip/vpu/rockchip_vpu_jpeg.h|  12 +
>  19 files changed, 3473 insertions(+)
>  create mode 100644 drivers/staging/media/rockchip/vpu/Kconfig
>  create mode 100644 drivers/staging/media/rockchip/vpu/Makefile
>  create mode 100644 drivers/staging/media/rockchip/vpu/TODO
>  create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw.c
>  create mode 100644 
> drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c
>  create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h
>  create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw.c
>  create mode 100644 
> drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c
>  create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_regs.h
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu.h
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_common.h
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_hw.h
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.c
>  create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.h
> 



> diff --git a/drivers/staging/media/rockchip/vpu/Kconfig 
> b/drivers/staging/media/rockchip/vpu/Kconfig
> new file mode 100644
> index ..fa65c03d65bf
> --- /dev/null
> +++ b/drivers/staging/media/rockchip/vpu/Kconfig
> @@ -0,0 +1,14 @@
> +config VIDEO_ROCKCHIP_VPU
> + tristate "Rockchip VPU driver"
> + depends on ARCH_ROCKCHIP || COMPILE_TEST
> + depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER
> + select VIDEOBUF2_DMA_CONTIG
> + select VIDEOBUF2_VMALLOC
> + select V4L2_MEM2MEM_DEV
> + default n
> + help
> +   Support for the Video Processing Unit present on Rockchip SoC,
> +   which accelerates video and image encoding and decoding.
> +   To compile this driver as a module, choose M here: the module
> +   will be called rockchip-vpu.
> +

checkpatch warns about empty line at the end of the Kconfig



> diff --git a/drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h 
> b/drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h
> new file mode 100644
> index ..d6cf9c682e7d
> --- /dev/null
> +++ b/drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h
> @@ -0,0 +1,442 @@
> +// SPDX-License-Identifier: GPL-2.0

Headers must use /* */ for the SPDX license. Sorry, I didn't make up these 
rules.

In any case, checkpatch.pl --strict complains about it.



> diff --git a/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.c 
> b/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.c
> new file mode 100644
> index ..678d53f3c2c2
> --- /dev/null
> +++ b/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.c
> @@ -0,0 +1,289 @@

Missing SPDX license!

> +/*
> + * Copyright (C) Collabora, Ltd.
> + *
> + * Based on GSPCA and CODA drivers:
> + * Copyright (C) Jean-Francois Moine (http://moinejf.free.fr)
> + * Copyright (C) 2014 Philipp Zabel, Pengutronix
> + */



> diff --git a/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.h 
> b/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.h
> new file mode 100644
> index ..a616d85359e8
> --- /dev/null
> +++ b/drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.h
> @@ -0,0 +1,12 @@

Missing SPDX license!

> +#define JPEG_HEADER_SIZE 601
> +
> +struct rockchip_vpu_jpeg_ctx {
> + int width;
> + int height;
> + int quality;
> + unsigned char *buffer;
> +};
> +
> +unsigned char

[PATCH v9 3/3] media: add Rockchip VPU JPEG encoder driver

2018-11-20 Thread Ezequiel Garcia
Add a mem2mem driver for the VPU available on Rockchip SoCs.
Currently only JPEG encoding is supported, for RK3399 and RK3288
platforms.

Signed-off-by: Ezequiel Garcia 
---
 MAINTAINERS   |   7 +
 drivers/staging/media/Kconfig |   2 +
 drivers/staging/media/Makefile|   1 +
 drivers/staging/media/rockchip/vpu/Kconfig|  14 +
 drivers/staging/media/rockchip/vpu/Makefile   |  10 +
 drivers/staging/media/rockchip/vpu/TODO   |   6 +
 .../media/rockchip/vpu/rk3288_vpu_hw.c| 118 +++
 .../rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c | 133 
 .../media/rockchip/vpu/rk3288_vpu_regs.h  | 442 +++
 .../media/rockchip/vpu/rk3399_vpu_hw.c| 118 +++
 .../rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c | 160 
 .../media/rockchip/vpu/rk3399_vpu_regs.h  | 600 +++
 .../staging/media/rockchip/vpu/rockchip_vpu.h | 237 ++
 .../media/rockchip/vpu/rockchip_vpu_common.h  |  29 +
 .../media/rockchip/vpu/rockchip_vpu_drv.c | 535 +
 .../media/rockchip/vpu/rockchip_vpu_enc.c | 702 ++
 .../media/rockchip/vpu/rockchip_vpu_hw.h  |  58 ++
 .../media/rockchip/vpu/rockchip_vpu_jpeg.c| 289 +++
 .../media/rockchip/vpu/rockchip_vpu_jpeg.h|  12 +
 19 files changed, 3473 insertions(+)
 create mode 100644 drivers/staging/media/rockchip/vpu/Kconfig
 create mode 100644 drivers/staging/media/rockchip/vpu/Makefile
 create mode 100644 drivers/staging/media/rockchip/vpu/TODO
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_regs.h
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu.h
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_common.h
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_hw.h
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.c
 create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_jpeg.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a8588dedc683..e5a294453393 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12742,6 +12742,13 @@ S: Maintained
 F: drivers/media/platform/rockchip/rga/
 F: Documentation/devicetree/bindings/media/rockchip-rga.txt
 
+ROCKCHIP VPU CODEC DRIVER
+M: Ezequiel Garcia 
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/staging/media/platform/rockchip/vpu/
+F: Documentation/devicetree/bindings/media/rockchip-vpu.txt
+
 ROCKER DRIVER
 M: Jiri Pirko 
 L: net...@vger.kernel.org
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index b3620a8f2d9f..c6f3404dea43 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -31,6 +31,8 @@ source "drivers/staging/media/mt9t031/Kconfig"
 
 source "drivers/staging/media/omap4iss/Kconfig"
 
+source "drivers/staging/media/rockchip/vpu/Kconfig"
+
 source "drivers/staging/media/sunxi/Kconfig"
 
 source "drivers/staging/media/tegra-vde/Kconfig"
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 42948f805548..43c7bee1fc8c 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_VIDEO_OMAP4)   += omap4iss/
 obj-$(CONFIG_VIDEO_SUNXI)  += sunxi/
 obj-$(CONFIG_TEGRA_VDE)+= tegra-vde/
 obj-$(CONFIG_VIDEO_ZORAN)  += zoran/
+obj-$(CONFIG_VIDEO_ROCKCHIP_VPU) += rockchip/vpu/
diff --git a/drivers/staging/media/rockchip/vpu/Kconfig 
b/drivers/staging/media/rockchip/vpu/Kconfig
new file mode 100644
index ..fa65c03d65bf
--- /dev/null
+++ b/drivers/staging/media/rockchip/vpu/Kconfig
@@ -0,0 +1,14 @@
+config VIDEO_ROCKCHIP_VPU
+   tristate "Rockchip VPU driver"
+   depends on ARCH_ROCKCHIP || COMPILE_TEST
+   depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER
+   select VIDEOBUF2_DMA_CONTIG
+   select VIDEOBUF2_VMALLOC
+   select V4L2_MEM2MEM_DEV
+   default n
+   help
+ Support for the Video Processing Unit present on Rockchip SoC,
+ which accelerates video and image encoding and decoding.
+ To compile this driver as a module, choose M here: the module
+ will be called rockchip-vpu.
+
diff --git a/drivers/staging/media/rockchip/vpu/Makefile 
b/drivers/staging/media/rockchip/vpu/Makefile
new file mode 100644
index ..e9d733bb7632
--- /dev/null
+++ b/drivers/staging/media/rockchip/vpu/Makefile
@@ -0,0 +1,10 @@
+obj-$(CONFIG