diff mbox

[1/3] libv4l2: Fix restoring of original dest-fmt after a VIDIOC_S_DV_TIMING

Message ID 1412085901-18528-1-git-send-email-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans de Goede Sept. 30, 2014, 2:04 p.m. UTC
Read the original pixelformat from dest_fmt, before overwriting dest_fmt with
the new src_fmt.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 lib/libv4l2/libv4l2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index fe513d7..22ed984 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -1245,6 +1245,8 @@  no_capture_request:
 	case VIDIOC_S_INPUT:
 	case VIDIOC_S_DV_TIMINGS: {
 		struct v4l2_format src_fmt = { 0 };
+		unsigned int orig_dest_pixelformat =
+			devices[index].dest_fmt.fmt.pix.pixelformat;
 
 		result = devices[index].dev_ops->ioctl(
 				devices[index].dev_ops_priv,
@@ -1274,8 +1276,7 @@  no_capture_request:
 		devices[index].src_fmt  = src_fmt;
 		devices[index].dest_fmt = src_fmt;
 		/* and try to restore the last set destination pixelformat. */
-		src_fmt.fmt.pix.pixelformat =
-			devices[index].dest_fmt.fmt.pix.pixelformat;
+		src_fmt.fmt.pix.pixelformat = orig_dest_pixelformat;
 		result = v4l2_s_fmt(index, &src_fmt);
 		if (result) {
 			V4L2_LOG_WARN("restoring destination pixelformat after %s failed\n",