diff options
-rw-r--r-- | v4l2-apps/util/bttv-dbg.h | 131 | ||||
-rw-r--r-- | v4l2-apps/util/v4l-board-dbg.c | 82 |
2 files changed, 120 insertions, 93 deletions
diff --git a/v4l2-apps/util/bttv-dbg.h b/v4l2-apps/util/bttv-dbg.h index 3b8e8e50b..02f829773 100644 --- a/v4l2-apps/util/bttv-dbg.h +++ b/v4l2-apps/util/bttv-dbg.h @@ -18,77 +18,80 @@ #define BTTV_IDENT "bttv" +/* Register name prefix */ +#define BTTV_PREFIX "BT848_" + static struct board_regs bt8xx_regs_other[] = { - {0x000, "BT848_DSTATUS", 1}, - {0x054, "BT848_TEST", 1}, - {0x060, "BT848_ADELAY", 1}, - {0x064, "BT848_BDELAY", 1}, - {0x07C, "BT848_SRESET", 1}, - {0x100, "BT848_INT_STAT", 1}, - {0x110, "BT848_I2C", 1}, - {0x11C, "BT848_GPIO_REG_INP", 1}, - {0x120, "BT848_RISC_COUNT", 1}, + {0x000, BTTV_PREFIX "DSTATUS", 1}, + {0x054, BTTV_PREFIX "TEST", 1}, + {0x060, BTTV_PREFIX "ADELAY", 1}, + {0x064, BTTV_PREFIX "BDELAY", 1}, + {0x07C, BTTV_PREFIX "SRESET", 1}, + {0x100, BTTV_PREFIX "INT_STAT", 1}, + {0x110, BTTV_PREFIX "I2C", 1}, + {0x11C, BTTV_PREFIX "GPIO_REG_INP", 1}, + {0x120, BTTV_PREFIX "RISC_COUNT", 1}, /* This is also defined at bt8xx_regs with other name */ - {0x0fc, "BT848_VBI_PACK_DEL_VBI_HDELAY", 1}, + {0x0fc, BTTV_PREFIX "VBI_PACK_DEL_VBI_HDELAY", 1}, }; static struct board_regs bt8xx_regs[] = { - {0x004, "BT848_IFORM", 1}, - {0x008, "BT848_TDEC", 1}, - {0x00C, "BT848_E_CROP", 1}, - {0x08C, "BT848_O_CROP", 1}, - {0x010, "BT848_E_VDELAY_LO", 1}, - {0x090, "BT848_O_VDELAY_LO", 1}, - {0x014, "BT848_E_VACTIVE_LO", 1}, - {0x094, "BT848_O_VACTIVE_LO", 1}, - {0x018, "BT848_E_HDELAY_LO", 1}, - {0x098, "BT848_O_HDELAY_LO", 1}, - {0x01C, "BT848_E_HACTIVE_LO", 1}, - {0x09C, "BT848_O_HACTIVE_LO", 1}, - {0x020, "BT848_E_HSCALE_HI", 1}, - {0x0A0, "BT848_O_HSCALE_HI", 1}, - {0x024, "BT848_E_HSCALE_LO", 1}, - {0x0A4, "BT848_O_HSCALE_LO", 1}, - {0x028, "BT848_BRIGHT", 1}, - {0x02C, "BT848_E_CONTROL", 1}, - {0x0AC, "BT848_O_CONTROL", 1}, - {0x030, "BT848_CONTRAST_LO", 1}, - {0x034, "BT848_SAT_U_LO", 1}, - {0x038, "BT848_SAT_V_LO", 1}, - {0x03C, "BT848_HUE", 1}, - {0x040, "BT848_E_SCLOOP", 1}, - {0x0C0, "BT848_O_SCLOOP", 1}, - {0x048, "BT848_OFORM", 1}, - {0x04C, "BT848_E_VSCALE_HI", 1}, - {0x0CC, "BT848_O_VSCALE_HI", 1}, - {0x050, "BT848_E_VSCALE_LO", 1}, - {0x0D0, "BT848_O_VSCALE_LO", 1}, - {0x068, "BT848_ADC", 1}, - {0x044, "BT848_WC_UP", 1}, - {0x078, "BT848_WC_DOWN", 1}, - {0x06C, "BT848_E_VTC", 1}, - {0x080, "BT848_TGCTRL", 1}, - {0x0EC, "BT848_O_VTC", 1}, - {0x0D4, "BT848_COLOR_FMT", 1}, - {0x0B0, "BT848_VTOTAL_LO", 1}, - {0x0B4, "BT848_VTOTAL_HI", 1}, - {0x0D8, "BT848_COLOR_CTL", 1}, - {0x0DC, "BT848_CAP_CTL", 1}, - {0x0E0, "BT848_VBI_PACK_SIZE", 1}, - {0x0E4, "BT848_VBI_PACK_DEL", 1}, - {0x0E8, "BT848_FCNTR", 1}, + {0x004, BTTV_PREFIX "IFORM", 1}, + {0x008, BTTV_PREFIX "TDEC", 1}, + {0x00C, BTTV_PREFIX "E_CROP", 1}, + {0x08C, BTTV_PREFIX "O_CROP", 1}, + {0x010, BTTV_PREFIX "E_VDELAY_LO", 1}, + {0x090, BTTV_PREFIX "O_VDELAY_LO", 1}, + {0x014, BTTV_PREFIX "E_VACTIVE_LO", 1}, + {0x094, BTTV_PREFIX "O_VACTIVE_LO", 1}, + {0x018, BTTV_PREFIX "E_HDELAY_LO", 1}, + {0x098, BTTV_PREFIX "O_HDELAY_LO", 1}, + {0x01C, BTTV_PREFIX "E_HACTIVE_LO", 1}, + {0x09C, BTTV_PREFIX "O_HACTIVE_LO", 1}, + {0x020, BTTV_PREFIX "E_HSCALE_HI", 1}, + {0x0A0, BTTV_PREFIX "O_HSCALE_HI", 1}, + {0x024, BTTV_PREFIX "E_HSCALE_LO", 1}, + {0x0A4, BTTV_PREFIX "O_HSCALE_LO", 1}, + {0x028, BTTV_PREFIX "BRIGHT", 1}, + {0x02C, BTTV_PREFIX "E_CONTROL", 1}, + {0x0AC, BTTV_PREFIX "O_CONTROL", 1}, + {0x030, BTTV_PREFIX "CONTRAST_LO", 1}, + {0x034, BTTV_PREFIX "SAT_U_LO", 1}, + {0x038, BTTV_PREFIX "SAT_V_LO", 1}, + {0x03C, BTTV_PREFIX "HUE", 1}, + {0x040, BTTV_PREFIX "E_SCLOOP", 1}, + {0x0C0, BTTV_PREFIX "O_SCLOOP", 1}, + {0x048, BTTV_PREFIX "OFORM", 1}, + {0x04C, BTTV_PREFIX "E_VSCALE_HI", 1}, + {0x0CC, BTTV_PREFIX "O_VSCALE_HI", 1}, + {0x050, BTTV_PREFIX "E_VSCALE_LO", 1}, + {0x0D0, BTTV_PREFIX "O_VSCALE_LO", 1}, + {0x068, BTTV_PREFIX "ADC", 1}, + {0x044, BTTV_PREFIX "WC_UP", 1}, + {0x078, BTTV_PREFIX "WC_DOWN", 1}, + {0x06C, BTTV_PREFIX "E_VTC", 1}, + {0x080, BTTV_PREFIX "TGCTRL", 1}, + {0x0EC, BTTV_PREFIX "O_VTC", 1}, + {0x0D4, BTTV_PREFIX "COLOR_FMT", 1}, + {0x0B0, BTTV_PREFIX "VTOTAL_LO", 1}, + {0x0B4, BTTV_PREFIX "VTOTAL_HI", 1}, + {0x0D8, BTTV_PREFIX "COLOR_CTL", 1}, + {0x0DC, BTTV_PREFIX "CAP_CTL", 1}, + {0x0E0, BTTV_PREFIX "VBI_PACK_SIZE", 1}, + {0x0E4, BTTV_PREFIX "VBI_PACK_DEL", 1}, + {0x0E8, BTTV_PREFIX "FCNTR", 1}, - {0x0F0, "BT848_PLL_F_LO", 1}, - {0x0F4, "BT848_PLL_F_HI", 1}, - {0x0F8, "BT848_PLL_XCI", 1}, + {0x0F0, BTTV_PREFIX "PLL_F_LO", 1}, + {0x0F4, BTTV_PREFIX "PLL_F_HI", 1}, + {0x0F8, BTTV_PREFIX "PLL_XCI", 1}, - {0x0FC, "BT848_DVSIF", 1}, + {0x0FC, BTTV_PREFIX "DVSIF", 1}, - {0x104, "BT848_INT_MASK", 4}, - {0x10C, "BT848_GPIO_DMA_CTL", 2}, - {0x114, "BT848_RISC_STRT_ADD", 4}, - {0x118, "BT848_GPIO_OUT_EN", 4}, - {0x11a, "BT848_GPIO_OUT_EN_HIBYTE", 4}, - {0x200, "BT848_GPIO_DATA", 4}, + {0x104, BTTV_PREFIX "INT_MASK", 4}, + {0x10C, BTTV_PREFIX "GPIO_DMA_CTL", 2}, + {0x114, BTTV_PREFIX "RISC_STRT_ADD", 4}, + {0x118, BTTV_PREFIX "GPIO_OUT_EN", 4}, + {0x11a, BTTV_PREFIX "GPIO_OUT_EN_HIBYTE", 4}, + {0x200, BTTV_PREFIX "GPIO_DATA", 4}, }; diff --git a/v4l2-apps/util/v4l-board-dbg.c b/v4l2-apps/util/v4l-board-dbg.c index 9d27ed8e1..468b03089 100644 --- a/v4l2-apps/util/v4l-board-dbg.c +++ b/v4l2-apps/util/v4l-board-dbg.c @@ -30,6 +30,26 @@ #define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) +struct board_list { + char *queryname; + int prefix; /* Register prefix size */ + struct board_regs *regs; + int regs_size; + struct board_regs *alt_regs; + int alt_regs_size; +}; + +struct board_list boards[] = { + [0] = { /* From bttv-dbg.h */ + .queryname = 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), + }, +}; + static int is_get=0, is_set=0; static int doioctl(int fd, int request, void *parm, const char *name) @@ -86,6 +106,8 @@ int main(int argc, char **argv) int i; int fd = -1; struct v4l2_register reg; + struct board_list *curr_bd; + int board = 0; struct option long_options[] = { /* Please keep in alphabetical order of the short option. That makes it easier to see which options are still free. */ @@ -95,6 +117,9 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; + /* FIXME: need to check for 'board' */ + curr_bd = &boards[board]; + /* command args */ if (argc == 1) { usage(); @@ -147,16 +172,16 @@ int main(int argc, char **argv) reg.match_chip = 0; if (is_get) { - for (i = 0; i < ARRAY_SIZE(bt8xx_regs); i++) { + for (i = 0; i < curr_bd->regs_size; i++) { char name[256]; - reg.reg = bt8xx_regs[i].reg; + reg.reg = curr_bd->regs[i].reg; if (ioctl(fd, VIDIOC_DBG_G_REGISTER, ®) < 0) { printf("Error while reading\n"); continue; } - sprintf(name, "%s:", bt8xx_regs[i].name); + sprintf(name, "%s:", curr_bd->regs[i].name); - switch (bt8xx_regs[i].size) { + switch (curr_bd->regs[i].size) { case 1: printf("%-32s %02llx ", name, reg.val & 0xff); break; @@ -167,7 +192,7 @@ int main(int argc, char **argv) printf("%-32s %08llx ", name, reg.val & 0xffffffff); break; } - print_bin (reg.val, bt8xx_regs[i].size); + print_bin (reg.val, curr_bd->regs[i].size); printf("\n"); } return 0; @@ -178,7 +203,7 @@ int main(int argc, char **argv) int val; int r, size; unsigned prev; - struct board_regs *bt_reg; + struct board_regs *bd_reg; reg_name = strtok(reg_set, "=:"); val = strtol(strtok(NULL, "=:"), 0L, 0); @@ -189,43 +214,43 @@ int main(int argc, char **argv) } - for (i = ARRAY_SIZE(bt8xx_regs) - 1; i >=0 ; i--) { - if (!strcasecmp(reg_name, bt8xx_regs[i].name)) { - bt_reg = &bt8xx_regs[i]; - r = bt8xx_regs[i].reg; - size = bt8xx_regs[i].size; + for (i = curr_bd->regs_size - 1; i >=0 ; i--) { + if (!strcasecmp(reg_name, curr_bd->regs[i].name)) { + bd_reg = &curr_bd->regs[i]; + r = bd_reg->reg; + size = bd_reg->size; break; } } if (i < 0) { - for (i = ARRAY_SIZE(bt8xx_regs_other) - 1; i >=0 ; i--) { - if (!strcasecmp(reg_name, bt8xx_regs_other[i].name)) { - bt_reg = &bt8xx_regs_other[i]; - r = bt8xx_regs_other[i].reg; - size = bt8xx_regs_other[i].size; + for (i = curr_bd->alt_regs_size - 1; i >=0 ; i--) { + if (!strcasecmp(reg_name, curr_bd->alt_regs[i].name)) { + bd_reg = &curr_bd->alt_regs[i]; + r = bd_reg->reg; + size = bd_reg->size; break; } } } if (i < 0) { - for (i = ARRAY_SIZE(bt8xx_regs) - 1; i >=0 ; i--) { - if (!strcasecmp(reg_name, bt8xx_regs[i].name+6)) { - bt_reg = &bt8xx_regs[i]; - r = bt8xx_regs[i].reg; - size = bt8xx_regs[i].size; + for (i = curr_bd->regs_size - 1; i >=0 ; i--) { + if (!strcasecmp(reg_name, curr_bd->regs[i].name + curr_bd->prefix)) { + bd_reg = &curr_bd->regs[i]; + r = bd_reg->reg; + size = bd_reg->size; break; } } } if (i < 0) { - for (i = ARRAY_SIZE(bt8xx_regs_other) - 1; i >=0 ; i--) { - if (!strcasecmp(reg_name, bt8xx_regs_other[i].name+6)) { - bt_reg = &bt8xx_regs_other[i]; - r = bt8xx_regs_other[i].reg; - size = bt8xx_regs_other[i].size; + for (i = curr_bd->alt_regs_size - 1; i >=0 ; i--) { + if (!strcasecmp(reg_name, curr_bd->alt_regs[i].name + curr_bd->prefix)) { + bd_reg = &curr_bd->regs[i]; + r = bd_reg->reg; + size = bd_reg->size; break; } } @@ -257,7 +282,7 @@ int main(int argc, char **argv) } printf("Changing value of register %s(0x%x) from 0x%02x to 0x%02x\n", - bt_reg->name, r, prev, (unsigned int)reg.val); + bd_reg->name, r, prev, (unsigned int)reg.val); prev = reg.val; @@ -271,9 +296,8 @@ int main(int argc, char **argv) } if (reg.val != prev) { printf("Value of register %s(0x%x) is now 0x%02x\n", - bt_reg->name, r, (unsigned int)reg.val); + bd_reg->name, r, (unsigned int)reg.val); } - } close(fd); |