From f62a7a8cd7c03f7694ea5260ac38b1f2cf7826d5 Mon Sep 17 00:00:00 2001 From: "hans@rhel5-devel.localdomain" Date: Wed, 17 Jun 2009 15:38:46 +0200 Subject: libv4l: Report aligned resolution on first get_fmt From: Hans de Goede 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 --- v4l2-apps/libv4l/libv4l2/libv4l2.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/libv4l') 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; } -- cgit v1.2.3