All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch v4l-utils 0/2] Fix bugs found with dmabuf
@ 2021-07-16 12:57 ` Dafna Hirschfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

1. first patch improve debugging
2. second patch fixes some bugs found when exporting buffers
from capture device to output device


Dafna Hirschfeld (2):
  v4l2-ctl: print specific error upon failure
  v4l2-ctl: fix bugs found in streaming_set_cap2out

 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 40 +++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 6 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch v4l-utils 0/2] Fix bugs found with dmabuf
@ 2021-07-16 12:57 ` Dafna Hirschfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

1. first patch improve debugging
2. second patch fixes some bugs found when exporting buffers
from capture device to output device


Dafna Hirschfeld (2):
  v4l2-ctl: print specific error upon failure
  v4l2-ctl: fix bugs found in streaming_set_cap2out

 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 40 +++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 6 deletions(-)

-- 
2.17.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch v4l-utils 1/2] v4l2-ctl: print specific error upon failure
  2021-07-16 12:57 ` Dafna Hirschfeld
@ 2021-07-16 12:57   ` Dafna Hirschfeld
  -1 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

When an operation fails, print an error message
that specify the specific operation that failed
prefixed with the current function name.
This makes debugging less painful.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 62424e4c..0f28a537 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1153,8 +1153,10 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
 			q.g_type() == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 	bool is_meta = q.g_type() == V4L2_BUF_TYPE_META_OUTPUT;
 
-	if (q.obtain_bufs(&fd))
+	if (q.obtain_bufs(&fd)) {
+		fprintf(stderr, "%s q.obtain_bufs failed\n", __func__);
 		return QUEUE_ERROR;
+	}
 
 	fd.g_fmt(fmt, q.g_type());
 	{
@@ -1226,8 +1228,10 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
 	for (unsigned i = 0; i < q.g_buffers(); i++) {
 		cv4l_buffer buf(q);
 
-		if (fd.querybuf(buf, i))
+		if (fd.querybuf(buf, i)) {
+			fprintf(stderr, "%s fd.querybuf failed\n", __func__);
 			return QUEUE_ERROR;
+		}
 
 		buf.update(q, i);
 		for (unsigned j = 0; j < q.g_num_planes(); j++)
@@ -2720,11 +2724,21 @@ static void streaming_set_cap2out(cv4l_fd &fd, cv4l_fd &out_fd)
 		fprintf(stderr, "mismatch between number of planes\n");
 		goto done;
 	}
+	if (in.obtain_bufs(&fd)) {
+		fprintf(stderr, "%s: in.obtain_bufs failed\n", __func__);
+		goto done;
+	}
 
-	if (in.obtain_bufs(&fd) ||
-	    in.queue_all(&fd) ||
-	    do_setup_out_buffers(out_fd, out, file[OUT], false, false) == QUEUE_ERROR)
+	if (in.queue_all(&fd)) {
+		fprintf(stderr, "%s: in.queue_all failed\n", __func__);
 		goto done;
+	}
+
+
+	if (do_setup_out_buffers(out_fd, out, file[OUT], false, false) == QUEUE_ERROR) {
+		fprintf(stderr, "%s: do_setup_out_buffers failed\n", __func__);
+		goto done;
+	}
 
 	fps_ts[CAP].determine_field(fd.g_fd(), in.g_type());
 	fps_ts[OUT].determine_field(fd.g_fd(), out.g_type());
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch v4l-utils 1/2] v4l2-ctl: print specific error upon failure
@ 2021-07-16 12:57   ` Dafna Hirschfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

When an operation fails, print an error message
that specify the specific operation that failed
prefixed with the current function name.
This makes debugging less painful.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 62424e4c..0f28a537 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1153,8 +1153,10 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
 			q.g_type() == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 	bool is_meta = q.g_type() == V4L2_BUF_TYPE_META_OUTPUT;
 
-	if (q.obtain_bufs(&fd))
+	if (q.obtain_bufs(&fd)) {
+		fprintf(stderr, "%s q.obtain_bufs failed\n", __func__);
 		return QUEUE_ERROR;
+	}
 
 	fd.g_fmt(fmt, q.g_type());
 	{
@@ -1226,8 +1228,10 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
 	for (unsigned i = 0; i < q.g_buffers(); i++) {
 		cv4l_buffer buf(q);
 
-		if (fd.querybuf(buf, i))
+		if (fd.querybuf(buf, i)) {
+			fprintf(stderr, "%s fd.querybuf failed\n", __func__);
 			return QUEUE_ERROR;
+		}
 
 		buf.update(q, i);
 		for (unsigned j = 0; j < q.g_num_planes(); j++)
@@ -2720,11 +2724,21 @@ static void streaming_set_cap2out(cv4l_fd &fd, cv4l_fd &out_fd)
 		fprintf(stderr, "mismatch between number of planes\n");
 		goto done;
 	}
+	if (in.obtain_bufs(&fd)) {
+		fprintf(stderr, "%s: in.obtain_bufs failed\n", __func__);
+		goto done;
+	}
 
-	if (in.obtain_bufs(&fd) ||
-	    in.queue_all(&fd) ||
-	    do_setup_out_buffers(out_fd, out, file[OUT], false, false) == QUEUE_ERROR)
+	if (in.queue_all(&fd)) {
+		fprintf(stderr, "%s: in.queue_all failed\n", __func__);
 		goto done;
+	}
+
+
+	if (do_setup_out_buffers(out_fd, out, file[OUT], false, false) == QUEUE_ERROR) {
+		fprintf(stderr, "%s: do_setup_out_buffers failed\n", __func__);
+		goto done;
+	}
 
 	fps_ts[CAP].determine_field(fd.g_fd(), in.g_type());
 	fps_ts[OUT].determine_field(fd.g_fd(), out.g_type());
-- 
2.17.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch v4l-utils 2/2] v4l2-ctl: fix bugs found in streaming_set_cap2out
  2021-07-16 12:57 ` Dafna Hirschfeld
@ 2021-07-16 12:57   ` Dafna Hirschfeld
  -1 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

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>
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 0f28a537..432f1cc6 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 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch v4l-utils 2/2] v4l2-ctl: fix bugs found in streaming_set_cap2out
@ 2021-07-16 12:57   ` Dafna Hirschfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Dafna Hirschfeld @ 2021-07-16 12:57 UTC (permalink / raw)
  To: linux-media
  Cc: laurent.pinchart, dafna.hirschfeld, helen.koike, ezequiel,
	hverkuil, kernel, dafna3, sakari.ailus, linux-rockchip, mchehab,
	tfiga

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>
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 0f28a537..432f1cc6 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 {
-- 
2.17.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-16 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 12:57 [patch v4l-utils 0/2] Fix bugs found with dmabuf Dafna Hirschfeld
2021-07-16 12:57 ` Dafna Hirschfeld
2021-07-16 12:57 ` [patch v4l-utils 1/2] v4l2-ctl: print specific error upon failure Dafna Hirschfeld
2021-07-16 12:57   ` Dafna Hirschfeld
2021-07-16 12:57 ` [patch v4l-utils 2/2] v4l2-ctl: fix bugs found in streaming_set_cap2out Dafna Hirschfeld
2021-07-16 12:57   ` Dafna Hirschfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.