aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDafna Hirschfeld <dafna.hirschfeld@collabora.com>2021-07-16 14:57:03 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-08-04 15:17:37 +0200
commit7952c0042ccf549959cf924fbd3e7dd894966e57 (patch)
tree5e4c8d38e889652767225469fc0685a7fbf895f1
parentac5c0dc4c24b5b956c3af58ccd1e524947610450 (diff)
downloadv4l-utils-7952c0042ccf549959cf924fbd3e7dd894966e57.tar.gz
v4l2-ctl: fix bugs found in streaming_set_cap2out
When exporting buffers from a capture device to an output device. There are several bugs: 1. The bytesused are set from the exported buffer, the value might be bigger than the length of the output buffer. 2. The file descriptor field 'm.fd' in 'struct v4l2_buffer' is not set. This patch fix those issues. Testing: modprobe vimc modprobe vivid //configure vimc pipeline media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d platform:vimc -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d platform:vimc -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]' v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=1920,height=1440 v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81 v4l2-ctl -z platform:vimc -d "Raw Capture 1" -v pixelformat=BA81 // export buffers from vimc capture device (/dev/video2) to vivid output device (/dev/video4) v4l2-ctl -d2 --stream-mmap --out-device /dev/video4 --stream-out-dmabuf Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-streaming.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 0f28a537..7e24e0ec 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1499,6 +1499,11 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
if (cap) {
buf.s_index(cap->g_index());
+ if (fd.querybuf(buf)) {
+ fprintf(stderr, "%s fd.querybuf failed\n", __func__);
+ return QUEUE_ERROR;
+ }
+
for (unsigned j = 0; j < buf.g_num_planes(); j++) {
unsigned data_offset = cap->g_data_offset(j);
@@ -1507,8 +1512,17 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
buf.s_bytesused(cap->g_bytesused(j) - data_offset, j);
buf.s_data_offset(0, j);
} else if (q.g_memory() == V4L2_MEMORY_DMABUF) {
- buf.s_bytesused(cap->g_bytesused(j), j);
+ __u32 bytesused = cap->g_bytesused(j);
+ /*
+ * bytesused comes from the exported cap buffer
+ * but the length of the out buffer might be smaller
+ * so take the smaller of the two
+ */
+ if (bytesused > buf.g_length(j))
+ bytesused = buf.g_length(j);
+ buf.s_bytesused(bytesused, j);
buf.s_data_offset(data_offset, j);
+ buf.s_fd(q.g_fd(buf.g_index(), j));
}
}
} else {