• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * v4l-test: Test environment for Video For Linux Two API
3  *
4  *  5 May 2009  0.1  First release
5  *
6  * Written by M�rton N�meth <nm127@freemail.hu>
7  * Released under GPL
8  */
9 
10 #include <stdio.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <fcntl.h>
14 #include <unistd.h>
15 #include <sys/ioctl.h>
16 #include <errno.h>
17 #include <string.h>
18 
19 #include <linux/videodev2.h>
20 #include <linux/errno.h>
21 
22 #include <CUnit/CUnit.h>
23 
24 #include "v4l2_test.h"
25 #include "v4l2_show.h"
26 #include "dev_video.h"
27 #include "video_limits.h"
28 
29 #include "test_VIDIOC_REQBUFS.h"
30 
do_VIDIOC_QUERYBUF(enum v4l2_memory memory,enum v4l2_buf_type type,__u32 count,int expected_ret_req)31 static void do_VIDIOC_QUERYBUF(enum v4l2_memory memory,
32 			       enum v4l2_buf_type type, __u32 count,
33 			       int expected_ret_req)
34 {
35 	int ret_req, errno_req;
36 	int ret_query, errno_query;
37 	struct v4l2_requestbuffers reqbuf;
38 	struct v4l2_buffer buf;
39 	__u32 i;
40 	unsigned int j;
41 	const enum v4l2_buf_type buffer_types[] = {
42 		0,
43 		V4L2_BUF_TYPE_VIDEO_CAPTURE,
44 		V4L2_BUF_TYPE_VIDEO_OUTPUT,
45 		V4L2_BUF_TYPE_VIDEO_OVERLAY,
46 		V4L2_BUF_TYPE_VBI_CAPTURE,
47 		V4L2_BUF_TYPE_VBI_OUTPUT,
48 		V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,
49 		V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,
50 		V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY,
51 		V4L2_BUF_TYPE_PRIVATE - 1,
52 		V4L2_BUF_TYPE_PRIVATE,
53 		V4L2_BUF_TYPE_PRIVATE + 1,
54 		S32_MAX,
55 		(__s32) ((__u32) S32_MAX + 1),
56 		U32_MAX - 1,
57 		U32_MAX
58 	};
59 
60 	memset(&reqbuf, 0, sizeof(reqbuf));
61 	reqbuf.count = count;
62 	reqbuf.type = type;
63 	reqbuf.memory = memory;
64 
65 	ret_req = ioctl(get_video_fd(), VIDIOC_REQBUFS, &reqbuf);
66 	errno_req = errno;
67 
68 	if (expected_ret_req == 0) {
69 		CU_ASSERT_EQUAL(ret_req, 0);
70 	} else {
71 		CU_ASSERT_EQUAL(ret_req, -1);
72 		CU_ASSERT_EQUAL(errno_req, EINVAL);
73 	}
74 
75 	dprintf
76 	    ("\t%s:%u: VIDIOC_REQBUF, count=%u, type=%i, memory=%i, ret_req=%i, errno_req=%i\n",
77 	     __FILE__, __LINE__, count, type, memory, ret_req, errno_req);
78 
79 	if (ret_req == 0) {
80 		show_v4l2_requestbuffers(&reqbuf);
81 	}
82 
83 	if (ret_req != 0) {
84 		reqbuf.count = 0;
85 	}
86 
87 	for (i = 0; i < reqbuf.count; i++) {
88 		memset(&buf, 0xff, sizeof(buf));
89 		buf.type = type;
90 		buf.index = i;
91 
92 		ret_query = ioctl(get_video_fd(), VIDIOC_QUERYBUF, &buf);
93 		errno_query = errno;
94 
95 		CU_ASSERT_EQUAL(buf.index, i);
96 		CU_ASSERT_EQUAL(buf.type, type);
97 		//CU_ASSERT_EQUAL(buf.bytesused, ???);
98 		CU_ASSERT_EQUAL(buf.
99 				flags & ~(V4L2_BUF_FLAG_MAPPED |
100 					  V4L2_BUF_FLAG_QUEUED |
101 					  V4L2_BUF_FLAG_DONE), 0);
102 		//CU_ASSERT_EQUAL(buf.field, ???);
103 		//CU_ASSERT_EQUAL(buf.timestamp.tv_sec, ???);
104 		//CU_ASSERT_EQUAL(buf.timestamp.tv_usec, ???);
105 		//CU_ASSERT_EQUAL(buf.timecode.type, ???);
106 		//CU_ASSERT_EQUAL(buf.timecode.flags, ???);
107 		//CU_ASSERT_EQUAL(buf.timecode.frames, ???);
108 		//CU_ASSERT_EQUAL(buf.timecode.seconds, ???);
109 		//CU_ASSERT_EQUAL(buf.timecode.minutes, ???);
110 		//CU_ASSERT_EQUAL(buf.timecode.hours, ???);
111 		//CU_ASSERT_EQUAL(buf.timecode.userbits[0], ???);
112 		//CU_ASSERT_EQUAL(buf.timecode.userbits[1], ???);
113 		//CU_ASSERT_EQUAL(buf.timecode.userbits[2], ???);
114 		//CU_ASSERT_EQUAL(buf.timecode.userbits[3], ???);
115 		//CU_ASSERT_EQUAL(buf.sequence, ???);
116 		CU_ASSERT_EQUAL(buf.memory, memory);
117 		//CU_ASSERT_EQUAL(buf.m.userptr, ???);
118 		//CU_ASSERT_EQUAL(buf.m.offset, ???);
119 		CU_ASSERT(0 < buf.length);
120 		//CU_ASSERT_EQUAL(buf.input, ???);
121 		CU_ASSERT_EQUAL(buf.reserved, 0);
122 
123 		dprintf
124 		    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
125 		     __FILE__, __LINE__, buf.type, buf.index, ret_query,
126 		     errno_query);
127 		if (ret_query == 0)
128 			show_v4l2_buffer(&buf);
129 
130 	}
131 
132 	/* Check for not buffer types which do not match the VIDIOC_REQBUF
133 	 * buffer type
134 	 */
135 	for (i = 0; i < reqbuf.count; i++) {
136 		for (j = 0; j < sizeof(buffer_types) / sizeof(*buffer_types);
137 		     j++) {
138 			if (buffer_types[j] != type) {
139 				memset(&buf, 0xff, sizeof(buf));
140 				buf.type = buffer_types[j];
141 				buf.index = i;
142 
143 				ret_query =
144 				    ioctl(get_video_fd(), VIDIOC_QUERYBUF,
145 					  &buf);
146 				errno_query = errno;
147 
148 				CU_ASSERT_EQUAL(ret_query, -1);
149 				CU_ASSERT_EQUAL(errno_query, EINVAL);
150 
151 				dprintf
152 				    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
153 				     __FILE__, __LINE__, buf.type, buf.index,
154 				     ret_query, errno_query);
155 				if (ret_query == 0)
156 					show_v4l2_buffer(&buf);
157 			}
158 		}
159 	}
160 
161 	memset(&buf, 0xff, sizeof(buf));
162 	buf.type = type;
163 	buf.index = reqbuf.count;
164 
165 	ret_query = ioctl(get_video_fd(), VIDIOC_QUERYBUF, &buf);
166 	errno_query = errno;
167 
168 	dprintf
169 	    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
170 	     __FILE__, __LINE__, buf.type, buf.index, ret_query, errno_query);
171 
172 	CU_ASSERT_EQUAL(ret_query, -1);
173 	CU_ASSERT_EQUAL(errno_query, EINVAL);
174 
175 	if (reqbuf.count < (__u32) S16_MIN) {
176 		memset(&buf, 0xff, sizeof(buf));
177 		buf.type = type;
178 		buf.index = (__u32) S16_MIN;
179 
180 		ret_query = ioctl(get_video_fd(), VIDIOC_QUERYBUF, &buf);
181 		errno_query = errno;
182 
183 		dprintf
184 		    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
185 		     __FILE__, __LINE__, buf.type, buf.index, ret_query,
186 		     errno_query);
187 
188 		CU_ASSERT_EQUAL(ret_query, -1);
189 		CU_ASSERT_EQUAL(errno_query, EINVAL);
190 	}
191 
192 	if (reqbuf.count < (__u32) S16_MAX) {
193 		memset(&buf, 0xff, sizeof(buf));
194 		buf.type = type;
195 		buf.index = (__u32) S16_MAX;
196 
197 		ret_query = ioctl(get_video_fd(), VIDIOC_QUERYBUF, &buf);
198 		errno_query = errno;
199 
200 		dprintf
201 		    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
202 		     __FILE__, __LINE__, buf.type, buf.index, ret_query,
203 		     errno_query);
204 
205 		CU_ASSERT_EQUAL(ret_query, -1);
206 		CU_ASSERT_EQUAL(errno_query, EINVAL);
207 	}
208 
209 	if (reqbuf.count < U32_MAX) {
210 		memset(&buf, 0xff, sizeof(buf));
211 		buf.type = type;
212 		buf.index = U32_MAX;
213 
214 		ret_query = ioctl(get_video_fd(), VIDIOC_QUERYBUF, &buf);
215 		errno_query = errno;
216 
217 		dprintf
218 		    ("\t%s:%u: VIDIOC_QUERYBUF, type=%i, index=%u, ret_query=%i, errno_query=%i\n",
219 		     __FILE__, __LINE__, buf.type, buf.index, ret_query,
220 		     errno_query);
221 
222 		CU_ASSERT_EQUAL(ret_query, -1);
223 		CU_ASSERT_EQUAL(errno_query, EINVAL);
224 	}
225 
226 	memset(&reqbuf, 0, sizeof(reqbuf));
227 	reqbuf.count = 0;
228 	reqbuf.type = type;
229 	reqbuf.memory = V4L2_MEMORY_MMAP;
230 
231 	ret_req = ioctl(get_video_fd(), VIDIOC_REQBUFS, &reqbuf);
232 	errno_req = errno;
233 
234 	dprintf("\t%s:%u: VIDIOC_REQBUF, count=%u, ret_req=%i, errno_req=%i\n",
235 		__FILE__, __LINE__, count, ret_req, errno_req);
236 
237 	if (expected_ret_req == 0) {
238 		CU_ASSERT_EQUAL(ret_req, 0);
239 	} else {
240 		CU_ASSERT_EQUAL(ret_req, -1);
241 		CU_ASSERT_EQUAL(errno_req, EINVAL);
242 	}
243 	if (ret_req == 0) {
244 		show_v4l2_requestbuffers(&reqbuf);
245 	}
246 }
247 
test_VIDIOC_QUERYBUF_capture_mmap()248 void test_VIDIOC_QUERYBUF_capture_mmap()
249 {
250 	int ret_cap, errno_cap;
251 	struct v4l2_capability cap;
252 	int expected_ret_req;
253 
254 	memset(&cap, 0, sizeof(cap));
255 
256 	ret_cap = ioctl(get_video_fd(), VIDIOC_QUERYCAP, &cap);
257 	errno_cap = errno;
258 
259 	if (ret_cap == 0 &&
260 	    (cap.capabilities & V4L2_CAP_STREAMING) &&
261 	    (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
262 		expected_ret_req = 0;
263 	} else {
264 		expected_ret_req = -1;
265 	}
266 
267 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
268 			   expected_ret_req);
269 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE, 1,
270 			   expected_ret_req);
271 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2,
272 			   expected_ret_req);
273 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE, 3,
274 			   expected_ret_req);
275 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE, 4,
276 			   expected_ret_req);
277 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE,
278 			   (__u32) S16_MIN, expected_ret_req);
279 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE,
280 			   (__u32) S16_MAX, expected_ret_req);
281 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_CAPTURE,
282 			   U32_MAX, expected_ret_req);
283 }
284 
test_VIDIOC_QUERYBUF_capture_userptr()285 void test_VIDIOC_QUERYBUF_capture_userptr()
286 {
287 	int ret_cap, errno_cap;
288 	int ret_req, errno_req;
289 	struct v4l2_capability cap;
290 	struct v4l2_requestbuffers reqbuf;
291 	int expected_ret_req;
292 
293 	memset(&cap, 0, sizeof(cap));
294 
295 	ret_cap = ioctl(get_video_fd(), VIDIOC_QUERYCAP, &cap);
296 	errno_cap = errno;
297 
298 	memset(&reqbuf, 0, sizeof(reqbuf));
299 	reqbuf.count = 2;
300 	reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
301 	reqbuf.memory = V4L2_MEMORY_USERPTR;
302 
303 	ret_req = ioctl(get_video_fd(), VIDIOC_REQBUFS, &reqbuf);
304 	errno_req = errno;
305 
306 	dprintf("\t%s:%u: VIDIOC_REQBUF, count=%u, ret_req=%i, errno_req=%i\n",
307 		__FILE__, __LINE__, reqbuf.count, ret_req, errno_req);
308 
309 	if (ret_cap == 0 &&
310 	    (cap.capabilities & V4L2_CAP_STREAMING) &&
311 	    (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) && ret_req == 0) {
312 		expected_ret_req = 0;
313 	} else {
314 		expected_ret_req = -1;
315 	}
316 
317 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
318 			   expected_ret_req);
319 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 1,
320 			   expected_ret_req);
321 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2,
322 			   expected_ret_req);
323 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 3,
324 			   expected_ret_req);
325 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 4,
326 			   expected_ret_req);
327 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE,
328 			   (__u32) S16_MIN, expected_ret_req);
329 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE,
330 			   (__u32) S16_MAX, expected_ret_req);
331 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE,
332 			   U32_MAX, expected_ret_req);
333 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
334 			   expected_ret_req);
335 }
336 
test_VIDIOC_QUERYBUF_output_mmap()337 void test_VIDIOC_QUERYBUF_output_mmap()
338 {
339 	int ret_cap, errno_cap;
340 	struct v4l2_capability cap;
341 	int expected_ret_req;
342 
343 	memset(&cap, 0, sizeof(cap));
344 
345 	ret_cap = ioctl(get_video_fd(), VIDIOC_QUERYCAP, &cap);
346 	errno_cap = errno;
347 
348 	if (ret_cap == 0 &&
349 	    (cap.capabilities & V4L2_CAP_STREAMING) &&
350 	    (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) {
351 		expected_ret_req = 0;
352 	} else {
353 		expected_ret_req = -1;
354 	}
355 
356 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0,
357 			   expected_ret_req);
358 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 1,
359 			   expected_ret_req);
360 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2,
361 			   expected_ret_req);
362 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 3,
363 			   expected_ret_req);
364 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 4,
365 			   expected_ret_req);
366 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT,
367 			   (__u32) S16_MIN, expected_ret_req);
368 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT,
369 			   (__u32) S16_MAX, expected_ret_req);
370 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT,
371 			   U32_MAX, expected_ret_req);
372 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0,
373 			   expected_ret_req);
374 }
375 
test_VIDIOC_QUERYBUF_output_userptr()376 void test_VIDIOC_QUERYBUF_output_userptr()
377 {
378 	int ret_cap, errno_cap;
379 	int ret_req, errno_req;
380 	struct v4l2_capability cap;
381 	struct v4l2_requestbuffers reqbuf;
382 	int expected_ret_req;
383 
384 	memset(&cap, 0, sizeof(cap));
385 
386 	ret_cap = ioctl(get_video_fd(), VIDIOC_QUERYCAP, &cap);
387 	errno_cap = errno;
388 
389 	memset(&reqbuf, 0, sizeof(reqbuf));
390 	reqbuf.count = 2;
391 	reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
392 	reqbuf.memory = V4L2_MEMORY_USERPTR;
393 
394 	ret_req = ioctl(get_video_fd(), VIDIOC_REQBUFS, &reqbuf);
395 	errno_req = errno;
396 
397 	dprintf("\t%s:%u: VIDIOC_REQBUF, count=%u, ret_req=%i, errno_req=%i\n",
398 		__FILE__, __LINE__, reqbuf.count, ret_req, errno_req);
399 
400 	if (ret_cap == 0 &&
401 	    (cap.capabilities & V4L2_CAP_STREAMING) &&
402 	    (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) && ret_req == 0) {
403 		expected_ret_req = 0;
404 	} else {
405 		expected_ret_req = -1;
406 	}
407 
408 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0,
409 			   expected_ret_req);
410 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 1,
411 			   expected_ret_req);
412 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2,
413 			   expected_ret_req);
414 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 3,
415 			   expected_ret_req);
416 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 4,
417 			   expected_ret_req);
418 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT,
419 			   (__u32) S16_MIN, expected_ret_req);
420 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT,
421 			   (__u32) S16_MAX, expected_ret_req);
422 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT,
423 			   U32_MAX, expected_ret_req);
424 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0,
425 			   expected_ret_req);
426 }
427 
test_VIDIOC_QUERYBUF_overlay_capture()428 void test_VIDIOC_QUERYBUF_overlay_capture()
429 {
430 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_OVERLAY, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2,
431 			   -1);
432 }
433 
test_VIDIOC_QUERYBUF_overlay_output()434 void test_VIDIOC_QUERYBUF_overlay_output()
435 {
436 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_OVERLAY, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2,
437 			   -1);
438 }
439 
test_VIDIOC_QUERYBUF_invalid_memory_capture()440 void test_VIDIOC_QUERYBUF_invalid_memory_capture()
441 {
442 	do_VIDIOC_QUERYBUF(SINT_MIN, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2, -1);
443 	do_VIDIOC_QUERYBUF(0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2, -1);
444 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_OVERLAY + 1, V4L2_BUF_TYPE_VIDEO_CAPTURE,
445 			   2, -1);
446 	do_VIDIOC_QUERYBUF(SINT_MAX, V4L2_BUF_TYPE_VIDEO_CAPTURE, 2, -1);
447 }
448 
test_VIDIOC_QUERYBUF_invalid_memory_output()449 void test_VIDIOC_QUERYBUF_invalid_memory_output()
450 {
451 	do_VIDIOC_QUERYBUF(SINT_MIN, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2, -1);
452 	do_VIDIOC_QUERYBUF(0, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2, -1);
453 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_OVERLAY + 1, V4L2_BUF_TYPE_VIDEO_OUTPUT,
454 			   2, -1);
455 	do_VIDIOC_QUERYBUF(SINT_MAX, V4L2_BUF_TYPE_VIDEO_OUTPUT, 2, -1);
456 }
457 
test_VIDIOC_QUERYBUF_invalid_type_mmap()458 void test_VIDIOC_QUERYBUF_invalid_type_mmap()
459 {
460 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, 0, 2, -1);
461 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OVERLAY, 2,
462 			   -1);
463 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VBI_CAPTURE, 2, -1);
464 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VBI_OUTPUT, 2, -1);
465 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,
466 			   2, -1);
467 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, 2,
468 			   -1);
469 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY,
470 			   2, -1);
471 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_PRIVATE - 1, 2, -1);
472 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_PRIVATE, 2, -1);
473 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, V4L2_BUF_TYPE_PRIVATE + 1, 2, -1);
474 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, S32_MAX, 2, -1);
475 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, (__s32) ((__u32) S32_MAX + 1), 2,
476 			   -1);
477 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, U32_MAX - 1, 2, -1);
478 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_MMAP, U32_MAX, 2, -1);
479 }
480 
test_VIDIOC_QUERYBUF_invalid_type_userptr()481 void test_VIDIOC_QUERYBUF_invalid_type_userptr()
482 {
483 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, 0, 2, -1);
484 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VIDEO_OVERLAY, 2,
485 			   -1);
486 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VBI_CAPTURE, 2,
487 			   -1);
488 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_VBI_OUTPUT, 2,
489 			   -1);
490 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR,
491 			   V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, 2, -1);
492 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,
493 			   2, -1);
494 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR,
495 			   V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, 2, -1);
496 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_PRIVATE - 1, 2,
497 			   -1);
498 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_PRIVATE, 2, -1);
499 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, V4L2_BUF_TYPE_PRIVATE + 1, 2,
500 			   -1);
501 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, S32_MAX, 2, -1);
502 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, (__s32) ((__u32) S32_MAX + 1),
503 			   2, -1);
504 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, U32_MAX - 1, 2, -1);
505 	do_VIDIOC_QUERYBUF(V4L2_MEMORY_USERPTR, U32_MAX, 2, -1);
506 }
507