diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-22 09:53:53 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-22 09:53:53 -0200 |
commit | d0dd746a466cef43b09aba57033f390dcc417967 (patch) | |
tree | 01ea45474c12029ba8ae8b376caabd0fde978218 | |
parent | eb7bc99b0b15c28d8d0bd3dd4be26710d03dac2a (diff) | |
download | mediapointer-dvb-s2-d0dd746a466cef43b09aba57033f390dcc417967.tar.gz mediapointer-dvb-s2-d0dd746a466cef43b09aba57033f390dcc417967.tar.bz2 |
v4l2-dbg: print register name when known
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Priority: normal
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | v4l2-apps/util/v4l2-dbg.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index c1e107de1..87044e851 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -293,6 +293,21 @@ static unsigned long long parse_reg(const struct board_list *curr_bd, const std: return strtoull(reg.c_str(), NULL, 0); } +static const char *reg_name(const struct board_list *curr_bd, unsigned long long reg) +{ + if (curr_bd) { + for (int i = 0; i < curr_bd->regs_size; i++) { + if (reg == curr_bd->regs[i].reg) + return curr_bd->regs[i].name; + } + for (int i = 0; i < curr_bd->alt_regs_size; i++) { + if (reg == curr_bd->regs[i].reg) + return curr_bd->regs[i].name; + } + } + return NULL; +} + static const char *binary(unsigned long long val) { static char bin[80]; @@ -582,9 +597,19 @@ int main(int argc, char **argv) if (ioctl(fd, VIDIOC_DBG_G_REGISTER, &get_reg) < 0) fprintf(stderr, "ioctl: VIDIOC_DBG_G_REGISTER " "failed for 0x%llx\n", get_reg.reg); - else - printf("%llx = %llxh = %lldd = %sb\n", get_reg.reg, + else { + const char *name = reg_name(curr_bd, get_reg.reg); + + printf("Register "); + + if (name) + printf("%s", name); + else + printf("0x%08llx", get_reg.reg); + + printf(" = %llxh (%lldd %sb)\n", get_reg.val, get_reg.val, binary(get_reg.val)); + } } } |