Skip to content

Commit

Permalink
Fix compile-time issue on very old kernels
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cockroach committed Apr 5, 2023
1 parent 9bcbc13 commit 09b536e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/v4l_id/v4l_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <linux/version.h>
#include <linux/videodev2.h>

#include "util.h"
Expand Down Expand Up @@ -71,9 +72,11 @@ int main(int argc, char *argv[]) {
printf("ID_V4L_VERSION=2\n");
printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
printf("ID_V4L_CAPABILITIES=:");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)
if (v2cap.capabilities & V4L2_CAP_DEVICE_CAPS)
capabilities = v2cap.device_caps;
else
#endif
capabilities = v2cap.capabilities;
if ((capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0 ||
(capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) > 0)
Expand Down

0 comments on commit 09b536e

Please sign in to comment.