linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO
@ 2015-05-06  6:57 Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 1/8] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab

From: Hans Verkuil <hans.verkuil@cisco.com>

This patch series adds the VIDIOC_SUBDEV_QUERYCAP ioctl for v4l-subdev devices
as discussed during the ELC in San Jose and as discussed here:

http://www.spinics.net/lists/linux-media/msg88009.html

It also add support for MEDIA_IOC_DEVICE_INFO to any media entities so
applications can use that to find the media controller and detailed information
about the entity.

This is the second RFC patch series. The main changes are:

- Drop the entity ID from the querycap ioctls
- Instead have every entity device implement MEDIA_IOC_DEVICE_INFO
- Add major, minor and entity_id fields to struct media_device_info:
  this allows applications to find the MC device and to determine
  the entity ID of the device for which they called the ioctl. It
  is 0 for the MC (entity IDs are always > 0 for entities).

This is IMHO simple, consistent, and it will work for any media entity.

Regards,

	Hans

PS: I have not tested the DVB changes yet. I hope I got those right.

Hans Verkuil (8):
  v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
  DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
  videodev2.h: add V4L2_CAP_ENTITY to querycap
  media: add major/minor/entity_id to struct media_device_info
  v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
  v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
  dvb: add MEDIA_IOC_DEVICE_INFO
  DocBook/media: document the new media_device_info fields.

 .../DocBook/media/v4l/media-ioc-device-info.xml    |  35 +++++-
 Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
 .../DocBook/media/v4l/vidioc-querycap.xml          |   6 +
 .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 +++++++++++++++++++++
 drivers/media/dvb-core/dmxdev.c                    |  24 +++-
 drivers/media/dvb-core/dvb_ca_en50221.c            |  11 ++
 drivers/media/dvb-core/dvb_net.c                   |  11 ++
 drivers/media/media-device.c                       |  29 +++--
 drivers/media/media-devnode.c                      |   5 +-
 drivers/media/v4l2-core/v4l2-ioctl.c               |  43 ++++++-
 drivers/media/v4l2-core/v4l2-subdev.c              |  26 +++++
 include/media/media-device.h                       |   3 +
 include/media/media-devnode.h                      |   1 +
 include/uapi/linux/media.h                         |   5 +-
 include/uapi/linux/v4l2-subdev.h                   |  10 ++
 include/uapi/linux/videodev2.h                     |   1 +
 16 files changed, 316 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml

-- 
2.1.4


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

* [RFCv2 PATCH 1/8] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 2/8] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl
that apps can call to determine that it is indeed a V4L2 device, there
is currently no equivalent for v4l-subdev nodes. Adding this ioctl will
solve that, and it will allow utilities like v4l2-compliance to be used
with these devices as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 14 ++++++++++++++
 include/uapi/linux/v4l2-subdev.h      | 10 ++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..50ada27 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -25,6 +25,7 @@
 #include <linux/types.h>
 #include <linux/videodev2.h>
 #include <linux/export.h>
+#include <linux/version.h>
 
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
@@ -187,6 +188,19 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 #endif
 
 	switch (cmd) {
+	case VIDIOC_SUBDEV_QUERYCAP: {
+		struct v4l2_subdev_capability *cap = arg;
+
+		cap->version = LINUX_VERSION_CODE;
+		cap->device_caps = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+		if (sd->entity.parent)
+			cap->device_caps = V4L2_SUBDEV_CAP_ENTITY;
+#endif
+		memset(cap->reserved, 0, sizeof(cap->reserved));
+		break;
+	}
+
 	case VIDIOC_QUERYCTRL:
 		return v4l2_queryctrl(vfh->ctrl_handler, arg);
 
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index dbce2b5..1848b74 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -154,9 +154,19 @@ struct v4l2_subdev_selection {
 	__u32 reserved[8];
 };
 
+struct v4l2_subdev_capability {
+	__u32 version;
+	__u32 device_caps;
+	__u32 reserved[50];
+};
+
+/* This v4l2_subdev is also a media entity and the entity_id field is valid */
+#define V4L2_SUBDEV_CAP_ENTITY		(1 << 0)
+
 /* Backwards compatibility define --- to be removed */
 #define v4l2_subdev_edid v4l2_edid
 
+#define VIDIOC_SUBDEV_QUERYCAP			 _IOR('V',  0, struct v4l2_subdev_capability)
 #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
 #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
-- 
2.1.4


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

* [RFCv2 PATCH 2/8] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 1/8] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 3/8] videodev2.h: add V4L2_CAP_ENTITY to querycap Hans Verkuil
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Add documentation for the new VIDIOC_SUBDEV_QUERYCAP ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
 .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 +++++++++++++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml

diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index e98caa1..23607bc 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -669,6 +669,7 @@ and discussions on the V4L mailing list.</revremark>
     &sub-subdev-g-fmt;
     &sub-subdev-g-frame-interval;
     &sub-subdev-g-selection;
+    &sub-subdev-querycap;
     &sub-subscribe-event;
     <!-- End of ioctls. -->
     &sub-mmap;
diff --git a/Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
new file mode 100644
index 0000000..7c4fceb
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
@@ -0,0 +1,125 @@
+<refentry id="vidioc-subdev-querycap">
+  <refmeta>
+    <refentrytitle>ioctl VIDIOC_SUBDEV_QUERYCAP</refentrytitle>
+    &manvol;
+  </refmeta>
+
+  <refnamediv>
+    <refname>VIDIOC_SUBDEV_QUERYCAP</refname>
+    <refpurpose>Query sub-device capabilities</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+	<funcdef>int <function>ioctl</function></funcdef>
+	<paramdef>int <parameter>fd</parameter></paramdef>
+	<paramdef>int <parameter>request</parameter></paramdef>
+	<paramdef>struct v4l2_subdev_capability *<parameter>argp</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Arguments</title>
+
+    <variablelist>
+      <varlistentry>
+	<term><parameter>fd</parameter></term>
+	<listitem>
+	  <para>&fd;</para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
+	<term><parameter>request</parameter></term>
+	<listitem>
+	  <para>VIDIOC_SUBDEV_QUERYCAP</para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
+	<term><parameter>argp</parameter></term>
+	<listitem>
+	  <para></para>
+	</listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>All V4L2 sub-devices support the
+<constant>VIDIOC_SUBDEV_QUERYCAP</constant> ioctl. It is used to identify
+kernel devices compatible with this specification and to obtain
+information about driver and hardware capabilities. The ioctl takes a
+pointer to a &v4l2-subdev-capability; which is filled by the driver. When the
+driver is not compatible with this specification the ioctl returns an
+error, most likely the &ENOTTY;.</para>
+
+    <table pgwide="1" frame="none" id="v4l2-subdev-capability">
+      <title>struct <structname>v4l2_subdev_capability</structname></title>
+      <tgroup cols="3">
+	&cs-str;
+	<tbody valign="top">
+	  <row>
+	    <entry>__u32</entry>
+	    <entry><structfield>version</structfield></entry>
+	    <entry><para>Version number of the driver.</para>
+<para>The version reported is provided by the
+V4L2 subsystem following the kernel numbering scheme. However, it
+may not always return the same version as the kernel if, for example,
+a stable or distribution-modified kernel uses the V4L2 stack from a
+newer kernel.</para>
+<para>The version number is formatted using the
+<constant>KERNEL_VERSION()</constant> macro:</para></entry>
+	  </row>
+	  <row>
+	    <entry spanname="hspan"><para>
+<programlisting>
+#define KERNEL_VERSION(a,b,c) (((a) &lt;&lt; 16) + ((b) &lt;&lt; 8) + (c))
+
+__u32 version = KERNEL_VERSION(0, 8, 1);
+
+printf ("Version: %u.%u.%u\n",
+	(version &gt;&gt; 16) &amp; 0xFF,
+	(version &gt;&gt; 8) &amp; 0xFF,
+	 version &amp; 0xFF);
+</programlisting></para></entry>
+	  </row>
+	  <row>
+	    <entry>__u32</entry>
+	    <entry><structfield>device_caps</structfield></entry>
+	    <entry>Sub-device capabilities of the opened device, see <xref
+		linkend="subdevice-capabilities" />.
+	    </entry>
+	  </row>
+	  <row>
+	    <entry>__u32</entry>
+	    <entry><structfield>reserved</structfield>[50]</entry>
+	    <entry>Reserved for future extensions. Drivers must set
+this array to zero.</entry>
+	  </row>
+	</tbody>
+      </tgroup>
+    </table>
+
+    <table pgwide="1" frame="none" id="subdevice-capabilities">
+      <title>Sub-Device Capabilities Flags</title>
+      <tgroup cols="3">
+	&cs-def;
+	<tbody valign="top">
+	  <row>
+	    <entry><constant>V4L2_SUBDEV_CAP_ENTITY</constant></entry>
+	    <entry>0x00000001</entry>
+	    <entry>The sub-device is a media controller entity. If this
+capability is set, then you can call &MEDIA-IOC-DEVICE-INFO;.</entry>
+	  </row>
+	</tbody>
+      </tgroup>
+    </table>
+  </refsect1>
+
+  <refsect1>
+    &return-value;
+  </refsect1>
+</refentry>
-- 
2.1.4


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

* [RFCv2 PATCH 3/8] videodev2.h: add V4L2_CAP_ENTITY to querycap
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 1/8] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 2/8] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 4/8] media: add major/minor/entity_id to struct media_device_info Hans Verkuil
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Add a capability to indicate that this device is a media entity.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/vidioc-querycap.xml | 6 ++++++
 drivers/media/v4l2-core/v4l2-ioctl.c                | 5 +++++
 include/uapi/linux/videodev2.h                      | 1 +
 3 files changed, 12 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index 20fda75..aaa5067 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -308,6 +308,12 @@ modulator programming see
 fields.</entry>
 	  </row>
 	  <row>
+	    <entry><constant>V4L2_CAP_ENTITY</constant></entry>
+	    <entry>0x00400000</entry>
+	    <entry>The device is a media controller entity. If this
+capability is set, then you can call &MEDIA-IOC-DEVICE-INFO;.</entry>
+	  </row>
+	  <row>
 	    <entry><constant>V4L2_CAP_READWRITE</constant></entry>
 	    <entry>0x01000000</entry>
 	    <entry>The device supports the <link
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 1476602..343f3e2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1011,6 +1011,7 @@ static void v4l_sanitize_format(struct v4l2_format *fmt)
 static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 				struct file *file, void *fh, void *arg)
 {
+	struct video_device *vfd = video_devdata(file);
 	struct v4l2_capability *cap = (struct v4l2_capability *)arg;
 	int ret;
 
@@ -1019,6 +1020,10 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 	ret = ops->vidioc_querycap(file, fh, cap);
 
 	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	if (vfd->entity.parent)
+		cap->capabilities |= V4L2_CAP_ENTITY;
+#endif
 	/*
 	 * Drivers MUST fill in device_caps, so check for this and
 	 * warn if it was forgotten.
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index fa376f7..31cf9f1 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -348,6 +348,7 @@ struct v4l2_capability {
 
 #define V4L2_CAP_SDR_CAPTURE		0x00100000  /* Is a SDR capture device */
 #define V4L2_CAP_EXT_PIX_FORMAT		0x00200000  /* Supports the extended pixel format */
+#define V4L2_CAP_ENTITY                 0x00400000  /* This is a Media Controller entity */
 
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */
-- 
2.1.4


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

* [RFCv2 PATCH 4/8] media: add major/minor/entity_id to struct media_device_info
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (2 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 3/8] videodev2.h: add V4L2_CAP_ENTITY to querycap Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 5/8] v4l2-subdev: add MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Device nodes associated with entities should support the MEDIA_IOC_DEVICE_INFO
ioctl in order to let userspace find the media device node from an entity
device node. To be able to do that the major and minor numbers of the
media device node should be available in struct media_device_info and
the function filling in struct media_device_info should be exported.

In addition it will export the entity_id of said device node (which will be
0 for the media controller device node itself).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/media-device.c  | 29 +++++++++++++++++++----------
 drivers/media/media-devnode.c |  5 +++--
 include/media/media-device.h  |  3 +++
 include/media/media-devnode.h |  1 +
 include/uapi/linux/media.h    |  5 ++++-
 5 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 7b39440..6a6ea68 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -44,21 +44,30 @@ static int media_device_close(struct file *filp)
 	return 0;
 }
 
+void media_device_fill_info(const struct media_device *dev,
+			    struct media_device_info *info)
+{
+	memset(info, 0, sizeof(*info));
+
+	strlcpy(info->driver, dev->dev->driver->name, sizeof(info->driver));
+	strlcpy(info->model, dev->model, sizeof(info->model));
+	strlcpy(info->serial, dev->serial, sizeof(info->serial));
+	strlcpy(info->bus_info, dev->bus_info, sizeof(info->bus_info));
+
+	info->media_version = MEDIA_API_VERSION;
+	info->hw_revision = dev->hw_revision;
+	info->driver_version = dev->driver_version;
+	info->major = dev->devnode.major;
+	info->minor = dev->devnode.minor;
+}
+EXPORT_SYMBOL_GPL(media_device_fill_info);
+
 static int media_device_get_info(struct media_device *dev,
 				 struct media_device_info __user *__info)
 {
 	struct media_device_info info;
 
-	memset(&info, 0, sizeof(info));
-
-	strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
-	strlcpy(info.model, dev->model, sizeof(info.model));
-	strlcpy(info.serial, dev->serial, sizeof(info.serial));
-	strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
-
-	info.media_version = MEDIA_API_VERSION;
-	info.hw_revision = dev->hw_revision;
-	info.driver_version = dev->driver_version;
+	media_device_fill_info(dev, &info);
 
 	if (copy_to_user(__info, &info, sizeof(*__info)))
 		return -EFAULT;
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index ebf9626..aaf7e59 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -249,13 +249,14 @@ int __must_check media_devnode_register(struct media_devnode *mdev,
 	set_bit(minor, media_devnode_nums);
 	mutex_unlock(&media_devnode_lock);
 
+	mdev->major = MAJOR(media_dev_t);
 	mdev->minor = minor;
 
 	/* Part 2: Initialize and register the character device */
 	cdev_init(&mdev->cdev, &media_devnode_fops);
 	mdev->cdev.owner = owner;
 
-	ret = cdev_add(&mdev->cdev, MKDEV(MAJOR(media_dev_t), mdev->minor), 1);
+	ret = cdev_add(&mdev->cdev, MKDEV(mdev->major, mdev->minor), 1);
 	if (ret < 0) {
 		pr_err("%s: cdev_add failed\n", __func__);
 		goto error;
@@ -263,7 +264,7 @@ int __must_check media_devnode_register(struct media_devnode *mdev,
 
 	/* Part 3: Register the media device */
 	mdev->dev.bus = &media_bus_type;
-	mdev->dev.devt = MKDEV(MAJOR(media_dev_t), mdev->minor);
+	mdev->dev.devt = MKDEV(mdev->major, mdev->minor);
 	mdev->dev.release = media_devnode_release;
 	if (mdev->parent)
 		mdev->dev.parent = mdev->parent;
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 6e6db78..99f8ec7 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -96,6 +96,9 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 					      struct media_entity *entity);
 void media_device_unregister_entity(struct media_entity *entity);
 
+void media_device_fill_info(const struct media_device *dev,
+			    struct media_device_info *__info);
+
 /* Iterate over all entities. */
 #define media_device_for_each_entity(entity, mdev)			\
 	list_for_each_entry(entity, &(mdev)->entities, list)
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
index 0dc7060..f3ba663 100644
--- a/include/media/media-devnode.h
+++ b/include/media/media-devnode.h
@@ -72,6 +72,7 @@ struct media_devnode {
 	struct device *parent;		/* device parent */
 
 	/* device info */
+	int major;
 	int minor;
 	unsigned long flags;		/* Use bitops to access flags */
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4e816be..7e1d8d0 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -37,7 +37,10 @@ struct media_device_info {
 	__u32 media_version;
 	__u32 hw_revision;
 	__u32 driver_version;
-	__u32 reserved[31];
+	__u32 major;
+	__u32 minor;
+	__u32 entity_id;
+	__u32 reserved[28];
 };
 
 #define MEDIA_ENT_ID_FLAG_NEXT		(1 << 31)
-- 
2.1.4


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

* [RFCv2 PATCH 5/8] v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (3 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 4/8] media: add major/minor/entity_id to struct media_device_info Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 6/8] v4l2-ioctl: " Hans Verkuil
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Support the MEDIA_IOC_DEVICE_INFO ioctl for entities.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 50ada27..ae7480b 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -201,6 +201,18 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 		break;
 	}
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	case MEDIA_IOC_DEVICE_INFO: {
+		struct media_device_info *info = arg;
+
+		if (sd->entity.parent == NULL)
+			return -ENOTTY;
+		media_device_fill_info(sd->entity.parent, info);
+		info->entity_id = sd->entity.id;
+		return 0;
+	}
+#endif
+
 	case VIDIOC_QUERYCTRL:
 		return v4l2_queryctrl(vfh->ctrl_handler, arg);
 
-- 
2.1.4


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

* [RFCv2 PATCH 6/8] v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (4 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 5/8] v4l2-subdev: add MEDIA_IOC_DEVICE_INFO Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 7/8] dvb: " Hans Verkuil
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Support the MEDIA_IOC_DEVICE_INFO ioctl for entities.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 38 +++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 343f3e2..02afffd 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -885,6 +885,19 @@ static void v4l_print_default(const void *arg, bool write_only)
 	pr_cont("driver-specific ioctl\n");
 }
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+static void media_print_device_info(const void *arg, bool write_only)
+{
+	const struct media_device_info *p = arg;
+
+	pr_cont("driver=%s, model=%s, serial=%s, bus_info=%s\n",
+		p->driver, p->model, p->serial, p->bus_info);
+	pr_cont("media_version=0x%08x, hw_revision=%u, driver_version=0x%08x, major=%u, minor=%u, entity_id=%u\n",
+		p->media_version, p->hw_revision, p->driver_version,
+		p->major, p->minor, p->entity_id);
+}
+#endif
+
 static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
 {
 	__u32 i;
@@ -2331,6 +2344,21 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
 	return -ENOTTY;
 }
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+static int media_device_info(const struct v4l2_ioctl_ops *ops,
+			     struct file *file, void *fh, void *arg)
+{
+	struct video_device *vdev = video_devdata(file);
+	struct media_device_info *info = arg;
+
+	if (vdev->entity.parent == NULL)
+		return -ENOTTY;
+	media_device_fill_info(vdev->entity.parent, info);
+	info->entity_id = vdev->entity.id;
+	return 0;
+}
+#endif
+
 struct v4l2_ioctl_info {
 	unsigned int ioctl;
 	u32 flags;
@@ -2465,7 +2493,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
 
 bool v4l2_is_known_ioctl(unsigned int cmd)
 {
-	if (_IOC_NR(cmd) >= V4L2_IOCTLS)
+	if (_IOC_TYPE(cmd) != 'V' || _IOC_NR(cmd) >= V4L2_IOCTLS)
 		return false;
 	return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd;
 }
@@ -2553,6 +2581,14 @@ static long __video_do_ioctl(struct file *file,
 			if (ret)
 				goto done;
 		}
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	} else if (cmd == MEDIA_IOC_DEVICE_INFO) {
+		default_info.ioctl = cmd;
+		default_info.flags = INFO_FL_FUNC;
+		default_info.debug = media_print_device_info;
+		default_info.u.func = media_device_info;
+		info = &default_info;
+#endif
 	} else {
 		default_info.ioctl = cmd;
 		default_info.flags = 0;
-- 
2.1.4


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

* [RFCv2 PATCH 7/8] dvb: add MEDIA_IOC_DEVICE_INFO
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (5 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 6/8] v4l2-ioctl: " Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  6:57 ` [RFCv2 PATCH 8/8] DocBook/media: document the new media_device_info fields Hans Verkuil
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Support the MEDIA_IOC_DEVICE_INFO ioctl for DVB entities.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/dvb-core/dmxdev.c         | 24 +++++++++++++++++++++++-
 drivers/media/dvb-core/dvb_ca_en50221.c | 11 +++++++++++
 drivers/media/dvb-core/dvb_net.c        | 11 +++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index d0e3f9d..ab096eb 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -967,6 +967,17 @@ static int dvb_demux_do_ioctl(struct file *file,
 		return -ERESTARTSYS;
 
 	switch (cmd) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	case MEDIA_IOC_DEVICE_INFO: {
+		struct media_device_info *info = parg;
+
+		if (dmxdev->dvbdev->entity->parent == NULL)
+			return -ENOTTY;
+		media_device_fill_info(dmxdev->dvbdev->entity->parent, info);
+		info->entity_id = dmxdev->dvbdev->entity->id;
+		break;
+	}
+#endif
 	case DMX_START:
 		if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
 			mutex_unlock(&dmxdev->mutex);
@@ -1152,12 +1163,23 @@ static int dvb_dvr_do_ioctl(struct file *file,
 	struct dvb_device *dvbdev = file->private_data;
 	struct dmxdev *dmxdev = dvbdev->priv;
 	unsigned long arg = (unsigned long)parg;
-	int ret;
+	int ret = 0;
 
 	if (mutex_lock_interruptible(&dmxdev->mutex))
 		return -ERESTARTSYS;
 
 	switch (cmd) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	case MEDIA_IOC_DEVICE_INFO: {
+		struct media_device_info *info = parg;
+
+		if (dvbdev->entity->parent == NULL)
+			return -ENOTTY;
+		media_device_fill_info(dvbdev->entity->parent, info);
+		info->entity_id = dvbdev->entity->id;
+		break;
+	}
+#endif
 	case DMX_SET_BUFFER_SIZE:
 		ret = dvb_dvr_set_buffer_size(dmxdev, arg);
 		break;
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 7293775..eca19f5 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1198,6 +1198,17 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 		return -ERESTARTSYS;
 
 	switch (cmd) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	case MEDIA_IOC_DEVICE_INFO: {
+		struct media_device_info *info = parg;
+
+		if (dvbdev->entity->parent == NULL)
+			return -ENOTTY;
+		media_device_fill_info(dvbdev->entity->parent, info);
+		info->entity_id = dvbdev->entity->id;
+		break;
+	}
+#endif
 	case CA_RESET:
 		for (slot = 0; slot < ca->slot_count; slot++) {
 			mutex_lock(&ca->slot_info[slot].slot_lock);
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index a694fb1..1c0c889 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1322,6 +1322,17 @@ static int dvb_net_do_ioctl(struct file *file,
 		return -ERESTARTSYS;
 
 	switch (cmd) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	case MEDIA_IOC_DEVICE_INFO: {
+		struct media_device_info *info = parg;
+
+		if (dvbdev->entity->parent == NULL)
+			return -ENOTTY;
+		media_device_fill_info(dvbdev->entity->parent, info);
+		info->entity_id = dvbdev->entity->id;
+		break;
+	}
+#endif
 	case NET_ADD_IF:
 	{
 		struct dvb_net_if *dvbnetif = parg;
-- 
2.1.4


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

* [RFCv2 PATCH 8/8] DocBook/media: document the new media_device_info fields.
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (6 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 7/8] dvb: " Hans Verkuil
@ 2015-05-06  6:57 ` Hans Verkuil
  2015-05-06  9:30 ` [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Mauro Carvalho Chehab
  2015-07-02 12:29 ` Laurent Pinchart
  9 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06  6:57 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, mchehab, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Document major, minor and entity_id, and that MEDIA_IOC_DEVICE_INFO
can be called for other media devices as well, besides just the
media controller.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 .../DocBook/media/v4l/media-ioc-device-info.xml    | 35 ++++++++++++++++++----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/media-ioc-device-info.xml b/Documentation/DocBook/media/v4l/media-ioc-device-info.xml
index 2ce5214..9506cf6 100644
--- a/Documentation/DocBook/media/v4l/media-ioc-device-info.xml
+++ b/Documentation/DocBook/media/v4l/media-ioc-device-info.xml
@@ -49,11 +49,20 @@
   <refsect1>
     <title>Description</title>
 
-    <para>All media devices must support the <constant>MEDIA_IOC_DEVICE_INFO</constant>
-    ioctl. To query device information, applications call the ioctl with a
-    pointer to a &media-device-info;. The driver fills the structure and returns
-    the information to the application.
-    The ioctl never fails.</para>
+    <para>All media devices, both the media controller device itself and any
+    device node used to access a media entity, must support the
+    <constant>MEDIA_IOC_DEVICE_INFO</constant> ioctl. To query device information,
+    applications call the ioctl with a pointer to a &media-device-info;. The driver
+    fills the structure and returns the information to the application.
+    The ioctl never fails, unless it is not a media device, in which case an error
+    is returned, most likely the &ENOTTY;.</para>
+
+    <para>Besides getting the device information from the media controller device
+    itself, applications can use this ioctl as well to check if a device node is part
+    of a media controller. If the ioctl succeeds, then the <structfield>major</structfield>
+    and <structfield>minor</structfield> fields will give you the major and minor
+    numbers of the media controller device and the <structfield>entity_id</structfield>
+    field gives you the entity ID of the media device.</para>
 
     <table pgwide="1" frame="none" id="media-device-info">
       <title>struct <structname>media_device_info</structname></title>
@@ -110,6 +119,22 @@
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
+	    <entry><structfield>major</structfield></entry>
+	    <entry>The major number of the media device node.</entry>
+	  </row>
+	  <row>
+	    <entry>__u32</entry>
+	    <entry><structfield>minor</structfield></entry>
+	    <entry>The minor number of the media device node.</entry>
+	  </row>
+	  <row>
+	    <entry>__u32</entry>
+	    <entry><structfield>entity_id</structfield></entry>
+	    <entry>The entity ID if this ioctl was called for a device that is
+	    an entity. The media controller will set this to 0.</entry>
+	  </row>
+	  <row>
+	    <entry>__u32</entry>
 	    <entry><structfield>reserved</structfield>[31]</entry>
 	    <entry>Reserved for future extensions. Drivers and applications must
 	    set this array to zero.</entry>
-- 
2.1.4


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

* Re: [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (7 preceding siblings ...)
  2015-05-06  6:57 ` [RFCv2 PATCH 8/8] DocBook/media: document the new media_device_info fields Hans Verkuil
@ 2015-05-06  9:30 ` Mauro Carvalho Chehab
  2015-05-06 10:50   ` Hans Verkuil
  2015-07-02 12:29 ` Laurent Pinchart
  9 siblings, 1 reply; 13+ messages in thread
From: Mauro Carvalho Chehab @ 2015-05-06  9:30 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, laurent.pinchart

Em Wed, 06 May 2015 08:57:15 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This patch series adds the VIDIOC_SUBDEV_QUERYCAP ioctl for v4l-subdev devices
> as discussed during the ELC in San Jose and as discussed here:
> 
> http://www.spinics.net/lists/linux-media/msg88009.html
> 
> It also add support for MEDIA_IOC_DEVICE_INFO to any media entities so
> applications can use that to find the media controller and detailed information
> about the entity.

Why "IOC" at MEDIA_IOC_DEVICE_INFO?

Also, I'm not sure yet how do you think apps should use this information,
especially when multiple media controller entities are present.

IMHO, the media controller instance number should be added at the
struct. Also, IMO, the docbook would need to give an usage example
for this ioctl.
> 
> This is the second RFC patch series. The main changes are:
> 
> - Drop the entity ID from the querycap ioctls

I'm not seeing this happening. Also, removing something at existing
ioctls may break userspace.

> - Instead have every entity device implement MEDIA_IOC_DEVICE_INFO
> - Add major, minor and entity_id fields to struct media_device_info:
>   this allows applications to find the MC device and to determine
>   the entity ID of the device for which they called the ioctl. It
>   is 0 for the MC (entity IDs are always > 0 for entities).
> 
> This is IMHO simple, consistent, and it will work for any media entity.
> 
> Regards,
> 
> 	Hans
> 
> PS: I have not tested the DVB changes yet. I hope I got those right.
> 
> Hans Verkuil (8):
>   v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
>   DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
>   videodev2.h: add V4L2_CAP_ENTITY to querycap
>   media: add major/minor/entity_id to struct media_device_info
>   v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
>   v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
>   dvb: add MEDIA_IOC_DEVICE_INFO
>   DocBook/media: document the new media_device_info fields.
> 
>  .../DocBook/media/v4l/media-ioc-device-info.xml    |  35 +++++-
>  Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
>  .../DocBook/media/v4l/vidioc-querycap.xml          |   6 +
>  .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 +++++++++++++++++++++
>  drivers/media/dvb-core/dmxdev.c                    |  24 +++-
>  drivers/media/dvb-core/dvb_ca_en50221.c            |  11 ++
>  drivers/media/dvb-core/dvb_net.c                   |  11 ++
>  drivers/media/media-device.c                       |  29 +++--
>  drivers/media/media-devnode.c                      |   5 +-
>  drivers/media/v4l2-core/v4l2-ioctl.c               |  43 ++++++-
>  drivers/media/v4l2-core/v4l2-subdev.c              |  26 +++++
>  include/media/media-device.h                       |   3 +
>  include/media/media-devnode.h                      |   1 +
>  include/uapi/linux/media.h                         |   5 +-
>  include/uapi/linux/v4l2-subdev.h                   |  10 ++
>  include/uapi/linux/videodev2.h                     |   1 +
>  16 files changed, 316 insertions(+), 20 deletions(-)
>  create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
> 

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

* Re: [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO
  2015-05-06  9:30 ` [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Mauro Carvalho Chehab
@ 2015-05-06 10:50   ` Hans Verkuil
  2015-05-06 11:27     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Verkuil @ 2015-05-06 10:50 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, laurent.pinchart

On 05/06/15 11:30, Mauro Carvalho Chehab wrote:
> Em Wed, 06 May 2015 08:57:15 +0200
> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> 
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> This patch series adds the VIDIOC_SUBDEV_QUERYCAP ioctl for v4l-subdev devices
>> as discussed during the ELC in San Jose and as discussed here:
>>
>> http://www.spinics.net/lists/linux-media/msg88009.html
>>
>> It also add support for MEDIA_IOC_DEVICE_INFO to any media entities so
>> applications can use that to find the media controller and detailed information
>> about the entity.
> 
> Why "IOC" at MEDIA_IOC_DEVICE_INFO?

Probably based on 'VIDIOC'. I can't help that that's the ioctl name.
The MEDIA_IOC_DEVICE_INFO ioctl already exists as part of the media
API. So I am not making a new ioctl here.

> 
> Also, I'm not sure yet how do you think apps should use this information,
> especially when multiple media controller entities are present.
> 
> IMHO, the media controller instance number should be added at the
> struct. Also, IMO, the docbook would need to give an usage example
> for this ioctl.

The major+minor identifies the media controller exactly. An instance
number doesn't add anything, or am I missing something?

And yes, a usage example will be needed, but this is still an RFC.

>>
>> This is the second RFC patch series. The main changes are:
>>
>> - Drop the entity ID from the querycap ioctls
> 
> I'm not seeing this happening. Also, removing something at existing
> ioctls may break userspace.

Changes since the *previous RFC patch series*. The existing code doesn't
have an entity_id.

Regards,

	Hans

>> - Instead have every entity device implement MEDIA_IOC_DEVICE_INFO
>> - Add major, minor and entity_id fields to struct media_device_info:
>>   this allows applications to find the MC device and to determine
>>   the entity ID of the device for which they called the ioctl. It
>>   is 0 for the MC (entity IDs are always > 0 for entities).
>>
>> This is IMHO simple, consistent, and it will work for any media entity.
>>
>> Regards,
>>
>> 	Hans
>>
>> PS: I have not tested the DVB changes yet. I hope I got those right.
>>
>> Hans Verkuil (8):
>>   v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
>>   DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
>>   videodev2.h: add V4L2_CAP_ENTITY to querycap
>>   media: add major/minor/entity_id to struct media_device_info
>>   v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
>>   v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
>>   dvb: add MEDIA_IOC_DEVICE_INFO
>>   DocBook/media: document the new media_device_info fields.
>>
>>  .../DocBook/media/v4l/media-ioc-device-info.xml    |  35 +++++-
>>  Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
>>  .../DocBook/media/v4l/vidioc-querycap.xml          |   6 +
>>  .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 +++++++++++++++++++++
>>  drivers/media/dvb-core/dmxdev.c                    |  24 +++-
>>  drivers/media/dvb-core/dvb_ca_en50221.c            |  11 ++
>>  drivers/media/dvb-core/dvb_net.c                   |  11 ++
>>  drivers/media/media-device.c                       |  29 +++--
>>  drivers/media/media-devnode.c                      |   5 +-
>>  drivers/media/v4l2-core/v4l2-ioctl.c               |  43 ++++++-
>>  drivers/media/v4l2-core/v4l2-subdev.c              |  26 +++++
>>  include/media/media-device.h                       |   3 +
>>  include/media/media-devnode.h                      |   1 +
>>  include/uapi/linux/media.h                         |   5 +-
>>  include/uapi/linux/v4l2-subdev.h                   |  10 ++
>>  include/uapi/linux/videodev2.h                     |   1 +
>>  16 files changed, 316 insertions(+), 20 deletions(-)
>>  create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO
  2015-05-06 10:50   ` Hans Verkuil
@ 2015-05-06 11:27     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 13+ messages in thread
From: Mauro Carvalho Chehab @ 2015-05-06 11:27 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, laurent.pinchart

Em Wed, 06 May 2015 12:50:31 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 05/06/15 11:30, Mauro Carvalho Chehab wrote:
> > Em Wed, 06 May 2015 08:57:15 +0200
> > Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> > 
> >> From: Hans Verkuil <hans.verkuil@cisco.com>
> >>
> >> This patch series adds the VIDIOC_SUBDEV_QUERYCAP ioctl for v4l-subdev devices
> >> as discussed during the ELC in San Jose and as discussed here:
> >>
> >> http://www.spinics.net/lists/linux-media/msg88009.html
> >>
> >> It also add support for MEDIA_IOC_DEVICE_INFO to any media entities so
> >> applications can use that to find the media controller and detailed information
> >> about the entity.
> > 
> > Why "IOC" at MEDIA_IOC_DEVICE_INFO?
> 
> Probably based on 'VIDIOC'. I can't help that that's the ioctl name.
> The MEDIA_IOC_DEVICE_INFO ioctl already exists as part of the media
> API. So I am not making a new ioctl here.

Ah, ok.

> > 
> > Also, I'm not sure yet how do you think apps should use this information,
> > especially when multiple media controller entities are present.
> > 
> > IMHO, the media controller instance number should be added at the
> > struct. Also, IMO, the docbook would need to give an usage example
> > for this ioctl.
> 
> The major+minor identifies the media controller exactly. An instance
> number doesn't add anything, or am I missing something?

Ah, so the major+minor are for the media controller device node, and
not for the v4l2 devnode.

OK.

> 
> And yes, a usage example will be needed, but this is still an RFC.
> 
> >>
> >> This is the second RFC patch series. The main changes are:
> >>
> >> - Drop the entity ID from the querycap ioctls
> > 
> > I'm not seeing this happening. Also, removing something at existing
> > ioctls may break userspace.
> 
> Changes since the *previous RFC patch series*. The existing code doesn't
> have an entity_id.

ah, ok.

I guess I should avoid avoid answering emails very early at morning
without taking first a good cup of coffee ;)
> 
> Regards,
> 
> 	Hans
> 
> >> - Instead have every entity device implement MEDIA_IOC_DEVICE_INFO
> >> - Add major, minor and entity_id fields to struct media_device_info:
> >>   this allows applications to find the MC device and to determine
> >>   the entity ID of the device for which they called the ioctl. It
> >>   is 0 for the MC (entity IDs are always > 0 for entities).
> >>
> >> This is IMHO simple, consistent, and it will work for any media entity.
> >>
> >> Regards,
> >>
> >> 	Hans
> >>
> >> PS: I have not tested the DVB changes yet. I hope I got those right.
> >>
> >> Hans Verkuil (8):
> >>   v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
> >>   DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
> >>   videodev2.h: add V4L2_CAP_ENTITY to querycap
> >>   media: add major/minor/entity_id to struct media_device_info
> >>   v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
> >>   v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
> >>   dvb: add MEDIA_IOC_DEVICE_INFO
> >>   DocBook/media: document the new media_device_info fields.
> >>
> >>  .../DocBook/media/v4l/media-ioc-device-info.xml    |  35 +++++-
> >>  Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
> >>  .../DocBook/media/v4l/vidioc-querycap.xml          |   6 +
> >>  .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 +++++++++++++++++++++
> >>  drivers/media/dvb-core/dmxdev.c                    |  24 +++-
> >>  drivers/media/dvb-core/dvb_ca_en50221.c            |  11 ++
> >>  drivers/media/dvb-core/dvb_net.c                   |  11 ++
> >>  drivers/media/media-device.c                       |  29 +++--
> >>  drivers/media/media-devnode.c                      |   5 +-
> >>  drivers/media/v4l2-core/v4l2-ioctl.c               |  43 ++++++-
> >>  drivers/media/v4l2-core/v4l2-subdev.c              |  26 +++++
> >>  include/media/media-device.h                       |   3 +
> >>  include/media/media-devnode.h                      |   1 +
> >>  include/uapi/linux/media.h                         |   5 +-
> >>  include/uapi/linux/v4l2-subdev.h                   |  10 ++
> >>  include/uapi/linux/videodev2.h                     |   1 +
> >>  16 files changed, 316 insertions(+), 20 deletions(-)
> >>  create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
> >>
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-media" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 

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

* Re: [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO
  2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
                   ` (8 preceding siblings ...)
  2015-05-06  9:30 ` [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Mauro Carvalho Chehab
@ 2015-07-02 12:29 ` Laurent Pinchart
  9 siblings, 0 replies; 13+ messages in thread
From: Laurent Pinchart @ 2015-07-02 12:29 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, mchehab

Hi Hans,

Thank you for the patches.

On Wednesday 06 May 2015 08:57:15 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This patch series adds the VIDIOC_SUBDEV_QUERYCAP ioctl for v4l-subdev
> devices as discussed during the ELC in San Jose and as discussed here:
> 
> http://www.spinics.net/lists/linux-media/msg88009.html
> 
> It also add support for MEDIA_IOC_DEVICE_INFO to any media entities so
> applications can use that to find the media controller and detailed
> information about the entity.
> 
> This is the second RFC patch series. The main changes are:
> 
> - Drop the entity ID from the querycap ioctls
> - Instead have every entity device implement MEDIA_IOC_DEVICE_INFO
> - Add major, minor and entity_id fields to struct media_device_info:
>   this allows applications to find the MC device and to determine
>   the entity ID of the device for which they called the ioctl. It
>   is 0 for the MC (entity IDs are always > 0 for entities).
> 
> This is IMHO simple, consistent, and it will work for any media entity.

As discussed over IRC, I'd prefer adding the entity ID back to the querycap 
ioctl, and skipping the MEDIA_IOC_DEVICE_INFO changes for now. The reason is 
that our only current use case is v4l2-compliance which, albeit a real use 
case, doesn't seem enough to me to design two new ioctls.

I'm fine with a VIDIOC_SUBDEV_QUERYCAP ioctl as it mimics the V4L2 video 
device nodes API and is generally useful, and I believe it should be enough to 
fulfill v4l2-compliance's use cases if we add the entity ID.

> PS: I have not tested the DVB changes yet. I hope I got those right.
> 
> Hans Verkuil (8):
>   v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
>   DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
>   videodev2.h: add V4L2_CAP_ENTITY to querycap
>   media: add major/minor/entity_id to struct media_device_info
>   v4l2-subdev: add MEDIA_IOC_DEVICE_INFO
>   v4l2-ioctl: add MEDIA_IOC_DEVICE_INFO
>   dvb: add MEDIA_IOC_DEVICE_INFO
>   DocBook/media: document the new media_device_info fields.
> 
>  .../DocBook/media/v4l/media-ioc-device-info.xml    |  35 +++++-
>  Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
>  .../DocBook/media/v4l/vidioc-querycap.xml          |   6 +
>  .../DocBook/media/v4l/vidioc-subdev-querycap.xml   | 125 ++++++++++++++++++
>  drivers/media/dvb-core/dmxdev.c                    |  24 +++-
>  drivers/media/dvb-core/dvb_ca_en50221.c            |  11 ++
>  drivers/media/dvb-core/dvb_net.c                   |  11 ++
>  drivers/media/media-device.c                       |  29 +++--
>  drivers/media/media-devnode.c                      |   5 +-
>  drivers/media/v4l2-core/v4l2-ioctl.c               |  43 ++++++-
>  drivers/media/v4l2-core/v4l2-subdev.c              |  26 +++++
>  include/media/media-device.h                       |   3 +
>  include/media/media-devnode.h                      |   1 +
>  include/uapi/linux/media.h                         |   5 +-
>  include/uapi/linux/v4l2-subdev.h                   |  10 ++
>  include/uapi/linux/videodev2.h                     |   1 +
>  16 files changed, 316 insertions(+), 20 deletions(-)
>  create mode 100644
> Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml

-- 
Regards,

Laurent Pinchart


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

end of thread, other threads:[~2015-07-02 12:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06  6:57 [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 1/8] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 2/8] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 3/8] videodev2.h: add V4L2_CAP_ENTITY to querycap Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 4/8] media: add major/minor/entity_id to struct media_device_info Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 5/8] v4l2-subdev: add MEDIA_IOC_DEVICE_INFO Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 6/8] v4l2-ioctl: " Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 7/8] dvb: " Hans Verkuil
2015-05-06  6:57 ` [RFCv2 PATCH 8/8] DocBook/media: document the new media_device_info fields Hans Verkuil
2015-05-06  9:30 ` [RFCv2 PATCH 0/8] Add VIDIOC_SUBDEV_QUERYCAP and use MEDIA_IOC_DEVICE_INFO Mauro Carvalho Chehab
2015-05-06 10:50   ` Hans Verkuil
2015-05-06 11:27     ` Mauro Carvalho Chehab
2015-07-02 12:29 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).