The patch number 8218 was added via Thierry MERLE <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Hans de Goede  <[EMAIL PROTECTED]>
v4l2-library: libv4l: update mercurial tree to latest 0.3.1 release


This patch syncs (updates) the libv4l in mercurial with (to) the latest 0.3.1
release.
- Only serialize V4L2_BUF_TYPE_VIDEO_CAPTURE type ioctls
- Do not return an uninitialized variable as result code for GPICT
(fixes vlc, but see below)
- Add an apps-patches directory which includes:
 * vlc-0.8.6-libv4l1.patch, modify vlc's v4l1 plugin to directly call into
   libv4l1, in the end we want all apps todo this as its better then
   LD_PRELOAD tricks, but for vlc this is needed as vlc's plugin system
   causes LD_PRELOAD to not work on symbols in the plugins
 * camorama-0.19-fixes.patch, small bugfixes to camorama's v4l1 support,
   this patch only fixes _real_ bugs in camorama and does not change it to
   work with v4l1compat. Although it does work better with these bugs fixed
   :) With this patch and LD_PRELOAD=<path>/v4l1compat.so it works
   flawless.

Signed-off-by: Hans de Goede <[EMAIL PROTECTED]>
Signed-off-by: Thierry MERLE <[EMAIL PROTECTED]>


---

 v4l2-apps/lib/libv4l/ChangeLog         |   17 ++
 v4l2-apps/lib/libv4l/libv4l1/libv4l1.c |    2 
 v4l2-apps/lib/libv4l/libv4l2/libv4l2.c |  149 +++++++++----------------
 3 files changed, 73 insertions(+), 95 deletions(-)

diff -r 7ef1f3daddc6 -r 40ccde267263 v4l2-apps/lib/libv4l/ChangeLog
--- a/v4l2-apps/lib/libv4l/ChangeLog    Thu Jul 03 20:34:29 2008 +0200
+++ b/v4l2-apps/lib/libv4l/ChangeLog    Thu Jul 03 20:41:07 2008 +0200
@@ -1,3 +1,20 @@ libv4l-0.3
+libv4l-0.3.1
+------------
+* Only serialize V4L2_BUF_TYPE_VIDEO_CAPTURE type ioctls
+* Do not return an uninitialized variable as result code for GPICT
+  (fixes vlc, but see below)
+* Add an apps-patches directory which includes:
+  * vlc-0.8.6-libv4l1.patch, modify vlc's v4l1 plugin to directly call into
+    libv4l1, in the end we want all apps todo this as its better then
+    LD_PRELOAD tricks, but for vlc this is needed as vlc's plugin system
+    causes LD_PRELOAD to not work on symbols in the plugins
+  * camorama-0.19-fixes.patch, small bugfixes to camorama's v4l1 support,
+    this patch only fixes _real_ bugs in camorama and does not change it to
+    work with v4l1compat. Although it does work better with these bugs fixed
+    :) With this patch and LD_PRELOAD=<path>/v4l1compat.so it works
+    flawless.
+
+
 libv4l-0.3
 ----------
 * add extern "C" magic to public header files for c++ usage (Gregor Jasny)
diff -r 7ef1f3daddc6 -r 40ccde267263 v4l2-apps/lib/libv4l/libv4l1/libv4l1.c
--- a/v4l2-apps/lib/libv4l/libv4l1/libv4l1.c    Thu Jul 03 20:34:29 2008 +0200
+++ b/v4l2-apps/lib/libv4l/libv4l1/libv4l1.c    Thu Jul 03 20:41:07 2008 +0200
@@ -532,6 +532,8 @@ int v4l1_ioctl (int fd, unsigned long in
                                           V4L2_CID_WHITENESS);
        pic->brightness = v4l2_get_control(devices[index].fd,
                                           V4L2_CID_BRIGHTNESS);
+
+       result = 0;
       }
       break;
 
diff -r 7ef1f3daddc6 -r 40ccde267263 v4l2-apps/lib/libv4l/libv4l2/libv4l2.c
--- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c    Thu Jul 03 20:34:29 2008 +0200
+++ b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c    Thu Jul 03 20:41:07 2008 +0200
@@ -527,31 +527,13 @@ int v4l2_dup(int fd)
   return fd;
 }
 
-static int v4l2_buf_ioctl_pre_check(int index, unsigned long int request,
-  struct v4l2_buffer *buf, int *result)
-{
-  if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-    *result = syscall(SYS_ioctl, devices[index].fd, request, buf);
-    return 1;
-  }
-
-  /* IMPROVEME (maybe?) add support for userptr's? */
-  if (devices[index].io != v4l2_io_mmap ||
-      buf->memory != V4L2_MEMORY_MMAP ||
-      buf->index  >= devices[index].no_frames) {
-    errno = EINVAL;
-    *result = -1;
-    return 1;
-  }
-
-  return 0;
-}
 
 int v4l2_ioctl (int fd, unsigned long int request, ...)
 {
   void *arg;
   va_list ap;
-  int result, converting, index, saved_err, stream_locked = 0;
+  int result, converting, index, saved_err;
+  int is_capture_request = 0, stream_needs_locking = 0;
 
   va_start (ap, request);
   arg = va_arg (ap, void *);
@@ -560,19 +542,52 @@ int v4l2_ioctl (int fd, unsigned long in
   if ((index = v4l2_get_index(fd)) == -1)
     return syscall(SYS_ioctl, fd, request, arg);
 
-  /* do we need to take the stream lock for this ioctl? */
+  /* Is this a capture request and do we need to take the stream lock? */
   switch (request) {
+    case VIDIOC_ENUM_FMT:
+      if (((struct v4l2_fmtdesc *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+       is_capture_request = 1;
+      break;
+    case VIDIOC_TRY_FMT:
+      if (((struct v4l2_format *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+       is_capture_request = 1;
+      break;
     case VIDIOC_S_FMT:
     case VIDIOC_G_FMT:
+      if (((struct v4l2_format *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+       is_capture_request = 1;
+       stream_needs_locking = 1;
+      }
+      break;
     case VIDIOC_REQBUFS:
+      if (((struct v4l2_requestbuffers *)arg)->type ==
+         V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+       is_capture_request = 1;
+       stream_needs_locking = 1;
+      }
+      break;
     case VIDIOC_QUERYBUF:
     case VIDIOC_QBUF:
     case VIDIOC_DQBUF:
+      if (((struct v4l2_buffer *)arg)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+       is_capture_request = 1;
+       stream_needs_locking = 1;
+      }
+      break;
     case VIDIOC_STREAMON:
     case VIDIOC_STREAMOFF:
-      pthread_mutex_lock(&devices[index].stream_lock);
-      stream_locked = 1;
-  }
+      if (*((enum v4l2_buf_type *)arg) == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+       is_capture_request = 1;
+       stream_needs_locking = 1;
+      }
+  }
+
+  if (!is_capture_request)
+    return syscall(SYS_ioctl, fd, request, arg);
+
+
+  if (stream_needs_locking)
+    pthread_mutex_lock(&devices[index].stream_lock);
 
   converting = devices[index].src_fmt.fmt.pix.pixelformat !=
               devices[index].dest_fmt.fmt.pix.pixelformat;
@@ -580,40 +595,16 @@ int v4l2_ioctl (int fd, unsigned long in
 
   switch (request) {
     case VIDIOC_ENUM_FMT:
-      {
-       struct v4l2_fmtdesc *fmtdesc = arg;
-
-       if (fmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
-           !(devices[index].flags & V4L2_ENABLE_ENUM_FMT_EMULATION))
-         result = syscall(SYS_ioctl, devices[index].fd, request, arg);
-       else
-         result = v4lconvert_enum_fmt(devices[index].convert, fmtdesc);
-      }
+      result = v4lconvert_enum_fmt(devices[index].convert, arg);
       break;
 
     case VIDIOC_TRY_FMT:
-      {
-       struct v4l2_format *fmt = arg;
-
-       if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
-           (devices[index].flags & V4L2_DISABLE_CONVERSION)) {
-         result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_TRY_FMT, fmt);
-         break;
-       }
-
-       result = v4lconvert_try_format(devices[index].convert, fmt, NULL);
-      }
+      result = v4lconvert_try_format(devices[index].convert, arg, NULL);
       break;
 
     case VIDIOC_S_FMT:
       {
        struct v4l2_format src_fmt, *dest_fmt = arg;
-
-       if (dest_fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-         result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_S_FMT,
-                          dest_fmt);
-         break;
-       }
 
        if (!memcmp(&devices[index].dest_fmt, dest_fmt, sizeof(*dest_fmt))) {
          result = 0;
@@ -658,7 +649,7 @@ int v4l2_ioctl (int fd, unsigned long in
            if (v4l2_activate_read_stream(index))
              V4L2_LOG_ERR(
                "reactivating stream after deactivate failure (AAIIEEEE)\n");
-           return result;
+           break;
          }
        }
 
@@ -681,11 +672,6 @@ int v4l2_ioctl (int fd, unsigned long in
       {
        struct v4l2_format* fmt = arg;
 
-       if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-         result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_G_FMT, fmt);
-         break;
-       }
-
        *fmt = devices[index].dest_fmt;
        result = 0;
       }
@@ -694,11 +680,6 @@ int v4l2_ioctl (int fd, unsigned long in
     case VIDIOC_REQBUFS:
       {
        struct v4l2_requestbuffers *req = arg;
-
-       if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-         result = syscall(SYS_ioctl, devices[index].fd, request, arg);
-         return 1;
-       }
 
        /* Don't allow mixing read / mmap io, either we control the buffers
           (read based io), or the app does */
@@ -753,9 +734,6 @@ int v4l2_ioctl (int fd, unsigned long in
       {
        struct v4l2_buffer *buf = arg;
 
-       if (v4l2_buf_ioctl_pre_check(index, request, buf, &result))
-         break;
-
        /* Do a real query even when converting to let the driver fill in
           things like buf->field */
        result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QUERYBUF, buf);
@@ -768,22 +746,12 @@ int v4l2_ioctl (int fd, unsigned long in
       break;
 
     case VIDIOC_QBUF:
-      {
-       struct v4l2_buffer *buf = arg;
-
-       if (v4l2_buf_ioctl_pre_check(index, request, buf, &result))
-         break;
-
-       result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QBUF, buf);
-      }
+      result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_QBUF, arg);
       break;
 
     case VIDIOC_DQBUF:
       {
        struct v4l2_buffer *buf = arg;
-
-       if (v4l2_buf_ioctl_pre_check(index, request, buf, &result))
-         break;
 
        result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_DQBUF, buf);
        if (result || !converting)
@@ -832,32 +800,23 @@ int v4l2_ioctl (int fd, unsigned long in
 
     case VIDIOC_STREAMON:
     case VIDIOC_STREAMOFF:
-      {
-       enum v4l2_buf_type *type = arg;
-
-       if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-         result = syscall(SYS_ioctl, devices[index].fd, request, type);
-         break;
-       }
-
-       if (devices[index].io != v4l2_io_mmap) {
-         errno = EINVAL;
-         result = -1;
-         break;
-       }
-
-       if (request == VIDIOC_STREAMON)
-         result = v4l2_streamon(index);
-       else
-         result = v4l2_streamoff(index);
-      }
+      if (devices[index].io != v4l2_io_mmap) {
+       errno = EINVAL;
+       result = -1;
+       break;
+      }
+
+      if (request == VIDIOC_STREAMON)
+       result = v4l2_streamon(index);
+      else
+       result = v4l2_streamoff(index);
       break;
 
     default:
       result = syscall(SYS_ioctl, fd, request, arg);
   }
 
-  if (stream_locked)
+  if (stream_needs_locking)
     pthread_mutex_unlock(&devices[index].stream_lock);
 
   saved_err = errno;


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/40ccde2672636c62d99ef1f7bfac7118e1dd5c6b

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to