1 /* 2 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv (at) altlinux.org> 3 * Copyright (c) 2016-2017 The strace developers. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include "tests.h" 30 #include <stdio.h> 31 #include <string.h> 32 #include <sys/ioctl.h> 33 #include <linux/types.h> 34 #include <linux/videodev2.h> 35 36 #if WORDS_BIGENDIAN 37 # define cc0(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 24)) 38 # define cc1(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 16)) 39 # define cc2(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 8)) 40 # define cc3(arg) ((unsigned int) (unsigned char) (arg)) 41 # define fourcc(a0, a1, a2, a3) \ 42 ((unsigned int)(a3) | \ 43 ((unsigned int)(a2) << 8) | \ 44 ((unsigned int)(a1) << 16) | \ 45 ((unsigned int)(a0) << 24)) 46 #else 47 # define cc0(arg) ((unsigned int) (unsigned char) (arg)) 48 # define cc1(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 8)) 49 # define cc2(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 16)) 50 # define cc3(arg) ((unsigned int) (unsigned char) ((unsigned int) (arg) >> 24)) 51 # define fourcc(a0, a1, a2, a3) \ 52 ((unsigned int)(a0) | \ 53 ((unsigned int)(a1) << 8) | \ 54 ((unsigned int)(a2) << 16) | \ 55 ((unsigned int)(a3) << 24)) 56 #endif 57 58 static const unsigned int magic = 0xdeadbeef; 59 60 static void 61 init_v4l2_format(struct v4l2_format *const f, 62 const unsigned int buf_type) 63 { 64 memset(f, -1, sizeof(*f)); 65 f->type = buf_type; 66 switch (buf_type) { 67 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 68 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 69 f->fmt.pix.width = 0x657b8160; 70 f->fmt.pix.height = 0x951c0047; 71 f->fmt.pix.pixelformat = magic; 72 f->fmt.pix.field = V4L2_FIELD_NONE; 73 f->fmt.pix.bytesperline = 0xdf20d185; 74 f->fmt.pix.sizeimage = 0x0cf7be41; 75 f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; 76 break; 77 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 78 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 79 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: { 80 unsigned int i; 81 82 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 83 f->fmt.pix_mp.width = 0x1f3b774b; 84 f->fmt.pix_mp.height = 0xab96a8d6; 85 f->fmt.pix_mp.pixelformat = magic; 86 f->fmt.pix_mp.field = V4L2_FIELD_NONE; 87 f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_JPEG; 88 struct v4l2_plane_pix_format *cur_pix = 89 f->fmt.pix_mp.plane_fmt; 90 for (i = 0; 91 i < ARRAY_SIZE(f->fmt.pix_mp.plane_fmt); 92 i++) { 93 cur_pix[i].sizeimage = 0x1e3c531c | i; 94 cur_pix[i].bytesperline = 0xa983d721 | i; 95 } 96 break; 97 } 98 #endif 99 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 100 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 101 #endif 102 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 103 f->fmt.win.w.left = 0xe8373662; 104 f->fmt.win.w.top = 0x0336d283; 105 f->fmt.win.w.width = 0x9235fe72; 106 f->fmt.win.w.height = 0xbbd886c8; 107 f->fmt.win.field = V4L2_FIELD_ANY; 108 f->fmt.win.chromakey = 0xdb1f991f; 109 f->fmt.win.clipcount = 2; 110 f->fmt.win.clips = 111 tail_alloc(sizeof(*f->fmt.win.clips) * 112 f->fmt.win.clipcount); 113 f->fmt.win.clips[0].c.left = 0x3313d36e; 114 f->fmt.win.clips[0].c.top = 0xcdffe510; 115 f->fmt.win.clips[0].c.width = 0x2064f3a8; 116 f->fmt.win.clips[0].c.height = 0xd06d314a; 117 f->fmt.win.clips[1].c.left = 0xd8c8a83f; 118 f->fmt.win.clips[1].c.top = 0x336e87ba; 119 f->fmt.win.clips[1].c.width = 0x9e3a6fb3; 120 f->fmt.win.clips[1].c.height = 0x05617b76; 121 122 f->fmt.win.bitmap = (void *) -2UL; 123 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA 124 f->fmt.win.global_alpha = 0xce; 125 #endif 126 break; 127 case V4L2_BUF_TYPE_VBI_CAPTURE: 128 case V4L2_BUF_TYPE_VBI_OUTPUT: 129 f->fmt.vbi.sampling_rate = 0x3d9b5b79; 130 f->fmt.vbi.offset = 0x055b3a09; 131 f->fmt.vbi.samples_per_line = 0xf176d436; 132 f->fmt.vbi.sample_format = magic; 133 f->fmt.vbi.start[0] = 0x9858e2eb; 134 f->fmt.vbi.start[1] = 0x8a4dc8c1; 135 f->fmt.vbi.count[0] = 0x4bcf36a3; 136 f->fmt.vbi.count[1] = 0x97dff65f; 137 f->fmt.vbi.flags = V4L2_VBI_INTERLACED; 138 break; 139 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 140 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 141 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: { 142 unsigned int i; 143 144 f->fmt.sliced.service_set = V4L2_SLICED_VPS; 145 f->fmt.sliced.io_size = 0xd897925a; 146 for (i = 0; 147 i < ARRAY_SIZE(f->fmt.sliced.service_lines[0]); 148 i++) { 149 f->fmt.sliced.service_lines[0][i] = 0xc38e | i; 150 f->fmt.sliced.service_lines[1][i] = 0x3abb | i; 151 } 152 break; 153 } 154 #endif 155 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT 156 case V4L2_BUF_TYPE_SDR_OUTPUT: 157 #endif 158 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE 159 case V4L2_BUF_TYPE_SDR_CAPTURE: 160 f->fmt.sdr.pixelformat = magic; 161 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE 162 f->fmt.sdr.buffersize = 0x25afabfb; 163 #endif 164 break; 165 #endif 166 } 167 } 168 169 static void 170 dprint_ioctl_v4l2(struct v4l2_format *const f, 171 const char *request, const unsigned int buf_type, 172 const char *buf_type_string) 173 { 174 switch (buf_type) { 175 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 176 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 177 printf("ioctl(-1, %s, {type=%s" 178 ", fmt.pix={width=%u, height=%u, pixelformat=" 179 "v4l2_fourcc('\\x%x', '\\x%x', '\\x%x', '\\x%x')" 180 ", field=V4L2_FIELD_NONE, bytesperline=%u, sizeimage=%u" 181 ", colorspace=V4L2_COLORSPACE_JPEG}}) = -1 EBADF (%m)\n", 182 request, 183 buf_type_string, 184 f->fmt.pix.width, f->fmt.pix.height, 185 cc0(magic), cc1(magic), cc2(magic), cc3(magic), 186 f->fmt.pix.bytesperline, 187 f->fmt.pix.sizeimage); 188 break; 189 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 190 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 191 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: { 192 unsigned int i; 193 194 printf("ioctl(-1, %s" 195 ", {type=%s" 196 ", fmt.pix_mp={width=%u, height=%u, pixelformat=" 197 "v4l2_fourcc('\\x%x', '\\x%x', '\\x%x', '\\x%x')" 198 ", field=V4L2_FIELD_NONE, colorspace=" 199 "V4L2_COLORSPACE_JPEG, plane_fmt=[", 200 request, 201 buf_type_string, 202 f->fmt.pix_mp.width, f->fmt.pix_mp.height, 203 cc0(magic), cc1(magic), cc2(magic), cc3(magic)); 204 for (i = 0; 205 i < ARRAY_SIZE(f->fmt.pix_mp.plane_fmt); 206 ++i) { 207 if (i) 208 printf(", "); 209 printf("{sizeimage=%u, bytesperline=%u}", 210 f->fmt.pix_mp.plane_fmt[i].sizeimage, 211 f->fmt.pix_mp.plane_fmt[i].bytesperline); 212 } 213 printf("], num_planes=%u}}) = -1 EBADF (%m)\n", 214 f->fmt.pix_mp.num_planes); 215 break; 216 } 217 #endif 218 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 219 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 220 #endif 221 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 222 printf("ioctl(-1, %s, {type=%s" 223 ", fmt.win={left=%d, top=%d, width=%u, height=%u" 224 ", field=V4L2_FIELD_ANY, chromakey=%#x, clips=" 225 "[{left=%d, top=%d, width=%u, height=%u}, " 226 "{left=%d, top=%d, width=%u, height=%u}]" 227 ", clipcount=%u, bitmap=%p" 228 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA 229 ", global_alpha=%#x" 230 #endif 231 "}}) = -1 EBADF (%m)\n", 232 request, 233 buf_type_string, 234 f->fmt.win.w.left, f->fmt.win.w.top, 235 f->fmt.win.w.width, f->fmt.win.w.height, 236 f->fmt.win.chromakey, 237 f->fmt.win.clips[0].c.left, 238 f->fmt.win.clips[0].c.top, 239 f->fmt.win.clips[0].c.width, 240 f->fmt.win.clips[0].c.height, 241 f->fmt.win.clips[1].c.left, 242 f->fmt.win.clips[1].c.top, 243 f->fmt.win.clips[1].c.width, 244 f->fmt.win.clips[1].c.height, 245 f->fmt.win.clipcount, f->fmt.win.bitmap 246 #ifdef HAVE_STRUCT_V4L2_WINDOW_GLOBAL_ALPHA 247 , f->fmt.win.global_alpha 248 #endif 249 ); 250 break; 251 case V4L2_BUF_TYPE_VBI_CAPTURE: 252 case V4L2_BUF_TYPE_VBI_OUTPUT: 253 printf("ioctl(-1, %s, {type=%s" 254 ", fmt.vbi={sampling_rate=%u, offset=%u" 255 ", samples_per_line=%u, sample_format=" 256 "v4l2_fourcc('\\x%x', '\\x%x', '\\x%x', '\\x%x')" 257 ", start=[%u, %u], count=[%u, %u]" 258 ", flags=V4L2_VBI_INTERLACED}})" 259 " = -1 EBADF (%m)\n", 260 request, 261 buf_type_string, 262 f->fmt.vbi.sampling_rate, f->fmt.vbi.offset, 263 f->fmt.vbi.samples_per_line, 264 cc0(magic), cc1(magic), cc2(magic), cc3(magic), 265 f->fmt.vbi.start[0], f->fmt.vbi.start[1], 266 f->fmt.vbi.count[0], f->fmt.vbi.count[1]); 267 break; 268 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 269 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 270 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: { 271 unsigned int i, j; 272 273 printf("ioctl(-1, %s, {type=%s" 274 ", fmt.sliced={service_set=V4L2_SLICED_VPS" 275 ", io_size=%u, service_lines=[", 276 request, 277 buf_type_string, 278 f->fmt.sliced.io_size); 279 for (i = 0; 280 i < ARRAY_SIZE(f->fmt.sliced.service_lines); 281 i++) { 282 if (i > 0) 283 printf(", "); 284 printf("["); 285 for (j = 0; 286 j < ARRAY_SIZE(f->fmt.sliced.service_lines[0]); 287 j++) { 288 if (j > 0) 289 printf(", "); 290 printf("%#x", 291 f->fmt.sliced.service_lines[i][j]); 292 } 293 printf("]"); 294 } 295 printf("]}}) = -1 EBADF (%m)\n"); 296 break; 297 } 298 #endif 299 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT 300 case V4L2_BUF_TYPE_SDR_OUTPUT: 301 #endif 302 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE 303 case V4L2_BUF_TYPE_SDR_CAPTURE: 304 printf("ioctl(-1, %s, {type=%s" 305 ", fmt.sdr={pixelformat=v4l2_fourcc('\\x%x', '\\x%x'," 306 " '\\x%x', '\\x%x')" 307 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE 308 ", buffersize=%u" 309 #endif 310 "}}) = -1 EBADF (%m)\n", 311 request, 312 buf_type_string, 313 cc0(magic), cc1(magic), cc2(magic), cc3(magic) 314 #ifdef HAVE_STRUCT_V4L2_SDR_FORMAT_BUFFERSIZE 315 , f->fmt.sdr.buffersize 316 #endif 317 ); 318 break; 319 #endif 320 } 321 } 322 #define print_ioctl_v4l2(v4l2_format, request, buf_type) \ 323 dprint_ioctl_v4l2((v4l2_format), (request), (buf_type), #buf_type) 324 325 int 326 main(void) 327 { 328 const unsigned int size = get_page_size(); 329 void *const page = tail_alloc(size); 330 fill_memory(page, size); 331 332 unsigned char cc[sizeof(int)] = { 'A', '\'', '\\', '\xfa' }; 333 334 /* VIDIOC_QUERYCAP */ 335 ioctl(-1, VIDIOC_QUERYCAP, 0); 336 printf("ioctl(-1, VIDIOC_QUERYCAP, NULL) = -1 EBADF (%m)\n"); 337 338 ioctl(-1, VIDIOC_QUERYCAP, page); 339 printf("ioctl(-1, VIDIOC_QUERYCAP, %p) = -1 EBADF (%m)\n", page); 340 341 /* VIDIOC_ENUM_FMT */ 342 ioctl(-1, VIDIOC_ENUM_FMT, 0); 343 printf("ioctl(-1, VIDIOC_ENUM_FMT, NULL) = -1 EBADF (%m)\n"); 344 345 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_fmtdesc, p_fmtdesc); 346 p_fmtdesc->index = magic; 347 p_fmtdesc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 348 ioctl(-1, VIDIOC_ENUM_FMT, p_fmtdesc); 349 printf("ioctl(-1, VIDIOC_ENUM_FMT, {index=%u" 350 ", type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EBADF (%m)\n", 351 p_fmtdesc->index); 352 353 /* VIDIOC_G_FMT */ 354 ioctl(-1, VIDIOC_G_FMT, 0); 355 printf("ioctl(-1, VIDIOC_G_FMT, NULL) = -1 EBADF (%m)\n"); 356 357 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_format, p_format); 358 359 p_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 360 ioctl(-1, VIDIOC_G_FMT, p_format); 361 printf("ioctl(-1, VIDIOC_G_FMT" 362 ", {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EBADF (%m)\n"); 363 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 364 p_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 365 ioctl(-1, VIDIOC_G_FMT, p_format); 366 printf("ioctl(-1, VIDIOC_G_FMT" 367 ", {type=V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE}) =" 368 " -1 EBADF (%m)\n"); 369 #endif 370 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 371 p_format->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; 372 ioctl(-1, VIDIOC_G_FMT, p_format); 373 printf("ioctl(-1, VIDIOC_G_FMT" 374 ", {type=V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY}) =" 375 " -1 EBADF (%m)\n"); 376 #endif 377 p_format->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 378 ioctl(-1, VIDIOC_G_FMT, p_format); 379 printf("ioctl(-1, VIDIOC_G_FMT" 380 ", {type=V4L2_BUF_TYPE_VIDEO_OVERLAY}) =" 381 " -1 EBADF (%m)\n"); 382 383 p_format->type = V4L2_BUF_TYPE_VBI_CAPTURE; 384 ioctl(-1, VIDIOC_G_FMT, p_format); 385 printf("ioctl(-1, VIDIOC_G_FMT" 386 ", {type=V4L2_BUF_TYPE_VBI_CAPTURE}) = -1 EBADF (%m)\n"); 387 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 388 p_format->type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 389 ioctl(-1, VIDIOC_G_FMT, p_format); 390 printf("ioctl(-1, VIDIOC_G_FMT" 391 ", {type=V4L2_BUF_TYPE_SLICED_VBI_CAPTURE}) = -1 EBADF (%m)\n"); 392 #endif 393 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE 394 p_format->type = V4L2_BUF_TYPE_SDR_CAPTURE; 395 ioctl(-1, VIDIOC_G_FMT, p_format); 396 printf("ioctl(-1, VIDIOC_G_FMT" 397 ", {type=V4L2_BUF_TYPE_SDR_CAPTURE}) = -1 EBADF (%m)\n"); 398 #endif 399 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT 400 p_format->type = V4L2_BUF_TYPE_SDR_OUTPUT; 401 ioctl(-1, VIDIOC_G_FMT, p_format); 402 printf("ioctl(-1, VIDIOC_G_FMT" 403 ", {type=V4L2_BUF_TYPE_SDR_OUTPUT}) = -1 EBADF (%m)\n"); 404 #endif 405 /* VIDIOC_S_FMT */ 406 ioctl(-1, VIDIOC_S_FMT, 0); 407 printf("ioctl(-1, VIDIOC_S_FMT, NULL) = -1 EBADF (%m)\n"); 408 409 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OUTPUT); 410 ioctl(-1, VIDIOC_S_FMT, p_format); 411 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", V4L2_BUF_TYPE_VIDEO_OUTPUT); 412 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 413 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 414 ioctl(-1, VIDIOC_S_FMT, p_format); 415 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", 416 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 417 #endif 418 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 419 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); 420 ioctl(-1, VIDIOC_S_FMT, p_format); 421 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", 422 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); 423 #endif 424 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OVERLAY); 425 ioctl(-1, VIDIOC_S_FMT, p_format); 426 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", 427 V4L2_BUF_TYPE_VIDEO_OVERLAY); 428 429 init_v4l2_format(p_format, V4L2_BUF_TYPE_VBI_CAPTURE); 430 ioctl(-1, VIDIOC_S_FMT, p_format); 431 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", V4L2_BUF_TYPE_VBI_CAPTURE); 432 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 433 init_v4l2_format(p_format, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE); 434 ioctl(-1, VIDIOC_S_FMT, p_format); 435 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", 436 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE); 437 #endif 438 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE 439 init_v4l2_format(p_format, V4L2_BUF_TYPE_SDR_CAPTURE); 440 ioctl(-1, VIDIOC_S_FMT, p_format); 441 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", V4L2_BUF_TYPE_SDR_CAPTURE); 442 #endif 443 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT 444 init_v4l2_format(p_format, V4L2_BUF_TYPE_SDR_OUTPUT); 445 ioctl(-1, VIDIOC_S_FMT, p_format); 446 print_ioctl_v4l2(p_format, "VIDIOC_S_FMT", V4L2_BUF_TYPE_SDR_OUTPUT); 447 #endif 448 /* VIDIOC_TRY_FMT */ 449 ioctl(-1, VIDIOC_TRY_FMT, 0); 450 printf("ioctl(-1, VIDIOC_TRY_FMT, NULL) = -1 EBADF (%m)\n"); 451 452 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OUTPUT); 453 ioctl(-1, VIDIOC_TRY_FMT, p_format); 454 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", 455 V4L2_BUF_TYPE_VIDEO_OUTPUT); 456 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 457 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 458 ioctl(-1, VIDIOC_TRY_FMT, p_format); 459 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", 460 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 461 #endif 462 #if HAVE_DECL_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 463 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); 464 ioctl(-1, VIDIOC_TRY_FMT, p_format); 465 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", 466 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY); 467 #endif 468 init_v4l2_format(p_format, V4L2_BUF_TYPE_VIDEO_OVERLAY); 469 ioctl(-1, VIDIOC_TRY_FMT, p_format); 470 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", 471 V4L2_BUF_TYPE_VIDEO_OVERLAY); 472 473 init_v4l2_format(p_format, V4L2_BUF_TYPE_VBI_CAPTURE); 474 ioctl(-1, VIDIOC_TRY_FMT, p_format); 475 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", V4L2_BUF_TYPE_VBI_CAPTURE); 476 #if HAVE_DECL_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 477 init_v4l2_format(p_format, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE); 478 ioctl(-1, VIDIOC_TRY_FMT, p_format); 479 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", 480 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE); 481 #endif 482 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_CAPTURE 483 init_v4l2_format(p_format, V4L2_BUF_TYPE_SDR_CAPTURE); 484 ioctl(-1, VIDIOC_TRY_FMT, p_format); 485 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", V4L2_BUF_TYPE_SDR_CAPTURE); 486 #endif 487 #if HAVE_DECL_V4L2_BUF_TYPE_SDR_OUTPUT 488 init_v4l2_format(p_format, V4L2_BUF_TYPE_SDR_OUTPUT); 489 ioctl(-1, VIDIOC_TRY_FMT, p_format); 490 print_ioctl_v4l2(p_format, "VIDIOC_TRY_FMT", V4L2_BUF_TYPE_SDR_OUTPUT); 491 #endif 492 struct v4l2_format *const p_v4l2_format = 493 page + size - sizeof(*p_v4l2_format); 494 ioctl(-1, VIDIOC_TRY_FMT, p_v4l2_format); 495 printf("ioctl(-1, VIDIOC_TRY_FMT, {type=%#x /* V4L2_BUF_TYPE_??? */})" 496 " = -1 EBADF (%m)\n", p_v4l2_format->type); 497 498 /* VIDIOC_REQBUFS */ 499 ioctl(-1, VIDIOC_REQBUFS, 0); 500 printf("ioctl(-1, VIDIOC_REQBUFS, NULL) = -1 EBADF (%m)\n"); 501 502 struct v4l2_requestbuffers *const p_v4l2_requestbuffers = 503 page + size - sizeof(*p_v4l2_requestbuffers); 504 ioctl(-1, VIDIOC_REQBUFS, p_v4l2_requestbuffers); 505 printf("ioctl(-1, VIDIOC_REQBUFS, {type=%#x /* V4L2_BUF_TYPE_??? */, " 506 "memory=%#x /* V4L2_MEMORY_??? */, count=%u})" 507 " = -1 EBADF (%m)\n", 508 p_v4l2_requestbuffers->type, 509 p_v4l2_requestbuffers->memory, 510 p_v4l2_requestbuffers->count); 511 512 /* VIDIOC_QUERYBUF */ 513 ioctl(-1, VIDIOC_QUERYBUF, 0); 514 printf("ioctl(-1, VIDIOC_QUERYBUF, NULL) = -1 EBADF (%m)\n"); 515 516 struct v4l2_buffer *const p_v4l2_buffer = 517 page + size - sizeof(*p_v4l2_buffer); 518 ioctl(-1, VIDIOC_QUERYBUF, p_v4l2_buffer); 519 printf("ioctl(-1, VIDIOC_QUERYBUF, {type=%#x /* V4L2_BUF_TYPE_??? */" 520 ", index=%u}) = -1 EBADF (%m)\n", 521 p_v4l2_buffer->type, p_v4l2_buffer->index); 522 523 /* VIDIOC_QBUF */ 524 ioctl(-1, VIDIOC_QBUF, 0); 525 printf("ioctl(-1, VIDIOC_QBUF, NULL) = -1 EBADF (%m)\n"); 526 527 ioctl(-1, VIDIOC_QBUF, p_v4l2_buffer); 528 printf("ioctl(-1, VIDIOC_QBUF, {type=%#x /* V4L2_BUF_TYPE_??? */" 529 ", index=%u}) = -1 EBADF (%m)\n", 530 p_v4l2_buffer->type, p_v4l2_buffer->index); 531 532 /* VIDIOC_DQBUF */ 533 ioctl(-1, VIDIOC_DQBUF, 0); 534 printf("ioctl(-1, VIDIOC_DQBUF, NULL) = -1 EBADF (%m)\n"); 535 536 ioctl(-1, VIDIOC_DQBUF, p_v4l2_buffer); 537 printf("ioctl(-1, VIDIOC_DQBUF, {type=%#x" 538 " /* V4L2_BUF_TYPE_??? */}) = -1 EBADF (%m)\n", 539 p_v4l2_buffer->type); 540 541 /* VIDIOC_G_FBUF */ 542 ioctl(-1, VIDIOC_G_FBUF, 0); 543 printf("ioctl(-1, VIDIOC_G_FBUF, NULL) = -1 EBADF (%m)\n"); 544 545 ioctl(-1, VIDIOC_G_FBUF, page); 546 printf("ioctl(-1, VIDIOC_G_FBUF, %p) = -1 EBADF (%m)\n", page); 547 548 /* VIDIOC_S_FBUF */ 549 ioctl(-1, VIDIOC_S_FBUF, 0); 550 printf("ioctl(-1, VIDIOC_S_FBUF, NULL) = -1 EBADF (%m)\n"); 551 552 struct v4l2_framebuffer *const p_v4l2_framebuffer = 553 page + size - sizeof(*p_v4l2_framebuffer); 554 ioctl(-1, VIDIOC_S_FBUF, p_v4l2_framebuffer); 555 printf("ioctl(-1, VIDIOC_S_FBUF, {capability=%#x" 556 ", flags=%#x, base=%p}) = -1 EBADF (%m)\n", 557 p_v4l2_framebuffer->capability, 558 p_v4l2_framebuffer->flags, 559 p_v4l2_framebuffer->base); 560 561 /* VIDIOC_STREAMON */ 562 ioctl(-1, VIDIOC_STREAMON, 0); 563 printf("ioctl(-1, VIDIOC_STREAMON, NULL) = -1 EBADF (%m)\n"); 564 565 int *const p_int = page + size - sizeof(int); 566 ioctl(-1, VIDIOC_STREAMON, p_int); 567 printf("ioctl(-1, VIDIOC_STREAMON, [%#x /* V4L2_BUF_TYPE_??? */])" 568 " = -1 EBADF (%m)\n", *p_int); 569 570 /* VIDIOC_STREAMOFF */ 571 ioctl(-1, VIDIOC_STREAMOFF, 0); 572 printf("ioctl(-1, VIDIOC_STREAMOFF, NULL) = -1 EBADF (%m)\n"); 573 574 ioctl(-1, VIDIOC_STREAMOFF, p_int); 575 printf("ioctl(-1, VIDIOC_STREAMOFF, [%#x /* V4L2_BUF_TYPE_??? */])" 576 " = -1 EBADF (%m)\n", *p_int); 577 578 /* VIDIOC_G_PARM */ 579 ioctl(-1, VIDIOC_G_PARM, 0); 580 printf("ioctl(-1, VIDIOC_G_PARM, NULL) = -1 EBADF (%m)\n"); 581 582 struct v4l2_streamparm *const p_v4l2_streamparm = 583 page + size - sizeof(*p_v4l2_streamparm); 584 ioctl(-1, VIDIOC_G_PARM, p_v4l2_streamparm); 585 printf("ioctl(-1, VIDIOC_G_PARM, {type=%#x /* V4L2_BUF_TYPE_??? */})" 586 " = -1 EBADF (%m)\n", p_v4l2_streamparm->type); 587 588 /* VIDIOC_S_PARM */ 589 ioctl(-1, VIDIOC_S_PARM, 0); 590 printf("ioctl(-1, VIDIOC_S_PARM, NULL) = -1 EBADF (%m)\n"); 591 592 ioctl(-1, VIDIOC_S_PARM, p_v4l2_streamparm); 593 printf("ioctl(-1, VIDIOC_S_PARM, {type=%#x /* V4L2_BUF_TYPE_??? */})" 594 " = -1 EBADF (%m)\n", p_v4l2_streamparm->type); 595 596 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_streamparm, p_streamparm); 597 p_streamparm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 598 p_streamparm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; 599 p_streamparm->parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; 600 p_streamparm->parm.capture.timeperframe.numerator = 0xdeadbeef; 601 p_streamparm->parm.capture.timeperframe.denominator = 0xbadc0ded; 602 ioctl(-1, VIDIOC_S_PARM, p_streamparm); 603 printf("ioctl(-1, VIDIOC_S_PARM, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE" 604 ", parm.capture={capability=V4L2_CAP_TIMEPERFRAME" 605 ", capturemode=V4L2_MODE_HIGHQUALITY, timeperframe=%u/%u" 606 ", extendedmode=%u, readbuffers=%u}}) = -1 EBADF (%m)\n", 607 p_streamparm->parm.capture.timeperframe.numerator, 608 p_streamparm->parm.capture.timeperframe.denominator, -1U, -1U); 609 610 p_streamparm->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 611 p_streamparm->parm.output.outputmode = 0; 612 ioctl(-1, VIDIOC_S_PARM, p_streamparm); 613 printf("ioctl(-1, VIDIOC_S_PARM, {type=V4L2_BUF_TYPE_VIDEO_OUTPUT" 614 ", parm.output={capability=V4L2_CAP_TIMEPERFRAME" 615 ", outputmode=0, timeperframe=%u/%u" 616 ", extendedmode=%u, writebuffers=%u}}) = -1 EBADF (%m)\n", 617 p_streamparm->parm.output.timeperframe.numerator, 618 p_streamparm->parm.output.timeperframe.denominator, -1U, -1U); 619 620 /* VIDIOC_G_STD */ 621 ioctl(-1, VIDIOC_G_STD, 0); 622 printf("ioctl(-1, VIDIOC_G_STD, NULL) = -1 EBADF (%m)\n"); 623 624 ioctl(-1, VIDIOC_G_STD, page); 625 printf("ioctl(-1, VIDIOC_G_STD, %p) = -1 EBADF (%m)\n", page); 626 627 /* VIDIOC_S_STD */ 628 ioctl(-1, VIDIOC_S_STD, 0); 629 printf("ioctl(-1, VIDIOC_S_STD, NULL) = -1 EBADF (%m)\n"); 630 631 long long *const p_longlong = page + size - sizeof(*p_longlong); 632 ioctl(-1, VIDIOC_S_STD, p_longlong); 633 printf("ioctl(-1, VIDIOC_S_STD, [%#llx]) = -1 EBADF (%m)\n", 634 *p_longlong); 635 636 /* VIDIOC_ENUMSTD */ 637 ioctl(-1, VIDIOC_ENUMSTD, 0); 638 printf("ioctl(-1, VIDIOC_ENUMSTD, NULL) = -1 EBADF (%m)\n"); 639 640 struct v4l2_standard *const p_v4l2_standard = 641 page + size - sizeof(*p_v4l2_standard); 642 ioctl(-1, VIDIOC_ENUMSTD, p_v4l2_standard); 643 printf("ioctl(-1, VIDIOC_ENUMSTD, {index=%u}) = -1 EBADF (%m)\n", 644 p_v4l2_standard->index); 645 646 /* VIDIOC_ENUMINPUT */ 647 ioctl(-1, VIDIOC_ENUMINPUT, 0); 648 printf("ioctl(-1, VIDIOC_ENUMINPUT, NULL) = -1 EBADF (%m)\n"); 649 650 struct v4l2_input *const p_v4l2_input = 651 page + size - sizeof(*p_v4l2_input); 652 ioctl(-1, VIDIOC_ENUMINPUT, p_v4l2_input); 653 printf("ioctl(-1, VIDIOC_ENUMINPUT, {index=%u}) = -1 EBADF (%m)\n", 654 p_v4l2_input->index); 655 656 /* VIDIOC_G_CTRL */ 657 ioctl(-1, VIDIOC_G_CTRL, 0); 658 printf("ioctl(-1, VIDIOC_G_CTRL, NULL) = -1 EBADF (%m)\n"); 659 660 struct v4l2_control *const p_v4l2_control = 661 page + size - sizeof(*p_v4l2_control); 662 ioctl(-1, VIDIOC_G_CTRL, p_v4l2_control); 663 printf("ioctl(-1, VIDIOC_G_CTRL, {id=%#x /* V4L2_CID_??? */})" 664 " = -1 EBADF (%m)\n", p_v4l2_control->id); 665 666 /* VIDIOC_S_CTRL */ 667 ioctl(-1, VIDIOC_S_CTRL, 0); 668 printf("ioctl(-1, VIDIOC_S_CTRL, NULL) = -1 EBADF (%m)\n"); 669 670 ioctl(-1, VIDIOC_S_CTRL, p_v4l2_control); 671 printf("ioctl(-1, VIDIOC_S_CTRL, {id=%#x /* V4L2_CID_??? */" 672 ", value=%d}) = -1 EBADF (%m)\n", 673 p_v4l2_control->id, p_v4l2_control->value); 674 675 /* VIDIOC_G_TUNER */ 676 ioctl(-1, VIDIOC_G_TUNER, 0); 677 printf("ioctl(-1, VIDIOC_G_TUNER, NULL) = -1 EBADF (%m)\n"); 678 679 struct v4l2_tuner *const p_v4l2_tuner = 680 page + size - sizeof(*p_v4l2_tuner); 681 ioctl(-1, VIDIOC_G_TUNER, p_v4l2_tuner); 682 printf("ioctl(-1, VIDIOC_G_TUNER, {index=%u})" 683 " = -1 EBADF (%m)\n", p_v4l2_tuner->index); 684 685 /* VIDIOC_S_TUNER */ 686 ioctl(-1, VIDIOC_S_TUNER, 0); 687 printf("ioctl(-1, VIDIOC_S_TUNER, NULL) = -1 EBADF (%m)\n"); 688 689 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_tuner, p_tuner); 690 p_tuner->index = 0x4fb6df39; 691 strcpy((char *) p_tuner->name, "cum tacent clamant"); 692 p_tuner->type = V4L2_TUNER_RADIO; 693 p_tuner->capability = V4L2_TUNER_CAP_LOW; 694 p_tuner->rangelow = 0xa673bc29; 695 p_tuner->rangehigh = 0xbaf16d12; 696 p_tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 697 p_tuner->audmode = V4L2_TUNER_MODE_MONO; 698 p_tuner->signal = 0x10bf92c8; 699 p_tuner->afc = 0x3bf7e18b; 700 ioctl(-1, VIDIOC_S_TUNER, p_tuner); 701 printf("ioctl(-1, VIDIOC_S_TUNER, {index=%u" 702 ", name=\"cum tacent clamant\"" 703 ", type=V4L2_TUNER_RADIO, capability=V4L2_TUNER_CAP_LOW" 704 ", rangelow=%u, rangehigh=%u" 705 ", rxsubchans=V4L2_TUNER_SUB_MONO" 706 ", audmode=V4L2_TUNER_MODE_MONO, signal=%d, afc=%d" 707 "}) = -1 EBADF (%m)\n", 708 p_tuner->index, p_tuner->rangelow, 709 p_tuner->rangehigh, p_tuner->signal, p_tuner->afc); 710 711 /* VIDIOC_QUERYCTRL */ 712 ioctl(-1, VIDIOC_QUERYCTRL, 0); 713 printf("ioctl(-1, VIDIOC_QUERYCTRL, NULL) = -1 EBADF (%m)\n"); 714 715 struct v4l2_queryctrl *const p_v4l2_queryctrl = 716 page + size - sizeof(*p_v4l2_queryctrl); 717 ioctl(-1, VIDIOC_QUERYCTRL, p_v4l2_queryctrl); 718 # ifdef V4L2_CTRL_FLAG_NEXT_CTRL 719 printf("ioctl(-1, VIDIOC_QUERYCTRL, {id=V4L2_CTRL_FLAG_NEXT_CTRL" 720 "|%#x /* V4L2_CID_??? */}) = -1 EBADF (%m)\n", 721 p_v4l2_queryctrl->id & ~V4L2_CTRL_FLAG_NEXT_CTRL); 722 # else 723 printf("ioctl(-1, VIDIOC_QUERYCTRL, {id=%#x /* V4L2_CID_??? */})" 724 " = -1 EBADF (%m)\n", p_v4l2_queryctrl->id); 725 # endif 726 727 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_queryctrl, p_queryctrl); 728 p_queryctrl->id = V4L2_CID_SATURATION; 729 ioctl(-1, VIDIOC_QUERYCTRL, p_queryctrl); 730 printf("ioctl(-1, VIDIOC_QUERYCTRL, {id=V4L2_CID_SATURATION})" 731 " = -1 EBADF (%m)\n"); 732 733 /* VIDIOC_G_INPUT */ 734 ioctl(-1, VIDIOC_G_INPUT, 0); 735 printf("ioctl(-1, VIDIOC_G_INPUT, NULL) = -1 EBADF (%m)\n"); 736 737 ioctl(-1, VIDIOC_G_INPUT, page); 738 printf("ioctl(-1, VIDIOC_G_INPUT, %p) = -1 EBADF (%m)\n", page); 739 740 /* VIDIOC_S_INPUT */ 741 ioctl(-1, VIDIOC_S_INPUT, 0); 742 printf("ioctl(-1, VIDIOC_S_INPUT, NULL) = -1 EBADF (%m)\n"); 743 744 ioctl(-1, VIDIOC_S_INPUT, p_int); 745 printf("ioctl(-1, VIDIOC_S_INPUT, [%u]) = -1 EBADF (%m)\n", *p_int); 746 747 /* VIDIOC_CROPCAP */ 748 ioctl(-1, VIDIOC_CROPCAP, 0); 749 printf("ioctl(-1, VIDIOC_CROPCAP, NULL) = -1 EBADF (%m)\n"); 750 751 struct v4l2_cropcap *const p_v4l2_cropcap = 752 page + size - sizeof(*p_v4l2_cropcap); 753 ioctl(-1, VIDIOC_CROPCAP, p_v4l2_cropcap); 754 printf("ioctl(-1, VIDIOC_CROPCAP, {type=%#x /* V4L2_BUF_TYPE_??? */})" 755 " = -1 EBADF (%m)\n", p_v4l2_cropcap->type); 756 757 /* VIDIOC_G_CROP */ 758 ioctl(-1, VIDIOC_G_CROP, 0); 759 printf("ioctl(-1, VIDIOC_G_CROP, NULL) = -1 EBADF (%m)\n"); 760 761 struct v4l2_crop *const p_v4l2_crop = 762 page + size - sizeof(*p_v4l2_crop); 763 ioctl(-1, VIDIOC_G_CROP, p_v4l2_crop); 764 printf("ioctl(-1, VIDIOC_G_CROP, {type=%#x /* V4L2_BUF_TYPE_??? */})" 765 " = -1 EBADF (%m)\n", p_v4l2_crop->type); 766 767 /* VIDIOC_S_CROP */ 768 ioctl(-1, VIDIOC_S_CROP, 0); 769 printf("ioctl(-1, VIDIOC_S_CROP, NULL) = -1 EBADF (%m)\n"); 770 771 ioctl(-1, VIDIOC_S_CROP, p_v4l2_crop); 772 printf("ioctl(-1, VIDIOC_S_CROP, {type=%#x /* V4L2_BUF_TYPE_??? */" 773 ", c={left=%d, top=%d, width=%u, height=%u}}) = -1 EBADF (%m)\n", 774 p_v4l2_crop->type, 775 p_v4l2_crop->c.left, 776 p_v4l2_crop->c.top, 777 p_v4l2_crop->c.width, 778 p_v4l2_crop->c.height); 779 780 #ifdef VIDIOC_S_EXT_CTRLS 781 /* VIDIOC_S_EXT_CTRLS */ 782 ioctl(-1, VIDIOC_S_EXT_CTRLS, 0); 783 printf("ioctl(-1, VIDIOC_S_EXT_CTRLS, NULL) = -1 EBADF (%m)\n"); 784 785 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_ext_controls, p_ext_controls); 786 p_ext_controls->ctrl_class = V4L2_CTRL_CLASS_USER; 787 p_ext_controls->count = 0; 788 p_ext_controls->controls = (void *) -2UL; 789 ioctl(-1, VIDIOC_S_EXT_CTRLS, p_ext_controls); 790 printf("ioctl(-1, VIDIOC_S_EXT_CTRLS, {ctrl_class=V4L2_CTRL_CLASS_USER" 791 ", count=%u}) = -1 EBADF (%m)\n", p_ext_controls->count); 792 793 p_ext_controls->ctrl_class = V4L2_CTRL_CLASS_MPEG; 794 p_ext_controls->count = magic; 795 ioctl(-1, VIDIOC_S_EXT_CTRLS, p_ext_controls); 796 printf("ioctl(-1, VIDIOC_S_EXT_CTRLS, {ctrl_class=V4L2_CTRL_CLASS_MPEG" 797 ", count=%u, controls=%p}) = -1 EBADF (%m)\n", 798 p_ext_controls->count, p_ext_controls->controls); 799 800 # if HAVE_DECL_V4L2_CTRL_TYPE_STRING 801 p_ext_controls->count = 2; 802 p_ext_controls->controls = 803 tail_alloc(sizeof(*p_ext_controls->controls) * p_ext_controls->count); 804 p_ext_controls->controls[0].id = V4L2_CID_BRIGHTNESS; 805 p_ext_controls->controls[0].size = 0; 806 p_ext_controls->controls[0].value64 = 0xfacefeeddeadbeefULL; 807 p_ext_controls->controls[1].id = V4L2_CID_CONTRAST; 808 p_ext_controls->controls[1].size = 2; 809 p_ext_controls->controls[1].string = 810 tail_alloc(p_ext_controls->controls[1].size); 811 812 ioctl(-1, VIDIOC_S_EXT_CTRLS, p_ext_controls); 813 printf("ioctl(-1, VIDIOC_S_EXT_CTRLS" 814 ", {ctrl_class=V4L2_CTRL_CLASS_MPEG, count=%u, controls=" 815 "[{id=V4L2_CID_BRIGHTNESS, size=0, value=%d, value64=%lld}" 816 ", {id=V4L2_CID_CONTRAST, size=2, string=\"\\377\\377\"}" 817 "] => controls=" 818 "[{id=V4L2_CID_BRIGHTNESS, size=0, value=%d, value64=%lld}" 819 ", {id=V4L2_CID_CONTRAST, size=2, string=\"\\377\\377\"}" 820 "], error_idx=%u}) = -1 EBADF (%m)\n", 821 p_ext_controls->count, 822 p_ext_controls->controls[0].value, 823 (long long) p_ext_controls->controls[0].value64, 824 p_ext_controls->controls[0].value, 825 (long long) p_ext_controls->controls[0].value64, 826 p_ext_controls->error_idx); 827 828 ++p_ext_controls->count; 829 ioctl(-1, VIDIOC_S_EXT_CTRLS, p_ext_controls); 830 printf("ioctl(-1, VIDIOC_S_EXT_CTRLS" 831 ", {ctrl_class=V4L2_CTRL_CLASS_MPEG, count=%u, controls=" 832 "[{id=V4L2_CID_BRIGHTNESS, size=0, value=%d, value64=%lld}" 833 ", {id=V4L2_CID_CONTRAST, size=2, string=\"\\377\\377\"}" 834 ", %p]}) = -1 EBADF (%m)\n", 835 p_ext_controls->count, 836 p_ext_controls->controls[0].value, 837 (long long) p_ext_controls->controls[0].value64, 838 p_ext_controls->controls + 2); 839 # endif /* HAVE_DECL_V4L2_CTRL_TYPE_STRING */ 840 841 /* VIDIOC_TRY_EXT_CTRLS */ 842 ioctl(-1, VIDIOC_TRY_EXT_CTRLS, 0); 843 printf("ioctl(-1, VIDIOC_TRY_EXT_CTRLS, NULL) = -1 EBADF (%m)\n"); 844 845 p_ext_controls->ctrl_class = V4L2_CTRL_CLASS_USER; 846 p_ext_controls->count = magic; 847 p_ext_controls->controls = (void *) -2UL; 848 ioctl(-1, VIDIOC_TRY_EXT_CTRLS, p_ext_controls); 849 printf("ioctl(-1, VIDIOC_TRY_EXT_CTRLS" 850 ", {ctrl_class=V4L2_CTRL_CLASS_USER, count=%u, controls=%p})" 851 " = -1 EBADF (%m)\n", 852 p_ext_controls->count, p_ext_controls->controls); 853 854 /* VIDIOC_G_EXT_CTRLS */ 855 ioctl(-1, VIDIOC_G_EXT_CTRLS, 0); 856 printf("ioctl(-1, VIDIOC_G_EXT_CTRLS, NULL) = -1 EBADF (%m)\n"); 857 858 ioctl(-1, VIDIOC_G_EXT_CTRLS, p_ext_controls); 859 printf("ioctl(-1, VIDIOC_G_EXT_CTRLS" 860 ", {ctrl_class=V4L2_CTRL_CLASS_USER, count=%u, controls=%p" 861 ", error_idx=%u}) = -1 EBADF (%m)\n", 862 p_ext_controls->count, p_ext_controls->controls, 863 p_ext_controls->error_idx); 864 #endif /* VIDIOC_S_EXT_CTRLS */ 865 866 #ifdef VIDIOC_ENUM_FRAMESIZES 867 ioctl(-1, VIDIOC_ENUM_FRAMESIZES, 0); 868 printf("ioctl(-1, VIDIOC_ENUM_FRAMESIZES, NULL) = -1 EBADF (%m)\n"); 869 870 TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_frmsizeenum, p_frmsizeenum); 871 p_frmsizeenum->index = magic; 872 p_frmsizeenum->pixel_format = fourcc(cc[0], cc[1], cc[2], cc[3]); 873 874 ioctl(-1, VIDIOC_ENUM_FRAMESIZES, p_frmsizeenum); 875 printf("ioctl(-1, VIDIOC_ENUM_FRAMESIZES, {index=%u" 876 ", pixel_format=v4l2_fourcc('%c', '\\%c', '\\%c', '\\x%x')})" 877 " = -1 EBADF (%m)\n", p_frmsizeenum->index, 878 cc[0], cc[1], cc[2], cc[3]); 879 #endif /* VIDIOC_ENUM_FRAMESIZES */ 880 881 #ifdef VIDIOC_ENUM_FRAMEINTERVALS 882 ioctl(-1, VIDIOC_ENUM_FRAMEINTERVALS, 0); 883 printf("ioctl(-1, VIDIOC_ENUM_FRAMEINTERVALS, NULL) = -1 EBADF (%m)\n"); 884 885 struct v4l2_frmivalenum *const p_v4l2_frmivalenum = 886 page + size - sizeof(*p_v4l2_frmivalenum); 887 ioctl(-1, VIDIOC_ENUM_FRAMEINTERVALS, p_v4l2_frmivalenum); 888 printf("ioctl(-1, VIDIOC_ENUM_FRAMEINTERVALS, {index=%u" 889 ", pixel_format=v4l2_fourcc('\\x%x', '\\x%x', '\\x%x', '\\x%x')" 890 ", width=%u, height=%u}) = -1 EBADF (%m)\n", 891 p_v4l2_frmivalenum->index, 892 cc0(p_v4l2_frmivalenum->pixel_format), 893 cc1(p_v4l2_frmivalenum->pixel_format), 894 cc2(p_v4l2_frmivalenum->pixel_format), 895 cc3(p_v4l2_frmivalenum->pixel_format), 896 p_v4l2_frmivalenum->width, 897 p_v4l2_frmivalenum->height); 898 #endif /* VIDIOC_ENUM_FRAMEINTERVALS */ 899 900 #ifdef VIDIOC_CREATE_BUFS 901 ioctl(-1, VIDIOC_CREATE_BUFS, 0); 902 printf("ioctl(-1, VIDIOC_CREATE_BUFS, NULL) = -1 EBADF (%m)\n"); 903 904 struct v4l2_create_buffers *const p_v4l2_create_buffers = 905 page + size - sizeof(*p_v4l2_create_buffers); 906 ioctl(-1, VIDIOC_CREATE_BUFS, p_v4l2_create_buffers); 907 printf("ioctl(-1, VIDIOC_CREATE_BUFS, {count=%u, memory=%#x" 908 " /* V4L2_MEMORY_??? */, format={type=%#x" 909 " /* V4L2_BUF_TYPE_??? */}}) = -1 EBADF (%m)\n", 910 p_v4l2_create_buffers->count, 911 p_v4l2_create_buffers->memory, 912 p_v4l2_create_buffers->format.type); 913 #endif /* VIDIOC_CREATE_BUFS */ 914 915 puts("+++ exited with 0 +++"); 916 return 0; 917 } 918