Skip to contentSkip to conversation

Add V4L2_BUF_TYPE_META_OUTPUT buffer type

RFC In review Sakari Ailus 4 participants 8 messages Jun 16, 2017 – Aug 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add V4L2_BUF_TYPE_META_OUTPUT buffer type

The V4L2_BUF_TYPE_META_OUTPUT buffer type complements the metadata buffer types support for OUTPUT buffers, capture being already supported. This is intended for similar cases than V4L2_BUF_TYPE_META_CAPTURE but for output buffers, e.g. device parameters that may be complex and highly hierarchical data structure. Statistics are a current use case for metadata capture buffers.

There's a warning related to references from make htmldocs; I'll fix that in v2 / non-RFC version.

Sakari Ailus (2):
v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT
docs-rst: v4l: Document V4L2_BUF_TYPE_META_OUTPUT interface

 Documentation/media/uapi/v4l/buffer.rst          |  3 +++
 Documentation/media/uapi/v4l/dev-meta.rst        | 32 ++++++++++++++----------
 Documentation/media/uapi/v4l/vidioc-querycap.rst |  3 +++
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c    |  2 ++
 drivers/media/v4l2-core/v4l2-ioctl.c             | 25 ++++++++++++++++++
 drivers/media/v4l2-core/videobuf2-v4l2.c         |  1 +
 include/media/v4l2-ioctl.h                       | 17 +++++++++++++
 include/uapi/linux/videodev2.h                   |  2 ++
 8 files changed, 72 insertions(+), 13 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

RFC 1/2 v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT

The V4L2_BUF_TYPE_META_OUTPUT mirrors the V4L2_BUF_TYPE_META_CAPTURE with the exception that it is an OUTPUT type. The use case for this is to pass buffers to the device that are not image data but metadata. The formats, just as the metadata capture formats, are typically device specific and highly structured.

---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c |  2 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          | 25 +++++++++++++++++++++++++
 drivers/media/v4l2-core/videobuf2-v4l2.c      |  1 +
 include/media/v4l2-ioctl.h                    | 17 +++++++++++++++++
 include/uapi/linux/videodev2.h                |  2 ++
 5 files changed, 47 insertions(+)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +2 -0
index 6f52970..a0360fe 100644
@@ -232,6 +232,7 @@ static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
 	case V4L2_BUF_TYPE_SDR_OUTPUT:
 		return get_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
 	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
 		return get_v4l2_meta_format(&kp->fmt.meta, &up->fmt.meta);
 	default:
 		pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
@@ -281,6 +282,7 @@ static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
 	case V4L2_BUF_TYPE_SDR_OUTPUT:
 		return put_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
 	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
 		return put_v4l2_meta_format(&kp->fmt.meta, &up->fmt.meta);
 	default:
 		pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
drivers/media/v4l2-core/v4l2-ioctl.c +25 -0
index 4f27cfa..30dd814 100644
@@ -156,6 +156,7 @@ const char *v4l2_type_names[] = {
 	[V4L2_BUF_TYPE_SDR_CAPTURE]        = "sdr-cap",
 	[V4L2_BUF_TYPE_SDR_OUTPUT]         = "sdr-out",
 	[V4L2_BUF_TYPE_META_CAPTURE]       = "meta-cap",
+	[V4L2_BUF_TYPE_META_OUTPUT]	   = "meta-out",
 };
 EXPORT_SYMBOL(v4l2_type_names);
 
@@ -328,6 +329,7 @@ static void v4l_print_format(const void *arg, bool write_only)
 			(sdr->pixelformat >> 24) & 0xff);
 		break;
 	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
 		meta = &p->fmt.meta;
 		pr_cont(", dataformat=%c%c%c%c, buffersize=%u\n",
 			(meta->dataformat >>  0) & 0xff,
@@ -958,6 +960,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
 		if (is_vid && is_rx && ops->vidioc_g_fmt_meta_cap)
 			return 0;
 		break;
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (is_vid && is_tx && ops->vidioc_g_fmt_meta_out)
+			return 0;
+		break;
 	default:
 		break;
 	}
@@ -1349,6 +1355,11 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
 			break;
 		ret = ops->vidioc_enum_fmt_meta_cap(file, fh, arg);
 		break;
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_enum_fmt_meta_out))
+			break;
+		ret = ops->vidioc_enum_fmt_meta_out(file, fh, arg);
+		break;
 	}
 	if (ret == 0)
 		v4l_fill_fmtdesc(p);
@@ -1452,6 +1463,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
 		if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_meta_cap))
 			break;
 		return ops->vidioc_g_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_meta_out))
+			break;
+		return ops->vidioc_g_fmt_meta_out(file, fh, arg);
 	}
 	return -EINVAL;
 }
@@ -1562,6 +1577,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
 			break;
 		CLEAR_AFTER_FIELD(p, fmt.meta);
 		return ops->vidioc_s_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_s_fmt_meta_out))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.meta);
+		return ops->vidioc_s_fmt_meta_out(file, fh, arg);
 	}
 	return -EINVAL;
 }
@@ -1652,6 +1672,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
 			break;
 		CLEAR_AFTER_FIELD(p, fmt.meta);
 		return ops->vidioc_try_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_try_fmt_meta_out))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.meta);
+		return ops->vidioc_try_fmt_meta_out(file, fh, arg);
 	}
 	return -EINVAL;
 }
drivers/media/v4l2-core/videobuf2-v4l2.c +1 -0
index 0c06699..f17f6d7 100644
@@ -545,6 +545,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
 		requested_sizes[0] = f->fmt.sdr.buffersize;
 		break;
 	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
 		requested_sizes[0] = f->fmt.meta.buffersize;
 		break;
 	default:
include/media/v4l2-ioctl.h +17 -0
index bd53121..696bd13 100644
@@ -47,6 +47,9 @@ struct v4l2_fh;
  * @vidioc_enum_fmt_meta_cap: pointer to the function that implements
  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
  *	for metadata capture
+ * @vidioc_enum_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
+ *	for metadata output
  * @vidioc_g_fmt_vid_cap: pointer to the function that implements
  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture
  *	in single plane mode
@@ -79,6 +82,8 @@ struct v4l2_fh;
  *	Radio output
  * @vidioc_g_fmt_meta_cap: pointer to the function that implements
  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_g_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata output
  * @vidioc_s_fmt_vid_cap: pointer to the function that implements
  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture
  *	in single plane mode
@@ -111,6 +116,8 @@ struct v4l2_fh;
  *	Radio output
  * @vidioc_s_fmt_meta_cap: pointer to the function that implements
  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_s_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata output
  * @vidioc_try_fmt_vid_cap: pointer to the function that implements
  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture
  *	in single plane mode
@@ -145,6 +152,8 @@ struct v4l2_fh;
  *	Radio output
  * @vidioc_try_fmt_meta_cap: pointer to the function that implements
  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_try_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata output
  * @vidioc_reqbufs: pointer to the function that implements
  *	:ref:`VIDIOC_REQBUFS <vidioc_reqbufs>` ioctl
  * @vidioc_querybuf: pointer to the function that implements
@@ -317,6 +326,8 @@ struct v4l2_ioctl_ops {
 				       struct v4l2_fmtdesc *f);
 	int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
 					struct v4l2_fmtdesc *f);
+	int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
+					struct v4l2_fmtdesc *f);
 
 	/* VIDIOC_G_FMT handlers */
 	int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
@@ -345,6 +356,8 @@ struct v4l2_ioctl_ops {
 				    struct v4l2_format *f);
 	int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
 				     struct v4l2_format *f);
+	int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
+				     struct v4l2_format *f);
 
 	/* VIDIOC_S_FMT handlers */
 	int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
@@ -373,6 +386,8 @@ struct v4l2_ioctl_ops {
 				    struct v4l2_format *f);
 	int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
 				     struct v4l2_format *f);
+	int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
+				     struct v4l2_format *f);
 
 	/* VIDIOC_TRY_FMT handlers */
 	int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
@@ -401,6 +416,8 @@ struct v4l2_ioctl_ops {
 				      struct v4l2_format *f);
 	int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
 				       struct v4l2_format *f);
+	int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
+				       struct v4l2_format *f);
 
 	/* Buffer handlers */
 	int (*vidioc_reqbufs)(struct file *file, void *fh,
include/uapi/linux/videodev2.h +2 -0
index 2b8feb8..b6c850a 100644
@@ -144,6 +144,7 @@ enum v4l2_buf_type {
 	V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
 	V4L2_BUF_TYPE_SDR_OUTPUT           = 12,
 	V4L2_BUF_TYPE_META_CAPTURE         = 13,
+	V4L2_BUF_TYPE_META_OUTPUT	   = 14,
 	/* Deprecated, do not use */
 	V4L2_BUF_TYPE_PRIVATE              = 0x80,
 };
@@ -457,6 +458,7 @@ struct v4l2_capability {
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
+#define V4L2_CAP_META_OUTPUT		0x08000000  /* Is a metadata output device */
 
 #define V4L2_CAP_TOUCH                  0x10000000  /* Is a touch device */
 
Signature · 1 line
2.7.4
Acked-by on v1 1/2
#2 lore raw

Re: [RFC 1/2] v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT

Quoted 7 lines · Sakari Ailus

The V4L2_BUF_TYPE_META_OUTPUT mirrors the V4L2_BUF_TYPE_META_CAPTURE with the exception that it is an OUTPUT type. The use case for this is to pass buffers to the device that are not image data but metadata. The formats, just as the metadata capture formats, are typically device specific and highly structured.

Thanks!

Hans

Quoted 216 lines
---
  drivers/media/v4l2-core/v4l2-compat-ioctl32.c |  2 ++
  drivers/media/v4l2-core/v4l2-ioctl.c          | 25 +++++++++++++++++++++++++
  drivers/media/v4l2-core/videobuf2-v4l2.c      |  1 +
  include/media/v4l2-ioctl.h                    | 17 +++++++++++++++++
  include/uapi/linux/videodev2.h                |  2 ++
  5 files changed, 47 insertions(+)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +2 -0
index 6f52970..a0360fe 100644
@@ -232,6 +232,7 @@ static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
  	case V4L2_BUF_TYPE_SDR_OUTPUT:
  		return get_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
  	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
  		return get_v4l2_meta_format(&kp->fmt.meta, &up->fmt.meta);
  	default:
  		pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
@@ -281,6 +282,7 @@ static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
  	case V4L2_BUF_TYPE_SDR_OUTPUT:
  		return put_v4l2_sdr_format(&kp->fmt.sdr, &up->fmt.sdr);
  	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
  		return put_v4l2_meta_format(&kp->fmt.meta, &up->fmt.meta);
  	default:
  		pr_info("compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
drivers/media/v4l2-core/v4l2-ioctl.c +25 -0
index 4f27cfa..30dd814 100644
@@ -156,6 +156,7 @@ const char *v4l2_type_names[] = {
  	[V4L2_BUF_TYPE_SDR_CAPTURE]        = "sdr-cap",
  	[V4L2_BUF_TYPE_SDR_OUTPUT]         = "sdr-out",
  	[V4L2_BUF_TYPE_META_CAPTURE]       = "meta-cap",
+	[V4L2_BUF_TYPE_META_OUTPUT]	   = "meta-out",
  };
  EXPORT_SYMBOL(v4l2_type_names);
 
@@ -328,6 +329,7 @@ static void v4l_print_format(const void *arg, bool write_only)
  			(sdr->pixelformat >> 24) & 0xff);
  		break;
  	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
  		meta = &p->fmt.meta;
  		pr_cont(", dataformat=%c%c%c%c, buffersize=%u\n",
  			(meta->dataformat >>  0) & 0xff,
@@ -958,6 +960,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
  		if (is_vid && is_rx && ops->vidioc_g_fmt_meta_cap)
  			return 0;
  		break;
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (is_vid && is_tx && ops->vidioc_g_fmt_meta_out)
+			return 0;
+		break;
  	default:
  		break;
  	}
@@ -1349,6 +1355,11 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
  			break;
  		ret = ops->vidioc_enum_fmt_meta_cap(file, fh, arg);
  		break;
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_enum_fmt_meta_out))
+			break;
+		ret = ops->vidioc_enum_fmt_meta_out(file, fh, arg);
+		break;
  	}
  	if (ret == 0)
  		v4l_fill_fmtdesc(p);
@@ -1452,6 +1463,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
  		if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_meta_cap))
  			break;
  		return ops->vidioc_g_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_meta_out))
+			break;
+		return ops->vidioc_g_fmt_meta_out(file, fh, arg);
  	}
  	return -EINVAL;
  }
@@ -1562,6 +1577,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
  			break;
  		CLEAR_AFTER_FIELD(p, fmt.meta);
  		return ops->vidioc_s_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_s_fmt_meta_out))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.meta);
+		return ops->vidioc_s_fmt_meta_out(file, fh, arg);
  	}
  	return -EINVAL;
  }
@@ -1652,6 +1672,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
  			break;
  		CLEAR_AFTER_FIELD(p, fmt.meta);
  		return ops->vidioc_try_fmt_meta_cap(file, fh, arg);
+	case V4L2_BUF_TYPE_META_OUTPUT:
+		if (unlikely(!is_tx || !is_vid || !ops->vidioc_try_fmt_meta_out))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.meta);
+		return ops->vidioc_try_fmt_meta_out(file, fh, arg);
  	}
  	return -EINVAL;
  }
drivers/media/v4l2-core/videobuf2-v4l2.c +1 -0
index 0c06699..f17f6d7 100644
@@ -545,6 +545,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
  		requested_sizes[0] = f->fmt.sdr.buffersize;
  		break;
  	case V4L2_BUF_TYPE_META_CAPTURE:
+	case V4L2_BUF_TYPE_META_OUTPUT:
  		requested_sizes[0] = f->fmt.meta.buffersize;
  		break;
  	default:
include/media/v4l2-ioctl.h +17 -0
index bd53121..696bd13 100644
@@ -47,6 +47,9 @@ struct v4l2_fh;
   * @vidioc_enum_fmt_meta_cap: pointer to the function that implements
   *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
   *	for metadata capture
+ * @vidioc_enum_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
+ *	for metadata output
   * @vidioc_g_fmt_vid_cap: pointer to the function that implements
   *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture
   *	in single plane mode
@@ -79,6 +82,8 @@ struct v4l2_fh;
   *	Radio output
   * @vidioc_g_fmt_meta_cap: pointer to the function that implements
   *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_g_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata output
   * @vidioc_s_fmt_vid_cap: pointer to the function that implements
   *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture
   *	in single plane mode
@@ -111,6 +116,8 @@ struct v4l2_fh;
   *	Radio output
   * @vidioc_s_fmt_meta_cap: pointer to the function that implements
   *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_s_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata output
   * @vidioc_try_fmt_vid_cap: pointer to the function that implements
   *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture
   *	in single plane mode
@@ -145,6 +152,8 @@ struct v4l2_fh;
   *	Radio output
   * @vidioc_try_fmt_meta_cap: pointer to the function that implements
   *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
+ * @vidioc_try_fmt_meta_out: pointer to the function that implements
+ *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata output
   * @vidioc_reqbufs: pointer to the function that implements
   *	:ref:`VIDIOC_REQBUFS <vidioc_reqbufs>` ioctl
   * @vidioc_querybuf: pointer to the function that implements
@@ -317,6 +326,8 @@ struct v4l2_ioctl_ops {
  				       struct v4l2_fmtdesc *f);
  	int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
  					struct v4l2_fmtdesc *f);
+	int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
+					struct v4l2_fmtdesc *f);
 
  	/* VIDIOC_G_FMT handlers */
  	int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
@@ -345,6 +356,8 @@ struct v4l2_ioctl_ops {
  				    struct v4l2_format *f);
  	int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
  				     struct v4l2_format *f);
+	int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
+				     struct v4l2_format *f);
 
  	/* VIDIOC_S_FMT handlers */
  	int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
@@ -373,6 +386,8 @@ struct v4l2_ioctl_ops {
  				    struct v4l2_format *f);
  	int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
  				     struct v4l2_format *f);
+	int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
+				     struct v4l2_format *f);
 
  	/* VIDIOC_TRY_FMT handlers */
  	int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
@@ -401,6 +416,8 @@ struct v4l2_ioctl_ops {
  				      struct v4l2_format *f);
  	int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
  				       struct v4l2_format *f);
+	int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
+				       struct v4l2_format *f);
 
  	/* Buffer handlers */
  	int (*vidioc_reqbufs)(struct file *file, void *fh,
include/uapi/linux/videodev2.h +2 -0
index 2b8feb8..b6c850a 100644
@@ -144,6 +144,7 @@ enum v4l2_buf_type {
  	V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
  	V4L2_BUF_TYPE_SDR_OUTPUT           = 12,
  	V4L2_BUF_TYPE_META_CAPTURE         = 13,
+	V4L2_BUF_TYPE_META_OUTPUT	   = 14,
  	/* Deprecated, do not use */
  	V4L2_BUF_TYPE_PRIVATE              = 0x80,
  };
@@ -457,6 +458,7 @@ struct v4l2_capability {
  #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
  #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */
  #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
+#define V4L2_CAP_META_OUTPUT		0x08000000  /* Is a metadata output device */
 
  #define V4L2_CAP_TOUCH                  0x10000000  /* Is a touch device */
 
#3 lore raw

Re: [RFC 1/2] v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT

Em Fri, 16 Jun 2017 17:48:44 +0200
Hans Verkuil <[email protected]> escreveu:

Quoted 10 lines · Sakari Ailus
Quoted 7 lines

The V4L2_BUF_TYPE_META_OUTPUT mirrors the V4L2_BUF_TYPE_META_CAPTURE with the exception that it is an OUTPUT type. The use case for this is to pass buffers to the device that are not image data but metadata. The formats, just as the metadata capture formats, are typically device specific and highly structured.

Looks OK to me too.

Thanks,
Mauro

#4 lore raw

RFC 2/2 docs-rst: v4l: Document V4L2_BUF_TYPE_META_OUTPUT interface

In reply to Sakari Ailus

Document the interface for metadata output, including V4L2_BUF_TYPE_META_OUTPUT buffer type and V4L2_CAP_META_OUTPUT capability bits.

---
 Documentation/media/uapi/v4l/buffer.rst          |  3 +++
 Documentation/media/uapi/v4l/dev-meta.rst        | 32 ++++++++++++++----------
 Documentation/media/uapi/v4l/vidioc-querycap.rst |  3 +++
 3 files changed, 25 insertions(+), 13 deletions(-)
Documentation/media/uapi/v4l/buffer.rst +3 -0
index ae6ee73..919ac1d 100644
@@ -452,6 +452,9 @@ enum v4l2_buf_type
     * - ``V4L2_BUF_TYPE_META_CAPTURE``
       - 13
       - Buffer for metadata capture, see :ref:`metadata`.
+    * - ``V4L2_BUF_TYPE_META_CAPTURE``
+      - 14
+      - Buffer for metadata output, see :ref:`metadata`.
 
 
 
Documentation/media/uapi/v4l/dev-meta.rst +19 -13
index 62518ad..cb007dd 100644
@@ -7,21 +7,26 @@ Metadata Interface
 ******************
 
 Metadata refers to any non-image data that supplements video frames with
-additional information. This may include statistics computed over the image
-or frame capture parameters supplied by the image source. This interface is
-intended for transfer of metadata to userspace and control of that operation.
+additional information. This may include statistics computed over the image,
+frame capture parameters supplied by the image source or device specific
+parameters. This interface is intended for transfer of metadata between
+the userspace and the hardware and control of that operation.
 
-The metadata interface is implemented on video capture device nodes. The device
-can be dedicated to metadata or can implement both video and metadata capture
-as specified in its reported capabilities.
+The metadata interface is implemented on video device nodes. The device can be
+dedicated to metadata or can support both video and metadata as specified in its
+reported capabilities.
 
 Querying Capabilities
 =====================
 
-Device nodes supporting the metadata interface set the ``V4L2_CAP_META_CAPTURE``
-flag in the ``device_caps`` field of the
+Device nodes supporting the metadata capture interface set the
+``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
 :c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
-ioctl. That flag means the device can capture metadata to memory.
+ioctl. That flag means the device can capture metadata to memory. Similarly,
+device nodes supporting metadata output interface set the
+``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
+:c:type:`v4l2_capability` structure. That flag means the device can read
+metadata from memory.
 
 At least one of the read/write or streaming I/O methods must be supported.
 
@@ -35,10 +40,11 @@ to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
 supported as well.
 
 To use the :ref:`format` ioctls applications set the ``type`` field of the
-:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` and use the
-:c:type:`v4l2_meta_format` ``meta`` member of the ``fmt`` union as needed per
-the desired operation. Both drivers and applications must set the remainder of
-the :c:type:`v4l2_format` structure to 0.
+:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
+``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
+member of the ``fmt`` union as needed per the desired operation. Both drivers
+and applications must set the remainder of the :c:type:`v4l2_format` structure
+to 0.
 
 .. _v4l2-meta-format:
 
Documentation/media/uapi/v4l/vidioc-querycap.rst +3 -0
index 12e0d9a..36bf879 100644
@@ -249,6 +249,9 @@ specification the ioctl returns an ``EINVAL`` error code.
     * - ``V4L2_CAP_STREAMING``
       - 0x04000000
       - The device supports the :ref:`streaming <mmap>` I/O method.
+    * - ``V4L2_CAP_META_OUTPUT``
+      - 0x08000000
+      - The device supports the :ref:`metadata` output interface.
     * - ``V4L2_CAP_TOUCH``
       - 0x10000000
       - This is a touch device.
Signature · 1 line
2.7.4
Acked-by on v1 2/2
#5 lore raw

Re: [RFC 2/2] docs-rst: v4l: Document V4L2_BUF_TYPE_META_OUTPUT interface

Quoted 16 lines · Sakari Ailus

Document the interface for metadata output, including V4L2_BUF_TYPE_META_OUTPUT buffer type and V4L2_CAP_META_OUTPUT capability bits.

---
  Documentation/media/uapi/v4l/buffer.rst          |  3 +++
  Documentation/media/uapi/v4l/dev-meta.rst        | 32 ++++++++++++++----------
  Documentation/media/uapi/v4l/vidioc-querycap.rst |  3 +++
  3 files changed, 25 insertions(+), 13 deletions(-)
Documentation/media/uapi/v4l/buffer.rst +0 -0
index ae6ee73..919ac1d 100644

Documentation/media/uapi/v4l/buffer.rst enum v4l2_buf_type · line 455

Quoted 4 lines
Documentation/media/uapi/v4l/buffer.rst +1 -0
@@ -452,6 +452,9 @@ enum v4l2_buf_type
      * - ``V4L2_BUF_TYPE_META_CAPTURE``
        - 13
        - Buffer for metadata capture, see :ref:`metadata`.
+    * - ``V4L2_BUF_TYPE_META_CAPTURE``

Should be OUTPUT of course.

Quoted 67 lines
Documentation/media/uapi/v4l/buffer.rst +2 -0
+      - 14
+      - Buffer for metadata output, see :ref:`metadata`.
 
 
 
Documentation/media/uapi/v4l/dev-meta.rst +19 -13
index 62518ad..cb007dd 100644
@@ -7,21 +7,26 @@ Metadata Interface
  ******************
 
  Metadata refers to any non-image data that supplements video frames with
-additional information. This may include statistics computed over the image
-or frame capture parameters supplied by the image source. This interface is
-intended for transfer of metadata to userspace and control of that operation.
+additional information. This may include statistics computed over the image,
+frame capture parameters supplied by the image source or device specific
+parameters. This interface is intended for transfer of metadata between
+the userspace and the hardware and control of that operation.
 
-The metadata interface is implemented on video capture device nodes. The device
-can be dedicated to metadata or can implement both video and metadata capture
-as specified in its reported capabilities.
+The metadata interface is implemented on video device nodes. The device can be
+dedicated to metadata or can support both video and metadata as specified in its
+reported capabilities.
 
  Querying Capabilities
  =====================
 
-Device nodes supporting the metadata interface set the ``V4L2_CAP_META_CAPTURE``
-flag in the ``device_caps`` field of the
+Device nodes supporting the metadata capture interface set the
+``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
  :c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
-ioctl. That flag means the device can capture metadata to memory.
+ioctl. That flag means the device can capture metadata to memory. Similarly,
+device nodes supporting metadata output interface set the
+``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
+:c:type:`v4l2_capability` structure. That flag means the device can read
+metadata from memory.
 
  At least one of the read/write or streaming I/O methods must be supported.
 
@@ -35,10 +40,11 @@ to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
  supported as well.
 
  To use the :ref:`format` ioctls applications set the ``type`` field of the
-:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` and use the
-:c:type:`v4l2_meta_format` ``meta`` member of the ``fmt`` union as needed per
-the desired operation. Both drivers and applications must set the remainder of
-the :c:type:`v4l2_format` structure to 0.
+:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
+``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
+member of the ``fmt`` union as needed per the desired operation. Both drivers
+and applications must set the remainder of the :c:type:`v4l2_format` structure
+to 0.
 
  .. _v4l2-meta-format:
 
Documentation/media/uapi/v4l/vidioc-querycap.rst +0 -0
index 12e0d9a..36bf879 100644

Documentation/media/uapi/v4l/vidioc-querycap.rst specification the ioctl returns an ``EINVAL`` error code. · line 257

Quoted 9 lines
Documentation/media/uapi/v4l/vidioc-querycap.rst +3 -0
@@ -249,6 +249,9 @@ specification the ioctl returns an ``EINVAL`` error code.
      * - ``V4L2_CAP_STREAMING``
        - 0x04000000
        - The device supports the :ref:`streaming <mmap>` I/O method.
+    * - ``V4L2_CAP_META_OUTPUT``
+      - 0x08000000
+      - The device supports the :ref:`metadata` output interface.
      * - ``V4L2_CAP_TOUCH``
        - 0x10000000
        - This is a touch device.

With that fixed:

Thanks!

Hans

#6 lore raw
In reply to Sakari Ailus

Hi Sakari,

Quoted 14 lines · Sakari Ailus

The V4L2_BUF_TYPE_META_OUTPUT buffer type complements the metadata buffer types support for OUTPUT buffers, capture being already supported. This is intended for similar cases than V4L2_BUF_TYPE_META_CAPTURE but for output buffers, e.g. device parameters that may be complex and highly hierarchical data structure. Statistics are a current use case for metadata capture buffers.

There's a warning related to references from make htmldocs; I'll fix that in v2 / non-RFC version.

Sakari Ailus (2):
v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT
docs-rst: v4l: Document V4L2_BUF_TYPE_META_OUTPUT interface

Quoted 10 lines
  Documentation/media/uapi/v4l/buffer.rst          |  3 +++
  Documentation/media/uapi/v4l/dev-meta.rst        | 32 ++++++++++++++----------
  Documentation/media/uapi/v4l/vidioc-querycap.rst |  3 +++
  drivers/media/v4l2-core/v4l2-compat-ioctl32.c    |  2 ++
  drivers/media/v4l2-core/v4l2-ioctl.c             | 25 ++++++++++++++++++
  drivers/media/v4l2-core/videobuf2-v4l2.c         |  1 +
  include/media/v4l2-ioctl.h                       | 17 +++++++++++++
  include/uapi/linux/videodev2.h                   |  2 ++
  8 files changed, 72 insertions(+), 13 deletions(-)

I would very much appreciate it if you can also provide patches for v4l2-ctl and v4l2-compliance. Should be quite easy, just follow what I did for the META_CAPTURE support.

Regards,

Hans

#7 lore raw
In reply to Sakari Ailus

Hi Sakari,

Quoted 14 lines · Sakari Ailus

The V4L2_BUF_TYPE_META_OUTPUT buffer type complements the metadata buffer types support for OUTPUT buffers, capture being already supported. This is intended for similar cases than V4L2_BUF_TYPE_META_CAPTURE but for output buffers, e.g. device parameters that may be complex and highly hierarchical data structure. Statistics are a current use case for metadata capture buffers.

There's a warning related to references from make htmldocs; I'll fix that in v2 / non-RFC version.

Sakari Ailus (2):
v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT
docs-rst: v4l: Document V4L2_BUF_TYPE_META_OUTPUT interface

Quoted 9 lines
 Documentation/media/uapi/v4l/buffer.rst          |  3 +++
 Documentation/media/uapi/v4l/dev-meta.rst        | 32 ++++++++++++++----------
 Documentation/media/uapi/v4l/vidioc-querycap.rst |  3 +++
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c    |  2 ++
 drivers/media/v4l2-core/v4l2-ioctl.c             | 25 ++++++++++++++++++
 drivers/media/v4l2-core/videobuf2-v4l2.c         |  1 +
 include/media/v4l2-ioctl.h                       | 17 +++++++++++++
 include/uapi/linux/videodev2.h                   |  2 ++
 8 files changed, 72 insertions(+), 13 deletions(-)

Is there by any chance an update on this series?

Best regards,
Tomasz