[vlc-commits] v4l2: use device node capabilities rather than whole device's

Rémi Denis-Courmont git at videolan.org
Wed Apr 4 17:51:31 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr  4 18:44:06 2012 +0300| [b80cbc8a31c569ed1851ce00e21e02ee988dfe79] | committer: Rémi Denis-Courmont

v4l2: use device node capabilities rather than whole device's

"capabilities" counter-intuitively specifies the overall capabilities of
all device nodes provided by the given instance of the device driver.
"device_caps" specifies the capabilities of the opened device node,
if the V4L2_CAP_DEVICE_CAPS bit is set in "capabilities" (phew!).
Those two sets of capabilities are different if the hardware has
multiple functions, e.g. both video and VBI capture.

VLC cares about the fact that the specific device node supports video
capture or not, so lets use "device_caps" when available. Unfortatunely,
this requires kernel version 3.4. In practice, this would only cause an
actual failure if V4L2_CAP_STREAMING is set even though the current node
does not support streaming I/O, I think.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b80cbc8a31c569ed1851ce00e21e02ee988dfe79
---

 modules/access/v4l2/demux.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index ab76680..d494915 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -264,27 +264,31 @@ static int InitVideo (demux_t *demux, int fd)
     msg_Dbg (demux, "device %s using driver %s (version %u.%u.%u) on %s",
             cap.card, cap.driver, (cap.version >> 16) & 0xFF,
             (cap.version >> 8) & 0xFF, cap.version & 0xFF, cap.bus_info);
-    msg_Dbg (demux, "the device has the capabilities: 0x%08X",
-             cap.capabilities );
-    msg_Dbg (demux, " (%c) Video Capture, (%c) Audio, (%c) Tuner, (%c) Radio",
-             (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE ? 'X' : ' '),
-             (cap.capabilities & V4L2_CAP_AUDIO ? 'X' : ' '),
-             (cap.capabilities & V4L2_CAP_TUNER ? 'X' : ' '),
-             (cap.capabilities & V4L2_CAP_RADIO ? 'X' : ' '));
-    msg_Dbg (demux, " (%c) Read/Write, (%c) Streaming, (%c) Asynchronous",
-             (cap.capabilities & V4L2_CAP_READWRITE ? 'X' : ' '),
-             (cap.capabilities & V4L2_CAP_STREAMING ? 'X' : ' '),
-             (cap.capabilities & V4L2_CAP_ASYNCIO ? 'X' : ' '));
-
-    if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
+
+    uint32_t caps;
+#ifdef V4L2_CAP_DEVICE_CAPS
+    if (cap.capabilities & V4L2_CAP_DEVICE_CAPS)
+    {
+        msg_Dbg (demux, " with capabilities 0x%08"PRIX32" "
+                 "(overall 0x%08"PRIX32")", cap.device_caps, cap.capabilities);
+        caps = cap.device_caps;
+    }
+    else
+#endif
+    {
+        msg_Dbg (demux, " with unknown capabilities  "
+                 "(overall 0x%08"PRIX32")", cap.capabilities);
+        caps = cap.capabilities;
+    }
+    if (!(caps & V4L2_CAP_VIDEO_CAPTURE))
     {
         msg_Err (demux, "not a video capture device");
         return -1;
     }
 
-    if (cap.capabilities & V4L2_CAP_STREAMING)
+    if (caps & V4L2_CAP_STREAMING)
         sys->io = IO_METHOD_MMAP;
-    else if (cap.capabilities & V4L2_CAP_READWRITE)
+    else if (caps & V4L2_CAP_READWRITE)
         sys->io = IO_METHOD_READ;
     else
     {



More information about the vlc-commits mailing list