Read the original pixelformat from dest_fmt, before overwriting dest_fmt with
the new src_fmt.

Signed-off-by: Hans de Goede <[email protected]>
---
 lib/libv4l2/libv4l2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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",
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to