Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 Philippe De Muyter <phdm@macqel.be> |
| 3 | * Copyright (c) 2014 William Manley <will@williammanley.net> |
| 4 | * Copyright (c) 2011 Peter Zotov <whitequark@whitequark.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
| 31 | |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 32 | #include DEF_MPERS_TYPE(struct_v4l2_buffer) |
| 33 | #include DEF_MPERS_TYPE(struct_v4l2_create_buffers) |
| 34 | #include DEF_MPERS_TYPE(struct_v4l2_ext_control) |
| 35 | #include DEF_MPERS_TYPE(struct_v4l2_ext_controls) |
| 36 | #include DEF_MPERS_TYPE(struct_v4l2_format) |
| 37 | #include DEF_MPERS_TYPE(struct_v4l2_framebuffer) |
| 38 | #include DEF_MPERS_TYPE(struct_v4l2_input) |
| 39 | #include DEF_MPERS_TYPE(struct_v4l2_standard) |
| 40 | |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 41 | #include <stdint.h> |
Dmitry V. Levin | fe3de9c | 2016-05-13 20:15:12 +0000 | [diff] [blame] | 42 | #include <linux/ioctl.h> |
Dmitry V. Levin | 0f4ad30 | 2015-02-22 02:13:04 +0000 | [diff] [blame] | 43 | #include <linux/types.h> |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 44 | #include <linux/videodev2.h> |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 45 | |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 46 | typedef struct v4l2_buffer struct_v4l2_buffer; |
| 47 | typedef struct v4l2_create_buffers struct_v4l2_create_buffers; |
| 48 | typedef struct v4l2_ext_control struct_v4l2_ext_control; |
| 49 | typedef struct v4l2_ext_controls struct_v4l2_ext_controls; |
| 50 | typedef struct v4l2_format struct_v4l2_format; |
| 51 | typedef struct v4l2_framebuffer struct_v4l2_framebuffer; |
| 52 | typedef struct v4l2_input struct_v4l2_input; |
| 53 | typedef struct v4l2_standard struct_v4l2_standard; |
| 54 | |
| 55 | #include MPERS_DEFS |
| 56 | |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 57 | /* some historical constants */ |
| 58 | #ifndef V4L2_CID_HCENTER |
| 59 | #define V4L2_CID_HCENTER (V4L2_CID_BASE+22) |
| 60 | #endif |
| 61 | #ifndef V4L2_CID_VCENTER |
| 62 | #define V4L2_CID_VCENTER (V4L2_CID_BASE+23) |
| 63 | #endif |
| 64 | #ifndef V4L2_CID_BAND_STOP_FILTER |
| 65 | #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33) |
| 66 | #endif |
| 67 | |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 68 | #define FMT_FRACT "%u/%u" |
| 69 | #define ARGS_FRACT(x) ((x).numerator), ((x).denominator) |
| 70 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 71 | #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}" |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 72 | #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height |
| 73 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 74 | static void |
| 75 | print_pixelformat(uint32_t fourcc) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 76 | { |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 77 | const union { |
Dmitry V. Levin | f0a5b08 | 2015-01-25 00:27:00 +0000 | [diff] [blame] | 78 | uint32_t pixelformat; |
| 79 | unsigned char cc[sizeof(uint32_t)]; |
Dmitry V. Levin | f2f162e | 2016-05-13 03:51:43 +0000 | [diff] [blame] | 80 | } u = { |
| 81 | #if WORDS_BIGENDIAN |
| 82 | .cc = { |
| 83 | (unsigned char) (fourcc >> 24), |
| 84 | (unsigned char) (fourcc >> 16), |
| 85 | (unsigned char) (fourcc >> 8), |
| 86 | (unsigned char) fourcc |
| 87 | } |
| 88 | #else |
| 89 | .pixelformat = fourcc |
| 90 | #endif |
| 91 | }; |
Dmitry V. Levin | f0a5b08 | 2015-01-25 00:27:00 +0000 | [diff] [blame] | 92 | unsigned int i; |
| 93 | |
| 94 | tprints("v4l2_fourcc("); |
| 95 | for (i = 0; i < sizeof(u.cc); ++i) { |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 96 | unsigned char c = u.cc[i]; |
Dmitry V. Levin | f0a5b08 | 2015-01-25 00:27:00 +0000 | [diff] [blame] | 97 | |
| 98 | if (i) |
| 99 | tprints(", "); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 100 | if (c == '\'' || c == '\\') { |
Dmitry V. Levin | f0a5b08 | 2015-01-25 00:27:00 +0000 | [diff] [blame] | 101 | char sym[] = { |
| 102 | '\'', |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 103 | '\\', |
| 104 | c, |
| 105 | '\'', |
| 106 | '\0' |
| 107 | }; |
| 108 | tprints(sym); |
| 109 | } else if (c >= ' ' && c <= 0x7e) { |
| 110 | char sym[] = { |
| 111 | '\'', |
| 112 | c, |
| 113 | '\'', |
| 114 | '\0' |
Dmitry V. Levin | f0a5b08 | 2015-01-25 00:27:00 +0000 | [diff] [blame] | 115 | }; |
| 116 | tprints(sym); |
| 117 | } else { |
| 118 | char hex[] = { |
| 119 | '\'', |
| 120 | '\\', |
| 121 | 'x', |
| 122 | "0123456789abcdef"[c >> 4], |
| 123 | "0123456789abcdef"[c & 0xf], |
| 124 | '\'', |
| 125 | '\0' |
| 126 | }; |
| 127 | tprints(hex); |
| 128 | } |
| 129 | } |
| 130 | tprints(")"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 133 | #include "xlat/v4l2_device_capabilities_flags.h" |
| 134 | |
| 135 | static int |
| 136 | print_v4l2_capability(struct tcb *tcp, const long arg) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 137 | { |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 138 | struct v4l2_capability caps; |
| 139 | |
| 140 | if (entering(tcp)) |
| 141 | return 0; |
| 142 | tprints(", "); |
| 143 | if (umove_or_printaddr(tcp, arg, &caps)) |
| 144 | return 1; |
| 145 | tprints("{driver="); |
| 146 | print_quoted_string((const char *) caps.driver, |
| 147 | sizeof(caps.driver), QUOTE_0_TERMINATED); |
| 148 | tprints(", card="); |
| 149 | print_quoted_string((const char *) caps.card, |
| 150 | sizeof(caps.card), QUOTE_0_TERMINATED); |
| 151 | tprints(", bus_info="); |
| 152 | print_quoted_string((const char *) caps.bus_info, |
| 153 | sizeof(caps.bus_info), QUOTE_0_TERMINATED); |
| 154 | tprintf(", version=%u.%u.%u, capabilities=", |
| 155 | (caps.version >> 16) & 0xFF, |
| 156 | (caps.version >> 8) & 0xFF, |
| 157 | caps.version & 0xFF); |
| 158 | printflags(v4l2_device_capabilities_flags, caps.capabilities, |
| 159 | "V4L2_CAP_???"); |
| 160 | #ifdef V4L2_CAP_DEVICE_CAPS |
| 161 | tprints(", device_caps="); |
| 162 | printflags(v4l2_device_capabilities_flags, caps.device_caps, |
| 163 | "V4L2_CAP_???"); |
| 164 | #endif |
| 165 | tprints("}"); |
| 166 | return 1; |
| 167 | } |
| 168 | |
| 169 | #include "xlat/v4l2_buf_types.h" |
| 170 | #include "xlat/v4l2_format_description_flags.h" |
| 171 | |
| 172 | static int |
| 173 | print_v4l2_fmtdesc(struct tcb *tcp, const long arg) |
| 174 | { |
| 175 | struct v4l2_fmtdesc f; |
| 176 | |
| 177 | if (entering(tcp)) { |
| 178 | tprints(", "); |
| 179 | if (umove_or_printaddr(tcp, arg, &f)) |
| 180 | return RVAL_DECODED | 1; |
| 181 | tprintf("{index=%u, type=", f.index); |
| 182 | printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | if (!syserror(tcp) && !umove(tcp, arg, &f)) { |
| 187 | tprints(", flags="); |
| 188 | printflags(v4l2_format_description_flags, f.flags, |
| 189 | "V4L2_FMT_FLAG_???"); |
| 190 | tprints(", description="); |
| 191 | print_quoted_string((const char *) f.description, |
| 192 | sizeof(f.description), |
| 193 | QUOTE_0_TERMINATED); |
| 194 | tprints(", pixelformat="); |
| 195 | print_pixelformat(f.pixelformat); |
| 196 | } |
| 197 | tprints("}"); |
| 198 | return 1; |
| 199 | } |
| 200 | |
| 201 | #include "xlat/v4l2_fields.h" |
| 202 | #include "xlat/v4l2_colorspaces.h" |
| 203 | |
| 204 | static void |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 205 | print_v4l2_format_fmt(const char *prefix, const struct_v4l2_format *f) |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 206 | { |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 207 | switch (f->type) { |
| 208 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 209 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
| 210 | tprints(prefix); |
| 211 | tprintf("fmt.pix={width=%u, height=%u, pixelformat=", |
| 212 | f->fmt.pix.width, f->fmt.pix.height); |
| 213 | print_pixelformat(f->fmt.pix.pixelformat); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 214 | tprints(", field="); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 215 | printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 216 | tprintf(", bytesperline=%u, sizeimage=%u, colorspace=", |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 217 | f->fmt.pix.bytesperline, f->fmt.pix.sizeimage); |
| 218 | printxval(v4l2_colorspaces, f->fmt.pix.colorspace, |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 219 | "V4L2_COLORSPACE_???"); |
| 220 | tprints("}"); |
| 221 | break; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 222 | #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE |
| 223 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
| 224 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: { |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 225 | unsigned int i, max; |
| 226 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 227 | tprints(prefix); |
| 228 | tprintf("fmt.pix_mp={width=%u, height=%u, pixelformat=", |
| 229 | f->fmt.pix_mp.width, f->fmt.pix_mp.height); |
| 230 | print_pixelformat(f->fmt.pix_mp.pixelformat); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 231 | tprints(", field="); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 232 | printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 233 | tprints(", colorspace="); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 234 | printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace, |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 235 | "V4L2_COLORSPACE_???"); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 236 | tprints(", plane_fmt=["); |
| 237 | max = f->fmt.pix_mp.num_planes; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 238 | if (max > VIDEO_MAX_PLANES) |
| 239 | max = VIDEO_MAX_PLANES; |
| 240 | for (i = 0; i < max; i++) { |
| 241 | if (i > 0) |
| 242 | tprints(", "); |
| 243 | tprintf("{sizeimage=%u, bytesperline=%u}", |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 244 | f->fmt.pix_mp.plane_fmt[i].sizeimage, |
| 245 | f->fmt.pix_mp.plane_fmt[i].bytesperline); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 246 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 247 | tprintf("], num_planes=%u}", (unsigned) f->fmt.pix_mp.num_planes); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 248 | break; |
| 249 | } |
| 250 | #endif |
| 251 | |
| 252 | /* TODO: Complete this switch statement */ |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 253 | #if 0 |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 254 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
Dmitry V. Levin | 197db57 | 2015-01-09 04:53:19 +0000 | [diff] [blame] | 255 | #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 256 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
Dmitry V. Levin | 197db57 | 2015-01-09 04:53:19 +0000 | [diff] [blame] | 257 | #endif |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 258 | tprints(prefix); |
| 259 | tprints("fmt.win={???}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 260 | break; |
| 261 | |
| 262 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 263 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 264 | tprints(prefix); |
| 265 | tprints("fmt.vbi={???}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 266 | break; |
| 267 | |
| 268 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
| 269 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 270 | tprints(prefix); |
| 271 | tprints("fmt.sliced={???}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 272 | break; |
| 273 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 274 | #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE |
| 275 | case V4L2_BUF_TYPE_SDR_CAPTURE: |
| 276 | case V4L2_BUF_TYPE_SDR_OUTPUT: |
| 277 | tprints(prefix); |
| 278 | tprints("fmt.sdr={???}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 279 | break; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 280 | #endif |
| 281 | #endif |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 285 | static int |
| 286 | print_v4l2_format(struct tcb *tcp, const long arg, const bool is_get) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 287 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 288 | struct_v4l2_format f; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 289 | |
| 290 | if (entering(tcp)) { |
| 291 | tprints(", "); |
| 292 | if (umove_or_printaddr(tcp, arg, &f)) |
| 293 | return RVAL_DECODED | 1; |
| 294 | tprints("{type="); |
| 295 | printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); |
| 296 | if (is_get) |
| 297 | return 0; |
| 298 | print_v4l2_format_fmt(", ", &f); |
| 299 | } else { |
| 300 | if (!syserror(tcp) && !umove(tcp, arg, &f)) { |
| 301 | const char *delim = is_get ? ", " : " => "; |
| 302 | print_v4l2_format_fmt(delim, &f); |
| 303 | } |
| 304 | tprints("}"); |
| 305 | } |
| 306 | return 1; |
| 307 | } |
| 308 | |
| 309 | #include "xlat/v4l2_memories.h" |
| 310 | |
| 311 | static int |
| 312 | print_v4l2_requestbuffers(struct tcb *tcp, const long arg) |
| 313 | { |
| 314 | struct v4l2_requestbuffers reqbufs; |
| 315 | |
| 316 | if (entering(tcp)) { |
| 317 | tprints(", "); |
| 318 | if (umove_or_printaddr(tcp, arg, &reqbufs)) |
| 319 | return RVAL_DECODED | 1; |
| 320 | tprintf("{count=%u, type=", reqbufs.count); |
| 321 | printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???"); |
| 322 | tprints(", memory="); |
| 323 | printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???"); |
| 324 | tprints("}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 325 | return 0; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 326 | } else { |
| 327 | static char outstr[sizeof("{count=}") + sizeof(int) * 3]; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 328 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 329 | if (syserror(tcp) || umove(tcp, arg, &reqbufs) < 0) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 330 | return 1; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 331 | sprintf(outstr, "{count=%u}", reqbufs.count); |
| 332 | tcp->auxstr = outstr; |
| 333 | return 1 + RVAL_STR; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 334 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 335 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 336 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 337 | #include "xlat/v4l2_buf_flags.h" |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 338 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 339 | static int |
| 340 | print_v4l2_buffer(struct tcb *tcp, const unsigned int code, const long arg) |
| 341 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 342 | struct_v4l2_buffer b; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 343 | |
| 344 | if (entering(tcp)) { |
| 345 | tprints(", "); |
| 346 | if (umove_or_printaddr(tcp, arg, &b)) |
| 347 | return RVAL_DECODED | 1; |
| 348 | tprints("{type="); |
| 349 | printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???"); |
| 350 | if (code != VIDIOC_DQBUF) |
| 351 | tprintf(", index=%u", b.index); |
| 352 | } else { |
| 353 | if (!syserror(tcp) && umove(tcp, arg, &b) == 0) { |
| 354 | if (code == VIDIOC_DQBUF) |
| 355 | tprintf(", index=%u", b.index); |
| 356 | tprints(", memory="); |
| 357 | printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???"); |
| 358 | |
| 359 | if (b.memory == V4L2_MEMORY_MMAP) { |
| 360 | tprintf(", m.offset=%#x", b.m.offset); |
| 361 | } else if (b.memory == V4L2_MEMORY_USERPTR) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 362 | tprints(", m.userptr="); |
| 363 | printaddr((unsigned long) b.m.userptr); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 364 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 365 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 366 | tprintf(", length=%u, bytesused=%u, flags=", |
| 367 | b.length, b.bytesused); |
| 368 | printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???"); |
| 369 | if (code == VIDIOC_DQBUF) |
| 370 | tprintf(", timestamp = {%ju.%06ju}", |
| 371 | (uintmax_t)b.timestamp.tv_sec, |
| 372 | (uintmax_t)b.timestamp.tv_usec); |
| 373 | tprints(", ..."); |
| 374 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 375 | tprints("}"); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 376 | } |
| 377 | return 1; |
| 378 | } |
| 379 | |
| 380 | static int |
| 381 | print_v4l2_framebuffer(struct tcb *tcp, const long arg) |
| 382 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 383 | struct_v4l2_framebuffer b; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 384 | |
| 385 | tprints(", "); |
| 386 | if (!umove_or_printaddr(tcp, arg, &b)) { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 387 | tprintf("{capability=%#x, flags=%#x, base=", |
| 388 | b.capability, b.flags); |
| 389 | printaddr((unsigned long) b.base); |
| 390 | tprints("}"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 391 | } |
| 392 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 393 | return RVAL_DECODED | 1; |
| 394 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 395 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 396 | static int |
| 397 | print_v4l2_buf_type(struct tcb *tcp, const long arg) |
| 398 | { |
| 399 | int type; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 400 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 401 | tprints(", "); |
| 402 | if (!umove_or_printaddr(tcp, arg, &type)) { |
| 403 | tprints("["); |
| 404 | printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???"); |
| 405 | tprints("]"); |
| 406 | } |
| 407 | return RVAL_DECODED | 1; |
| 408 | } |
| 409 | |
| 410 | #include "xlat/v4l2_streaming_capabilities.h" |
| 411 | #include "xlat/v4l2_capture_modes.h" |
| 412 | |
| 413 | static int |
| 414 | print_v4l2_streamparm(struct tcb *tcp, const long arg, const bool is_get) |
| 415 | { |
| 416 | struct v4l2_streamparm s; |
| 417 | |
| 418 | if (entering(tcp)) { |
| 419 | tprints(", "); |
| 420 | if (umove_or_printaddr(tcp, arg, &s)) |
| 421 | return RVAL_DECODED | 1; |
| 422 | tprints("{type="); |
| 423 | printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???"); |
| 424 | switch (s.type) { |
| 425 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 426 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
| 427 | if (is_get) |
| 428 | return 0; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 429 | tprints(", "); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 430 | break; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 431 | default: |
| 432 | tprints("}"); |
| 433 | return RVAL_DECODED | 1; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 434 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 435 | } else { |
| 436 | if (syserror(tcp) || umove(tcp, arg, &s) < 0) { |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 437 | tprints("}"); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 438 | return 1; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 439 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 440 | tprints(is_get ? ", " : " => "); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 441 | } |
| 442 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 443 | if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
| 444 | tprints("parm.capture={capability="); |
| 445 | printflags(v4l2_streaming_capabilities, |
| 446 | s.parm.capture.capability, "V4L2_CAP_???"); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 447 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 448 | tprints(", capturemode="); |
| 449 | printflags(v4l2_capture_modes, |
| 450 | s.parm.capture.capturemode, "V4L2_MODE_???"); |
| 451 | |
| 452 | tprintf(", timeperframe=" FMT_FRACT, |
| 453 | ARGS_FRACT(s.parm.capture.timeperframe)); |
| 454 | |
| 455 | tprintf(", extendedmode=%u, readbuffers=%u}", |
| 456 | s.parm.capture.extendedmode, |
| 457 | s.parm.capture.readbuffers); |
| 458 | } else { |
| 459 | tprints("parm.output={capability="); |
| 460 | printflags(v4l2_streaming_capabilities, |
| 461 | s.parm.output.capability, "V4L2_CAP_???"); |
| 462 | |
| 463 | tprintf(", outputmode=%u", s.parm.output.outputmode); |
| 464 | |
| 465 | tprintf(", timeperframe=" FMT_FRACT, |
| 466 | ARGS_FRACT(s.parm.output.timeperframe)); |
| 467 | |
| 468 | tprintf(", extendedmode=%u, writebuffers=%u}", |
| 469 | s.parm.output.extendedmode, |
| 470 | s.parm.output.writebuffers); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 471 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 472 | if (exiting(tcp)) |
| 473 | tprints("}"); |
| 474 | return 1; |
| 475 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 476 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 477 | static int |
| 478 | print_v4l2_standard(struct tcb *tcp, const long arg) |
| 479 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 480 | struct_v4l2_standard s; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 481 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 482 | if (entering(tcp)) { |
| 483 | tprints(", "); |
| 484 | if (umove_or_printaddr(tcp, arg, &s)) |
| 485 | return RVAL_DECODED | 1; |
| 486 | tprintf("{index=%u", s.index); |
| 487 | } else { |
| 488 | if (!syserror(tcp) && !umove(tcp, arg, &s)) { |
| 489 | tprints(", name="); |
| 490 | print_quoted_string((const char *) s.name, |
| 491 | sizeof(s.name), |
| 492 | QUOTE_0_TERMINATED); |
| 493 | tprintf(", frameperiod=" FMT_FRACT, |
| 494 | ARGS_FRACT(s.frameperiod)); |
| 495 | tprintf(", framelines=%d", s.framelines); |
| 496 | } |
| 497 | tprints("}"); |
| 498 | } |
| 499 | return 1; |
| 500 | } |
| 501 | |
| 502 | #include "xlat/v4l2_input_types.h" |
| 503 | |
| 504 | static int |
| 505 | print_v4l2_input(struct tcb *tcp, const long arg) |
| 506 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 507 | struct_v4l2_input i; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 508 | |
| 509 | if (entering(tcp)) { |
| 510 | tprints(", "); |
| 511 | if (umove_or_printaddr(tcp, arg, &i)) |
| 512 | return RVAL_DECODED | 1; |
| 513 | tprintf("{index=%u", i.index); |
| 514 | } else { |
| 515 | if (!syserror(tcp) && !umove(tcp, arg, &i)) { |
Dmitry V. Levin | 1de59cf | 2015-01-26 02:45:09 +0000 | [diff] [blame] | 516 | tprints(", name="); |
| 517 | print_quoted_string((const char *) i.name, |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 518 | sizeof(i.name), |
| 519 | QUOTE_0_TERMINATED); |
Dmitry V. Levin | 1de59cf | 2015-01-26 02:45:09 +0000 | [diff] [blame] | 520 | tprints(", type="); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 521 | printxval(v4l2_input_types, i.type, |
| 522 | "V4L2_INPUT_TYPE_???"); |
| 523 | } |
| 524 | tprints("}"); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 525 | } |
| 526 | return 1; |
| 527 | } |
| 528 | |
| 529 | #include "xlat/v4l2_control_ids.h" |
| 530 | |
| 531 | static int |
| 532 | print_v4l2_control(struct tcb *tcp, const long arg, const bool is_get) |
| 533 | { |
| 534 | struct v4l2_control c; |
| 535 | |
| 536 | if (entering(tcp)) { |
| 537 | tprints(", "); |
| 538 | if (umove_or_printaddr(tcp, arg, &c)) |
| 539 | return RVAL_DECODED | 1; |
| 540 | tprints("{id="); |
| 541 | printxval(v4l2_control_ids, c.id, "V4L2_CID_???"); |
| 542 | if (!is_get) |
| 543 | tprintf(", value=%d", c.value); |
| 544 | return 0; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 545 | } |
| 546 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 547 | if (!syserror(tcp) && !umove(tcp, arg, &c)) { |
| 548 | tprints(is_get ? ", " : " => "); |
| 549 | tprintf("value=%d", c.value); |
| 550 | } |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 551 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 552 | tprints("}"); |
| 553 | return 1; |
| 554 | } |
| 555 | |
| 556 | #include "xlat/v4l2_control_types.h" |
| 557 | #include "xlat/v4l2_control_flags.h" |
| 558 | |
| 559 | static int |
| 560 | print_v4l2_queryctrl(struct tcb *tcp, const long arg) |
| 561 | { |
| 562 | struct v4l2_queryctrl c; |
| 563 | |
| 564 | if (entering(tcp)) { |
| 565 | tprints(", "); |
| 566 | if (umove_or_printaddr(tcp, arg, &c)) |
| 567 | return RVAL_DECODED | 1; |
| 568 | tprints("{id="); |
| 569 | } else { |
| 570 | if (syserror(tcp) || umove(tcp, arg, &c) < 0) { |
| 571 | tprints("}"); |
| 572 | return 1; |
| 573 | } |
| 574 | if (tcp->auxstr) |
| 575 | tprints(" => "); |
| 576 | } |
| 577 | |
| 578 | if (entering(tcp) || tcp->auxstr) { |
| 579 | #ifdef V4L2_CTRL_FLAG_NEXT_CTRL |
| 580 | tcp->auxstr = (c.id & V4L2_CTRL_FLAG_NEXT_CTRL) ? "" : NULL; |
| 581 | if (tcp->auxstr) { |
| 582 | tprints("V4L2_CTRL_FLAG_NEXT_CTRL|"); |
| 583 | c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL; |
| 584 | } |
| 585 | #endif |
| 586 | printxval(v4l2_control_ids, c.id, "V4L2_CID_???"); |
| 587 | } |
| 588 | |
| 589 | if (exiting(tcp)) { |
| 590 | tprints(", type="); |
| 591 | printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???"); |
| 592 | tprints(", name="); |
| 593 | print_quoted_string((const char *) c.name, |
| 594 | sizeof(c.name), |
| 595 | QUOTE_0_TERMINATED); |
| 596 | tprintf(", minimum=%d, maximum=%d, step=%d" |
| 597 | ", default_value=%d, flags=", |
| 598 | c.minimum, c.maximum, c.step, c.default_value); |
| 599 | printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???"); |
| 600 | tprints("}"); |
| 601 | } |
| 602 | return 1; |
| 603 | } |
| 604 | |
| 605 | static int |
| 606 | print_v4l2_cropcap(struct tcb *tcp, const long arg) |
| 607 | { |
| 608 | struct v4l2_cropcap c; |
| 609 | |
| 610 | if (entering(tcp)) { |
| 611 | tprints(", "); |
| 612 | if (umove_or_printaddr(tcp, arg, &c)) |
| 613 | return RVAL_DECODED | 1; |
| 614 | tprints("{type="); |
| 615 | printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???"); |
| 616 | return 0; |
| 617 | } |
| 618 | if (!syserror(tcp) && !umove(tcp, arg, &c)) { |
| 619 | tprintf(", bounds=" FMT_RECT |
| 620 | ", defrect=" FMT_RECT |
| 621 | ", pixelaspect=" FMT_FRACT, |
| 622 | ARGS_RECT(c.bounds), |
| 623 | ARGS_RECT(c.defrect), |
| 624 | ARGS_FRACT(c.pixelaspect)); |
| 625 | } |
| 626 | tprints("}"); |
| 627 | return 1; |
| 628 | } |
| 629 | |
| 630 | static int |
| 631 | print_v4l2_crop(struct tcb *tcp, const long arg, const bool is_get) |
| 632 | { |
| 633 | struct v4l2_crop c; |
| 634 | |
| 635 | if (entering(tcp)) { |
| 636 | tprints(", "); |
| 637 | if (umove_or_printaddr(tcp, arg, &c)) |
| 638 | return RVAL_DECODED | 1; |
| 639 | tprints("{type="); |
| 640 | printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???"); |
| 641 | if (is_get) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 642 | return 0; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 643 | tprintf(", c=" FMT_RECT, ARGS_RECT(c.c)); |
| 644 | } else { |
| 645 | if (!syserror(tcp) && !umove(tcp, arg, &c)) |
| 646 | tprintf(", c=" FMT_RECT, ARGS_RECT(c.c)); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 647 | } |
| 648 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 649 | tprints("}"); |
| 650 | return RVAL_DECODED | 1; |
| 651 | } |
| 652 | |
| 653 | #ifdef VIDIOC_S_EXT_CTRLS |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 654 | static bool |
| 655 | print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 656 | { |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 657 | const struct_v4l2_ext_control *p = elem_buf; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 658 | |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 659 | tprints("{id="); |
| 660 | printxval(v4l2_control_ids, p->id, "V4L2_CID_???"); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 661 | # if HAVE_DECL_V4L2_CTRL_TYPE_STRING |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 662 | tprintf(", size=%u", p->size); |
| 663 | if (p->size > 0) { |
| 664 | tprints(", string="); |
| 665 | printstr(tcp, (long) p->string, p->size); |
| 666 | } else |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 667 | # endif |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 668 | tprintf(", value=%d, value64=%lld", p->value, |
| 669 | (long long) p->value64); |
| 670 | tprints("}"); |
| 671 | |
| 672 | return true; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | #include "xlat/v4l2_control_classes.h" |
| 676 | |
| 677 | static int |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 678 | umoven_or_printaddr_ignore_syserror(struct tcb *tcp, const long addr, |
| 679 | const unsigned int len, void *our_addr) |
| 680 | { |
Dmitry V. Levin | 484326d | 2016-06-11 01:28:21 +0000 | [diff] [blame] | 681 | if (!addr || umoven(tcp, addr, len, our_addr) < 0) { |
| 682 | printaddr(addr); |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 683 | return -1; |
| 684 | } |
| 685 | return 0; |
| 686 | } |
| 687 | |
| 688 | static int |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 689 | print_v4l2_ext_controls(struct tcb *tcp, const long arg, const bool is_get) |
| 690 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 691 | struct_v4l2_ext_controls c; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 692 | |
| 693 | if (entering(tcp)) { |
| 694 | tprints(", "); |
| 695 | if (umove_or_printaddr(tcp, arg, &c)) |
| 696 | return RVAL_DECODED | 1; |
| 697 | tprints("{ctrl_class="); |
| 698 | printxval(v4l2_control_classes, c.ctrl_class, |
| 699 | "V4L2_CTRL_CLASS_???"); |
| 700 | tprintf(", count=%u", c.count); |
| 701 | if (!c.count) { |
| 702 | tprints("}"); |
| 703 | return RVAL_DECODED | 1; |
| 704 | } |
| 705 | if (is_get) |
| 706 | return 0; |
| 707 | tprints(", "); |
| 708 | } else { |
| 709 | if (umove(tcp, arg, &c) < 0) { |
| 710 | tprints("}"); |
| 711 | return 1; |
| 712 | } |
| 713 | tprints(is_get ? ", " : " => "); |
| 714 | } |
| 715 | |
| 716 | tprints("controls="); |
Dmitry V. Levin | 17d1a16 | 2016-05-07 23:15:36 +0000 | [diff] [blame] | 717 | struct_v4l2_ext_control ctrl; |
| 718 | bool fail = !print_array(tcp, (unsigned long) c.controls, c.count, |
| 719 | &ctrl, sizeof(ctrl), |
| 720 | umoven_or_printaddr_ignore_syserror, |
| 721 | print_v4l2_ext_control, 0); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 722 | |
| 723 | if (exiting(tcp) && syserror(tcp)) |
| 724 | tprintf(", error_idx=%u", c.error_idx); |
| 725 | |
| 726 | if (exiting(tcp) || fail) { |
| 727 | tprints("}"); |
| 728 | return RVAL_DECODED | 1; |
| 729 | } |
| 730 | return 1; |
| 731 | } |
| 732 | #endif /* VIDIOC_S_EXT_CTRLS */ |
| 733 | |
| 734 | #ifdef VIDIOC_ENUM_FRAMESIZES |
| 735 | # include "xlat/v4l2_framesize_types.h" |
| 736 | |
| 737 | static int |
| 738 | print_v4l2_frmsizeenum(struct tcb *tcp, const long arg) |
| 739 | { |
| 740 | struct v4l2_frmsizeenum s; |
| 741 | |
| 742 | if (entering(tcp)) { |
| 743 | tprints(", "); |
| 744 | if (umove_or_printaddr(tcp, arg, &s)) |
| 745 | return RVAL_DECODED | 1; |
| 746 | tprintf("{index=%u, pixel_format=", s.index); |
| 747 | print_pixelformat(s.pixel_format); |
| 748 | return 0; |
| 749 | } |
| 750 | |
| 751 | if (!syserror(tcp) && !umove(tcp, arg, &s)) { |
| 752 | tprints(", type="); |
| 753 | printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???"); |
| 754 | switch (s.type) { |
| 755 | case V4L2_FRMSIZE_TYPE_DISCRETE: |
| 756 | tprintf(", discrete={width=%u, height=%u}", |
| 757 | s.discrete.width, s.discrete.height); |
| 758 | break; |
| 759 | case V4L2_FRMSIZE_TYPE_STEPWISE: |
| 760 | tprintf(", stepwise={min_width=%u, max_width=%u, " |
| 761 | "step_width=%u, min_height=%u, max_height=%u, " |
| 762 | "step_height=%u}", |
| 763 | s.stepwise.min_width, s.stepwise.max_width, |
| 764 | s.stepwise.step_width, s.stepwise.min_height, |
| 765 | s.stepwise.max_height, s.stepwise.step_height); |
| 766 | break; |
| 767 | } |
| 768 | } |
| 769 | tprints("}"); |
| 770 | return 1; |
| 771 | } |
| 772 | #endif /* VIDIOC_ENUM_FRAMESIZES */ |
| 773 | |
Dmitry V. Levin | 197db57 | 2015-01-09 04:53:19 +0000 | [diff] [blame] | 774 | #ifdef VIDIOC_ENUM_FRAMEINTERVALS |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 775 | # include "xlat/v4l2_frameinterval_types.h" |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 776 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 777 | static int |
| 778 | print_v4l2_frmivalenum(struct tcb *tcp, const long arg) |
| 779 | { |
| 780 | struct v4l2_frmivalenum f; |
| 781 | |
| 782 | if (entering(tcp)) { |
| 783 | tprints(", "); |
| 784 | if (umove_or_printaddr(tcp, arg, &f)) |
| 785 | return RVAL_DECODED | 1; |
| 786 | tprintf("{index=%u, pixel_format=", f.index); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 787 | print_pixelformat(f.pixel_format); |
| 788 | tprintf(", width=%u, height=%u", f.width, f.height); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 789 | return 0; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 790 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 791 | if (!syserror(tcp) && !umove(tcp, arg, &f)) { |
| 792 | tprints(", type="); |
| 793 | printxval(v4l2_frameinterval_types, f.type, |
| 794 | "V4L2_FRMIVAL_TYPE_???"); |
| 795 | switch (f.type) { |
| 796 | case V4L2_FRMIVAL_TYPE_DISCRETE: |
| 797 | tprintf(", discrete=" FMT_FRACT, |
| 798 | ARGS_FRACT(f.discrete)); |
| 799 | break; |
| 800 | case V4L2_FRMIVAL_TYPE_STEPWISE: |
| 801 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: |
| 802 | tprintf(", stepwise={min=" FMT_FRACT ", max=" |
| 803 | FMT_FRACT ", step=" FMT_FRACT "}", |
| 804 | ARGS_FRACT(f.stepwise.min), |
| 805 | ARGS_FRACT(f.stepwise.max), |
| 806 | ARGS_FRACT(f.stepwise.step)); |
| 807 | break; |
| 808 | } |
| 809 | } |
| 810 | tprints("}"); |
| 811 | return 1; |
| 812 | } |
Dmitry V. Levin | 197db57 | 2015-01-09 04:53:19 +0000 | [diff] [blame] | 813 | #endif /* VIDIOC_ENUM_FRAMEINTERVALS */ |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 814 | |
Dmitry V. Levin | fffe50d | 2015-08-26 11:55:05 +0000 | [diff] [blame] | 815 | #ifdef VIDIOC_CREATE_BUFS |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 816 | static int |
| 817 | print_v4l2_create_buffers(struct tcb *tcp, const long arg) |
| 818 | { |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 819 | struct_v4l2_create_buffers b; |
Philippe De Muyter | 6779e71 | 2015-04-18 15:06:43 +0200 | [diff] [blame] | 820 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 821 | if (entering(tcp)) { |
| 822 | tprints(", "); |
| 823 | if (umove_or_printaddr(tcp, arg, &b)) |
| 824 | return RVAL_DECODED | 1; |
| 825 | tprintf("{count=%u, memory=", b.count); |
| 826 | printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???"); |
| 827 | tprints(", format={type="); |
| 828 | printxval(v4l2_buf_types, b.format.type, |
| 829 | "V4L2_BUF_TYPE_???"); |
| 830 | print_v4l2_format_fmt(", ", |
Dmitry V. Levin | 1e56814 | 2016-05-03 22:30:41 +0000 | [diff] [blame] | 831 | (struct_v4l2_format *) &b.format); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 832 | tprints("}}"); |
| 833 | return 0; |
| 834 | } else { |
| 835 | static const char fmt[] = "{index=%u, count=%u}"; |
| 836 | static char outstr[sizeof(fmt) + sizeof(int) * 6]; |
Philippe De Muyter | 6779e71 | 2015-04-18 15:06:43 +0200 | [diff] [blame] | 837 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 838 | if (syserror(tcp) || umove(tcp, arg, &b) < 0) |
| 839 | return 1; |
| 840 | sprintf(outstr, fmt, b.index, b.count); |
| 841 | tcp->auxstr = outstr; |
| 842 | return 1 + RVAL_STR; |
Philippe De Muyter | 6779e71 | 2015-04-18 15:06:43 +0200 | [diff] [blame] | 843 | } |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 844 | } |
Dmitry V. Levin | fffe50d | 2015-08-26 11:55:05 +0000 | [diff] [blame] | 845 | #endif /* VIDIOC_CREATE_BUFS */ |
Philippe De Muyter | 6779e71 | 2015-04-18 15:06:43 +0200 | [diff] [blame] | 846 | |
Dmitry V. Levin | a8fce09 | 2016-05-21 22:53:06 +0000 | [diff] [blame] | 847 | MPERS_PRINTER_DECL(int, v4l2_ioctl, |
| 848 | struct tcb *tcp, const unsigned int code, const long arg) |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 849 | { |
| 850 | if (!verbose(tcp)) |
| 851 | return RVAL_DECODED; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 852 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 853 | switch (code) { |
| 854 | case VIDIOC_QUERYCAP: /* R */ |
| 855 | return print_v4l2_capability(tcp, arg); |
| 856 | |
| 857 | case VIDIOC_ENUM_FMT: /* RW */ |
| 858 | return print_v4l2_fmtdesc(tcp, arg); |
| 859 | |
| 860 | case VIDIOC_G_FMT: /* RW */ |
| 861 | case VIDIOC_S_FMT: /* RW */ |
| 862 | case VIDIOC_TRY_FMT: /* RW */ |
| 863 | return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT); |
| 864 | |
| 865 | case VIDIOC_REQBUFS: /* RW */ |
| 866 | return print_v4l2_requestbuffers(tcp, arg); |
| 867 | |
| 868 | case VIDIOC_QUERYBUF: /* RW */ |
| 869 | case VIDIOC_QBUF: /* RW */ |
| 870 | case VIDIOC_DQBUF: /* RW */ |
| 871 | return print_v4l2_buffer(tcp, code, arg); |
| 872 | |
| 873 | case VIDIOC_G_FBUF: /* R */ |
| 874 | if (entering(tcp)) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 875 | return 0; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 876 | /* fall through */ |
| 877 | case VIDIOC_S_FBUF: /* W */ |
| 878 | return print_v4l2_framebuffer(tcp, arg); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 879 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 880 | case VIDIOC_STREAMON: /* W */ |
| 881 | case VIDIOC_STREAMOFF: /* W */ |
| 882 | return print_v4l2_buf_type(tcp, arg); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 883 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 884 | case VIDIOC_G_PARM: /* RW */ |
| 885 | case VIDIOC_S_PARM: /* RW */ |
| 886 | return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 887 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 888 | case VIDIOC_G_STD: /* R */ |
| 889 | if (entering(tcp)) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 890 | return 0; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 891 | /* fall through */ |
| 892 | case VIDIOC_S_STD: /* W */ |
| 893 | tprints(", "); |
| 894 | printnum_int64(tcp, arg, "%#" PRIx64); |
| 895 | return RVAL_DECODED | 1; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 896 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 897 | case VIDIOC_ENUMSTD: /* RW */ |
| 898 | return print_v4l2_standard(tcp, arg); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 899 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 900 | case VIDIOC_ENUMINPUT: /* RW */ |
| 901 | return print_v4l2_input(tcp, arg); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 902 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 903 | case VIDIOC_G_CTRL: /* RW */ |
| 904 | case VIDIOC_S_CTRL: /* RW */ |
| 905 | return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL); |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 906 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 907 | case VIDIOC_QUERYCTRL: /* RW */ |
| 908 | return print_v4l2_queryctrl(tcp, arg); |
| 909 | |
| 910 | case VIDIOC_G_INPUT: /* R */ |
| 911 | if (entering(tcp)) |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 912 | return 0; |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 913 | /* fall through */ |
| 914 | case VIDIOC_S_INPUT: /* RW */ |
| 915 | tprints(", "); |
| 916 | printnum_int(tcp, arg, "%u"); |
| 917 | return RVAL_DECODED | 1; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 918 | |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 919 | case VIDIOC_CROPCAP: /* RW */ |
| 920 | return print_v4l2_cropcap(tcp, arg); |
| 921 | |
| 922 | case VIDIOC_G_CROP: /* RW */ |
| 923 | case VIDIOC_S_CROP: /* W */ |
| 924 | return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP); |
| 925 | |
| 926 | #ifdef VIDIOC_S_EXT_CTRLS |
| 927 | case VIDIOC_S_EXT_CTRLS: /* RW */ |
| 928 | case VIDIOC_TRY_EXT_CTRLS: /* RW */ |
| 929 | case VIDIOC_G_EXT_CTRLS: /* RW */ |
| 930 | return print_v4l2_ext_controls(tcp, arg, |
| 931 | code == VIDIOC_G_EXT_CTRLS); |
| 932 | #endif /* VIDIOC_S_EXT_CTRLS */ |
| 933 | |
| 934 | #ifdef VIDIOC_ENUM_FRAMESIZES |
| 935 | case VIDIOC_ENUM_FRAMESIZES: /* RW */ |
| 936 | return print_v4l2_frmsizeenum(tcp, arg); |
| 937 | #endif /* VIDIOC_ENUM_FRAMESIZES */ |
| 938 | |
| 939 | #ifdef VIDIOC_ENUM_FRAMEINTERVALS |
| 940 | case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */ |
| 941 | return print_v4l2_frmivalenum(tcp, arg); |
| 942 | #endif /* VIDIOC_ENUM_FRAMEINTERVALS */ |
| 943 | |
| 944 | #ifdef VIDIOC_CREATE_BUFS |
| 945 | case VIDIOC_CREATE_BUFS: /* RW */ |
| 946 | return print_v4l2_create_buffers(tcp, arg); |
| 947 | #endif /* VIDIOC_CREATE_BUFS */ |
| 948 | |
| 949 | default: |
| 950 | return RVAL_DECODED; |
Philippe De Muyter | 0cc9614 | 2014-11-03 21:27:40 +0100 | [diff] [blame] | 951 | } |
| 952 | } |