* [RFCv3 PATCH 0/2] Add VIDIOC_SUBDEV_QUERYCAP
@ 2015-07-02 13:27 Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 1/2] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 2/2] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
0 siblings, 2 replies; 3+ messages in thread
From: Hans Verkuil @ 2015-07-02 13:27 UTC (permalink / raw)
To: linux-media
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
This patch series returns to the v1 patch series, but it drops the pads field
and the VIDIOC_QUERYCAP changes.
This should hopefully make this a minimal uncontroversial implementation that
I can finally start using in the v4l2-compliance utility.
Ideally I'd like to have a link back to the media controller, which is what
the v2 patch series was all about, but not everyone agrees so I will probably
require that when v4l2-compliance is called for a v4l-subdev node you also
have to provide the MC device node.
Regards,
Hans
Hans Verkuil (2):
v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
Documentation/DocBook/media/v4l/v4l2.xml | 1 +
.../DocBook/media/v4l/vidioc-subdev-querycap.xml | 133 +++++++++++++++++++++
drivers/media/v4l2-core/v4l2-subdev.c | 17 +++
include/uapi/linux/v4l2-subdev.h | 18 +++
4 files changed, 169 insertions(+)
create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
--
2.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RFCv3 PATCH 1/2] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
2015-07-02 13:27 [RFCv3 PATCH 0/2] Add VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
@ 2015-07-02 13:27 ` Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 2/2] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
1 sibling, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2015-07-02 13:27 UTC (permalink / raw)
To: linux-media; +Cc: 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.
SUBDEV_QUERYCAP currently returns the version, device_caps and the
entity_id of the subdevice (if there is any).
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 17 +++++++++++++++++
include/uapi/linux/v4l2-subdev.h | 18 ++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..160a91a 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,22 @@ 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;
+ cap->entity_id = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ if (sd->entity.parent) {
+ cap->device_caps = V4L2_SUBDEV_CAP_ENTITY;
+ cap->entity_id = sd->entity.id;
+ }
+#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..d92ffbf 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -154,9 +154,27 @@ struct v4l2_subdev_selection {
__u32 reserved[8];
};
+/**
+ * struct v4l2_subdev_capability - subdev capabilities
+ * @version: the kernel version
+ * @device_caps: the subdev capabilities
+ * @entity_id: the entity ID if V4L2_SUBDEV_CAP_ENTITY is set
+ * @reserved: for future use, set to zero for now
+ */
+struct v4l2_subdev_capability {
+ __u32 version;
+ __u32 device_caps;
+ __u32 entity_id;
+ __u32 reserved[29];
+};
+
+/* 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] 3+ messages in thread
* [RFCv3 PATCH 2/2] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP
2015-07-02 13:27 [RFCv3 PATCH 0/2] Add VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 1/2] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
@ 2015-07-02 13:27 ` Hans Verkuil
1 sibling, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2015-07-02 13:27 UTC (permalink / raw)
To: linux-media; +Cc: 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 | 133 +++++++++++++++++++++
2 files changed, 134 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..2c091d0
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/vidioc-subdev-querycap.xml
@@ -0,0 +1,133 @@
+<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
+&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) << 16) + ((b) << 8) + (c))
+
+__u32 version = KERNEL_VERSION(0, 8, 1);
+
+printf ("Version: %u.%u.%u\n",
+ (version >> 16) & 0xFF,
+ (version >> 8) & 0xFF,
+ version & 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>entity_id</structfield></entry>
+ <entry>The media controller entity ID of the sub-device. This is only valid if
+ the <constant>V4L2_SUBDEV_CAP_ENTITY</constant> capability is set.
+ </entry>
+ </row>
+ <row>
+ <entry>__u32</entry>
+ <entry><structfield>reserved</structfield>[29]</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 and
+ the <structfield>entity_id</structfield> field of &v4l2-subdev-capability;
+ is valid.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </refsect1>
+
+ <refsect1>
+ &return-value;
+ </refsect1>
+</refentry>
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-02 13:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-02 13:27 [RFCv3 PATCH 0/2] Add VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 1/2] v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl Hans Verkuil
2015-07-02 13:27 ` [RFCv3 PATCH 2/2] DocBook/media: document VIDIOC_SUBDEV_QUERYCAP Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox