media: vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs

Use the new helper functions for the try_de/decoder_cmd ioctls.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Hans Verkuil 2019-05-28 04:34:37 -04:00 committed by Mauro Carvalho Chehab
parent ef732d5e28
commit 9b92536556

View File

@ -1188,25 +1188,13 @@ static void vicodec_mark_last_buf(struct vicodec_ctx *ctx)
spin_unlock(ctx->lock); 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, static int vicodec_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *ec) struct v4l2_encoder_cmd *ec)
{ {
struct vicodec_ctx *ctx = file2ctx(file); struct vicodec_ctx *ctx = file2ctx(file);
int ret; int ret;
ret = vicodec_try_encoder_cmd(file, fh, ec); ret = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, ec);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -1214,28 +1202,13 @@ static int vicodec_encoder_cmd(struct file *file, void *fh,
return 0; 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, static int vicodec_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *dc) struct v4l2_decoder_cmd *dc)
{ {
struct vicodec_ctx *ctx = file2ctx(file); struct vicodec_ctx *ctx = file2ctx(file);
int ret; int ret;
ret = vicodec_try_decoder_cmd(file, fh, dc); ret = v4l2_m2m_ioctl_try_decoder_cmd(file, fh, dc);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -1324,9 +1297,9 @@ static const struct v4l2_ioctl_ops vicodec_ioctl_ops = {
.vidioc_g_selection = vidioc_g_selection, .vidioc_g_selection = vidioc_g_selection,
.vidioc_s_selection = vidioc_s_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_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_decoder_cmd = vicodec_decoder_cmd,
.vidioc_enum_framesizes = vicodec_enum_framesizes, .vidioc_enum_framesizes = vicodec_enum_framesizes,