SDL: SDL_camera_v4l2: allow building against older kernel headers

From 3b7533f4a291b3b75997c6cc306c91a6775ac597 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 22 Feb 2024 00:04:10 +0300
Subject: [PATCH] SDL_camera_v4l2: allow building against older kernel headers

---
 src/camera/v4l2/SDL_camera_v4l2.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/camera/v4l2/SDL_camera_v4l2.c b/src/camera/v4l2/SDL_camera_v4l2.c
index 4a94b2563b04..07968923d047 100644
--- a/src/camera/v4l2/SDL_camera_v4l2.c
+++ b/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"