This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 02f608b64d27761a2c953bcfc398dc93f30f4ac8
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Dec 6 19:21:37 2022 +0800

    examples/camera: Call VIDIOC_S_FMT before VIDIOC_REQBUFS
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 examples/camera/camera_main.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/examples/camera/camera_main.c b/examples/camera/camera_main.c
index 024d68f13..e9c9f0bab 100644
--- a/examples/camera/camera_main.c
+++ b/examples/camera/camera_main.c
@@ -131,20 +131,6 @@ static int camera_prepare(int fd, enum v4l2_buf_type type,
     0
   };
 
-  /* VIDIOC_REQBUFS initiate user pointer I/O */
-
-  req.type   = type;
-  req.memory = V4L2_MEMORY_USERPTR;
-  req.count  = buffernum;
-  req.mode   = buf_mode;
-
-  ret = ioctl(fd, VIDIOC_REQBUFS, (unsigned long)&req);
-  if (ret < 0)
-    {
-      printf("Failed to VIDIOC_REQBUFS: errno = %d\n", errno);
-      return ret;
-    }
-
   /* VIDIOC_S_FMT set format */
 
   fmt.type                = type;
@@ -160,6 +146,20 @@ static int camera_prepare(int fd, enum v4l2_buf_type type,
       return ret;
     }
 
+  /* VIDIOC_REQBUFS initiate user pointer I/O */
+
+  req.type   = type;
+  req.memory = V4L2_MEMORY_USERPTR;
+  req.count  = buffernum;
+  req.mode   = buf_mode;
+
+  ret = ioctl(fd, VIDIOC_REQBUFS, (unsigned long)&req);
+  if (ret < 0)
+    {
+      printf("Failed to VIDIOC_REQBUFS: errno = %d\n", errno);
+      return ret;
+    }
+
   /* Prepare video memory to store images */
 
   *vbuf = malloc(sizeof(v_buffer_t) * buffernum);

Reply via email to