From 8cdc7e8c7e08da82b8b3b7516f957f13e541af59 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 29 Jan 2020 18:48:31 +0100
Subject: [PATCH 85/86] v4l2: decode frame intervals/sizes unconditionally
---
v4l2.c | 62 ++++++++++++++++++++++++++++++++--------
xlat/v4l2_frameinterval_types.in | 6 ++--
xlat/v4l2_framesize_types.in | 6 ++--
3 files changed, 56 insertions(+), 18 deletions(-)
Index: strace-5.1/v4l2.c
===================================================================
--- strace-5.1.orig/v4l2.c 2020-01-29 21:08:39.766035121 +0100
+++ strace-5.1/v4l2.c 2020-01-29 21:08:41.137022537 +0100
@@ -206,6 +206,52 @@
typedef struct {
+ uint32_t width;
+ uint32_t height;
+} struct_v4l2_frmsize_discrete;
+
+typedef struct {
+ uint32_t min_width;
+ uint32_t max_width;
+ uint32_t step_width;
+ uint32_t min_height;
+ uint32_t max_height;
+ uint32_t step_height;
+} struct_v4l2_frmsize_stepwise;
+
+/** Added by Linux commit v2.6.19-rc1~183 */
+typedef struct {
+ uint32_t index;
+ uint32_t pixel_format;
+ uint32_t type; /**< enum v4l2_frmsizetypes */
+ union {
+ struct_v4l2_frmsize_discrete discrete;
+ struct_v4l2_frmsize_stepwise stepwise;
+ };
+ uint32_t reserved[2];
+} struct_v4l2_frmsizeenum;
+
+typedef struct {
+ struct v4l2_fract min;
+ struct v4l2_fract max;
+ struct v4l2_fract step;
+} struct_v4l2_frmival_stepwise;
+
+typedef struct {
+ uint32_t index;
+ uint32_t pixel_format;
+ uint32_t width;
+ uint32_t height;
+ uint32_t type; /**< enum v4l2_frmivaltypes */
+ union {
+ struct v4l2_fract discrete;
+ struct_v4l2_frmival_stepwise stepwise;
+ };
+ uint32_t reserved[2];
+} struct_v4l2_frmivalenum;
+
+
+typedef struct {
uint32_t index;
uint32_t count;
uint32_t memory;
@@ -1076,13 +1122,12 @@
return 0;
}
-#ifdef VIDIOC_ENUM_FRAMESIZES
-# include "xlat/v4l2_framesize_types.h"
+#include "xlat/v4l2_framesize_types.h"
static int
print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
{
- struct v4l2_frmsizeenum s;
+ struct_v4l2_frmsizeenum s;
if (entering(tcp)) {
tprints(", ");
@@ -1114,15 +1159,13 @@
tprints("}");
return RVAL_IOCTL_DECODED;
}
-#endif /* VIDIOC_ENUM_FRAMESIZES */
-#ifdef VIDIOC_ENUM_FRAMEINTERVALS
-# include "xlat/v4l2_frameinterval_types.h"
+#include "xlat/v4l2_frameinterval_types.h"
static int
print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
{
- struct v4l2_frmivalenum f;
+ struct_v4l2_frmivalenum f;
if (entering(tcp)) {
tprints(", ");
@@ -1158,7 +1201,6 @@
return RVAL_IOCTL_DECODED;
}
-#endif /* VIDIOC_ENUM_FRAMEINTERVALS */
static int
print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
@@ -1281,15 +1323,11 @@
return print_v4l2_ext_controls(tcp, arg,
code == VIDIOC_G_EXT_CTRLS);
-#ifdef VIDIOC_ENUM_FRAMESIZES
case VIDIOC_ENUM_FRAMESIZES: /* RW */
return print_v4l2_frmsizeenum(tcp, arg);
-#endif /* VIDIOC_ENUM_FRAMESIZES */
-#ifdef VIDIOC_ENUM_FRAMEINTERVALS
case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
return print_v4l2_frmivalenum(tcp, arg);
-#endif /* VIDIOC_ENUM_FRAMEINTERVALS */
case VIDIOC_CREATE_BUFS: /* RW */
return print_v4l2_create_buffers(tcp, arg);
Index: strace-5.1/xlat/v4l2_frameinterval_types.in
===================================================================
--- strace-5.1.orig/xlat/v4l2_frameinterval_types.in 2020-01-29 21:08:21.012207266 +0100
+++ strace-5.1/xlat/v4l2_frameinterval_types.in 2020-01-29 21:08:41.137022537 +0100
@@ -1,3 +1,3 @@
-V4L2_FRMIVAL_TYPE_DISCRETE
-V4L2_FRMIVAL_TYPE_CONTINUOUS
-V4L2_FRMIVAL_TYPE_STEPWISE
+V4L2_FRMIVAL_TYPE_DISCRETE 1
+V4L2_FRMIVAL_TYPE_CONTINUOUS 2
+V4L2_FRMIVAL_TYPE_STEPWISE 3
Index: strace-5.1/xlat/v4l2_framesize_types.in
===================================================================
--- strace-5.1.orig/xlat/v4l2_framesize_types.in 2020-01-29 21:08:21.012207266 +0100
+++ strace-5.1/xlat/v4l2_framesize_types.in 2020-01-29 21:08:41.137022537 +0100
@@ -1,3 +1,3 @@
-V4L2_FRMSIZE_TYPE_DISCRETE
-V4L2_FRMSIZE_TYPE_CONTINUOUS
-V4L2_FRMSIZE_TYPE_STEPWISE
+V4L2_FRMSIZE_TYPE_DISCRETE 1
+V4L2_FRMSIZE_TYPE_CONTINUOUS 2
+V4L2_FRMSIZE_TYPE_STEPWISE 3
Index: strace-5.1/xlat/v4l2_frameinterval_types.h
===================================================================
--- strace-5.1.orig/xlat/v4l2_frameinterval_types.h 2019-05-22 15:08:30.000000000 +0200
+++ strace-5.1/xlat/v4l2_frameinterval_types.h 2020-01-29 21:12:03.513076783 +0100
@@ -3,6 +3,27 @@
#include "gcc_compat.h"
#include "static_assert.h"
+#if defined(V4L2_FRMIVAL_TYPE_DISCRETE) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_DISCRETE) && HAVE_DECL_V4L2_FRMIVAL_TYPE_DISCRETE)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMIVAL_TYPE_DISCRETE) == (1), "V4L2_FRMIVAL_TYPE_DISCRETE != 1");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMIVAL_TYPE_DISCRETE 1
+#endif
+#if defined(V4L2_FRMIVAL_TYPE_CONTINUOUS) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_CONTINUOUS) && HAVE_DECL_V4L2_FRMIVAL_TYPE_CONTINUOUS)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMIVAL_TYPE_CONTINUOUS) == (2), "V4L2_FRMIVAL_TYPE_CONTINUOUS != 2");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMIVAL_TYPE_CONTINUOUS 2
+#endif
+#if defined(V4L2_FRMIVAL_TYPE_STEPWISE) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_STEPWISE) && HAVE_DECL_V4L2_FRMIVAL_TYPE_STEPWISE)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMIVAL_TYPE_STEPWISE) == (3), "V4L2_FRMIVAL_TYPE_STEPWISE != 3");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMIVAL_TYPE_STEPWISE 3
+#endif
#ifndef XLAT_MACROS_ONLY
@@ -16,15 +37,9 @@
static
# endif
const struct xlat v4l2_frameinterval_types[] = {
-#if defined(V4L2_FRMIVAL_TYPE_DISCRETE) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_DISCRETE) && HAVE_DECL_V4L2_FRMIVAL_TYPE_DISCRETE)
- XLAT(V4L2_FRMIVAL_TYPE_DISCRETE),
-#endif
-#if defined(V4L2_FRMIVAL_TYPE_CONTINUOUS) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_CONTINUOUS) && HAVE_DECL_V4L2_FRMIVAL_TYPE_CONTINUOUS)
- XLAT(V4L2_FRMIVAL_TYPE_CONTINUOUS),
-#endif
-#if defined(V4L2_FRMIVAL_TYPE_STEPWISE) || (defined(HAVE_DECL_V4L2_FRMIVAL_TYPE_STEPWISE) && HAVE_DECL_V4L2_FRMIVAL_TYPE_STEPWISE)
- XLAT(V4L2_FRMIVAL_TYPE_STEPWISE),
-#endif
+ XLAT(V4L2_FRMIVAL_TYPE_DISCRETE),
+ XLAT(V4L2_FRMIVAL_TYPE_CONTINUOUS),
+ XLAT(V4L2_FRMIVAL_TYPE_STEPWISE),
XLAT_END
};
Index: strace-5.1/xlat/v4l2_framesize_types.h
===================================================================
--- strace-5.1.orig/xlat/v4l2_framesize_types.h 2019-05-22 15:08:31.000000000 +0200
+++ strace-5.1/xlat/v4l2_framesize_types.h 2020-01-29 21:12:03.681075121 +0100
@@ -3,6 +3,27 @@
#include "gcc_compat.h"
#include "static_assert.h"
+#if defined(V4L2_FRMSIZE_TYPE_DISCRETE) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_DISCRETE) && HAVE_DECL_V4L2_FRMSIZE_TYPE_DISCRETE)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMSIZE_TYPE_DISCRETE) == (1), "V4L2_FRMSIZE_TYPE_DISCRETE != 1");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMSIZE_TYPE_DISCRETE 1
+#endif
+#if defined(V4L2_FRMSIZE_TYPE_CONTINUOUS) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_CONTINUOUS) && HAVE_DECL_V4L2_FRMSIZE_TYPE_CONTINUOUS)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMSIZE_TYPE_CONTINUOUS) == (2), "V4L2_FRMSIZE_TYPE_CONTINUOUS != 2");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMSIZE_TYPE_CONTINUOUS 2
+#endif
+#if defined(V4L2_FRMSIZE_TYPE_STEPWISE) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_STEPWISE) && HAVE_DECL_V4L2_FRMSIZE_TYPE_STEPWISE)
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((V4L2_FRMSIZE_TYPE_STEPWISE) == (3), "V4L2_FRMSIZE_TYPE_STEPWISE != 3");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define V4L2_FRMSIZE_TYPE_STEPWISE 3
+#endif
#ifndef XLAT_MACROS_ONLY
@@ -16,15 +37,9 @@
static
# endif
const struct xlat v4l2_framesize_types[] = {
-#if defined(V4L2_FRMSIZE_TYPE_DISCRETE) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_DISCRETE) && HAVE_DECL_V4L2_FRMSIZE_TYPE_DISCRETE)
- XLAT(V4L2_FRMSIZE_TYPE_DISCRETE),
-#endif
-#if defined(V4L2_FRMSIZE_TYPE_CONTINUOUS) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_CONTINUOUS) && HAVE_DECL_V4L2_FRMSIZE_TYPE_CONTINUOUS)
- XLAT(V4L2_FRMSIZE_TYPE_CONTINUOUS),
-#endif
-#if defined(V4L2_FRMSIZE_TYPE_STEPWISE) || (defined(HAVE_DECL_V4L2_FRMSIZE_TYPE_STEPWISE) && HAVE_DECL_V4L2_FRMSIZE_TYPE_STEPWISE)
- XLAT(V4L2_FRMSIZE_TYPE_STEPWISE),
-#endif
+ XLAT(V4L2_FRMSIZE_TYPE_DISCRETE),
+ XLAT(V4L2_FRMSIZE_TYPE_CONTINUOUS),
+ XLAT(V4L2_FRMSIZE_TYPE_STEPWISE),
XLAT_END
};