On Tue, May 28, 2019 at 5:34 PM Hans Verkuil <hverkuil-cisco@xxxxxxxxx> wrote: > > Use the new helper functions for the try_de/decoder_cmd ioctls. > > Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> > --- > drivers/media/platform/vicodec/vicodec-core.c | 35 +++---------------- > 1 file changed, 4 insertions(+), 31 deletions(-) > > diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c > index bd01a9206aa6..71abc87b7b59 100644 > --- a/drivers/media/platform/vicodec/vicodec-core.c > +++ b/drivers/media/platform/vicodec/vicodec-core.c > @@ -1188,25 +1188,13 @@ static void vicodec_mark_last_buf(struct vicodec_ctx *ctx) > spin_unlock(ctx->lock); > } > > -static int vicodec_try_encoder_cmd(struct file *file, void *fh, > - struct v4l2_encoder_cmd *ec) > -{ > - if (ec->cmd != V4L2_ENC_CMD_STOP) > - return -EINVAL; > - > - if (ec->flags & V4L2_ENC_CMD_STOP_AT_GOP_END) > - return -EINVAL; > - > - return 0; > -} > - > static int vicodec_encoder_cmd(struct file *file, void *fh, > struct v4l2_encoder_cmd *ec) > { > struct vicodec_ctx *ctx = file2ctx(file); > int ret; > > - ret = vicodec_try_encoder_cmd(file, fh, ec); > + ret = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, ec); > if (ret < 0) > return ret; > > @@ -1214,28 +1202,13 @@ static int vicodec_encoder_cmd(struct file *file, void *fh, > return 0; > } > > -static int vicodec_try_decoder_cmd(struct file *file, void *fh, > - struct v4l2_decoder_cmd *dc) > -{ > - if (dc->cmd != V4L2_DEC_CMD_STOP) > - return -EINVAL; > - > - if (dc->flags & V4L2_DEC_CMD_STOP_TO_BLACK) > - return -EINVAL; > - > - if (!(dc->flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) && (dc->stop.pts != 0)) > - return -EINVAL; > - > - return 0; > -} > - > static int vicodec_decoder_cmd(struct file *file, void *fh, > struct v4l2_decoder_cmd *dc) > { > struct vicodec_ctx *ctx = file2ctx(file); > int ret; > > - ret = vicodec_try_decoder_cmd(file, fh, dc); > + ret = v4l2_m2m_ioctl_try_decoder_cmd(file, fh, dc); > if (ret < 0) > return ret; > > @@ -1326,9 +1299,9 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = { > .vidioc_g_selection = vidioc_g_selection, > .vidioc_s_selection = vidioc_s_selection, > > - .vidioc_try_encoder_cmd = vicodec_try_encoder_cmd, > + .vidioc_try_encoder_cmd = v4l2_m2m_ioctl_try_encoder_cmd, > .vidioc_encoder_cmd = vicodec_encoder_cmd, > - .vidioc_try_decoder_cmd = vicodec_try_decoder_cmd, > + .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_try_decoder_cmd, > .vidioc_decoder_cmd = vicodec_decoder_cmd, > .vidioc_enum_framesizes = vicodec_enum_framesizes, > > -- > 2.20.1 > Reviewed-by: Tomasz Figa <tfiga@xxxxxxxxxxxx> Best regards, Tomasz