* [PATCH 1/6] v4l2-tracer: look in more places for libv4l2tracer
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
2023-12-01 0:46 ` [PATCH 2/6] v4l2-tracer: ignore single line comments when parsing headers Deborah Brouwer
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
The v4l2-tracer already looks in the build and install directories for its
library, but now it will also look in a truncated version of the
LIBTRACER_PATH which is helpful if it was installed by a cross-build. If
all else fails, it also allows the user to set a custom path using the
LD_PRELOAD environment variable.
Exit if the libv4l2tracer.so can’t be found.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/v4l2-tracer.cpp | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp b/utils/v4l2-tracer/v4l2-tracer.cpp
index a039f528..37e17eb6 100644
--- a/utils/v4l2-tracer/v4l2-tracer.cpp
+++ b/utils/v4l2-tracer/v4l2-tracer.cpp
@@ -306,13 +306,31 @@ int tracer(int argc, char *argv[], bool retrace)
else
idx++;
- /* look for libv4l2tracer next to the executable */
libv4l2tracer_path = program.replace(program.begin() + idx, program.end(), "libv4l2tracer.so");
- /* otherwise, use the installation path */
- if (stat(libv4l2tracer_path.c_str(), &sb) == -1)
+ if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+ /* If not found, get the libv4l2tracer library from the meson install path 'prefix' */
libv4l2tracer_path = std::string(LIBTRACER_PATH) + "/libv4l2tracer.so";
+ /* Otherwise, guess where the library might be for a cross-build. */
+ if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+ std::size_t idx = libv4l2tracer_path.find("/home");
+ libv4l2tracer_path = libv4l2tracer_path.substr(idx);
+
+ /* Finally, check if the user set a custom path using LD_PRELOAD. */
+ if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+ if (getenv("LD_PRELOAD"))
+ libv4l2tracer_path = std::string(getenv("LD_PRELOAD"));
+
+ if (stat(libv4l2tracer_path.c_str(), &sb) == -1) {
+ fprintf(stderr, "Exiting: can't find libv4l2tracer library\n");
+ fprintf(stderr, "Set a custom libv4l2tracer library path using: LD_PRELOAD\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+ }
+
if (is_verbose())
fprintf(stderr, "Loading libv4l2tracer: %s\n", libv4l2tracer_path.c_str());
setenv("LD_PRELOAD", libv4l2tracer_path.c_str(), 0);
@@ -355,6 +373,7 @@ int tracer(int argc, char *argv[], bool retrace)
fprintf(stderr, "%s", trace_filename.c_str());
fprintf(stderr, "\n");
+ unsetenv("LD_PRELOAD");
return exec_result;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] v4l2-tracer: ignore single line comments when parsing headers
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
2023-12-01 0:46 ` [PATCH 1/6] v4l2-tracer: look in more places for libv4l2tracer Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
2023-12-01 0:46 ` [PATCH 3/6] v4l2-tracer: add re/tracing for MAX_NUM_BUFFERS Deborah Brouwer
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
Just in case there are single-line comments that start with '//',
ignore them in the autogeneration script.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/v4l2-tracer-gen.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl
index 1e4cadda..7b4f859b 100755
--- a/utils/v4l2-tracer/v4l2-tracer-gen.pl
+++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl
@@ -151,7 +151,8 @@ sub clean_up_line {
$line =~ s/^\s+//; # remove leading whitespace
$line =~ s/.*\# define.*//; # zero out line if it has defines inside a structure (e.g. v4l2_jpegcompression)
$line =~ s/^\s*\/?\s?\*.*//; # zero out line if it has comments where the line starts with start with /* / * or just *
- $line =~ s/\s*\/\*.*//; # remove comments at the end of a line following a member
+ $line =~ s/\s*\/\*.*//; # remove comments /* */ at the end of a line following a member
+ $line =~ s/\s*\/\/.*//; # remove comments // at the end of a line following a member
$line =~ s/\*\/$//; # zero out line if it has comments that begin without any slashs or asterisks but end with */
# zero out lines that don't have a ; or { because they are comments but without any identifying slashes or asteriks
if ($line !~ /.*[\;|\{].*/) {
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] v4l2-tracer: add re/tracing for MAX_NUM_BUFFERS
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
2023-12-01 0:46 ` [PATCH 1/6] v4l2-tracer: look in more places for libv4l2tracer Deborah Brouwer
2023-12-01 0:46 ` [PATCH 2/6] v4l2-tracer: ignore single line comments when parsing headers Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
2023-12-01 0:46 ` [PATCH 4/6] v4l2-tracer: add re/tracing for AV1 controls Deborah Brouwer
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
In the last sync of the kernel headers, the autogeneration script failed
to pick up the new flag V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS, so add it.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/v4l2-tracer-gen.pl | 2 +-
utils/v4l2-tracer/v4l2-tracer-info-gen.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl
index 7b4f859b..b0ec9d6e 100755
--- a/utils/v4l2-tracer/v4l2-tracer-gen.pl
+++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl
@@ -943,7 +943,7 @@ while (<>) {
}
if (grep {/^#define V4L2_BUF_CAP_SUPPORTS_MMAP\s+/} $_) {
printf $fh_common_info_h "constexpr flag_def v4l2_buf_cap_flag_def[] = {\n";
- flag_def_gen("V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS");
+ flag_def_gen("V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS");
next;
}
if (grep {/^#define V4L2_STD_PAL_B\s+/} $_) {
diff --git a/utils/v4l2-tracer/v4l2-tracer-info-gen.h b/utils/v4l2-tracer/v4l2-tracer-info-gen.h
index 332e271f..b103b9bd 100644
--- a/utils/v4l2-tracer/v4l2-tracer-info-gen.h
+++ b/utils/v4l2-tracer/v4l2-tracer-info-gen.h
@@ -1518,6 +1518,7 @@ constexpr flag_def v4l2_buf_cap_flag_def[] = {
{ V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS, "V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS" },
{ V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF, "V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF" },
{ V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS, "V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS" },
+ { V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS, "V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS" },
{ 0, "" }
};
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] v4l2-tracer: add re/tracing for AV1 controls
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
` (2 preceding siblings ...)
2023-12-01 0:46 ` [PATCH 3/6] v4l2-tracer: add re/tracing for MAX_NUM_BUFFERS Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
2023-12-01 0:46 ` [PATCH 5/6] v4l2-tracer: stop waiting to handle a signal Deborah Brouwer
2023-12-01 0:46 ` [PATCH 6/6] v4l2-tracer: use stat to verify that retrace file exists Deborah Brouwer
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
Hook up the existing autogenerated AV1 tracing and retracing functions so
that they are called by the tracer and retracer.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/retrace.cpp | 12 ++++++++++++
utils/v4l2-tracer/trace.cpp | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 03fe13f8..b8a1c8fb 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -876,6 +876,18 @@ struct v4l2_ext_control *retrace_v4l2_ext_control(json_object *parent_obj, int c
case V4L2_CID_STATELESS_MPEG2_QUANTISATION:
p->ptr = retrace_v4l2_ctrl_mpeg2_quantisation_gen(v4l2_ext_control_obj);
break;
+ case V4L2_CID_STATELESS_AV1_SEQUENCE:
+ p->ptr = retrace_v4l2_ctrl_av1_sequence_gen(v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY:
+ p->ptr = retrace_v4l2_ctrl_av1_tile_group_entry_gen(v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_FRAME:
+ p->ptr = retrace_v4l2_ctrl_av1_frame_gen(v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_FILM_GRAIN:
+ p->ptr = retrace_v4l2_ctrl_av1_film_grain_gen(v4l2_ext_control_obj);
+ break;
default:
line_info("\n\tWarning: cannot retrace control: %s",
val2s(p->id, control_val_def).c_str());
diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index c4fc1584..996fb043 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -412,6 +412,18 @@ void trace_v4l2_ext_control(void *arg, json_object *parent_obj, std::string key_
case V4L2_CID_PIXEL_RATE:
json_object_object_add(v4l2_ext_control_obj, "value64", json_object_new_int64(p->value64));
break;
+ case V4L2_CID_STATELESS_AV1_SEQUENCE:
+ trace_v4l2_ctrl_av1_sequence_gen(p->p_av1_sequence, v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY:
+ trace_v4l2_ctrl_av1_tile_group_entry_gen(p->p_av1_tile_group_entry, v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_FRAME:
+ trace_v4l2_ctrl_av1_frame_gen(p->p_av1_frame, v4l2_ext_control_obj);
+ break;
+ case V4L2_CID_STATELESS_AV1_FILM_GRAIN:
+ trace_v4l2_ctrl_av1_film_grain_gen(p->p_av1_film_grain, v4l2_ext_control_obj);
+ break;
default:
if (p->size)
line_info("\n\tWarning: cannot trace control: %s", val2s(p->id, control_val_def).c_str());
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] v4l2-tracer: stop waiting to handle a signal
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
` (3 preceding siblings ...)
2023-12-01 0:46 ` [PATCH 4/6] v4l2-tracer: add re/tracing for AV1 controls Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
2023-12-01 0:46 ` [PATCH 6/6] v4l2-tracer: use stat to verify that retrace file exists Deborah Brouwer
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
Usually the v4l2-tracer will wait for its tracee to handle a signal e.g.
from ctrl+c before the v4l2-tracer exits, but if there is no tracee,
then the v4l2-tracer waits forever.
Exit gracefully by waiting only if a tracee exists.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/v4l2-tracer.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp b/utils/v4l2-tracer/v4l2-tracer.cpp
index 37e17eb6..05e5b368 100644
--- a/utils/v4l2-tracer/v4l2-tracer.cpp
+++ b/utils/v4l2-tracer/v4l2-tracer.cpp
@@ -16,9 +16,12 @@ pid_t tracee_pid = 0;
void v4l2_tracer_sig_handler(int signum)
{
line_info("\n\tReceived signum: %d", signum);
- kill(tracee_pid, signum);
- /* Wait for tracee to handle the signal first before v4l2-tracer exits. */
- wait(nullptr);
+
+ /* If there is a tracee, wait for it to handle the signal first before exiting. */
+ if (tracee_pid) {
+ kill(tracee_pid, signum);
+ wait(nullptr);
+ }
}
enum Options {
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] v4l2-tracer: use stat to verify that retrace file exists
2023-12-01 0:46 [PATCH 0/6] v4l2-tracer: misc fixes and improvements Deborah Brouwer
` (4 preceding siblings ...)
2023-12-01 0:46 ` [PATCH 5/6] v4l2-tracer: stop waiting to handle a signal Deborah Brouwer
@ 2023-12-01 0:46 ` Deborah Brouwer
5 siblings, 0 replies; 7+ messages in thread
From: Deborah Brouwer @ 2023-12-01 0:46 UTC (permalink / raw)
To: linux-media; +Cc: hverkuil-cisco, Deborah Brouwer
Instead of opening and closing the file to see if it exists, just use
stat. This avoids cluttering a trace with extra opens/closes. Also change
the return value to give a better description of the failure to the
calling function.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/retrace.cpp | 7 +++----
utils/v4l2-tracer/v4l2-tracer-common.h | 1 +
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index b8a1c8fb..60d64d8b 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -1537,12 +1537,11 @@ void retrace_array(json_object *root_array_obj)
int retrace(std::string trace_filename)
{
- FILE *trace_file = fopen(trace_filename.c_str(), "r");
- if (trace_file == nullptr) {
+ struct stat sb;
+ if (stat(trace_filename.c_str(), &sb) == -1) {
line_info("\n\tTrace file error: \'%s\'", trace_filename.c_str());
- return 1;
+ return -EINVAL;
}
- fclose(trace_file);
fprintf(stderr, "Retracing: %s\n", trace_filename.c_str());
diff --git a/utils/v4l2-tracer/v4l2-tracer-common.h b/utils/v4l2-tracer/v4l2-tracer-common.h
index c8b5dbd4..adb41218 100644
--- a/utils/v4l2-tracer/v4l2-tracer-common.h
+++ b/utils/v4l2-tracer/v4l2-tracer-common.h
@@ -26,6 +26,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <unordered_map>
#include <vector>
--
2.41.0
^ permalink raw reply related [flat|nested] 7+ messages in thread