OSDN Git Service

media: amphion: add lock around vdec_g_fmt
authorMing Qian <ming.qian@nxp.com>
Tue, 1 Nov 2022 08:04:20 +0000 (16:04 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 18 Nov 2022 14:48:16 +0000 (15:48 +0100)
the capture format may be changed when
sequence header is parsed,
it may be read and write in the same time,
add lock around vdec_g_fmt to synchronize it

Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/amphion/vdec.c

index feb75dc..6f2aff8 100644 (file)
@@ -286,6 +286,7 @@ static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
        struct vpu_format *cur_fmt;
        int i;
 
+       vpu_inst_lock(inst);
        cur_fmt = vpu_get_format(inst, f->type);
 
        pixmp->pixelformat = cur_fmt->pixfmt;
@@ -303,6 +304,7 @@ static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
        f->fmt.pix_mp.xfer_func = vdec->codec_info.transfer_chars;
        f->fmt.pix_mp.ycbcr_enc = vdec->codec_info.matrix_coeffs;
        f->fmt.pix_mp.quantization = vdec->codec_info.full_range;
+       vpu_inst_unlock(inst);
 
        return 0;
 }