All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
@ 2019-05-28  8:34 Hans Verkuil
  2019-05-28  8:34 ` [PATCH 1/2] " Hans Verkuil
  2019-05-28  8:34 ` [PATCH 2/2] vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs Hans Verkuil
  0 siblings, 2 replies; 7+ messages in thread
From: Hans Verkuil @ 2019-05-28  8:34 UTC (permalink / raw)
  To: linux-media
  Cc: Tomasz Figa, Paul Kocialkowski, Nicolas Dufresne, Boris Brezillon

The implementation of these two ioctls is the same for all codecs, so
add helper functions for this, rather than re-implementing it for all
codecs.

Regards,

	Hans

Hans Verkuil (2):
  v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
  vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs

 drivers/media/platform/vicodec/vicodec-core.c | 35 +++----------------
 drivers/media/v4l2-core/v4l2-mem2mem.c        | 32 +++++++++++++++++
 include/media/v4l2-mem2mem.h                  |  4 +++
 3 files changed, 40 insertions(+), 31 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
  2019-05-28  8:34 [PATCH 0/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers Hans Verkuil
@ 2019-05-28  8:34 ` Hans Verkuil
  2019-05-29  3:11   ` Tomasz Figa
  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
  1 sibling, 2 replies; 7+ messages in thread
From: Hans Verkuil @ 2019-05-28  8:34 UTC (permalink / raw)
  To: linux-media
  Cc: Tomasz Figa, Paul Kocialkowski, Nicolas Dufresne,
	Boris Brezillon, Hans Verkuil

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.

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;
+	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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs
  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-28  8:34 ` Hans Verkuil
  2019-05-29  3:22   ` Tomasz Figa
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Verkuil @ 2019-05-28  8:34 UTC (permalink / raw)
  To: linux-media
  Cc: Tomasz Figa, Paul Kocialkowski, Nicolas Dufresne,
	Boris Brezillon, Hans Verkuil

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

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
  2019-05-28  8:34 ` [PATCH 1/2] " Hans Verkuil
@ 2019-05-29  3:11   ` Tomasz Figa
  2019-05-29  6:28     ` Hans Verkuil
  2019-05-29  6:45   ` [PATCHv2 " Hans Verkuil
  1 sibling, 1 reply; 7+ messages in thread
From: Tomasz Figa @ 2019-05-29  3:11 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Paul Kocialkowski, Nicolas Dufresne,
	Boris Brezillon

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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] vicodec: use new v4l2_m2m_ioctl_try_en/decoder_cmd funcs
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Tomasz Figa @ 2019-05-29  3:22 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Paul Kocialkowski, Nicolas Dufresne,
	Boris Brezillon

On Tue, May 28, 2019 at 5:34 PM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
>
> Use the new helper functions for the try_de/decoder_cmd ioctls.
>
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  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@chromium.org>

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
  2019-05-29  3:11   ` Tomasz Figa
@ 2019-05-29  6:28     ` Hans Verkuil
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2019-05-29  6:28 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: Linux Media Mailing List, Paul Kocialkowski, Nicolas Dufresne,
	Boris Brezillon

On 5/29/19 5:11 AM, Tomasz Figa wrote:
> 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?

The spec says:

"If no flags are defined for this command, drivers and applications must set this field to zero."

Since START has no defined flags, we just set it to 0.

That said, I think this function should just set flags to 0 for both
commands.

The idea is that an application calls TRY_ENCODER_CMD to check if 1) the
command is supported and 2) to see which flags are supported. In this case,
no flags are supported, so just signal that by setting flags to 0.

> 
> 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;
>> +       }

The same thing is true for TRY_DECODER_CMD, it should just set flags to 0
and also dc->stop.pts.

Just like TRY_FMT it should set values to what the driver is capable of.

I'll prepare a v2 (and update the compliance tests for this).

Regards,

	Hans

>> +       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
>>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv2 1/2] v4l2-mem2mem: add try_en/decoder_cmd ioctl helpers
  2019-05-28  8:34 ` [PATCH 1/2] " Hans Verkuil
  2019-05-29  3:11   ` Tomasz Figa
@ 2019-05-29  6:45   ` Hans Verkuil
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2019-05-29  6:45 UTC (permalink / raw)
  To: linux-media
  Cc: Tomasz Figa, Paul Kocialkowski, Nicolas Dufresne, Boris Brezillon

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.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
Changes in v2:

Don't check, just clear flags and stop.pts fields. TRY_* shouldn't check
the passed values, but just return what it actually supported by the driver.
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 29 ++++++++++++++++++++++++++
 include/media/v4l2-mem2mem.h           |  4 ++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 3392833d9541..498044a0cb4e 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -1122,6 +1122,35 @@ 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;
+
+	ec->flags = 0;
+	return 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;
+
+	dc->flags = 0;
+
+	if (dc->cmd == V4L2_DEC_CMD_STOP) {
+		dc->stop.pts = 0;
+	} else 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-05-29  6:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.