From 351571009d31ec584cada4c5a8c0707271dea4ed Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 16 Jun 2008 17:41:25 -0300 Subject: v4l-board-dbg: Add support for saa7134 registers From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/util/Makefile | 3 +++ v4l2-apps/util/v4l-board-dbg.c | 31 ++++++++++++++++++++++++++++--- v4l2-apps/util/v4l-board-dbg.h | 3 +++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/v4l2-apps/util/Makefile b/v4l2-apps/util/Makefile index 7c15423b0..64e544225 100644 --- a/v4l2-apps/util/Makefile +++ b/v4l2-apps/util/Makefile @@ -54,6 +54,7 @@ keytables: ./gen_keytables.pl ../../linux/drivers/media/common/ir-keymaps.c keytable: keytable.c parse.h keytables +v4l-board-dbg: v4l-board-dbg.c bttv-dbg.h saa7134-dbg.h v4l2-driverids.cpp: ../../linux/include/linux/i2c-id.h @echo "struct driverid { const char *name; unsigned id; } driverids[] = {" >$@ @@ -64,3 +65,5 @@ v4l2-chipids.cpp: ../../linux/include/media/v4l2-chip-ident.h @echo "struct chipid { const char *name; unsigned id; } chipids[] = {" >$@ @grep V4L2_IDENT_ $^ | sed -e 's/.*V4L2_IDENT_\([0-9A-Z_]*\)[^=]*=[^0-9]*\([0-9]*\).*/{ "\1", \2 },/' | tr A-Z a-z >>$@ @echo "{ 0, 0 }};" >>$@ + + diff --git a/v4l2-apps/util/v4l-board-dbg.c b/v4l2-apps/util/v4l-board-dbg.c index 468b03089..b3a25bce9 100644 --- a/v4l2-apps/util/v4l-board-dbg.c +++ b/v4l2-apps/util/v4l-board-dbg.c @@ -27,11 +27,12 @@ #include #include "bttv-dbg.h" +#include "saa7134-dbg.h" #define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) struct board_list { - char *queryname; + char *name; int prefix; /* Register prefix size */ struct board_regs *regs; int regs_size; @@ -41,13 +42,21 @@ struct board_list { struct board_list boards[] = { [0] = { /* From bttv-dbg.h */ - .queryname = BTTV_IDENT, + .name = BTTV_IDENT, .prefix = sizeof (BTTV_PREFIX), .regs = bt8xx_regs, .regs_size = ARRAY_SIZE(bt8xx_regs), .alt_regs = bt8xx_regs_other, .alt_regs_size = ARRAY_SIZE(bt8xx_regs_other), }, + [1] = { /* From saa7134-dbg.h */ + .name = SAA7134_IDENT, + .prefix = sizeof (SAA7134_PREFIX), + .regs = saa7134_regs, + .regs_size = ARRAY_SIZE(saa7134_regs), + .alt_regs = NULL, + .alt_regs_size = 0, + }, }; static int is_get=0, is_set=0; @@ -106,6 +115,7 @@ int main(int argc, char **argv) int i; int fd = -1; struct v4l2_register reg; + struct v4l2_capability cap; struct board_list *curr_bd; int board = 0; struct option long_options[] = { @@ -118,6 +128,7 @@ int main(int argc, char **argv) }; /* FIXME: need to check for 'board' */ +board=1; curr_bd = &boards[board]; /* command args */ @@ -168,6 +179,20 @@ int main(int argc, char **argv) } free(device); + if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) { + printf("Error while reading capabilities\n"); + exit(2); + } + + for (board = ARRAY_SIZE(boards)-1; board >= 0; board--) { + if (!strcasecmp((char *)cap.driver, boards[board].name)) + break; + } + if (board < 0) { + printf("This software doesn't support %s yet\n", cap.driver); + exit(3); + } + reg.match_type = V4L2_CHIP_MATCH_HOST; reg.match_chip = 0; @@ -176,7 +201,7 @@ int main(int argc, char **argv) char name[256]; reg.reg = curr_bd->regs[i].reg; if (ioctl(fd, VIDIOC_DBG_G_REGISTER, ®) < 0) { - printf("Error while reading\n"); + printf("Error while reading. Maybe you're not root?\n"); continue; } sprintf(name, "%s:", curr_bd->regs[i].name); diff --git a/v4l2-apps/util/v4l-board-dbg.h b/v4l2-apps/util/v4l-board-dbg.h index c5f744f49..5d040812d 100644 --- a/v4l2-apps/util/v4l-board-dbg.h +++ b/v4l2-apps/util/v4l-board-dbg.h @@ -14,8 +14,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _V4L_BOARD_DBG +#define _V4L_BOARD_DBG struct board_regs { unsigned int reg; char *name; int size; }; +#endif \ No newline at end of file -- cgit v1.2.3