All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: linux-media@vger.kernel.org
Cc: hverkuil-cisco@xs4all.nl,
	Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH 2/8] v4l2-tracer: replace buftype2s with val2s
Date: Mon, 13 Nov 2023 12:06:13 -0800	[thread overview]
Message-ID: <0d7a8b49dafb090481a03b61c5bd4dabcf4b4386.1699904350.git.deborah.brouwer@collabora.com> (raw)
In-Reply-To: <cover.1699904350.git.deborah.brouwer@collabora.com>

While buftype2s gives a written description of the buffer type, val2s will
reproduce the type exactly as it appears in videodev2.h which is easier to
follow for tracing.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
 utils/v4l2-tracer/retrace.cpp      | 19 ++++++++++++-------
 utils/v4l2-tracer/trace-helper.cpp |  6 +++---
 utils/v4l2-tracer/trace.cpp        |  4 ++--
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 14c42568..1bec635d 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -336,7 +336,8 @@ void retrace_vidioc_querybuf(int fd_retrace, json_object *ioctl_args_user)
 
 	if (is_verbose() || (errno != 0)) {
 		fprintf(stderr, "%s, index: %d, fd: %d, ",
-		        buftype2s((int) buf->type).c_str(), buf->index, fd_retrace);
+			val2s(buf->type, v4l2_buf_type_val_def).c_str(),
+			buf->index, fd_retrace);
 		perror("VIDIOC_QUERYBUF");
 		debug_line_info();
 		print_context();
@@ -360,7 +361,8 @@ void retrace_vidioc_qbuf(int fd_retrace, json_object *ioctl_args_user)
 
 	if (is_verbose() || (errno != 0)) {
 		fprintf(stderr, "%s, index: %d, fd: %d, ",
-		        buftype2s((int) ptr->type).c_str(), ptr->index, fd_retrace);
+		        val2s(ptr->type, v4l2_buf_type_val_def).c_str(),
+		        ptr->index, fd_retrace);
 		perror("VIDIOC_QBUF");
 		debug_line_info();
 		print_context();
@@ -395,7 +397,8 @@ void retrace_vidioc_dqbuf(int fd_retrace, json_object *ioctl_args_user)
 
 	if (is_verbose() || (errno != 0)) {
 		fprintf(stderr, "%s, index: %d, fd: %d, ",
-		        buftype2s((int) buf->type).c_str(), buf->index, fd_retrace);
+		        val2s(buf->type, v4l2_buf_type_val_def).c_str(),
+		        buf->index, fd_retrace);
 		perror("VIDIOC_DQBUF");
 		debug_line_info();
 		print_context();
@@ -416,7 +419,8 @@ void retrace_vidioc_prepare_buf(int fd_retrace, json_object *ioctl_args_user)
 
 	if (is_verbose() || (errno != 0)) {
 		fprintf(stderr, "%s, index: %d, fd: %d, ",
-		        buftype2s((int) buf->type).c_str(), buf->index, fd_retrace);
+		        val2s(buf->type, v4l2_buf_type_val_def).c_str(),
+		        buf->index, fd_retrace);
 		perror("VIDIOC_PREPARE_BUF");
 		debug_line_info();
 		print_context();
@@ -482,7 +486,7 @@ void retrace_vidioc_streamon(int fd_retrace, json_object *ioctl_args)
 	ioctl(fd_retrace, VIDIOC_STREAMON, &buf_type);
 
 	if (is_verbose() || (errno != 0)) {
-		fprintf(stderr, "%s, ", buftype2s(buf_type).c_str());
+		fprintf(stderr, "%s, ", val2s(buf_type, v4l2_buf_type_val_def).c_str());
 		perror("VIDIOC_STREAMON");
 	}
 }
@@ -497,7 +501,7 @@ void retrace_vidioc_streamoff(int fd_retrace, json_object *ioctl_args)
 	ioctl(fd_retrace, VIDIOC_STREAMOFF, &buf_type);
 
 	if (is_verbose() || (errno != 0)) {
-		fprintf(stderr, "%s, ", buftype2s(buf_type).c_str());
+		fprintf(stderr, "%s, ", val2s(buf_type, v4l2_buf_type_val_def).c_str());
 		perror("VIDIOC_STREAMOFF");
 	}
 }
@@ -1451,7 +1455,8 @@ void retrace_mem(json_object *mem_obj)
 		write_to_output_buffer(buffer_pointer, bytesused, mem_obj);
 
 	debug_line_info("\n\t%s, bytesused: %d, offset: %d, addr: %ld",
-	                buftype2s(type).c_str(), bytesused, offset, buffer_address_retrace);
+			val2s(type, v4l2_buf_type_val_def).c_str(),
+			bytesused, offset, buffer_address_retrace);
 	print_context();
 }
 
diff --git a/utils/v4l2-tracer/trace-helper.cpp b/utils/v4l2-tracer/trace-helper.cpp
index e5094b67..a1e83a44 100644
--- a/utils/v4l2-tracer/trace-helper.cpp
+++ b/utils/v4l2-tracer/trace-helper.cpp
@@ -228,7 +228,7 @@ void print_buffers_trace(void)
 		return;
 	for (auto &b : ctx_trace.buffers) {
 		fprintf(stderr, "fd: %d, %s, index: %d, display_order: %ld, bytesused: %d, ",
-		        b.fd, buftype2s(b.type).c_str(), b.index, b.display_order, b.bytesused);
+		        b.fd, val2s(b.type, v4l2_buf_type_val_def).c_str(), b.index, b.display_order, b.bytesused);
 		fprintf(stderr, "address: %lu, offset: %u \n",  b.address, b.offset);
 	}
 }
@@ -320,7 +320,7 @@ void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls)
 
 void qbuf_setup(struct v4l2_buffer *buf)
 {
-	debug_line_info("\n\t%s, index: %d", buftype2s((int) buf->type).c_str(), buf->index);
+	debug_line_info("\n\t%s, index: %d", val2s(buf->type, v4l2_buf_type_val_def).c_str(), buf->index);
 
 	int buf_fd = get_buffer_fd_trace(buf->type, buf->index);
 	__u32 buf_offset = get_buffer_offset_trace(buf->type, buf->index);
@@ -361,7 +361,7 @@ void streamoff_cleanup(v4l2_buf_type buf_type)
 {
 	debug_line_info();
 	if (is_verbose() || (getenv("V4L2_TRACER_OPTION_WRITE_DECODED_TO_YUV_FILE") != nullptr)) {
-		fprintf(stderr, "VIDIOC_STREAMOFF: %s\n", buftype2s(buf_type).c_str());
+		fprintf(stderr, "VIDIOC_STREAMOFF: %s\n", val2s(buf_type, v4l2_buf_type_val_def).c_str());
 		fprintf(stderr, "%s, %s %s, width: %d, height: %d\n",
 		        val2s(ctx_trace.compression_format, v4l2_pix_fmt_val_def).c_str(),
 		        val2s(ctx_trace.pixelformat, v4l2_pix_fmt_val_def).c_str(),
diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index 0e8531ff..f81f68d1 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -181,8 +181,8 @@ void trace_mem_decoded(void)
 			 */
 			if (it->bytesused < expected_length)
 				break;
-			debug_line_info("\n\tDisplaying: %ld, %s, index: %d",
-			                it->display_order, buftype2s(it->type).c_str(), it->index);
+			debug_line_info("\n\tDisplaying: %ld, %s, index: %d", it->display_order,
+					val2s(it->type, v4l2_buf_type_val_def).c_str(), it->index);
 			displayed_count++;
 
 			if (getenv("V4L2_TRACER_OPTION_WRITE_DECODED_TO_YUV_FILE") != nullptr) {
-- 
2.41.0


  parent reply	other threads:[~2023-11-13 20:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 20:06 [PATCH 0/8] v4l2-tracer: expand to stateful decoding Deborah Brouwer
2023-11-13 20:06 ` [PATCH 1/8] v4l2-info/v4l2-tracer: add macro to mark the trace Deborah Brouwer
2023-11-13 20:06 ` Deborah Brouwer [this message]
2023-11-13 20:06 ` [PATCH 3/8] v4l2-tracer: remove buffers by type and index Deborah Brouwer
2023-11-13 20:06 ` [PATCH 4/8] v4l2-tracer: remove compress_frame_count Deborah Brouwer
2023-11-13 20:06 ` [PATCH 5/8] v4l2-tracer: get decoded bytesused from DQBUF Deborah Brouwer
2023-11-13 20:06 ` [PATCH 6/8] v4l2-tracer: create an option to trace userspace args Deborah Brouwer
2023-11-13 20:06 ` [PATCH 7/8] v4l2-tracer: stop retracing failed ioctls Deborah Brouwer
2023-11-13 20:06 ` [PATCH 8/8] v4l2-tracer: auto generate flags for DECODER_CMD Deborah Brouwer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d7a8b49dafb090481a03b61c5bd4dabcf4b4386.1699904350.git.deborah.brouwer@collabora.com \
    --to=deborah.brouwer@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.