enumerate image formats

This commit is contained in:
tth 2019-07-27 04:03:57 +02:00
parent bba944e055
commit c74695d07e
3 changed files with 49 additions and 3 deletions

View File

@ -70,6 +70,19 @@ fprintf(FP, " capabilities 0x%X\n", ptr->capabilities);
pr_capabilities(ptr->capabilities); pr_capabilities(ptr->capabilities);
fprintf(FP, " device caps 0x%X\n", ptr->device_caps); fprintf(FP, " device caps 0x%X\n", ptr->device_caps);
return -1;
}
/* --------------------------------------------------------------------- */
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr)
{
fprintf(FP, "-- v4l2_fmtdesc, %-15s %p\n", txt, ptr);
fprintf(FP, " index %d\n", ptr->index);
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
fprintf(FP, " flags 0x%X\n", ptr->flags);
fprintf(FP, " description %s\n", ptr->description);
fprintf(FP, " pixel format 0x%X\n", ptr->pixelformat); /* FOURCC */
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

View File

@ -9,6 +9,7 @@ int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr);
int pr_v4l2_input(char *txt, struct v4l2_input *ptr); int pr_v4l2_input(char *txt, struct v4l2_input *ptr);
int pr_v4l2_format(char *txt, struct v4l2_format *ptr); int pr_v4l2_format(char *txt, struct v4l2_format *ptr);
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr); int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr);
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr);
char *str_input_type(int t); char *str_input_type(int t);
char *str_ctrl_type(int type); char *str_ctrl_type(int type);

View File

@ -19,6 +19,37 @@
int verbosity; int verbosity;
/* --------------------------------------------------------------------- */
int enum_image_formats(int fd, char *txt, int k)
{
int foo, idx;
struct v4l2_fmtdesc fmtd;
printf("-- image formats enumeration (%s)\n", txt);
idx = 0;
for (;;) {
memset(&fmtd, 0, sizeof(fmtd));
fmtd.index = idx;
fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
foo = ioctl(fd, VIDIOC_ENUM_FMT, &fmtd);
// fprintf(stderr, "B idx=%d, foo=%d, errno=%d\n", idx, foo, errno);
if (foo) {
if (EINVAL==errno) {
break;
}
else {
perror(__func__);
break;
}
}
pr_v4l2_fmtdesc(__func__, &fmtd);
idx++;
}
return -1;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static int enum_inputs(int fd, char *txt, int k) static int enum_inputs(int fd, char *txt, int k)
{ {
@ -124,7 +155,7 @@ while (0 == ioctl (fd, VIDIOC_QUERYCTRL, &qctrl)) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int show_webcam_infos(char *devname, int k) int show_webcam_infos(char *devname, char *title, int k)
{ {
int vfd, foo; int vfd, foo;
@ -162,8 +193,9 @@ if (-1 == ioctl(vfd, VIDIOC_ENUMINPUT, &input)) {
} }
pr_v4l2_input("input 0", &input); pr_v4l2_input("input 0", &input);
foo = enum_inputs(vfd, "is that working ?", 0); foo = enum_inputs(vfd, "on peut voir quoi ?", 0);
foo = enum_image_formats(vfd, "Experimental", 0);
fputs("--\n", stderr); fputs("--\n", stderr);
foo = enum_controls(vfd, "is that working ?", 0); foo = enum_controls(vfd, "is that working ?", 0);
@ -216,7 +248,7 @@ while ((opt = getopt(argc, argv, "d:hK:lv")) != -1) {
if (verbosity) fimg_print_version(0); if (verbosity) fimg_print_version(0);
foo = show_webcam_infos(device, K); foo = show_webcam_infos(device, "", K);
fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo); fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo);
return 0; return 0;