Browse Source

SDL_camera_v4l2: allow building against older kernel headers

Ozkan Sezer 1 year ago
parent
commit
3b7533f4a2
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/camera/v4l2/SDL_camera_v4l2.c

+ 7 - 0
src/camera/v4l2/SDL_camera_v4l2.c

@@ -22,6 +22,7 @@
 
 #ifdef SDL_CAMERA_DRIVER_V4L2
 
+#include <stddef.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>              // low-level i/o
@@ -30,6 +31,12 @@
 #include <sys/stat.h>
 #include <linux/videodev2.h>
 
+#ifndef V4L2_CAP_DEVICE_CAPS
+// device_caps was added to struct v4l2_capability as of kernel 3.4.
+#define device_caps reserved[0]
+SDL_COMPILE_TIME_ASSERT(v4l2devicecaps, offsetof(struct v4l2_capability,device_caps) == offsetof(struct v4l2_capability,capabilities) + 4);
+#endif
+
 #include "../SDL_syscamera.h"
 #include "../SDL_camera_c.h"
 #include "../../video/SDL_pixels_c.h"