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 /* some historical constants */
61 #ifndef V4L2_CID_HCENTER
62 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
64 #ifndef V4L2_CID_VCENTER
65 #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
67 #ifndef V4L2_CID_BAND_STOP_FILTER
68 #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
71 #define FMT_FRACT "%u/%u"
72 #define ARGS_FRACT(x) ((x).numerator), ((x).denominator)
74 #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}"
75 #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height
78 print_pixelformat(uint32_t fourcc)
82 unsigned char cc[sizeof(uint32_t)];
86 (unsigned char) (fourcc >> 24),
87 (unsigned char) (fourcc >> 16),
88 (unsigned char) (fourcc >> 8),
89 (unsigned char) fourcc
97 tprints("v4l2_fourcc(");
98 for (i = 0; i < sizeof(u.cc); ++i) {
99 unsigned char c = u.cc[i];
103 if (c == '\'' || c == '\\') {
112 } else if (c >= ' ' && c <= 0x7e) {
125 "0123456789abcdef"[c >> 4],
126 "0123456789abcdef"[c & 0xf],
136 #include "xlat/v4l2_device_capabilities_flags.h"
139 print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg)
141 struct v4l2_capability caps;
146 if (umove_or_printaddr(tcp, arg, &caps))
149 print_quoted_string((const char *) caps.driver,
150 sizeof(caps.driver), QUOTE_0_TERMINATED);
152 print_quoted_string((const char *) caps.card,
153 sizeof(caps.card), QUOTE_0_TERMINATED);
154 tprints(", bus_info=");
155 print_quoted_string((const char *) caps.bus_info,
156 sizeof(caps.bus_info), QUOTE_0_TERMINATED);
157 tprintf(", version=%u.%u.%u, capabilities=",
158 (caps.version >> 16) & 0xFF,
159 (caps.version >> 8) & 0xFF,
160 caps.version & 0xFF);
161 printflags(v4l2_device_capabilities_flags, caps.capabilities,
163 #ifdef V4L2_CAP_DEVICE_CAPS
164 tprints(", device_caps=");
165 printflags(v4l2_device_capabilities_flags, caps.device_caps,
172 #include "xlat/v4l2_buf_types.h"
173 #include "xlat/v4l2_format_description_flags.h"
176 print_v4l2_fmtdesc(struct tcb *const tcp, const kernel_ulong_t arg)
178 struct v4l2_fmtdesc f;
182 if (umove_or_printaddr(tcp, arg, &f))
183 return RVAL_DECODED | 1;
184 tprintf("{index=%u, type=", f.index);
185 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
189 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
191 printflags(v4l2_format_description_flags, f.flags,
192 "V4L2_FMT_FLAG_???");
193 tprints(", description=");
194 print_quoted_string((const char *) f.description,
195 sizeof(f.description),
197 tprints(", pixelformat=");
198 print_pixelformat(f.pixelformat);
204 #include "xlat/v4l2_fields.h"
205 #include "xlat/v4l2_colorspaces.h"
206 #include "xlat/v4l2_vbi_flags.h"
207 #include "xlat/v4l2_sliced_flags.h"
210 print_v4l2_clip(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
212 const struct_v4l2_clip *p = elem_buf;
213 tprintf(FMT_RECT, ARGS_RECT(p->c));
218 print_v4l2_format_fmt(struct tcb *const tcp, const char *prefix,
219 const struct_v4l2_format *f)
223 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
224 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
226 tprintf("fmt.pix={width=%u, height=%u, pixelformat=",
227 f->fmt.pix.width, f->fmt.pix.height);
228 print_pixelformat(f->fmt.pix.pixelformat);
230 printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???");
231 tprintf(", bytesperline=%u, sizeimage=%u, colorspace=",
232 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
233 printxval(v4l2_colorspaces, f->fmt.pix.colorspace,
234 "V4L2_COLORSPACE_???");
237 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
238 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
239 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: {
243 tprintf("fmt.pix_mp={width=%u, height=%u, pixelformat=",
244 f->fmt.pix_mp.width, f->fmt.pix_mp.height);
245 print_pixelformat(f->fmt.pix_mp.pixelformat);
247 printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???");
248 tprints(", colorspace=");
249 printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace,
250 "V4L2_COLORSPACE_???");
251 tprints(", plane_fmt=[");
252 max = f->fmt.pix_mp.num_planes;
253 if (max > VIDEO_MAX_PLANES)
254 max = VIDEO_MAX_PLANES;
255 for (i = 0; i < max; i++) {
258 tprintf("{sizeimage=%u, bytesperline=%u}",
259 f->fmt.pix_mp.plane_fmt[i].sizeimage,
260 f->fmt.pix_mp.plane_fmt[i].bytesperline);
262 tprintf("], num_planes=%u}",
263 (unsigned) f->fmt.pix_mp.num_planes);
267 /* OUTPUT_OVERLAY since Linux v2.6.22-rc1~1118^2~179 */
268 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
269 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
271 case V4L2_BUF_TYPE_VIDEO_OVERLAY: {
272 struct_v4l2_clip clip;
274 tprintf("fmt.win={left=%d, top=%d, width=%u, height=%u, field=",
275 ARGS_RECT(f->fmt.win.w));
276 printxval(v4l2_fields, f->fmt.win.field, "V4L2_FIELD_???");
277 tprintf(", chromakey=%#x, clips=", f->fmt.win.chromakey);
278 ret = print_array(tcp, ptr_to_kulong(f->fmt.win.clips),
279 f->fmt.win.clipcount, &clip, sizeof(clip),
280 umoven_or_printaddr, print_v4l2_clip, 0);
281 tprintf(", clipcount=%u, bitmap=", f->fmt.win.clipcount);
282 printaddr(ptr_to_kulong(f->fmt.win.bitmap));
283 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA
284 tprintf(", global_alpha=%#x", f->fmt.win.global_alpha);
289 case V4L2_BUF_TYPE_VBI_CAPTURE:
290 case V4L2_BUF_TYPE_VBI_OUTPUT:
292 tprintf("fmt.vbi={sampling_rate=%u, offset=%u, "
293 "samples_per_line=%u, sample_format=",
294 f->fmt.vbi.sampling_rate, f->fmt.vbi.offset,
295 f->fmt.vbi.samples_per_line);
296 print_pixelformat(f->fmt.vbi.sample_format);
297 tprintf(", start=[%u, %u], count=[%u, %u], ",
298 f->fmt.vbi.start[0], f->fmt.vbi.start[1],
299 f->fmt.vbi.count[0], f->fmt.vbi.count[1]);
301 printxval(v4l2_vbi_flags, f->fmt.vbi.flags, "V4L2_VBI_???");
304 /* both since Linux v2.6.14-rc2~64 */
305 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
306 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
307 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: {
311 tprints("fmt.sliced={service_set=");
312 printxval(v4l2_sliced_flags, f->fmt.sliced.service_set,
314 tprintf(", io_size=%u, service_lines=[",
315 f->fmt.sliced.io_size);
316 for (i = 0; i < ARRAY_SIZE(f->fmt.sliced.service_lines); i++) {
321 j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
326 f->fmt.sliced.service_lines[i][j]);
334 /* since Linux v4.4-rc1~118^2~14 */
335 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT
336 case V4L2_BUF_TYPE_SDR_OUTPUT:
338 /* since Linux v3.15-rc1~85^2~213 */
339 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
340 case V4L2_BUF_TYPE_SDR_CAPTURE:
342 tprints("fmt.sdr={pixelformat=");
343 print_pixelformat(f->fmt.sdr.pixelformat);
344 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
345 tprintf(", buffersize=%u",
346 f->fmt.sdr.buffersize);
356 print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg,
359 struct_v4l2_format f;
363 if (umove_or_printaddr(tcp, arg, &f))
364 return RVAL_DECODED | 1;
366 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
369 if (!print_v4l2_format_fmt(tcp, ", ", &f)) {
371 return RVAL_DECODED | 1;
374 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
375 const char *delim = is_get ? ", " : " => ";
376 print_v4l2_format_fmt(tcp, delim, &f);
383 #include "xlat/v4l2_memories.h"
386 print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg)
388 struct v4l2_requestbuffers reqbufs;
392 if (umove_or_printaddr(tcp, arg, &reqbufs))
393 return RVAL_DECODED | 1;
394 tprintf("{count=%u, type=", reqbufs.count);
395 printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???");
396 tprints(", memory=");
397 printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???");
401 static char outstr[sizeof("{count=}") + sizeof(int) * 3];
403 if (syserror(tcp) || umove(tcp, arg, &reqbufs) < 0)
405 sprintf(outstr, "{count=%u}", reqbufs.count);
406 tcp->auxstr = outstr;
411 #include "xlat/v4l2_buf_flags.h"
414 print_v4l2_buffer(struct tcb *const tcp, const unsigned int code,
415 const kernel_ulong_t arg)
417 struct_v4l2_buffer b;
421 if (umove_or_printaddr(tcp, arg, &b))
422 return RVAL_DECODED | 1;
424 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
425 if (code != VIDIOC_DQBUF)
426 tprintf(", index=%u", b.index);
428 if (!syserror(tcp) && umove(tcp, arg, &b) == 0) {
429 if (code == VIDIOC_DQBUF)
430 tprintf(", index=%u", b.index);
431 tprints(", memory=");
432 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
434 if (b.memory == V4L2_MEMORY_MMAP) {
435 tprintf(", m.offset=%#x", b.m.offset);
436 } else if (b.memory == V4L2_MEMORY_USERPTR) {
437 tprints(", m.userptr=");
438 printaddr(b.m.userptr);
441 tprintf(", length=%u, bytesused=%u, flags=",
442 b.length, b.bytesused);
443 printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
444 if (code == VIDIOC_DQBUF) {
445 tprints(", timestamp = ");
446 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
456 print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg)
458 struct_v4l2_framebuffer b;
461 if (!umove_or_printaddr(tcp, arg, &b)) {
462 tprintf("{capability=%#x, flags=%#x, base=",
463 b.capability, b.flags);
464 printaddr(ptr_to_kulong(b.base));
468 return RVAL_DECODED | 1;
472 print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg)
477 if (!umove_or_printaddr(tcp, arg, &type)) {
479 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
482 return RVAL_DECODED | 1;
485 #include "xlat/v4l2_streaming_capabilities.h"
486 #include "xlat/v4l2_capture_modes.h"
489 print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg,
492 struct v4l2_streamparm s;
496 if (umove_or_printaddr(tcp, arg, &s))
497 return RVAL_DECODED | 1;
499 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
501 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
502 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
509 return RVAL_DECODED | 1;
512 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
516 tprints(is_get ? ", " : " => ");
519 if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
520 tprints("parm.capture={capability=");
521 printflags(v4l2_streaming_capabilities,
522 s.parm.capture.capability, "V4L2_CAP_???");
524 tprints(", capturemode=");
525 printflags(v4l2_capture_modes,
526 s.parm.capture.capturemode, "V4L2_MODE_???");
528 tprintf(", timeperframe=" FMT_FRACT,
529 ARGS_FRACT(s.parm.capture.timeperframe));
531 tprintf(", extendedmode=%u, readbuffers=%u}",
532 s.parm.capture.extendedmode,
533 s.parm.capture.readbuffers);
535 tprints("parm.output={capability=");
536 printflags(v4l2_streaming_capabilities,
537 s.parm.output.capability, "V4L2_CAP_???");
539 tprintf(", outputmode=%u", s.parm.output.outputmode);
541 tprintf(", timeperframe=" FMT_FRACT,
542 ARGS_FRACT(s.parm.output.timeperframe));
544 tprintf(", extendedmode=%u, writebuffers=%u}",
545 s.parm.output.extendedmode,
546 s.parm.output.writebuffers);
554 print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg)
556 struct_v4l2_standard s;
560 if (umove_or_printaddr(tcp, arg, &s))
561 return RVAL_DECODED | 1;
562 tprintf("{index=%u", s.index);
564 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
566 print_quoted_string((const char *) s.name,
569 tprintf(", frameperiod=" FMT_FRACT,
570 ARGS_FRACT(s.frameperiod));
571 tprintf(", framelines=%d", s.framelines);
578 #include "xlat/v4l2_input_types.h"
581 print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
587 if (umove_or_printaddr(tcp, arg, &i))
588 return RVAL_DECODED | 1;
589 tprintf("{index=%u", i.index);
591 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
593 print_quoted_string((const char *) i.name,
597 printxval(v4l2_input_types, i.type,
598 "V4L2_INPUT_TYPE_???");
605 #include "xlat/v4l2_control_ids.h"
608 print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg,
611 struct v4l2_control c;
615 if (umove_or_printaddr(tcp, arg, &c))
616 return RVAL_DECODED | 1;
618 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
620 tprintf(", value=%d", c.value);
624 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
625 tprints(is_get ? ", " : " => ");
626 tprintf("value=%d", c.value);
633 #include "xlat/v4l2_tuner_types.h"
634 #include "xlat/v4l2_tuner_capabilities.h"
635 #include "xlat/v4l2_tuner_rxsubchanses.h"
636 #include "xlat/v4l2_tuner_audmodes.h"
639 print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg,
645 if (umove_or_printaddr(tcp, arg, &c))
646 return RVAL_DECODED | 1;
647 tprintf("{index=%u", c.index);
652 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
656 tprints(is_get ? ", " : " => ");
660 print_quoted_string((const char *) c.name, sizeof(c.name),
663 printxval(v4l2_tuner_types, c.type, "V4L2_TUNER_TYPE_???");
664 tprints(", capability=");
665 printxval(v4l2_tuner_capabilities, c.capability,
666 "V4L2_TUNER_CAP_???");
667 tprintf(", rangelow=%u, rangehigh=%u, rxsubchans=",
668 c.rangelow, c.rangehigh);
669 printxval(v4l2_tuner_rxsubchanses, c.rxsubchans,
670 "V4L2_TUNER_SUB_???");
671 tprints(", audmode=");
672 printxval(v4l2_tuner_audmodes, c.audmode,
673 "V4L2_TUNER_MODE_???");
674 tprintf(", signal=%d, afc=%d", c.signal, c.afc);
681 #include "xlat/v4l2_control_types.h"
682 #include "xlat/v4l2_control_flags.h"
685 print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg)
687 struct v4l2_queryctrl c;
691 if (umove_or_printaddr(tcp, arg, &c))
692 return RVAL_DECODED | 1;
695 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
699 if (get_tcb_priv_ulong(tcp))
703 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
704 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
705 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
706 set_tcb_priv_ulong(tcp, next);
708 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
709 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
712 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
717 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
719 print_quoted_string((const char *) c.name,
722 tprintf(", minimum=%d, maximum=%d, step=%d"
723 ", default_value=%d, flags=",
724 c.minimum, c.maximum, c.step, c.default_value);
725 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
732 print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg)
734 struct v4l2_cropcap c;
738 if (umove_or_printaddr(tcp, arg, &c))
739 return RVAL_DECODED | 1;
741 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
744 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
745 tprintf(", bounds=" FMT_RECT
746 ", defrect=" FMT_RECT
747 ", pixelaspect=" FMT_FRACT,
749 ARGS_RECT(c.defrect),
750 ARGS_FRACT(c.pixelaspect));
757 print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg,
764 if (umove_or_printaddr(tcp, arg, &c))
765 return RVAL_DECODED | 1;
767 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
770 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
772 if (!syserror(tcp) && !umove(tcp, arg, &c))
773 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
777 return RVAL_DECODED | 1;
780 #ifdef VIDIOC_S_EXT_CTRLS
782 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
784 const struct_v4l2_ext_control *p = elem_buf;
787 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
788 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
789 tprintf(", size=%u", p->size);
791 tprints(", string=");
792 printstrn(tcp, ptr_to_kulong(p->string), p->size);
795 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
801 #include "xlat/v4l2_control_classes.h"
804 print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg,
807 struct_v4l2_ext_controls c;
811 if (umove_or_printaddr(tcp, arg, &c))
812 return RVAL_DECODED | 1;
813 tprints("{ctrl_class=");
814 printxval(v4l2_control_classes, c.ctrl_class,
815 "V4L2_CTRL_CLASS_???");
816 tprintf(", count=%u", c.count);
819 return RVAL_DECODED | 1;
825 if (umove(tcp, arg, &c) < 0) {
829 tprints(is_get ? ", " : " => ");
832 tprints("controls=");
833 struct_v4l2_ext_control ctrl;
834 bool fail = !print_array(tcp, ptr_to_kulong(c.controls), c.count,
836 umoven_or_printaddr_ignore_syserror,
837 print_v4l2_ext_control, 0);
839 if (exiting(tcp) && syserror(tcp))
840 tprintf(", error_idx=%u", c.error_idx);
842 if (exiting(tcp) || fail) {
844 return RVAL_DECODED | 1;
848 #endif /* VIDIOC_S_EXT_CTRLS */
850 #ifdef VIDIOC_ENUM_FRAMESIZES
851 # include "xlat/v4l2_framesize_types.h"
854 print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
856 struct v4l2_frmsizeenum s;
860 if (umove_or_printaddr(tcp, arg, &s))
861 return RVAL_DECODED | 1;
862 tprintf("{index=%u, pixel_format=", s.index);
863 print_pixelformat(s.pixel_format);
867 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
869 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
871 case V4L2_FRMSIZE_TYPE_DISCRETE:
872 tprintf(", discrete={width=%u, height=%u}",
873 s.discrete.width, s.discrete.height);
875 case V4L2_FRMSIZE_TYPE_STEPWISE:
876 tprintf(", stepwise={min_width=%u, max_width=%u, "
877 "step_width=%u, min_height=%u, max_height=%u, "
879 s.stepwise.min_width, s.stepwise.max_width,
880 s.stepwise.step_width, s.stepwise.min_height,
881 s.stepwise.max_height, s.stepwise.step_height);
888 #endif /* VIDIOC_ENUM_FRAMESIZES */
890 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
891 # include "xlat/v4l2_frameinterval_types.h"
894 print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
896 struct v4l2_frmivalenum f;
900 if (umove_or_printaddr(tcp, arg, &f))
901 return RVAL_DECODED | 1;
902 tprintf("{index=%u, pixel_format=", f.index);
903 print_pixelformat(f.pixel_format);
904 tprintf(", width=%u, height=%u", f.width, f.height);
907 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
909 printxval(v4l2_frameinterval_types, f.type,
910 "V4L2_FRMIVAL_TYPE_???");
912 case V4L2_FRMIVAL_TYPE_DISCRETE:
913 tprintf(", discrete=" FMT_FRACT,
914 ARGS_FRACT(f.discrete));
916 case V4L2_FRMIVAL_TYPE_STEPWISE:
917 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
918 tprintf(", stepwise={min=" FMT_FRACT ", max="
919 FMT_FRACT ", step=" FMT_FRACT "}",
920 ARGS_FRACT(f.stepwise.min),
921 ARGS_FRACT(f.stepwise.max),
922 ARGS_FRACT(f.stepwise.step));
929 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
931 #ifdef VIDIOC_CREATE_BUFS
933 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
935 struct_v4l2_create_buffers b;
939 if (umove_or_printaddr(tcp, arg, &b))
940 return RVAL_DECODED | 1;
941 tprintf("{count=%u, memory=", b.count);
942 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
943 tprints(", format={type=");
944 printxval(v4l2_buf_types, b.format.type,
945 "V4L2_BUF_TYPE_???");
946 print_v4l2_format_fmt(tcp, ", ",
947 (struct_v4l2_format *) &b.format);
951 static const char fmt[] = "{index=%u, count=%u}";
952 static char outstr[sizeof(fmt) + sizeof(int) * 6];
954 if (syserror(tcp) || umove(tcp, arg, &b) < 0)
956 sprintf(outstr, fmt, b.index, b.count);
957 tcp->auxstr = outstr;
961 #endif /* VIDIOC_CREATE_BUFS */
963 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
964 const unsigned int code, const kernel_ulong_t arg)
970 case VIDIOC_QUERYCAP: /* R */
971 return print_v4l2_capability(tcp, arg);
973 case VIDIOC_ENUM_FMT: /* RW */
974 return print_v4l2_fmtdesc(tcp, arg);
976 case VIDIOC_G_FMT: /* RW */
977 case VIDIOC_S_FMT: /* RW */
978 case VIDIOC_TRY_FMT: /* RW */
979 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
981 case VIDIOC_REQBUFS: /* RW */
982 return print_v4l2_requestbuffers(tcp, arg);
984 case VIDIOC_QUERYBUF: /* RW */
985 case VIDIOC_QBUF: /* RW */
986 case VIDIOC_DQBUF: /* RW */
987 return print_v4l2_buffer(tcp, code, arg);
989 case VIDIOC_G_FBUF: /* R */
993 case VIDIOC_S_FBUF: /* W */
994 return print_v4l2_framebuffer(tcp, arg);
996 case VIDIOC_STREAMON: /* W */
997 case VIDIOC_STREAMOFF: /* W */
998 return print_v4l2_buf_type(tcp, arg);
1000 case VIDIOC_G_PARM: /* RW */
1001 case VIDIOC_S_PARM: /* RW */
1002 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
1004 case VIDIOC_G_STD: /* R */
1008 case VIDIOC_S_STD: /* W */
1010 printnum_int64(tcp, arg, "%#" PRIx64);
1011 return RVAL_DECODED | 1;
1013 case VIDIOC_ENUMSTD: /* RW */
1014 return print_v4l2_standard(tcp, arg);
1016 case VIDIOC_ENUMINPUT: /* RW */
1017 return print_v4l2_input(tcp, arg);
1019 case VIDIOC_G_CTRL: /* RW */
1020 case VIDIOC_S_CTRL: /* RW */
1021 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
1023 case VIDIOC_G_TUNER: /* RW */
1024 case VIDIOC_S_TUNER: /* RW */
1025 return print_v4l2_tuner(tcp, arg, code == VIDIOC_G_TUNER);
1027 case VIDIOC_QUERYCTRL: /* RW */
1028 return print_v4l2_queryctrl(tcp, arg);
1030 case VIDIOC_G_INPUT: /* R */
1034 case VIDIOC_S_INPUT: /* RW */
1036 printnum_int(tcp, arg, "%u");
1037 return RVAL_DECODED | 1;
1039 case VIDIOC_CROPCAP: /* RW */
1040 return print_v4l2_cropcap(tcp, arg);
1042 case VIDIOC_G_CROP: /* RW */
1043 case VIDIOC_S_CROP: /* W */
1044 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
1046 #ifdef VIDIOC_S_EXT_CTRLS
1047 case VIDIOC_S_EXT_CTRLS: /* RW */
1048 case VIDIOC_TRY_EXT_CTRLS: /* RW */
1049 case VIDIOC_G_EXT_CTRLS: /* RW */
1050 return print_v4l2_ext_controls(tcp, arg,
1051 code == VIDIOC_G_EXT_CTRLS);
1052 #endif /* VIDIOC_S_EXT_CTRLS */
1054 #ifdef VIDIOC_ENUM_FRAMESIZES
1055 case VIDIOC_ENUM_FRAMESIZES: /* RW */
1056 return print_v4l2_frmsizeenum(tcp, arg);
1057 #endif /* VIDIOC_ENUM_FRAMESIZES */
1059 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
1060 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
1061 return print_v4l2_frmivalenum(tcp, arg);
1062 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
1064 #ifdef VIDIOC_CREATE_BUFS
1065 case VIDIOC_CREATE_BUFS: /* RW */
1066 return print_v4l2_create_buffers(tcp, arg);
1067 #endif /* VIDIOC_CREATE_BUFS */
1070 return RVAL_DECODED;