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 * Copyright (c) 2014-2017 The strace developers.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include DEF_MPERS_TYPE(struct_v4l2_buffer)
34 #include DEF_MPERS_TYPE(struct_v4l2_clip)
35 #include DEF_MPERS_TYPE(struct_v4l2_create_buffers)
36 #include DEF_MPERS_TYPE(struct_v4l2_ext_control)
37 #include DEF_MPERS_TYPE(struct_v4l2_ext_controls)
38 #include DEF_MPERS_TYPE(struct_v4l2_format)
39 #include DEF_MPERS_TYPE(struct_v4l2_framebuffer)
40 #include DEF_MPERS_TYPE(struct_v4l2_input)
41 #include DEF_MPERS_TYPE(struct_v4l2_standard)
44 #include <linux/ioctl.h>
45 #include <linux/types.h>
46 #include <linux/videodev2.h>
48 typedef struct v4l2_buffer struct_v4l2_buffer;
49 typedef struct v4l2_clip struct_v4l2_clip;
50 typedef struct v4l2_create_buffers struct_v4l2_create_buffers;
51 typedef struct v4l2_ext_control struct_v4l2_ext_control;
52 typedef struct v4l2_ext_controls struct_v4l2_ext_controls;
53 typedef struct v4l2_format struct_v4l2_format;
54 typedef struct v4l2_framebuffer struct_v4l2_framebuffer;
55 typedef struct v4l2_input struct_v4l2_input;
56 typedef struct v4l2_standard struct_v4l2_standard;
60 #include "print_fields.h"
62 /* some historical constants */
63 #ifndef V4L2_CID_HCENTER
64 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
66 #ifndef V4L2_CID_VCENTER
67 #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
69 #ifndef V4L2_CID_BAND_STOP_FILTER
70 #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
73 #define FMT_FRACT "%u/%u"
74 #define ARGS_FRACT(x) ((x).numerator), ((x).denominator)
76 #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}"
77 #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height
80 print_pixelformat(uint32_t fourcc)
84 unsigned char cc[sizeof(uint32_t)];
88 (unsigned char) (fourcc >> 24),
89 (unsigned char) (fourcc >> 16),
90 (unsigned char) (fourcc >> 8),
91 (unsigned char) fourcc
99 tprints("v4l2_fourcc(");
100 for (i = 0; i < sizeof(u.cc); ++i) {
101 unsigned char c = u.cc[i];
105 if (c == '\'' || c == '\\') {
114 } else if (c >= ' ' && c <= 0x7e) {
127 "0123456789abcdef"[c >> 4],
128 "0123456789abcdef"[c & 0xf],
138 #include "xlat/v4l2_device_capabilities_flags.h"
141 print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg)
143 struct v4l2_capability caps;
148 if (umove_or_printaddr(tcp, arg, &caps))
149 return RVAL_IOCTL_DECODED;
150 PRINT_FIELD_CSTRING("{", caps, driver);
151 PRINT_FIELD_CSTRING(", ", caps, card);
152 PRINT_FIELD_CSTRING(", ", caps, bus_info);
153 tprintf(", version=%u.%u.%u, capabilities=",
154 (caps.version >> 16) & 0xFF,
155 (caps.version >> 8) & 0xFF,
156 caps.version & 0xFF);
157 printflags(v4l2_device_capabilities_flags, caps.capabilities,
159 #ifdef V4L2_CAP_DEVICE_CAPS
160 tprints(", device_caps=");
161 printflags(v4l2_device_capabilities_flags, caps.device_caps,
165 return RVAL_IOCTL_DECODED;
168 #include "xlat/v4l2_buf_types.h"
169 #include "xlat/v4l2_format_description_flags.h"
172 print_v4l2_fmtdesc(struct tcb *const tcp, const kernel_ulong_t arg)
174 struct v4l2_fmtdesc f;
178 if (umove_or_printaddr(tcp, arg, &f))
179 return RVAL_IOCTL_DECODED;
180 tprintf("{index=%u, type=", f.index);
181 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
185 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
187 printflags(v4l2_format_description_flags, f.flags,
188 "V4L2_FMT_FLAG_???");
189 PRINT_FIELD_CSTRING(", ", f, description);
190 tprints(", pixelformat=");
191 print_pixelformat(f.pixelformat);
194 return RVAL_IOCTL_DECODED;
197 #include "xlat/v4l2_fields.h"
198 #include "xlat/v4l2_colorspaces.h"
199 #include "xlat/v4l2_vbi_flags.h"
200 #include "xlat/v4l2_sliced_flags.h"
203 print_v4l2_clip(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
205 const struct_v4l2_clip *p = elem_buf;
206 tprintf(FMT_RECT, ARGS_RECT(p->c));
211 print_v4l2_format_fmt(struct tcb *const tcp, const char *prefix,
212 const struct_v4l2_format *f)
216 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
217 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
219 tprintf("fmt.pix={width=%u, height=%u, pixelformat=",
220 f->fmt.pix.width, f->fmt.pix.height);
221 print_pixelformat(f->fmt.pix.pixelformat);
223 printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???");
224 tprintf(", bytesperline=%u, sizeimage=%u, colorspace=",
225 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
226 printxval(v4l2_colorspaces, f->fmt.pix.colorspace,
227 "V4L2_COLORSPACE_???");
230 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
231 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
232 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: {
236 tprintf("fmt.pix_mp={width=%u, height=%u, pixelformat=",
237 f->fmt.pix_mp.width, f->fmt.pix_mp.height);
238 print_pixelformat(f->fmt.pix_mp.pixelformat);
240 printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???");
241 tprints(", colorspace=");
242 printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace,
243 "V4L2_COLORSPACE_???");
244 tprints(", plane_fmt=[");
245 max = f->fmt.pix_mp.num_planes;
246 if (max > VIDEO_MAX_PLANES)
247 max = VIDEO_MAX_PLANES;
248 for (i = 0; i < max; i++) {
251 tprintf("{sizeimage=%u, bytesperline=%u}",
252 f->fmt.pix_mp.plane_fmt[i].sizeimage,
253 f->fmt.pix_mp.plane_fmt[i].bytesperline);
255 tprintf("], num_planes=%u}",
256 (unsigned) f->fmt.pix_mp.num_planes);
260 /* OUTPUT_OVERLAY since Linux v2.6.22-rc1~1118^2~179 */
261 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
262 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
264 case V4L2_BUF_TYPE_VIDEO_OVERLAY: {
265 struct_v4l2_clip clip;
267 tprintf("fmt.win={left=%d, top=%d, width=%u, height=%u, field=",
268 ARGS_RECT(f->fmt.win.w));
269 printxval(v4l2_fields, f->fmt.win.field, "V4L2_FIELD_???");
270 tprintf(", chromakey=%#x, clips=", f->fmt.win.chromakey);
271 ret = print_array(tcp, ptr_to_kulong(f->fmt.win.clips),
272 f->fmt.win.clipcount, &clip, sizeof(clip),
273 umoven_or_printaddr, print_v4l2_clip, 0);
274 tprintf(", clipcount=%u, bitmap=", f->fmt.win.clipcount);
275 printaddr(ptr_to_kulong(f->fmt.win.bitmap));
276 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA
277 tprintf(", global_alpha=%#x", f->fmt.win.global_alpha);
282 case V4L2_BUF_TYPE_VBI_CAPTURE:
283 case V4L2_BUF_TYPE_VBI_OUTPUT:
285 tprintf("fmt.vbi={sampling_rate=%u, offset=%u, "
286 "samples_per_line=%u, sample_format=",
287 f->fmt.vbi.sampling_rate, f->fmt.vbi.offset,
288 f->fmt.vbi.samples_per_line);
289 print_pixelformat(f->fmt.vbi.sample_format);
290 tprintf(", start=[%u, %u], count=[%u, %u], ",
291 f->fmt.vbi.start[0], f->fmt.vbi.start[1],
292 f->fmt.vbi.count[0], f->fmt.vbi.count[1]);
294 printxval(v4l2_vbi_flags, f->fmt.vbi.flags, "V4L2_VBI_???");
297 /* both since Linux v2.6.14-rc2~64 */
298 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
299 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
300 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: {
304 tprints("fmt.sliced={service_set=");
305 printxval(v4l2_sliced_flags, f->fmt.sliced.service_set,
307 tprintf(", io_size=%u, service_lines=[",
308 f->fmt.sliced.io_size);
309 for (i = 0; i < ARRAY_SIZE(f->fmt.sliced.service_lines); i++) {
314 j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
319 f->fmt.sliced.service_lines[i][j]);
327 /* since Linux v4.4-rc1~118^2~14 */
328 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT
329 case V4L2_BUF_TYPE_SDR_OUTPUT:
331 /* since Linux v3.15-rc1~85^2~213 */
332 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
333 case V4L2_BUF_TYPE_SDR_CAPTURE:
335 tprints("fmt.sdr={pixelformat=");
336 print_pixelformat(f->fmt.sdr.pixelformat);
337 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
338 tprintf(", buffersize=%u",
339 f->fmt.sdr.buffersize);
349 print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg,
352 struct_v4l2_format f;
356 if (umove_or_printaddr(tcp, arg, &f))
357 return RVAL_IOCTL_DECODED;
359 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
362 if (!print_v4l2_format_fmt(tcp, ", ", &f)) {
364 return RVAL_IOCTL_DECODED;
370 if (!syserror(tcp) && !umove(tcp, arg, &f))
371 print_v4l2_format_fmt(tcp, is_get ? ", " : " => ", &f);
375 return RVAL_IOCTL_DECODED;
378 #include "xlat/v4l2_memories.h"
381 print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg)
383 struct v4l2_requestbuffers reqbufs;
388 if (umove_or_printaddr(tcp, arg, &reqbufs))
389 return RVAL_IOCTL_DECODED;
392 printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???");
393 tprints(", memory=");
394 printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???");
395 tprintf(", count=%u", reqbufs.count);
400 if (!syserror(tcp)) {
403 if (!umove(tcp, arg, &reqbufs))
404 tprintf("%u", reqbufs.count);
411 return RVAL_IOCTL_DECODED;
414 #include "xlat/v4l2_buf_flags.h"
417 print_v4l2_buffer(struct tcb *const tcp, const unsigned int code,
418 const kernel_ulong_t arg)
420 struct_v4l2_buffer b;
424 if (umove_or_printaddr(tcp, arg, &b))
425 return RVAL_IOCTL_DECODED;
427 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
428 if (code != VIDIOC_DQBUF)
429 tprintf(", index=%u", b.index);
434 if (!syserror(tcp) && !umove(tcp, arg, &b)) {
435 if (code == VIDIOC_DQBUF)
436 tprintf(", index=%u", b.index);
437 tprints(", memory=");
438 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
440 if (b.memory == V4L2_MEMORY_MMAP) {
441 tprintf(", m.offset=%#x", b.m.offset);
442 } else if (b.memory == V4L2_MEMORY_USERPTR) {
443 tprints(", m.userptr=");
444 printaddr(b.m.userptr);
447 tprintf(", length=%u, bytesused=%u, flags=",
448 b.length, b.bytesused);
449 printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
450 if (code == VIDIOC_DQBUF) {
451 tprints(", timestamp = ");
452 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
459 return RVAL_IOCTL_DECODED;
463 print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg)
465 struct_v4l2_framebuffer b;
468 if (!umove_or_printaddr(tcp, arg, &b)) {
469 tprintf("{capability=%#x, flags=%#x, base=",
470 b.capability, b.flags);
471 printaddr(ptr_to_kulong(b.base));
475 return RVAL_IOCTL_DECODED;
479 print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg)
484 if (!umove_or_printaddr(tcp, arg, &type)) {
486 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
489 return RVAL_IOCTL_DECODED;
492 #include "xlat/v4l2_streaming_capabilities.h"
493 #include "xlat/v4l2_capture_modes.h"
496 print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg,
499 struct v4l2_streamparm s;
503 if (umove_or_printaddr(tcp, arg, &s))
504 return RVAL_IOCTL_DECODED;
506 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
508 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
509 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
516 return RVAL_IOCTL_DECODED;
519 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
521 return RVAL_IOCTL_DECODED;
523 tprints(is_get ? ", " : " => ");
526 if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
527 tprints("parm.capture={capability=");
528 printflags(v4l2_streaming_capabilities,
529 s.parm.capture.capability, "V4L2_CAP_???");
531 tprints(", capturemode=");
532 printflags(v4l2_capture_modes,
533 s.parm.capture.capturemode, "V4L2_MODE_???");
535 tprintf(", timeperframe=" FMT_FRACT,
536 ARGS_FRACT(s.parm.capture.timeperframe));
538 tprintf(", extendedmode=%u, readbuffers=%u}",
539 s.parm.capture.extendedmode,
540 s.parm.capture.readbuffers);
542 tprints("parm.output={capability=");
543 printflags(v4l2_streaming_capabilities,
544 s.parm.output.capability, "V4L2_CAP_???");
546 tprintf(", outputmode=%u", s.parm.output.outputmode);
548 tprintf(", timeperframe=" FMT_FRACT,
549 ARGS_FRACT(s.parm.output.timeperframe));
551 tprintf(", extendedmode=%u, writebuffers=%u}",
552 s.parm.output.extendedmode,
553 s.parm.output.writebuffers);
559 return RVAL_IOCTL_DECODED;
564 print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg)
566 struct_v4l2_standard s;
570 if (umove_or_printaddr(tcp, arg, &s))
571 return RVAL_IOCTL_DECODED;
572 tprintf("{index=%u", s.index);
577 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
578 PRINT_FIELD_CSTRING(", ", s, name);
579 tprintf(", frameperiod=" FMT_FRACT,
580 ARGS_FRACT(s.frameperiod));
581 tprintf(", framelines=%d", s.framelines);
586 return RVAL_IOCTL_DECODED;
589 #include "xlat/v4l2_input_types.h"
592 print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
598 if (umove_or_printaddr(tcp, arg, &i))
599 return RVAL_IOCTL_DECODED;
600 tprintf("{index=%u", i.index);
605 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
606 PRINT_FIELD_CSTRING(", ", i, name);
608 printxval(v4l2_input_types, i.type, "V4L2_INPUT_TYPE_???");
613 return RVAL_IOCTL_DECODED;
616 #include "xlat/v4l2_control_ids.h"
619 print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg,
622 struct v4l2_control c;
626 if (umove_or_printaddr(tcp, arg, &c))
627 return RVAL_IOCTL_DECODED;
629 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
631 tprintf(", value=%d", c.value);
635 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
636 tprints(is_get ? ", " : " => ");
637 tprintf("value=%d", c.value);
642 return RVAL_IOCTL_DECODED;
645 #include "xlat/v4l2_tuner_types.h"
646 #include "xlat/v4l2_tuner_capabilities.h"
647 #include "xlat/v4l2_tuner_rxsubchanses.h"
648 #include "xlat/v4l2_tuner_audmodes.h"
651 print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg,
657 if (umove_or_printaddr(tcp, arg, &c))
658 return RVAL_IOCTL_DECODED;
659 tprintf("{index=%u", c.index);
664 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
666 return RVAL_IOCTL_DECODED;
668 tprints(is_get ? ", " : " => ");
671 PRINT_FIELD_CSTRING("", c, name);
673 printxval(v4l2_tuner_types, c.type, "V4L2_TUNER_TYPE_???");
674 tprints(", capability=");
675 printxval(v4l2_tuner_capabilities, c.capability,
676 "V4L2_TUNER_CAP_???");
677 tprintf(", rangelow=%u, rangehigh=%u, rxsubchans=",
678 c.rangelow, c.rangehigh);
679 printxval(v4l2_tuner_rxsubchanses, c.rxsubchans,
680 "V4L2_TUNER_SUB_???");
681 tprints(", audmode=");
682 printxval(v4l2_tuner_audmodes, c.audmode,
683 "V4L2_TUNER_MODE_???");
684 tprintf(", signal=%d, afc=%d", c.signal, c.afc);
690 return RVAL_IOCTL_DECODED;
694 #include "xlat/v4l2_control_types.h"
695 #include "xlat/v4l2_control_flags.h"
698 print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg)
700 struct v4l2_queryctrl c;
704 if (umove_or_printaddr(tcp, arg, &c))
705 return RVAL_IOCTL_DECODED;
708 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
710 return RVAL_IOCTL_DECODED;
712 if (get_tcb_priv_ulong(tcp))
716 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
717 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
718 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
719 set_tcb_priv_ulong(tcp, next);
721 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
722 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
725 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
730 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
731 PRINT_FIELD_CSTRING(", ", c, name);
732 tprintf(", minimum=%d, maximum=%d, step=%d"
733 ", default_value=%d, flags=",
734 c.minimum, c.maximum, c.step, c.default_value);
735 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
738 return entering(tcp) ? 0 : RVAL_IOCTL_DECODED;
742 print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg)
744 struct v4l2_cropcap c;
748 if (umove_or_printaddr(tcp, arg, &c))
749 return RVAL_IOCTL_DECODED;
751 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
756 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
757 tprintf(", bounds=" FMT_RECT
758 ", defrect=" FMT_RECT
759 ", pixelaspect=" FMT_FRACT,
761 ARGS_RECT(c.defrect),
762 ARGS_FRACT(c.pixelaspect));
767 return RVAL_IOCTL_DECODED;
771 print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg,
778 if (umove_or_printaddr(tcp, arg, &c))
779 return RVAL_IOCTL_DECODED;
781 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
784 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
786 if (!syserror(tcp) && !umove(tcp, arg, &c))
787 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
792 return RVAL_IOCTL_DECODED;
795 #ifdef VIDIOC_S_EXT_CTRLS
797 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
799 const struct_v4l2_ext_control *p = elem_buf;
802 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
803 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
804 tprintf(", size=%u", p->size);
806 tprints(", string=");
807 printstrn(tcp, ptr_to_kulong(p->string), p->size);
810 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
816 #include "xlat/v4l2_control_classes.h"
819 print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg,
822 struct_v4l2_ext_controls c;
826 if (umove_or_printaddr(tcp, arg, &c))
827 return RVAL_IOCTL_DECODED;
828 tprints("{ctrl_class=");
829 printxval(v4l2_control_classes, c.ctrl_class,
830 "V4L2_CTRL_CLASS_???");
831 tprintf(", count=%u", c.count);
834 return RVAL_IOCTL_DECODED;
840 if (umove(tcp, arg, &c) < 0) {
842 return RVAL_IOCTL_DECODED;
844 tprints(is_get ? ", " : " => ");
847 tprints("controls=");
848 struct_v4l2_ext_control ctrl;
849 bool fail = !print_array(tcp, ptr_to_kulong(c.controls), c.count,
851 umoven_or_printaddr_ignore_syserror,
852 print_v4l2_ext_control, 0);
854 if (exiting(tcp) && syserror(tcp))
855 tprintf(", error_idx=%u", c.error_idx);
857 if (exiting(tcp) || fail) {
859 return RVAL_IOCTL_DECODED;
865 #endif /* VIDIOC_S_EXT_CTRLS */
867 #ifdef VIDIOC_ENUM_FRAMESIZES
868 # include "xlat/v4l2_framesize_types.h"
871 print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
873 struct v4l2_frmsizeenum s;
877 if (umove_or_printaddr(tcp, arg, &s))
878 return RVAL_IOCTL_DECODED;
879 tprintf("{index=%u, pixel_format=", s.index);
880 print_pixelformat(s.pixel_format);
884 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
886 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
888 case V4L2_FRMSIZE_TYPE_DISCRETE:
889 tprintf(", discrete={width=%u, height=%u}",
890 s.discrete.width, s.discrete.height);
892 case V4L2_FRMSIZE_TYPE_STEPWISE:
893 tprintf(", stepwise={min_width=%u, max_width=%u, "
894 "step_width=%u, min_height=%u, max_height=%u, "
896 s.stepwise.min_width, s.stepwise.max_width,
897 s.stepwise.step_width, s.stepwise.min_height,
898 s.stepwise.max_height, s.stepwise.step_height);
903 return RVAL_IOCTL_DECODED;
905 #endif /* VIDIOC_ENUM_FRAMESIZES */
907 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
908 # include "xlat/v4l2_frameinterval_types.h"
911 print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
913 struct v4l2_frmivalenum f;
917 if (umove_or_printaddr(tcp, arg, &f))
918 return RVAL_IOCTL_DECODED;
919 tprintf("{index=%u, pixel_format=", f.index);
920 print_pixelformat(f.pixel_format);
921 tprintf(", width=%u, height=%u", f.width, f.height);
925 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
927 printxval(v4l2_frameinterval_types, f.type,
928 "V4L2_FRMIVAL_TYPE_???");
930 case V4L2_FRMIVAL_TYPE_DISCRETE:
931 tprintf(", discrete=" FMT_FRACT,
932 ARGS_FRACT(f.discrete));
934 case V4L2_FRMIVAL_TYPE_STEPWISE:
935 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
936 tprintf(", stepwise={min=" FMT_FRACT ", max="
937 FMT_FRACT ", step=" FMT_FRACT "}",
938 ARGS_FRACT(f.stepwise.min),
939 ARGS_FRACT(f.stepwise.max),
940 ARGS_FRACT(f.stepwise.step));
947 return RVAL_IOCTL_DECODED;
949 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
951 #ifdef VIDIOC_CREATE_BUFS
953 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
955 static const char fmt[] = "{index=%u, count=%u}";
956 static char outstr[sizeof(fmt) + sizeof(int) * 6];
958 struct_v4l2_create_buffers b;
962 if (umove_or_printaddr(tcp, arg, &b))
963 return RVAL_IOCTL_DECODED;
964 tprintf("{count=%u, memory=", b.count);
965 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
966 tprints(", format={type=");
967 printxval(v4l2_buf_types, b.format.type,
968 "V4L2_BUF_TYPE_???");
969 print_v4l2_format_fmt(tcp, ", ",
970 (struct_v4l2_format *) &b.format);
975 if (syserror(tcp) || umove(tcp, arg, &b))
976 return RVAL_IOCTL_DECODED;
978 sprintf(outstr, fmt, b.index, b.count);
979 tcp->auxstr = outstr;
981 return RVAL_IOCTL_DECODED | RVAL_STR;
983 #endif /* VIDIOC_CREATE_BUFS */
985 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
986 const unsigned int code, const kernel_ulong_t arg)
992 case VIDIOC_QUERYCAP: /* R */
993 return print_v4l2_capability(tcp, arg);
995 case VIDIOC_ENUM_FMT: /* RW */
996 return print_v4l2_fmtdesc(tcp, arg);
998 case VIDIOC_G_FMT: /* RW */
999 case VIDIOC_S_FMT: /* RW */
1000 case VIDIOC_TRY_FMT: /* RW */
1001 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
1003 case VIDIOC_REQBUFS: /* RW */
1004 return print_v4l2_requestbuffers(tcp, arg);
1006 case VIDIOC_QUERYBUF: /* RW */
1007 case VIDIOC_QBUF: /* RW */
1008 case VIDIOC_DQBUF: /* RW */
1009 return print_v4l2_buffer(tcp, code, arg);
1011 case VIDIOC_G_FBUF: /* R */
1015 case VIDIOC_S_FBUF: /* W */
1016 return print_v4l2_framebuffer(tcp, arg);
1018 case VIDIOC_STREAMON: /* W */
1019 case VIDIOC_STREAMOFF: /* W */
1020 return print_v4l2_buf_type(tcp, arg);
1022 case VIDIOC_G_PARM: /* RW */
1023 case VIDIOC_S_PARM: /* RW */
1024 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
1026 case VIDIOC_G_STD: /* R */
1030 case VIDIOC_S_STD: /* W */
1032 printnum_int64(tcp, arg, "%#" PRIx64);
1035 case VIDIOC_ENUMSTD: /* RW */
1036 return print_v4l2_standard(tcp, arg);
1038 case VIDIOC_ENUMINPUT: /* RW */
1039 return print_v4l2_input(tcp, arg);
1041 case VIDIOC_G_CTRL: /* RW */
1042 case VIDIOC_S_CTRL: /* RW */
1043 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
1045 case VIDIOC_G_TUNER: /* RW */
1046 case VIDIOC_S_TUNER: /* RW */
1047 return print_v4l2_tuner(tcp, arg, code == VIDIOC_G_TUNER);
1049 case VIDIOC_QUERYCTRL: /* RW */
1050 return print_v4l2_queryctrl(tcp, arg);
1052 case VIDIOC_G_INPUT: /* R */
1056 case VIDIOC_S_INPUT: /* RW */
1058 printnum_int(tcp, arg, "%u");
1061 case VIDIOC_CROPCAP: /* RW */
1062 return print_v4l2_cropcap(tcp, arg);
1064 case VIDIOC_G_CROP: /* RW */
1065 case VIDIOC_S_CROP: /* W */
1066 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
1068 #ifdef VIDIOC_S_EXT_CTRLS
1069 case VIDIOC_S_EXT_CTRLS: /* RW */
1070 case VIDIOC_TRY_EXT_CTRLS: /* RW */
1071 case VIDIOC_G_EXT_CTRLS: /* RW */
1072 return print_v4l2_ext_controls(tcp, arg,
1073 code == VIDIOC_G_EXT_CTRLS);
1074 #endif /* VIDIOC_S_EXT_CTRLS */
1076 #ifdef VIDIOC_ENUM_FRAMESIZES
1077 case VIDIOC_ENUM_FRAMESIZES: /* RW */
1078 return print_v4l2_frmsizeenum(tcp, arg);
1079 #endif /* VIDIOC_ENUM_FRAMESIZES */
1081 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
1082 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
1083 return print_v4l2_frmivalenum(tcp, arg);
1084 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
1086 #ifdef VIDIOC_CREATE_BUFS
1087 case VIDIOC_CREATE_BUFS: /* RW */
1088 return print_v4l2_create_buffers(tcp, arg);
1089 #endif /* VIDIOC_CREATE_BUFS */
1092 return RVAL_DECODED;
1095 return RVAL_IOCTL_DECODED;