diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2019-04-08 15:32:51 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-04-22 18:54:25 +0300 |
commit | 784867d2135a1a8ebc213bcc3ca26283a2c0d9b8 (patch) | |
tree | 9c6792f5935b958dc93ac49c11d11be9e128415e /drivers/media | |
parent | c1b6761e1f4ea9ca6e858c4b0d6fd5461786f2b9 (diff) | |
download | linux-784867d2135a1a8ebc213bcc3ca26283a2c0d9b8.tar.xz |
media: coda: disable encoder command on decoder and vice versa
Return -ENOTTY when userspace tries to call VIDIOC_(TRY_)ENCODER_CMD on
a decoder instance or VIDIOC_(TRY_)DECODER_CMD on an encoder instance.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/coda/coda-common.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index f1d3fb17784a..c0421f06ca48 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1000,6 +1000,11 @@ static int coda_s_selection(struct file *file, void *fh, static int coda_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *ec) { + struct coda_ctx *ctx = fh_to_ctx(fh); + + if (ctx->inst_type != CODA_INST_ENCODER) + return -ENOTTY; + if (ec->cmd != V4L2_ENC_CMD_STOP) return -EINVAL; @@ -1020,10 +1025,6 @@ static int coda_encoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - /* Ignore encoder stop command silently in decoder context */ - if (ctx->inst_type != CODA_INST_ENCODER) - return 0; - /* Set the stream-end flag on this context */ ctx->bit_stream_param |= CODA_BIT_STREAM_END_FLAG; @@ -1041,6 +1042,11 @@ static int coda_encoder_cmd(struct file *file, void *fh, static int coda_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dc) { + struct coda_ctx *ctx = fh_to_ctx(fh); + + if (ctx->inst_type != CODA_INST_DECODER) + return -ENOTTY; + if (dc->cmd != V4L2_DEC_CMD_STOP) return -EINVAL; @@ -1063,10 +1069,6 @@ static int coda_decoder_cmd(struct file *file, void *fh, if (ret < 0) return ret; - /* Ignore decoder stop command silently in encoder context */ - if (ctx->inst_type != CODA_INST_DECODER) - return 0; - /* Set the stream-end flag on this context */ coda_bit_stream_end_flag(ctx); ctx->hold = false; |