|
29 | 29 | #include <arvv4l2deviceprivate.h>
|
30 | 30 | #include <arvinterfaceprivate.h>
|
31 | 31 | #include <arvv4l2device.h>
|
32 |
| -#include <arvdebug.h> |
| 32 | +#include <arvdebugprivate.h> |
33 | 33 | #include <gudev/gudev.h>
|
34 | 34 | #include <libv4l2.h>
|
35 | 35 | #include <linux/videodev2.h>
|
@@ -75,22 +75,46 @@ arv_v4l2_interface_device_infos_new (const char *device_file, const char *name)
|
75 | 75 | if (v4l2_ioctl (fd, VIDIOC_QUERYCAP, &cap) != -1 &&
|
76 | 76 | ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) != 0) &&
|
77 | 77 | ((cap.capabilities & V4L2_CAP_STREAMING) != 0)) {
|
78 |
| - infos = g_new0 (ArvV4l2InterfaceDeviceInfos, 1); |
79 |
| - |
80 |
| - infos->ref_count = 1; |
81 |
| - infos->id = g_strdup_printf ("%s-%s", (char *) cap.card, name); |
82 |
| - infos->bus = g_strdup ((char *) cap.bus_info); |
83 |
| - infos->device_file = g_strdup (device_file); |
84 |
| - infos->version = g_strdup_printf ("%d.%d.%d", |
85 |
| - (cap.version >> 16) & 0xff, |
86 |
| - (cap.version >> 8) & 0xff, |
87 |
| - (cap.version >> 0) & 0xff); |
88 |
| - |
89 |
| - return infos; |
90 |
| - } |
91 |
| - v4l2_close (fd); |
92 |
| - } |
93 |
| - } |
| 78 | + unsigned int i; |
| 79 | + gboolean found = FALSE; |
| 80 | + |
| 81 | + for (i = 0; TRUE; i++) { |
| 82 | + struct v4l2_fmtdesc format = {0}; |
| 83 | + |
| 84 | + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 85 | + format.index = i; |
| 86 | + if (v4l2_ioctl(fd, VIDIOC_ENUM_FMT, &format) == -1) |
| 87 | + break; |
| 88 | + |
| 89 | + if (arv_pixel_format_from_v4l2(format.pixelformat) != 0) { |
| 90 | + found = TRUE; |
| 91 | + break; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + if (found) { |
| 96 | + infos = g_new0 (ArvV4l2InterfaceDeviceInfos, 1); |
| 97 | + |
| 98 | + infos->ref_count = 1; |
| 99 | + infos->id = g_strdup_printf ("%s-%s", (char *) cap.card, name); |
| 100 | + infos->bus = g_strdup ((char *) cap.bus_info); |
| 101 | + infos->device_file = g_strdup (device_file); |
| 102 | + infos->version = g_strdup_printf ("%d.%d.%d", |
| 103 | + (cap.version >> 16) & 0xff, |
| 104 | + (cap.version >> 8) & 0xff, |
| 105 | + (cap.version >> 0) & 0xff); |
| 106 | + |
| 107 | + v4l2_close (fd); |
| 108 | + |
| 109 | + return infos; |
| 110 | + } |
| 111 | + |
| 112 | + arv_warning_interface ("No suitable pixel format found for v4l2 device '%s'", |
| 113 | + device_file); |
| 114 | + } |
| 115 | + v4l2_close (fd); |
| 116 | + } |
| 117 | + } |
94 | 118 |
|
95 | 119 | return NULL;
|
96 | 120 | }
|
|
0 commit comments