#include #include #include #include #include #include #include #include #include #include #include #include #include #include "uvc_compat.h" static int xioctl( int fd, int request, void *arg ) { int r; do r = ioctl (fd, request, arg); while (r == -1 && errno == EINTR); return r; }; int main( int argc, char *argv[] ) { int fd; if (argc < 2) return -1; // open device if ((fd = open (argv[1], O_RDWR)) < 0) { fd = 0; fprintf (stderr, "open (): %s\n", strerror(errno)); return -1; } fcntl (fd, F_SETFD, FD_CLOEXEC); int index = 0, ret, ret2; struct v4l2_frmsizeenum fsize; memset (&fsize, 0, sizeof(fsize)); fsize.pixel_format = V4L2_PIX_FMT_YUV420; fsize.index = 0; struct v4l2_frmivalenum fival; memset (&fival, 0, sizeof(fival)); do { ret = xioctl (fd, VIDIOC_ENUM_FRAMESIZES, &fsize); if (ret == 0 && fsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) { printf ("%i: %ix%i: ", fsize.index, fsize.discrete.width, fsize.discrete.height); fival.pixel_format = fsize.pixel_format; fival.width = fsize.discrete.width; fival.height = fsize.discrete.height; fival.index = 0; do { ret2 = xioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS, &fival); if (ret2 == 0 && fival.type == V4L2_FRMIVAL_TYPE_DISCRETE) { printf ("%u/%u ", fival.discrete.numerator, fival.discrete.denominator); } fival.index++; } while (ret2 == 0); printf ("\n"); } fsize.index++; } while (ret==0); close (fd); return 0; }