summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:07:44 +0100
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-03-11 13:07:44 +0100
commita5d0ef3556720bdb676c2c752b27e02be2d7e869 (patch)
tree971bed138cbf1370a6fe5aba0b5a82d15ed44be3 /v4l2-apps/libv4l
parent20b5011195e9b98e0cd6904e7a82d735ee542a52 (diff)
downloadmediapointer-dvb-s2-a5d0ef3556720bdb676c2c752b27e02be2d7e869.tar.gz
mediapointer-dvb-s2-a5d0ef3556720bdb676c2c752b27e02be2d7e869.tar.bz2
libv4l: make s_fmt more robust part 2
From: Hans de Goede <hdegoede@redhat.com> Check that s_fmt atleast gives us the width, height and pixelformat try_fmt promised us, and if not disable conversion Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'v4l2-apps/libv4l')
-rw-r--r--v4l2-apps/libv4l/ChangeLog2
-rw-r--r--v4l2-apps/libv4l/libv4l2/libv4l2.c11
2 files changed, 13 insertions, 0 deletions
diff --git a/v4l2-apps/libv4l/ChangeLog b/v4l2-apps/libv4l/ChangeLog
index 509e64a62..04d9931b5 100644
--- a/v4l2-apps/libv4l/ChangeLog
+++ b/v4l2-apps/libv4l/ChangeLog
@@ -4,6 +4,8 @@ libv4l-0.5.2
Rieker Flaik
* Work around some drivers (pwc) not properly reflecting what one gets after a
s_fmt in their try_fmt answer
+* Check that s_fmt atleast gives us the width, height and pixelformat try_fmt
+ promised us, and if not disable conversion
libv4l-0.5.1
------------
diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c
index dd422ea34..d60ed6d39 100644
--- a/v4l2-apps/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c
@@ -764,6 +764,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
case VIDIOC_S_FMT:
{
struct v4l2_format src_fmt, *dest_fmt = arg;
+ struct v4l2_pix_format req_pix_fmt;
if (v4l2_pix_fmt_identical(&devices[index].dest_fmt, dest_fmt)) {
*dest_fmt = devices[index].dest_fmt;
@@ -816,6 +817,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
if ((result = v4l2_check_buffer_change_ok(index)))
break;
+ req_pix_fmt = src_fmt.fmt.pix;
result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_S_FMT, &src_fmt);
if (result) {
saved_err = errno;
@@ -825,6 +827,15 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
errno = saved_err;
break;
}
+ /* See if we've gotten what try_fmt promised us
+ (this check should never fail) */
+ if (src_fmt.fmt.pix.width != req_pix_fmt.width ||
+ src_fmt.fmt.pix.height != req_pix_fmt.height ||
+ src_fmt.fmt.pix.pixelformat != req_pix_fmt.pixelformat) {
+ V4L2_LOG_ERR("set_fmt gave us a different result then try_fmt!\n");
+ /* Not what we expected / wanted, disable conversion */
+ *dest_fmt = src_fmt;
+ }
v4l2_set_src_and_dest_format(index, &src_fmt, dest_fmt);
}