From 02070de48e42d30eeb6dfa4ea2d3aeff1a0a980f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 20 Dec 2008 13:14:03 +0100 Subject: v4l2-dbg: get-chip-ident has no arguments From: Hans Verkuil get-chip-ident expected an argument when none was needed. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-dbg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index e0d6153fe..31206a562 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -136,7 +136,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}, -- cgit v1.2.3 From eb7bc99b0b15c28d8d0bd3dd4be26710d03dac2a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 09:36:29 -0200 Subject: v4l2-dbg: fix --list-symbols option From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 31206a562..c1e107de1 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -706,9 +706,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); } } -- cgit v1.2.3 From d0dd746a466cef43b09aba57033f390dcc417967 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 09:53:53 -0200 Subject: v4l2-dbg: print register name when known From: Mauro Carvalho Chehab Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') 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)); + } } } -- cgit v1.2.3 From 585b4e51209e77b24d2d03f4dd30af1ec34e9002 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 10:17:16 -0200 Subject: v4l2-dbg: print register name and fix doioctl check From: Mauro Carvalho Chehab Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 87044e851..620702858 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -549,8 +549,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", name); + 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++; } } -- cgit v1.2.3 From b041d4c5cfa27296e25d7719299bb0e745fc45cf Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 10:19:13 -0200 Subject: v4l2-dbg: print also register number when name is available From: Mauro Carvalho Chehab Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 620702858..1841e677b 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -555,7 +555,7 @@ int main(int argc, char **argv) printf("Register "); if (name) - printf("%s", name); + printf("%s (0x%08llx)", name, set_reg.reg); else printf("0x%08llx", set_reg.reg); @@ -616,7 +616,7 @@ int main(int argc, char **argv) printf("Register "); if (name) - printf("%s", name); + printf("%s (0x%08llx)", name, get_reg.reg); else printf("0x%08llx", get_reg.reg); -- cgit v1.2.3 From 71447659e72af9641c95885d7b92a568e7ce8dfc Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 10:22:42 -0200 Subject: v4l2-dbg: em2800 registers are not very common nowadays. Use it as alternate names From: Mauro Carvalho Chehab Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 1841e677b..dfeae8cea 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -79,8 +79,8 @@ static const struct board_list boards[] = { sizeof(EM28XX_PREFIX) - 1, em28xx_regs, ARRAY_SIZE(em28xx_regs), - NULL, - 0, + em28xx_alt_regs, + ARRAY_SIZE(em28xx_alt_regs), }, }; -- cgit v1.2.3 From 1d183a32a6fbcd8812f35d0eeca02347de4223bf Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 14:49:07 -0200 Subject: em28xx: update regiters on v4l2-dbg debug util From: Mauro Carvalho Chehab Some ac97 registers where presented as if they are em28xx ones. Also, add mising em2874 registers. The code were generated by the following command: $ more em28xx-reg.h |perl -ne 'if (m/(EM2[A-Z0-9]..)_R.._([^\s]+)\s+(0x[0-9A-Fa-f].)/) { printf "\t{$3, $1_PREFIX \"$2\", 1},\n"; }' |grep -v EM2800_PREFIX|sort >/tmp/registers Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index dfeae8cea..e05be1f03 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -158,6 +158,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: host chip number \n" " host (default): same as host0\n" " -l, --list-registers[=min=[,max=]]\n" @@ -448,6 +449,11 @@ int main(int argc, char **argv) match_chip = strtoul(optarg + 4, NULL, 0); break; } + if (!strcasecmp(optarg, "ac97")) { + match_type = V4L2_CHIP_MATCH_AC97; + match_chip = strtoul(optarg + 4, NULL, 0); + break; + } match_type = V4L2_CHIP_MATCH_I2C_DRIVER; match_chip = parse_chip(optarg); if (!match_chip) { -- cgit v1.2.3 From 5b8cbae207001dd7cd7e4a4f09a987b4194d0a8f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 15:06:33 -0200 Subject: v4l2-dbg: Add support for get/set ac97 registers From: Mauro Carvalho Chehab em28xx devices can have an ac97 anciliary chip. This patch allows get/set ac97 registers Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index e05be1f03..412d3bea5 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -45,6 +45,7 @@ #include "v4l2-dbg-bttv.h" #include "v4l2-dbg-saa7134.h" #include "v4l2-dbg-em28xx.h" +#include "v4l2-dbg-ac97.h" #define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) @@ -58,6 +59,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, @@ -451,7 +461,6 @@ int main(int argc, char **argv) } if (!strcasecmp(optarg, "ac97")) { match_type = V4L2_CHIP_MATCH_AC97; - match_chip = strtoul(optarg + 4, NULL, 0); break; } match_type = V4L2_CHIP_MATCH_I2C_DRIVER; @@ -537,10 +546,14 @@ 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 { + for (int board = ARRAY_SIZE(boards) - 1; board >= 0; board--) { + if (!strcasecmp((char *)vcap.driver, boards[board].name)) { + curr_bd = &boards[board]; + break; + } } } -- cgit v1.2.3 From 508d4c2d232f61a3ffc92c05bee7a9afe7559081 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 16:01:46 -0200 Subject: v4l2-dbg: Use aliases for debug, on available chips From: Mauro Carvalho Chehab Priority: normal Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 412d3bea5..c7ef1206b 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -487,6 +487,7 @@ int main(int argc, char **argv) subs = optarg; if (subs == NULL) break; + while (*subs != '\0') { static const char * const subopts[] = { "min", @@ -658,6 +659,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()) @@ -668,6 +706,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: -- cgit v1.2.3 From 43e99e5ec6d0b7bc9249119867ff553cba80b0ee Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Dec 2008 22:00:03 -0200 Subject: v4l2-dbg: allow debug tvp5150 registers From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/v4l2-dbg.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index c7ef1206b..577c8585e 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -46,6 +46,7 @@ #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]))) @@ -92,6 +93,14 @@ static const struct board_list boards[] = { 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, + }, }; struct driverid { @@ -406,6 +415,7 @@ int main(int argc, char **argv) std::vector 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)); @@ -464,6 +474,7 @@ int main(int argc, char **argv) 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); @@ -549,13 +560,20 @@ int main(int argc, char **argv) if (match_type == V4L2_CHIP_MATCH_AC97) { curr_bd = &boards[AC97_BOARD]; - } else { + } 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; + } + } } /* Set options */ @@ -651,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 { -- cgit v1.2.3 From 1b466c7ec5d6b66905c47c49fd3cbc59569e7b4e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 30 Dec 2008 11:14:19 +0100 Subject: v4l2: debugging API changed to match against driver name instead of ID. From: Hans Verkuil Since the i2c driver ID will be removed in the near future we have to modify the v4l2 debugging API to use the driver name instead of driver ID. Note that this API is not used in applications other than v4l2-dbg.cpp as it is for debugging and testing only. Should anyone use the old VIDIOC_G_CHIP_IDENT, then this will be logged with a warning that it is deprecated and will be removed in 2.6.30. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-dbg.cpp | 177 +++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 109 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index 577c8585e..b38d18cf0 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -103,13 +103,6 @@ static const struct board_list boards[] = { }, }; -struct driverid { - const char *name; - unsigned id; -}; - -extern struct driverid driverids[]; - struct chipid { const char *name; unsigned id; @@ -138,7 +131,6 @@ enum Option { OptLogStatus = 128, OptVerbose, - OptListDriverIDs, OptListSymbols, OptLast = 256 }; @@ -159,7 +151,6 @@ static struct option long_options[] = { {"info", no_argument, 0, OptGetDriverInfo}, {"verbose", no_argument, 0, OptVerbose}, {"log-status", no_argument, 0, OptLogStatus}, - {"list-driverids", no_argument, 0, OptListDriverIDs}, {"list-symbols", no_argument, 0, OptListSymbols}, {"wide", required_argument, 0, OptSetStride}, {0, 0, 0, 0} @@ -175,7 +166,7 @@ static void usage(void) " --verbose Turn on verbose ioctl error reporting\n" " -c, --chip= The chip identifier to use with other commands\n" " It can be one of:\n" - " I2C driver ID (see --list-driverids)\n" + " I2C driver name\n" " I2C 7-bit address\n" " AC97: for ac97 anciliary mixer\n" " host: host chip number \n" @@ -188,25 +179,16 @@ static void usage(void) " Set the register with the commandline arguments\n" " The register will autoincrement [VIDIOC_DBG_S_REGISTER]\n" " -S, --scan-chip-idents\n" - " Scan the available host and i2c chips [VIDIOC_G_CHIP_IDENT]\n" + " Scan the available host and i2c chips [VIDIOC_DBG_G_CHIP_IDENT]\n" " -i, --get-chip-ident\n" - " Get the chip identifier [VIDIOC_G_CHIP_IDENT]\n" + " Get the chip identifier [VIDIOC_DBG_G_CHIP_IDENT]\n" " -w, --wide=\n" " Sets step between two registers\n" " --list-symbols List the symbolic register names you can use, if any\n" - " --log-status Log the board status in the kernel log [VIDIOC_LOG_STATUS]\n" - " --list-driverids List the known I2C driver IDs for use with the i2cdrv type\n"); + " --log-status Log the board status in the kernel log [VIDIOC_LOG_STATUS]\n"); exit(0); } -static unsigned parse_chip(const std::string &s) -{ - for (int i = 0; driverids[i].name; i++) - if (!strcasecmp(s.c_str(), driverids[i].name)) - return driverids[i].id; - return 0; -} - static std::string cap2s(unsigned cap) { std::string s; @@ -244,7 +226,7 @@ static std::string cap2s(unsigned cap) return s; } -static void print_regs(int fd, struct v4l2_register *reg, unsigned long min, unsigned long max, int stride) +static void print_regs(int fd, struct v4l2_dbg_register *reg, unsigned long min, unsigned long max, int stride) { unsigned long mask = stride > 1 ? 0x1f : 0x0f; unsigned long i; @@ -278,7 +260,7 @@ static void print_regs(int fd, struct v4l2_register *reg, unsigned long min, uns printf("\n"); } -static void print_chip(struct v4l2_chip_ident *chip) +static void print_chip(struct v4l2_dbg_chip_ident *chip) { const char *name = NULL; @@ -403,9 +385,9 @@ int main(int argc, char **argv) int ch; const char *device = "/dev/video0"; /* -d device */ struct v4l2_capability vcap; /* list_cap */ - struct v4l2_register set_reg; - struct v4l2_register get_reg; - struct v4l2_chip_ident chip_id; + struct v4l2_dbg_register set_reg; + struct v4l2_dbg_register get_reg; + struct v4l2_dbg_chip_ident chip_id; const struct board_list *curr_bd = NULL; char short_options[26 * 2 * 2 + 1]; int idx = 0; @@ -413,10 +395,11 @@ int main(int argc, char **argv) std::string reg_set_arg; unsigned long long reg_min = 0, reg_max = 0; std::vector get_regs; - int match_type = V4L2_CHIP_MATCH_HOST; - int match_chip = 0; char driver[255]; + struct v4l2_dbg_match match; + match.type = V4L2_CHIP_MATCH_HOST; + match.addr = 0; memset(&set_reg, 0, sizeof(set_reg)); memset(&get_reg, 0, sizeof(get_reg)); memset(&chip_id, 0, sizeof(chip_id)); @@ -460,26 +443,23 @@ int main(int argc, char **argv) case OptChip: if (isdigit(optarg[0])) { - match_type = V4L2_CHIP_MATCH_I2C_ADDR; - match_chip = strtoul(optarg, NULL, 0); + match.type = V4L2_CHIP_MATCH_I2C_ADDR; + match.addr = strtoul(optarg, NULL, 0); break; } if (!memcmp(optarg, "host", 4)) { - match_type = V4L2_CHIP_MATCH_HOST; - match_chip = strtoul(optarg + 4, NULL, 0); + match.type = V4L2_CHIP_MATCH_HOST; + match.addr = strtoul(optarg + 4, NULL, 0); break; } if (!strcasecmp(optarg, "ac97")) { - match_type = V4L2_CHIP_MATCH_AC97; + match.type = V4L2_CHIP_MATCH_AC97; + match.addr = 0; 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); - exit(-1); - } + match.type = V4L2_CHIP_MATCH_I2C_DRIVER; + strncpy(match.name, optarg, sizeof(match.name)); + match.name[sizeof(match.name) - 1] = '\0'; break; case OptSetRegister: @@ -558,16 +538,16 @@ int main(int argc, char **argv) printf("%s", cap2s(vcap.capabilities).c_str()); } - if (match_type == V4L2_CHIP_MATCH_AC97) { + if (match.type == V4L2_CHIP_MATCH_AC97) { curr_bd = &boards[AC97_BOARD]; - } else if (match_type == V4L2_CHIP_MATCH_HOST) { + } 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) { + } 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]; @@ -579,8 +559,7 @@ int main(int argc, char **argv) /* Set options */ if (options[OptSetRegister]) { - set_reg.match_type = match_type; - set_reg.match_chip = match_chip; + set_reg.match = match; if (optind >= argc) usage(); set_reg.reg = parse_reg(curr_bd, reg_set_arg); @@ -607,28 +586,27 @@ int main(int argc, char **argv) } if (options[OptGetChipIdent]) { - chip_id.match_type = match_type; - chip_id.match_chip = match_chip; - if (doioctl(fd, VIDIOC_G_CHIP_IDENT, &chip_id, "VIDIOC_G_CHIP_IDENT") == 0) + chip_id.match = match; + if (doioctl(fd, VIDIOC_DBG_G_CHIP_IDENT, &chip_id, "VIDIOC_DBG_G_CHIP_IDENT") == 0) print_chip(&chip_id); } if (options[OptScanChipIdents]) { int i; - chip_id.match_type = V4L2_CHIP_MATCH_HOST; - chip_id.match_chip = 0; + chip_id.match.type = V4L2_CHIP_MATCH_HOST; + chip_id.match.addr = 0; - while (doioctl(fd, VIDIOC_G_CHIP_IDENT, &chip_id, "VIDIOC_G_CHIP_IDENT") == 0 && chip_id.ident) { - printf("host%d: ", chip_id.match_chip); + while (doioctl(fd, VIDIOC_DBG_G_CHIP_IDENT, &chip_id, "VIDIOC_DBG_G_CHIP_IDENT") == 0 && chip_id.ident) { + printf("host%d: ", chip_id.match.addr); print_chip(&chip_id); - chip_id.match_chip++; + chip_id.match.addr++; } - chip_id.match_type = V4L2_CHIP_MATCH_I2C_ADDR; + chip_id.match.type = V4L2_CHIP_MATCH_I2C_ADDR; for (i = 0; i < 128; i++) { - chip_id.match_chip = i; - if (doioctl(fd, VIDIOC_G_CHIP_IDENT, &chip_id, "VIDIOC_G_CHIP_IDENT") == 0 && chip_id.ident) { + chip_id.match.addr = i; + if (doioctl(fd, VIDIOC_DBG_G_CHIP_IDENT, &chip_id, "VIDIOC_DBG_G_CHIP_IDENT") == 0 && chip_id.ident) { printf("i2c 0x%02x: ", i); print_chip(&chip_id); } @@ -638,8 +616,7 @@ int main(int argc, char **argv) if (options[OptGetRegister]) { int stride = 1; - get_reg.match_type = match_type; - get_reg.match_chip = match_chip; + get_reg.match = match; printf("ioctl: VIDIOC_DBG_G_REGISTER\n"); for (std::vector::iterator iter = get_regs.begin(); @@ -665,16 +642,14 @@ int main(int argc, char **argv) } if (options[OptListRegisters]) { + std::string name; int stride = 1; - get_reg.match_type = match_type; - get_reg.match_chip = match_chip; - + get_reg.match = match; if (forcedstride) { stride = forcedstride; - } else { - if (get_reg.match_type == V4L2_CHIP_MATCH_HOST) - stride = 4; + } else if (get_reg.match.type == V4L2_CHIP_MATCH_HOST) { + stride = 4; } printf("ioctl: VIDIOC_DBG_G_REGISTER\n"); @@ -726,57 +701,47 @@ int main(int argc, char **argv) goto list_done; } - /* try to match the i2c chip */ - switch (get_reg.match_chip) { - case I2C_DRIVERID_SAA711X: - print_regs(fd, &get_reg, 0, 0xff, stride); + /* try to figure out which chip it is */ + chip_id.match = match; + if (doioctl(fd, VIDIOC_DBG_G_CHIP_IDENT, &chip_id, "VIDIOC_DBG_G_CHIP_IDENT") != 0) { + chip_id.ident = V4L2_IDENT_NONE; + } + switch (chip_id.ident) { + case V4L2_IDENT_CX23415: + case V4L2_IDENT_CX23416: + name = "cx23416"; + break; + case V4L2_IDENT_CX23418: + name = "cx23418"; break; - case I2C_DRIVERID_SAA717X: + default: + if (get_reg.match.type == V4L2_CHIP_MATCH_I2C_DRIVER) + name = get_reg.match.name; + break; + } + + if (name == "saa7115") { + print_regs(fd, &get_reg, 0, 0xff, stride); + } else if (name == "saa717x") { // FIXME: use correct reg regions print_regs(fd, &get_reg, 0, 0xff, stride); - break; - case I2C_DRIVERID_SAA7127: + } else if (name == "saa7127") { print_regs(fd, &get_reg, 0, 0x7f, stride); - break; - case I2C_DRIVERID_CX25840: + } else if (name == "cx25840") { print_regs(fd, &get_reg, 0, 2, stride); print_regs(fd, &get_reg, 0x100, 0x15f, stride); print_regs(fd, &get_reg, 0x200, 0x23f, stride); print_regs(fd, &get_reg, 0x400, 0x4bf, stride); print_regs(fd, &get_reg, 0x800, 0x9af, stride); - break; - case I2C_DRIVERID_CS5345: + } else if (name == "cs5345") { print_regs(fd, &get_reg, 1, 0x10, stride); - break; - case 0: - /* host chip, handle later */ - break; - default: - /* unknown i2c chip, dump 0-0xff by default */ - print_regs(fd, &get_reg, 0, 0xff, stride); - break; - } - if (get_reg.match_chip != 0) { - /* found i2c chip, we're done */ - goto list_done; - } - /* try to figure out which host chip it is */ - if (doioctl(fd, VIDIOC_G_CHIP_IDENT, &chip_id, "VIDIOC_G_CHIP_IDENT") != 0) { - chip_id.ident = V4L2_IDENT_NONE; - } - - switch (chip_id.ident) { - case V4L2_IDENT_CX23415: - case V4L2_IDENT_CX23416: + } else if (name == "cx23416") { print_regs(fd, &get_reg, 0x02000000, 0x020000ff, stride); - break; - case V4L2_IDENT_CX23418: + } else if (name == "cx23418") { print_regs(fd, &get_reg, 0x02c40000, 0x02c409c7, stride); - break; - default: - /* By default print range 0-0xff */ + } else { + /* unknown chip, dump 0-0xff by default */ print_regs(fd, &get_reg, 0, 0xff, stride); - break; } } list_done: @@ -808,12 +773,6 @@ list_done: } } - if (options[OptListDriverIDs]) { - printf("Known I2C driver IDs:\n"); - for (int i = 0; driverids[i].name; i++) - printf("%s\n", driverids[i].name); - } - if (options[OptListSymbols]) { if (curr_bd == NULL) { printf("No symbols found for driver %s\n", vcap.driver); -- cgit v1.2.3 From b50e38700408ec0bb073fc56ade123a1305842b6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 23 Dec 2008 15:58:55 +0100 Subject: v4l2-dbg: fix --list-symbols From: Hans Verkuil --list-symbols didn't work for i2c drivers anymore. Priority: normal Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-dbg.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/util/v4l2-dbg.cpp') diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp index b38d18cf0..f427d4442 100644 --- a/v4l2-apps/util/v4l2-dbg.cpp +++ b/v4l2-apps/util/v4l2-dbg.cpp @@ -395,7 +395,6 @@ int main(int argc, char **argv) std::string reg_set_arg; unsigned long long reg_min = 0, reg_max = 0; std::vector get_regs; - char driver[255]; struct v4l2_dbg_match match; match.type = V4L2_CHIP_MATCH_HOST; @@ -549,7 +548,7 @@ int main(int argc, char **argv) } } 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)) { + if (!strcasecmp(match.name, boards[board].name)) { curr_bd = &boards[board]; break; } @@ -778,7 +777,7 @@ list_done: printf("No symbols found for driver %s\n", vcap.driver); } else { - printf("Symbols for driver %s:\n", vcap.driver); + printf("Symbols for driver %s:\n", curr_bd->name); for (int i = 0; i < curr_bd->regs_size; i++) 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++) -- cgit v1.2.3