summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-06-17 15:38:46 +0200
committerhans@rhel5-devel.localdomain <hans@rhel5-devel.localdomain>2009-06-17 15:38:46 +0200
commitf62a7a8cd7c03f7694ea5260ac38b1f2cf7826d5 (patch)
treeb067b4c624727f182051d10d0e7c34b248976d14
parent7a7d2c3791928d88ef83f28a7d1fd3095f0bb459 (diff)
downloadmediapointer-dvb-s2-f62a7a8cd7c03f7694ea5260ac38b1f2cf7826d5.tar.gz
mediapointer-dvb-s2-f62a7a8cd7c03f7694ea5260ac38b1f2cf7826d5.tar.bz2
libv4l: Report aligned resolution on first get_fmt
From: Hans de Goede <hdegoede@redhat.com> When a user does a try_fmt with the current dest_fmt and the dest_fmt is a supported one we will align the resulution (see try_fmt for why). Do the on the result of the first get_fmt, so that a try_fmt on the result of a get_fmt done immediately after open leaves the fmt unchanged Priority: normal Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--v4l2-apps/libv4l/libv4l2/libv4l2.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c
index a12b41c2c..36fb8e21e 100644
--- a/v4l2-apps/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c
@@ -507,6 +507,16 @@ int v4l2_fd_open(int fd, int v4l2_flags)
devices[index].src_fmt = fmt;
devices[index].dest_fmt = fmt;
+ /* When a user does a try_fmt with the current dest_fmt and the dest_fmt
+ is a supported one we will align the resulution (see try_fmt for why).
+ Do the same here now, so that a try_fmt on the result of a get_fmt done
+ immediately after open leaves the fmt unchanged. */
+ if (v4lconvert_supported_dst_format(
+ devices[index].dest_fmt.fmt.pix.pixelformat)) {
+ devices[index].dest_fmt.fmt.pix.width &= ~7;
+ devices[index].dest_fmt.fmt.pix.height &= ~1;
+ }
+
pthread_mutex_init(&devices[index].stream_lock, NULL);
devices[index].no_frames = 0;
@@ -748,6 +758,7 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
if (stream_needs_locking) {
+ pthread_mutex_lock(&devices[index].stream_lock);
/* If this is the first stream related ioctl, and we should only allow
libv4lconvert supported destination formats (so that it can do flipping,
processing, etc.) and the current destination format is not supported,
@@ -765,7 +776,6 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt);
V4L2_LOG("Done setting pixelformat (supported_dst_fmt_only)");
}
- pthread_mutex_lock(&devices[index].stream_lock);
devices[index].flags |= V4L2_STREAM_TOUCHED;
}