Blame SOURCES/0080-v4l2-bundle-struct-v4l2_create_buffers-definition.patch

86f512
From 99067b14797a6877c3a98017c56e60c239930919 Mon Sep 17 00:00:00 2001
86f512
From: Eugene Syromyatnikov <evgsyr@gmail.com>
86f512
Date: Fri, 1 Nov 2019 02:00:53 +0100
86f512
Subject: [PATCH 80/86] v4l2: bundle struct v4l2_create_buffers definition
86f512
86f512
* configure.ac (AC_CHECK_TYPES): Add a check for
86f512
struct v4l2_create_buffers definition.
86f512
* v4l2.c (DEF_MPERS_TYPE(struct_v4l2_create_buffers)): Remove
86f512
VIDIOC_CREATE_BUFS guard.
86f512
(struct_v4l2_create_buffers): typedef to a structure definition and not
86f512
struct v4l2_create_buffers.
86f512
[HAVE_STRUCT_V4L2_CREATE_BUFFERS]: Check struct v4l2_create_buffers
86f512
with CHECK_V4L2_STRUCT_RESERVED_SIZE.
86f512
---
86f512
 configure.ac |  7 +++++++
86f512
 v4l2.c       | 25 ++++++++++++++++---------
86f512
 2 files changed, 23 insertions(+), 9 deletions(-)
86f512
86f512
diff --git a/configure.ac b/configure.ac
86f512
index 63f57f9..e47ba38 100644
86f512
--- a/configure.ac
86f512
+++ b/configure.ac
86f512
@@ -774,6 +774,13 @@ AC_CHECK_DECLS(m4_normalize([
86f512
 #include <linux/types.h>
86f512
 #include <linux/videodev2.h>])
86f512
 
86f512
+AC_CHECK_TYPES(m4_normalize([
86f512
+	struct v4l2_create_buffers
86f512
+]),,, [#include <sys/time.h>
86f512
+#include <linux/ioctl.h>
86f512
+#include <linux/types.h>
86f512
+#include <linux/videodev2.h>])
86f512
+
86f512
 AC_CHECK_MEMBERS(m4_normalize([
86f512
 	struct v4l2_capability.device_caps,
86f512
 	struct v4l2_ext_control.string,
86f512
diff --git a/v4l2.c b/v4l2.c
86f512
index b45f7f8..561aee2 100644
86f512
--- a/v4l2.c
86f512
+++ b/v4l2.c
86f512
@@ -35,9 +35,7 @@
86f512
 
86f512
 #include DEF_MPERS_TYPE(struct_v4l2_buffer)
86f512
 #include DEF_MPERS_TYPE(struct_v4l2_clip)
86f512
-#ifdef VIDIOC_CREATE_BUFS
86f512
-# include DEF_MPERS_TYPE(struct_v4l2_create_buffers)
86f512
-#endif
86f512
+#include DEF_MPERS_TYPE(struct_v4l2_create_buffers)
86f512
 #include DEF_MPERS_TYPE(struct_v4l2_ext_control)
86f512
 #include DEF_MPERS_TYPE(struct_v4l2_ext_controls)
86f512
 #include DEF_MPERS_TYPE(struct_v4l2_format)
86f512
@@ -47,9 +45,22 @@
86f512
 
86f512
 typedef struct v4l2_buffer struct_v4l2_buffer;
86f512
 typedef struct v4l2_clip struct_v4l2_clip;
86f512
-#ifdef VIDIOC_CREATE_BUFS
86f512
-typedef struct v4l2_create_buffers struct_v4l2_create_buffers;
86f512
+
86f512
+typedef struct {
86f512
+	uint32_t index;
86f512
+	uint32_t count;
86f512
+	uint32_t memory;
86f512
+	struct_v4l2_format format;
86f512
+	/** V4L2_BUF_CAP_SUPPORTS_*, added by Linux commit v4.20-rc1~51^2~14 */
86f512
+	uint32_t capabilities;
86f512
+	uint32_t reserved[7];
86f512
+} struct_v4l2_create_buffers;
86f512
+
86f512
+#ifdef HAVE_STRUCT_V4L2_CREATE_BUFFERS
86f512
+CHECK_V4L2_STRUCT_RESERVED_SIZE(v4l2_create_buffers);
86f512
 #endif
86f512
+
86f512
+
86f512
 typedef struct v4l2_ext_control struct_v4l2_ext_control;
86f512
 typedef struct v4l2_ext_controls struct_v4l2_ext_controls;
86f512
 typedef struct v4l2_format struct_v4l2_format;
86f512
@@ -967,7 +978,6 @@ print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
86f512
 }
86f512
 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
86f512
 
86f512
-#ifdef VIDIOC_CREATE_BUFS
86f512
 static int
86f512
 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
86f512
 {
86f512
@@ -999,7 +1009,6 @@ print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
86f512
 
86f512
 	return RVAL_IOCTL_DECODED | RVAL_STR;
86f512
 }
86f512
-#endif /* VIDIOC_CREATE_BUFS */
86f512
 
86f512
 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
86f512
 		   const unsigned int code, const kernel_ulong_t arg)
86f512
@@ -1102,10 +1111,8 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
86f512
 		return print_v4l2_frmivalenum(tcp, arg);
86f512
 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
86f512
 
86f512
-#ifdef VIDIOC_CREATE_BUFS
86f512
 	case VIDIOC_CREATE_BUFS: /* RW */
86f512
 		return print_v4l2_create_buffers(tcp, arg);
86f512
-#endif /* VIDIOC_CREATE_BUFS */
86f512
 
86f512
 	default:
86f512
 		return RVAL_DECODED;
86f512
-- 
86f512
2.1.4
86f512