The patch number 11003 was added via h...@rhel5-devel.localdomain to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward compatible with older kernels. Compatibility modifications will be removed before inclusion into the mainstream Kernel If anyone has any objections, please let us know by sending a message to: Linux Media Mailing List <linux-me...@vger.kernel.org> ------ From: Hans de Goede <hdego...@redhat.com> libv4l: 0.5.7 release * Fix a nasty (and stupid) bug in the special try_fmt handling for UVC cams * Add some more verbose logging of various calls when asking libv4l to log calls to a file, to assist in (future) debugging Priority: normal Signed-off-by: Hans de Goede <hdego...@redhat.com> --- v4l2-apps/libv4l/ChangeLog | 6 + v4l2-apps/libv4l/Makefile | 2 v4l2-apps/libv4l/libv4l2/libv4l2.c | 5 - v4l2-apps/libv4l/libv4l2/log.c | 71 ++++++++++++++++- v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c | 53 +++++++++++- 5 files changed, 127 insertions(+), 10 deletions(-) diff -r 819746003236 -r 7a76802a9780 v4l2-apps/libv4l/ChangeLog --- a/v4l2-apps/libv4l/ChangeLog Wed Mar 11 13:15:10 2009 +0100 +++ b/v4l2-apps/libv4l/ChangeLog Wed Mar 11 13:15:43 2009 +0100 @@ -1,3 +1,9 @@ libv4l-0.5.6 +libv4l-0.5.7 +------------ +* Fix a nasty (and stupid) bug in the special try_fmt handling for UVC cams +* Add some more verbose logging of various calls when asking libv4l to log + calls to a file, to assist in (future) debugging + libv4l-0.5.6 ------------ * Always do a s_fmt on uvc cams even if this changes nothing, as not doing diff -r 819746003236 -r 7a76802a9780 v4l2-apps/libv4l/Makefile --- a/v4l2-apps/libv4l/Makefile Wed Mar 11 13:15:10 2009 +0100 +++ b/v4l2-apps/libv4l/Makefile Wed Mar 11 13:15:43 2009 +0100 @@ -1,5 +1,5 @@ LIB_RELEASE=0 LIB_RELEASE=0 -V4L2_LIB_VERSION=$(LIB_RELEASE).5.6 +V4L2_LIB_VERSION=$(LIB_RELEASE).5.7 all clean install: $(MAKE) -C libv4lconvert V4L2_LIB_VERSION=$(V4L2_LIB_VERSION) $@ diff -r 819746003236 -r 7a76802a9780 v4l2-apps/libv4l/libv4l2/libv4l2.c --- a/v4l2-apps/libv4l/libv4l2/libv4l2.c Wed Mar 11 13:15:10 2009 +0100 +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c Wed Mar 11 13:15:43 2009 +0100 @@ -760,6 +760,9 @@ int v4l2_ioctl (int fd, unsigned long in case VIDIOC_ENUM_FRAMEINTERVALS: result = v4lconvert_enum_frameintervals(devices[index].convert, arg); + if (result) + V4L2_LOG("ENUM_FRAMEINTERVALS Error: %s", + v4lconvert_get_error_message(devices[index].convert)); break; case VIDIOC_TRY_FMT: @@ -949,7 +952,7 @@ int v4l2_ioctl (int fd, unsigned long in but we need the buffer _now_ to write our converted data to it! */ if (devices[index].convert_mmap_buf == MAP_FAILED) { - devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, + devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, NULL, (size_t)( devices[index].no_frames * V4L2_FRAME_BUF_SIZE), diff -r 819746003236 -r 7a76802a9780 v4l2-apps/libv4l/libv4l2/log.c --- a/v4l2-apps/libv4l/libv4l2/log.c Wed Mar 11 13:15:10 2009 +0100 +++ b/v4l2-apps/libv4l/libv4l2/log.c Wed Mar 11 13:15:43 2009 +0100 @@ -91,6 +91,10 @@ static const char *v4l2_ioctls[] = { [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS", +#ifdef VIDIOC_ENUM_FRAMESIZES + [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES", + [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS", +#endif }; void v4l2_log_ioctl(unsigned long int request, void *arg, int result) @@ -105,7 +109,7 @@ void v4l2_log_ioctl(unsigned long int re if (_IOC_TYPE(request) == 'V' && _IOC_NR(request) < ARRAY_SIZE(v4l2_ioctls)) ioctl_str = v4l2_ioctls[_IOC_NR(request)]; else { - snprintf(buf, sizeof(buf), "unknown request: %c %d\n", + snprintf(buf, sizeof(buf), "unknown request: %c %d", (int)_IOC_TYPE(request), (int)_IOC_NR(request)); ioctl_str = buf; } @@ -113,11 +117,18 @@ void v4l2_log_ioctl(unsigned long int re fprintf(v4l2_log_file, "request == %s\n", ioctl_str); switch (request) { + case VIDIOC_ENUM_FMT: + { + struct v4l2_fmtdesc *fmt = arg; + fprintf(v4l2_log_file, " index: %u, description: %s\n", + fmt->index, (result < 0) ? "" : fmt->description); + } + break; case VIDIOC_G_FMT: case VIDIOC_S_FMT: case VIDIOC_TRY_FMT: { - struct v4l2_format* fmt = arg; + struct v4l2_format *fmt = arg; int pixfmt = fmt->fmt.pix.pixelformat; if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { @@ -144,6 +155,62 @@ void v4l2_log_ioctl(unsigned long int re req->count, (int)req->type, (int)req->memory); } break; +#ifdef VIDIOC_ENUM_FRAMESIZES + case VIDIOC_ENUM_FRAMESIZES: + { + struct v4l2_frmsizeenum *frmsize = arg; + int pixfmt = frmsize->pixel_format; + + fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c", + frmsize->index, + pixfmt & 0xff, + (pixfmt >> 8) & 0xff, + (pixfmt >> 16) & 0xff, + pixfmt >> 24); + switch (frmsize->type) { + case V4L2_FRMSIZE_TYPE_DISCRETE: + fprintf(v4l2_log_file, " %ux%u\n", frmsize->discrete.width, + frmsize->discrete.height); + break; + case V4L2_FRMSIZE_TYPE_CONTINUOUS: + case V4L2_FRMSIZE_TYPE_STEPWISE: + fprintf(v4l2_log_file, " %ux%u -> %ux%u\n", + frmsize->stepwise.min_width, frmsize->stepwise.min_height, + frmsize->stepwise.max_width, frmsize->stepwise.max_height); + break; + } + } + break; + case VIDIOC_ENUM_FRAMEINTERVALS: + { + struct v4l2_frmivalenum *frmival = arg; + int pixfmt = frmival->pixel_format; + + fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c %ux%u: ", + frmival->index, + pixfmt & 0xff, + (pixfmt >> 8) & 0xff, + (pixfmt >> 16) & 0xff, + pixfmt >> 24, + frmival->width, + frmival->height); + switch (frmival->type) { + case V4L2_FRMIVAL_TYPE_DISCRETE: + fprintf(v4l2_log_file, "%u/%u\n", frmival->discrete.numerator, + frmival->discrete.denominator); + break; + case V4L2_FRMIVAL_TYPE_CONTINUOUS: + case V4L2_FRMIVAL_TYPE_STEPWISE: + fprintf(v4l2_log_file, "%u/%u -> %u/%u\n", + frmival->stepwise.min.numerator, + frmival->stepwise.min.denominator, + frmival->stepwise.max.numerator, + frmival->stepwise.max.denominator); + break; + } + } + break; +#endif } if (result < 0) diff -r 819746003236 -r 7a76802a9780 v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c --- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c Wed Mar 11 13:15:10 2009 +0100 +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c Wed Mar 11 13:15:43 2009 +0100 @@ -209,8 +209,11 @@ static int v4lconvert_do_try_format_uvc( data->framesizes[i].discrete.height; unsigned int size_diff = size_x_diff * size_x_diff + size_y_diff * size_y_diff; - if (size_diff < closest_fmt_size_diff) + + if (size_diff < closest_fmt_size_diff) { + closest_fmt_size_diff = size_diff; best_framesize = i; + } } } @@ -452,7 +455,7 @@ static int v4lconvert_convert_pixfmt(str /* Check for (pixart) rotated JPEG */ if (header_width == height && header_height == width) { if (!(data->flags & V4LCONVERT_ROTATE_90)) { - V4LCONVERT_ERR("JPEG needs 90 degree rotation"); + V4LCONVERT_ERR("JPEG needs 90 degree rotation\n"); data->flags |= V4LCONVERT_ROTATE_90; errno = EAGAIN; return -1; @@ -497,7 +500,7 @@ static int v4lconvert_convert_pixfmt(str the upper layer this is an intermediate fault and it should try again with a new buffer by setting errno to EAGAIN */ if (src_pix_fmt == V4L2_PIX_FMT_PJPG) { - V4LCONVERT_ERR("Error decompressing JPEG: %s", + V4LCONVERT_ERR("decompressing JPEG: %s", tinyjpeg_get_errorstring(data->jdec)); errno = EAGAIN; return -1; @@ -923,8 +926,12 @@ int v4lconvert_enum_frameintervals(struc int res; struct v4l2_format src_fmt, dest_fmt; - if (!v4lconvert_supported_dst_format(frmival->pixel_format)) - return syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival); + if (!v4lconvert_supported_dst_format(frmival->pixel_format)) { + res = syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival); + if (res) + V4LCONVERT_ERR("%s\n", strerror(errno)); + return res; + } /* Check which format we will be using to convert to frmival->pixel_format */ memset(&dest_fmt, 0, sizeof(dest_fmt)); @@ -932,13 +939,30 @@ int v4lconvert_enum_frameintervals(struc dest_fmt.fmt.pix.pixelformat = frmival->pixel_format; dest_fmt.fmt.pix.width = frmival->width; dest_fmt.fmt.pix.height = frmival->height; - if ((res = v4lconvert_try_format(data, &dest_fmt, &src_fmt))) + if ((res = v4lconvert_try_format(data, &dest_fmt, &src_fmt))) { + if (res) + V4LCONVERT_ERR("trying format: %s\n", strerror(errno)); return res; + } /* Check the requested format is supported exactly as requested */ if (dest_fmt.fmt.pix.pixelformat != frmival->pixel_format || dest_fmt.fmt.pix.width != frmival->width || dest_fmt.fmt.pix.height != frmival->height) { + int frmival_pixformat = frmival->pixel_format; + int dest_pixformat = dest_fmt.fmt.pix.pixelformat; + V4LCONVERT_ERR("Could not find matching framesize for: %c%c%c%c %dx%d " + "closest match: %c%c%c%c %dx%d\n", + frmival_pixformat & 0xff, + (frmival_pixformat >> 8) & 0xff, + (frmival_pixformat >> 16) & 0xff, + frmival_pixformat >> 24, + frmival->width, frmival->height, + dest_pixformat & 0xff, + (dest_pixformat >> 8) & 0xff, + (dest_pixformat >> 16) & 0xff, + dest_pixformat >> 24, + dest_fmt.fmt.pix.width , dest_fmt.fmt.pix.height); errno = EINVAL; return -1; } @@ -948,6 +972,23 @@ int v4lconvert_enum_frameintervals(struc frmival->width = src_fmt.fmt.pix.width; frmival->height = src_fmt.fmt.pix.height; res = syscall(SYS_ioctl, data->fd, VIDIOC_ENUM_FRAMEINTERVALS, frmival); + if (res) { + int dest_pixfmt = dest_fmt.fmt.pix.pixelformat; + int src_pixfmt = src_fmt.fmt.pix.pixelformat; + V4LCONVERT_ERR("Could not enum frameival index: %d for: %c%c%c%c %dx%d " + "using src: %c%c%c%c %dx%d, error: %s\n", + frmival->index, + dest_pixfmt & 0xff, + (dest_pixfmt >> 8) & 0xff, + (dest_pixfmt >> 16) & 0xff, + dest_pixfmt >> 24, + dest_fmt.fmt.pix.width , dest_fmt.fmt.pix.height, + src_pixfmt & 0xff, + (src_pixfmt >> 8) & 0xff, + (src_pixfmt >> 16) & 0xff, + src_pixfmt >> 24, + src_fmt.fmt.pix.width, src_fmt.fmt.pix.height, strerror(errno)); + } /* Restore the requested format in the frmival struct */ frmival->pixel_format = dest_fmt.fmt.pix.pixelformat; --- Patch is available at: http://linuxtv.org/hg/v4l-dvb/rev/7a76802a9780ebbdfaf722808a65d82fb23562e3 _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits