28 #include <linux/videodev2.h>
29 #include <sys/ioctl.h>
34 struct v4l2_fmtdesc fmtd;
40 memset(&fmtd, 0,
sizeof(
struct v4l2_fmtdesc));
41 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
44 while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtd) >= 0) {
46 "%d - %s (compressed : %d) (%#x)",
59 struct v4l2_format fmt;
60 struct v4l2_fmtdesc fmtd;
62 memset(&fmt, 0,
sizeof(
struct v4l2_format));
63 fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
64 memset(&fmtd, 0,
sizeof(
struct v4l2_fmtdesc));
66 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
72 if (-1 == ioctl(fd, VIDIOC_G_FMT, &fmt)) {
73 yCError(
USBCAMERA,
"Failed to get image format: %d, %s", errno, strerror(errno));
77 yCInfo(
USBCAMERA,
"Current bytes per line: %d", fmt.fmt.pix.bytesperline);
81 while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtd) >= 0) {
82 if (fmt.fmt.pix.pixelformat == fmtd.pixelformat) {
95 struct v4l2_input vin;
96 struct v4l2_tuner tun;
97 struct v4l2_frequency freq;
99 memset(&vin, 0,
sizeof(
struct v4l2_input));
106 while (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) {
110 if (vin.type & V4L2_INPUT_TYPE_TUNER) {
113 memset(&tun, 0,
sizeof(
struct v4l2_tuner));
114 tun.index = vin.tuner;
115 if (ioctl(fd, VIDIOC_G_TUNER, &tun) == 0) {
117 if (tun.type == V4L2_TUNER_RADIO) {
120 if (tun.type == V4L2_TUNER_ANALOG_TV) {
123 if (tun.capability & V4L2_TUNER_CAP_LOW) {
129 if (tun.capability & V4L2_TUNER_CAP_NORM) {
132 if (tun.capability & V4L2_TUNER_CAP_STEREO) {
137 "lowest tunable frequency: %.2f %s",
139 (tun.capability & V4L2_TUNER_CAP_LOW) ?
"Hz" :
"kHz");
141 "highest tunable frequency: %.2f %s",
142 tun.rangehigh * 62.5,
143 (tun.capability & V4L2_TUNER_CAP_LOW) ?
"Hz" :
"kHz");
144 memset(&freq, 0,
sizeof(
struct v4l2_frequency));
145 freq.tuner = vin.tuner;
146 if (ioctl(fd, VIDIOC_G_FREQUENCY, &freq) == 0) {
148 "Current frequency: %.2f %s",
149 freq.frequency * 62.5,
150 (tun.capability & V4L2_TUNER_CAP_LOW) ?
"Hz" :
"kHz");
154 if (vin.type & V4L2_INPUT_TYPE_CAMERA) {
158 if (vin.std & V4L2_STD_PAL) {
161 if (vin.std & V4L2_STD_NTSC) {
164 if (vin.std & V4L2_STD_SECAM) {
174 struct v4l2_frmsizeenum frms;
175 struct v4l2_fmtdesc fmtd;
177 memset(&frms, 0,
sizeof(
struct v4l2_frmsizeenum));
178 memset(&fmtd, 0,
sizeof(
struct v4l2_fmtdesc));
179 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
187 while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtd) >= 0) {
190 frms.pixel_format = fmtd.pixelformat;
191 while (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frms) >= 0) {
192 if (frms.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
194 "index %2d: Width: %4d - Height: %d",
197 frms.discrete.height);
201 "index %2d\tMin, max & step height: %d - %d - %d Min, max & step width: %d - %d - %d",
203 frms.stepwise.min_height,
204 frms.stepwise.max_height,
205 frms.stepwise.step_height,
206 frms.stepwise.min_width,
207 frms.stepwise.max_width,
208 frms.stepwise.step_width);
219 "Control: id: 0x%x - name: %s - min: %d -max: %d - step: %d - type: %d(%s) - flags: %d (%s%s%s%s%s%s)",
226 (qc->type == V4L2_CTRL_TYPE_INTEGER ?
"Integer" :
227 qc->type == V4L2_CTRL_TYPE_BOOLEAN ?
"Boolean" :
228 qc->type == V4L2_CTRL_TYPE_MENU ?
"Menu" :
229 qc->type == V4L2_CTRL_TYPE_BUTTON ?
"Button" :
230 qc->type == V4L2_CTRL_TYPE_INTEGER64 ?
"Integer64" :
231 qc->type == V4L2_CTRL_TYPE_CTRL_CLASS ?
"Class" :
234 qc->flags & V4L2_CTRL_FLAG_DISABLED ?
"Disabled " :
"",
235 qc->flags & V4L2_CTRL_FLAG_GRABBED ?
"Grabbed " :
"",
236 qc->flags & V4L2_CTRL_FLAG_READ_ONLY ?
"ReadOnly " :
"",
237 qc->flags & V4L2_CTRL_FLAG_UPDATE ?
"Update " :
"",
238 qc->flags & V4L2_CTRL_FLAG_INACTIVE ?
"Inactive " :
"",
239 qc->flags & V4L2_CTRL_FLAG_SLIDER ?
"slider " :
"");
293 struct v4l2_capability cap;
299 if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) {
308 (cap.version >> 16) & 0xFF,
309 (cap.version >> 8) & 0xFF,
312 yCInfo(
USBCAMERA,
"%s capture capability", (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) ?
"Has" :
"Does NOT have");
313 yCInfo(
USBCAMERA,
"%s output capability", (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) ?
"Has" :
"Does NOT have");
314 yCInfo(
USBCAMERA,
"%s overlay capability", (cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) ?
"Has" :
"Does NOT have");
315 yCInfo(
USBCAMERA,
"%s VBI capture capability", (cap.capabilities & V4L2_CAP_VBI_CAPTURE) ?
"Has" :
"Does NOT have");
316 yCInfo(
USBCAMERA,
"%s VBI output capability", (cap.capabilities & V4L2_CAP_VBI_OUTPUT) ?
"Has" :
"Does NOT have");
317 yCInfo(
USBCAMERA,
"%s SLICED VBI capture capability", (cap.capabilities & V4L2_CAP_SLICED_VBI_CAPTURE) ?
"Has" :
"Does NOT have");
318 yCInfo(
USBCAMERA,
"%s SLICED VBI output capability", (cap.capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) ?
"Has" :
"Does NOT have");
319 yCInfo(
USBCAMERA,
"%s RDS capability", (cap.capabilities & V4L2_CAP_RDS_CAPTURE) ?
"Has" :
"Does NOT have");
320 yCInfo(
USBCAMERA,
"%s tuner capability", (cap.capabilities & V4L2_CAP_TUNER) ?
"Has" :
"Does NOT have");
321 yCInfo(
USBCAMERA,
"%s audio capability", (cap.capabilities & V4L2_CAP_AUDIO) ?
"Has" :
"Does NOT have");
322 yCInfo(
USBCAMERA,
"%s radio capability", (cap.capabilities & V4L2_CAP_RADIO) ?
"Has" :
"Does NOT have");
323 yCInfo(
USBCAMERA,
"%s read/write capability", (cap.capabilities & V4L2_CAP_READWRITE) ?
"Has" :
"Does NOT have");
324 yCInfo(
USBCAMERA,
"%s async IO capability", (cap.capabilities & V4L2_CAP_ASYNCIO) ?
"Has" :
"Does NOT have");
325 yCInfo(
USBCAMERA,
"%s streaming capability", (cap.capabilities & V4L2_CAP_STREAMING) ?
"Has" :
"Does NOT have");
328 if (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) {