aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-20 17:54:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-20 17:54:35 -0400
commitd6f410bdbcb435c744c4f8259d6659ae2c6e447a (patch)
tree5426dd9fd8a358fe7e3517c00f83f38ba7f9dca7
parenteaf729c8a8bfc9c7a5ff5659e3b2584bf2ef22e1 (diff)
parent1b2232ab879993fcf5b9391c3febf6ab5d78201e (diff)
Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb: V4L/DVB (5880): wm8775/wm8739: Fix memory leak when unloading module V4L/DVB (5877): radio-gemtek-pci: remove unused structure member V4L/DVB (5871): Conexant 2388x: check for kthread_run V4L/DVB (5869): Add check for valid control ID to v4l2_ctrl_next. V4L/DVB (5867): videodev2.h: add missing <sys/time.h> for userspace V4L/DVB (5866): ivtv: fix DMA timeout when capturing VBI + another stream V4L/DVB (5865): Remove usage of HZ on ivtv driver, replacing by msecs_to_jiffies V4L/DVB (5861): Use msecs_to_jiffies instead of HZ on bttv, cx88 and saa7134 V4L/DVB (5860): Use msecs_to_jiffies instead of HZ on some webcam drivers V4L/DVB (5859): use msecs_to_jiffies on InfraRed RC5 timeout V4L/DVB (5858): Use msecs_to_jiffies instead of HZ on media/video I2C drivers V4L/DVB (5857): Use msecs_to_jiffies instead of HZ on radio drivers V4L/DVB (5855): ivtv: fix Kconfig typo and refer to the driver homepage. V4L/DVB (5854): ivtv: cleanup of driver messages V4L/DVB (5853): ivtv: add support to suppress high volume i2c debug messages. V4L/DVB (5852): ivtv: don't recompile needlessly V4L/DVB (5851): ivtv: fix missing I2C_ALGOBIT config option V4L/DVB (5850): ivtv: improve API command debugging V4L/DVB (5848): Av7110: fix typo
-rw-r--r--drivers/media/common/ir-functions.c4
-rw-r--r--drivers/media/dvb/ttpci/av7110.c2
-rw-r--r--drivers/media/radio/radio-aimslab.c2
-rw-r--r--drivers/media/radio/radio-cadet.c4
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c3
-rw-r--r--drivers/media/video/bt866.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c2
-rw-r--r--drivers/media/video/bt8xx/bttvp.h4
-rw-r--r--drivers/media/video/c-qcam.c4
-rw-r--r--drivers/media/video/cx88/cx88-video.c8
-rw-r--r--drivers/media/video/cx88/cx88.h2
-rw-r--r--drivers/media/video/ivtv/Kconfig5
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c43
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c6
-rw-r--r--drivers/media/video/ivtv/ivtv-firmware.c25
-rw-r--r--drivers/media/video/ivtv/ivtv-gpio.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c20
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c11
-rw-r--r--drivers/media/video/ivtv/ivtv-mailbox.c33
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c12
-rw-r--r--drivers/media/video/saa5249.c8
-rw-r--r--drivers/media/video/saa7110.c4
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
-rw-r--r--drivers/media/video/tvaudio.c4
-rw-r--r--drivers/media/video/v4l2-common.c19
-rw-r--r--drivers/media/video/vino.c2
-rw-r--r--drivers/media/video/wm8739.c2
-rw-r--r--drivers/media/video/wm8775.c2
-rw-r--r--include/linux/videodev2.h1
31 files changed, 134 insertions, 108 deletions
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index fe447a06e24e..a3292e955aaa 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -345,8 +345,8 @@ void ir_rc5_timer_end(unsigned long data)
345 } 345 }
346 346
347 /* Set/reset key-up timer */ 347 /* Set/reset key-up timer */
348 timeout = current_jiffies + (500 + ir->rc5_key_timeout 348 timeout = current_jiffies +
349 * HZ) / 1000; 349 msecs_to_jiffies(ir->rc5_key_timeout);
350 mod_timer(&ir->timer_keyup, timeout); 350 mod_timer(&ir->timer_keyup, timeout);
351 351
352 /* Save code for repeat test */ 352 /* Save code for repeat test */
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 2cee9e3bd29f..8178832d14a8 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2267,7 +2267,7 @@ static int frontend_init(struct av7110 *av7110)
2267 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd); 2267 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
2268 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst); 2268 FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
2269 FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, av7110_fe_set_tone); 2269 FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
2270 FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage;) 2270 FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage);
2271 FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command); 2271 FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2272 FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend); 2272 FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2273 2273
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index ce940b1b787f..f0a67e93d7fd 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -63,7 +63,7 @@ struct rt_device
63static void sleep_delay(long n) 63static void sleep_delay(long n)
64{ 64{
65 /* Sleep nicely for 'n' uS */ 65 /* Sleep nicely for 'n' uS */
66 int d=n/(1000000/HZ); 66 int d=n/msecs_to_jiffies(1000);
67 if(!d) 67 if(!d)
68 udelay(n); 68 udelay(n);
69 else 69 else
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 8cf2e9df5c8a..34e317ced5a3 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -329,7 +329,7 @@ cadet_handler(unsigned long data)
329 init_timer(&readtimer); 329 init_timer(&readtimer);
330 readtimer.function=cadet_handler; 330 readtimer.function=cadet_handler;
331 readtimer.data=(unsigned long)0; 331 readtimer.data=(unsigned long)0;
332 readtimer.expires=jiffies+(HZ/20); 332 readtimer.expires=jiffies+msecs_to_jiffies(50);
333 add_timer(&readtimer); 333 add_timer(&readtimer);
334} 334}
335 335
@@ -349,7 +349,7 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
349 init_timer(&readtimer); 349 init_timer(&readtimer);
350 readtimer.function=cadet_handler; 350 readtimer.function=cadet_handler;
351 readtimer.data=(unsigned long)0; 351 readtimer.data=(unsigned long)0;
352 readtimer.expires=jiffies+(HZ/20); 352 readtimer.expires=jiffies+msecs_to_jiffies(50);
353 add_timer(&readtimer); 353 add_timer(&readtimer);
354 } 354 }
355 if(rdsin==rdsout) { 355 if(rdsin==rdsout) {
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 4db05b2b1b6e..99a323131333 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -94,7 +94,6 @@ struct gemtek_pci_card {
94 94
95 u32 iobase; 95 u32 iobase;
96 u32 length; 96 u32 length;
97 u16 model;
98 97
99 u32 current_frequency; 98 u32 current_frequency;
100 u8 mute; 99 u8 mute;
@@ -413,8 +412,6 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
413 goto err_pci; 412 goto err_pci;
414 } 413 }
415 414
416 pci_read_config_word( pci_dev, PCI_SUBSYSTEM_ID, &card->model );
417
418 pci_set_drvdata( pci_dev, card ); 415 pci_set_drvdata( pci_dev, card );
419 416
420 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) { 417 if ( (devradio = kmalloc( sizeof( struct video_device ), GFP_KERNEL )) == NULL ) {
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 2e4cf1efdd21..b767b098d14b 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -257,7 +257,7 @@ static int bt866_write(struct bt866 *encoder,
257 printk(KERN_WARNING "%s: I/O error #%d " 257 printk(KERN_WARNING "%s: I/O error #%d "
258 "(write 0x%02x/0x%02x)\n", 258 "(write 0x%02x/0x%02x)\n",
259 encoder->i2c->name, err, encoder->addr, subaddr); 259 encoder->i2c->name, err, encoder->addr, subaddr);
260 schedule_timeout_interruptible(HZ/10); 260 schedule_timeout_interruptible(msecs_to_jiffies(100));
261 } 261 }
262 if (err == 3) { 262 if (err == 3) {
263 printk(KERN_WARNING "%s: giving up\n", 263 printk(KERN_WARNING "%s: giving up\n",
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 2aea09c72093..387cb2122d4f 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4209,7 +4209,7 @@ static int tea5757_read(struct bttv *btv)
4209 bus_low(btv,btv->mbox_clk); 4209 bus_low(btv,btv->mbox_clk);
4210 4210
4211 udelay(10); 4211 udelay(10);
4212 timeout= jiffies + HZ; 4212 timeout= jiffies + msecs_to_jiffies(1000);
4213 4213
4214 /* wait for DATA line to go low; error if it doesn't */ 4214 /* wait for DATA line to go low; error if it doesn't */
4215 while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout)) 4215 while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 94a13d0ee614..4201552bc3c0 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -153,7 +153,7 @@ static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
153{ 153{
154 if (ir->polling) { 154 if (ir->polling) {
155 setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv); 155 setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv);
156 ir->timer.expires = jiffies + HZ; 156 ir->timer.expires = jiffies + msecs_to_jiffies(1000);
157 add_timer(&ir->timer); 157 add_timer(&ir->timer);
158 } else if (ir->rc5_gpio) { 158 } else if (ir->rc5_gpio) {
159 /* set timer_end for code completion */ 159 /* set timer_end for code completion */
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index bd85f6d0fbe3..5b25faca1504 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -284,8 +284,8 @@ extern int fini_bttv_i2c(struct bttv *btv);
284#define d2printk if (bttv_debug >= 2) printk 284#define d2printk if (bttv_debug >= 2) printk
285 285
286#define BTTV_MAX_FBUF 0x208000 286#define BTTV_MAX_FBUF 0x208000
287#define BTTV_TIMEOUT (HZ/2) /* 0.5 seconds */ 287#define BTTV_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
288#define BTTV_FREE_IDLE (HZ) /* one second */ 288#define BTTV_FREE_IDLE msecs_to_jiffies(1000) /* one second */
289 289
290 290
291struct bttv_pll_info { 291struct bttv_pll_info {
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 925ff17efbbc..f76c6a6c3766 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -95,7 +95,7 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
95 unsigned long oldjiffies = jiffies; 95 unsigned long oldjiffies = jiffies;
96 unsigned int i; 96 unsigned int i;
97 97
98 for (oldjiffies = jiffies; (jiffies - oldjiffies) < (HZ/25); ) 98 for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); )
99 if (qcam_ready1(qcam) == value) 99 if (qcam_ready1(qcam) == value)
100 return 0; 100 return 0;
101 101
@@ -120,7 +120,7 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
120 unsigned long oldjiffies = jiffies; 120 unsigned long oldjiffies = jiffies;
121 unsigned int i; 121 unsigned int i;
122 122
123 for (oldjiffies = jiffies; (jiffies - oldjiffies) < (HZ/25); ) 123 for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); )
124 if (qcam_ready2(qcam) == value) 124 if (qcam_ready2(qcam) == value)
125 return 0; 125 return 0;
126 126
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 98fa35421bdd..06b233a7b20b 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1881,8 +1881,14 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1881 mutex_unlock(&core->lock); 1881 mutex_unlock(&core->lock);
1882 1882
1883 /* start tvaudio thread */ 1883 /* start tvaudio thread */
1884 if (core->tuner_type != TUNER_ABSENT) 1884 if (core->tuner_type != TUNER_ABSENT) {
1885 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); 1885 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
1886 if (IS_ERR(core->kthread)) {
1887 err = PTR_ERR(core->kthread);
1888 printk(KERN_ERR "Failed to create cx88 audio thread, err=%d\n",
1889 err);
1890 }
1891 }
1886 return 0; 1892 return 0;
1887 1893
1888fail_unreg: 1894fail_unreg:
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index c4f656ec46b0..809126866a3e 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -259,7 +259,7 @@ struct cx88_subid {
259#define RESOURCE_VIDEO 2 259#define RESOURCE_VIDEO 2
260#define RESOURCE_VBI 4 260#define RESOURCE_VBI 4
261 261
262#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ 262#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
263 263
264/* buffer for one video frame */ 264/* buffer for one video frame */
265struct cx88_buffer { 265struct cx88_buffer {
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index 1aaeaa02f158..e43beb2c9cbf 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 select I2C_ALGOBIT
4 select FW_LOADER 5 select FW_LOADER
5 select VIDEO_TUNER 6 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
@@ -16,11 +17,11 @@ config VIDEO_IVTV
16 select VIDEO_UPD64031A 17 select VIDEO_UPD64031A
17 select VIDEO_UPD64083 18 select VIDEO_UPD64083
18 ---help--- 19 ---help---
19 This is a video4linux driver for Conexant cx23416 or cx23416 based 20 This is a video4linux driver for Conexant cx23416 or cx23415 based
20 PCI personal video recorder devices. 21 PCI personal video recorder devices.
21 22
22 This is used in devices such as the Hauppauge PVR-150/250/350/500 23 This is used in devices such as the Hauppauge PVR-150/250/350/500
23 cards. 24 cards. There is a driver homepage at <http://www.ivtvdriver.org>.
24 25
25 To compile this driver as a module, choose M here: the 26 To compile this driver as a module, choose M here: the
26 module will be called ivtv. 27 module will be called ivtv.
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 4c93466a89e5..d73d433a4ff6 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -56,7 +56,6 @@
56#include "ivtv-gpio.h" 56#include "ivtv-gpio.h"
57#include "ivtv-yuv.h" 57#include "ivtv-yuv.h"
58 58
59#include <linux/vermagic.h>
60#include <media/tveeprom.h> 59#include <media/tveeprom.h>
61#include <media/v4l2-chip-ident.h> 60#include <media/v4l2-chip-ident.h>
62 61
@@ -276,9 +275,10 @@ int ivtv_waitq(wait_queue_head_t *waitq)
276} 275}
277 276
278/* Generic utility functions */ 277/* Generic utility functions */
279int ivtv_sleep_timeout(int timeout, int intr) 278int ivtv_msleep_timeout(unsigned int msecs, int intr)
280{ 279{
281 int ret; 280 int ret;
281 int timeout = msecs_to_jiffies(msecs);
282 282
283 do { 283 do {
284 set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); 284 set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
@@ -427,7 +427,7 @@ static void ivtv_process_eeprom(struct ivtv *itv)
427 if (itv->options.newi2c == -1 && tv.has_ir != -1 && tv.has_ir != 2) { 427 if (itv->options.newi2c == -1 && tv.has_ir != -1 && tv.has_ir != 2) {
428 itv->options.newi2c = (tv.has_ir & 2) ? 1 : 0; 428 itv->options.newi2c = (tv.has_ir & 2) ? 1 : 0;
429 if (itv->options.newi2c) { 429 if (itv->options.newi2c) {
430 IVTV_INFO("reopen i2c bus for IR-blaster support\n"); 430 IVTV_INFO("Reopen i2c bus for IR-blaster support\n");
431 exit_ivtv_i2c(itv); 431 exit_ivtv_i2c(itv);
432 init_ivtv_i2c(itv); 432 init_ivtv_i2c(itv);
433 } 433 }
@@ -951,7 +951,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
951 951
952 /* Make sure we've got a place for this card */ 952 /* Make sure we've got a place for this card */
953 if (ivtv_cards_active == IVTV_MAX_CARDS) { 953 if (ivtv_cards_active == IVTV_MAX_CARDS) {
954 printk(KERN_ERR "ivtv: Maximum number of cards detected (%d).\n", 954 printk(KERN_ERR "ivtv: Maximum number of cards detected (%d)\n",
955 ivtv_cards_active); 955 ivtv_cards_active);
956 spin_unlock(&ivtv_cards_lock); 956 spin_unlock(&ivtv_cards_lock);
957 return -ENOMEM; 957 return -ENOMEM;
@@ -966,9 +966,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
966 itv->dev = dev; 966 itv->dev = dev;
967 itv->num = ivtv_cards_active++; 967 itv->num = ivtv_cards_active++;
968 snprintf(itv->name, sizeof(itv->name) - 1, "ivtv%d", itv->num); 968 snprintf(itv->name, sizeof(itv->name) - 1, "ivtv%d", itv->num);
969 if (itv->num) { 969 IVTV_INFO("Initializing card #%d\n", itv->num);
970 printk(KERN_INFO "ivtv: ====================== NEXT CARD ======================\n");
971 }
972 970
973 spin_unlock(&ivtv_cards_lock); 971 spin_unlock(&ivtv_cards_lock);
974 972
@@ -1215,7 +1213,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1215 if (itv->has_cx23415) 1213 if (itv->has_cx23415)
1216 ivtv_set_osd_alpha(itv); 1214 ivtv_set_osd_alpha(itv);
1217 1215
1218 IVTV_INFO("Initialized %s, card #%d\n", itv->card_name, itv->num); 1216 IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name);
1219 1217
1220 return 0; 1218 return 0;
1221 1219
@@ -1248,15 +1246,15 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1248{ 1246{
1249 struct ivtv *itv = pci_get_drvdata(pci_dev); 1247 struct ivtv *itv = pci_get_drvdata(pci_dev);
1250 1248
1251 IVTV_DEBUG_INFO("Removing Card #%d.\n", itv->num); 1249 IVTV_DEBUG_INFO("Removing Card #%d\n", itv->num);
1252 1250
1253 /* Stop all captures */ 1251 /* Stop all captures */
1254 IVTV_DEBUG_INFO(" Stopping all streams.\n"); 1252 IVTV_DEBUG_INFO("Stopping all streams\n");
1255 if (atomic_read(&itv->capturing) > 0) 1253 if (atomic_read(&itv->capturing) > 0)
1256 ivtv_stop_all_captures(itv); 1254 ivtv_stop_all_captures(itv);
1257 1255
1258 /* Stop all decoding */ 1256 /* Stop all decoding */
1259 IVTV_DEBUG_INFO(" Stopping decoding.\n"); 1257 IVTV_DEBUG_INFO("Stopping decoding\n");
1260 if (atomic_read(&itv->decoding) > 0) { 1258 if (atomic_read(&itv->decoding) > 0) {
1261 int type; 1259 int type;
1262 1260
@@ -1269,30 +1267,30 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1269 } 1267 }
1270 1268
1271 /* Interrupts */ 1269 /* Interrupts */
1272 IVTV_DEBUG_INFO(" Disabling interrupts.\n"); 1270 IVTV_DEBUG_INFO("Disabling interrupts\n");
1273 ivtv_set_irq_mask(itv, 0xffffffff); 1271 ivtv_set_irq_mask(itv, 0xffffffff);
1274 del_timer_sync(&itv->dma_timer); 1272 del_timer_sync(&itv->dma_timer);
1275 1273
1276 /* Stop all Work Queues */ 1274 /* Stop all Work Queues */
1277 IVTV_DEBUG_INFO(" Stop Work Queues.\n"); 1275 IVTV_DEBUG_INFO("Stop Work Queues\n");
1278 flush_workqueue(itv->irq_work_queues); 1276 flush_workqueue(itv->irq_work_queues);
1279 destroy_workqueue(itv->irq_work_queues); 1277 destroy_workqueue(itv->irq_work_queues);
1280 1278
1281 IVTV_DEBUG_INFO(" Stopping Firmware.\n"); 1279 IVTV_DEBUG_INFO("Stopping Firmware\n");
1282 ivtv_halt_firmware(itv); 1280 ivtv_halt_firmware(itv);
1283 1281
1284 IVTV_DEBUG_INFO(" Unregistering v4l devices.\n"); 1282 IVTV_DEBUG_INFO("Unregistering v4l devices\n");
1285 ivtv_streams_cleanup(itv); 1283 ivtv_streams_cleanup(itv);
1286 IVTV_DEBUG_INFO(" Freeing dma resources.\n"); 1284 IVTV_DEBUG_INFO("Freeing dma resources\n");
1287 ivtv_udma_free(itv); 1285 ivtv_udma_free(itv);
1288 1286
1289 exit_ivtv_i2c(itv); 1287 exit_ivtv_i2c(itv);
1290 1288
1291 IVTV_DEBUG_INFO(" Releasing irq.\n"); 1289 IVTV_DEBUG_INFO(" Releasing irq\n");
1292 free_irq(itv->dev->irq, (void *)itv); 1290 free_irq(itv->dev->irq, (void *)itv);
1293 ivtv_iounmap(itv); 1291 ivtv_iounmap(itv);
1294 1292
1295 IVTV_DEBUG_INFO(" Releasing mem.\n"); 1293 IVTV_DEBUG_INFO(" Releasing mem\n");
1296 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); 1294 release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
1297 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); 1295 release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
1298 if (itv->has_cx23415) 1296 if (itv->has_cx23415)
@@ -1313,28 +1311,27 @@ static struct pci_driver ivtv_pci_driver = {
1313 1311
1314static int module_start(void) 1312static int module_start(void)
1315{ 1313{
1316 printk(KERN_INFO "ivtv: ==================== START INIT IVTV ====================\n"); 1314 printk(KERN_INFO "ivtv: Start initialization, version %s\n", IVTV_VERSION);
1317 printk(KERN_INFO "ivtv: version %s (" VERMAGIC_STRING ") loading\n", IVTV_VERSION);
1318 1315
1319 memset(ivtv_cards, 0, sizeof(ivtv_cards)); 1316 memset(ivtv_cards, 0, sizeof(ivtv_cards));
1320 1317
1321 /* Validate parameters */ 1318 /* Validate parameters */
1322 if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) { 1319 if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) {
1323 printk(KERN_ERR "ivtv: ivtv_first_minor must be between 0 and %d. Exiting...\n", 1320 printk(KERN_ERR "ivtv: Exiting, ivtv_first_minor must be between 0 and %d\n",
1324 IVTV_MAX_CARDS - 1); 1321 IVTV_MAX_CARDS - 1);
1325 return -1; 1322 return -1;
1326 } 1323 }
1327 1324
1328 if (ivtv_debug < 0 || ivtv_debug > 1023) { 1325 if (ivtv_debug < 0 || ivtv_debug > 1023) {
1329 ivtv_debug = 0; 1326 ivtv_debug = 0;
1330 printk(KERN_INFO "ivtv: debug value must be >= 0 and <= 1023!\n"); 1327 printk(KERN_INFO "ivtv: Debug value must be >= 0 and <= 1023\n");
1331 } 1328 }
1332 1329
1333 if (pci_register_driver(&ivtv_pci_driver)) { 1330 if (pci_register_driver(&ivtv_pci_driver)) {
1334 printk(KERN_ERR "ivtv: Error detecting PCI card\n"); 1331 printk(KERN_ERR "ivtv: Error detecting PCI card\n");
1335 return -ENODEV; 1332 return -ENODEV;
1336 } 1333 }
1337 printk(KERN_INFO "ivtv: ==================== END INIT IVTV ====================\n"); 1334 printk(KERN_INFO "ivtv: End initialization\n");
1338 return 0; 1335 return 0;
1339} 1336}
1340 1337
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 6c1a85f1ee1b..91b588d261ae 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -848,7 +848,7 @@ int ivtv_set_output_mode(struct ivtv *itv, int mode);
848struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv); 848struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv);
849 849
850/* Return non-zero if a signal is pending */ 850/* Return non-zero if a signal is pending */
851int ivtv_sleep_timeout(int timeout, int intr); 851int ivtv_msleep_timeout(unsigned int msecs, int intr);
852 852
853/* Wait on queue, returns -EINTR if interrupted */ 853/* Wait on queue, returns -EINTR if interrupted */
854int ivtv_waitq(wait_queue_head_t *waitq); 854int ivtv_waitq(wait_queue_head_t *waitq);
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index ee7e884e9c4f..8e97a938398f 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -218,7 +218,7 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block,
218 /* Process pending program info updates and pending VBI data */ 218 /* Process pending program info updates and pending VBI data */
219 ivtv_update_pgm_info(itv); 219 ivtv_update_pgm_info(itv);
220 220
221 if (jiffies - itv->dualwatch_jiffies > HZ) { 221 if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) {
222 itv->dualwatch_jiffies = jiffies; 222 itv->dualwatch_jiffies = jiffies;
223 ivtv_dualwatch(itv); 223 ivtv_dualwatch(itv);
224 } 224 }
@@ -832,7 +832,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
832 if (itv == NULL) { 832 if (itv == NULL) {
833 /* Couldn't find a device registered 833 /* Couldn't find a device registered
834 on that minor, shouldn't happen! */ 834 on that minor, shouldn't happen! */
835 printk(KERN_WARNING "ivtv: no ivtv device found on minor %d\n", minor); 835 printk(KERN_WARNING "ivtv: No ivtv device found on minor %d\n", minor);
836 return -ENXIO; 836 return -ENXIO;
837 } 837 }
838 838
@@ -924,7 +924,7 @@ void ivtv_unmute(struct ivtv *itv)
924 if (atomic_read(&itv->capturing) == 0) 924 if (atomic_read(&itv->capturing) == 0)
925 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); 925 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
926 926
927 ivtv_sleep_timeout(HZ / 10, 0); 927 ivtv_msleep_timeout(100, 0);
928 928
929 if (atomic_read(&itv->capturing)) { 929 if (atomic_read(&itv->capturing)) {
930 ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12); 930 ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12);
diff --git a/drivers/media/video/ivtv/ivtv-firmware.c b/drivers/media/video/ivtv/ivtv-firmware.c
index 2b6208a6a108..d0feabf93080 100644
--- a/drivers/media/video/ivtv/ivtv-firmware.c
+++ b/drivers/media/video/ivtv/ivtv-firmware.c
@@ -36,7 +36,7 @@
36#define IVTV_CMD_SPU_STOP 0x00000001 36#define IVTV_CMD_SPU_STOP 0x00000001
37#define IVTV_CMD_SDRAM_PRECHARGE_INIT 0x0000001A 37#define IVTV_CMD_SDRAM_PRECHARGE_INIT 0x0000001A
38#define IVTV_CMD_SDRAM_REFRESH_INIT 0x80000640 38#define IVTV_CMD_SDRAM_REFRESH_INIT 0x80000640
39#define IVTV_SDRAM_SLEEPTIME (60 * HZ / 100) /* 600 ms */ 39#define IVTV_SDRAM_SLEEPTIME 600
40 40
41#define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg" 41#define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg"
42#define IVTV_DECODE_INIT_MPEG_SIZE (152*1024) 42#define IVTV_DECODE_INIT_MPEG_SIZE (152*1024)
@@ -61,7 +61,7 @@ retry:
61 the wrong file was sometimes loaded. So we check filesizes to 61 the wrong file was sometimes loaded. So we check filesizes to
62 see if at least the right-sized file was loaded. If not, then we 62 see if at least the right-sized file was loaded. If not, then we
63 retry. */ 63 retry. */
64 IVTV_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n", fn, size, fw->size); 64 IVTV_INFO("Retry: file loaded was not %s (expected size %ld, got %zd)\n", fn, size, fw->size);
65 release_firmware(fw); 65 release_firmware(fw);
66 retries--; 66 retries--;
67 goto retry; 67 goto retry;
@@ -73,11 +73,11 @@ retry:
73 src++; 73 src++;
74 } 74 }
75 release_firmware(fw); 75 release_firmware(fw);
76 IVTV_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size); 76 IVTV_INFO("Loaded %s firmware (%zd bytes)\n", fn, fw->size);
77 return size; 77 return size;
78 } 78 }
79 IVTV_ERR("unable to open firmware %s (must be %ld bytes)\n", fn, size); 79 IVTV_ERR("Unable to open firmware %s (must be %ld bytes)\n", fn, size);
80 IVTV_ERR("did you put the firmware in the hotplug firmware directory?\n"); 80 IVTV_ERR("Did you put the firmware in the hotplug firmware directory?\n");
81 return -ENOMEM; 81 return -ENOMEM;
82} 82}
83 83
@@ -89,7 +89,7 @@ void ivtv_halt_firmware(struct ivtv *itv)
89 if (itv->enc_mbox.mbox) 89 if (itv->enc_mbox.mbox)
90 ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0); 90 ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0);
91 91
92 ivtv_sleep_timeout(HZ / 100, 0); 92 ivtv_msleep_timeout(10, 0);
93 itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL; 93 itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL;
94 94
95 IVTV_DEBUG_INFO("Stopping VDM\n"); 95 IVTV_DEBUG_INFO("Stopping VDM\n");
@@ -113,7 +113,7 @@ void ivtv_halt_firmware(struct ivtv *itv)
113 IVTV_DEBUG_INFO("Stopping SPU\n"); 113 IVTV_DEBUG_INFO("Stopping SPU\n");
114 write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU); 114 write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU);
115 115
116 ivtv_sleep_timeout(HZ / 100, 0); 116 ivtv_msleep_timeout(10, 0);
117 117
118 IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n"); 118 IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n");
119 write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE); 119 write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE);
@@ -129,9 +129,8 @@ void ivtv_halt_firmware(struct ivtv *itv)
129 write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH); 129 write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH);
130 } 130 }
131 131
132 IVTV_DEBUG_INFO("Sleeping for %dms (600 recommended)\n", 132 IVTV_DEBUG_INFO("Sleeping for %dms\n", IVTV_SDRAM_SLEEPTIME);
133 (int)(IVTV_SDRAM_SLEEPTIME * 1000 / HZ)); 133 ivtv_msleep_timeout(IVTV_SDRAM_SLEEPTIME, 0);
134 ivtv_sleep_timeout(IVTV_SDRAM_SLEEPTIME, 0);
135} 134}
136 135
137void ivtv_firmware_versions(struct ivtv *itv) 136void ivtv_firmware_versions(struct ivtv *itv)
@@ -204,12 +203,12 @@ int ivtv_firmware_init(struct ivtv *itv)
204 203
205 /* start firmware */ 204 /* start firmware */
206 write_reg(read_reg(IVTV_REG_SPU) & IVTV_MASK_SPU_ENABLE, IVTV_REG_SPU); 205 write_reg(read_reg(IVTV_REG_SPU) & IVTV_MASK_SPU_ENABLE, IVTV_REG_SPU);
207 ivtv_sleep_timeout(HZ / 10, 0); 206 ivtv_msleep_timeout(100, 0);
208 if (itv->has_cx23415) 207 if (itv->has_cx23415)
209 write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE15, IVTV_REG_VPU); 208 write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE15, IVTV_REG_VPU);
210 else 209 else
211 write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE16, IVTV_REG_VPU); 210 write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE16, IVTV_REG_VPU);
212 ivtv_sleep_timeout(HZ / 10, 0); 211 ivtv_msleep_timeout(100, 0);
213 212
214 /* find mailboxes and ping firmware */ 213 /* find mailboxes and ping firmware */
215 itv->enc_mbox.mbox = ivtv_search_mailbox(itv->enc_mem, IVTV_ENCODER_SIZE); 214 itv->enc_mbox.mbox = ivtv_search_mailbox(itv->enc_mem, IVTV_ENCODER_SIZE);
@@ -264,7 +263,7 @@ void ivtv_init_mpeg_decoder(struct ivtv *itv)
264 IVTV_DECODE_INIT_MPEG_FILENAME); 263 IVTV_DECODE_INIT_MPEG_FILENAME);
265 } else { 264 } else {
266 ivtv_vapi(itv, CX2341X_DEC_SCHED_DMA_FROM_HOST, 3, 0, readbytes, 0); 265 ivtv_vapi(itv, CX2341X_DEC_SCHED_DMA_FROM_HOST, 3, 0, readbytes, 0);
267 ivtv_sleep_timeout(HZ / 10, 0); 266 ivtv_msleep_timeout(100, 0);
268 } 267 }
269 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1); 268 ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1);
270} 269}
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c b/drivers/media/video/ivtv/ivtv-gpio.c
index 676418cbaaad..6a5a7aa66976 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -130,7 +130,7 @@ int ivtv_reset_tuner_gpio(enum v4l2_tuner_type mode, void *priv, int ptr)
130 130
131 if (itv->card->type != IVTV_CARD_PG600V2 || itv->options.tuner != TUNER_XCEIVE_XC3028) 131 if (itv->card->type != IVTV_CARD_PG600V2 || itv->options.tuner != TUNER_XCEIVE_XC3028)
132 return -EINVAL; 132 return -EINVAL;
133 IVTV_INFO("Resetting tuner.\n"); 133 IVTV_INFO("Resetting tuner\n");
134 curout = read_reg(IVTV_REG_GPIO_OUT); 134 curout = read_reg(IVTV_REG_GPIO_OUT);
135 curdir = read_reg(IVTV_REG_GPIO_DIR); 135 curdir = read_reg(IVTV_REG_GPIO_DIR);
136 curdir |= (1 << 12); /* GPIO bit 12 */ 136 curdir |= (1 << 12); /* GPIO bit 12 */
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 50624c6a62a5..b3557435456d 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -144,7 +144,7 @@ static int attach_inform(struct i2c_client *client)
144 } 144 }
145 } 145 }
146 if (i == I2C_CLIENTS_MAX) { 146 if (i == I2C_CLIENTS_MAX) {
147 IVTV_ERR("insufficient room for new I2C client!\n"); 147 IVTV_ERR("Insufficient room for new I2C client\n");
148 } 148 }
149 return 0; 149 return 0;
150} 150}
@@ -236,7 +236,7 @@ static int ivtv_ack(struct ivtv *itv)
236 int ret = 0; 236 int ret = 0;
237 237
238 if (ivtv_getscl(itv) == 1) { 238 if (ivtv_getscl(itv) == 1) {
239 IVTV_DEBUG_I2C("SCL was high starting an ack\n"); 239 IVTV_DEBUG_HI_I2C("SCL was high starting an ack\n");
240 ivtv_setscl(itv, 0); 240 ivtv_setscl(itv, 0);
241 if (!ivtv_waitscl(itv, 0)) { 241 if (!ivtv_waitscl(itv, 0)) {
242 IVTV_DEBUG_I2C("Could not set SCL low starting an ack\n"); 242 IVTV_DEBUG_I2C("Could not set SCL low starting an ack\n");
@@ -263,7 +263,7 @@ static int ivtv_sendbyte(struct ivtv *itv, unsigned char byte)
263{ 263{
264 int i, bit; 264 int i, bit;
265 265
266 IVTV_DEBUG_I2C("write %x\n",byte); 266 IVTV_DEBUG_HI_I2C("write %x\n",byte);
267 for (i = 0; i < 8; ++i, byte<<=1) { 267 for (i = 0; i < 8; ++i, byte<<=1) {
268 ivtv_setscl(itv, 0); 268 ivtv_setscl(itv, 0);
269 if (!ivtv_waitscl(itv, 0)) { 269 if (!ivtv_waitscl(itv, 0)) {
@@ -318,7 +318,7 @@ static int ivtv_readbyte(struct ivtv *itv, unsigned char *byte, int nack)
318 ivtv_scldelay(itv); 318 ivtv_scldelay(itv);
319 ivtv_setscl(itv, 0); 319 ivtv_setscl(itv, 0);
320 ivtv_scldelay(itv); 320 ivtv_scldelay(itv);
321 IVTV_DEBUG_I2C("read %x\n",*byte); 321 IVTV_DEBUG_HI_I2C("read %x\n",*byte);
322 return 0; 322 return 0;
323} 323}
324 324
@@ -330,7 +330,7 @@ static int ivtv_start(struct ivtv *itv)
330 330
331 sda = ivtv_getsda(itv); 331 sda = ivtv_getsda(itv);
332 if (sda != 1) { 332 if (sda != 1) {
333 IVTV_DEBUG_I2C("SDA was low at start\n"); 333 IVTV_DEBUG_HI_I2C("SDA was low at start\n");
334 ivtv_setsda(itv, 1); 334 ivtv_setsda(itv, 1);
335 if (!ivtv_waitsda(itv, 1)) { 335 if (!ivtv_waitsda(itv, 1)) {
336 IVTV_DEBUG_I2C("SDA stuck low\n"); 336 IVTV_DEBUG_I2C("SDA stuck low\n");
@@ -355,7 +355,7 @@ static int ivtv_stop(struct ivtv *itv)
355 int i; 355 int i;
356 356
357 if (ivtv_getscl(itv) != 0) { 357 if (ivtv_getscl(itv) != 0) {
358 IVTV_DEBUG_I2C("SCL not low when stopping\n"); 358 IVTV_DEBUG_HI_I2C("SCL not low when stopping\n");
359 ivtv_setscl(itv, 0); 359 ivtv_setscl(itv, 0);
360 if (!ivtv_waitscl(itv, 0)) { 360 if (!ivtv_waitscl(itv, 0)) {
361 IVTV_DEBUG_I2C("SCL could not be set low\n"); 361 IVTV_DEBUG_I2C("SCL could not be set low\n");
@@ -569,7 +569,7 @@ int ivtv_call_i2c_client(struct ivtv *itv, int addr, unsigned int cmd, void *arg
569 } 569 }
570 } 570 }
571 if (cmd != VIDIOC_G_CHIP_IDENT) 571 if (cmd != VIDIOC_G_CHIP_IDENT)
572 IVTV_ERR("i2c addr 0x%02x not found for command 0x%x!\n", addr, cmd); 572 IVTV_ERR("i2c addr 0x%02x not found for command 0x%x\n", addr, cmd);
573 return -ENODEV; 573 return -ENODEV;
574} 574}
575 575
@@ -640,7 +640,7 @@ int ivtv_i2c_hw(struct ivtv *itv, u32 hw, unsigned int cmd, void *arg)
640 640
641 addr = ivtv_i2c_hw_addr(itv, hw); 641 addr = ivtv_i2c_hw_addr(itv, hw);
642 if (addr < 0) { 642 if (addr < 0) {
643 IVTV_ERR("i2c hardware 0x%08x (%s) not found for command 0x%x!\n", 643 IVTV_ERR("i2c hardware 0x%08x (%s) not found for command 0x%x\n",
644 hw, ivtv_i2c_hw_name(hw), cmd); 644 hw, ivtv_i2c_hw_name(hw), cmd);
645 return addr; 645 return addr;
646 } 646 }
@@ -655,7 +655,7 @@ int ivtv_i2c_id(struct ivtv *itv, u32 id, unsigned int cmd, void *arg)
655 addr = ivtv_i2c_id_addr(itv, id); 655 addr = ivtv_i2c_id_addr(itv, id);
656 if (addr < 0) { 656 if (addr < 0) {
657 if (cmd != VIDIOC_G_CHIP_IDENT) 657 if (cmd != VIDIOC_G_CHIP_IDENT)
658 IVTV_ERR("i2c ID 0x%08x (%s) not found for command 0x%x!\n", 658 IVTV_ERR("i2c ID 0x%08x (%s) not found for command 0x%x\n",
659 id, ivtv_i2c_id_name(id), cmd); 659 id, ivtv_i2c_id_name(id), cmd);
660 return addr; 660 return addr;
661 } 661 }
@@ -696,7 +696,7 @@ int ivtv_upd64083(struct ivtv *itv, unsigned int cmd, void *arg)
696void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg) 696void ivtv_call_i2c_clients(struct ivtv *itv, unsigned int cmd, void *arg)
697{ 697{
698 if (itv->i2c_adap.algo == NULL) { 698 if (itv->i2c_adap.algo == NULL) {
699 IVTV_ERR("adapter is not set"); 699 IVTV_ERR("Adapter is not set");
700 return; 700 return;
701 } 701 }
702 i2c_clients_command(&itv->i2c_adap, cmd, arg); 702 i2c_clients_command(&itv->i2c_adap, cmd, arg);
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index 1a3ee464a826..fcd6e7f5f121 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -403,6 +403,11 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
403 /* Mark last buffer size for Interrupt flag */ 403 /* Mark last buffer size for Interrupt flag */
404 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000); 404 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000);
405 405
406 if (s->type == IVTV_ENC_STREAM_TYPE_VBI)
407 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
408 else
409 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
410
406 if (ivtv_use_pio(s)) { 411 if (ivtv_use_pio(s)) {
407 for (i = 0; i < s->SG_length; i++) { 412 for (i = 0; i < s->SG_length; i++) {
408 s->PIOarray[i].src = le32_to_cpu(s->SGarray[i].src); 413 s->PIOarray[i].src = le32_to_cpu(s->SGarray[i].src);
@@ -420,7 +425,7 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
420 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); 425 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER);
421 set_bit(IVTV_F_I_DMA, &itv->i_flags); 426 set_bit(IVTV_F_I_DMA, &itv->i_flags);
422 itv->cur_dma_stream = s->type; 427 itv->cur_dma_stream = s->type;
423 itv->dma_timer.expires = jiffies + HZ / 10; 428 itv->dma_timer.expires = jiffies + msecs_to_jiffies(100);
424 add_timer(&itv->dma_timer); 429 add_timer(&itv->dma_timer);
425 } 430 }
426} 431}
@@ -437,7 +442,7 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s)
437 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); 442 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER);
438 set_bit(IVTV_F_I_DMA, &itv->i_flags); 443 set_bit(IVTV_F_I_DMA, &itv->i_flags);
439 itv->cur_dma_stream = s->type; 444 itv->cur_dma_stream = s->type;
440 itv->dma_timer.expires = jiffies + HZ / 10; 445 itv->dma_timer.expires = jiffies + msecs_to_jiffies(100);
441 add_timer(&itv->dma_timer); 446 add_timer(&itv->dma_timer);
442} 447}
443 448
@@ -597,7 +602,6 @@ static void ivtv_irq_enc_start_cap(struct ivtv *itv)
597 data[0], data[1], data[2]); 602 data[0], data[1], data[2]);
598 return; 603 return;
599 } 604 }
600 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
601 s = &itv->streams[ivtv_stream_map[data[0]]]; 605 s = &itv->streams[ivtv_stream_map[data[0]]];
602 if (!stream_enc_dma_append(s, data)) { 606 if (!stream_enc_dma_append(s, data)) {
603 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags); 607 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
@@ -634,7 +638,6 @@ static void ivtv_irq_enc_vbi_cap(struct ivtv *itv)
634 then start a DMA request for just the VBI data. */ 638 then start a DMA request for just the VBI data. */
635 if (!stream_enc_dma_append(s, data) && 639 if (!stream_enc_dma_append(s, data) &&
636 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) { 640 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) {
637 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
638 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags); 641 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
639 } 642 }
640} 643}
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c
index 6ae42a3b03cc..814a673712b3 100644
--- a/drivers/media/video/ivtv/ivtv-mailbox.c
+++ b/drivers/media/video/ivtv/ivtv-mailbox.c
@@ -37,6 +37,7 @@
37#define API_RESULT (1 << 1) /* Allow 1 second for this cmd to end */ 37#define API_RESULT (1 << 1) /* Allow 1 second for this cmd to end */
38#define API_FAST_RESULT (3 << 1) /* Allow 0.1 second for this cmd to end */ 38#define API_FAST_RESULT (3 << 1) /* Allow 0.1 second for this cmd to end */
39#define API_DMA (1 << 3) /* DMA mailbox, has special handling */ 39#define API_DMA (1 << 3) /* DMA mailbox, has special handling */
40#define API_HIGH_VOL (1 << 5) /* High volume command (i.e. called during encoding or decoding) */
40#define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */ 41#define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */
41#define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */ 42#define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */
42 43
@@ -77,11 +78,11 @@ static const struct ivtv_api_info api_info[256] = {
77 API_ENTRY(CX2341X_ENC_SET_DMA_BLOCK_SIZE, API_CACHE), 78 API_ENTRY(CX2341X_ENC_SET_DMA_BLOCK_SIZE, API_CACHE),
78 API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_10, API_FAST_RESULT), 79 API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_10, API_FAST_RESULT),
79 API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_9, API_FAST_RESULT), 80 API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_9, API_FAST_RESULT),
80 API_ENTRY(CX2341X_ENC_SCHED_DMA_TO_HOST, API_DMA), 81 API_ENTRY(CX2341X_ENC_SCHED_DMA_TO_HOST, API_DMA | API_HIGH_VOL),
81 API_ENTRY(CX2341X_ENC_INITIALIZE_INPUT, API_RESULT), 82 API_ENTRY(CX2341X_ENC_INITIALIZE_INPUT, API_RESULT),
82 API_ENTRY(CX2341X_ENC_SET_FRAME_DROP_RATE, API_CACHE), 83 API_ENTRY(CX2341X_ENC_SET_FRAME_DROP_RATE, API_CACHE),
83 API_ENTRY(CX2341X_ENC_PAUSE_ENCODER, API_RESULT), 84 API_ENTRY(CX2341X_ENC_PAUSE_ENCODER, API_RESULT),
84 API_ENTRY(CX2341X_ENC_REFRESH_INPUT, API_NO_WAIT_MB), 85 API_ENTRY(CX2341X_ENC_REFRESH_INPUT, API_NO_WAIT_MB | API_HIGH_VOL),
85 API_ENTRY(CX2341X_ENC_SET_COPYRIGHT, API_CACHE), 86 API_ENTRY(CX2341X_ENC_SET_COPYRIGHT, API_CACHE),
86 API_ENTRY(CX2341X_ENC_SET_EVENT_NOTIFICATION, API_RESULT), 87 API_ENTRY(CX2341X_ENC_SET_EVENT_NOTIFICATION, API_RESULT),
87 API_ENTRY(CX2341X_ENC_SET_NUM_VSYNC_LINES, API_CACHE), 88 API_ENTRY(CX2341X_ENC_SET_NUM_VSYNC_LINES, API_CACHE),
@@ -102,7 +103,7 @@ static const struct ivtv_api_info api_info[256] = {
102 API_ENTRY(CX2341X_DEC_SET_DMA_BLOCK_SIZE, API_CACHE), 103 API_ENTRY(CX2341X_DEC_SET_DMA_BLOCK_SIZE, API_CACHE),
103 API_ENTRY(CX2341X_DEC_GET_XFER_INFO, API_FAST_RESULT), 104 API_ENTRY(CX2341X_DEC_GET_XFER_INFO, API_FAST_RESULT),
104 API_ENTRY(CX2341X_DEC_GET_DMA_STATUS, API_FAST_RESULT), 105 API_ENTRY(CX2341X_DEC_GET_DMA_STATUS, API_FAST_RESULT),
105 API_ENTRY(CX2341X_DEC_SCHED_DMA_FROM_HOST, API_DMA), 106 API_ENTRY(CX2341X_DEC_SCHED_DMA_FROM_HOST, API_DMA | API_HIGH_VOL),
106 API_ENTRY(CX2341X_DEC_PAUSE_PLAYBACK, API_RESULT), 107 API_ENTRY(CX2341X_DEC_PAUSE_PLAYBACK, API_RESULT),
107 API_ENTRY(CX2341X_DEC_HALT_FW, API_FAST_RESULT), 108 API_ENTRY(CX2341X_DEC_HALT_FW, API_FAST_RESULT),
108 API_ENTRY(CX2341X_DEC_SET_STANDARD, API_CACHE), 109 API_ENTRY(CX2341X_DEC_SET_STANDARD, API_CACHE),
@@ -175,9 +176,9 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f
175 176
176 /* Sleep before a retry, if not atomic */ 177 /* Sleep before a retry, if not atomic */
177 if (!(flags & API_NO_WAIT_MB)) { 178 if (!(flags & API_NO_WAIT_MB)) {
178 if (jiffies - then > retries * HZ / 100) 179 if (jiffies - then > msecs_to_jiffies(10*retries))
179 break; 180 break;
180 ivtv_sleep_timeout(HZ / 100, 0); 181 ivtv_msleep_timeout(10, 0);
181 } 182 }
182 } 183 }
183 return -ENODEV; 184 return -ENODEV;
@@ -212,7 +213,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
212{ 213{
213 struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox; 214 struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox;
214 volatile struct ivtv_mailbox __iomem *mbox; 215 volatile struct ivtv_mailbox __iomem *mbox;
215 int api_timeout = HZ; 216 int api_timeout = msecs_to_jiffies(1000);
216 int flags, mb, i; 217 int flags, mb, i;
217 unsigned long then; 218 unsigned long then;
218 219
@@ -227,7 +228,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
227 return -EINVAL; 228 return -EINVAL;
228 } 229 }
229 230
230 IVTV_DEBUG_API("API Call: %s\n", api_info[cmd].name); 231 if (api_info[cmd].flags & API_HIGH_VOL) {
232 IVTV_DEBUG_HI_API("API Call: %s\n", api_info[cmd].name);
233 }
234 else {
235 IVTV_DEBUG_API("API Call: %s\n", api_info[cmd].name);
236 }
231 237
232 /* clear possibly uninitialized part of data array */ 238 /* clear possibly uninitialized part of data array */
233 for (i = args; i < CX2341X_MBOX_MAX_DATA; i++) 239 for (i = args; i < CX2341X_MBOX_MAX_DATA; i++)
@@ -237,7 +243,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
237 data, then just return 0 as there is no need to issue this command again. 243 data, then just return 0 as there is no need to issue this command again.
238 Just an optimization to prevent unnecessary use of mailboxes. */ 244 Just an optimization to prevent unnecessary use of mailboxes. */
239 if (itv->api_cache[cmd].last_jiffies && 245 if (itv->api_cache[cmd].last_jiffies &&
240 jiffies - itv->api_cache[cmd].last_jiffies < HZ * 1800 && 246 jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) &&
241 !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { 247 !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) {
242 itv->api_cache[cmd].last_jiffies = jiffies; 248 itv->api_cache[cmd].last_jiffies = jiffies;
243 return 0; 249 return 0;
@@ -262,7 +268,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
262 } 268 }
263 269
264 if ((flags & API_FAST_RESULT) == API_FAST_RESULT) 270 if ((flags & API_FAST_RESULT) == API_FAST_RESULT)
265 api_timeout = HZ / 10; 271 api_timeout = msecs_to_jiffies(100);
266 272
267 mb = get_mailbox(itv, mbdata, flags); 273 mb = get_mailbox(itv, mbdata, flags);
268 if (mb < 0) { 274 if (mb < 0) {
@@ -295,11 +301,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
295 if (flags & API_NO_WAIT_RES) 301 if (flags & API_NO_WAIT_RES)
296 mdelay(1); 302 mdelay(1);
297 else 303 else
298 ivtv_sleep_timeout(HZ / 100, 0); 304 ivtv_msleep_timeout(10, 0);
299 } 305 }
300 if (jiffies - then > HZ / 10) 306 if (jiffies - then > msecs_to_jiffies(100))
301 IVTV_DEBUG_WARN("%s took %lu jiffies (%d per HZ)\n", 307 IVTV_DEBUG_WARN("%s took %u jiffies\n",
302 api_info[cmd].name, jiffies - then, HZ); 308 api_info[cmd].name,
309 jiffies_to_msecs(jiffies - then));
303 310
304 for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) 311 for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++)
305 data[i] = readl(&mbox->data[i]); 312 data[i] = readl(&mbox->data[i]);
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 287117187499..322b347b67c2 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -565,7 +565,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
565 /* Initialize Digitizer for Capture */ 565 /* Initialize Digitizer for Capture */
566 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); 566 ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
567 567
568 ivtv_sleep_timeout(HZ / 10, 0); 568 ivtv_msleep_timeout(100, 0);
569 } 569 }
570 570
571 /* begin_capture */ 571 /* begin_capture */
@@ -781,8 +781,9 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
781 set_current_state(TASK_INTERRUPTIBLE); 781 set_current_state(TASK_INTERRUPTIBLE);
782 782
783 /* wait 2s for EOS interrupt */ 783 /* wait 2s for EOS interrupt */
784 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && jiffies < then + 2 * HZ) { 784 while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
785 schedule_timeout(HZ / 100); 785 jiffies < then + msecs_to_jiffies (2000)) {
786 schedule_timeout(msecs_to_jiffies(10));
786 } 787 }
787 788
788 /* To convert jiffies to ms, we must multiply by 1000 789 /* To convert jiffies to ms, we must multiply by 1000
@@ -821,7 +822,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
821 } else if (read_reg(IVTV_REG_DMASTATUS) & 0x02) { 822 } else if (read_reg(IVTV_REG_DMASTATUS) & 0x02) {
822 break; 823 break;
823 } 824 }
824 } while (!ivtv_sleep_timeout(HZ / 100, 1) && then + HZ * 2 > jiffies); 825 } while (!ivtv_msleep_timeout(10, 1) &&
826 then + msecs_to_jiffies(2000) > jiffies);
825 827
826 set_current_state(TASK_RUNNING); 828 set_current_state(TASK_RUNNING);
827 remove_wait_queue(&s->waitq, &wait); 829 remove_wait_queue(&s->waitq, &wait);
@@ -892,7 +894,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
892 break; 894 break;
893 tmp = data[3]; 895 tmp = data[3];
894 } 896 }
895 if (ivtv_sleep_timeout(HZ/10, 1)) 897 if (ivtv_msleep_timeout(100, 1))
896 break; 898 break;
897 } 899 }
898 } 900 }
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index f2a2f34cd626..17f1e2e9a66b 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -86,9 +86,9 @@ static const int disp_modes[8][3] =
86 86
87 87
88 88
89#define PAGE_WAIT (300*HZ/1000) /* Time between requesting page and */ 89#define PAGE_WAIT msecs_to_jiffies(300) /* Time between requesting page and */
90 /* checking status bits */ 90 /* checking status bits */
91#define PGBUF_EXPIRE (15*HZ) /* Time to wait before retransmitting */ 91#define PGBUF_EXPIRE msecs_to_jiffies(15000) /* Time to wait before retransmitting */
92 /* page regardless of infobits */ 92 /* page regardless of infobits */
93typedef struct { 93typedef struct {
94 u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */ 94 u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */
@@ -115,8 +115,8 @@ struct saa5249_device
115#define CCTWR 34 /* I²C write/read-address of vtx-chip */ 115#define CCTWR 34 /* I²C write/read-address of vtx-chip */
116#define CCTRD 35 116#define CCTRD 35
117#define NOACK_REPEAT 10 /* Retry access this many times on failure */ 117#define NOACK_REPEAT 10 /* Retry access this many times on failure */
118#define CLEAR_DELAY (HZ/20) /* Time required to clear a page */ 118#define CLEAR_DELAY msecs_to_jiffies(50) /* Time required to clear a page */
119#define READY_TIMEOUT (30*HZ/1000) /* Time to wait for ready signal of I²C-bus interface */ 119#define READY_TIMEOUT msecs_to_jiffies(30) /* Time to wait for ready signal of I2C-bus interface */
120#define INIT_DELAY 500 /* Time in usec to wait at initialization of CEA interface */ 120#define INIT_DELAY 500 /* Time in usec to wait at initialization of CEA interface */
121#define START_DELAY 10 /* Time in usec to wait before starting write-cycle (CEA) */ 121#define START_DELAY 10 /* Time in usec to wait before starting write-cycle (CEA) */
122 122
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 676b9970eb2e..061134a7ba9f 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -208,7 +208,7 @@ determine_norm (struct i2c_client *client)
208 saa7110_write_block(client, initseq, sizeof(initseq)); 208 saa7110_write_block(client, initseq, sizeof(initseq));
209 saa7110_selmux(client, decoder->input); 209 saa7110_selmux(client, decoder->input);
210 prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE); 210 prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE);
211 schedule_timeout(HZ/4); 211 schedule_timeout(msecs_to_jiffies(250));
212 finish_wait(&decoder->wq, &wait); 212 finish_wait(&decoder->wq, &wait);
213 status = saa7110_read(client); 213 status = saa7110_read(client);
214 if (status & 0x40) { 214 if (status & 0x40) {
@@ -249,7 +249,7 @@ determine_norm (struct i2c_client *client)
249 //saa7110_write(client,0x2E,0x9A); 249 //saa7110_write(client,0x2E,0x9A);
250 250
251 prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE); 251 prepare_to_wait(&decoder->wq, &wait, TASK_UNINTERRUPTIBLE);
252 schedule_timeout(HZ/4); 252 schedule_timeout(msecs_to_jiffies(250));
253 finish_wait(&decoder->wq, &wait); 253 finish_wait(&decoder->wq, &wait);
254 254
255 status = saa7110_read(client); 255 status = saa7110_read(client);
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index d32a856192d7..346255468dad 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -314,7 +314,7 @@ struct saa7134_board {
314#define INTERLACE_ON 1 314#define INTERLACE_ON 1
315#define INTERLACE_OFF 2 315#define INTERLACE_OFF 2
316 316
317#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ 317#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
318 318
319struct saa7134_dev; 319struct saa7134_dev;
320struct saa7134_dma; 320struct saa7134_dma;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 9da338dc4f3b..cffb011590e3 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -290,7 +290,7 @@ static int chip_thread(void *data)
290 desc->checkmode(chip); 290 desc->checkmode(chip);
291 291
292 /* schedule next check */ 292 /* schedule next check */
293 mod_timer(&chip->wt, jiffies+2*HZ); 293 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
294 } 294 }
295 295
296 v4l_dbg(1, debug, &chip->c, "%s: thread exiting\n", chip->c.name); 296 v4l_dbg(1, debug, &chip->c, "%s: thread exiting\n", chip->c.name);
@@ -1770,7 +1770,7 @@ static int chip_command(struct i2c_client *client,
1770 desc->setmode(chip,VIDEO_SOUND_MONO); 1770 desc->setmode(chip,VIDEO_SOUND_MONO);
1771 if (chip->prevmode != VIDEO_SOUND_MONO) 1771 if (chip->prevmode != VIDEO_SOUND_MONO)
1772 chip->prevmode = -1; /* reset previous mode */ 1772 chip->prevmode = -1; /* reset previous mode */
1773 mod_timer(&chip->wt, jiffies+2*HZ); 1773 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
1774 /* the thread will call checkmode() later */ 1774 /* the thread will call checkmode() later */
1775 } 1775 }
1776 break; 1776 break;
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 13ee550d3215..d2915d3530ea 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -939,16 +939,25 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
939 When no more controls are available 0 is returned. */ 939 When no more controls are available 0 is returned. */
940u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) 940u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
941{ 941{
942 u32 ctrl_class; 942 u32 ctrl_class = V4L2_CTRL_ID2CLASS(id);
943 const u32 *pctrl; 943 const u32 *pctrl;
944 944
945 /* if no query is desired, then just return the control ID */
946 if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0)
947 return id;
948 if (ctrl_classes == NULL) 945 if (ctrl_classes == NULL)
949 return 0; 946 return 0;
947
948 /* if no query is desired, then check if the ID is part of ctrl_classes */
949 if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0) {
950 /* find class */
951 while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) != ctrl_class)
952 ctrl_classes++;
953 if (*ctrl_classes == NULL)
954 return 0;
955 pctrl = *ctrl_classes;
956 /* find control ID */
957 while (*pctrl && *pctrl != id) pctrl++;
958 return *pctrl ? id : 0;
959 }
950 id &= V4L2_CTRL_ID_MASK; 960 id &= V4L2_CTRL_ID_MASK;
951 ctrl_class = V4L2_CTRL_ID2CLASS(id);
952 id++; /* select next control */ 961 id++; /* select next control */
953 /* find first class that matches (or is greater than) the class of 962 /* find first class that matches (or is greater than) the class of
954 the ID */ 963 the ID */
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index e94a9a6036f5..a0c1647a2ba4 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -2080,7 +2080,7 @@ static int vino_wait_for_frame(struct vino_channel_settings *vcs)
2080 2080
2081 /* to ensure that schedule_timeout will return immediately 2081 /* to ensure that schedule_timeout will return immediately
2082 * if VINO interrupt was triggered meanwhile */ 2082 * if VINO interrupt was triggered meanwhile */
2083 schedule_timeout_interruptible(HZ / 10); 2083 schedule_timeout_interruptible(msecs_to_jiffies(100));
2084 2084
2085 if (signal_pending(current)) 2085 if (signal_pending(current))
2086 err = -EINTR; 2086 err = -EINTR;
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 8f6741a28a47..1bf4cbec6a87 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -321,12 +321,14 @@ static int wm8739_probe(struct i2c_adapter *adapter)
321 321
322static int wm8739_detach(struct i2c_client *client) 322static int wm8739_detach(struct i2c_client *client)
323{ 323{
324 struct wm8739_state *state = i2c_get_clientdata(client);
324 int err; 325 int err;
325 326
326 err = i2c_detach_client(client); 327 err = i2c_detach_client(client);
327 if (err) 328 if (err)
328 return err; 329 return err;
329 330
331 kfree(state);
330 kfree(client); 332 kfree(client);
331 return 0; 333 return 0;
332} 334}
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index 4df5d30d4d09..9f7e894ef962 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -222,12 +222,14 @@ static int wm8775_probe(struct i2c_adapter *adapter)
222 222
223static int wm8775_detach(struct i2c_client *client) 223static int wm8775_detach(struct i2c_client *client)
224{ 224{
225 struct wm8775_state *state = i2c_get_clientdata(client);
225 int err; 226 int err;
226 227
227 err = i2c_detach_client(client); 228 err = i2c_detach_client(client);
228 if (err) { 229 if (err) {
229 return err; 230 return err;
230 } 231 }
232 kfree(state);
231 kfree(client); 233 kfree(client);
232 234
233 return 0; 235 return 0;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index d16a2b57dc81..c66c8a3410b9 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -60,6 +60,7 @@
60#include <linux/compiler.h> /* need __user */ 60#include <linux/compiler.h> /* need __user */
61#else 61#else
62#define __user 62#define __user
63#include <sys/time.h>
63#endif 64#endif
64#include <linux/types.h> 65#include <linux/types.h>
65 66