summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/v4l2-dbg.cpp
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-12-23 19:57:17 +0100
committerJean-Francois Moine <moinejf@free.fr>2008-12-23 19:57:17 +0100
commitac2c9fd519acfcea10f4b1b17b69e9f3d8f49555 (patch)
tree3aa28180723e897e8ae6704940ed70d0679ed680 /v4l2-apps/util/v4l2-dbg.cpp
parente3ed9d5ccedc1a7a60c7cf106fbfb795448b32ea (diff)
parentd8fa5b2669acb99dcbc246d93bef9f2028c1aff0 (diff)
downloadmediapointer-dvb-s2-ac2c9fd519acfcea10f4b1b17b69e9f3d8f49555.tar.gz
mediapointer-dvb-s2-ac2c9fd519acfcea10f4b1b17b69e9f3d8f49555.tar.bz2
merge: v4l-dvb
Diffstat (limited to 'v4l2-apps/util/v4l2-dbg.cpp')
-rw-r--r--v4l2-apps/util/v4l2-dbg.cpp137
1 files changed, 126 insertions, 11 deletions
diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp
index e0d6153fe..577c8585e 100644
--- a/v4l2-apps/util/v4l2-dbg.cpp
+++ b/v4l2-apps/util/v4l2-dbg.cpp
@@ -45,6 +45,8 @@
#include "v4l2-dbg-bttv.h"
#include "v4l2-dbg-saa7134.h"
#include "v4l2-dbg-em28xx.h"
+#include "v4l2-dbg-ac97.h"
+#include "v4l2-dbg-tvp5150.h"
#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0])))
@@ -58,6 +60,15 @@ struct board_list {
};
static const struct board_list boards[] = {
+#define AC97_BOARD 0
+ { /* From ac97-dbg.h */
+ AC97_IDENT,
+ sizeof(AC97_PREFIX) - 1,
+ ac97_regs,
+ ARRAY_SIZE(ac97_regs),
+ NULL,
+ 0,
+ },
{ /* From bttv-dbg.h */
BTTV_IDENT,
sizeof(BTTV_PREFIX) - 1,
@@ -79,6 +90,14 @@ static const struct board_list boards[] = {
sizeof(EM28XX_PREFIX) - 1,
em28xx_regs,
ARRAY_SIZE(em28xx_regs),
+ em28xx_alt_regs,
+ ARRAY_SIZE(em28xx_alt_regs),
+ },
+ { /* From tvp5150-dbg.h */
+ TVP5150_IDENT,
+ sizeof(TVP5150_PREFIX) - 1,
+ tvp5150_regs,
+ ARRAY_SIZE(tvp5150_regs),
NULL,
0,
},
@@ -136,7 +155,7 @@ static struct option long_options[] = {
{"set-register", required_argument, 0, OptSetRegister},
{"chip", required_argument, 0, OptChip},
{"scan-chip-idents", no_argument, 0, OptScanChipIdents},
- {"get-chip-ident", required_argument, 0, OptGetChipIdent},
+ {"get-chip-ident", no_argument, 0, OptGetChipIdent},
{"info", no_argument, 0, OptGetDriverInfo},
{"verbose", no_argument, 0, OptVerbose},
{"log-status", no_argument, 0, OptLogStatus},
@@ -158,6 +177,7 @@ static void usage(void)
" It can be one of:\n"
" I2C driver ID (see --list-driverids)\n"
" I2C 7-bit address\n"
+ " AC97: for ac97 anciliary mixer\n"
" host<num>: host chip number <num>\n"
" host (default): same as host0\n"
" -l, --list-registers[=min=<addr>[,max=<addr>]]\n"
@@ -293,6 +313,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];
@@ -380,6 +415,7 @@ int main(int argc, char **argv)
std::vector<std::string> get_regs;
int match_type = V4L2_CHIP_MATCH_HOST;
int match_chip = 0;
+ char driver[255];
memset(&set_reg, 0, sizeof(set_reg));
memset(&get_reg, 0, sizeof(get_reg));
@@ -433,7 +469,12 @@ int main(int argc, char **argv)
match_chip = strtoul(optarg + 4, NULL, 0);
break;
}
+ if (!strcasecmp(optarg, "ac97")) {
+ match_type = V4L2_CHIP_MATCH_AC97;
+ break;
+ }
match_type = V4L2_CHIP_MATCH_I2C_DRIVER;
+ strcpy(driver, optarg);
match_chip = parse_chip(optarg);
if (!match_chip) {
fprintf(stderr, "unknown driver ID %s\n", optarg);
@@ -457,6 +498,7 @@ int main(int argc, char **argv)
subs = optarg;
if (subs == NULL)
break;
+
while (*subs != '\0') {
static const char * const subopts[] = {
"min",
@@ -516,10 +558,21 @@ int main(int argc, char **argv)
printf("%s", cap2s(vcap.capabilities).c_str());
}
- for (int board = ARRAY_SIZE(boards) - 1; board >= 0; board--) {
- if (!strcasecmp((char *)vcap.driver, boards[board].name)) {
- curr_bd = &boards[board];
- break;
+ if (match_type == V4L2_CHIP_MATCH_AC97) {
+ curr_bd = &boards[AC97_BOARD];
+ } else if (match_type == V4L2_CHIP_MATCH_HOST) {
+ for (int board = ARRAY_SIZE(boards) - 1; board >= 0; board--) {
+ if (!strcasecmp((char *)vcap.driver, boards[board].name)) {
+ curr_bd = &boards[board];
+ break;
+ }
+ }
+ } else if (match_type == V4L2_CHIP_MATCH_I2C_DRIVER) {
+ for (int board = ARRAY_SIZE(boards) - 1; board >= 0; board--) {
+ if (!strcasecmp(driver, boards[board].name)) {
+ curr_bd = &boards[board];
+ break;
+ }
}
}
@@ -534,8 +587,21 @@ int main(int argc, char **argv)
while (optind < argc) {
set_reg.val = strtoull(argv[optind++], NULL, 0);
if (doioctl(fd, VIDIOC_DBG_S_REGISTER, &set_reg,
- "VIDIOC_DBG_S_REGISTER") == 0)
- printf("register 0x%llx set to 0x%llx\n", set_reg.reg, set_reg.val);
+ "VIDIOC_DBG_S_REGISTER") >= 0) {
+ const char *name = reg_name(curr_bd, set_reg.reg);
+
+ printf("Register ");
+
+ if (name)
+ printf("%s (0x%08llx)", name, set_reg.reg);
+ else
+ printf("0x%08llx", set_reg.reg);
+
+ printf(" set to 0x%llx\n", set_reg.val);
+ } else {
+ printf("Failed to set register 0x%08llx value 0x%llx\n",
+ set_reg.reg, set_reg.val);
+ }
set_reg.reg++;
}
}
@@ -582,9 +648,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 (0x%08llx)", name, get_reg.reg);
+ else
+ printf("0x%08llx", get_reg.reg);
+
+ printf(" = %llxh (%lldd %sb)\n",
get_reg.val, get_reg.val, binary(get_reg.val));
+ }
}
}
@@ -593,6 +669,7 @@ int main(int argc, char **argv)
get_reg.match_type = match_type;
get_reg.match_chip = match_chip;
+
if (forcedstride) {
stride = forcedstride;
} else {
@@ -601,6 +678,43 @@ int main(int argc, char **argv)
}
printf("ioctl: VIDIOC_DBG_G_REGISTER\n");
+ if (curr_bd) {
+ if (reg_min_arg.empty())
+ reg_min = 0;
+ else
+ reg_min = parse_reg(curr_bd, reg_min_arg);
+
+
+ if (reg_max_arg.empty())
+ reg_max = 1<<31 - 1;
+ else
+ reg_max = parse_reg(curr_bd, reg_max_arg);
+
+ for (int i = 0; i < curr_bd->regs_size; i++) {
+ if (reg_min_arg.empty() || ((curr_bd->regs[i].reg >= reg_min) && curr_bd->regs[i].reg <= reg_max)) {
+ get_reg.reg = curr_bd->regs[i].reg;
+
+ 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 {
+ const char *name = reg_name(curr_bd, get_reg.reg);
+
+ printf("Register ");
+
+ if (name)
+ printf("%s (0x%08llx)", name, get_reg.reg);
+ else
+ printf("0x%08llx", get_reg.reg);
+
+ printf(" = %llxh (%lldd %sb)\n",
+ get_reg.val, get_reg.val, binary(get_reg.val));
+ }
+ }
+ }
+ goto list_done;
+ }
+
if (!reg_min_arg.empty()) {
reg_min = parse_reg(curr_bd, reg_min_arg);
if (reg_max_arg.empty())
@@ -611,6 +725,7 @@ int main(int argc, char **argv)
print_regs(fd, &get_reg, reg_min, reg_max, stride);
goto list_done;
}
+
/* try to match the i2c chip */
switch (get_reg.match_chip) {
case I2C_DRIVERID_SAA711X:
@@ -706,9 +821,9 @@ list_done:
else {
printf("Symbols for driver %s:\n", vcap.driver);
for (int i = 0; i < curr_bd->regs_size; i++)
- printf("0x%08x: %s\n", curr_bd->regs[i], curr_bd->regs[i].name);
+ printf("0x%08x: %s\n", curr_bd->regs[i].reg, curr_bd->regs[i].name);
for (int i = 0; i < curr_bd->alt_regs_size; i++)
- printf("0x%08x: %s\n", curr_bd->alt_regs[i], curr_bd->alt_regs[i].name);
+ printf("0x%08x: %s\n", curr_bd->alt_regs[i].reg, curr_bd->alt_regs[i].name);
}
}