All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Nicolas Dufresne <nicolas@ndufresne.ca>,
	Boris Brezillon <boris.brezillon@collabora.com>
Subject: Re: [PATCH 1/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
Date: Wed, 29 May 2019 12:11:53 +0900	[thread overview]
Message-ID: <CAAFQd5CaiNfpvopRYAL-r=6JN9Peat0nciqh=K8h53P4_=umXg@mail.gmail.com> (raw)
In-Reply-To: <20190528083437.103215-2-hverkuil-cisco@xs4all.nl>

Hi Hans,

On Tue, May 28, 2019 at 5:34 PM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
>
> Most if not all codecs will need to implement these ioctls and
> it is expected to be the same for all codecs. So add this to
> the core v4l2-mem2mem framework so that this code can easily be
> reused.
>

Thanks for the patch. Please see my comments inline.

> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/media/v4l2-core/v4l2-mem2mem.c | 32 ++++++++++++++++++++++++++
>  include/media/v4l2-mem2mem.h           |  4 ++++
>  2 files changed, 36 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
> index 3392833d9541..ba799db5866a 100644
> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> @@ -1122,6 +1122,38 @@ int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
>  }
>  EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamoff);
>
> +int v4l2_m2m_ioctl_try_encoder_cmd(struct file *file, void *fh,
> +                                  struct v4l2_encoder_cmd *ec)
> +{
> +       if (ec->cmd != V4L2_ENC_CMD_STOP && ec->cmd != V4L2_ENC_CMD_START)
> +               return -EINVAL;
> +
> +       if (ec->cmd == V4L2_ENC_CMD_START)
> +               ec->flags = 0;

Hmm, why do we allow any value for flags in case of START? Shouldn't
we also fail if it's non-zero?

Best regards,
Tomasz

> +       return ec->flags ? -EINVAL : 0;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_try_encoder_cmd);
> +
> +int v4l2_m2m_ioctl_try_decoder_cmd(struct file *file, void *fh,
> +                                  struct v4l2_decoder_cmd *dc)
> +{
> +       if (dc->cmd != V4L2_DEC_CMD_STOP && dc->cmd != V4L2_DEC_CMD_START)
> +               return -EINVAL;
> +
> +       if (dc->flags)
> +               return -EINVAL;
> +
> +       if (dc->cmd == V4L2_DEC_CMD_STOP && dc->stop.pts)
> +               return -EINVAL;
> +
> +       if (dc->cmd == V4L2_DEC_CMD_START) {
> +               dc->start.speed = 0;
> +               dc->start.format = V4L2_DEC_START_FMT_NONE;
> +       }
> +       return 0;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_try_decoder_cmd);
> +
>  /*
>   * v4l2_file_operations helpers. It is assumed here same lock is used
>   * for the output and the capture buffer queue.
> diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
> index bb3e63d6bd1a..2e0c989266a7 100644
> --- a/include/media/v4l2-mem2mem.h
> +++ b/include/media/v4l2-mem2mem.h
> @@ -672,6 +672,10 @@ int v4l2_m2m_ioctl_streamon(struct file *file, void *fh,
>                                 enum v4l2_buf_type type);
>  int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
>                                 enum v4l2_buf_type type);
> +int v4l2_m2m_ioctl_try_encoder_cmd(struct file *file, void *fh,
> +                                  struct v4l2_encoder_cmd *ec);
> +int v4l2_m2m_ioctl_try_decoder_cmd(struct file *file, void *fh,
> +                                  struct v4l2_decoder_cmd *dc);
>  int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
>  __poll_t v4l2_m2m_fop_poll(struct file *file, poll_table *wait);
>
> --
> 2.20.1
>

  reply	other threads:[~2019-05-29  3:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28  8:34 [PATCH 0/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers Hans Verkuil
2019-05-28  8:34 ` [PATCH 1/2] " Hans Verkuil
2019-05-29  3:11   ` Tomasz Figa [this message]
2019-05-29  6:28     ` Hans Verkuil
2019-05-29  6:45   ` [PATCHv2 " Hans Verkuil
2019-05-28  8:34 ` [PATCH 2/2] vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs Hans Verkuil
2019-05-29  3:22   ` Tomasz Figa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAFQd5CaiNfpvopRYAL-r=6JN9Peat0nciqh=K8h53P4_=umXg@mail.gmail.com' \
    --to=tfiga@chromium.org \
    --cc=boris.brezillon@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=paul.kocialkowski@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.