avicap32: fix build with recent kernel headers

Rafał Mużyło galtgendo at gmail.com
Thu May 5 21:55:50 CDT 2011


Attached patch seems to fix build problem with recent kernel headers,
where v4l1 was removed. I'm sending it here first (instead straight
to wine-patches), as I have no real way of testing it - I only know it builds.

As such, I haven't bothered yet with keeping consistant folding style.

In case of any questions, CC me.

PS.: qcap *might* need a similar, though far more complex fix.

-------------- next part --------------
--- configure.ac	2011-04-29 20:04:41.000000000 +0200
+++ configure.ac	2011-05-06 01:23:59.000000000 +0200
@@ -655,6 +655,15 @@
 #include <asm/types.h>
 #endif])
 
+AC_CHECK_HEADERS([linux/videodev2.h],,,
+[#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/types.h>
+#ifdef HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#endif])
+
 dnl Check for broken kernel header that doesn't define __user
 AC_CHECK_HEADERS([linux/capi.h],,,[#define __user])
 
--- dlls/avicap32/avicap32_main.c	2011-04-29 20:04:41.000000000 +0200
+++ dlls/avicap32/avicap32_main.c	2011-05-06 01:37:46.000000000 +0200
@@ -41,6 +41,9 @@
 #ifdef HAVE_LINUX_VIDEODEV_H
 # include <linux/videodev.h>
 #endif
+#ifdef HAVE_LINUX_VIDEODEV2_H
+# include <linux/videodev2.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -91,7 +94,7 @@
     return retW;
 }
 
-#ifdef HAVE_LINUX_VIDEODEV_H
+#if defined(HAVE_LINUX_VIDEODEV_H) || defined (HAVE_LINUX_VIDEODEV2_H)
 
 static int xioctl(int fd, int request, void * arg)
 {
@@ -108,8 +111,10 @@
    int fd;
    char device[16];
    struct stat st;
+#ifdef HAVE_LINUX_VIDEODEV_H
    struct video_capability capa;
-#ifdef HAVE_V4L2
+#endif
+#ifdef HAVE_LINUX_VIDEODEV2_H
    struct v4l2_capability caps;
 #endif
 
@@ -132,7 +137,7 @@
       return FALSE;
    }
 
-#ifdef HAVE_V4L2
+#ifdef HAVE_LINUX_VIDEODEV2_H
    memset(&caps, 0, sizeof(caps));
    if (xioctl(fd, VIDIOC_QUERYCAP, &caps) != -1) {
       lstrcpynA(name, (char *)caps.card, namesize);
@@ -143,24 +148,33 @@
    }
 
    if (errno != EINVAL && errno != 515)
+#ifndef HAVE_LINUX_VIDEODEV_H
+         ERR("%s: Querying failed: %s\n", device, strerror(errno));
+      else ERR("%s: Querying failed: Not a V4L compatible device\n", device);
+      close(fd);
+      return FALSE;
+#else
       WARN("%s: ioctl failed: %s -- Falling back to V4L\n", device, strerror(errno));
    else WARN("%s: Not a V4L2 compatible device, trying V4l 1\n", device);
-#endif /* HAVE_V4L2 */
+#endif /* ! HAVE_LINUX_VIDEODEV_H */
+#endif /* HAVE_LINUX_VIDEODEV2_H */
 
+#ifdef HAVE_LINUX_VIDEODEV_H
    memset(&capa, 0, sizeof(capa));
-   if (xioctl(fd, VIDIOCGCAP, &capa) == -1) {
+   if (xioctl(fd, VIDIOCGCAP, &capa) != -1) {
+   lstrcpynA(name, capa.name, namesize);
+   lstrcpynA(version, device, versionsize);
+   close(fd);
+   return TRUE;
+   }
+
 /* errno 515 is used by some webcam drivers for unknown IOICTL command */
       if (errno != EINVAL && errno != 515)
          ERR("%s: Querying failed: %s\n", device, strerror(errno));
       else ERR("%s: Querying failed: Not a V4L compatible device\n", device);
       close(fd);
       return FALSE;
-   }
-
-   lstrcpynA(name, capa.name, namesize);
-   lstrcpynA(version, device, versionsize);
-   close(fd);
-   return TRUE;
+#endif /* HAVE_LINUX_VIDEODEV_H */
 }
 
 #else /* HAVE_LINUX_VIDEODEV_H */


More information about the wine-devel mailing list