diff options
author | Hans Verkuil <devnull@localhost> | 2006-01-02 18:22:39 +0000 |
---|---|---|
committer | Hans Verkuil <devnull@localhost> | 2006-01-02 18:22:39 +0000 |
commit | 3d80f276313cd11569c95a5aade93a3dff009aaa (patch) | |
tree | 8a66b7b9736dab2fc74f36e37c5cbf0ac63cf2be | |
parent | f591fa75d8325a9732e155b7db70d8aec349d183 (diff) | |
download | mediapointer-dvb-s2-3d80f276313cd11569c95a5aade93a3dff009aaa.tar.gz mediapointer-dvb-s2-3d80f276313cd11569c95a5aade93a3dff009aaa.tar.bz2 |
Added new diagnositics macros, convert msp3400 to the new macros.
- Added new v4l_err, v4l_warn, v4l_info and v4l_dbg macros to
v4l2-common.h for use in v4l-dvb i2c drivers. This ensures
a unique prefix for each device instance.
- At a later stage these macros may be reimplemented using the
device-generic macros from device.h.
- Converted the msp3400 driver to the new macros.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r-- | linux/drivers/media/video/msp3400-driver.c | 62 | ||||
-rw-r--r-- | linux/drivers/media/video/msp3400-kthreads.c | 102 | ||||
-rw-r--r-- | linux/drivers/media/video/msp3400.h | 36 | ||||
-rw-r--r-- | linux/include/media/v4l2-common.h | 63 | ||||
-rw-r--r-- | v4l/ChangeLog | 20 |
5 files changed, 154 insertions, 129 deletions
diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c index 5176d84e5..f41216225 100644 --- a/linux/drivers/media/video/msp3400-driver.c +++ b/linux/drivers/media/video/msp3400-driver.c @@ -149,11 +149,11 @@ int msp_reset(struct i2c_client *client) { client->addr, I2C_M_RD, 2, read }, }; - msp_dbg3("msp_reset\n"); + v4l_dbg(3, client, "msp_reset\n"); if (i2c_transfer(client->adapter, &reset[0], 1) != 1 || i2c_transfer(client->adapter, &reset[1], 1) != 1 || i2c_transfer(client->adapter, test, 2) != 2) { - msp_err("chip reset failed\n"); + v4l_err(client, "chip reset failed\n"); return -1; } return 0; @@ -176,18 +176,18 @@ static int msp_read(struct i2c_client *client, int dev, int addr) for (err = 0; err < 3; err++) { if (i2c_transfer(client->adapter, msgs, 2) == 2) break; - msp_warn("I/O error #%d (read 0x%02x/0x%02x)\n", err, + v4l_warn(client, "I/O error #%d (read 0x%02x/0x%02x)\n", err, dev, addr); current->state = TASK_INTERRUPTIBLE; schedule_timeout(msecs_to_jiffies(10)); } if (err == 3) { - msp_warn("giving up, resetting chip. Sound will go off, sorry folks :-|\n"); + v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); msp_reset(client); return -1; } retval = read[0] << 8 | read[1]; - msp_dbg3("msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); + v4l_dbg(3, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); return retval; } @@ -212,17 +212,17 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val) buffer[3] = val >> 8; buffer[4] = val & 0xff; - msp_dbg3("msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); + v4l_dbg(3, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); for (err = 0; err < 3; err++) { if (i2c_master_send(client, buffer, 5) == 5) break; - msp_warn("I/O error #%d (write 0x%02x/0x%02x)\n", err, + v4l_warn(client, "I/O error #%d (write 0x%02x/0x%02x)\n", err, dev, addr); current->state = TASK_INTERRUPTIBLE; schedule_timeout(msecs_to_jiffies(10)); } if (err == 3) { - msp_warn("giving up, resetting chip. Sound will go off, sorry folks :-|\n"); + v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); msp_reset(client); return -1; } @@ -295,7 +295,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out) } else state->acb = 0xf60; /* Mute Input and SCART 1 Output */ - msp_dbg1("scart switch: %s => %d (ACB=0x%04x)\n", + v4l_dbg(1, client, "scart switch: %s => %d (ACB=0x%04x)\n", scart_names[in], out, state->acb); msp_write_dsp(client, 0x13, state->acb); @@ -305,7 +305,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out) void msp_set_mute(struct i2c_client *client) { - msp_dbg1("mute audio\n"); + v4l_dbg(1, client, "mute audio\n"); msp_write_dsp(client, 0x0000, 0); /* loudspeaker */ msp_write_dsp(client, 0x0006, 0); /* headphones */ } @@ -322,7 +322,7 @@ void msp_set_audio(struct i2c_client *client) bass = ((state->bass - 32768) * 0x60 / 65535) << 8; treble = ((state->treble - 32768) * 0x60 / 65535) << 8; - msp_dbg1("mute=%s volume=%d balance=%d bass=%d treble=%d\n", + v4l_dbg(1, client, "mute=%s volume=%d balance=%d bass=%d treble=%d\n", state->muted ? "on" : "off", state->volume, state->balance, state->bass, state->treble); @@ -338,7 +338,7 @@ int msp_modus(struct i2c_client *client, int norm) { switch (norm) { case VIDEO_MODE_PAL: - msp_dbg1("video mode selected to PAL\n"); + v4l_dbg(1, client, "video mode selected to PAL\n"); #if 1 /* KEEP */ /* experimental: not sure this works with all chip versions */ @@ -348,16 +348,16 @@ int msp_modus(struct i2c_client *client, int norm) return 0x1003; #endif case VIDEO_MODE_NTSC: /* BTSC */ - msp_dbg1("video mode selected to NTSC\n"); + v4l_dbg(1, client, "video mode selected to NTSC\n"); return 0x2003; case VIDEO_MODE_SECAM: - msp_dbg1("video mode selected to SECAM\n"); + v4l_dbg(1, client, "video mode selected to SECAM\n"); return 0x0003; case VIDEO_MODE_RADIO: - msp_dbg1("video mode selected to Radio\n"); + v4l_dbg(1, client, "video mode selected to Radio\n"); return 0x0003; case VIDEO_MODE_AUTO: - msp_dbg1("video mode selected to Auto\n"); + v4l_dbg(1, client, "video mode selected to Auto\n"); return 0x2003; default: return 0x0003; @@ -673,7 +673,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) case AUDC_SET_RADIO: state->norm = VIDEO_MODE_RADIO; - msp_dbg1("switching to radio mode\n"); + v4l_dbg(1, client, "switching to radio mode\n"); state->watch_stereo = 0; switch (state->opmode) { case OPMODE_MANUAL: @@ -928,7 +928,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) if (a->index < 0 || a->index > 2) return -EINVAL; - msp_dbg1("Setting audio out on msp34xx to input %i\n", a->index); + v4l_dbg(1, client, "Setting audio out on msp34xx to input %i\n", a->index); msp_set_scart(client, state->in_scart, a->index + 1); break; @@ -938,7 +938,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) { u32 *a = (u32 *)arg; - msp_dbg1("Setting I2S speed to %d\n", *a); + v4l_dbg(1, client, "Setting I2S speed to %d\n", *a); switch (*a) { case 1024000: @@ -974,16 +974,16 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) case VIDIOC_LOG_STATUS: msp_any_detect_stereo(client); - msp_info("%s rev1 = 0x%04x rev2 = 0x%04x\n", + v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n", client->name, state->rev1, state->rev2); - msp_info("Audio: volume %d balance %d bass %d treble %d%s\n", + v4l_info(client, "Audio: volume %d balance %d bass %d treble %d%s\n", state->volume, state->balance, state->bass, state->treble, state->muted ? " (muted)" : ""); - msp_info("Mode: %s (%s%s)\n", msp_standard_mode_name(state->mode), + v4l_info(client, "Mode: %s (%s%s)\n", msp_standard_mode_name(state->mode), (state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono", (state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : ""); - msp_info("ACB: 0x%04x\n", state->acb); + v4l_info(client, "ACB: 0x%04x\n", state->acb); break; default: @@ -1006,7 +1006,7 @@ static int msp_suspend(struct device * dev, u32 state, u32 level) { struct i2c_client *client = container_of(dev, struct i2c_client, dev); - msp_dbg1("suspend\n"); + v4l_dbg(1, client, "suspend\n"); msp_reset(client); return 0; } @@ -1019,7 +1019,7 @@ static int msp_resume(struct device * dev, u32 level) { struct i2c_client *client = container_of(dev, struct i2c_client, dev); - msp_dbg1("resume\n"); + v4l_dbg(1, client, "resume\n"); msp_wake_thread(client); return 0; } @@ -1051,7 +1051,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) snprintf(client->name, sizeof(client->name) - 1, "msp3400"); if (msp_reset(client) == -1) { - msp_dbg1("msp3400 not found\n"); + v4l_dbg(1, client, "msp3400 not found\n"); kfree(client); return -1; } @@ -1077,9 +1077,9 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) state->rev1 = msp_read_dsp(client, 0x1e); if (state->rev1 != -1) state->rev2 = msp_read_dsp(client, 0x1f); - msp_dbg1("rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); + v4l_dbg(1, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { - msp_dbg1("not an msp3400 (cannot read chip version)\n"); + v4l_dbg(1, client, "not an msp3400 (cannot read chip version)\n"); kfree(state); kfree(client); return -1; @@ -1111,8 +1111,8 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) } /* hello world :-) */ - msp_info("%s found @ 0x%x (%s)\n", client->name, address << 1, adapter->name); - msp_info("%s ", client->name); + v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, address << 1, adapter->name); + v4l_info(client, "%s ", client->name); if (HAVE_NICAM(state) && HAVE_RADIO(state)) printk("supports nicam and radio, "); else if (HAVE_NICAM(state)) @@ -1144,7 +1144,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) state->kthread = kthread_run(thread_func, client, "msp34xx"); if (state->kthread == NULL) - msp_warn("kernel_thread() failed\n"); + v4l_warn(client, "kernel_thread() failed\n"); #else DECLARE_MUTEX_LOCKED(sem); diff --git a/linux/drivers/media/video/msp3400-kthreads.c b/linux/drivers/media/video/msp3400-kthreads.c index 5aa308a02..e68241d90 100644 --- a/linux/drivers/media/video/msp3400-kthreads.c +++ b/linux/drivers/media/video/msp3400-kthreads.c @@ -174,7 +174,7 @@ void msp3400c_setmode(struct i2c_client *client, int type) struct msp_state *state = i2c_get_clientdata(client); int i; - msp_dbg1("setmode: %d\n", type); + v4l_dbg(1, client, "setmode: %d\n", type); state->mode = type; state->audmode = V4L2_TUNER_MODE_MONO; state->rxsubchans = V4L2_TUNER_SUB_MONO; @@ -241,7 +241,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) /* this method would break everything, let's make sure * it's never called */ - msp_dbg1("setstereo called with mode=%d instead of set_source (ignored)\n", + v4l_dbg(1, client, "setstereo called with mode=%d instead of set_source (ignored)\n", mode); return; } @@ -249,7 +249,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) /* switch demodulator */ switch (state->mode) { case MSP_MODE_FM_TERRA: - msp_dbg1("FM setstereo: %s\n", strmode[mode]); + v4l_dbg(1, client, "FM setstereo: %s\n", strmode[mode]); msp3400c_setcarrier(client,state->second,state->main); switch (mode) { case V4L2_TUNER_MODE_STEREO: @@ -263,7 +263,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) } break; case MSP_MODE_FM_SAT: - msp_dbg1("SAT setstereo: %s\n", strmode[mode]); + v4l_dbg(1, client, "SAT setstereo: %s\n", strmode[mode]); switch (mode) { case V4L2_TUNER_MODE_MONO: msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); @@ -282,24 +282,24 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM2: case MSP_MODE_AM_NICAM: - msp_dbg1("NICAM setstereo: %s\n",strmode[mode]); + v4l_dbg(1, client, "NICAM setstereo: %s\n",strmode[mode]); msp3400c_setcarrier(client,state->second,state->main); if (state->nicam_on) nicam=0x0100; break; case MSP_MODE_BTSC: - msp_dbg1("BTSC setstereo: %s\n",strmode[mode]); + v4l_dbg(1, client, "BTSC setstereo: %s\n",strmode[mode]); nicam=0x0300; break; case MSP_MODE_EXTERN: - msp_dbg1("extern setstereo: %s\n",strmode[mode]); + v4l_dbg(1, client, "extern setstereo: %s\n",strmode[mode]); nicam = 0x0200; break; case MSP_MODE_FM_RADIO: - msp_dbg1("FM-Radio setstereo: %s\n",strmode[mode]); + v4l_dbg(1, client, "FM-Radio setstereo: %s\n",strmode[mode]); break; default: - msp_dbg1("mono setstereo\n"); + v4l_dbg(1, client, "mono setstereo\n"); return; } @@ -314,7 +314,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) break; case V4L2_TUNER_MODE_MONO: if (state->mode == MSP_MODE_AM_NICAM) { - msp_dbg1("switching to AM mono\n"); + v4l_dbg(1, client, "switching to AM mono\n"); /* AM mono decoding is handled by tuner, not MSP chip */ /* SCART switching control register */ msp_set_scart(client, SCART_MONO, 0); @@ -328,7 +328,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode) src = 0x0010 | nicam; break; } - msp_dbg1("setstereo final source/matrix = 0x%x\n", src); + v4l_dbg(1, client, "setstereo final source/matrix = 0x%x\n", src); if (dolby) { msp_write_dsp(client, 0x0008, 0x0520); @@ -348,20 +348,20 @@ static void msp3400c_print_mode(struct i2c_client *client) struct msp_state *state = i2c_get_clientdata(client); if (state->main == state->second) { - msp_dbg1("mono sound carrier: %d.%03d MHz\n", + v4l_dbg(1, client, "mono sound carrier: %d.%03d MHz\n", state->main / 910000, (state->main / 910) % 1000); } else { - msp_dbg1("main sound carrier: %d.%03d MHz\n", + v4l_dbg(1, client, "main sound carrier: %d.%03d MHz\n", state->main / 910000, (state->main / 910) % 1000); } if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2) - msp_dbg1("NICAM/FM carrier : %d.%03d MHz\n", + v4l_dbg(1, client, "NICAM/FM carrier : %d.%03d MHz\n", state->second / 910000, (state->second/910) % 1000); if (state->mode == MSP_MODE_AM_NICAM) - msp_dbg1("NICAM/AM carrier : %d.%03d MHz\n", + v4l_dbg(1, client, "NICAM/AM carrier : %d.%03d MHz\n", state->second / 910000, (state->second / 910) % 1000); if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) { - msp_dbg1("FM-stereo carrier : %d.%03d MHz\n", + v4l_dbg(1, client, "FM-stereo carrier : %d.%03d MHz\n", state->second / 910000, (state->second / 910) % 1000); } } @@ -381,7 +381,7 @@ int autodetect_stereo(struct i2c_client *client) val = msp_read_dsp(client, 0x18); if (val > 32767) val -= 65536; - msp_dbg2("stereo detect register: %d\n", val); + v4l_dbg(2, client, "stereo detect register: %d\n", val); if (val > 4096) { rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; } else if (val < -4096) { @@ -395,7 +395,7 @@ int autodetect_stereo(struct i2c_client *client) case MSP_MODE_FM_NICAM2: case MSP_MODE_AM_NICAM: val = msp_read_dem(client, 0x23); - msp_dbg2("nicam sync=%d, mode=%d\n", + v4l_dbg(2, client, "nicam sync=%d, mode=%d\n", val & 1, (val & 0x1e) >> 1); if (val & 1) { @@ -428,7 +428,7 @@ int autodetect_stereo(struct i2c_client *client) break; case MSP_MODE_BTSC: val = msp_read_dem(client, 0x200); - msp_dbg2("status=0x%x (pri=%s, sec=%s, %s%s%s)\n", + v4l_dbg(2, client, "status=0x%x (pri=%s, sec=%s, %s%s%s)\n", val, (val & 0x0002) ? "no" : "yes", (val & 0x0004) ? "no" : "yes", @@ -442,13 +442,13 @@ int autodetect_stereo(struct i2c_client *client) } if (rxsubchans != state->rxsubchans) { update = 1; - msp_dbg1("watch: rxsubchans %d => %d\n", + v4l_dbg(1, client, "watch: rxsubchans %d => %d\n", state->rxsubchans,rxsubchans); state->rxsubchans = rxsubchans; } if (newnicam != state->nicam_on) { update = 1; - msp_dbg1("watch: nicam %d => %d\n", + v4l_dbg(1, client, "watch: nicam %d => %d\n", state->nicam_on,newnicam); state->nicam_on = newnicam; } @@ -488,14 +488,14 @@ int msp3400c_thread(void *data) msp_setup_thread(state); #endif - msp_dbg1("msp3400 daemon started\n"); + v4l_dbg(1, client, "msp3400 daemon started\n"); for (;;) { - msp_dbg2("msp3400 thread: sleep\n"); + v4l_dbg(2, client, "msp3400 thread: sleep\n"); msp_sleep(state, -1); - msp_dbg2("msp3400 thread: wakeup\n"); + v4l_dbg(2, client, "msp3400 thread: wakeup\n"); restart: - msp_dbg1("thread: restart scan\n"); + v4l_dbg(1, client, "thread: restart scan\n"); state->restart = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (state->rmmod || signal_pending(current)) @@ -507,7 +507,7 @@ int msp3400c_thread(void *data) if (VIDEO_MODE_RADIO == state->norm || MSP_MODE_EXTERN == state->mode) { /* no carrier scan, just unmute */ - msp_dbg1("thread: no carrier scan\n"); + v4l_dbg(1, client, "thread: no carrier scan\n"); msp_set_audio(client); continue; } @@ -531,7 +531,7 @@ int msp3400c_thread(void *data) /* autodetect doesn't work well with AM ... */ max1 = 3; count = 0; - msp_dbg1("AM sound override\n"); + v4l_dbg(1, client, "AM sound override\n"); } for (this = 0; this < count; this++) { @@ -543,7 +543,7 @@ int msp3400c_thread(void *data) val -= 65536; if (val1 < val) val1 = val, max1 = this; - msp_dbg1("carrier1 val: %5d / %s\n", val,cd[this].name); + v4l_dbg(1, client, "carrier1 val: %5d / %s\n", val,cd[this].name); } /* carrier detect pass #2 -- second (stereo) carrier */ @@ -579,7 +579,7 @@ int msp3400c_thread(void *data) val -= 65536; if (val2 < val) val2 = val, max2 = this; - msp_dbg1("carrier2 val: %5d / %s\n", val,cd[this].name); + v4l_dbg(1, client, "carrier2 val: %5d / %s\n", val,cd[this].name); } /* program the msp3400 according to the results */ @@ -667,7 +667,7 @@ int msp3400c_thread(void *data) watch_stereo(client); } } - msp_dbg1("thread: exit\n"); + v4l_dbg(1, client, "thread: exit\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) state->kthread = NULL; @@ -687,15 +687,15 @@ int msp3410d_thread(void *data) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) msp_setup_thread(state); #endif - msp_dbg1("msp3410 daemon started\n"); + v4l_dbg(1, client, "msp3410 daemon started\n"); for (;;) { - msp_dbg2("msp3410 thread: sleep\n"); + v4l_dbg(2, client, "msp3410 thread: sleep\n"); msp_sleep(state,-1); - msp_dbg2("msp3410 thread: wakeup\n"); + v4l_dbg(2, client, "msp3410 thread: wakeup\n"); restart: - msp_dbg1("thread: restart scan\n"); + v4l_dbg(1, client, "thread: restart scan\n"); state->restart = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (state->rmmod || signal_pending(current)) @@ -706,7 +706,7 @@ int msp3410d_thread(void *data) if (state->mode == MSP_MODE_EXTERN) { /* no carrier scan needed, just unmute */ - msp_dbg1("thread: no carrier scan\n"); + v4l_dbg(1, client, "thread: no carrier scan\n"); msp_set_audio(client); continue; } @@ -726,7 +726,7 @@ int msp3410d_thread(void *data) state->watch_stereo = 0; if (debug) - msp_dbg1("setting mode: %s (0x%04x)\n", + v4l_dbg(1, client, "setting mode: %s (0x%04x)\n", msp_standard_mode_name(std), std); if (std != 1) { @@ -742,20 +742,20 @@ int msp3410d_thread(void *data) val = msp_read_dem(client, 0x7e); if (val < 0x07ff) break; - msp_dbg1("detection still in progress\n"); + v4l_dbg(1, client, "detection still in progress\n"); } } for (i = 0; msp_modelist[i].name != NULL; i++) if (msp_modelist[i].retval == val) break; - msp_dbg1("current mode: %s (0x%04x)\n", + v4l_dbg(1, client, "current mode: %s (0x%04x)\n", msp_standard_mode_name(val), val); state->main = msp_modelist[i].main; state->second = msp_modelist[i].second; if (amsound && (state->norm == VIDEO_MODE_SECAM) && (val != 0x0009)) { /* autodetection has failed, let backup */ - msp_dbg1("autodetection failed," + v4l_dbg(1, client, "autodetection failed," " switching to backup mode: %s (0x%04x)\n", msp_modelist[8].name ? msp_modelist[8].name : "unknown",val); val = 0x0009; @@ -844,7 +844,7 @@ int msp3410d_thread(void *data) watch_stereo(client); } } - msp_dbg1("thread: exit\n"); + v4l_dbg(1, client, "thread: exit\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) state->kthread = NULL; @@ -877,7 +877,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source) */ int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20); - msp_dbg1("set source to %d (0x%x)\n", source, value); + v4l_dbg(1, client, "set source to %d (0x%x)\n", source, value); /* Loudspeaker Output */ msp_write_dsp(client, 0x08, value); /* SCART1 DA Output */ @@ -948,16 +948,16 @@ int msp34xxg_thread(void *data) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) msp_setup_thread(state); #endif - msp_dbg1("msp34xxg daemon started\n"); + v4l_dbg(1, client, "msp34xxg daemon started\n"); state->source = 1; /* default */ for (;;) { - msp_dbg2("msp34xxg thread: sleep\n"); + v4l_dbg(2, client, "msp34xxg thread: sleep\n"); msp_sleep(state, -1); - msp_dbg2("msp34xxg thread: wakeup\n"); + v4l_dbg(2, client, "msp34xxg thread: wakeup\n"); restart: - msp_dbg1("thread: restart scan\n"); + v4l_dbg(1, client, "thread: restart scan\n"); state->restart = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (state->rmmod || signal_pending(current)) @@ -973,7 +973,7 @@ int msp34xxg_thread(void *data) goto unmute; /* watch autodetect */ - msp_dbg1("triggered autodetect, waiting for result\n"); + v4l_dbg(1, client, "triggered autodetect, waiting for result\n"); for (i = 0; i < 10; i++) { if (msp_sleep(state, 100)) goto restart; @@ -984,16 +984,16 @@ int msp34xxg_thread(void *data) std = val; break; } - msp_dbg2("detection still in progress\n"); + v4l_dbg(2, client, "detection still in progress\n"); } if (std == 1) { - msp_dbg1("detection still in progress after 10 tries. giving up.\n"); + v4l_dbg(1, client, "detection still in progress after 10 tries. giving up.\n"); continue; } unmute: state->mode = std; - msp_dbg1("current mode: %s (0x%04x)\n", + v4l_dbg(1, client, "current mode: %s (0x%04x)\n", msp_standard_mode_name(std), std); /* unmute: dispatch sound to scart output, set scart volume */ @@ -1005,7 +1005,7 @@ int msp34xxg_thread(void *data) msp_write_dem(client, 0x40, state->i2s_mode); } - msp_dbg1("thread: exit\n"); + v4l_dbg(1, client, "thread: exit\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) state->kthread = NULL; @@ -1037,7 +1037,7 @@ void msp34xxg_detect_stereo(struct i2c_client *client) * this is a problem, I'll handle SAP just like lang1/lang2. */ } - msp_dbg1("status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", + v4l_dbg(1, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", status, is_stereo, is_bilingual, state->rxsubchans); } diff --git a/linux/drivers/media/video/msp3400.h b/linux/drivers/media/video/msp3400.h index 3f9e03daf..5291ef919 100644 --- a/linux/drivers/media/video/msp3400.h +++ b/linux/drivers/media/video/msp3400.h @@ -1,5 +1,5 @@ /* - * $Id: msp3400.h,v 1.4 2006/01/02 17:25:19 hverkuil Exp $ + * $Id: msp3400.h,v 1.5 2006/01/02 18:22:39 hverkuil Exp $ */ #ifndef MSP3400_H @@ -7,40 +7,6 @@ /* ---------------------------------------------------------------------- */ -#define msp_err(fmt, arg...) \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) -#define msp_warn(fmt, arg...) \ - printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) -#define msp_info(fmt, arg...) \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) - -/* level 1 debug. */ -#define msp_dbg1(fmt, arg...) \ - do { \ - if (debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - -/* level 2 debug. */ -#define msp_dbg2(fmt, arg...) \ - do { \ - if (debug >= 2) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - -/* level 3 debug. Use with care. */ -#define msp_dbg3(fmt, arg...) \ - do { \ - if (debug >= 16) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - struct msp_matrix { int input; int output; diff --git a/linux/include/media/v4l2-common.h b/linux/include/media/v4l2-common.h index 9ee616261..99eb14c2f 100644 --- a/linux/include/media/v4l2-common.h +++ b/linux/include/media/v4l2-common.h @@ -26,6 +26,57 @@ #ifndef V4L2_COMMON_H_ #define V4L2_COMMON_H_ +/* v4l debugging and diagnostics */ + +/* Common printk constucts for v4l-i2c drivers. These macros create a unique + prefix consisting of the driver name, the adapter number and the i2c + address. */ +#define v4l_printk(level, name, adapter, addr, fmt, arg...) \ + printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg) + +#define v4l_client_printk(level, client, fmt, arg...) \ + v4l_printk(level, (client)->driver->name, (client)->adapter, \ + (client)->addr, fmt , ## arg) + +#define v4l_err(client, fmt, arg...) \ + v4l_client_printk(KERN_ERR, client, fmt , ## arg) + +#define v4l_warn(client, fmt, arg...) \ + v4l_client_printk(KERN_WARNING, client, fmt , ## arg) + +#define v4l_info(client, fmt, arg...) \ + v4l_client_printk(KERN_INFO, client, fmt , ## arg) + +/* These three macros assume that the debug level is set with a module + parameter called 'debug'. */ +#define v4l_dbg(level, client, fmt, arg...) \ + do { \ + if (debug >= (level)) \ + v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ + } while (0) + +/* Prints the ioctl in a human-readable format */ +extern void v4l_printk_ioctl(unsigned int cmd); + +/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ +#define v4l_print_ioctl(name, cmd) \ + do { \ + printk(KERN_DEBUG "%s: ", name); \ + v4l_printk_ioctl(cmd); \ + } while (0) + +/* Use this macro in I2C drivers where 'client' is the struct i2c_client + pointer */ +#define v4l_i2c_print_ioctl(client, cmd) \ + do { \ + v4l_client_printk(KERN_DEBUG, client, ""); \ + v4l_printk_ioctl(cmd); \ + } while (0) + +/* ------------------------------------------------------------------------- */ + +/* Internal ioctls */ + /* VIDIOC_INT_G_REGISTER and VIDIOC_INT_S_REGISTER */ struct v4l2_register { u32 i2c_id; /* I2C driver ID of the I2C chip. 0 for the I2C adapter. */ @@ -122,16 +173,4 @@ enum v4l2_chip_ident { If the frequency is not supported, then -EINVAL is returned. */ #define VIDIOC_INT_I2S_CLOCK_FREQ _IOW ('d', 108, u32) -/* Prints used ioctl */ -extern void v4l_printk_ioctl(unsigned int cmd); - -#define v4l_print_ioctl(name,cmd) do {\ - printk(KERN_DEBUG "%s: ", name); \ - v4l_printk_ioctl(cmd); } while (0) - -#define v4l_i2c_print_ioctl(client,cmd) do {\ - printk(KERN_DEBUG "%s %d-%04x: ", (client)->driver->name, \ - i2c_adapter_id((client)->adapter),(client)->addr); \ - v4l_printk_ioctl(cmd); } while (0) - #endif /* V4L2_COMMON_H_ */ diff --git a/v4l/ChangeLog b/v4l/ChangeLog index 49877474d..6787443b9 100644 --- a/v4l/ChangeLog +++ b/v4l/ChangeLog @@ -1,3 +1,23 @@ +2006-01-02 18:15 hverkuil + + * linux/drivers/media/video/msp3400-driver.c: (msp_reset), + (msp_read), (msp_write), (msp_set_scart), (msp_set_mute), + (msp_set_audio), (msp_modus): + * linux/drivers/media/video/msp3400-kthreads.c: (msp3400c_setmode), + (msp3400c_setstereo), (msp3400c_print_mode), (autodetect_stereo), + (msp3400c_thread), (msp3410d_thread), (msp34xxg_set_source), + (msp34xxg_thread), (msp34xxg_detect_stereo): + * linux/drivers/media/video/msp3400.h: + * linux/include/media/v4l2-common.h: + - Added new v4l_err, v4l_warn, v4l_info and v4l_dbg macros to + v4l2-common.h for use in v4l-dvb i2c drivers. This ensures + a unique prefix for each device instance. + - At a later stage these macros may be reimplemented using the + device-generic macros from device.h. + - Converted the msp3400 driver to the new macros. + + Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> + 2006-01-02 17:20 hverkuil * linux/drivers/media/video/Makefile: |