diff --git a/v4l2/v4l2_pr_structs.c b/v4l2/v4l2_pr_structs.c index c40faa5..d587798 100644 --- a/v4l2/v4l2_pr_structs.c +++ b/v4l2/v4l2_pr_structs.c @@ -70,6 +70,19 @@ fprintf(FP, " capabilities 0x%X\n", ptr->capabilities); pr_capabilities(ptr->capabilities); 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; } /* --------------------------------------------------------------------- */ diff --git a/v4l2/v4l2_pr_structs.h b/v4l2/v4l2_pr_structs.h index f1616eb..7641387 100644 --- a/v4l2/v4l2_pr_structs.h +++ b/v4l2/v4l2_pr_structs.h @@ -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_format(char *txt, struct v4l2_format *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_ctrl_type(int type); diff --git a/v4l2/video-infos.c b/v4l2/video-infos.c index 7533d81..f910481 100644 --- a/v4l2/video-infos.c +++ b/v4l2/video-infos.c @@ -19,6 +19,37 @@ 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) { @@ -124,7 +155,7 @@ while (0 == ioctl (fd, VIDIOC_QUERYCTRL, &qctrl)) { return -1; } /* --------------------------------------------------------------------- */ -int show_webcam_infos(char *devname, int k) +int show_webcam_infos(char *devname, char *title, int k) { int vfd, foo; @@ -162,8 +193,9 @@ if (-1 == ioctl(vfd, VIDIOC_ENUMINPUT, &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); 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); -foo = show_webcam_infos(device, K); +foo = show_webcam_infos(device, "", K); fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo); return 0;