You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/12/08 11:39:03 UTC
[nuttx-apps] 02/04: examples/camera: Call VIDIOC_S_FMT before VIDIOC_REQBUFS
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 <xi...@xiaomi.com>
AuthorDate: Tue Dec 6 19:21:37 2022 +0800
examples/camera: Call VIDIOC_S_FMT before VIDIOC_REQBUFS
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
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);