diff --git a/v4l2/t.c b/v4l2/t.c index cabc1eb..6e6618d 100644 --- a/v4l2/t.c +++ b/v4l2/t.c @@ -29,32 +29,21 @@ struct v4l2_requestbuffers reqbuf; fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, dev, k); vfd = open_device(dev); -fprintf(stderr, "\topen %s -> %d\n", dev, vfd); +if (verbosity) fprintf(stderr, "\topen %s -> %d\n", dev, vfd); memset(&fmt, 0, sizeof(fmt)); -pr_v4l2_format("after 0", &fmt); - fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -fmt.fmt.pix.width = 640; -fmt.fmt.pix.height = 480; -fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; -fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; +// pr_v4l2_format("before ioctl", &fmt); -pr_v4l2_format("before ioctl", &fmt); - -foo = ioctl(vfd, VIDIOC_S_FMT, &fmt); +foo = ioctl(vfd, VIDIOC_G_FMT, &fmt); fprintf(stderr, "ioctl -> %d\n", foo); -if (foo < 0) { +if (0 != foo) { perror("ioctl S_FMT"); exit(1); } pr_v4l2_format("after ioctl", &fmt); -/* todo V4L2_BUF_TYPE_VIDEO_CAPTURE */ -memset(&reqbuf, 0, sizeof(reqbuf)); -pr_v4l2_requestbuffers("after 0", &reqbuf); - return k; } diff --git a/v4l2/v4l2_pr_structs.c b/v4l2/v4l2_pr_structs.c index efda876..ce6071e 100644 --- a/v4l2/v4l2_pr_structs.c +++ b/v4l2/v4l2_pr_structs.c @@ -18,13 +18,13 @@ static char *fmttype2str(int type) switch(type) { case 0: return "[zero]"; - case 1: return "video capture"; - case 2: return "video output"; + case V4L2_BUF_TYPE_VIDEO_CAPTURE: return "video capture"; + case V4L2_BUF_TYPE_VIDEO_OUTPUT: return "video output"; case 13: return "META capture"; } -return "???"; +return "XXX"; } /* --------------------------------------------------------------------- */ static void pr_capabilities(uint32_t caps) @@ -198,18 +198,25 @@ return -1; int pr_v4l2_format(char *txt, struct v4l2_format *ptr) { fprintf(FP, "-- v4l2_format, %-15s %p\n", txt, ptr); -fprintf(FP, " type %d %s\n", ptr->type,/* enum v4l2_buf_type */ +fprintf(FP, " type %d %s\n", ptr->type,/* enum v4l2_buf_type */ fmttype2str(ptr->type)); switch(ptr->type) { - case 1: // fputs(" Capture\n", FP); - fprintf(FP, " dims %dx%d\n", - ptr->fmt.pix.width, - ptr->fmt.pix.height); - break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + fprintf(FP, " dims %dx%d\n", + ptr->fmt.pix.width, + ptr->fmt.pix.height); + fprintf(FP, " pixformat %s\n", + str_fourcc(ptr->fmt.pix.pixelformat)); + fprintf(FP, " field %d\n", + ptr->fmt.pix.field); /* enum v4l2_field */ + fprintf(FP, " padding %d\n", + ptr->fmt.pix.bytesperline); - default: fprintf(FP, "type is %d\n", ptr->type); + break; + + default: fprintf(FP, "XXX type %d unknow\n", ptr->type); break; } diff --git a/v4l2/video-infos.c b/v4l2/video-infos.c index 99385b7..a2b6333 100644 --- a/v4l2/video-infos.c +++ b/v4l2/video-infos.c @@ -161,7 +161,8 @@ return -1; /* --------------------------------------------------------------------- */ int show_webcam_infos(char *devname, char *title, int k) { -int vfd, foo; +int vfd, foo; +char ligne[100]; struct v4l2_capability cap; // struct v4l2_format fmt; @@ -191,11 +192,13 @@ if (foo < 0) { pr_v4l2_capability(devname, &cap); memset(&input, 0, sizeof(input)); +input.index = 1; if (-1 == ioctl(vfd, VIDIOC_ENUMINPUT, &input)) { perror("VIDIOC_ENUMINPUT"); exit(EXIT_FAILURE); } -pr_v4l2_input("input 0", &input); +sprintf(ligne, "input %d", input.index); +pr_v4l2_input(ligne, &input); foo = enum_inputs(vfd, "on peut voir quoi ?", 0);