Skip to content

Commit 09b536e

Browse files
author
Stefan Ott
committed
Fix compile-time issue on very old kernels
Kernel versions prior to 3.4 did not have V4L2_CAP_DEVICE_CAPS and compiling against such a kernel will fail. This patch introduces a version check and makes eudev fall back to v2cap.capabilities on these kernels.
1 parent 9bcbc13 commit 09b536e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/v4l_id/v4l_id.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <sys/types.h>
2929
#include <sys/time.h>
3030
#include <sys/ioctl.h>
31+
#include <linux/version.h>
3132
#include <linux/videodev2.h>
3233

3334
#include "util.h"
@@ -71,9 +72,11 @@ int main(int argc, char *argv[]) {
7172
printf("ID_V4L_VERSION=2\n");
7273
printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
7374
printf("ID_V4L_CAPABILITIES=:");
75+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
7476
if (v2cap.capabilities & V4L2_CAP_DEVICE_CAPS)
7577
capabilities = v2cap.device_caps;
7678
else
79+
#endif
7780
capabilities = v2cap.capabilities;
7881
if ((capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0 ||
7982
(capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) > 0)

0 commit comments

Comments
 (0)