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"
63 /* some historical constants */
64 #ifndef V4L2_CID_HCENTER
65 #define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
67 #ifndef V4L2_CID_VCENTER
68 #define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
70 #ifndef V4L2_CID_BAND_STOP_FILTER
71 #define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
74 #define FMT_FRACT "%u/%u"
75 #define ARGS_FRACT(x) ((x).numerator), ((x).denominator)
77 #define FMT_RECT "{left=%d, top=%d, width=%u, height=%u}"
78 #define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height
81 print_pixelformat(uint32_t fourcc)
85 unsigned char cc[sizeof(uint32_t)];
89 (unsigned char) (fourcc >> 24),
90 (unsigned char) (fourcc >> 16),
91 (unsigned char) (fourcc >> 8),
92 (unsigned char) fourcc
100 tprints("v4l2_fourcc(");
101 for (i = 0; i < sizeof(u.cc); ++i) {
102 unsigned char c = u.cc[i];
106 if (c == '\'' || c == '\\') {
115 } else if (c >= ' ' && c <= 0x7e) {
128 "0123456789abcdef"[c >> 4],
129 "0123456789abcdef"[c & 0xf],
139 #include "xlat/v4l2_device_capabilities_flags.h"
142 print_v4l2_capability(struct tcb *const tcp, const kernel_ulong_t arg)
144 struct v4l2_capability caps;
149 if (umove_or_printaddr(tcp, arg, &caps))
150 return RVAL_IOCTL_DECODED;
151 PRINT_FIELD_CSTRING("{", caps, driver);
152 PRINT_FIELD_CSTRING(", ", caps, card);
153 PRINT_FIELD_CSTRING(", ", caps, bus_info);
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,
166 return RVAL_IOCTL_DECODED;
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_IOCTL_DECODED;
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 PRINT_FIELD_CSTRING(", ", f, description);
191 tprints(", pixelformat=");
192 print_pixelformat(f.pixelformat);
195 return RVAL_IOCTL_DECODED;
198 #include "xlat/v4l2_fields.h"
199 #include "xlat/v4l2_colorspaces.h"
200 #include "xlat/v4l2_vbi_flags.h"
201 #include "xlat/v4l2_sliced_flags.h"
204 print_v4l2_clip(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
206 const struct_v4l2_clip *p = elem_buf;
207 tprintf(FMT_RECT, ARGS_RECT(p->c));
212 print_v4l2_format_fmt(struct tcb *const tcp, const char *prefix,
213 const struct_v4l2_format *f)
217 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
218 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
220 tprintf("fmt.pix={width=%u, height=%u, pixelformat=",
221 f->fmt.pix.width, f->fmt.pix.height);
222 print_pixelformat(f->fmt.pix.pixelformat);
224 printxval(v4l2_fields, f->fmt.pix.field, "V4L2_FIELD_???");
225 tprintf(", bytesperline=%u, sizeimage=%u, colorspace=",
226 f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
227 printxval(v4l2_colorspaces, f->fmt.pix.colorspace,
228 "V4L2_COLORSPACE_???");
231 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
232 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
233 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: {
237 tprintf("fmt.pix_mp={width=%u, height=%u, pixelformat=",
238 f->fmt.pix_mp.width, f->fmt.pix_mp.height);
239 print_pixelformat(f->fmt.pix_mp.pixelformat);
241 printxval(v4l2_fields, f->fmt.pix_mp.field, "V4L2_FIELD_???");
242 tprints(", colorspace=");
243 printxval(v4l2_colorspaces, f->fmt.pix_mp.colorspace,
244 "V4L2_COLORSPACE_???");
245 tprints(", plane_fmt=[");
246 max = f->fmt.pix_mp.num_planes;
247 if (max > VIDEO_MAX_PLANES)
248 max = VIDEO_MAX_PLANES;
249 for (i = 0; i < max; i++) {
252 tprintf("{sizeimage=%u, bytesperline=%u}",
253 f->fmt.pix_mp.plane_fmt[i].sizeimage,
254 f->fmt.pix_mp.plane_fmt[i].bytesperline);
256 tprintf("], num_planes=%u}",
257 (unsigned) f->fmt.pix_mp.num_planes);
261 /* OUTPUT_OVERLAY since Linux v2.6.22-rc1~1118^2~179 */
262 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
263 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
265 case V4L2_BUF_TYPE_VIDEO_OVERLAY: {
266 struct_v4l2_clip clip;
268 tprintf("fmt.win={left=%d, top=%d, width=%u, height=%u, field=",
269 ARGS_RECT(f->fmt.win.w));
270 printxval(v4l2_fields, f->fmt.win.field, "V4L2_FIELD_???");
271 tprintf(", chromakey=%#x, clips=", f->fmt.win.chromakey);
272 ret = print_array(tcp, ptr_to_kulong(f->fmt.win.clips),
273 f->fmt.win.clipcount, &clip, sizeof(clip),
274 umoven_or_printaddr, print_v4l2_clip, 0);
275 tprintf(", clipcount=%u, bitmap=", f->fmt.win.clipcount);
276 printaddr(ptr_to_kulong(f->fmt.win.bitmap));
277 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA
278 tprintf(", global_alpha=%#x", f->fmt.win.global_alpha);
283 case V4L2_BUF_TYPE_VBI_CAPTURE:
284 case V4L2_BUF_TYPE_VBI_OUTPUT:
286 tprintf("fmt.vbi={sampling_rate=%u, offset=%u, "
287 "samples_per_line=%u, sample_format=",
288 f->fmt.vbi.sampling_rate, f->fmt.vbi.offset,
289 f->fmt.vbi.samples_per_line);
290 print_pixelformat(f->fmt.vbi.sample_format);
291 tprintf(", start=[%u, %u], count=[%u, %u], ",
292 f->fmt.vbi.start[0], f->fmt.vbi.start[1],
293 f->fmt.vbi.count[0], f->fmt.vbi.count[1]);
295 printxval(v4l2_vbi_flags, f->fmt.vbi.flags, "V4L2_VBI_???");
298 /* both since Linux v2.6.14-rc2~64 */
299 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
300 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
301 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: {
305 tprints("fmt.sliced={service_set=");
306 printxval(v4l2_sliced_flags, f->fmt.sliced.service_set,
308 tprintf(", io_size=%u, service_lines=[",
309 f->fmt.sliced.io_size);
310 for (i = 0; i < ARRAY_SIZE(f->fmt.sliced.service_lines); i++) {
315 j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]);
320 f->fmt.sliced.service_lines[i][j]);
328 /* since Linux v4.4-rc1~118^2~14 */
329 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT
330 case V4L2_BUF_TYPE_SDR_OUTPUT:
332 /* since Linux v3.15-rc1~85^2~213 */
333 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE
334 case V4L2_BUF_TYPE_SDR_CAPTURE:
336 tprints("fmt.sdr={pixelformat=");
337 print_pixelformat(f->fmt.sdr.pixelformat);
338 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE
339 tprintf(", buffersize=%u",
340 f->fmt.sdr.buffersize);
350 print_v4l2_format(struct tcb *const tcp, const kernel_ulong_t arg,
353 struct_v4l2_format f;
357 if (umove_or_printaddr(tcp, arg, &f))
358 return RVAL_IOCTL_DECODED;
360 printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???");
363 if (!print_v4l2_format_fmt(tcp, ", ", &f)) {
365 return RVAL_IOCTL_DECODED;
371 if (!syserror(tcp) && !umove(tcp, arg, &f))
372 print_v4l2_format_fmt(tcp, is_get ? ", " : " => ", &f);
376 return RVAL_IOCTL_DECODED;
379 #include "xlat/v4l2_memories.h"
382 print_v4l2_requestbuffers(struct tcb *const tcp, const kernel_ulong_t arg)
384 struct v4l2_requestbuffers reqbufs;
389 if (umove_or_printaddr(tcp, arg, &reqbufs))
390 return RVAL_IOCTL_DECODED;
393 printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???");
394 tprints(", memory=");
395 printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???");
396 tprintf(", count=%u", reqbufs.count);
401 if (!syserror(tcp)) {
404 if (!umove(tcp, arg, &reqbufs))
405 tprintf("%u", reqbufs.count);
412 return RVAL_IOCTL_DECODED;
415 #include "xlat/v4l2_buf_flags.h"
418 print_v4l2_buffer(struct tcb *const tcp, const unsigned int code,
419 const kernel_ulong_t arg)
421 struct_v4l2_buffer b;
425 if (umove_or_printaddr(tcp, arg, &b))
426 return RVAL_IOCTL_DECODED;
428 printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???");
429 if (code != VIDIOC_DQBUF)
430 tprintf(", index=%u", b.index);
435 if (!syserror(tcp) && !umove(tcp, arg, &b)) {
436 if (code == VIDIOC_DQBUF)
437 tprintf(", index=%u", b.index);
438 tprints(", memory=");
439 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
441 if (b.memory == V4L2_MEMORY_MMAP) {
442 tprintf(", m.offset=%#x", b.m.offset);
443 } else if (b.memory == V4L2_MEMORY_USERPTR) {
444 tprints(", m.userptr=");
445 printaddr(b.m.userptr);
448 tprintf(", length=%u, bytesused=%u, flags=",
449 b.length, b.bytesused);
450 printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
451 if (code == VIDIOC_DQBUF) {
452 tprints(", timestamp = ");
453 MPERS_FUNC_NAME(print_struct_timeval)(&b.timestamp);
460 return RVAL_IOCTL_DECODED;
464 print_v4l2_framebuffer(struct tcb *const tcp, const kernel_ulong_t arg)
466 struct_v4l2_framebuffer b;
469 if (!umove_or_printaddr(tcp, arg, &b)) {
470 tprintf("{capability=%#x, flags=%#x, base=",
471 b.capability, b.flags);
472 printaddr(ptr_to_kulong(b.base));
476 return RVAL_IOCTL_DECODED;
480 print_v4l2_buf_type(struct tcb *const tcp, const kernel_ulong_t arg)
485 if (!umove_or_printaddr(tcp, arg, &type)) {
487 printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???");
490 return RVAL_IOCTL_DECODED;
493 #include "xlat/v4l2_streaming_capabilities.h"
494 #include "xlat/v4l2_capture_modes.h"
497 print_v4l2_streamparm(struct tcb *const tcp, const kernel_ulong_t arg,
500 struct v4l2_streamparm s;
504 if (umove_or_printaddr(tcp, arg, &s))
505 return RVAL_IOCTL_DECODED;
507 printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???");
509 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
510 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
517 return RVAL_IOCTL_DECODED;
520 if (syserror(tcp) || umove(tcp, arg, &s) < 0) {
522 return RVAL_IOCTL_DECODED;
524 tprints(is_get ? ", " : " => ");
527 if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
528 tprints("parm.capture={capability=");
529 printflags(v4l2_streaming_capabilities,
530 s.parm.capture.capability, "V4L2_CAP_???");
532 tprints(", capturemode=");
533 printflags(v4l2_capture_modes,
534 s.parm.capture.capturemode, "V4L2_MODE_???");
536 tprintf(", timeperframe=" FMT_FRACT,
537 ARGS_FRACT(s.parm.capture.timeperframe));
539 tprintf(", extendedmode=%u, readbuffers=%u}",
540 s.parm.capture.extendedmode,
541 s.parm.capture.readbuffers);
543 tprints("parm.output={capability=");
544 printflags(v4l2_streaming_capabilities,
545 s.parm.output.capability, "V4L2_CAP_???");
547 tprintf(", outputmode=%u", s.parm.output.outputmode);
549 tprintf(", timeperframe=" FMT_FRACT,
550 ARGS_FRACT(s.parm.output.timeperframe));
552 tprintf(", extendedmode=%u, writebuffers=%u}",
553 s.parm.output.extendedmode,
554 s.parm.output.writebuffers);
560 return RVAL_IOCTL_DECODED;
565 print_v4l2_standard(struct tcb *const tcp, const kernel_ulong_t arg)
567 struct_v4l2_standard s;
571 if (umove_or_printaddr(tcp, arg, &s))
572 return RVAL_IOCTL_DECODED;
573 tprintf("{index=%u", s.index);
578 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
579 PRINT_FIELD_CSTRING(", ", s, name);
580 tprintf(", frameperiod=" FMT_FRACT,
581 ARGS_FRACT(s.frameperiod));
582 tprintf(", framelines=%d", s.framelines);
587 return RVAL_IOCTL_DECODED;
590 #include "xlat/v4l2_input_types.h"
593 print_v4l2_input(struct tcb *const tcp, const kernel_ulong_t arg)
599 if (umove_or_printaddr(tcp, arg, &i))
600 return RVAL_IOCTL_DECODED;
601 tprintf("{index=%u", i.index);
606 if (!syserror(tcp) && !umove(tcp, arg, &i)) {
607 PRINT_FIELD_CSTRING(", ", i, name);
609 printxval(v4l2_input_types, i.type, "V4L2_INPUT_TYPE_???");
614 return RVAL_IOCTL_DECODED;
617 #include "xlat/v4l2_control_ids.h"
620 print_v4l2_control(struct tcb *const tcp, const kernel_ulong_t arg,
623 struct v4l2_control c;
627 if (umove_or_printaddr(tcp, arg, &c))
628 return RVAL_IOCTL_DECODED;
630 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
632 tprintf(", value=%d", c.value);
636 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
637 tprints(is_get ? ", " : " => ");
638 tprintf("value=%d", c.value);
643 return RVAL_IOCTL_DECODED;
646 #include "xlat/v4l2_tuner_types.h"
647 #include "xlat/v4l2_tuner_capabilities.h"
648 #include "xlat/v4l2_tuner_rxsubchanses.h"
649 #include "xlat/v4l2_tuner_audmodes.h"
652 print_v4l2_tuner(struct tcb *const tcp, const kernel_ulong_t arg,
658 if (umove_or_printaddr(tcp, arg, &c))
659 return RVAL_IOCTL_DECODED;
660 tprintf("{index=%u", c.index);
665 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
667 return RVAL_IOCTL_DECODED;
669 tprints(is_get ? ", " : " => ");
672 PRINT_FIELD_CSTRING("", c, name);
674 printxval(v4l2_tuner_types, c.type, "V4L2_TUNER_TYPE_???");
675 tprints(", capability=");
676 printxval(v4l2_tuner_capabilities, c.capability,
677 "V4L2_TUNER_CAP_???");
678 tprintf(", rangelow=%u, rangehigh=%u, rxsubchans=",
679 c.rangelow, c.rangehigh);
680 printxval(v4l2_tuner_rxsubchanses, c.rxsubchans,
681 "V4L2_TUNER_SUB_???");
682 tprints(", audmode=");
683 printxval(v4l2_tuner_audmodes, c.audmode,
684 "V4L2_TUNER_MODE_???");
685 tprintf(", signal=%d, afc=%d", c.signal, c.afc);
691 return RVAL_IOCTL_DECODED;
695 #include "xlat/v4l2_control_types.h"
696 #include "xlat/v4l2_control_flags.h"
699 print_v4l2_queryctrl(struct tcb *const tcp, const kernel_ulong_t arg)
701 struct v4l2_queryctrl c;
705 if (umove_or_printaddr(tcp, arg, &c))
706 return RVAL_IOCTL_DECODED;
709 if (syserror(tcp) || umove(tcp, arg, &c) < 0) {
711 return RVAL_IOCTL_DECODED;
713 if (get_tcb_priv_ulong(tcp))
717 if (entering(tcp) || get_tcb_priv_ulong(tcp)) {
718 #ifdef V4L2_CTRL_FLAG_NEXT_CTRL
719 const unsigned long next = c.id & V4L2_CTRL_FLAG_NEXT_CTRL;
720 set_tcb_priv_ulong(tcp, next);
722 tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
723 c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
726 printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
731 printxval(v4l2_control_types, c.type, "V4L2_CTRL_TYPE_???");
732 PRINT_FIELD_CSTRING(", ", c, name);
733 tprintf(", minimum=%d, maximum=%d, step=%d"
734 ", default_value=%d, flags=",
735 c.minimum, c.maximum, c.step, c.default_value);
736 printflags(v4l2_control_flags, c.flags, "V4L2_CTRL_FLAG_???");
739 return entering(tcp) ? 0 : RVAL_IOCTL_DECODED;
743 print_v4l2_cropcap(struct tcb *const tcp, const kernel_ulong_t arg)
745 struct v4l2_cropcap c;
749 if (umove_or_printaddr(tcp, arg, &c))
750 return RVAL_IOCTL_DECODED;
752 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
757 if (!syserror(tcp) && !umove(tcp, arg, &c)) {
758 tprintf(", bounds=" FMT_RECT
759 ", defrect=" FMT_RECT
760 ", pixelaspect=" FMT_FRACT,
762 ARGS_RECT(c.defrect),
763 ARGS_FRACT(c.pixelaspect));
768 return RVAL_IOCTL_DECODED;
772 print_v4l2_crop(struct tcb *const tcp, const kernel_ulong_t arg,
779 if (umove_or_printaddr(tcp, arg, &c))
780 return RVAL_IOCTL_DECODED;
782 printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???");
785 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
787 if (!syserror(tcp) && !umove(tcp, arg, &c))
788 tprintf(", c=" FMT_RECT, ARGS_RECT(c.c));
793 return RVAL_IOCTL_DECODED;
796 #ifdef VIDIOC_S_EXT_CTRLS
798 print_v4l2_ext_control(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
800 const struct_v4l2_ext_control *p = elem_buf;
803 printxval(v4l2_control_ids, p->id, "V4L2_CID_???");
804 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING
805 tprintf(", size=%u", p->size);
807 tprints(", string=");
808 printstrn(tcp, ptr_to_kulong(p->string), p->size);
811 tprintf(", value=%d, value64=%" PRId64, p->value, (int64_t) p->value64);
817 #include "xlat/v4l2_control_classes.h"
820 print_v4l2_ext_controls(struct tcb *const tcp, const kernel_ulong_t arg,
823 struct_v4l2_ext_controls c;
827 if (umove_or_printaddr(tcp, arg, &c))
828 return RVAL_IOCTL_DECODED;
829 tprints("{ctrl_class=");
830 printxval(v4l2_control_classes, c.ctrl_class,
831 "V4L2_CTRL_CLASS_???");
832 tprintf(", count=%u", c.count);
835 return RVAL_IOCTL_DECODED;
841 if (umove(tcp, arg, &c) < 0) {
843 return RVAL_IOCTL_DECODED;
845 tprints(is_get ? ", " : " => ");
848 tprints("controls=");
849 struct_v4l2_ext_control ctrl;
850 bool fail = !print_array(tcp, ptr_to_kulong(c.controls), c.count,
852 umoven_or_printaddr_ignore_syserror,
853 print_v4l2_ext_control, 0);
855 if (exiting(tcp) && syserror(tcp))
856 tprintf(", error_idx=%u", c.error_idx);
858 if (exiting(tcp) || fail) {
860 return RVAL_IOCTL_DECODED;
866 #endif /* VIDIOC_S_EXT_CTRLS */
868 #ifdef VIDIOC_ENUM_FRAMESIZES
869 # include "xlat/v4l2_framesize_types.h"
872 print_v4l2_frmsizeenum(struct tcb *const tcp, const kernel_ulong_t arg)
874 struct v4l2_frmsizeenum s;
878 if (umove_or_printaddr(tcp, arg, &s))
879 return RVAL_IOCTL_DECODED;
880 tprintf("{index=%u, pixel_format=", s.index);
881 print_pixelformat(s.pixel_format);
885 if (!syserror(tcp) && !umove(tcp, arg, &s)) {
887 printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???");
889 case V4L2_FRMSIZE_TYPE_DISCRETE:
890 tprintf(", discrete={width=%u, height=%u}",
891 s.discrete.width, s.discrete.height);
893 case V4L2_FRMSIZE_TYPE_STEPWISE:
894 tprintf(", stepwise={min_width=%u, max_width=%u, "
895 "step_width=%u, min_height=%u, max_height=%u, "
897 s.stepwise.min_width, s.stepwise.max_width,
898 s.stepwise.step_width, s.stepwise.min_height,
899 s.stepwise.max_height, s.stepwise.step_height);
904 return RVAL_IOCTL_DECODED;
906 #endif /* VIDIOC_ENUM_FRAMESIZES */
908 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
909 # include "xlat/v4l2_frameinterval_types.h"
912 print_v4l2_frmivalenum(struct tcb *const tcp, const kernel_ulong_t arg)
914 struct v4l2_frmivalenum f;
918 if (umove_or_printaddr(tcp, arg, &f))
919 return RVAL_IOCTL_DECODED;
920 tprintf("{index=%u, pixel_format=", f.index);
921 print_pixelformat(f.pixel_format);
922 tprintf(", width=%u, height=%u", f.width, f.height);
926 if (!syserror(tcp) && !umove(tcp, arg, &f)) {
928 printxval(v4l2_frameinterval_types, f.type,
929 "V4L2_FRMIVAL_TYPE_???");
931 case V4L2_FRMIVAL_TYPE_DISCRETE:
932 tprintf(", discrete=" FMT_FRACT,
933 ARGS_FRACT(f.discrete));
935 case V4L2_FRMIVAL_TYPE_STEPWISE:
936 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
937 tprintf(", stepwise={min=" FMT_FRACT ", max="
938 FMT_FRACT ", step=" FMT_FRACT "}",
939 ARGS_FRACT(f.stepwise.min),
940 ARGS_FRACT(f.stepwise.max),
941 ARGS_FRACT(f.stepwise.step));
948 return RVAL_IOCTL_DECODED;
950 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
952 #ifdef VIDIOC_CREATE_BUFS
954 print_v4l2_create_buffers(struct tcb *const tcp, const kernel_ulong_t arg)
956 static const char fmt[] = "{index=%u, count=%u}";
957 static char outstr[sizeof(fmt) + sizeof(int) * 6];
959 struct_v4l2_create_buffers b;
963 if (umove_or_printaddr(tcp, arg, &b))
964 return RVAL_IOCTL_DECODED;
965 tprintf("{count=%u, memory=", b.count);
966 printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???");
967 tprints(", format={type=");
968 printxval(v4l2_buf_types, b.format.type,
969 "V4L2_BUF_TYPE_???");
970 print_v4l2_format_fmt(tcp, ", ",
971 (struct_v4l2_format *) &b.format);
976 if (syserror(tcp) || umove(tcp, arg, &b))
977 return RVAL_IOCTL_DECODED;
979 xsprintf(outstr, fmt, b.index, b.count);
980 tcp->auxstr = outstr;
982 return RVAL_IOCTL_DECODED | RVAL_STR;
984 #endif /* VIDIOC_CREATE_BUFS */
986 MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb *const tcp,
987 const unsigned int code, const kernel_ulong_t arg)
993 case VIDIOC_QUERYCAP: /* R */
994 return print_v4l2_capability(tcp, arg);
996 case VIDIOC_ENUM_FMT: /* RW */
997 return print_v4l2_fmtdesc(tcp, arg);
999 case VIDIOC_G_FMT: /* RW */
1000 case VIDIOC_S_FMT: /* RW */
1001 case VIDIOC_TRY_FMT: /* RW */
1002 return print_v4l2_format(tcp, arg, code == VIDIOC_G_FMT);
1004 case VIDIOC_REQBUFS: /* RW */
1005 return print_v4l2_requestbuffers(tcp, arg);
1007 case VIDIOC_QUERYBUF: /* RW */
1008 case VIDIOC_QBUF: /* RW */
1009 case VIDIOC_DQBUF: /* RW */
1010 return print_v4l2_buffer(tcp, code, arg);
1012 case VIDIOC_G_FBUF: /* R */
1016 case VIDIOC_S_FBUF: /* W */
1017 return print_v4l2_framebuffer(tcp, arg);
1019 case VIDIOC_STREAMON: /* W */
1020 case VIDIOC_STREAMOFF: /* W */
1021 return print_v4l2_buf_type(tcp, arg);
1023 case VIDIOC_G_PARM: /* RW */
1024 case VIDIOC_S_PARM: /* RW */
1025 return print_v4l2_streamparm(tcp, arg, code == VIDIOC_G_PARM);
1027 case VIDIOC_G_STD: /* R */
1031 case VIDIOC_S_STD: /* W */
1033 printnum_int64(tcp, arg, "%#" PRIx64);
1036 case VIDIOC_ENUMSTD: /* RW */
1037 return print_v4l2_standard(tcp, arg);
1039 case VIDIOC_ENUMINPUT: /* RW */
1040 return print_v4l2_input(tcp, arg);
1042 case VIDIOC_G_CTRL: /* RW */
1043 case VIDIOC_S_CTRL: /* RW */
1044 return print_v4l2_control(tcp, arg, code == VIDIOC_G_CTRL);
1046 case VIDIOC_G_TUNER: /* RW */
1047 case VIDIOC_S_TUNER: /* RW */
1048 return print_v4l2_tuner(tcp, arg, code == VIDIOC_G_TUNER);
1050 case VIDIOC_QUERYCTRL: /* RW */
1051 return print_v4l2_queryctrl(tcp, arg);
1053 case VIDIOC_G_INPUT: /* R */
1057 case VIDIOC_S_INPUT: /* RW */
1059 printnum_int(tcp, arg, "%u");
1062 case VIDIOC_CROPCAP: /* RW */
1063 return print_v4l2_cropcap(tcp, arg);
1065 case VIDIOC_G_CROP: /* RW */
1066 case VIDIOC_S_CROP: /* W */
1067 return print_v4l2_crop(tcp, arg, code == VIDIOC_G_CROP);
1069 #ifdef VIDIOC_S_EXT_CTRLS
1070 case VIDIOC_S_EXT_CTRLS: /* RW */
1071 case VIDIOC_TRY_EXT_CTRLS: /* RW */
1072 case VIDIOC_G_EXT_CTRLS: /* RW */
1073 return print_v4l2_ext_controls(tcp, arg,
1074 code == VIDIOC_G_EXT_CTRLS);
1075 #endif /* VIDIOC_S_EXT_CTRLS */
1077 #ifdef VIDIOC_ENUM_FRAMESIZES
1078 case VIDIOC_ENUM_FRAMESIZES: /* RW */
1079 return print_v4l2_frmsizeenum(tcp, arg);
1080 #endif /* VIDIOC_ENUM_FRAMESIZES */
1082 #ifdef VIDIOC_ENUM_FRAMEINTERVALS
1083 case VIDIOC_ENUM_FRAMEINTERVALS: /* RW */
1084 return print_v4l2_frmivalenum(tcp, arg);
1085 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */
1087 #ifdef VIDIOC_CREATE_BUFS
1088 case VIDIOC_CREATE_BUFS: /* RW */
1089 return print_v4l2_create_buffers(tcp, arg);
1090 #endif /* VIDIOC_CREATE_BUFS */
1093 return RVAL_DECODED;
1096 return RVAL_IOCTL_DECODED;