[PATCH v4 2/2] v4l2-tracer: add support for most basic controls

Deborah Brouwer
2022-11-30T18:24:18Z

From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

The v4l2-tracer utility didn't support tracing simple controls without
a payload (i.e. the 'size' field is 0) and just a simple value.

This adds support for that, plus the four standard INTEGER64 controls
that use field value64.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
utils/v4l2-tracer/retrace.cpp | 16 ++++++++++++++++
utils/v4l2-tracer/trace.cpp | 14 ++++++++++++--
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 9b03d3bb..36a218d3 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -726,7 +726,23 @@ struct v4l2_ext_control *retrace_v4l2_ext_control(json_object *parent_obj, int c
p->value = retrace_v4l2_ext_control_value(v4l2_ext_control_obj,
v4l2_stateless_hevc_start_code_val_def);
break;
+ case V4L2_CID_MPEG_VIDEO_DEC_PTS:
+ case V4L2_CID_MPEG_VIDEO_DEC_FRAME:
+ case V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR:
+ case V4L2_CID_PIXEL_RATE: {
+ json_object *value64_obj;
+
+ if (json_object_object_get_ex(v4l2_ext_control_obj, "value64", &value64_obj))
+ p->value64 = json_object_get_int64(value64_obj);
+ break;
+ }
default:
+ if (!p->size) {
+ json_object *value_obj;
+
+ if (json_object_object_get_ex(v4l2_ext_control_obj, "value", &value_obj))
+ p->value = json_object_get_int(value_obj);
+ }
break;
}

diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp
index cff78315..d5a09ad7 100644
--- a/utils/v4l2-tracer/trace.cpp
+++ b/utils/v4l2-tracer/trace.cpp
@@ -410,9 +410,19 @@ void trace_v4l2_ext_control(void *arg, json_object *parent_obj, std::string key_
case V4L2_CID_STATELESS_MPEG2_QUANTISATION:
trace_v4l2_ctrl_mpeg2_quantisation_gen(p->p_mpeg2_quantisation, v4l2_ext_control_obj);
break;
+ case V4L2_CID_MPEG_VIDEO_DEC_PTS:
+ case V4L2_CID_MPEG_VIDEO_DEC_FRAME:
+ case V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR:
+ case V4L2_CID_PIXEL_RATE:
+ json_object_object_add(v4l2_ext_control_obj, "value64", json_object_new_int64(p->value64));
+ break;
default:
- fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
- fprintf(stderr, "warning: cannot trace control: %s\n", val2s(p->id, control_val_def).c_str());
+ if (p->size) {
+ fprintf(stderr, "%s:%s:%d: ", __FILE__, __func__, __LINE__);
+ fprintf(stderr, "warning: cannot trace control: %s\n", val2s(p->id, control_val_def).c_str());
+ } else {
+ json_object_object_add(v4l2_ext_control_obj, "value", json_object_new_int(p->value));
+ }
break;
}

--
2.38.0