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_clip)
34 #include DEF_MPERS_TYPE(struct_v4l2_create_buffers)
35 #include DEF_MPERS_TYPE(struct_v4l2_ext_control)
36 #include DEF_MPERS_TYPE(struct_v4l2_ext_controls)
37 #include DEF_MPERS_TYPE(struct_v4l2_format)
38 #include DEF_MPERS_TYPE(struct_v4l2_framebuffer)
39 #include DEF_MPERS_TYPE(struct_v4l2_input)
40 #include DEF_MPERS_TYPE(struct_v4l2_standard)
43 #include <linux/ioctl.h>
44 #include <linux/types.h>
45 #include <linux/videodev2.h>
47 typedef struct v4l2_buffer struct_v4l2_buffer;
48 typedef struct v4l2_clip struct_v4l2_clip;
49 typedef struct v4l2_create_buffers struct_v4l2_create_buffers;
50 typedef struct v4l2_ext_control struct_v4l2_ext_control;
51 typedef struct v4l2_ext_controls struct_v4l2_ext_controls;
52 typedef struct v4l2_format struct_v4l2_format;
53 typedef struct v4l2_framebuffer struct_v4l2_framebuffer;
54 typedef struct v4l2_input struct_v4l2_input;
55 typedef struct v4l2_standard struct_v4l2_standard;
59 /* some historical constants */
60 #ifndef V4L2_CID_HCENTER
61 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
63 #ifndef V4L2_CID_VCENTER
64 #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
66 #ifndef V4L2_CID_BAND_STOP_FILTER
67 #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
70 #define FMT_FRACT "%u/%u"
71 #define ARGS_FRACT(x) ((x).numerator), ((x).denominator)
73 #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}"
74 #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height
77 print_pixelformat(uint32_t fourcc)
81 unsigned char cc[sizeof(uint32_t)];
85 (unsigned char) (fourcc >> 24),
86 (unsigned char) (fourcc >> 16),
87 (unsigned char) (fourcc >> 8),
88 (unsigned char) fourcc
96 tprints("v4l2_fourcc(");
97 for (i = 0; i < sizeof(u.cc); ++i) {
98 unsigned char c = u.cc[i];
102 if (c == '\'' || c == '\\') {
111 } else if (c >= ' ' && c <= 0x7e) {
124 "0123456789abcdef"[c >> 4],
125 "0123456789abcdef"[c & 0xf],
135 #include "xlat/v4l2_device_capabilities_flags.h"
138 print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg)
140 struct v4l2_capability caps;
145 if (umove_or_printaddr(tcp, arg, &caps))
148 print_quoted_string((const char *) caps.driver,
149 sizeof(caps.driver), QUOTE_0_TERMINATED);
151 print_quoted_string((const char *) caps.card,
152 sizeof(caps.card), QUOTE_0_TERMINATED);
153 tprints(", bus_info=");
154 print_quoted_string((const char *) caps.bus_info,
155 sizeof(caps.bus_info), QUOTE_0_TERMINATED);
156 tprintf(", version=%u.%u.%u, capabilities=",
157 (caps.version >> 16) & 0xFF,
158 (caps.version >> 8) & 0xFF,
159 caps.version & 0xFF);
160 printflags(v4l2_device_capabilities_flags, caps.capabilities,
162 #ifdef V4L2_CAP_DEVICE_CAPS
163 tprints(", device_caps=");
164 printflags(v4l2_device_capabilities_flags, caps.device_caps,
171 #include "xlat/v4l2_buf_types.h"
172 #include "xlat/v4l2_format_description_flags.h"
175 print_v4l2_fmtdesc(struct tcb *const tcp, const kernel_ulong_t arg)
177 struct v4l2_fmtdesc f;
181 if (umove_or_printaddr(tcp, arg, &f))
182 return RVAL_DECODED | 1;
183 tprintf("{index=%u, type=", f.index);
184 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
188 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
190 printflags(v4l2_format_description_flags, f.flags,
191 "V4L2_FMT_FLAG_???");
192 tprints(", description=");
193 print_quoted_string((const char *) f.description,
194 sizeof(f.description),
196 tprints(", pixelformat=");
197 print_pixelformat(f.pixelformat);
203 #include "xlat/v4l2_fields.h"
204 #include "xlat/v4l2_colorspaces.h"
205 #include "xlat/v4l2_vbi_flags.h"
206 #include "xlat/v4l2_sliced_flags.h"
209 print_v4l2_clip(struct tcb *tcp, void *elem_buf, size_t elem_size, void* data)
211 const struct_v4l2_clip *p = elem_buf;
212 tprintf(FMT_RECT, ARGS_RECT(p->c));
217 print_v4l2_format_fmt(struct tcb *const tcp, const char *prefix,
218 const struct_v4l2_format *f)
222 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
223 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
225 tprintf("fmt.pix={width=%u, height=%u, pixelformat=",
226 f->fmt.pix.width, f->fmt.pix.height);
227 print_pixelformat(f->fmt.pix.pixelformat);
229 printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???");
230 tprintf(", bytesperline=%u, sizeimage=%u, colorspace=",
231 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
232 printxval(v4l2_colorspaces, f->fmt.pix.colorspace,
233 "V4L2_COLORSPACE_???");
236 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
237 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
238 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: {
242 tprintf("fmt.pix_mp={width=%u, height=%u, pixelformat=",
243 f->fmt.pix_mp.width, f->fmt.pix_mp.height);
244 print_pixelformat(f->fmt.pix_mp.pixelformat);
246 printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???");
247 tprints(", colorspace=");
248 printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace,
249 "V4L2_COLORSPACE_???");
250 tprints(", plane_fmt=[");
251 max = f->fmt.pix_mp.num_planes;
252 if (max > VIDEO_MAX_PLANES)
253 max = VIDEO_MAX_PLANES;
254 for (i = 0; i < max; i++) {
257 tprintf("{sizeimage=%u, bytesperline=%u}",
258 f->fmt.pix_mp.plane_fmt[i].sizeimage,
259 f->fmt.pix_mp.plane_fmt[i].bytesperline);
261 tprintf("], num_planes=%u}",
262 (unsigned) f->fmt.pix_mp.num_planes);
266 /* OUTPUT_OVERLAY since Linux v2.6.22-rc1~1118^2~179 */
267 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
268 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
270 case V4L2_BUF_TYPE_VIDEO_OVERLAY: {
271 struct_v4l2_clip clip;
273 tprintf("fmt.win={left=%d, top=%d, width=%u, height=%u, field=",
274 ARGS_RECT(f->fmt.win.w));
275 printxval(v4l2_fields, f->fmt.win.field, "V4L2_FIELD_???");
276 tprintf(", chromakey=%#x, clips=", f->fmt.win.chromakey);
277 ret = print_array(tcp, ptr_to_kulong(f->fmt.win.clips),
278 f->fmt.win.clipcount, &clip, sizeof(clip),
279 umoven_or_printaddr, print_v4l2_clip, 0);
280 tprintf(", clipcount=%u, bitmap=", f->fmt.win.clipcount);
281 printaddr(ptr_to_kulong(f->fmt.win.bitmap));
282 #if HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA
283 tprintf(", global_alpha=%#x", f->fmt.win.global_alpha);
288 case V4L2_BUF_TYPE_VBI_CAPTURE:
289 case V4L2_BUF_TYPE_VBI_OUTPUT:
291 tprintf("fmt.vbi={sampling_rate=%u, offset=%u, "
292 "samples_per_line=%u, sample_format=",
293 f->fmt.vbi.sampling_rate, f->fmt.vbi.offset,
294 f->fmt.vbi.samples_per_line);
295 print_pixelformat(f->fmt.vbi.sample_format);
296 tprintf(", start=[%u, %u], count=[%u, %u], ",
297 f->fmt.vbi.start[0], f->fmt.vbi.start[1],
298 f->fmt.vbi.count[0], f->fmt.vbi.count[1]);
300 printxval(v4l2_vbi_flags, f->fmt.vbi.flags, "V4L2_VBI_???");
303 /* both since Linux v2.6.14-rc2~64 */
304 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
305 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
306 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: {
310 tprints("fmt.sliced={service_set=");
311 printxval(v4l2_sliced_flags, f->fmt.sliced.service_set,
313 tprintf(", io_size=%u, service_lines=[",
314 f->fmt.sliced.io_size);
315 for (i = 0; i < ARRAY_SIZE(f->fmt.sliced.service_lines); i++) {
320 j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
325 f->fmt.sliced.service_lines[i][j]);
333 /* since Linux v4.4-rc1~118^2~14 */
334 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT
335 case V4L2_BUF_TYPE_SDR_OUTPUT:
337 /* since Linux v3.15-rc1~85^2~213 */
338 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
339 case V4L2_BUF_TYPE_SDR_CAPTURE:
341 tprints("fmt.sdr={pixelformat=");
342 print_pixelformat(f->fmt.sdr.pixelformat);
343 #if HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
344 tprintf(", buffersize=%u",
345 f->fmt.sdr.buffersize);
355 print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg,
358 struct_v4l2_format f;
362 if (umove_or_printaddr(tcp, arg, &f))
363 return RVAL_DECODED | 1;
365 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
368 if (!print_v4l2_format_fmt(tcp, ", ", &f)) {
370 return RVAL_DECODED | 1;
373 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
374 const char *delim = is_get ? ", " : " => ";
375 print_v4l2_format_fmt(tcp, delim, &f);
382 #include "xlat/v4l2_memories.h"
385 print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg)
387 struct v4l2_requestbuffers reqbufs;
391 if (umove_or_printaddr(tcp, arg, &reqbufs))
392 return RVAL_DECODED | 1;
393 tprintf("{count=%u, type=", reqbufs.count);
394 printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???");
395 tprints(", memory=");
396 printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???");
400 static char outstr[sizeof("{count=}") + sizeof(int) * 3];
402 if (syserror(tcp) || umove(tcp, arg, &reqbufs) < 0)
404 sprintf(outstr, "{count=%u}", reqbufs.count);
405 tcp->auxstr = outstr;
410 #include "xlat/v4l2_buf_flags.h"
413 print_v4l2_buffer(struct tcb *const tcp, const unsigned int code,
414 const kernel_ulong_t arg)
416 struct_v4l2_buffer b;
420 if (umove_or_printaddr(tcp, arg, &b))
421 return RVAL_DECODED | 1;
423 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
424 if (code != VIDIOC_DQBUF)
425 tprintf(", index=%u", b.index);
427 if (!syserror(tcp) && umove(tcp, arg, &b) == 0) {
428 if (code == VIDIOC_DQBUF)
429 tprintf(", index=%u", b.index);
430 tprints(", memory=");
431 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
433 if (b.memory == V4L2_MEMORY_MMAP) {
434 tprintf(", m.offset=%#x", b.m.offset);
435 } else if (b.memory == V4L2_MEMORY_USERPTR) {
436 tprints(", m.userptr=");
437 printaddr(b.m.userptr);
440 tprintf(", length=%u, bytesused=%u, flags=",
441 b.length, b.bytesused);
442 printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
443 if (code == VIDIOC_DQBUF) {
444 tprints(", timestamp = ");
445 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
455 print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg)
457 struct_v4l2_framebuffer b;
460 if (!umove_or_printaddr(tcp, arg, &b)) {
461 tprintf("{capability=%#x, flags=%#x, base=",
462 b.capability, b.flags);
463 printaddr(ptr_to_kulong(b.base));
467 return RVAL_DECODED | 1;
471 print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg)
476 if (!umove_or_printaddr(tcp, arg, &type)) {
478 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
481 return RVAL_DECODED | 1;
484 #include "xlat/v4l2_streaming_capabilities.h"
485 #include "xlat/v4l2_capture_modes.h"
488 print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg,
491 struct v4l2_streamparm s;
495 if (umove_or_printaddr(tcp, arg, &s))
496 return RVAL_DECODED | 1;
498 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
500 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
501 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
508 return RVAL_DECODED | 1;
511 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
515 tprints(is_get ? ", " : " => ");
518 if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
519 tprints("parm.capture={capability=");
520 printflags(v4l2_streaming_capabilities,
521 s.parm.capture.capability, "V4L2_CAP_???");
523 tprints(", capturemode=");
524 printflags(v4l2_capture_modes,
525 s.parm.capture.capturemode, "V4L2_MODE_???");
527 tprintf(", timeperframe=" FMT_FRACT,
528 ARGS_FRACT(s.parm.capture.timeperframe));
530 tprintf(", extendedmode=%u, readbuffers=%u}",
531 s.parm.capture.extendedmode,
532 s.parm.capture.readbuffers);
534 tprints("parm.output={capability=");
535 printflags(v4l2_streaming_capabilities,
536 s.parm.output.capability, "V4L2_CAP_???");
538 tprintf(", outputmode=%u", s.parm.output.outputmode);
540 tprintf(", timeperframe=" FMT_FRACT,
541 ARGS_FRACT(s.parm.output.timeperframe));
543 tprintf(", extendedmode=%u, writebuffers=%u}",
544 s.parm.output.extendedmode,
545 s.parm.output.writebuffers);
553 print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg)
555 struct_v4l2_standard s;
559 if (umove_or_printaddr(tcp, arg, &s))
560 return RVAL_DECODED | 1;
561 tprintf("{index=%u", s.index);
563 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
565 print_quoted_string((const char *) s.name,
568 tprintf(", frameperiod=" FMT_FRACT,
569 ARGS_FRACT(s.frameperiod));
570 tprintf(", framelines=%d", s.framelines);
577 #include "xlat/v4l2_input_types.h"
580 print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
586 if (umove_or_printaddr(tcp, arg, &i))
587 return RVAL_DECODED | 1;
588 tprintf("{index=%u", i.index);
590 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
592 print_quoted_string((const char *) i.name,
596 printxval(v4l2_input_types, i.type,
597 "V4L2_INPUT_TYPE_???");
604 #include "xlat/v4l2_control_ids.h"
607 print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg,
610 struct v4l2_control c;
614 if (umove_or_printaddr(tcp, arg, &c))
615 return RVAL_DECODED | 1;
617 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
619 tprintf(", value=%d", c.value);
623 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
624 tprints(is_get ? ", " : " => ");
625 tprintf("value=%d", c.value);
632 #include "xlat/v4l2_control_types.h"
633 #include "xlat/v4l2_control_flags.h"
636 print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg)
638 struct v4l2_queryctrl c;
642 if (umove_or_printaddr(tcp, arg, &c))
643 return RVAL_DECODED | 1;
646 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
650 if (get_tcb_priv_ulong(tcp))
654 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
655 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
656 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
657 set_tcb_priv_ulong(tcp, next);
659 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
660 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
663 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
668 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
670 print_quoted_string((const char *) c.name,
673 tprintf(", minimum=%d, maximum=%d, step=%d"
674 ", default_value=%d, flags=",
675 c.minimum, c.maximum, c.step, c.default_value);
676 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
683 print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg)
685 struct v4l2_cropcap c;
689 if (umove_or_printaddr(tcp, arg, &c))
690 return RVAL_DECODED | 1;
692 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
695 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
696 tprintf(", bounds=" FMT_RECT
697 ", defrect=" FMT_RECT
698 ", pixelaspect=" FMT_FRACT,
700 ARGS_RECT(c.defrect),
701 ARGS_FRACT(c.pixelaspect));
708 print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg,
715 if (umove_or_printaddr(tcp, arg, &c))
716 return RVAL_DECODED | 1;
718 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
721 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
723 if (!syserror(tcp) && !umove(tcp, arg, &c))
724 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
728 return RVAL_DECODED | 1;
731 #ifdef VIDIOC_S_EXT_CTRLS
733 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
735 const struct_v4l2_ext_control *p = elem_buf;
738 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
739 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
740 tprintf(", size=%u", p->size);
742 tprints(", string=");
743 printstrn(tcp, ptr_to_kulong(p->string), p->size);
746 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
752 #include "xlat/v4l2_control_classes.h"
755 print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg,
758 struct_v4l2_ext_controls c;
762 if (umove_or_printaddr(tcp, arg, &c))
763 return RVAL_DECODED | 1;
764 tprints("{ctrl_class=");
765 printxval(v4l2_control_classes, c.ctrl_class,
766 "V4L2_CTRL_CLASS_???");
767 tprintf(", count=%u", c.count);
770 return RVAL_DECODED | 1;
776 if (umove(tcp, arg, &c) < 0) {
780 tprints(is_get ? ", " : " => ");
783 tprints("controls=");
784 struct_v4l2_ext_control ctrl;
785 bool fail = !print_array(tcp, ptr_to_kulong(c.controls), c.count,
787 umoven_or_printaddr_ignore_syserror,
788 print_v4l2_ext_control, 0);
790 if (exiting(tcp) && syserror(tcp))
791 tprintf(", error_idx=%u", c.error_idx);
793 if (exiting(tcp) || fail) {
795 return RVAL_DECODED | 1;
799 #endif /* VIDIOC_S_EXT_CTRLS */
801 #ifdef VIDIOC_ENUM_FRAMESIZES
802 # include "xlat/v4l2_framesize_types.h"
805 print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
807 struct v4l2_frmsizeenum s;
811 if (umove_or_printaddr(tcp, arg, &s))
812 return RVAL_DECODED | 1;
813 tprintf("{index=%u, pixel_format=", s.index);
814 print_pixelformat(s.pixel_format);
818 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
820 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
822 case V4L2_FRMSIZE_TYPE_DISCRETE:
823 tprintf(", discrete={width=%u, height=%u}",
824 s.discrete.width, s.discrete.height);
826 case V4L2_FRMSIZE_TYPE_STEPWISE:
827 tprintf(", stepwise={min_width=%u, max_width=%u, "
828 "step_width=%u, min_height=%u, max_height=%u, "
830 s.stepwise.min_width, s.stepwise.max_width,
831 s.stepwise.step_width, s.stepwise.min_height,
832 s.stepwise.max_height, s.stepwise.step_height);
839 #endif /* VIDIOC_ENUM_FRAMESIZES */
841 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
842 # include "xlat/v4l2_frameinterval_types.h"
845 print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
847 struct v4l2_frmivalenum f;
851 if (umove_or_printaddr(tcp, arg, &f))
852 return RVAL_DECODED | 1;
853 tprintf("{index=%u, pixel_format=", f.index);
854 print_pixelformat(f.pixel_format);
855 tprintf(", width=%u, height=%u", f.width, f.height);
858 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
860 printxval(v4l2_frameinterval_types, f.type,
861 "V4L2_FRMIVAL_TYPE_???");
863 case V4L2_FRMIVAL_TYPE_DISCRETE:
864 tprintf(", discrete=" FMT_FRACT,
865 ARGS_FRACT(f.discrete));
867 case V4L2_FRMIVAL_TYPE_STEPWISE:
868 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
869 tprintf(", stepwise={min=" FMT_FRACT ", max="
870 FMT_FRACT ", step=" FMT_FRACT "}",
871 ARGS_FRACT(f.stepwise.min),
872 ARGS_FRACT(f.stepwise.max),
873 ARGS_FRACT(f.stepwise.step));
880 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
882 #ifdef VIDIOC_CREATE_BUFS
884 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
886 struct_v4l2_create_buffers b;
890 if (umove_or_printaddr(tcp, arg, &b))
891 return RVAL_DECODED | 1;
892 tprintf("{count=%u, memory=", b.count);
893 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
894 tprints(", format={type=");
895 printxval(v4l2_buf_types, b.format.type,
896 "V4L2_BUF_TYPE_???");
897 print_v4l2_format_fmt(tcp, ", ",
898 (struct_v4l2_format *) &b.format);
902 static const char fmt[] = "{index=%u, count=%u}";
903 static char outstr[sizeof(fmt) + sizeof(int) * 6];
905 if (syserror(tcp) || umove(tcp, arg, &b) < 0)
907 sprintf(outstr, fmt, b.index, b.count);
908 tcp->auxstr = outstr;
912 #endif /* VIDIOC_CREATE_BUFS */
914 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
915 const unsigned int code, const kernel_ulong_t arg)
921 case VIDIOC_QUERYCAP: /* R */
922 return print_v4l2_capability(tcp, arg);
924 case VIDIOC_ENUM_FMT: /* RW */
925 return print_v4l2_fmtdesc(tcp, arg);
927 case VIDIOC_G_FMT: /* RW */
928 case VIDIOC_S_FMT: /* RW */
929 case VIDIOC_TRY_FMT: /* RW */
930 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
932 case VIDIOC_REQBUFS: /* RW */
933 return print_v4l2_requestbuffers(tcp, arg);
935 case VIDIOC_QUERYBUF: /* RW */
936 case VIDIOC_QBUF: /* RW */
937 case VIDIOC_DQBUF: /* RW */
938 return print_v4l2_buffer(tcp, code, arg);
940 case VIDIOC_G_FBUF: /* R */
944 case VIDIOC_S_FBUF: /* W */
945 return print_v4l2_framebuffer(tcp, arg);
947 case VIDIOC_STREAMON: /* W */
948 case VIDIOC_STREAMOFF: /* W */
949 return print_v4l2_buf_type(tcp, arg);
951 case VIDIOC_G_PARM: /* RW */
952 case VIDIOC_S_PARM: /* RW */
953 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
955 case VIDIOC_G_STD: /* R */
959 case VIDIOC_S_STD: /* W */
961 printnum_int64(tcp, arg, "%#" PRIx64);
962 return RVAL_DECODED | 1;
964 case VIDIOC_ENUMSTD: /* RW */
965 return print_v4l2_standard(tcp, arg);
967 case VIDIOC_ENUMINPUT: /* RW */
968 return print_v4l2_input(tcp, arg);
970 case VIDIOC_G_CTRL: /* RW */
971 case VIDIOC_S_CTRL: /* RW */
972 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
974 case VIDIOC_QUERYCTRL: /* RW */
975 return print_v4l2_queryctrl(tcp, arg);
977 case VIDIOC_G_INPUT: /* R */
981 case VIDIOC_S_INPUT: /* RW */
983 printnum_int(tcp, arg, "%u");
984 return RVAL_DECODED | 1;
986 case VIDIOC_CROPCAP: /* RW */
987 return print_v4l2_cropcap(tcp, arg);
989 case VIDIOC_G_CROP: /* RW */
990 case VIDIOC_S_CROP: /* W */
991 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
993 #ifdef VIDIOC_S_EXT_CTRLS
994 case VIDIOC_S_EXT_CTRLS: /* RW */
995 case VIDIOC_TRY_EXT_CTRLS: /* RW */
996 case VIDIOC_G_EXT_CTRLS: /* RW */
997 return print_v4l2_ext_controls(tcp, arg,
998 code == VIDIOC_G_EXT_CTRLS);
999 #endif /* VIDIOC_S_EXT_CTRLS */
1001 #ifdef VIDIOC_ENUM_FRAMESIZES
1002 case VIDIOC_ENUM_FRAMESIZES: /* RW */
1003 return print_v4l2_frmsizeenum(tcp, arg);
1004 #endif /* VIDIOC_ENUM_FRAMESIZES */
1006 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
1007 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
1008 return print_v4l2_frmivalenum(tcp, arg);
1009 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
1011 #ifdef VIDIOC_CREATE_BUFS
1012 case VIDIOC_CREATE_BUFS: /* RW */
1013 return print_v4l2_create_buffers(tcp, arg);
1014 #endif /* VIDIOC_CREATE_BUFS */
1017 return RVAL_DECODED;