@@ -61,6 +61,10 @@
#define V4L1_PIX_FMT_TOUCHED 0x04
#define V4L1_PIX_SIZE_TOUCHED 0x08
+#ifndef min
+ #define min( a, b ) ( ((a) < (b)) ? (a) : (b) )
+#endif
+
static pthread_mutex_t v4l1_open_mutex = PTHREAD_MUTEX_INITIALIZER;
static struct v4l1_dev_info devices[V4L1_MAX_DEVICES] = {
{ .fd = -1 },
@@ -130,6 +134,45 @@ static unsigned int pixelformat_to_palette(unsigned
int pixelformat)
return 0;
}
+static int count_inputs(int fd)
+{
+ struct v4l2_input input2;
+ int i;
+ for (i = 0;; i++) {
+ memset(&input2, 0, sizeof(input2));
+ input2.index = i;
+ if (0 != SYS_IOCTL(fd, VIDIOC_ENUMINPUT, &input2))
+ break;
+ }
+ return i;
+}
+
+static int check_size(int fd,int *maxw,int *maxh)
+{
+ struct v4l2_fmtdesc desc2;
+ struct v4l2_format fmt2;
+
+ memset(&desc2, 0, sizeof(desc2));
+ memset(&fmt2, 0, sizeof(fmt2));
+
+ desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (0 != SYS_IOCTL(fd, VIDIOC_ENUM_FMT, &desc2))
+ goto done;
+
+ fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt2.fmt.pix.width = 10000;
+ fmt2.fmt.pix.height = 10000;
+ fmt2.fmt.pix.pixelformat = desc2.pixelformat;
+ if (0 != SYS_IOCTL(fd, VIDIOC_TRY_FMT, &fmt2))
+ goto done;
+
+ *maxw = fmt2.fmt.pix.width;
+ *maxh = fmt2.fmt.pix.height;
+
+ done:
+ return 0;
+}
+
static int v4l1_set_format(int index, unsigned int width,
unsigned int height, int v4l1_pal, int width_height_may_differ)