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>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
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)
42 #include <linux/ioctl.h>
43 #include <linux/types.h>
44 #include <linux/videodev2.h>
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;
57 /* some historical constants */
58 #ifndef V4L2_CID_HCENTER
59 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
61 #ifndef V4L2_CID_VCENTER
62 #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
64 #ifndef V4L2_CID_BAND_STOP_FILTER
65 #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
68 #define FMT_FRACT "%u/%u"
69 #define ARGS_FRACT(x) ((x).numerator), ((x).denominator)
71 #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}"
72 #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height
75 print_pixelformat(uint32_t fourcc)
79 unsigned char cc[sizeof(uint32_t)];
83 (unsigned char) (fourcc >> 24),
84 (unsigned char) (fourcc >> 16),
85 (unsigned char) (fourcc >> 8),
86 (unsigned char) fourcc
94 tprints("v4l2_fourcc(");
95 for (i = 0; i < sizeof(u.cc); ++i) {
96 unsigned char c = u.cc[i];
100 if (c == '\'' || c == '\\') {
109 } else if (c >= ' ' && c <= 0x7e) {
122 "0123456789abcdef"[c >> 4],
123 "0123456789abcdef"[c & 0xf],
133 #include "xlat/v4l2_device_capabilities_flags.h"
136 print_v4l2_capability(struct tcb *tcp, const long arg)
138 struct v4l2_capability caps;
143 if (umove_or_printaddr(tcp, arg, &caps))
146 print_quoted_string((const char *) caps.driver,
147 sizeof(caps.driver), QUOTE_0_TERMINATED);
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,
160 #ifdef V4L2_CAP_DEVICE_CAPS
161 tprints(", device_caps=");
162 printflags(v4l2_device_capabilities_flags, caps.device_caps,
169 #include "xlat/v4l2_buf_types.h"
170 #include "xlat/v4l2_format_description_flags.h"
173 print_v4l2_fmtdesc(struct tcb *tcp, const long arg)
175 struct v4l2_fmtdesc f;
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_???");
186 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
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),
194 tprints(", pixelformat=");
195 print_pixelformat(f.pixelformat);
201 #include "xlat/v4l2_fields.h"
202 #include "xlat/v4l2_colorspaces.h"
205 print_v4l2_format_fmt(const char *prefix, const struct_v4l2_format *f)
208 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
209 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
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);
215 printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???");
216 tprintf(", bytesperline=%u, sizeimage=%u, colorspace=",
217 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
218 printxval(v4l2_colorspaces, f->fmt.pix.colorspace,
219 "V4L2_COLORSPACE_???");
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: {
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);
232 printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???");
233 tprints(", colorspace=");
234 printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace,
235 "V4L2_COLORSPACE_???");
236 tprints(", plane_fmt=[");
237 max = f->fmt.pix_mp.num_planes;
238 if (max > VIDEO_MAX_PLANES)
239 max = VIDEO_MAX_PLANES;
240 for (i = 0; i < max; i++) {
243 tprintf("{sizeimage=%u, bytesperline=%u}",
244 f->fmt.pix_mp.plane_fmt[i].sizeimage,
245 f->fmt.pix_mp.plane_fmt[i].bytesperline);
247 tprintf("], num_planes=%u}", (unsigned) f->fmt.pix_mp.num_planes);
252 /* TODO: Complete this switch statement */
254 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
255 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
256 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
259 tprints("fmt.win={???}");
262 case V4L2_BUF_TYPE_VBI_CAPTURE:
263 case V4L2_BUF_TYPE_VBI_OUTPUT:
265 tprints("fmt.vbi={???}");
268 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
269 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
271 tprints("fmt.sliced={???}");
274 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
275 case V4L2_BUF_TYPE_SDR_CAPTURE:
276 case V4L2_BUF_TYPE_SDR_OUTPUT:
278 tprints("fmt.sdr={???}");
286 print_v4l2_format(struct tcb *tcp, const long arg, const bool is_get)
288 struct_v4l2_format f;
292 if (umove_or_printaddr(tcp, arg, &f))
293 return RVAL_DECODED | 1;
295 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
298 print_v4l2_format_fmt(", ", &f);
300 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
301 const char *delim = is_get ? ", " : " => ";
302 print_v4l2_format_fmt(delim, &f);
309 #include "xlat/v4l2_memories.h"
312 print_v4l2_requestbuffers(struct tcb *tcp, const long arg)
314 struct v4l2_requestbuffers reqbufs;
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_???");
327 static char outstr[sizeof("{count=}") + sizeof(int) * 3];
329 if (syserror(tcp) || umove(tcp, arg, &reqbufs) < 0)
331 sprintf(outstr, "{count=%u}", reqbufs.count);
332 tcp->auxstr = outstr;
337 #include "xlat/v4l2_buf_flags.h"
340 print_v4l2_buffer(struct tcb *tcp, const unsigned int code, const long arg)
342 struct_v4l2_buffer b;
346 if (umove_or_printaddr(tcp, arg, &b))
347 return RVAL_DECODED | 1;
349 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
350 if (code != VIDIOC_DQBUF)
351 tprintf(", index=%u", b.index);
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_???");
359 if (b.memory == V4L2_MEMORY_MMAP) {
360 tprintf(", m.offset=%#x", b.m.offset);
361 } else if (b.memory == V4L2_MEMORY_USERPTR) {
362 tprints(", m.userptr=");
363 printaddr((unsigned long) b.m.userptr);
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 tprints(", timestamp = ");
371 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
381 print_v4l2_framebuffer(struct tcb *tcp, const long arg)
383 struct_v4l2_framebuffer b;
386 if (!umove_or_printaddr(tcp, arg, &b)) {
387 tprintf("{capability=%#x, flags=%#x, base=",
388 b.capability, b.flags);
389 printaddr((unsigned long) b.base);
393 return RVAL_DECODED | 1;
397 print_v4l2_buf_type(struct tcb *tcp, const long arg)
402 if (!umove_or_printaddr(tcp, arg, &type)) {
404 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
407 return RVAL_DECODED | 1;
410 #include "xlat/v4l2_streaming_capabilities.h"
411 #include "xlat/v4l2_capture_modes.h"
414 print_v4l2_streamparm(struct tcb *tcp, const long arg, const bool is_get)
416 struct v4l2_streamparm s;
420 if (umove_or_printaddr(tcp, arg, &s))
421 return RVAL_DECODED | 1;
423 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
425 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
426 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
433 return RVAL_DECODED | 1;
436 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
440 tprints(is_get ? ", " : " => ");
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_???");
448 tprints(", capturemode=");
449 printflags(v4l2_capture_modes,
450 s.parm.capture.capturemode, "V4L2_MODE_???");
452 tprintf(", timeperframe=" FMT_FRACT,
453 ARGS_FRACT(s.parm.capture.timeperframe));
455 tprintf(", extendedmode=%u, readbuffers=%u}",
456 s.parm.capture.extendedmode,
457 s.parm.capture.readbuffers);
459 tprints("parm.output={capability=");
460 printflags(v4l2_streaming_capabilities,
461 s.parm.output.capability, "V4L2_CAP_???");
463 tprintf(", outputmode=%u", s.parm.output.outputmode);
465 tprintf(", timeperframe=" FMT_FRACT,
466 ARGS_FRACT(s.parm.output.timeperframe));
468 tprintf(", extendedmode=%u, writebuffers=%u}",
469 s.parm.output.extendedmode,
470 s.parm.output.writebuffers);
478 print_v4l2_standard(struct tcb *tcp, const long arg)
480 struct_v4l2_standard s;
484 if (umove_or_printaddr(tcp, arg, &s))
485 return RVAL_DECODED | 1;
486 tprintf("{index=%u", s.index);
488 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
490 print_quoted_string((const char *) s.name,
493 tprintf(", frameperiod=" FMT_FRACT,
494 ARGS_FRACT(s.frameperiod));
495 tprintf(", framelines=%d", s.framelines);
502 #include "xlat/v4l2_input_types.h"
505 print_v4l2_input(struct tcb *tcp, const long arg)
511 if (umove_or_printaddr(tcp, arg, &i))
512 return RVAL_DECODED | 1;
513 tprintf("{index=%u", i.index);
515 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
517 print_quoted_string((const char *) i.name,
521 printxval(v4l2_input_types, i.type,
522 "V4L2_INPUT_TYPE_???");
529 #include "xlat/v4l2_control_ids.h"
532 print_v4l2_control(struct tcb *tcp, const long arg, const bool is_get)
534 struct v4l2_control c;
538 if (umove_or_printaddr(tcp, arg, &c))
539 return RVAL_DECODED | 1;
541 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
543 tprintf(", value=%d", c.value);
547 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
548 tprints(is_get ? ", " : " => ");
549 tprintf("value=%d", c.value);
556 #include "xlat/v4l2_control_types.h"
557 #include "xlat/v4l2_control_flags.h"
560 print_v4l2_queryctrl(struct tcb *tcp, const long arg)
562 struct v4l2_queryctrl c;
566 if (umove_or_printaddr(tcp, arg, &c))
567 return RVAL_DECODED | 1;
570 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
574 if (get_tcb_priv_ulong(tcp))
578 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
579 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
580 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
581 set_tcb_priv_ulong(tcp, next);
583 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
584 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
587 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
592 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
594 print_quoted_string((const char *) c.name,
597 tprintf(", minimum=%d, maximum=%d, step=%d"
598 ", default_value=%d, flags=",
599 c.minimum, c.maximum, c.step, c.default_value);
600 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
607 print_v4l2_cropcap(struct tcb *tcp, const long arg)
609 struct v4l2_cropcap c;
613 if (umove_or_printaddr(tcp, arg, &c))
614 return RVAL_DECODED | 1;
616 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
619 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
620 tprintf(", bounds=" FMT_RECT
621 ", defrect=" FMT_RECT
622 ", pixelaspect=" FMT_FRACT,
624 ARGS_RECT(c.defrect),
625 ARGS_FRACT(c.pixelaspect));
632 print_v4l2_crop(struct tcb *tcp, const long arg, const bool is_get)
638 if (umove_or_printaddr(tcp, arg, &c))
639 return RVAL_DECODED | 1;
641 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
644 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
646 if (!syserror(tcp) && !umove(tcp, arg, &c))
647 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
651 return RVAL_DECODED | 1;
654 #ifdef VIDIOC_S_EXT_CTRLS
656 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
658 const struct_v4l2_ext_control *p = elem_buf;
661 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
662 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
663 tprintf(", size=%u", p->size);
665 tprints(", string=");
666 printstr(tcp, (long) p->string, p->size);
669 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
675 #include "xlat/v4l2_control_classes.h"
678 print_v4l2_ext_controls(struct tcb *tcp, const long arg, const bool is_get)
680 struct_v4l2_ext_controls c;
684 if (umove_or_printaddr(tcp, arg, &c))
685 return RVAL_DECODED | 1;
686 tprints("{ctrl_class=");
687 printxval(v4l2_control_classes, c.ctrl_class,
688 "V4L2_CTRL_CLASS_???");
689 tprintf(", count=%u", c.count);
692 return RVAL_DECODED | 1;
698 if (umove(tcp, arg, &c) < 0) {
702 tprints(is_get ? ", " : " => ");
705 tprints("controls=");
706 struct_v4l2_ext_control ctrl;
707 bool fail = !print_array(tcp, (unsigned long) c.controls, c.count,
709 umoven_or_printaddr_ignore_syserror,
710 print_v4l2_ext_control, 0);
712 if (exiting(tcp) && syserror(tcp))
713 tprintf(", error_idx=%u", c.error_idx);
715 if (exiting(tcp) || fail) {
717 return RVAL_DECODED | 1;
721 #endif /* VIDIOC_S_EXT_CTRLS */
723 #ifdef VIDIOC_ENUM_FRAMESIZES
724 # include "xlat/v4l2_framesize_types.h"
727 print_v4l2_frmsizeenum(struct tcb *tcp, const long arg)
729 struct v4l2_frmsizeenum s;
733 if (umove_or_printaddr(tcp, arg, &s))
734 return RVAL_DECODED | 1;
735 tprintf("{index=%u, pixel_format=", s.index);
736 print_pixelformat(s.pixel_format);
740 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
742 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
744 case V4L2_FRMSIZE_TYPE_DISCRETE:
745 tprintf(", discrete={width=%u, height=%u}",
746 s.discrete.width, s.discrete.height);
748 case V4L2_FRMSIZE_TYPE_STEPWISE:
749 tprintf(", stepwise={min_width=%u, max_width=%u, "
750 "step_width=%u, min_height=%u, max_height=%u, "
752 s.stepwise.min_width, s.stepwise.max_width,
753 s.stepwise.step_width, s.stepwise.min_height,
754 s.stepwise.max_height, s.stepwise.step_height);
761 #endif /* VIDIOC_ENUM_FRAMESIZES */
763 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
764 # include "xlat/v4l2_frameinterval_types.h"
767 print_v4l2_frmivalenum(struct tcb *tcp, const long arg)
769 struct v4l2_frmivalenum f;
773 if (umove_or_printaddr(tcp, arg, &f))
774 return RVAL_DECODED | 1;
775 tprintf("{index=%u, pixel_format=", f.index);
776 print_pixelformat(f.pixel_format);
777 tprintf(", width=%u, height=%u", f.width, f.height);
780 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
782 printxval(v4l2_frameinterval_types, f.type,
783 "V4L2_FRMIVAL_TYPE_???");
785 case V4L2_FRMIVAL_TYPE_DISCRETE:
786 tprintf(", discrete=" FMT_FRACT,
787 ARGS_FRACT(f.discrete));
789 case V4L2_FRMIVAL_TYPE_STEPWISE:
790 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
791 tprintf(", stepwise={min=" FMT_FRACT ", max="
792 FMT_FRACT ", step=" FMT_FRACT "}",
793 ARGS_FRACT(f.stepwise.min),
794 ARGS_FRACT(f.stepwise.max),
795 ARGS_FRACT(f.stepwise.step));
802 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
804 #ifdef VIDIOC_CREATE_BUFS
806 print_v4l2_create_buffers(struct tcb *tcp, const long arg)
808 struct_v4l2_create_buffers b;
812 if (umove_or_printaddr(tcp, arg, &b))
813 return RVAL_DECODED | 1;
814 tprintf("{count=%u, memory=", b.count);
815 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
816 tprints(", format={type=");
817 printxval(v4l2_buf_types, b.format.type,
818 "V4L2_BUF_TYPE_???");
819 print_v4l2_format_fmt(", ",
820 (struct_v4l2_format *) &b.format);
824 static const char fmt[] = "{index=%u, count=%u}";
825 static char outstr[sizeof(fmt) + sizeof(int) * 6];
827 if (syserror(tcp) || umove(tcp, arg, &b) < 0)
829 sprintf(outstr, fmt, b.index, b.count);
830 tcp->auxstr = outstr;
834 #endif /* VIDIOC_CREATE_BUFS */
836 MPERS_PRINTER_DECL(int, v4l2_ioctl,
837 struct tcb *tcp, const unsigned int code, const long arg)
843 case VIDIOC_QUERYCAP: /* R */
844 return print_v4l2_capability(tcp, arg);
846 case VIDIOC_ENUM_FMT: /* RW */
847 return print_v4l2_fmtdesc(tcp, arg);
849 case VIDIOC_G_FMT: /* RW */
850 case VIDIOC_S_FMT: /* RW */
851 case VIDIOC_TRY_FMT: /* RW */
852 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
854 case VIDIOC_REQBUFS: /* RW */
855 return print_v4l2_requestbuffers(tcp, arg);
857 case VIDIOC_QUERYBUF: /* RW */
858 case VIDIOC_QBUF: /* RW */
859 case VIDIOC_DQBUF: /* RW */
860 return print_v4l2_buffer(tcp, code, arg);
862 case VIDIOC_G_FBUF: /* R */
866 case VIDIOC_S_FBUF: /* W */
867 return print_v4l2_framebuffer(tcp, arg);
869 case VIDIOC_STREAMON: /* W */
870 case VIDIOC_STREAMOFF: /* W */
871 return print_v4l2_buf_type(tcp, arg);
873 case VIDIOC_G_PARM: /* RW */
874 case VIDIOC_S_PARM: /* RW */
875 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
877 case VIDIOC_G_STD: /* R */
881 case VIDIOC_S_STD: /* W */
883 printnum_int64(tcp, arg, "%#" PRIx64);
884 return RVAL_DECODED | 1;
886 case VIDIOC_ENUMSTD: /* RW */
887 return print_v4l2_standard(tcp, arg);
889 case VIDIOC_ENUMINPUT: /* RW */
890 return print_v4l2_input(tcp, arg);
892 case VIDIOC_G_CTRL: /* RW */
893 case VIDIOC_S_CTRL: /* RW */
894 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
896 case VIDIOC_QUERYCTRL: /* RW */
897 return print_v4l2_queryctrl(tcp, arg);
899 case VIDIOC_G_INPUT: /* R */
903 case VIDIOC_S_INPUT: /* RW */
905 printnum_int(tcp, arg, "%u");
906 return RVAL_DECODED | 1;
908 case VIDIOC_CROPCAP: /* RW */
909 return print_v4l2_cropcap(tcp, arg);
911 case VIDIOC_G_CROP: /* RW */
912 case VIDIOC_S_CROP: /* W */
913 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
915 #ifdef VIDIOC_S_EXT_CTRLS
916 case VIDIOC_S_EXT_CTRLS: /* RW */
917 case VIDIOC_TRY_EXT_CTRLS: /* RW */
918 case VIDIOC_G_EXT_CTRLS: /* RW */
919 return print_v4l2_ext_controls(tcp, arg,
920 code == VIDIOC_G_EXT_CTRLS);
921 #endif /* VIDIOC_S_EXT_CTRLS */
923 #ifdef VIDIOC_ENUM_FRAMESIZES
924 case VIDIOC_ENUM_FRAMESIZES: /* RW */
925 return print_v4l2_frmsizeenum(tcp, arg);
926 #endif /* VIDIOC_ENUM_FRAMESIZES */
928 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
929 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
930 return print_v4l2_frmivalenum(tcp, arg);
931 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
933 #ifdef VIDIOC_CREATE_BUFS
934 case VIDIOC_CREATE_BUFS: /* RW */
935 return print_v4l2_create_buffers(tcp, arg);
936 #endif /* VIDIOC_CREATE_BUFS */