Commit a69a7a33 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab

v4l2-core: Print control name in VIDIOC_S/G_(EXT)_CTRL(S)

While debugging, it's currently really hard to identify controls
by their ID. Print the control name making the print more helpful.

With this change, the print changes from:

video1: VIDIOC_S_EXT_CTRLS: which=0xf010000, count=5, error_idx=4, request_fd=45, id/size=0x990ce8/1048, id/size=0x990ce9/12, id/size=0x990cea/480, id/size=0x990ceb/896, id/size=0x990cec/400

video1: VIDIOC_S_EXT_CTRLS: which=0xf010000, count=5, error_idx=4, request_fd=42, name=H264 Sequence Parameter Set, id/size=0x990ce8/1048, name=H264 Picture Parameter Set, id/size=0x990ce9/12, name=H264 Scaling Matrix, id/size=0x990cea/480, name=H264 Slice Parameters, id/size=0x990ceb/896, name=H264 Decode Parameters, id/size=0x990cec/400

For instance, this is specially helpful when the ioctl fails. Consider
the following example:

v4l2-ctrls: prepare_ext_ctrls: video1: pointer control id 0x990cec size too small, 400 bytes but 784 bytes needed
v4l2-ctrls: try_set_ext_ctrls: video1: video1: try_set_ext_ctrls_common failed (-14)
video1: VIDIOC_S_EXT_CTRLS: error -14: which=0xf010000, count=5, error_idx=5, request_fd=39, name=H264 Sequence Parameter Set, id/size=0x990ce8/1048, name=H264 Picture Parameter Set, id/size=0x990ce9/12, name=H264 Scaling Matrix, id/size=0x990cea/480, name=H264 Slice Parameters, id/size=0x990ceb/896, name=H264 Decode Parameters, id/size=0x990cec/400
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent e8bf419e
...@@ -582,7 +582,10 @@ static void v4l_print_querymenu(const void *arg, bool write_only) ...@@ -582,7 +582,10 @@ static void v4l_print_querymenu(const void *arg, bool write_only)
static void v4l_print_control(const void *arg, bool write_only) static void v4l_print_control(const void *arg, bool write_only)
{ {
const struct v4l2_control *p = arg; const struct v4l2_control *p = arg;
const char *name = v4l2_ctrl_get_name(p->id);
if (name)
pr_cont("name=%s, ", name);
pr_cont("id=0x%x, value=%d\n", p->id, p->value); pr_cont("id=0x%x, value=%d\n", p->id, p->value);
} }
...@@ -594,12 +597,15 @@ static void v4l_print_ext_controls(const void *arg, bool write_only) ...@@ -594,12 +597,15 @@ static void v4l_print_ext_controls(const void *arg, bool write_only)
pr_cont("which=0x%x, count=%d, error_idx=%d, request_fd=%d", pr_cont("which=0x%x, count=%d, error_idx=%d, request_fd=%d",
p->which, p->count, p->error_idx, p->request_fd); p->which, p->count, p->error_idx, p->request_fd);
for (i = 0; i < p->count; i++) { for (i = 0; i < p->count; i++) {
unsigned int id = p->controls[i].id;
const char *name = v4l2_ctrl_get_name(id);
if (name)
pr_cont(", name=%s", name);
if (!p->controls[i].size) if (!p->controls[i].size)
pr_cont(", id/val=0x%x/0x%x", pr_cont(", id/val=0x%x/0x%x", id, p->controls[i].value);
p->controls[i].id, p->controls[i].value);
else else
pr_cont(", id/size=0x%x/%u", pr_cont(", id/size=0x%x/%u", id, p->controls[i].size);
p->controls[i].id, p->controls[i].size);
} }
pr_cont("\n"); pr_cont("\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment