diff --git a/v4l2/t.c b/v4l2/t.c index bf537fa..2edc5a6 100644 --- a/v4l2/t.c +++ b/v4l2/t.c @@ -20,9 +20,9 @@ int verbosity; /* --------------------------------------------------------------------- */ -int essai(char *dev, int k) +int essai_get_fmt(char *dev, int k) { -int vfd, foo; +int vfd, idx, foo; struct v4l2_format fmt; struct v4l2_requestbuffers reqbuf; @@ -31,20 +31,22 @@ fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, dev, k); vfd = open_device(dev); if (verbosity) fprintf(stderr, "\topen %s -> %d\n", dev, vfd); -memset(&fmt, 0, sizeof(fmt)); -fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - -foo = ioctl(vfd, VIDIOC_G_FMT, &fmt); -fprintf(stderr, "ioctl -> %d\n", foo); -if (0 != foo) { - perror("ioctl G_FMT"); - exit(1); - } + memset(&fmt, 0, sizeof(fmt)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + foo = ioctl(vfd, VIDIOC_G_FMT, &fmt); + fprintf(stderr, "%s : ioctl -> %d\n", __func__, foo); + if (0 != foo) { + perror("ioctl G_FMT"); + return -1; + } pr_v4l2_format("after ioctl VIDIOC_G_FMT", &fmt); /* this function is bugged */ +close(vfd); + + return k; } /* --------------------------------------------------------------------- */ @@ -79,7 +81,7 @@ while ((opt = getopt(argc, argv, "d:hK:v")) != -1) { if (verbosity) fimg_print_version(0); -foo = essai(device, K); +foo = essai_get_fmt(device, K); fprintf(stderr, "\tessai -> %d\n", foo); return 0;