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 *const tcp, const kernel_ulong_t 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 *const tcp, const kernel_ulong_t 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 *const tcp, const kernel_ulong_t arg,
289 struct_v4l2_format f;
293 if (umove_or_printaddr(tcp, arg, &f))
294 return RVAL_DECODED | 1;
296 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
299 print_v4l2_format_fmt(", ", &f);
301 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
302 const char *delim = is_get ? ", " : " => ";
303 print_v4l2_format_fmt(delim, &f);
310 #include "xlat/v4l2_memories.h"
313 print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg)
315 struct v4l2_requestbuffers reqbufs;
319 if (umove_or_printaddr(tcp, arg, &reqbufs))
320 return RVAL_DECODED | 1;
321 tprintf("{count=%u, type=", reqbufs.count);
322 printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???");
323 tprints(", memory=");
324 printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???");
328 static char outstr[sizeof("{count=}") + sizeof(int) * 3];
330 if (syserror(tcp) || umove(tcp, arg, &reqbufs) < 0)
332 sprintf(outstr, "{count=%u}", reqbufs.count);
333 tcp->auxstr = outstr;
338 #include "xlat/v4l2_buf_flags.h"
341 print_v4l2_buffer(struct tcb *const tcp, const unsigned int code,
342 const kernel_ulong_t arg)
344 struct_v4l2_buffer b;
348 if (umove_or_printaddr(tcp, arg, &b))
349 return RVAL_DECODED | 1;
351 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
352 if (code != VIDIOC_DQBUF)
353 tprintf(", index=%u", b.index);
355 if (!syserror(tcp) && umove(tcp, arg, &b) == 0) {
356 if (code == VIDIOC_DQBUF)
357 tprintf(", index=%u", b.index);
358 tprints(", memory=");
359 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
361 if (b.memory == V4L2_MEMORY_MMAP) {
362 tprintf(", m.offset=%#x", b.m.offset);
363 } else if (b.memory == V4L2_MEMORY_USERPTR) {
364 tprints(", m.userptr=");
365 printaddr(b.m.userptr);
368 tprintf(", length=%u, bytesused=%u, flags=",
369 b.length, b.bytesused);
370 printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
371 if (code == VIDIOC_DQBUF) {
372 tprints(", timestamp = ");
373 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
383 print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg)
385 struct_v4l2_framebuffer b;
388 if (!umove_or_printaddr(tcp, arg, &b)) {
389 tprintf("{capability=%#x, flags=%#x, base=",
390 b.capability, b.flags);
391 printaddr(ptr_to_kulong(b.base));
395 return RVAL_DECODED | 1;
399 print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg)
404 if (!umove_or_printaddr(tcp, arg, &type)) {
406 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
409 return RVAL_DECODED | 1;
412 #include "xlat/v4l2_streaming_capabilities.h"
413 #include "xlat/v4l2_capture_modes.h"
416 print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg,
419 struct v4l2_streamparm s;
423 if (umove_or_printaddr(tcp, arg, &s))
424 return RVAL_DECODED | 1;
426 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
428 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
429 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
436 return RVAL_DECODED | 1;
439 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
443 tprints(is_get ? ", " : " => ");
446 if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
447 tprints("parm.capture={capability=");
448 printflags(v4l2_streaming_capabilities,
449 s.parm.capture.capability, "V4L2_CAP_???");
451 tprints(", capturemode=");
452 printflags(v4l2_capture_modes,
453 s.parm.capture.capturemode, "V4L2_MODE_???");
455 tprintf(", timeperframe=" FMT_FRACT,
456 ARGS_FRACT(s.parm.capture.timeperframe));
458 tprintf(", extendedmode=%u, readbuffers=%u}",
459 s.parm.capture.extendedmode,
460 s.parm.capture.readbuffers);
462 tprints("parm.output={capability=");
463 printflags(v4l2_streaming_capabilities,
464 s.parm.output.capability, "V4L2_CAP_???");
466 tprintf(", outputmode=%u", s.parm.output.outputmode);
468 tprintf(", timeperframe=" FMT_FRACT,
469 ARGS_FRACT(s.parm.output.timeperframe));
471 tprintf(", extendedmode=%u, writebuffers=%u}",
472 s.parm.output.extendedmode,
473 s.parm.output.writebuffers);
481 print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg)
483 struct_v4l2_standard s;
487 if (umove_or_printaddr(tcp, arg, &s))
488 return RVAL_DECODED | 1;
489 tprintf("{index=%u", s.index);
491 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
493 print_quoted_string((const char *) s.name,
496 tprintf(", frameperiod=" FMT_FRACT,
497 ARGS_FRACT(s.frameperiod));
498 tprintf(", framelines=%d", s.framelines);
505 #include "xlat/v4l2_input_types.h"
508 print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
514 if (umove_or_printaddr(tcp, arg, &i))
515 return RVAL_DECODED | 1;
516 tprintf("{index=%u", i.index);
518 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
520 print_quoted_string((const char *) i.name,
524 printxval(v4l2_input_types, i.type,
525 "V4L2_INPUT_TYPE_???");
532 #include "xlat/v4l2_control_ids.h"
535 print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg,
538 struct v4l2_control c;
542 if (umove_or_printaddr(tcp, arg, &c))
543 return RVAL_DECODED | 1;
545 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
547 tprintf(", value=%d", c.value);
551 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
552 tprints(is_get ? ", " : " => ");
553 tprintf("value=%d", c.value);
560 #include "xlat/v4l2_control_types.h"
561 #include "xlat/v4l2_control_flags.h"
564 print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg)
566 struct v4l2_queryctrl c;
570 if (umove_or_printaddr(tcp, arg, &c))
571 return RVAL_DECODED | 1;
574 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
578 if (get_tcb_priv_ulong(tcp))
582 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
583 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
584 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
585 set_tcb_priv_ulong(tcp, next);
587 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
588 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
591 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
596 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
598 print_quoted_string((const char *) c.name,
601 tprintf(", minimum=%d, maximum=%d, step=%d"
602 ", default_value=%d, flags=",
603 c.minimum, c.maximum, c.step, c.default_value);
604 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
611 print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg)
613 struct v4l2_cropcap c;
617 if (umove_or_printaddr(tcp, arg, &c))
618 return RVAL_DECODED | 1;
620 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
623 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
624 tprintf(", bounds=" FMT_RECT
625 ", defrect=" FMT_RECT
626 ", pixelaspect=" FMT_FRACT,
628 ARGS_RECT(c.defrect),
629 ARGS_FRACT(c.pixelaspect));
636 print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg,
643 if (umove_or_printaddr(tcp, arg, &c))
644 return RVAL_DECODED | 1;
646 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
649 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
651 if (!syserror(tcp) && !umove(tcp, arg, &c))
652 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
656 return RVAL_DECODED | 1;
659 #ifdef VIDIOC_S_EXT_CTRLS
661 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
663 const struct_v4l2_ext_control *p = elem_buf;
666 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
667 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
668 tprintf(", size=%u", p->size);
670 tprints(", string=");
671 printstrn(tcp, ptr_to_kulong(p->string), p->size);
674 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
680 #include "xlat/v4l2_control_classes.h"
683 print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg,
686 struct_v4l2_ext_controls c;
690 if (umove_or_printaddr(tcp, arg, &c))
691 return RVAL_DECODED | 1;
692 tprints("{ctrl_class=");
693 printxval(v4l2_control_classes, c.ctrl_class,
694 "V4L2_CTRL_CLASS_???");
695 tprintf(", count=%u", c.count);
698 return RVAL_DECODED | 1;
704 if (umove(tcp, arg, &c) < 0) {
708 tprints(is_get ? ", " : " => ");
711 tprints("controls=");
712 struct_v4l2_ext_control ctrl;
713 bool fail = !print_array(tcp, ptr_to_kulong(c.controls), c.count,
715 umoven_or_printaddr_ignore_syserror,
716 print_v4l2_ext_control, 0);
718 if (exiting(tcp) && syserror(tcp))
719 tprintf(", error_idx=%u", c.error_idx);
721 if (exiting(tcp) || fail) {
723 return RVAL_DECODED | 1;
727 #endif /* VIDIOC_S_EXT_CTRLS */
729 #ifdef VIDIOC_ENUM_FRAMESIZES
730 # include "xlat/v4l2_framesize_types.h"
733 print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
735 struct v4l2_frmsizeenum s;
739 if (umove_or_printaddr(tcp, arg, &s))
740 return RVAL_DECODED | 1;
741 tprintf("{index=%u, pixel_format=", s.index);
742 print_pixelformat(s.pixel_format);
746 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
748 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
750 case V4L2_FRMSIZE_TYPE_DISCRETE:
751 tprintf(", discrete={width=%u, height=%u}",
752 s.discrete.width, s.discrete.height);
754 case V4L2_FRMSIZE_TYPE_STEPWISE:
755 tprintf(", stepwise={min_width=%u, max_width=%u, "
756 "step_width=%u, min_height=%u, max_height=%u, "
758 s.stepwise.min_width, s.stepwise.max_width,
759 s.stepwise.step_width, s.stepwise.min_height,
760 s.stepwise.max_height, s.stepwise.step_height);
767 #endif /* VIDIOC_ENUM_FRAMESIZES */
769 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
770 # include "xlat/v4l2_frameinterval_types.h"
773 print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
775 struct v4l2_frmivalenum f;
779 if (umove_or_printaddr(tcp, arg, &f))
780 return RVAL_DECODED | 1;
781 tprintf("{index=%u, pixel_format=", f.index);
782 print_pixelformat(f.pixel_format);
783 tprintf(", width=%u, height=%u", f.width, f.height);
786 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
788 printxval(v4l2_frameinterval_types, f.type,
789 "V4L2_FRMIVAL_TYPE_???");
791 case V4L2_FRMIVAL_TYPE_DISCRETE:
792 tprintf(", discrete=" FMT_FRACT,
793 ARGS_FRACT(f.discrete));
795 case V4L2_FRMIVAL_TYPE_STEPWISE:
796 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
797 tprintf(", stepwise={min=" FMT_FRACT ", max="
798 FMT_FRACT ", step=" FMT_FRACT "}",
799 ARGS_FRACT(f.stepwise.min),
800 ARGS_FRACT(f.stepwise.max),
801 ARGS_FRACT(f.stepwise.step));
808 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
810 #ifdef VIDIOC_CREATE_BUFS
812 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
814 struct_v4l2_create_buffers b;
818 if (umove_or_printaddr(tcp, arg, &b))
819 return RVAL_DECODED | 1;
820 tprintf("{count=%u, memory=", b.count);
821 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
822 tprints(", format={type=");
823 printxval(v4l2_buf_types, b.format.type,
824 "V4L2_BUF_TYPE_???");
825 print_v4l2_format_fmt(", ",
826 (struct_v4l2_format *) &b.format);
830 static const char fmt[] = "{index=%u, count=%u}";
831 static char outstr[sizeof(fmt) + sizeof(int) * 6];
833 if (syserror(tcp) || umove(tcp, arg, &b) < 0)
835 sprintf(outstr, fmt, b.index, b.count);
836 tcp->auxstr = outstr;
840 #endif /* VIDIOC_CREATE_BUFS */
842 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
843 const unsigned int code, const kernel_ulong_t arg)
849 case VIDIOC_QUERYCAP: /* R */
850 return print_v4l2_capability(tcp, arg);
852 case VIDIOC_ENUM_FMT: /* RW */
853 return print_v4l2_fmtdesc(tcp, arg);
855 case VIDIOC_G_FMT: /* RW */
856 case VIDIOC_S_FMT: /* RW */
857 case VIDIOC_TRY_FMT: /* RW */
858 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
860 case VIDIOC_REQBUFS: /* RW */
861 return print_v4l2_requestbuffers(tcp, arg);
863 case VIDIOC_QUERYBUF: /* RW */
864 case VIDIOC_QBUF: /* RW */
865 case VIDIOC_DQBUF: /* RW */
866 return print_v4l2_buffer(tcp, code, arg);
868 case VIDIOC_G_FBUF: /* R */
872 case VIDIOC_S_FBUF: /* W */
873 return print_v4l2_framebuffer(tcp, arg);
875 case VIDIOC_STREAMON: /* W */
876 case VIDIOC_STREAMOFF: /* W */
877 return print_v4l2_buf_type(tcp, arg);
879 case VIDIOC_G_PARM: /* RW */
880 case VIDIOC_S_PARM: /* RW */
881 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
883 case VIDIOC_G_STD: /* R */
887 case VIDIOC_S_STD: /* W */
889 printnum_int64(tcp, arg, "%#" PRIx64);
890 return RVAL_DECODED | 1;
892 case VIDIOC_ENUMSTD: /* RW */
893 return print_v4l2_standard(tcp, arg);
895 case VIDIOC_ENUMINPUT: /* RW */
896 return print_v4l2_input(tcp, arg);
898 case VIDIOC_G_CTRL: /* RW */
899 case VIDIOC_S_CTRL: /* RW */
900 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
902 case VIDIOC_QUERYCTRL: /* RW */
903 return print_v4l2_queryctrl(tcp, arg);
905 case VIDIOC_G_INPUT: /* R */
909 case VIDIOC_S_INPUT: /* RW */
911 printnum_int(tcp, arg, "%u");
912 return RVAL_DECODED | 1;
914 case VIDIOC_CROPCAP: /* RW */
915 return print_v4l2_cropcap(tcp, arg);
917 case VIDIOC_G_CROP: /* RW */
918 case VIDIOC_S_CROP: /* W */
919 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
921 #ifdef VIDIOC_S_EXT_CTRLS
922 case VIDIOC_S_EXT_CTRLS: /* RW */
923 case VIDIOC_TRY_EXT_CTRLS: /* RW */
924 case VIDIOC_G_EXT_CTRLS: /* RW */
925 return print_v4l2_ext_controls(tcp, arg,
926 code == VIDIOC_G_EXT_CTRLS);
927 #endif /* VIDIOC_S_EXT_CTRLS */
929 #ifdef VIDIOC_ENUM_FRAMESIZES
930 case VIDIOC_ENUM_FRAMESIZES: /* RW */
931 return print_v4l2_frmsizeenum(tcp, arg);
932 #endif /* VIDIOC_ENUM_FRAMESIZES */
934 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
935 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
936 return print_v4l2_frmivalenum(tcp, arg);
937 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
939 #ifdef VIDIOC_CREATE_BUFS
940 case VIDIOC_CREATE_BUFS: /* RW */
941 return print_v4l2_create_buffers(tcp, arg);
942 #endif /* VIDIOC_CREATE_BUFS */