Hi, In an attempt to see how V4L2 programming works, I try to write a little capture program. The program below returns an invalid argument in the VIDIOC_QUERYBUF ioctl: [gert@viper v4l2]$ gcc -O2 v4l2_cap.c [gert@viper v4l2]$ ./a.out image size: 152064 2 buffers granted VIDIOC_QUERYBUF: Invalid argument [gert@viper v4l2]$ What am I overlooking? -- Gert driver : bttv-0.8.31 kernel : 2.4.15 patches : 10_videodev-2.4.15-pre6.diff 11_v4l2-2.4.15-pre6.diff 12_userdma-2.4.15-pre6.diff v4l2_cap.c: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <linux/videodev.h> #define HSIZE 352 #define VSIZE 288 #define NUM_BUFFERS 2 struct buffer { struct v4l2_buffer vidbuf; char* data; int length; }; int main() { struct v4l2_capability vidcap; struct v4l2_format fmt; struct v4l2_requestbuffers reqbufs; struct buffer cap_bufs[NUM_BUFFERS]; int fd; int i; if((fd = open("/dev/video", O_RDWR)) < 0) { perror("open"); exit(-1); } if(ioctl(fd, VIDIOC_QUERYCAP, &vidcap) < 0) { perror("VIDIOC_QUERYCAP"); exit(-1); } if (vidcap.type != V4L2_TYPE_CAPTURE) { fprintf(stderr, "Error, not a capture device\n"); exit(-1); } if(!(vidcap.flags & V4L2_FLAG_STREAMING)) { fprintf(stderr, "Error, streaming capture not supported\n"); exit(-1); } memset(&fmt, 0x0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_CAPTURE; fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; fmt.fmt.pix.flags = V4L2_FMT_FLAG_INTERLACED; fmt.fmt.pix.width = HSIZE; fmt.fmt.pix.height = VSIZE; if(ioctl(fd, VIDIOC_S_FMT, &fmt) < 0) { perror("VIDIOC_S_FMT"); exit(-1); } printf("image size: %d\n", fmt.fmt.pix.sizeimage); reqbufs.count = NUM_BUFFERS; reqbufs.type = V4L2_BUF_TYPE_CAPTURE; if(ioctl(fd, VIDIOC_REQBUFS, &reqbufs) < 0) { perror("VIDIOC_REQBUFS"); exit(-1); } printf("%d buffers granted\n", reqbufs.count); for(i=0; i<reqbufs.count; i++) { struct v4l2_buffer *vidbuf = &cap_bufs[i].vidbuf; vidbuf->index = i; vidbuf->type = V4L2_BUF_TYPE_CAPTURE; if(ioctl(fd, VIDIOC_QUERYBUF, vidbuf) < 0) { perror("VIDIOC_QUERYBUF"); exit(-1); } } close(fd); return 0; }