Re: [PATCH v8 2/3] media: meson: add v4l2 m2m video decoder driver

From: Hans Verkuil
Date: Thu Jun 06 2019 - 08:36:32 EST


On 6/5/19 6:18 PM, Maxime Jourdan wrote:
> Amlogic SoCs feature a powerful video decoder unit able to
> decode many formats, with a performance of usually up to 4k60.
>
> This is a driver for this IP that is based around the v4l2 m2m framework.
>
> It features decoding for:
> - MPEG 1
> - MPEG 2
>
> Supported SoCs are: GXBB (S905), GXL (S905X/W/D), GXM (S912)
>
> There is also a hardware bitstream parser (ESPARSER) that is handled here.
>
> Signed-off-by: Maxime Jourdan <mjourdan@xxxxxxxxxxxx>
> ---
> drivers/staging/media/Kconfig | 2 +
> drivers/staging/media/Makefile | 1 +
> drivers/staging/media/meson/vdec/Kconfig | 11 +
> drivers/staging/media/meson/vdec/Makefile | 8 +
> drivers/staging/media/meson/vdec/TODO | 8 +
> .../staging/media/meson/vdec/codec_mpeg12.c | 209 ++++
> .../staging/media/meson/vdec/codec_mpeg12.h | 14 +
> drivers/staging/media/meson/vdec/dos_regs.h | 98 ++
> drivers/staging/media/meson/vdec/esparser.c | 324 +++++
> drivers/staging/media/meson/vdec/esparser.h | 32 +
> drivers/staging/media/meson/vdec/vdec.c | 1075 +++++++++++++++++
> drivers/staging/media/meson/vdec/vdec.h | 269 +++++
> drivers/staging/media/meson/vdec/vdec_1.c | 229 ++++
> drivers/staging/media/meson/vdec/vdec_1.h | 14 +
> drivers/staging/media/meson/vdec/vdec_ctrls.c | 29 +
> drivers/staging/media/meson/vdec/vdec_ctrls.h | 14 +
> .../staging/media/meson/vdec/vdec_helpers.c | 449 +++++++
> .../staging/media/meson/vdec/vdec_helpers.h | 83 ++
> .../staging/media/meson/vdec/vdec_platform.c | 101 ++
> .../staging/media/meson/vdec/vdec_platform.h | 30 +
> 20 files changed, 3000 insertions(+)
> create mode 100644 drivers/staging/media/meson/vdec/Kconfig
> create mode 100644 drivers/staging/media/meson/vdec/Makefile
> create mode 100644 drivers/staging/media/meson/vdec/TODO
> create mode 100644 drivers/staging/media/meson/vdec/codec_mpeg12.c
> create mode 100644 drivers/staging/media/meson/vdec/codec_mpeg12.h
> create mode 100644 drivers/staging/media/meson/vdec/dos_regs.h
> create mode 100644 drivers/staging/media/meson/vdec/esparser.c
> create mode 100644 drivers/staging/media/meson/vdec/esparser.h
> create mode 100644 drivers/staging/media/meson/vdec/vdec.c
> create mode 100644 drivers/staging/media/meson/vdec/vdec.h
> create mode 100644 drivers/staging/media/meson/vdec/vdec_1.c
> create mode 100644 drivers/staging/media/meson/vdec/vdec_1.h
> create mode 100644 drivers/staging/media/meson/vdec/vdec_ctrls.c
> create mode 100644 drivers/staging/media/meson/vdec/vdec_ctrls.h
> create mode 100644 drivers/staging/media/meson/vdec/vdec_helpers.c
> create mode 100644 drivers/staging/media/meson/vdec/vdec_helpers.h
> create mode 100644 drivers/staging/media/meson/vdec/vdec_platform.c
> create mode 100644 drivers/staging/media/meson/vdec/vdec_platform.h
>

While preparing this series for merging I came across the following checkpatch
and sparse warnings:

checkpatch:

CHECK: Alignment should match open parenthesis
#159: FILE: drivers/staging/media/meson/vdec/codec_mpeg12.c:83:
+ ret = amvdec_set_canvases(sess, (u32[]){ AV_SCRATCH_0, 0 },
+ (u32[]){ 8, 0 });

HV: I think this doesn't need changing, this is easier to read.

CHECK: Alignment should match open parenthesis
#968: FILE: drivers/staging/media/meson/vdec/vdec.c:185:
+static int vdec_queue_setup(struct vb2_queue *q,
+ unsigned int *num_buffers, unsigned int *num_planes,

CHECK: Alignment should match open parenthesis
#1755: FILE: drivers/staging/media/meson/vdec/vdec.c:972:
+ core->regmap_ao = syscon_regmap_lookup_by_phandle(dev->of_node,
+ "amlogic,ao-sysctrl");

CHECK: struct mutex definition without comment
#1949: FILE: drivers/staging/media/meson/vdec/vdec.h:85:
+ struct mutex lock;

CHECK: struct mutex definition without comment
#2085: FILE: drivers/staging/media/meson/vdec/vdec.h:221:
+ struct mutex lock;

CHECK: struct mutex definition without comment
#2116: FILE: drivers/staging/media/meson/vdec/vdec.h:252:
+ struct mutex bufs_recycle_lock;

CHECK: spinlock_t definition without comment
#2120: FILE: drivers/staging/media/meson/vdec/vdec.h:256:
+ spinlock_t ts_spinlock;

CHECK: Alignment should match open parenthesis
#2247: FILE: drivers/staging/media/meson/vdec/vdec_1.c:108:
+ amvdec_write_dos_bits(core, VLD_MEM_VIFIFO_CONTROL,
+ (0x11 << MEM_FIFO_CNT_BIT) | MEM_FILL_ON_LEVEL |

CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt
#2313: FILE: drivers/staging/media/meson/vdec/vdec_1.c:174:
+ udelay(10);

CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt
#2354: FILE: drivers/staging/media/meson/vdec/vdec_1.c:215:
+ udelay(10);

CHECK: Alignment should match open parenthesis
#2413: FILE: drivers/staging/media/meson/vdec/vdec_ctrls.c:19:
+ sess->ctrl_min_buf_capture = v4l2_ctrl_new_std(ctrl_handler, NULL,
+ V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 1);


sparse:

SPARSE:/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/codec_mpeg12.c
/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/codec_mpeg12.c:201:25: warning: symbol 'codec_mpeg12_ops' was not
declared. Should it be static?
SPARSE:/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec.c
/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec.c:417:5: warning: symbol 'vdec_vb2_buf_prepare' was not declared.
Should it be static?
SPARSE:/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec_1.c
/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec_1.c:85:5: warning: symbol 'vdec_1_stbuf_power_up' was not declared.
Should it be static?
/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec_1.c:85:5: warning: no previous prototype for 'vdec_1_stbuf_power_up'
[-Wmissing-prototypes]
/home/hans/work/build/media-git/drivers/staging/media/meson/vdec/vdec.c:417:5: warning: no previous prototype for 'vdec_vb2_buf_prepare'
[-Wmissing-prototypes]

Can you fix these issues?

Regards,

Hans