[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <492894c9-4724-7bf4-6382-1efa6c8b04e3@xs4all.nl>
Date: Thu, 29 Aug 2019 13:11:46 +0200
From: Hans Verkuil <hverkuil-cisco@...all.nl>
To: Jernej Skrabec <jernej.skrabec@...l.net>, mchehab@...nel.org,
paul.kocialkowski@...tlin.com, mripard@...nel.org
Cc: pawel@...iak.com, m.szyprowski@...sung.com,
kyungmin.park@...sung.com, tfiga@...omium.org, wens@...e.org,
acourbot@...omium.org, gregkh@...uxfoundation.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
devel@...verdev.osuosl.org, linux-arm-kernel@...ts.infradead.org,
ezequiel@...labora.com, jonas@...boo.se
Subject: Re: [PATCH 8/8] media: cedrus: Add support for V4L2_DEC_CMD_FLUSH
On 8/22/19 9:45 PM, Jernej Skrabec wrote:
> This command is useful for explicitly flushing last decoded frame.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@...l.net>
> ---
> .../staging/media/sunxi/cedrus/cedrus_video.c | 34 +++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> index 5153b2bba21e..9eae69d5741c 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> @@ -331,6 +331,37 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv,
> return 0;
> }
>
> +static int cedrus_try_decoder_cmd(struct file *file, void *fh,
> + struct v4l2_decoder_cmd *dc)
> +{
> + if (dc->cmd != V4L2_DEC_CMD_FLUSH)
> + return -EINVAL;
You need to add this line here as well:
dc->flags = 0;
As per the decoder_cmd spec.
> +
> + return 0;
> +}
> +
> +static int cedrus_decoder_cmd(struct file *file, void *fh,
> + struct v4l2_decoder_cmd *dc)
> +{
> + struct cedrus_ctx *ctx = cedrus_file2ctx(file);
You don't need this...
> + struct vb2_v4l2_buffer *out_vb, *cap_vb;
> + int ret;
> +
> + ret = cedrus_try_decoder_cmd(file, fh, dc);
> + if (ret < 0)
> + return ret;
> +
> + out_vb = v4l2_m2m_last_src_buf(ctx->fh.m2m_ctx);
... since you can use fh->m2m_ctx directly.
> + cap_vb = v4l2_m2m_last_dst_buf(ctx->fh.m2m_ctx);
> +
> + if (out_vb)
> + out_vb->flags &= ~V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF;
> + else if (cap_vb && cap_vb->is_held)
> + v4l2_m2m_buf_done(cap_vb, VB2_BUF_STATE_DONE);
> +
> + return 0;
> +}
> +
Both these functions should be moved to v4l2-mem2mem.c and renamed to
v4l2_m2m_ioctl_stateless_(try_)decoder_cmd.
As far as I can see they are completely generic and valid for any
stateless decoder. Which is very nice :-)
> const struct v4l2_ioctl_ops cedrus_ioctl_ops = {
> .vidioc_querycap = cedrus_querycap,
>
> @@ -355,6 +386,9 @@ const struct v4l2_ioctl_ops cedrus_ioctl_ops = {
> .vidioc_streamon = v4l2_m2m_ioctl_streamon,
> .vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
>
> + .vidioc_try_decoder_cmd = cedrus_try_decoder_cmd,
> + .vidioc_decoder_cmd = cedrus_decoder_cmd,
> +
> .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
> };
>
Regards,
Hans
Powered by blists - more mailing lists