summaryrefslogtreecommitdiff
path: root/v4l2-apps/util
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps/util')
-rw-r--r--v4l2-apps/util/Makefile14
-rw-r--r--v4l2-apps/util/bttv-dbg.h97
-rw-r--r--v4l2-apps/util/em28xx-dbg.h84
-rw-r--r--v4l2-apps/util/saa7134-dbg.h141
-rw-r--r--v4l2-apps/util/v4l-board-dbg.c335
-rw-r--r--v4l2-apps/util/v4l-board-dbg.h24
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp16
-rw-r--r--v4l2-apps/util/v4l2-dbg.cpp2
8 files changed, 705 insertions, 8 deletions
diff --git a/v4l2-apps/util/Makefile b/v4l2-apps/util/Makefile
index cc0547c32..873553a95 100644
--- a/v4l2-apps/util/Makefile
+++ b/v4l2-apps/util/Makefile
@@ -1,9 +1,13 @@
# Makefile for linuxtv.org v4l2-apps/util
+ifeq ($(KERNEL_DIR),)
+ KERNEL_DIR = /usr
+endif
+
CPPFLAGS += -I../../linux/include -D_GNU_SOURCE
LDFLAGS += -lm
-binaries = v4l2-ctl v4l2-dbg ivtv-ctl cx18-ctl
+binaries = v4l2-ctl v4l2-dbg ivtv-ctl cx18-ctl v4l-board-dbg
ifeq ($(prefix),)
prefix = /usr
@@ -32,12 +36,12 @@ install:
include ../Make.rules
-parse.h: /usr/include/linux/input.h
+parse.h: $(KERNEL_DIR)/include/linux/input.h
@echo generating parse.h
@echo -en "struct parse_key {\n\tchar *name;\n\tunsigned int value;\n} " >parse.h
@echo -en "keynames[] = {\n" >>parse.h
- @more /usr/include/linux/input.h |perl -n \
+ @more $(KERNEL_DIR)/linux/input.h |perl -n \
-e 'if (m/^\#define\s+(KEY_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
-e '{ printf "\t{\"%s\", %s},\n",$$1,$$2; }' \
-e 'if (m/^\#define\s+(BTN_[^\s]+)\s+(0x[\d\w]+|[\d]+)/) ' \
@@ -51,6 +55,8 @@ keytables:
keytable: keytable.c parse.h keytables
+v4l-board-dbg: v4l-board-dbg.c bttv-dbg.h saa7134-dbg.h em28xx-dbg.h
+
v4l2-driverids.cpp: ../../linux/include/linux/i2c-id.h
@echo "struct driverid { const char *name; unsigned id; } driverids[] = {" >$@
@grep I2C_DRIVERID_ $^ | sed -e 's/.*I2C_DRIVERID_\([0-9A-Z_]*\)[^0-9]*\([0-9]*\).*/{ "\1", \2 },/' | tr A-Z a-z >>$@
@@ -60,3 +66,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/bttv-dbg.h b/v4l2-apps/util/bttv-dbg.h
new file mode 100644
index 000000000..02f829773
--- /dev/null
+++ b/v4l2-apps/util/bttv-dbg.h
@@ -0,0 +1,97 @@
+/*
+ Copyright (C) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "v4l-board-dbg.h"
+
+#define BTTV_IDENT "bttv"
+
+/* Register name prefix */
+#define BTTV_PREFIX "BT848_"
+
+static struct board_regs bt8xx_regs_other[] = {
+ {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, BTTV_PREFIX "VBI_PACK_DEL_VBI_HDELAY", 1},
+};
+
+static struct board_regs bt8xx_regs[] = {
+ {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, BTTV_PREFIX "PLL_F_LO", 1},
+ {0x0F4, BTTV_PREFIX "PLL_F_HI", 1},
+ {0x0F8, BTTV_PREFIX "PLL_XCI", 1},
+
+ {0x0FC, BTTV_PREFIX "DVSIF", 1},
+
+ {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/em28xx-dbg.h b/v4l2-apps/util/em28xx-dbg.h
new file mode 100644
index 000000000..d2edc60bc
--- /dev/null
+++ b/v4l2-apps/util/em28xx-dbg.h
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "v4l-board-dbg.h"
+
+#define EM28XX_IDENT "em28xx"
+
+/* Register name prefix */
+#define EM2800_PREFIX "EM2800_"
+#define EM2880_PREFIX "EM2880_"
+#define EM28XX_PREFIX "EM28XX_"
+
+static struct board_regs em28xx_regs[] = {
+ {0x08, EM2800_PREFIX "AUDIOSRC", 1},
+ {0x04, EM2880_PREFIX "GPO", 1},
+ {0x08, EM28XX_PREFIX "GPIO", 1},
+
+ {0x06, EM28XX_PREFIX "I2C_CLK", 1},
+ {0x0a, EM28XX_PREFIX "CHIPID", 1},
+ {0x0c, EM28XX_PREFIX "USBSUSP", 1},
+
+ {0x0e, EM28XX_PREFIX "AUDIOSRC", 1},
+ {0x0f, EM28XX_PREFIX "XCLK", 1},
+
+ {0x10, EM28XX_PREFIX "VINMODE", 1},
+ {0x11, EM28XX_PREFIX "VINCTRL", 1},
+ {0x12, EM28XX_PREFIX "VINENABLE", 1},
+
+ {0x14, EM28XX_PREFIX "GAMMA", 1},
+ {0x15, EM28XX_PREFIX "RGAIN", 1},
+ {0x16, EM28XX_PREFIX "GGAIN", 1},
+ {0x17, EM28XX_PREFIX "BGAIN", 1},
+ {0x18, EM28XX_PREFIX "ROFFSET", 1},
+ {0x19, EM28XX_PREFIX "GOFFSET", 1},
+ {0x1a, EM28XX_PREFIX "BOFFSET", 1},
+
+ {0x1b, EM28XX_PREFIX "OFLOW", 1},
+ {0x1c, EM28XX_PREFIX "HSTART", 1},
+ {0x1d, EM28XX_PREFIX "VSTART", 1},
+ {0x1e, EM28XX_PREFIX "CWIDTH", 1},
+ {0x1f, EM28XX_PREFIX "CHEIGHT", 1},
+
+ {0x20, EM28XX_PREFIX "YGAIN", 1},
+ {0x21, EM28XX_PREFIX "YOFFSET", 1},
+ {0x22, EM28XX_PREFIX "UVGAIN", 1},
+ {0x23, EM28XX_PREFIX "UOFFSET", 1},
+ {0x24, EM28XX_PREFIX "VOFFSET", 1},
+ {0x25, EM28XX_PREFIX "SHARPNESS", 1},
+
+ {0x26, EM28XX_PREFIX "COMPR", 1},
+ {0x27, EM28XX_PREFIX "OUTFMT", 1},
+
+ {0x28, EM28XX_PREFIX "XMIN", 1},
+ {0x29, EM28XX_PREFIX "XMAX", 1},
+ {0x2a, EM28XX_PREFIX "YMIN", 1},
+ {0x2b, EM28XX_PREFIX "YMAX", 1},
+
+ {0x30, EM28XX_PREFIX "HSCALELOW", 1},
+ {0x31, EM28XX_PREFIX "HSCALEHIGH", 1},
+ {0x32, EM28XX_PREFIX "VSCALELOW", 1},
+ {0x33, EM28XX_PREFIX "VSCALEHIGH", 1},
+
+ {0x40, EM28XX_PREFIX "AC97LSB", 1},
+ {0x41, EM28XX_PREFIX "AC97MSB", 1},
+ {0x42, EM28XX_PREFIX "AC97ADDR", 1},
+ {0x43, EM28XX_PREFIX "AC97BUSY", 1},
+
+ {0x02, EM28XX_PREFIX "MASTER_AC97", 1},
+ {0x10, EM28XX_PREFIX "LINE_IN_AC97", 1},
+ {0x14, EM28XX_PREFIX "VIDEO_AC97", 1},
+}; \ No newline at end of file
diff --git a/v4l2-apps/util/saa7134-dbg.h b/v4l2-apps/util/saa7134-dbg.h
new file mode 100644
index 000000000..aee29da76
--- /dev/null
+++ b/v4l2-apps/util/saa7134-dbg.h
@@ -0,0 +1,141 @@
+/*
+ Copyright (C) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "v4l-board-dbg.h"
+
+#define SAA7134_IDENT "saa7134"
+
+/* Register name prefix */
+#define SAA7134_PREFIX "SAA7134_"
+#define SAA7135_PREFIX "SAA7135_"
+#define SAA7133_PREFIX "SAA7133_"
+
+static struct board_regs saa7134_regs[] = {
+ {0x101, SAA7134_PREFIX "INCR_DELAY", 1},
+ {0x102, SAA7134_PREFIX "ANALOG_IN_CTRL1", 1},
+ {0x103, SAA7134_PREFIX "ANALOG_IN_CTRL2", 1},
+ {0x104, SAA7134_PREFIX "ANALOG_IN_CTRL3", 1},
+ {0x105, SAA7134_PREFIX "ANALOG_IN_CTRL4", 1},
+ {0x106, SAA7134_PREFIX "HSYNC_START", 1},
+ {0x107, SAA7134_PREFIX "HSYNC_STOP", 1},
+ {0x108, SAA7134_PREFIX "SYNC_CTRL", 1},
+ {0x109, SAA7134_PREFIX "LUMA_CTRL", 1},
+ {0x10a, SAA7134_PREFIX "DEC_LUMA_BRIGHT", 1},
+ {0x10b, SAA7134_PREFIX "DEC_LUMA_CONTRAST", 1},
+ {0x10c, SAA7134_PREFIX "DEC_CHROMA_SATURATION", 1},
+ {0x10d, SAA7134_PREFIX "DEC_CHROMA_HUE", 1},
+ {0x10e, SAA7134_PREFIX "CHROMA_CTRL1", 1},
+ {0x10f, SAA7134_PREFIX "CHROMA_GAIN", 1},
+ {0x110, SAA7134_PREFIX "CHROMA_CTRL2", 1},
+ {0x111, SAA7134_PREFIX "MODE_DELAY_CTRL", 1},
+ {0x114, SAA7134_PREFIX "ANALOG_ADC", 1},
+ {0x115, SAA7134_PREFIX "VGATE_START", 1},
+ {0x116, SAA7134_PREFIX "VGATE_STOP", 1},
+ {0x117, SAA7134_PREFIX "MISC_VGATE_MSB", 1},
+ {0x118, SAA7134_PREFIX "RAW_DATA_GAIN", 1},
+ {0x119, SAA7134_PREFIX "RAW_DATA_OFFSET", 1},
+ {0x11e, SAA7134_PREFIX "STATUS_VIDEO1", 1},
+ {0x11f, SAA7134_PREFIX "STATUS_VIDEO2", 1},
+ {0x300, SAA7134_PREFIX "OFMT_VIDEO_A", 1},
+ {0x301, SAA7134_PREFIX "OFMT_DATA_A", 1},
+ {0x302, SAA7134_PREFIX "OFMT_VIDEO_B", 1},
+ {0x303, SAA7134_PREFIX "OFMT_DATA_B", 1},
+ {0x304, SAA7134_PREFIX "ALPHA_NOCLIP", 1},
+ {0x305, SAA7134_PREFIX "ALPHA_CLIP", 1},
+ {0x308, SAA7134_PREFIX "UV_PIXEL", 1},
+ {0x309, SAA7134_PREFIX "CLIP_RED", 1},
+ {0x30a, SAA7134_PREFIX "CLIP_GREEN", 1},
+ {0x30b, SAA7134_PREFIX "CLIP_BLUE", 1},
+ {0x180, SAA7134_PREFIX "I2C_ATTR_STATUS", 1},
+ {0x181, SAA7134_PREFIX "I2C_DATA", 1},
+ {0x182, SAA7134_PREFIX "I2C_CLOCK_SELECT", 1},
+ {0x183, SAA7134_PREFIX "I2C_TIMER", 1},
+ {0x140, SAA7134_PREFIX "NICAM_ADD_DATA1", 1},
+ {0x141, SAA7134_PREFIX "NICAM_ADD_DATA2", 1},
+ {0x142, SAA7134_PREFIX "NICAM_STATUS", 1},
+ {0x143, SAA7134_PREFIX "AUDIO_STATUS", 1},
+ {0x144, SAA7134_PREFIX "NICAM_ERROR_COUNT", 1},
+ {0x145, SAA7134_PREFIX "IDENT_SIF", 1},
+ {0x146, SAA7134_PREFIX "LEVEL_READOUT1", 1},
+ {0x147, SAA7134_PREFIX "LEVEL_READOUT2", 1},
+ {0x148, SAA7134_PREFIX "NICAM_ERROR_LOW", 1},
+ {0x149, SAA7134_PREFIX "NICAM_ERROR_HIGH", 1},
+ {0x14a, SAA7134_PREFIX "DCXO_IDENT_CTRL", 1},
+ {0x14b, SAA7134_PREFIX "DEMODULATOR", 1},
+ {0x14c, SAA7134_PREFIX "AGC_GAIN_SELECT", 1},
+ {0x150, SAA7134_PREFIX "CARRIER1_FREQ0", 1},
+ {0x151, SAA7134_PREFIX "CARRIER1_FREQ1", 1},
+ {0x152, SAA7134_PREFIX "CARRIER1_FREQ2", 1},
+ {0x154, SAA7134_PREFIX "CARRIER2_FREQ0", 1},
+ {0x155, SAA7134_PREFIX "CARRIER2_FREQ1", 1},
+ {0x156, SAA7134_PREFIX "CARRIER2_FREQ2", 1},
+ {0x158, SAA7134_PREFIX "NUM_SAMPLES0", 1},
+ {0x159, SAA7134_PREFIX "NUM_SAMPLES1", 1},
+ {0x15a, SAA7134_PREFIX "NUM_SAMPLES2", 1},
+ {0x15b, SAA7134_PREFIX "AUDIO_FORMAT_CTRL", 1},
+ {0x160, SAA7134_PREFIX "MONITOR_SELECT", 1},
+ {0x161, SAA7134_PREFIX "FM_DEEMPHASIS", 1},
+ {0x162, SAA7134_PREFIX "FM_DEMATRIX", 1},
+ {0x163, SAA7134_PREFIX "CHANNEL1_LEVEL", 1},
+ {0x164, SAA7134_PREFIX "CHANNEL2_LEVEL", 1},
+ {0x165, SAA7134_PREFIX "NICAM_CONFIG", 1},
+ {0x166, SAA7134_PREFIX "NICAM_LEVEL_ADJUST", 1},
+ {0x167, SAA7134_PREFIX "STEREO_DAC_OUTPUT_SELECT", 1},
+ {0x168, SAA7134_PREFIX "I2S_OUTPUT_FORMAT", 1},
+ {0x169, SAA7134_PREFIX "I2S_OUTPUT_SELECT", 1},
+ {0x16a, SAA7134_PREFIX "I2S_OUTPUT_LEVEL", 1},
+ {0x16b, SAA7134_PREFIX "DSP_OUTPUT_SELECT", 1},
+ {0x16c, SAA7134_PREFIX "AUDIO_MUTE_CTRL", 1},
+ {0x16d, SAA7134_PREFIX "SIF_SAMPLE_FREQ", 1},
+ {0x16e, SAA7134_PREFIX "ANALOG_IO_SELECT", 1},
+ {0x170, SAA7134_PREFIX "AUDIO_CLOCK0", 1},
+ {0x171, SAA7134_PREFIX "AUDIO_CLOCK1", 1},
+ {0x172, SAA7134_PREFIX "AUDIO_CLOCK2", 1},
+ {0x173, SAA7134_PREFIX "AUDIO_PLL_CTRL", 1},
+ {0x174, SAA7134_PREFIX "AUDIO_CLOCKS_PER_FIELD0", 1},
+ {0x175, SAA7134_PREFIX "AUDIO_CLOCKS_PER_FIELD1", 1},
+ {0x176, SAA7134_PREFIX "AUDIO_CLOCKS_PER_FIELD2", 1},
+ {0x190, SAA7134_PREFIX "VIDEO_PORT_CTRL0", 1},
+ {0x191, SAA7134_PREFIX "VIDEO_PORT_CTRL1", 1},
+ {0x192, SAA7134_PREFIX "VIDEO_PORT_CTRL2", 1},
+ {0x193, SAA7134_PREFIX "VIDEO_PORT_CTRL3", 1},
+ {0x194, SAA7134_PREFIX "VIDEO_PORT_CTRL4", 1},
+ {0x195, SAA7134_PREFIX "VIDEO_PORT_CTRL5", 1},
+ {0x196, SAA7134_PREFIX "VIDEO_PORT_CTRL6", 1},
+ {0x197, SAA7134_PREFIX "VIDEO_PORT_CTRL7", 1},
+ {0x198, SAA7134_PREFIX "VIDEO_PORT_CTRL8", 1},
+ {0x1a0, SAA7134_PREFIX "TS_PARALLEL", 1},
+ {0x1a1, SAA7134_PREFIX "TS_PARALLEL_SERIAL", 1},
+ {0x1a2, SAA7134_PREFIX "TS_SERIAL0", 1},
+ {0x1a3, SAA7134_PREFIX "TS_SERIAL1", 1},
+ {0x1a4, SAA7134_PREFIX "TS_DMA0", 1},
+ {0x1a5, SAA7134_PREFIX "TS_DMA1", 1},
+ {0x1a6, SAA7134_PREFIX "TS_DMA2", 1},
+ {0x1B0, SAA7134_PREFIX "GPIO_GPMODE0", 1},
+ {0x1B1, SAA7134_PREFIX "GPIO_GPMODE1", 1},
+ {0x1B2, SAA7134_PREFIX "GPIO_GPMODE2", 1},
+ {0x1B3, SAA7134_PREFIX "GPIO_GPMODE3", 1},
+ {0x1B4, SAA7134_PREFIX "GPIO_GPSTATUS0", 1},
+ {0x1B5, SAA7134_PREFIX "GPIO_GPSTATUS1", 1},
+ {0x1B6, SAA7134_PREFIX "GPIO_GPSTATUS2", 1},
+ {0x1B7, SAA7134_PREFIX "GPIO_GPSTATUS3", 1},
+ {0x1c0, SAA7134_PREFIX "I2S_AUDIO_OUTPUT", 1},
+ {0x1d0, SAA7134_PREFIX "SPECIAL_MODE", 1},
+ {0x1d1, SAA7134_PREFIX "PRODUCTION_TEST_MODE", 1},
+ {0x580, SAA7135_PREFIX "DSP_RWSTATE", 1},
+ {0x586, SAA7135_PREFIX "DSP_RWCLEAR", 1},
+ {0x591, SAA7133_PREFIX "I2S_AUDIO_CONTROL", 1},
+};
diff --git a/v4l2-apps/util/v4l-board-dbg.c b/v4l2-apps/util/v4l-board-dbg.c
new file mode 100644
index 000000000..e74c7300e
--- /dev/null
+++ b/v4l2-apps/util/v4l-board-dbg.c
@@ -0,0 +1,335 @@
+/*
+ Copyright (C) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <linux/types.h>
+#include <linux/videodev2.h>
+
+#include "bttv-dbg.h"
+#include "saa7134-dbg.h"
+#include "em28xx-dbg.h"
+
+#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0])))
+
+struct board_list {
+ char *name;
+ 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 */
+ .name = BTTV_IDENT,
+ .prefix = sizeof(BTTV_PREFIX) - 1,
+ .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) - 1,
+ .regs = saa7134_regs,
+ .regs_size = ARRAY_SIZE(saa7134_regs),
+ .alt_regs = NULL,
+ .alt_regs_size = 0,
+ },
+ [2] = { /* From em28xx-dbg.h */
+ .name = EM28XX_IDENT,
+ .prefix = sizeof(EM28XX_PREFIX) - 1,
+ .regs = em28xx_regs,
+ .regs_size = ARRAY_SIZE(em28xx_regs),
+ .alt_regs = NULL,
+ .alt_regs_size = 0,
+ },
+};
+
+static int is_get=0, is_set=0;
+
+static int doioctl(int fd, int request, void *parm, const char *name)
+{
+ int retVal;
+
+ printf("ioctl %s ", name);
+ retVal = ioctl(fd, request, parm);
+ if (retVal < 0)
+ printf("failed: %s\n", strerror(errno));
+ else
+ printf("ok\n");
+
+ return retVal;
+}
+
+static void usage(void)
+{
+ printf("bttv-dbg <args>\n");
+}
+
+enum Option {
+ OptGetReg = 'g',
+ OptSetReg = 's',
+ OptHelp = 'h',
+};
+
+static void print_bin (int val, int size)
+{
+ int i, j, v;
+
+ printf("(");
+ for (i = size-1; i >= 0; i--) {
+ v = (val >> (i * 8)) & 0xff;
+ for (j = 7; j >= 0; j--) {
+ int bit = (v >> j) & 0x1;
+ if (bit)
+ printf("1");
+ else
+ printf("0");
+ }
+ if (i)
+ printf(" ");
+ else
+ printf(")");
+ }
+}
+
+int main(int argc, char **argv)
+{
+ char *device = strdup("/dev/video0");
+ char *reg_set = NULL;
+ int ch;
+ 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[] = {
+ /* Please keep in alphabetical order of the short option.
+ That makes it easier to see which options are still free. */
+ {"get-reg", no_argument, 0, OptGetReg},
+ {"set-reg", required_argument, 0, OptSetReg},
+ {"help", no_argument, 0, OptHelp},
+ {0, 0, 0, 0}
+ };
+
+ /* command args */
+ if (argc == 1) {
+ usage();
+ return 0;
+ }
+ while (1) {
+ int option_index = 0;
+
+ ch = getopt_long(argc, argv, "gs:", long_options, &option_index);
+ if (ch == -1)
+ break;
+
+ switch (ch) {
+ case OptHelp:
+ usage();
+ return 0;
+ case OptGetReg:
+ is_get++;
+ break;
+ case OptSetReg:
+ is_set++;
+ reg_set = optarg;
+
+ break;
+ case '?':
+ fprintf(stderr, "Unknown argument `%s'\n",
+ argv[optind]);
+ usage();
+ return 1;
+ }
+ }
+ if (optind < argc) {
+ printf("unknown arguments: ");
+ while (optind < argc)
+ printf("%s ", argv[optind++]);
+ printf("\n");
+ usage();
+ return 1;
+ }
+
+ fd = open(device, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Failed to open %s: %s\n", device,
+ strerror(errno));
+ exit(1);
+ }
+ 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);
+ }
+
+ curr_bd = &boards[board];
+
+ reg.match_type = V4L2_CHIP_MATCH_HOST;
+ reg.match_chip = 0;
+
+ if (is_get) {
+ for (i = 0; i < curr_bd->regs_size; i++) {
+ char name[256];
+ reg.reg = curr_bd->regs[i].reg;
+ if (ioctl(fd, VIDIOC_DBG_G_REGISTER, &reg) < 0) {
+ printf("Error while reading. Maybe you're not root?\n");
+ continue;
+ }
+ sprintf(name, "%s:", curr_bd->regs[i].name);
+
+ switch (curr_bd->regs[i].size) {
+ case 1:
+ printf("%-32s %02llx ", name, reg.val & 0xff);
+ break;
+ case 2:
+ printf("%-32s %04llx ", name, reg.val & 0xffff);
+ break;
+ case 4:
+ printf("%-32s %08llx ", name, reg.val & 0xffffffff);
+ break;
+ }
+ print_bin (reg.val, curr_bd->regs[i].size);
+ printf("\n");
+ }
+ return 0;
+ }
+
+ if (is_set) {
+ char *reg_name;
+ int val;
+ int r, size;
+ unsigned prev;
+ struct board_regs *bd_reg;
+
+ reg_name = strtok(reg_set, "=:");
+ val = strtol(strtok(NULL, "=:"), 0L, 0);
+
+ if (!reg_name) {
+ printf("set argument is invalid\n");
+ return -1;
+ }
+
+ 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 = 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 = 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 = 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;
+ }
+ }
+ }
+
+ if (i < 0) {
+ printf("Register not found\n");
+ return -1;
+ }
+
+ reg.reg = r;
+ if (ioctl(fd, VIDIOC_DBG_G_REGISTER, &reg) < 0) {
+ printf("Error while reading register 0x%02x\n", r);
+ return -1;
+ }
+ prev = reg.val;
+
+ switch (size) {
+ case 1:
+ reg.val = (reg.val & (~0xff)) | val;
+ break;
+ case 2:
+ reg.val = (reg.val & (~0xffff)) | val;
+ break;
+ case 4:
+ reg.val = val;
+ break;
+ }
+
+ printf("Changing value of register %s(0x%x) from 0x%02x to 0x%02x\n",
+ bd_reg->name, r, prev, (unsigned int)reg.val);
+
+ prev = reg.val;
+
+ if (ioctl(fd, VIDIOC_DBG_S_REGISTER, &reg) < 0) {
+ printf("Error while writing\n");
+ return -1;
+ }
+ if (ioctl(fd, VIDIOC_DBG_G_REGISTER, &reg) < 0) {
+ printf("Error while reading register 0x%02x\n", r);
+ return -1;
+ }
+ if (reg.val != prev) {
+ printf("Value of register %s(0x%x) is now 0x%02x\n",
+ bd_reg->name, r, (unsigned int)reg.val);
+ }
+ }
+
+ close(fd);
+ exit(0);
+}
diff --git a/v4l2-apps/util/v4l-board-dbg.h b/v4l2-apps/util/v4l-board-dbg.h
new file mode 100644
index 000000000..5d040812d
--- /dev/null
+++ b/v4l2-apps/util/v4l-board-dbg.h
@@ -0,0 +1,24 @@
+/*
+ Copyright (C) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ 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
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index d637e34d7..57d98fc13 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -485,10 +485,16 @@ static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap)
static std::string name2var(unsigned char *name)
{
std::string s;
+ int add_underscore = 0;
while (*name) {
- if (*name == ' ') s += "_";
- else s += std::string(1, tolower(*name));
+ if (isalnum(*name)) {
+ if (add_underscore)
+ s += '_';
+ add_underscore = 0;
+ s += std::string(1, tolower(*name));
+ }
+ else if (s.length()) add_underscore = 1;
name++;
}
return s;
@@ -1365,7 +1371,7 @@ int main(int argc, char **argv)
std = V4L2_STD_SECAM;
}
else {
- std = strtol(optarg, 0L, 0);
+ std = strtol(optarg, 0L, 0) | (1ULL << 63);
}
break;
case OptGetCtrl:
@@ -1562,8 +1568,8 @@ int main(int argc, char **argv)
}
if (options[OptSetStandard]) {
- if (std < 16) {
- vs.index = std;
+ if (std & (1ULL << 63)) {
+ vs.index = std & 0xffff;
if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) {
std = vs.id;
}
diff --git a/v4l2-apps/util/v4l2-dbg.cpp b/v4l2-apps/util/v4l2-dbg.cpp
index e24ae7140..8323f2120 100644
--- a/v4l2-apps/util/v4l2-dbg.cpp
+++ b/v4l2-apps/util/v4l2-dbg.cpp
@@ -369,6 +369,8 @@ int main(int argc, char **argv)
break;
case 2:
reg_min = strtoull(value, 0L, 0);
+ if (reg_max == 0)
+ reg_max = reg_min + 0xff;
break;
case 3:
reg_max = strtoull(value, 0L, 0);