v4l2.c revision c7afb4881f14e44968f3a78ae5988f04ecc66b68
10cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter/* 20cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * Copyright (c) 2014 Philippe De Muyter <phdm@macqel.be> 30cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * Copyright (c) 2014 William Manley <will@williammanley.net> 40cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * Copyright (c) 2011 Peter Zotov <whitequark@whitequark.org> 50cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * All rights reserved. 60cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * 70cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * Redistribution and use in source and binary forms, with or without 80cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * modification, are permitted provided that the following conditions 90cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * are met: 100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * 1. Redistributions of source code must retain the above copyright 110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * notice, this list of conditions and the following disclaimer. 120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * 2. Redistributions in binary form must reproduce the above copyright 130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * notice, this list of conditions and the following disclaimer in the 140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * documentation and/or other materials provided with the distribution. 150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * 3. The name of the author may not be used to endorse or promote products 160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * derived from this software without specific prior written permission. 170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * 180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter */ 290cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "defs.h" 310cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include <stdint.h> 330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include <sys/ioctl.h> 340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include <linux/videodev2.h> 350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter/* some historical constants */ 360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#ifndef V4L2_CID_HCENTER 370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) 380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#ifndef V4L2_CID_VCENTER 400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) 410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#ifndef V4L2_CID_BAND_STOP_FILTER 430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33) 440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_device_capabilities_flags.h" 470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_buf_types.h" 480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_buf_flags.h" 490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_framesize_types.h" 500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_frameinterval_types.h" 510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_fields.h" 520cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_colorspaces.h" 530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_format_description_flags.h" 540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_memories.h" 550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_control_ids.h" 560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_control_types.h" 570cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_control_flags.h" 580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_control_classes.h" 590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_streaming_capabilities.h" 600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_capture_modes.h" 610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#include "xlat/v4l2_input_types.h" 620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define FMT_FRACT "%u/%u" 640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define ARGS_FRACT(x) ((x).numerator), ((x).denominator) 650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define FMT_RECT "{left=%i, top=%i, width=%i, height=%i}" 670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#define ARGS_RECT(x) (x).left, (x).top, (x).width, (x).height 680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyterstatic void print_pixelformat(uint32_t fourcc) 700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter{ 710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#if WORDS_BIGENDIAN 720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter fourcc = htole32(fourcc); 730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf("%.4s", (char*)&fourcc); 750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter} 760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyterstatic void print_v4l2_format_fmt(const struct v4l2_format *f) 780cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter{ 790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("fmt."); 800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter switch (f->type) { 810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_CAPTURE: 820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_OUTPUT: { 830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter const struct v4l2_pix_format *pix = &f->fmt.pix; 840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf("pix={width=%u, height=%u, pixelformat=", 860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter pix->width, pix->height); 870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_pixelformat(pix->pixelformat); 880cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", field="); 890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_fields, pix->field, "V4L2_FIELD_???"); 900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", bytesperline=%u, sizeimage=%u, colorspace=", 910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter pix->bytesperline, pix->sizeimage); 920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_colorspaces, pix->colorspace, 930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_COLORSPACE_???"); 940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 970cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 980cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 990cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: { 1000cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter const struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; 1010cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter unsigned int i, max; 1020cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1030cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf("pix_mp={width=%u, height=%u, pixelformat=", 1040cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter pix_mp->width, pix_mp->height); 1050cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_pixelformat(pix_mp->pixelformat); 1060cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", field="); 1070cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_fields, pix_mp->field, "V4L2_FIELD_???"); 1080cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", colorspace="); 1090cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_colorspaces, pix_mp->colorspace, 1100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_COLORSPACE_???"); 1110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("plane_fmt=["); 1120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter max = pix_mp->num_planes; 1130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (max > VIDEO_MAX_PLANES) 1140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter max = VIDEO_MAX_PLANES; 1150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter for (i = 0; i < max; i++) { 1160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (i > 0) 1170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", "); 1180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf("{sizeimage=%u, bytesperline=%u}", 1190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter pix_mp->plane_fmt[i].sizeimage, 1200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter pix_mp->plane_fmt[i].bytesperline); 1210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 1220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf("], num_planes=%u}", (unsigned) pix_mp->num_planes); 1230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 1250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 1260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter /* TODO: Complete this switch statement */ 1280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_OVERLAY: 129197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 1300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 131197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#endif 1320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("win={???}"); 1330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VBI_CAPTURE: 1360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_VBI_OUTPUT: 1370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("vbi={???}"); 1380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 1410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: 1420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("sliced={???}"); 1430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter default: 1460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("???"); 1470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 1490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter} 1500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyterint 152c7afb4881f14e44968f3a78ae5988f04ecc66b68Dmitry V. Levinv4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg) 1530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter{ 1540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!verbose(tcp)) 1550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 1560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1570cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter switch (code) { 1580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_QUERYCAP: /* decode on exit */ { 1590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_capability caps; 1600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || syserror(tcp) || umove(tcp, arg, &caps) < 0) 1620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 1630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {driver=\"%s\", card=\"%s\", bus_info=\"%s\", " 1640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "version=%u.%u.%u, capabilities=", caps.driver, caps.card, 1650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter caps.bus_info, (caps.version >> 16) & 0xFF, 1660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter (caps.version >> 8) & 0xFF, caps.version & 0xFF); 1670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_device_capabilities_flags, caps.capabilities, 1680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_CAP_???"); 1690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#ifdef V4L2_CAP_DEVICE_CAPS 1700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", device_caps="); 1710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_device_capabilities_flags, caps.device_caps, 1720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_CAP_???"); 1730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 1740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 1750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 1760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 1770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 178197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#ifdef VIDIOC_ENUM_FRAMESIZES 1790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_ENUM_FRAMESIZES: /* decode on exit */ { 1800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_frmsizeenum s; 1810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &s) < 0) 1830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 1840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {index=%u, pixel_format=", s.index); 1850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_pixelformat(s.pixel_format); 1860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 1870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 1880cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", type="); 1890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_framesize_types, s.type, "V4L2_FRMSIZE_TYPE_???"); 1900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter switch (s.type) { 1910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_FRMSIZE_TYPE_DISCRETE: 1920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", discrete={width=%u, height=%u}", 1930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter s.discrete.width, s.discrete.height); 1940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 1950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_FRMSIZE_TYPE_STEPWISE: 1960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", stepwise={min_width=%u, max_width=%u, " 1970cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "step_width=%u, min_height=%u, max_height=%u, " 1980cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "step_height=%u}", 1990cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter s.stepwise.min_width, s.stepwise.max_width, 2000cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter s.stepwise.step_width, s.stepwise.min_height, 2010cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter s.stepwise.max_height, s.stepwise.step_height); 2020cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 2030cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2040cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2050cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 2060cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 2070cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 208197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#endif /* VIDIOC_ENUM_FRAMESIZES */ 2090cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_FMT: 2110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_FMT: 2120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_TRY_FMT: { 2130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_format f; 2140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &f) < 0) 2160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 2170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) { 2180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", {type="); 2190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); 2200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if ((entering(tcp) && code != VIDIOC_G_FMT) 2220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter || (exiting(tcp) && !syserror(tcp))) { 2230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(exiting(tcp) && code != VIDIOC_G_FMT ? " => " : ", "); 2240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_v4l2_format_fmt(&f); 2250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp)) 2270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 2280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 2290cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2310cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_ENUM_FMT: { 2320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_fmtdesc f; 2330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &f) < 0) 2350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 2360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {index=%u", f.index); 2380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 2390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", type="); 2400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, f.type, "V4L2_BUF_TYPE_???"); 2410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", flags="); 2420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_format_description_flags, f.flags, 2430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_FMT_FLAG_???"); 2440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", description=\"%s\", pixelformat=", 2450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter f.description); 2460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_pixelformat(f.pixelformat); 2470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 2490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 2500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2520cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_PARM: 2530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_PARM: { 2540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_streamparm s; 2550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) && code == VIDIOC_G_PARM) 2570cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 2580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp) && syserror(tcp)) 2590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return code == VIDIOC_S_PARM; 2600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &s) < 0) 2610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 2620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) { 2630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", {type="); 2640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, s.type, "V4L2_BUF_TYPE_???"); 2650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(exiting(tcp) && code == VIDIOC_S_PARM ? " => {" : ", {"); 2680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (s.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 2690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_captureparm *cap = &s.parm.capture; 2700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("capability="); 2720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_streaming_capabilities, 2730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter cap->capability, "V4L2_CAP_???"); 2740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", capturemode="); 2760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_capture_modes, 2770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter cap->capturemode, "V4L2_MODE_???"); 2780cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", timeperframe=" FMT_FRACT, 2800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_FRACT(cap->timeperframe)); 2810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", extendedmode=%u, readbuffers=%u", 2830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter cap->extendedmode, 2840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter cap->readbuffers); 2850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } else 2860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("..."); 2870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 2880cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp)) 2890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 2900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 2910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 2920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_QUERYCTRL: { 2940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_queryctrl c; 2950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 2960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &c) < 0) 2970cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 2980cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter /* 'id' field must be printed : 2990cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * on enter 3000cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter * on exit if !syserror(tcp) && V4L2_CTRL_FLAG_NEXT_CTRL was set 3010cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter */ 3020cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) 3030cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter || (exiting(tcp) && tcp->auxstr && !syserror(tcp))) { 3040cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(exiting(tcp) ? " => " : ", {id="); 3050cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tcp->auxstr = (c.id & V4L2_CTRL_FLAG_NEXT_CTRL) ? "" : NULL; 3060cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (tcp->auxstr) { 3070cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("V4L2_CTRL_FLAG_NEXT_CTRL|"); 3080cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL; 3090cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_control_ids, c.id, "V4L2_CID_???"); 3110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp)) { 3130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 3140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", type="); 3150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_control_types, c.type, 3160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_CTRL_TYPE_???"); 3170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", name=\"%s\", minimum=%i, maximum=%i, step=%i, " 3180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "default_value=%i, flags=", 3190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter c.name, c.minimum, c.maximum, 3200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter c.step, c.default_value); 3210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_control_flags, c.flags, 3220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_CTRL_FLAG_???"); 3230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 3250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 3270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 3290cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_CTRL: 3300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_CTRL: { 3310cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_control c; 3320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 3330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &c) < 0) 3340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 3350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", {id="); 3360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_control_ids, c.id, "V4L2_CID_???"); 3370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp) || code != VIDIOC_G_CTRL) 3380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", value=%i", c.value); 3390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 3400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 3410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 3430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_EXT_CTRLS: 3440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_TRY_EXT_CTRLS: 3450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_EXT_CTRLS: { 3460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_ext_controls c; 3470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter unsigned int n; 3480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter bool must_print_values; 3490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 3500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) && code == VIDIOC_G_EXT_CTRLS) 3510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 3520cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp) && syserror(tcp) && code != VIDIOC_G_EXT_CTRLS) 3530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 3540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter must_print_values = ((entering(tcp) && code != VIDIOC_G_EXT_CTRLS) 3550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter || (exiting(tcp) && !syserror(tcp))); 3560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &c) < 0) 3570cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 3580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(code != VIDIOC_G_EXT_CTRLS && exiting(tcp) ? " => " : ", "); 3590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("{ctrl_class="); 3600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_control_classes, c.ctrl_class, 3610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_CTRL_CLASS_???"); 3620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", count=%u", c.count); 3630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (exiting(tcp) && syserror(tcp)) 3640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", error_idx=%u", c.error_idx); 3650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", controls=["); 3660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter for (n = 0; n < c.count; ++n) { 3670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_ext_control ctrl; 3680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 3690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (n > 0) 3700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", "); 3710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, (long) (c.controls + n), &ctrl) < 0) 3720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 3730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (abbrev(tcp) && n == 2) { 3740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("..."); 3750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 3760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("{id="); 3780cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_control_ids, ctrl.id, "V4L2_CID_???"); 3790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#if HAVE_DECL_V4L2_CTRL_TYPE_STRING 3800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", size=%u", ctrl.size); 3810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (ctrl.size > 0) { 3820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (must_print_values) { 3830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", string="); 3840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printstr(tcp, (long) ctrl.string, ctrl.size); 3850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } else 3870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter#endif 3880cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter { 3890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (must_print_values) { 3900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", value=%i, value64=%lli", ctrl.value, 3910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ctrl.value64); 3920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 3950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("]}"); 3970cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 3980cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 3990cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4000cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_ENUMSTD: { 4010cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_standard s; 4020cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4030cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &s) < 0) 4040cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4050cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) 4060cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {index=%i", s.index); 4070cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter else { 4080cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 4090cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", name=\"%s\"", s.name); 4100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", frameperiod=" FMT_FRACT, ARGS_FRACT(s.frameperiod)); 4110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", framelines=%i", s.framelines); 4120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 4140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_STD: 4190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_STD: { 4200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter v4l2_std_id s; 4210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (code == VIDIOC_G_STD && exiting(tcp) && syserror(tcp)) 4230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &s) < 0) 4250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if ((code == VIDIOC_S_STD) == entering(tcp)) 4270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", std=%#llx", s); 4280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4290cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4310cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_ENUMINPUT: { 4320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_input i; 4330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &i) < 0) 4350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {index=%i", i.index); 4370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 4380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", name=\"%s\", type=", i.name); 4390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_input_types, i.type, 4400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_INPUT_TYPE_???"); 4410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 4430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_INPUT: 4470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_INPUT: { 4480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter int index; 4490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || syserror(tcp) || umove(tcp, arg, &index) < 0) 4510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4520cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", index=%i", index); 4540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 457197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#ifdef VIDIOC_ENUM_FRAMEINTERVALS 4580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_ENUM_FRAMEINTERVALS: { 4590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_frmivalenum f; 4600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &f) < 0) 4620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {index=%i, pixel_format=", f.index); 4640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter print_pixelformat(f.pixel_format); 4650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", width=%u, height=%u", f.width, f.height); 4660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 4670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", type="); 4680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_frameinterval_types, f.type, 4690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "V4L2_FRMIVAL_TYPE_???"); 4700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter switch (f.type) { 4710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_FRMIVAL_TYPE_DISCRETE: 4720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", discrete=" FMT_FRACT, 4730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_FRACT(f.discrete)); 4740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 4750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_FRMIVAL_TYPE_STEPWISE: 4760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case V4L2_FRMSIZE_TYPE_CONTINUOUS: 4770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", stepwise={min=" FMT_FRACT ", max=" 4780cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter FMT_FRACT ", step=" FMT_FRACT "}", 4790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_FRACT(f.stepwise.min), 4800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_FRACT(f.stepwise.max), 4810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_FRACT(f.stepwise.step)); 4820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter break; 4830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 4850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 4860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 488197db577e832ad033954885e2a3a7fad4046968cDmitry V. Levin#endif /* VIDIOC_ENUM_FRAMEINTERVALS */ 4890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_CROPCAP: { 4910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_cropcap c; 4920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 4930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &c) < 0) 4940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 4950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", type="); 4960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, c.type, "V4L2_BUF_TYPE_???"); 4970cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (syserror(tcp)) 4980cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 4990cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", bounds=" FMT_RECT ", defrect=" FMT_RECT ", " 5000cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter "pixelaspect=" FMT_FRACT, ARGS_RECT(c.bounds), 5010cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter ARGS_RECT(c.defrect), ARGS_FRACT(c.pixelaspect)); 5020cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5030cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5040cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5050cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_G_FBUF: 5060cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_S_FBUF: { 5070cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_framebuffer b; 5080cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5090cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (syserror(tcp) && code == VIDIOC_G_FBUF) 5100cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5110cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp) || umove(tcp, arg, &b) < 0) 5120cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5130cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {capability=%x, flags=%x, base=%p}", 5140cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter b.capability, b.flags, b.base); 5150cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5160cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5170cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5180cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_REQBUFS: { 5190cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_requestbuffers reqbufs; 5200cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5210cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &reqbufs) < 0) 5220cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5230cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) { 5240cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", {count=%u, type=", reqbufs.count); 5250cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, reqbufs.type, "V4L2_BUF_TYPE_???"); 5260cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", memory="); 5270cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_memories, reqbufs.memory, "V4L2_MEMORY_???"); 5280cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 5290cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5300cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } else if (syserror(tcp)) 5310cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5320cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter else { 5330cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter static char outstr[sizeof("{count=}") + sizeof(int) * 3]; 5340cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5350cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter sprintf(outstr, "{count=%u}", reqbufs.count); 5360cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tcp->auxstr = outstr; 5370cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1 + RVAL_STR; 5380cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5390cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5400cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5410cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_QUERYBUF: 5420cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_QBUF: 5430cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_DQBUF: { 5440cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter struct v4l2_buffer b; 5450cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5460cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &b) < 0) 5470cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5480cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) { 5490cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", {type="); 5500cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, b.type, "V4L2_BUF_TYPE_???"); 5510cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (code != VIDIOC_DQBUF) 5520cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", index=%u", b.index); 5530cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } else { 5540cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (!syserror(tcp)) { 5550cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (code == VIDIOC_DQBUF) 5560cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", index=%u", b.index); 5570cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", memory="); 5580cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_memories, b.memory, "V4L2_MEMORY_???"); 5590cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5600cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (b.memory == V4L2_MEMORY_MMAP) { 5610cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", m.offset=%#x", b.m.offset); 5620cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } else if (b.memory == V4L2_MEMORY_USERPTR) { 5630cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", m.userptr=%#lx", b.m.userptr); 5640cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5650cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5660cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", length=%u, bytesused=%u, flags=", 5670cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter b.length, b.bytesused); 5680cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???"); 5690cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (code == VIDIOC_DQBUF) 5700cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprintf(", timestamp = {%lu.%06lu}", 5710cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter b.timestamp.tv_sec, 5720cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter b.timestamp.tv_usec); 5730cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", ..."); 5740cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5750cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints("}"); 5760cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5770cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5780cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5790cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5800cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_STREAMON: 5810cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter case VIDIOC_STREAMOFF: { 5820cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter int type; 5830cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5840cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (umove(tcp, arg, &type) < 0) 5850cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5860cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter if (entering(tcp)) { 5870cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter tprints(", "); 5880cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter printxval(v4l2_buf_types, type, "V4L2_BUF_TYPE_???"); 5890cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5900cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 1; 5910cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5920cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter 5930cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter default: /* decode on exit */ 5940cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter return 0; 5950cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter } 5960cc961440b527ff8c16954fc411a1529072edb92Philippe De Muyter} 597