aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 22:20:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 22:20:22 -0400
commitad792f4f46e12bae58298fc64f5139b99664a773 (patch)
tree3d20c3a0840b00deb95fe62fdff1bc6e59eb37fe /drivers
parent3650b0a304663d98a63c68f9020eb1ded477989e (diff)
parentf40aa808bad19a079a0e122e326d6970df141afb (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: (37 commits) V4L/DVB (6382): saa7134: fix NULL dereference at suspend time for cards without IR receiver V4L/DVB (6380): ivtvfb: Removal of the 'osd_compat' module option V4L/DVB (6379): patch which improves GotView Saa7135 remote control V4L/DVB (6378b): Updates info about the removal of V4L1 at feature-removal-schedule.txt V4L/DVB (6378a): Removal of VIDIOC_[G|S]_MPEGCOMP from feature-removal-schedule.txt V4L/DVB (6378): DiB0700-device: Using 1.10 firmware V4L/DVB (6357): pvrusb2: Improve encoder chip health tracking V4L/DVB (6356): "while (!ca->wakeup)" breaks the CAM initialisation V4L/DVB (6352): ir-kbd-i2c: Missing break statement V4L/DVB (6350): V4L: possible leak in em28xx_init_isoc V4L/DVB (6348): ivtv: undo video mute when closing the radio V4L/DVB (6347): ivtv: fix video mute when radio is used V4L/DVB (6346): ivtvfb: YUV output size fix when ivtvfb is not loaded V4L/DVB (6345): ivtvfb: YUV handling of an image which is not visible in the display area V4L/DVB (6343): ivtvfb: check return value of unregister_framebuffer V4L/DVB (6342): ivtv: fix circular locking (bug 9037) V4L/DVB (6341): ivtv: fix resizing MPEG1 streams V4L/DVB (6340): ivtvfb: screen mode change sometimes goes wrong V4L/DVB (6339): ivtv: set the video color to black instead of green when capturing from the radio V4L/DVB (6338): ivtv: fix incorrect EBUSY return ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/ir-keymaps.c70
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c42
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c2
-rw-r--r--drivers/media/radio/miropcm20-radio.c1
-rw-r--r--drivers/media/radio/radio-gemtek.c1
-rw-r--r--drivers/media/video/arv.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c3
-rw-r--r--drivers/media/video/bw-qcam.c1
-rw-r--r--drivers/media/video/c-qcam.c1
-rw-r--r--drivers/media/video/cpia.c5
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c5
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c6
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c86
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c57
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c3
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c133
-rw-r--r--drivers/media/video/cx88/cx88-video.c1
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c16
-rw-r--r--drivers/media/video/cx88/cx88.h24
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c1
-rw-r--r--drivers/media/video/ir-kbd-i2c.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c11
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c116
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.h1
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c160
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.h1
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c92
-rw-r--r--drivers/media/video/meye.c1
-rw-r--r--drivers/media/video/ov511.c1
-rw-r--r--drivers/media/video/planb.c1
-rw-r--r--drivers/media/video/pms.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h11
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c3
-rw-r--r--drivers/media/video/pwc/pwc-if.c1
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c111
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c44
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c12
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c29
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c32
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c28
-rw-r--r--drivers/media/video/saa7134/saa7134.h7
-rw-r--r--drivers/media/video/se401.c1
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c1
-rw-r--r--drivers/media/video/stradis.c1
-rw-r--r--drivers/media/video/stv680.c1
-rw-r--r--drivers/media/video/tuner-core.c2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c1
-rw-r--r--drivers/media/video/usbvideo/vicam.c1
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c3
-rw-r--r--drivers/media/video/v4l2-common.c2
-rw-r--r--drivers/media/video/videobuf-core.c2
-rw-r--r--drivers/media/video/videocodec.c4
-rw-r--r--drivers/media/video/videodev.c42
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/media/video/w9966.c1
-rw-r--r--drivers/media/video/w9968cf.c1
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c1
-rw-r--r--drivers/media/video/zoran_card.c10
-rw-r--r--drivers/media/video/zoran_driver.c2
66 files changed, 556 insertions, 681 deletions
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c
index aefcf28da1ca..185e8a860c1a 100644
--- a/drivers/media/common/ir-keymaps.c
+++ b/drivers/media/common/ir-keymaps.c
@@ -1074,41 +1074,41 @@ EXPORT_SYMBOL_GPL(ir_codes_manli);
1074/* Mike Baikov <mike@baikov.com> */ 1074/* Mike Baikov <mike@baikov.com> */
1075IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE] = { 1075IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE] = {
1076 1076
1077 [ 0x21 ] = KEY_POWER, 1077 [ 0x11 ] = KEY_POWER,
1078 [ 0x69 ] = KEY_TV, 1078 [ 0x35 ] = KEY_TV,
1079 [ 0x33 ] = KEY_0, 1079 [ 0x1b ] = KEY_0,
1080 [ 0x51 ] = KEY_1, 1080 [ 0x29 ] = KEY_1,
1081 [ 0x31 ] = KEY_2, 1081 [ 0x19 ] = KEY_2,
1082 [ 0x71 ] = KEY_3, 1082 [ 0x39 ] = KEY_3,
1083 [ 0x3b ] = KEY_4, 1083 [ 0x1f ] = KEY_4,
1084 [ 0x58 ] = KEY_5, 1084 [ 0x2c ] = KEY_5,
1085 [ 0x41 ] = KEY_6, 1085 [ 0x21 ] = KEY_6,
1086 [ 0x48 ] = KEY_7, 1086 [ 0x24 ] = KEY_7,
1087 [ 0x30 ] = KEY_8, 1087 [ 0x18 ] = KEY_8,
1088 [ 0x53 ] = KEY_9, 1088 [ 0x2b ] = KEY_9,
1089 [ 0x73 ] = KEY_AGAIN, /* LOOP */ 1089 [ 0x3b ] = KEY_AGAIN, /* LOOP */
1090 [ 0x0a ] = KEY_AUDIO, 1090 [ 0x06 ] = KEY_AUDIO,
1091 [ 0x61 ] = KEY_PRINT, /* PREVIEW */ 1091 [ 0x31 ] = KEY_PRINT, /* PREVIEW */
1092 [ 0x7a ] = KEY_VIDEO, 1092 [ 0x3e ] = KEY_VIDEO,
1093 [ 0x20 ] = KEY_CHANNELUP, 1093 [ 0x10 ] = KEY_CHANNELUP,
1094 [ 0x40 ] = KEY_CHANNELDOWN, 1094 [ 0x20 ] = KEY_CHANNELDOWN,
1095 [ 0x18 ] = KEY_VOLUMEDOWN, 1095 [ 0x0c ] = KEY_VOLUMEDOWN,
1096 [ 0x50 ] = KEY_VOLUMEUP, 1096 [ 0x28 ] = KEY_VOLUMEUP,
1097 [ 0x10 ] = KEY_MUTE, 1097 [ 0x08 ] = KEY_MUTE,
1098 [ 0x4a ] = KEY_SEARCH, 1098 [ 0x26 ] = KEY_SEARCH, /*SCAN*/
1099 [ 0x7b ] = KEY_SHUFFLE, /* SNAPSHOT */ 1099 [ 0x3f ] = KEY_SHUFFLE, /* SNAPSHOT */
1100 [ 0x22 ] = KEY_RECORD, 1100 [ 0x12 ] = KEY_RECORD,
1101 [ 0x62 ] = KEY_STOP, 1101 [ 0x32 ] = KEY_STOP,
1102 [ 0x78 ] = KEY_PLAY, 1102 [ 0x3c ] = KEY_PLAY,
1103 [ 0x39 ] = KEY_REWIND, 1103 [ 0x1d ] = KEY_REWIND,
1104 [ 0x59 ] = KEY_PAUSE, 1104 [ 0x2d ] = KEY_PAUSE,
1105 [ 0x19 ] = KEY_FORWARD, 1105 [ 0x0d ] = KEY_FORWARD,
1106 [ 0x09 ] = KEY_ZOOM, 1106 [ 0x05 ] = KEY_ZOOM, /*FULL*/
1107 1107
1108 [ 0x52 ] = KEY_F21, /* LIVE TIMESHIFT */ 1108 [ 0x2a ] = KEY_F21, /* LIVE TIMESHIFT */
1109 [ 0x1a ] = KEY_F22, /* MIN TIMESHIFT */ 1109 [ 0x0e ] = KEY_F22, /* MIN TIMESHIFT */
1110 [ 0x3a ] = KEY_F23, /* TIMESHIFT */ 1110 [ 0x1e ] = KEY_F23, /* TIMESHIFT */
1111 [ 0x70 ] = KEY_F24, /* NORMAL TIMESHIFT */ 1111 [ 0x38 ] = KEY_F24, /* NORMAL TIMESHIFT */
1112}; 1112};
1113 1113
1114EXPORT_SYMBOL_GPL(ir_codes_gotview7135); 1114EXPORT_SYMBOL_GPL(ir_codes_gotview7135);
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index a05e5c182288..db08b0a8888a 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -345,7 +345,9 @@ static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
345 struct dvb_demux *demux = dvbdmxfeed->demux; 345 struct dvb_demux *demux = dvbdmxfeed->demux;
346 struct cinergyt2 *cinergyt2 = demux->priv; 346 struct cinergyt2 *cinergyt2 = demux->priv;
347 347
348 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 348 if (cinergyt2->disconnect_pending)
349 return -EAGAIN;
350 if (mutex_lock_interruptible(&cinergyt2->sem))
349 return -ERESTARTSYS; 351 return -ERESTARTSYS;
350 352
351 if (cinergyt2->streaming == 0) 353 if (cinergyt2->streaming == 0)
@@ -361,7 +363,9 @@ static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
361 struct dvb_demux *demux = dvbdmxfeed->demux; 363 struct dvb_demux *demux = dvbdmxfeed->demux;
362 struct cinergyt2 *cinergyt2 = demux->priv; 364 struct cinergyt2 *cinergyt2 = demux->priv;
363 365
364 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 366 if (cinergyt2->disconnect_pending)
367 return -EAGAIN;
368 if (mutex_lock_interruptible(&cinergyt2->sem))
365 return -ERESTARTSYS; 369 return -ERESTARTSYS;
366 370
367 if (--cinergyt2->streaming == 0) 371 if (--cinergyt2->streaming == 0)
@@ -481,12 +485,16 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
481{ 485{
482 struct dvb_device *dvbdev = file->private_data; 486 struct dvb_device *dvbdev = file->private_data;
483 struct cinergyt2 *cinergyt2 = dvbdev->priv; 487 struct cinergyt2 *cinergyt2 = dvbdev->priv;
484 int err = -ERESTARTSYS; 488 int err = -EAGAIN;
485 489
486 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) 490 if (cinergyt2->disconnect_pending)
491 goto out;
492 err = mutex_lock_interruptible(&cinergyt2->wq_sem);
493 if (err)
487 goto out; 494 goto out;
488 495
489 if (mutex_lock_interruptible(&cinergyt2->sem)) 496 err = mutex_lock_interruptible(&cinergyt2->sem);
497 if (err)
490 goto out_unlock1; 498 goto out_unlock1;
491 499
492 if ((err = dvb_generic_open(inode, file))) 500 if ((err = dvb_generic_open(inode, file)))
@@ -550,7 +558,9 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct
550 struct cinergyt2 *cinergyt2 = dvbdev->priv; 558 struct cinergyt2 *cinergyt2 = dvbdev->priv;
551 unsigned int mask = 0; 559 unsigned int mask = 0;
552 560
553 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 561 if (cinergyt2->disconnect_pending)
562 return -EAGAIN;
563 if (mutex_lock_interruptible(&cinergyt2->sem))
554 return -ERESTARTSYS; 564 return -ERESTARTSYS;
555 565
556 poll_wait(file, &cinergyt2->poll_wq, wait); 566 poll_wait(file, &cinergyt2->poll_wq, wait);
@@ -625,7 +635,9 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
625 if (copy_from_user(&p, (void __user*) arg, sizeof(p))) 635 if (copy_from_user(&p, (void __user*) arg, sizeof(p)))
626 return -EFAULT; 636 return -EFAULT;
627 637
628 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 638 if (cinergyt2->disconnect_pending)
639 return -EAGAIN;
640 if (mutex_lock_interruptible(&cinergyt2->sem))
629 return -ERESTARTSYS; 641 return -ERESTARTSYS;
630 642
631 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; 643 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
@@ -996,7 +1008,9 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
996{ 1008{
997 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 1009 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
998 1010
999 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) 1011 if (cinergyt2->disconnect_pending)
1012 return -EAGAIN;
1013 if (mutex_lock_interruptible(&cinergyt2->wq_sem))
1000 return -ERESTARTSYS; 1014 return -ERESTARTSYS;
1001 1015
1002 cinergyt2_suspend_rc(cinergyt2); 1016 cinergyt2_suspend_rc(cinergyt2);
@@ -1017,16 +1031,18 @@ static int cinergyt2_resume (struct usb_interface *intf)
1017{ 1031{
1018 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 1032 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
1019 struct dvbt_set_parameters_msg *param = &cinergyt2->param; 1033 struct dvbt_set_parameters_msg *param = &cinergyt2->param;
1020 int err = -ERESTARTSYS; 1034 int err = -EAGAIN;
1021 1035
1022 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) 1036 if (cinergyt2->disconnect_pending)
1037 goto out;
1038 err = mutex_lock_interruptible(&cinergyt2->wq_sem);
1039 if (err)
1023 goto out; 1040 goto out;
1024 1041
1025 if (mutex_lock_interruptible(&cinergyt2->sem)) 1042 err = mutex_lock_interruptible(&cinergyt2->sem);
1043 if (err)
1026 goto out_unlock1; 1044 goto out_unlock1;
1027 1045
1028 err = 0;
1029
1030 if (!cinergyt2->sleeping) { 1046 if (!cinergyt2->sleeping) {
1031 cinergyt2_sleep(cinergyt2, 0); 1047 cinergyt2_sleep(cinergyt2, 0);
1032 cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0); 1048 cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0);
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 084a508a03da..89437fdab8be 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -972,7 +972,7 @@ static int dvb_ca_en50221_thread(void *data)
972 /* main loop */ 972 /* main loop */
973 while (!kthread_should_stop()) { 973 while (!kthread_should_stop()) {
974 /* sleep for a bit */ 974 /* sleep for a bit */
975 while (!ca->wakeup) { 975 if (!ca->wakeup) {
976 set_current_state(TASK_INTERRUPTIBLE); 976 set_current_state(TASK_INTERRUPTIBLE);
977 schedule_timeout(ca->delay); 977 schedule_timeout(ca->delay);
978 if (kthread_should_stop()) 978 if (kthread_should_stop())
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index e8c4a8694532..58452b52002c 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -828,7 +828,7 @@ MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
828#define DIB0700_DEFAULT_DEVICE_PROPERTIES \ 828#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
829 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \ 829 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
830 .usb_ctrl = DEVICE_SPECIFIC, \ 830 .usb_ctrl = DEVICE_SPECIFIC, \
831 .firmware = "dvb-usb-dib0700-03-pre1.fw", \ 831 .firmware = "dvb-usb-dib0700-1.10.fw", \
832 .download_firmware = dib0700_download_firmware, \ 832 .download_firmware = dib0700_download_firmware, \
833 .no_reconnect = 1, \ 833 .no_reconnect = 1, \
834 .size_of_priv = sizeof(struct dib0700_state), \ 834 .size_of_priv = sizeof(struct dib0700_state), \
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c
index c7c9d1dc0690..3ae56fef8c92 100644
--- a/drivers/media/radio/miropcm20-radio.c
+++ b/drivers/media/radio/miropcm20-radio.c
@@ -229,7 +229,6 @@ static struct video_device pcm20_radio = {
229 .owner = THIS_MODULE, 229 .owner = THIS_MODULE,
230 .name = "Miro PCM 20 radio", 230 .name = "Miro PCM 20 radio",
231 .type = VID_TYPE_TUNER, 231 .type = VID_TYPE_TUNER,
232 .hardware = VID_HARDWARE_RTRACK,
233 .fops = &pcm20_fops, 232 .fops = &pcm20_fops,
234 .priv = &pcm20_unit 233 .priv = &pcm20_unit
235}; 234};
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 0c963db03614..5e4b9ddb23c0 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -554,7 +554,6 @@ static struct video_device gemtek_radio = {
554 .owner = THIS_MODULE, 554 .owner = THIS_MODULE,
555 .name = "GemTek Radio card", 555 .name = "GemTek Radio card",
556 .type = VID_TYPE_TUNER, 556 .type = VID_TYPE_TUNER,
557 .hardware = VID_HARDWARE_GEMTEK,
558 .fops = &gemtek_fops, 557 .fops = &gemtek_fops,
559 .vidioc_querycap = vidioc_querycap, 558 .vidioc_querycap = vidioc_querycap,
560 .vidioc_g_tuner = vidioc_g_tuner, 559 .vidioc_g_tuner = vidioc_g_tuner,
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 19e9929ffa0f..c94a4d0f2804 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -755,7 +755,6 @@ static struct video_device ar_template = {
755 .owner = THIS_MODULE, 755 .owner = THIS_MODULE,
756 .name = "Colour AR VGA", 756 .name = "Colour AR VGA",
757 .type = VID_TYPE_CAPTURE, 757 .type = VID_TYPE_CAPTURE,
758 .hardware = VID_HARDWARE_ARV,
759 .fops = &ar_fops, 758 .fops = &ar_fops,
760 .release = ar_release, 759 .release = ar_release,
761 .minor = -1, 760 .minor = -1,
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 7a332b3efe51..9feeb636ff9b 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -3877,7 +3877,6 @@ static struct video_device bttv_video_template =
3877 .name = "UNSET", 3877 .name = "UNSET",
3878 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| 3878 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|
3879 VID_TYPE_CLIPPING|VID_TYPE_SCALES, 3879 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
3880 .hardware = VID_HARDWARE_BT848,
3881 .fops = &bttv_fops, 3880 .fops = &bttv_fops,
3882 .minor = -1, 3881 .minor = -1,
3883}; 3882};
@@ -3886,7 +3885,6 @@ static struct video_device bttv_vbi_template =
3886{ 3885{
3887 .name = "bt848/878 vbi", 3886 .name = "bt848/878 vbi",
3888 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, 3887 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT,
3889 .hardware = VID_HARDWARE_BT848,
3890 .fops = &bttv_fops, 3888 .fops = &bttv_fops,
3891 .minor = -1, 3889 .minor = -1,
3892}; 3890};
@@ -4034,7 +4032,6 @@ static struct video_device radio_template =
4034{ 4032{
4035 .name = "bt848/878 radio", 4033 .name = "bt848/878 radio",
4036 .type = VID_TYPE_TUNER, 4034 .type = VID_TYPE_TUNER,
4037 .hardware = VID_HARDWARE_BT848,
4038 .fops = &radio_fops, 4035 .fops = &radio_fops,
4039 .minor = -1, 4036 .minor = -1,
4040}; 4037};
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7f7e3d3398d0..58423525591f 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -899,7 +899,6 @@ static struct video_device qcam_template=
899 .owner = THIS_MODULE, 899 .owner = THIS_MODULE,
900 .name = "Connectix Quickcam", 900 .name = "Connectix Quickcam",
901 .type = VID_TYPE_CAPTURE, 901 .type = VID_TYPE_CAPTURE,
902 .hardware = VID_HARDWARE_QCAM_BW,
903 .fops = &qcam_fops, 902 .fops = &qcam_fops,
904}; 903};
905 904
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index f76c6a6c3766..cf1546b5a7f1 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -699,7 +699,6 @@ static struct video_device qcam_template=
699 .owner = THIS_MODULE, 699 .owner = THIS_MODULE,
700 .name = "Colour QuickCam", 700 .name = "Colour QuickCam",
701 .type = VID_TYPE_CAPTURE, 701 .type = VID_TYPE_CAPTURE,
702 .hardware = VID_HARDWARE_QCAM_C,
703 .fops = &qcam_fops, 702 .fops = &qcam_fops,
704}; 703};
705 704
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index a1d02e5ce0fd..7c630f5ee725 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -65,10 +65,6 @@ MODULE_PARM_DESC(colorspace_conv,
65 65
66#define ABOUT "V4L-Driver for Vision CPiA based cameras" 66#define ABOUT "V4L-Driver for Vision CPiA based cameras"
67 67
68#ifndef VID_HARDWARE_CPIA
69#define VID_HARDWARE_CPIA 24 /* FIXME -> from linux/videodev.h */
70#endif
71
72#define CPIA_MODULE_CPIA (0<<5) 68#define CPIA_MODULE_CPIA (0<<5)
73#define CPIA_MODULE_SYSTEM (1<<5) 69#define CPIA_MODULE_SYSTEM (1<<5)
74#define CPIA_MODULE_VP_CTRL (5<<5) 70#define CPIA_MODULE_VP_CTRL (5<<5)
@@ -3804,7 +3800,6 @@ static struct video_device cpia_template = {
3804 .owner = THIS_MODULE, 3800 .owner = THIS_MODULE,
3805 .name = "CPiA Camera", 3801 .name = "CPiA Camera",
3806 .type = VID_TYPE_CAPTURE, 3802 .type = VID_TYPE_CAPTURE,
3807 .hardware = VID_HARDWARE_CPIA,
3808 .fops = &cpia_fops, 3803 .fops = &cpia_fops,
3809}; 3804};
3810 3805
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index e3aaba1e0e0a..e378abec806d 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -86,10 +86,6 @@ MODULE_LICENSE("GPL");
86 86
87#define ABOUT "V4L-Driver for Vision CPiA2 based cameras" 87#define ABOUT "V4L-Driver for Vision CPiA2 based cameras"
88 88
89#ifndef VID_HARDWARE_CPIA2
90#error "VID_HARDWARE_CPIA2 should have been defined in linux/videodev.h"
91#endif
92
93struct control_menu_info { 89struct control_menu_info {
94 int value; 90 int value;
95 char name[32]; 91 char name[32];
@@ -1942,7 +1938,6 @@ static struct video_device cpia2_template = {
1942 .type= VID_TYPE_CAPTURE, 1938 .type= VID_TYPE_CAPTURE,
1943 .type2 = V4L2_CAP_VIDEO_CAPTURE | 1939 .type2 = V4L2_CAP_VIDEO_CAPTURE |
1944 V4L2_CAP_STREAMING, 1940 V4L2_CAP_STREAMING,
1945 .hardware= VID_HARDWARE_CPIA2,
1946 .minor= -1, 1941 .minor= -1,
1947 .fops= &fops_template, 1942 .fops= &fops_template,
1948 .release= video_device_release, 1943 .release= video_device_release,
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index af16505bd2e0..3cdd136477e5 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -793,7 +793,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
793 dev->pci->subsystem_device); 793 dev->pci->subsystem_device);
794 794
795 cx23885_devcount--; 795 cx23885_devcount--;
796 goto fail_free; 796 return -ENODEV;
797 } 797 }
798 798
799 /* PCIe stuff */ 799 /* PCIe stuff */
@@ -835,10 +835,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
835 } 835 }
836 836
837 return 0; 837 return 0;
838
839fail_free:
840 kfree(dev);
841 return -ENODEV;
842} 838}
843 839
844void cx23885_dev_unregister(struct cx23885_dev *dev) 840void cx23885_dev_unregister(struct cx23885_dev *dev)
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 141dadf7cf1b..40ffd7a5579a 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -39,6 +39,7 @@
39#include <sound/pcm_params.h> 39#include <sound/pcm_params.h>
40#include <sound/control.h> 40#include <sound/control.h>
41#include <sound/initval.h> 41#include <sound/initval.h>
42#include <sound/tlv.h>
42 43
43#include "cx88.h" 44#include "cx88.h"
44#include "cx88-reg.h" 45#include "cx88-reg.h"
@@ -82,6 +83,7 @@ typedef struct cx88_audio_dev snd_cx88_card_t;
82 83
83 84
84 85
86
85/**************************************************************************** 87/****************************************************************************
86 Module global static vars 88 Module global static vars
87 ****************************************************************************/ 89 ****************************************************************************/
@@ -545,8 +547,8 @@ static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name)
545/**************************************************************************** 547/****************************************************************************
546 CONTROL INTERFACE 548 CONTROL INTERFACE
547 ****************************************************************************/ 549 ****************************************************************************/
548static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, 550static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *info) 551 struct snd_ctl_elem_info *info)
550{ 552{
551 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 553 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
552 info->count = 2; 554 info->count = 2;
@@ -556,9 +558,8 @@ static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol,
556 return 0; 558 return 0;
557} 559}
558 560
559/* OK - TODO: test it */ 561static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
560static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, 562 struct snd_ctl_elem_value *value)
561 struct snd_ctl_elem_value *value)
562{ 563{
563 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 564 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
564 struct cx88_core *core=chip->core; 565 struct cx88_core *core=chip->core;
@@ -573,8 +574,8 @@ static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol,
573} 574}
574 575
575/* OK - TODO: test it */ 576/* OK - TODO: test it */
576static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, 577static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
577 struct snd_ctl_elem_value *value) 578 struct snd_ctl_elem_value *value)
578{ 579{
579 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 580 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
580 struct cx88_core *core=chip->core; 581 struct cx88_core *core=chip->core;
@@ -605,14 +606,67 @@ static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol,
605 return changed; 606 return changed;
606} 607}
607 608
608static struct snd_kcontrol_new snd_cx88_capture_volume = { 609static const DECLARE_TLV_DB_SCALE(snd_cx88_db_scale, -6300, 100, 0);
610
611static struct snd_kcontrol_new snd_cx88_volume = {
612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
613 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
614 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
615 .name = "Playback Volume",
616 .info = snd_cx88_volume_info,
617 .get = snd_cx88_volume_get,
618 .put = snd_cx88_volume_put,
619 .tlv.p = snd_cx88_db_scale,
620};
621
622static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *value)
624{
625 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
626 struct cx88_core *core = chip->core;
627 u32 bit = kcontrol->private_value;
628
629 value->value.integer.value[0] = !(cx_read(AUD_VOL_CTL) & bit);
630 return 0;
631}
632
633static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *value)
635{
636 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
637 struct cx88_core *core = chip->core;
638 u32 bit = kcontrol->private_value;
639 int ret = 0;
640 u32 vol;
641
642 spin_lock_irq(&chip->reg_lock);
643 vol = cx_read(AUD_VOL_CTL);
644 if (value->value.integer.value[0] != !(vol & bit)) {
645 vol ^= bit;
646 cx_write(AUD_VOL_CTL, vol);
647 ret = 1;
648 }
649 spin_unlock_irq(&chip->reg_lock);
650 return ret;
651}
652
653static struct snd_kcontrol_new snd_cx88_dac_switch = {
609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
610 .name = "Capture Volume", 655 .name = "Playback Switch",
611 .info = snd_cx88_capture_volume_info, 656 .info = snd_ctl_boolean_mono_info,
612 .get = snd_cx88_capture_volume_get, 657 .get = snd_cx88_switch_get,
613 .put = snd_cx88_capture_volume_put, 658 .put = snd_cx88_switch_put,
659 .private_value = (1<<8),
614}; 660};
615 661
662static struct snd_kcontrol_new snd_cx88_source_switch = {
663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
664 .name = "Capture Switch",
665 .info = snd_ctl_boolean_mono_info,
666 .get = snd_cx88_switch_get,
667 .put = snd_cx88_switch_put,
668 .private_value = (1<<6),
669};
616 670
617/**************************************************************************** 671/****************************************************************************
618 Basic Flow for Sound Devices 672 Basic Flow for Sound Devices
@@ -762,7 +816,13 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
762 if (err < 0) 816 if (err < 0)
763 goto error; 817 goto error;
764 818
765 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_capture_volume, chip)); 819 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_volume, chip));
820 if (err < 0)
821 goto error;
822 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_dac_switch, chip));
823 if (err < 0)
824 goto error;
825 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_source_switch, chip));
766 if (err < 0) 826 if (err < 0)
767 goto error; 827 goto error;
768 828
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 6d6f5048d762..f33f0b47142c 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -527,44 +527,6 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
527 cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params); 527 cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params);
528} 528}
529 529
530static struct v4l2_mpeg_compression default_mpeg_params = {
531 .st_type = V4L2_MPEG_PS_2,
532 .st_bitrate = {
533 .mode = V4L2_BITRATE_CBR,
534 .min = 0,
535 .target = 0,
536 .max = 0
537 },
538 .ts_pid_pmt = 16,
539 .ts_pid_audio = 260,
540 .ts_pid_video = 256,
541 .ts_pid_pcr = 259,
542 .ps_size = 0,
543 .au_type = V4L2_MPEG_AU_2_II,
544 .au_bitrate = {
545 .mode = V4L2_BITRATE_CBR,
546 .min = 224,
547 .target = 224,
548 .max = 224
549 },
550 .au_sample_rate = 48000,
551 .au_pesid = 0,
552 .vi_type = V4L2_MPEG_VI_2,
553 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
554 .vi_bitrate = {
555 .mode = V4L2_BITRATE_CBR,
556 .min = 4000,
557 .target = 4500,
558 .max = 6000
559 },
560 .vi_frame_rate = 25,
561 .vi_frames_per_gop = 12,
562 .vi_bframes_count = 2,
563 .vi_pesid = 0,
564 .closed_gops = 1,
565 .pulldown = 0
566};
567
568static int blackbird_initialize_codec(struct cx8802_dev *dev) 530static int blackbird_initialize_codec(struct cx8802_dev *dev)
569{ 531{
570 struct cx88_core *core = dev->core; 532 struct cx88_core *core = dev->core;
@@ -852,23 +814,6 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
852 return videobuf_streamoff(&fh->mpegq); 814 return videobuf_streamoff(&fh->mpegq);
853} 815}
854 816
855static int vidioc_g_mpegcomp (struct file *file, void *fh,
856 struct v4l2_mpeg_compression *f)
857{
858 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
859 "Replace with VIDIOC_G_EXT_CTRLS!");
860 memcpy(f,&default_mpeg_params,sizeof(*f));
861 return 0;
862}
863
864static int vidioc_s_mpegcomp (struct file *file, void *fh,
865 struct v4l2_mpeg_compression *f)
866{
867 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
868 "Replace with VIDIOC_S_EXT_CTRLS!");
869 return 0;
870}
871
872static int vidioc_g_ext_ctrls (struct file *file, void *priv, 817static int vidioc_g_ext_ctrls (struct file *file, void *priv,
873 struct v4l2_ext_controls *f) 818 struct v4l2_ext_controls *f)
874{ 819{
@@ -1216,8 +1161,6 @@ static struct video_device cx8802_mpeg_template =
1216 .vidioc_dqbuf = vidioc_dqbuf, 1161 .vidioc_dqbuf = vidioc_dqbuf,
1217 .vidioc_streamon = vidioc_streamon, 1162 .vidioc_streamon = vidioc_streamon,
1218 .vidioc_streamoff = vidioc_streamoff, 1163 .vidioc_streamoff = vidioc_streamoff,
1219 .vidioc_g_mpegcomp = vidioc_g_mpegcomp,
1220 .vidioc_s_mpegcomp = vidioc_s_mpegcomp,
1221 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, 1164 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,
1222 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, 1165 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,
1223 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, 1166 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index d16e5c6d21c0..fce19caf9d04 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -475,8 +475,9 @@ static int dvb_register(struct cx8802_dev *dev)
475 break; 475 break;
476 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 476 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
477#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 477#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
478 /* MT352 is on a secondary I2C bus made from some GPIO lines */
478 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 479 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
479 &((struct vp3054_i2c_state *)dev->card_priv)->adap); 480 &dev->vp3054->adap);
480 if (dev->dvb.frontend != NULL) { 481 if (dev->dvb.frontend != NULL) {
481 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 482 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
482 &dev->core->i2c_adap, DVB_PLL_FMD1216ME); 483 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index a652f294d23d..448c67380945 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -79,7 +79,8 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
79{ 79{
80 struct cx88_core *core = dev->core; 80 struct cx88_core *core = dev->core;
81 81
82 dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", dev->width, dev->height, buf->vb.field); 82 dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n",
83 buf->vb.width, buf->vb.height, buf->vb.field);
83 84
84 /* setup fifo + format */ 85 /* setup fifo + format */
85 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 86 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28],
@@ -177,7 +178,6 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
177 struct cx88_dmaqueue *q) 178 struct cx88_dmaqueue *q)
178{ 179{
179 struct cx88_buffer *buf; 180 struct cx88_buffer *buf;
180 struct list_head *item;
181 181
182 dprintk( 1, "cx8802_restart_queue\n" ); 182 dprintk( 1, "cx8802_restart_queue\n" );
183 if (list_empty(&q->active)) 183 if (list_empty(&q->active))
@@ -223,10 +223,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
223 dprintk(2,"restart_queue [%p/%d]: restart dma\n", 223 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
224 buf, buf->vb.i); 224 buf, buf->vb.i);
225 cx8802_start_dma(dev, q, buf); 225 cx8802_start_dma(dev, q, buf);
226 list_for_each(item,&q->active) { 226 list_for_each_entry(buf, &q->active, vb.queue)
227 buf = list_entry(item, struct cx88_buffer, vb.queue);
228 buf->count = q->count++; 227 buf->count = q->count++;
229 }
230 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 228 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
231 return 0; 229 return 0;
232} 230}
@@ -572,42 +570,29 @@ int cx8802_resume_common(struct pci_dev *pci_dev)
572 return 0; 570 return 0;
573} 571}
574 572
573#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
574 defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
575struct cx8802_dev * cx8802_get_device(struct inode *inode) 575struct cx8802_dev * cx8802_get_device(struct inode *inode)
576{ 576{
577 int minor = iminor(inode); 577 int minor = iminor(inode);
578 struct cx8802_dev *h = NULL; 578 struct cx8802_dev *dev;
579 struct list_head *list;
580 579
581 list_for_each(list,&cx8802_devlist) { 580 list_for_each_entry(dev, &cx8802_devlist, devlist)
582 h = list_entry(list, struct cx8802_dev, devlist); 581 if (dev->mpeg_dev && dev->mpeg_dev->minor == minor)
583 if (h->mpeg_dev && h->mpeg_dev->minor == minor) 582 return dev;
584 return h;
585 }
586 583
587 return NULL; 584 return NULL;
588} 585}
586EXPORT_SYMBOL(cx8802_get_device);
587#endif
589 588
590struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) 589struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype)
591{ 590{
592 struct cx8802_dev *h = NULL; 591 struct cx8802_driver *d;
593 struct cx8802_driver *d = NULL;
594 struct list_head *list;
595 struct list_head *list2;
596
597 list_for_each(list,&cx8802_devlist) {
598 h = list_entry(list, struct cx8802_dev, devlist);
599 if (h != dev)
600 continue;
601
602 list_for_each(list2, &h->drvlist.devlist) {
603 d = list_entry(list2, struct cx8802_driver, devlist);
604 592
605 /* only unregister the correct driver type */ 593 list_for_each_entry(d, &dev->drvlist, drvlist)
606 if (d->type_id == btype) { 594 if (d->type_id == btype)
607 return d; 595 return d;
608 }
609 }
610 }
611 596
612 return NULL; 597 return NULL;
613} 598}
@@ -671,10 +656,9 @@ static int cx8802_check_driver(struct cx8802_driver *drv)
671 656
672int cx8802_register_driver(struct cx8802_driver *drv) 657int cx8802_register_driver(struct cx8802_driver *drv)
673{ 658{
674 struct cx8802_dev *h; 659 struct cx8802_dev *dev;
675 struct cx8802_driver *driver; 660 struct cx8802_driver *driver;
676 struct list_head *list; 661 int err, i = 0;
677 int err = 0, i = 0;
678 662
679 printk(KERN_INFO 663 printk(KERN_INFO
680 "cx88/2: registering cx8802 driver, type: %s access: %s\n", 664 "cx88/2: registering cx8802 driver, type: %s access: %s\n",
@@ -686,14 +670,12 @@ int cx8802_register_driver(struct cx8802_driver *drv)
686 return err; 670 return err;
687 } 671 }
688 672
689 list_for_each(list,&cx8802_devlist) { 673 list_for_each_entry(dev, &cx8802_devlist, devlist) {
690 h = list_entry(list, struct cx8802_dev, devlist);
691
692 printk(KERN_INFO 674 printk(KERN_INFO
693 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", 675 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n",
694 h->core->name, h->pci->subsystem_vendor, 676 dev->core->name, dev->pci->subsystem_vendor,
695 h->pci->subsystem_device, h->core->board.name, 677 dev->pci->subsystem_device, dev->core->board.name,
696 h->core->boardnr); 678 dev->core->boardnr);
697 679
698 /* Bring up a new struct for each driver instance */ 680 /* Bring up a new struct for each driver instance */
699 driver = kzalloc(sizeof(*drv),GFP_KERNEL); 681 driver = kzalloc(sizeof(*drv),GFP_KERNEL);
@@ -701,7 +683,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
701 return -ENOMEM; 683 return -ENOMEM;
702 684
703 /* Snapshot of the driver registration data */ 685 /* Snapshot of the driver registration data */
704 drv->core = h->core; 686 drv->core = dev->core;
705 drv->suspend = cx8802_suspend_common; 687 drv->suspend = cx8802_suspend_common;
706 drv->resume = cx8802_resume_common; 688 drv->resume = cx8802_resume_common;
707 drv->request_acquire = cx8802_request_acquire; 689 drv->request_acquire = cx8802_request_acquire;
@@ -712,49 +694,38 @@ int cx8802_register_driver(struct cx8802_driver *drv)
712 if (err == 0) { 694 if (err == 0) {
713 i++; 695 i++;
714 mutex_lock(&drv->core->lock); 696 mutex_lock(&drv->core->lock);
715 list_add_tail(&driver->devlist,&h->drvlist.devlist); 697 list_add_tail(&driver->drvlist, &dev->drvlist);
716 mutex_unlock(&drv->core->lock); 698 mutex_unlock(&drv->core->lock);
717 } else { 699 } else {
718 printk(KERN_ERR 700 printk(KERN_ERR
719 "%s/2: cx8802 probe failed, err = %d\n", 701 "%s/2: cx8802 probe failed, err = %d\n",
720 h->core->name, err); 702 dev->core->name, err);
721 } 703 }
722 704
723 } 705 }
724 if (i == 0)
725 err = -ENODEV;
726 else
727 err = 0;
728 706
729 return err; 707 return i ? 0 : -ENODEV;
730} 708}
731 709
732int cx8802_unregister_driver(struct cx8802_driver *drv) 710int cx8802_unregister_driver(struct cx8802_driver *drv)
733{ 711{
734 struct cx8802_dev *h; 712 struct cx8802_dev *dev;
735 struct cx8802_driver *d; 713 struct cx8802_driver *d, *dtmp;
736 struct list_head *list; 714 int err = 0;
737 struct list_head *list2, *q;
738 int err = 0, i = 0;
739 715
740 printk(KERN_INFO 716 printk(KERN_INFO
741 "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", 717 "cx88/2: unregistering cx8802 driver, type: %s access: %s\n",
742 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", 718 drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird",
743 drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); 719 drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive");
744 720
745 list_for_each(list,&cx8802_devlist) { 721 list_for_each_entry(dev, &cx8802_devlist, devlist) {
746 i++;
747 h = list_entry(list, struct cx8802_dev, devlist);
748
749 printk(KERN_INFO 722 printk(KERN_INFO
750 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", 723 "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n",
751 h->core->name, h->pci->subsystem_vendor, 724 dev->core->name, dev->pci->subsystem_vendor,
752 h->pci->subsystem_device, h->core->board.name, 725 dev->pci->subsystem_device, dev->core->board.name,
753 h->core->boardnr); 726 dev->core->boardnr);
754
755 list_for_each_safe(list2, q, &h->drvlist.devlist) {
756 d = list_entry(list2, struct cx8802_driver, devlist);
757 727
728 list_for_each_entry_safe(d, dtmp, &dev->drvlist, drvlist) {
758 /* only unregister the correct driver type */ 729 /* only unregister the correct driver type */
759 if (d->type_id != drv->type_id) 730 if (d->type_id != drv->type_id)
760 continue; 731 continue;
@@ -762,12 +733,12 @@ int cx8802_unregister_driver(struct cx8802_driver *drv)
762 err = d->remove(d); 733 err = d->remove(d);
763 if (err == 0) { 734 if (err == 0) {
764 mutex_lock(&drv->core->lock); 735 mutex_lock(&drv->core->lock);
765 list_del(list2); 736 list_del(&d->drvlist);
766 mutex_unlock(&drv->core->lock); 737 mutex_unlock(&drv->core->lock);
738 kfree(d);
767 } else 739 } else
768 printk(KERN_ERR "%s/2: cx8802 driver remove " 740 printk(KERN_ERR "%s/2: cx8802 driver remove "
769 "failed (%d)\n", h->core->name, err); 741 "failed (%d)\n", dev->core->name, err);
770
771 } 742 }
772 743
773 } 744 }
@@ -805,7 +776,7 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
805 if (err != 0) 776 if (err != 0)
806 goto fail_free; 777 goto fail_free;
807 778
808 INIT_LIST_HEAD(&dev->drvlist.devlist); 779 INIT_LIST_HEAD(&dev->drvlist);
809 list_add_tail(&dev->devlist,&cx8802_devlist); 780 list_add_tail(&dev->devlist,&cx8802_devlist);
810 781
811 /* Maintain a reference so cx88-video can query the 8802 device. */ 782 /* Maintain a reference so cx88-video can query the 8802 device. */
@@ -825,23 +796,30 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
825static void __devexit cx8802_remove(struct pci_dev *pci_dev) 796static void __devexit cx8802_remove(struct pci_dev *pci_dev)
826{ 797{
827 struct cx8802_dev *dev; 798 struct cx8802_dev *dev;
828 struct cx8802_driver *h;
829 struct list_head *list;
830 799
831 dev = pci_get_drvdata(pci_dev); 800 dev = pci_get_drvdata(pci_dev);
832 801
833 dprintk( 1, "%s\n", __FUNCTION__); 802 dprintk( 1, "%s\n", __FUNCTION__);
834 803
835 list_for_each(list,&dev->drvlist.devlist) { 804 if (!list_empty(&dev->drvlist)) {
836 h = list_entry(list, struct cx8802_driver, devlist); 805 struct cx8802_driver *drv, *tmp;
837 dprintk( 1, " ->driver\n"); 806 int err;
838 if (h->remove == NULL) { 807
839 printk(KERN_ERR "%s .. skipping driver, no probe function\n", __FUNCTION__); 808 printk(KERN_WARNING "%s/2: Trying to remove cx8802 driver "
840 continue; 809 "while cx8802 sub-drivers still loaded?!\n",
810 dev->core->name);
811
812 list_for_each_entry_safe(drv, tmp, &dev->drvlist, drvlist) {
813 err = drv->remove(drv);
814 if (err == 0) {
815 mutex_lock(&drv->core->lock);
816 list_del(&drv->drvlist);
817 mutex_unlock(&drv->core->lock);
818 } else
819 printk(KERN_ERR "%s/2: cx8802 driver remove "
820 "failed (%d)\n", dev->core->name, err);
821 kfree(drv);
841 } 822 }
842 printk(KERN_INFO "%s .. Removing driver type %d\n", __FUNCTION__, h->type_id);
843 cx8802_unregister_driver(h);
844 list_del(&dev->drvlist.devlist);
845 } 823 }
846 824
847 /* Destroy any 8802 reference. */ 825 /* Destroy any 8802 reference. */
@@ -901,7 +879,6 @@ EXPORT_SYMBOL(cx8802_fini_common);
901 879
902EXPORT_SYMBOL(cx8802_register_driver); 880EXPORT_SYMBOL(cx8802_register_driver);
903EXPORT_SYMBOL(cx8802_unregister_driver); 881EXPORT_SYMBOL(cx8802_unregister_driver);
904EXPORT_SYMBOL(cx8802_get_device);
905EXPORT_SYMBOL(cx8802_get_driver); 882EXPORT_SYMBOL(cx8802_get_driver);
906/* ----------------------------------------------------------- */ 883/* ----------------------------------------------------------- */
907/* 884/*
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 231ae6c4dd22..5ee05f8f3fad 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1675,7 +1675,6 @@ static struct video_device cx8800_radio_template =
1675{ 1675{
1676 .name = "cx8800-radio", 1676 .name = "cx8800-radio",
1677 .type = VID_TYPE_TUNER, 1677 .type = VID_TYPE_TUNER,
1678 .hardware = 0,
1679 .fops = &radio_fops, 1678 .fops = &radio_fops,
1680 .minor = -1, 1679 .minor = -1,
1681 .vidioc_querycap = radio_querycap, 1680 .vidioc_querycap = radio_querycap,
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 77c37889232b..6ce5af488471 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -41,7 +41,7 @@ static void vp3054_bit_setscl(void *data, int state)
41{ 41{
42 struct cx8802_dev *dev = data; 42 struct cx8802_dev *dev = data;
43 struct cx88_core *core = dev->core; 43 struct cx88_core *core = dev->core;
44 struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 44 struct vp3054_i2c_state *vp3054_i2c = dev->vp3054;
45 45
46 if (state) { 46 if (state) {
47 vp3054_i2c->state |= 0x0001; /* SCL high */ 47 vp3054_i2c->state |= 0x0001; /* SCL high */
@@ -58,7 +58,7 @@ static void vp3054_bit_setsda(void *data, int state)
58{ 58{
59 struct cx8802_dev *dev = data; 59 struct cx8802_dev *dev = data;
60 struct cx88_core *core = dev->core; 60 struct cx88_core *core = dev->core;
61 struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 61 struct vp3054_i2c_state *vp3054_i2c = dev->vp3054;
62 62
63 if (state) { 63 if (state) {
64 vp3054_i2c->state |= 0x0002; /* SDA high */ 64 vp3054_i2c->state |= 0x0002; /* SDA high */
@@ -113,10 +113,10 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
113 if (core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 113 if (core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)
114 return 0; 114 return 0;
115 115
116 dev->card_priv = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); 116 vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL);
117 if (dev->card_priv == NULL) 117 if (vp3054_i2c == NULL)
118 return -ENOMEM; 118 return -ENOMEM;
119 vp3054_i2c = dev->card_priv; 119 dev->vp3054 = vp3054_i2c;
120 120
121 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, 121 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template,
122 sizeof(vp3054_i2c->algo)); 122 sizeof(vp3054_i2c->algo));
@@ -139,8 +139,8 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
139 if (0 != rc) { 139 if (0 != rc) {
140 printk("%s: vp3054_i2c register FAILED\n", core->name); 140 printk("%s: vp3054_i2c register FAILED\n", core->name);
141 141
142 kfree(dev->card_priv); 142 kfree(dev->vp3054);
143 dev->card_priv = NULL; 143 dev->vp3054 = NULL;
144 } 144 }
145 145
146 return rc; 146 return rc;
@@ -148,7 +148,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
148 148
149void vp3054_i2c_remove(struct cx8802_dev *dev) 149void vp3054_i2c_remove(struct cx8802_dev *dev)
150{ 150{
151 struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; 151 struct vp3054_i2c_state *vp3054_i2c = dev->vp3054;
152 152
153 if (vp3054_i2c == NULL || 153 if (vp3054_i2c == NULL ||
154 dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 154 dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 42e0a9b8c550..eb296bdecb1e 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -412,7 +412,9 @@ struct cx8802_suspend_state {
412 412
413struct cx8802_driver { 413struct cx8802_driver {
414 struct cx88_core *core; 414 struct cx88_core *core;
415 struct list_head devlist; 415
416 /* List of drivers attached to device */
417 struct list_head drvlist;
416 418
417 /* Type of driver and access required */ 419 /* Type of driver and access required */
418 enum cx88_board_type type_id; 420 enum cx88_board_type type_id;
@@ -453,27 +455,33 @@ struct cx8802_dev {
453 455
454 /* for blackbird only */ 456 /* for blackbird only */
455 struct list_head devlist; 457 struct list_head devlist;
458#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
459 defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
456 struct video_device *mpeg_dev; 460 struct video_device *mpeg_dev;
457 u32 mailbox; 461 u32 mailbox;
458 int width; 462 int width;
459 int height; 463 int height;
460 464
465 /* mpeg params */
466 struct cx2341x_mpeg_params params;
467#endif
468
461#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 469#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
462 /* for dvb only */ 470 /* for dvb only */
463 struct videobuf_dvb dvb; 471 struct videobuf_dvb dvb;
472#endif
464 473
465 void *card_priv; 474#if defined(CONFIG_VIDEO_CX88_VP3054) || \
475 defined(CONFIG_VIDEO_CX88_VP3054_MODULE)
476 /* For VP3045 secondary I2C bus support */
477 struct vp3054_i2c_state *vp3054;
466#endif 478#endif
467 /* for switching modulation types */ 479 /* for switching modulation types */
468 unsigned char ts_gen_cntrl; 480 unsigned char ts_gen_cntrl;
469 481
470 /* mpeg params */
471 struct cx2341x_mpeg_params params;
472
473 /* List of attached drivers */ 482 /* List of attached drivers */
474 struct cx8802_driver drvlist; 483 struct list_head drvlist;
475 struct work_struct request_module_wk; 484 struct work_struct request_module_wk;
476
477}; 485};
478 486
479/* ----------------------------------------------------------- */ 487/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index d3282ec62c5b..d56484f20467 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -648,7 +648,7 @@ void em28xx_uninit_isoc(struct em28xx *dev)
648 */ 648 */
649int em28xx_init_isoc(struct em28xx *dev) 649int em28xx_init_isoc(struct em28xx *dev)
650{ 650{
651 /* change interface to 3 which allowes the biggest packet sizes */ 651 /* change interface to 3 which allows the biggest packet sizes */
652 int i, errCode; 652 int i, errCode;
653 const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; 653 const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size;
654 654
@@ -673,6 +673,7 @@ int em28xx_init_isoc(struct em28xx *dev)
673 ("unable to allocate %i bytes for transfer buffer %i\n", 673 ("unable to allocate %i bytes for transfer buffer %i\n",
674 sb_size, i); 674 sb_size, i);
675 em28xx_uninit_isoc(dev); 675 em28xx_uninit_isoc(dev);
676 usb_free_urb(urb);
676 return -ENOMEM; 677 return -ENOMEM;
677 } 678 }
678 memset(dev->transfer_buffer[i], 0, sb_size); 679 memset(dev->transfer_buffer[i], 0, sb_size);
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index e467682aabd7..a4c2a907124a 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1617,7 +1617,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1617 1617
1618 /* Fills VBI device info */ 1618 /* Fills VBI device info */
1619 dev->vbi_dev->type = VFL_TYPE_VBI; 1619 dev->vbi_dev->type = VFL_TYPE_VBI;
1620 dev->vbi_dev->hardware = 0;
1621 dev->vbi_dev->fops = &em28xx_v4l_fops; 1620 dev->vbi_dev->fops = &em28xx_v4l_fops;
1622 dev->vbi_dev->minor = -1; 1621 dev->vbi_dev->minor = -1;
1623 dev->vbi_dev->dev = &dev->udev->dev; 1622 dev->vbi_dev->dev = &dev->udev->dev;
@@ -1629,7 +1628,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1629 dev->vdev->type = VID_TYPE_CAPTURE; 1628 dev->vdev->type = VID_TYPE_CAPTURE;
1630 if (dev->has_tuner) 1629 if (dev->has_tuner)
1631 dev->vdev->type |= VID_TYPE_TUNER; 1630 dev->vdev->type |= VID_TYPE_TUNER;
1632 dev->vdev->hardware = 0;
1633 dev->vdev->fops = &em28xx_v4l_fops; 1631 dev->vdev->fops = &em28xx_v4l_fops;
1634 dev->vdev->minor = -1; 1632 dev->vdev->minor = -1;
1635 dev->vdev->dev = &dev->udev->dev; 1633 dev->vdev->dev = &dev->udev->dev;
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index d5fef4c01c87..d19d73b81ede 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -2585,7 +2585,6 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2585 strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera"); 2585 strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera");
2586 cam->v4ldev->owner = THIS_MODULE; 2586 cam->v4ldev->owner = THIS_MODULE;
2587 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; 2587 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
2588 cam->v4ldev->hardware = 0;
2589 cam->v4ldev->fops = &et61x251_fops; 2588 cam->v4ldev->fops = &et61x251_fops;
2590 cam->v4ldev->minor = video_nr[dev_nr]; 2589 cam->v4ldev->minor = video_nr[dev_nr];
2591 cam->v4ldev->release = video_device_release; 2590 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index d98dd0d1e373..29779d8bf7fb 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -528,6 +528,7 @@ static int ir_probe(struct i2c_adapter *adap)
528 break; 528 break;
529 case I2C_HW_B_CX2388x: 529 case I2C_HW_B_CX2388x:
530 probe = probe_cx88; 530 probe = probe_cx88;
531 break;
531 case I2C_HW_B_CX23885: 532 case I2C_HW_B_CX23885:
532 probe = probe_cx23885; 533 probe = probe_cx23885;
533 break; 534 break;
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index fd7a932e1d33..6d2dd8764f81 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -1003,8 +1003,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1003 1003
1004 IVTV_DEBUG_INFO("base addr: 0x%08x\n", itv->base_addr); 1004 IVTV_DEBUG_INFO("base addr: 0x%08x\n", itv->base_addr);
1005 1005
1006 mutex_lock(&itv->serialize_lock);
1007
1008 /* PCI Device Setup */ 1006 /* PCI Device Setup */
1009 if ((retval = ivtv_setup_pci(itv, dev, pci_id)) != 0) { 1007 if ((retval = ivtv_setup_pci(itv, dev, pci_id)) != 0) {
1010 if (retval == -EIO) 1008 if (retval == -EIO)
@@ -1064,7 +1062,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1064 IVTV_DEBUG_INFO("activating i2c...\n"); 1062 IVTV_DEBUG_INFO("activating i2c...\n");
1065 if (init_ivtv_i2c(itv)) { 1063 if (init_ivtv_i2c(itv)) {
1066 IVTV_ERR("Could not initialize i2c\n"); 1064 IVTV_ERR("Could not initialize i2c\n");
1067 goto free_irq; 1065 goto free_io;
1068 } 1066 }
1069 1067
1070 IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active); 1068 IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active);
@@ -1176,7 +1174,11 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1176 IVTV_ERR("Failed to register irq %d\n", retval); 1174 IVTV_ERR("Failed to register irq %d\n", retval);
1177 goto free_streams; 1175 goto free_streams;
1178 } 1176 }
1179 mutex_unlock(&itv->serialize_lock); 1177 retval = ivtv_streams_register(itv);
1178 if (retval) {
1179 IVTV_ERR("Error %d registering devices\n", retval);
1180 goto free_irq;
1181 }
1180 IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name); 1182 IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name);
1181 return 0; 1183 return 0;
1182 1184
@@ -1195,7 +1197,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1195 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); 1197 release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
1196 free_workqueue: 1198 free_workqueue:
1197 destroy_workqueue(itv->irq_work_queues); 1199 destroy_workqueue(itv->irq_work_queues);
1198 mutex_unlock(&itv->serialize_lock);
1199 err: 1200 err:
1200 if (retval == 0) 1201 if (retval == 0)
1201 retval = -ENODEV; 1202 retval = -ENODEV;
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index da50fa4a72a5..a200a8a95a2d 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -822,6 +822,11 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
822 crystal_freq.flags = 0; 822 crystal_freq.flags = 0;
823 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq); 823 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq);
824 } 824 }
825 if (atomic_read(&itv->capturing) > 0) {
826 /* Undo video mute */
827 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1,
828 itv->params.video_mute | (itv->params.video_mute_yuv << 8));
829 }
825 /* Done! Unmute and continue. */ 830 /* Done! Unmute and continue. */
826 ivtv_unmute(itv); 831 ivtv_unmute(itv);
827 ivtv_release_stream(s); 832 ivtv_release_stream(s);
@@ -892,6 +897,7 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp)
892 if (atomic_read(&itv->capturing) > 0) { 897 if (atomic_read(&itv->capturing) > 0) {
893 /* switching to radio while capture is 898 /* switching to radio while capture is
894 in progress is not polite */ 899 in progress is not polite */
900 ivtv_release_stream(s);
895 kfree(item); 901 kfree(item);
896 return -EBUSY; 902 return -EBUSY;
897 } 903 }
@@ -947,7 +953,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
947 if (itv == NULL) { 953 if (itv == NULL) {
948 /* Couldn't find a device registered 954 /* Couldn't find a device registered
949 on that minor, shouldn't happen! */ 955 on that minor, shouldn't happen! */
950 IVTV_WARN("No ivtv device found on minor %d\n", minor); 956 printk(KERN_WARNING "No ivtv device found on minor %d\n", minor);
951 return -ENXIO; 957 return -ENXIO;
952 } 958 }
953 959
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 206eee7542db..fd6826f472e3 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -555,6 +555,7 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
555 555
556 /* set window size */ 556 /* set window size */
557 if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 557 if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
558 struct cx2341x_mpeg_params *p = &itv->params;
558 int w = fmt->fmt.pix.width; 559 int w = fmt->fmt.pix.width;
559 int h = fmt->fmt.pix.height; 560 int h = fmt->fmt.pix.height;
560 561
@@ -566,17 +567,19 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
566 fmt->fmt.pix.width = w; 567 fmt->fmt.pix.width = w;
567 fmt->fmt.pix.height = h; 568 fmt->fmt.pix.height = h;
568 569
569 if (!set_fmt || (itv->params.width == w && itv->params.height == h)) 570 if (!set_fmt || (p->width == w && p->height == h))
570 return 0; 571 return 0;
571 if (atomic_read(&itv->capturing) > 0) 572 if (atomic_read(&itv->capturing) > 0)
572 return -EBUSY; 573 return -EBUSY;
573 574
574 itv->params.width = w; 575 p->width = w;
575 itv->params.height = h; 576 p->height = h;
576 if (w != 720 || h != (itv->is_50hz ? 576 : 480)) 577 if (w != 720 || h != (itv->is_50hz ? 576 : 480))
577 itv->params.video_temporal_filter = 0; 578 p->video_temporal_filter = 0;
578 else 579 else
579 itv->params.video_temporal_filter = 8; 580 p->video_temporal_filter = 8;
581 if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
582 fmt->fmt.pix.width /= 2;
580 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); 583 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
581 return ivtv_get_fmt(itv, streamtype, fmt); 584 return ivtv_get_fmt(itv, streamtype, fmt);
582 } 585 }
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index fd135985e70f..aa03e61ef310 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -166,10 +166,9 @@ static void ivtv_stream_init(struct ivtv *itv, int type)
166 ivtv_queue_init(&s->q_io); 166 ivtv_queue_init(&s->q_io);
167} 167}
168 168
169static int ivtv_reg_dev(struct ivtv *itv, int type) 169static int ivtv_prep_dev(struct ivtv *itv, int type)
170{ 170{
171 struct ivtv_stream *s = &itv->streams[type]; 171 struct ivtv_stream *s = &itv->streams[type];
172 int vfl_type = ivtv_stream_info[type].vfl_type;
173 int minor_offset = ivtv_stream_info[type].minor_offset; 172 int minor_offset = ivtv_stream_info[type].minor_offset;
174 int minor; 173 int minor;
175 174
@@ -187,15 +186,12 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
187 if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 186 if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
188 return 0; 187 return 0;
189 188
190 if (minor_offset >= 0) 189 /* card number + user defined offset + device offset */
191 /* card number + user defined offset + device offset */ 190 minor = itv->num + ivtv_first_minor + minor_offset;
192 minor = itv->num + ivtv_first_minor + minor_offset;
193 else
194 minor = -1;
195 191
196 /* User explicitly selected 0 buffers for these streams, so don't 192 /* User explicitly selected 0 buffers for these streams, so don't
197 create them. */ 193 create them. */
198 if (minor >= 0 && ivtv_stream_info[type].dma != PCI_DMA_NONE && 194 if (ivtv_stream_info[type].dma != PCI_DMA_NONE &&
199 itv->options.kilobytes[type] == 0) { 195 itv->options.kilobytes[type] == 0) {
200 IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name); 196 IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name);
201 return 0; 197 return 0;
@@ -223,21 +219,53 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
223 s->v4l2dev->fops = ivtv_stream_info[type].fops; 219 s->v4l2dev->fops = ivtv_stream_info[type].fops;
224 s->v4l2dev->release = video_device_release; 220 s->v4l2dev->release = video_device_release;
225 221
226 if (minor >= 0) { 222 return 0;
227 /* Register device. First try the desired minor, then any free one. */ 223}
228 if (video_register_device(s->v4l2dev, vfl_type, minor) && 224
229 video_register_device(s->v4l2dev, vfl_type, -1)) { 225/* Initialize v4l2 variables and prepare v4l2 devices */
230 IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n", 226int ivtv_streams_setup(struct ivtv *itv)
231 s->name, minor); 227{
232 video_device_release(s->v4l2dev); 228 int type;
233 s->v4l2dev = NULL; 229
234 return -ENOMEM; 230 /* Setup V4L2 Devices */
235 } 231 for (type = 0; type < IVTV_MAX_STREAMS; type++) {
232 /* Prepare device */
233 if (ivtv_prep_dev(itv, type))
234 break;
235
236 if (itv->streams[type].v4l2dev == NULL)
237 continue;
238
239 /* Allocate Stream */
240 if (ivtv_stream_alloc(&itv->streams[type]))
241 break;
236 } 242 }
237 else { 243 if (type == IVTV_MAX_STREAMS)
238 /* Don't register a 'hidden' stream (OSD) */
239 IVTV_INFO("Created framebuffer stream for %s\n", s->name);
240 return 0; 244 return 0;
245
246 /* One or more streams could not be initialized. Clean 'em all up. */
247 ivtv_streams_cleanup(itv);
248 return -ENOMEM;
249}
250
251static int ivtv_reg_dev(struct ivtv *itv, int type)
252{
253 struct ivtv_stream *s = &itv->streams[type];
254 int vfl_type = ivtv_stream_info[type].vfl_type;
255 int minor;
256
257 if (s->v4l2dev == NULL)
258 return 0;
259
260 minor = s->v4l2dev->minor;
261 /* Register device. First try the desired minor, then any free one. */
262 if (video_register_device(s->v4l2dev, vfl_type, minor) &&
263 video_register_device(s->v4l2dev, vfl_type, -1)) {
264 IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n",
265 s->name, minor);
266 video_device_release(s->v4l2dev);
267 s->v4l2dev = NULL;
268 return -ENOMEM;
241 } 269 }
242 270
243 switch (vfl_type) { 271 switch (vfl_type) {
@@ -262,27 +290,18 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
262 return 0; 290 return 0;
263} 291}
264 292
265/* Initialize v4l2 variables and register v4l2 devices */ 293/* Register v4l2 devices */
266int ivtv_streams_setup(struct ivtv *itv) 294int ivtv_streams_register(struct ivtv *itv)
267{ 295{
268 int type; 296 int type;
297 int err = 0;
269 298
270 /* Setup V4L2 Devices */ 299 /* Register V4L2 devices */
271 for (type = 0; type < IVTV_MAX_STREAMS; type++) { 300 for (type = 0; type < IVTV_MAX_STREAMS; type++)
272 /* Register Device */ 301 err |= ivtv_reg_dev(itv, type);
273 if (ivtv_reg_dev(itv, type))
274 break;
275
276 if (itv->streams[type].v4l2dev == NULL)
277 continue;
278 302
279 /* Allocate Stream */ 303 if (err == 0)
280 if (ivtv_stream_alloc(&itv->streams[type]))
281 break;
282 }
283 if (type == IVTV_MAX_STREAMS) {
284 return 0; 304 return 0;
285 }
286 305
287 /* One or more streams could not be initialized. Clean 'em all up. */ 306 /* One or more streams could not be initialized. Clean 'em all up. */
288 ivtv_streams_cleanup(itv); 307 ivtv_streams_cleanup(itv);
@@ -303,11 +322,8 @@ void ivtv_streams_cleanup(struct ivtv *itv)
303 continue; 322 continue;
304 323
305 ivtv_stream_free(&itv->streams[type]); 324 ivtv_stream_free(&itv->streams[type]);
306 /* Free Device */ 325 /* Unregister device */
307 if (vdev->minor == -1) /* 'Hidden' never registered stream (OSD) */ 326 video_unregister_device(vdev);
308 video_device_release(vdev);
309 else /* All others, just unregister. */
310 video_unregister_device(vdev);
311 } 327 }
312} 328}
313 329
@@ -425,6 +441,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
425{ 441{
426 u32 data[CX2341X_MBOX_MAX_DATA]; 442 u32 data[CX2341X_MBOX_MAX_DATA];
427 struct ivtv *itv = s->itv; 443 struct ivtv *itv = s->itv;
444 struct cx2341x_mpeg_params *p = &itv->params;
428 int captype = 0, subtype = 0; 445 int captype = 0, subtype = 0;
429 int enable_passthrough = 0; 446 int enable_passthrough = 0;
430 447
@@ -445,7 +462,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
445 } 462 }
446 itv->mpg_data_received = itv->vbi_data_inserted = 0; 463 itv->mpg_data_received = itv->vbi_data_inserted = 0;
447 itv->dualwatch_jiffies = jiffies; 464 itv->dualwatch_jiffies = jiffies;
448 itv->dualwatch_stereo_mode = itv->params.audio_properties & 0x0300; 465 itv->dualwatch_stereo_mode = p->audio_properties & 0x0300;
449 itv->search_pack_header = 0; 466 itv->search_pack_header = 0;
450 break; 467 break;
451 468
@@ -477,9 +494,6 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
477 s->subtype = subtype; 494 s->subtype = subtype;
478 s->buffers_stolen = 0; 495 s->buffers_stolen = 0;
479 496
480 /* mute/unmute video */
481 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? 1 : 0);
482
483 /* Clear Streamoff flags in case left from last capture */ 497 /* Clear Streamoff flags in case left from last capture */
484 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); 498 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags);
485 499
@@ -536,7 +550,12 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
536 itv->pgm_info_offset, itv->pgm_info_num); 550 itv->pgm_info_offset, itv->pgm_info_num);
537 551
538 /* Setup API for Stream */ 552 /* Setup API for Stream */
539 cx2341x_update(itv, ivtv_api_func, NULL, &itv->params); 553 cx2341x_update(itv, ivtv_api_func, NULL, p);
554
555 /* mute if capturing radio */
556 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
557 ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1,
558 1 | (p->video_mute_yuv << 8));
540 } 559 }
541 560
542 /* Vsync Setup */ 561 /* Vsync Setup */
@@ -585,6 +604,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
585{ 604{
586 u32 data[CX2341X_MBOX_MAX_DATA]; 605 u32 data[CX2341X_MBOX_MAX_DATA];
587 struct ivtv *itv = s->itv; 606 struct ivtv *itv = s->itv;
607 struct cx2341x_mpeg_params *p = &itv->params;
588 int datatype; 608 int datatype;
589 609
590 if (s->v4l2dev == NULL) 610 if (s->v4l2dev == NULL)
@@ -623,7 +643,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
623 break; 643 break;
624 } 644 }
625 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype, 645 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype,
626 itv->params.width, itv->params.height, itv->params.audio_properties)) { 646 p->width, p->height, p->audio_properties)) {
627 IVTV_DEBUG_WARN("Couldn't initialize decoder source\n"); 647 IVTV_DEBUG_WARN("Couldn't initialize decoder source\n");
628 } 648 }
629 return 0; 649 return 0;
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h
index 8f5f5b1c7c89..3d76a415fbd8 100644
--- a/drivers/media/video/ivtv/ivtv-streams.h
+++ b/drivers/media/video/ivtv/ivtv-streams.h
@@ -22,6 +22,7 @@
22#define IVTV_STREAMS_H 22#define IVTV_STREAMS_H
23 23
24int ivtv_streams_setup(struct ivtv *itv); 24int ivtv_streams_setup(struct ivtv *itv);
25int ivtv_streams_register(struct ivtv *itv);
25void ivtv_streams_cleanup(struct ivtv *itv); 26void ivtv_streams_cleanup(struct ivtv *itv);
26 27
27/* Capture related */ 28/* Capture related */
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index e2288f224ab6..9091c4837bbc 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -710,7 +710,7 @@ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *windo
710 710
711 /* If there's nothing to safe to display, we may as well stop now */ 711 /* If there's nothing to safe to display, we may as well stop now */
712 if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { 712 if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) {
713 return 0; 713 return IVTV_YUV_UPDATE_INVALID;
714 } 714 }
715 715
716 /* Ensure video remains inside OSD area */ 716 /* Ensure video remains inside OSD area */
@@ -791,7 +791,7 @@ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *windo
791 791
792 /* Check again. If there's nothing to safe to display, stop now */ 792 /* Check again. If there's nothing to safe to display, stop now */
793 if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { 793 if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) {
794 return 0; 794 return IVTV_YUV_UPDATE_INVALID;
795 } 795 }
796 796
797 /* Both x offset & width are linked, so they have to be done together */ 797 /* Both x offset & width are linked, so they have to be done together */
@@ -840,110 +840,118 @@ void ivtv_yuv_work_handler (struct ivtv *itv)
840 if (!(yuv_update = ivtv_yuv_window_setup (itv, &window))) 840 if (!(yuv_update = ivtv_yuv_window_setup (itv, &window)))
841 return; 841 return;
842 842
843 /* Update horizontal settings */ 843 if (yuv_update & IVTV_YUV_UPDATE_INVALID) {
844 if (yuv_update & IVTV_YUV_UPDATE_HORIZONTAL) 844 write_reg(0x01008080, 0x2898);
845 ivtv_yuv_handle_horizontal(itv, &window); 845 } else if (yuv_update) {
846 write_reg(0x00108080, 0x2898);
846 847
847 if (yuv_update & IVTV_YUV_UPDATE_VERTICAL) 848 if (yuv_update & IVTV_YUV_UPDATE_HORIZONTAL)
848 ivtv_yuv_handle_vertical(itv, &window); 849 ivtv_yuv_handle_horizontal(itv, &window);
850
851 if (yuv_update & IVTV_YUV_UPDATE_VERTICAL)
852 ivtv_yuv_handle_vertical(itv, &window);
853 }
849 854
850 memcpy(&itv->yuv_info.old_frame_info, &window, sizeof (itv->yuv_info.old_frame_info)); 855 memcpy(&itv->yuv_info.old_frame_info, &window, sizeof (itv->yuv_info.old_frame_info));
851} 856}
852 857
853static void ivtv_yuv_init (struct ivtv *itv) 858static void ivtv_yuv_init (struct ivtv *itv)
854{ 859{
860 struct yuv_playback_info *yi = &itv->yuv_info;
861
855 IVTV_DEBUG_YUV("ivtv_yuv_init\n"); 862 IVTV_DEBUG_YUV("ivtv_yuv_init\n");
856 863
857 /* Take a snapshot of the current register settings */ 864 /* Take a snapshot of the current register settings */
858 itv->yuv_info.reg_2834 = read_reg(0x02834); 865 yi->reg_2834 = read_reg(0x02834);
859 itv->yuv_info.reg_2838 = read_reg(0x02838); 866 yi->reg_2838 = read_reg(0x02838);
860 itv->yuv_info.reg_283c = read_reg(0x0283c); 867 yi->reg_283c = read_reg(0x0283c);
861 itv->yuv_info.reg_2840 = read_reg(0x02840); 868 yi->reg_2840 = read_reg(0x02840);
862 itv->yuv_info.reg_2844 = read_reg(0x02844); 869 yi->reg_2844 = read_reg(0x02844);
863 itv->yuv_info.reg_2848 = read_reg(0x02848); 870 yi->reg_2848 = read_reg(0x02848);
864 itv->yuv_info.reg_2854 = read_reg(0x02854); 871 yi->reg_2854 = read_reg(0x02854);
865 itv->yuv_info.reg_285c = read_reg(0x0285c); 872 yi->reg_285c = read_reg(0x0285c);
866 itv->yuv_info.reg_2864 = read_reg(0x02864); 873 yi->reg_2864 = read_reg(0x02864);
867 itv->yuv_info.reg_2870 = read_reg(0x02870); 874 yi->reg_2870 = read_reg(0x02870);
868 itv->yuv_info.reg_2874 = read_reg(0x02874); 875 yi->reg_2874 = read_reg(0x02874);
869 itv->yuv_info.reg_2898 = read_reg(0x02898); 876 yi->reg_2898 = read_reg(0x02898);
870 itv->yuv_info.reg_2890 = read_reg(0x02890); 877 yi->reg_2890 = read_reg(0x02890);
871 878
872 itv->yuv_info.reg_289c = read_reg(0x0289c); 879 yi->reg_289c = read_reg(0x0289c);
873 itv->yuv_info.reg_2918 = read_reg(0x02918); 880 yi->reg_2918 = read_reg(0x02918);
874 itv->yuv_info.reg_291c = read_reg(0x0291c); 881 yi->reg_291c = read_reg(0x0291c);
875 itv->yuv_info.reg_2920 = read_reg(0x02920); 882 yi->reg_2920 = read_reg(0x02920);
876 itv->yuv_info.reg_2924 = read_reg(0x02924); 883 yi->reg_2924 = read_reg(0x02924);
877 itv->yuv_info.reg_2928 = read_reg(0x02928); 884 yi->reg_2928 = read_reg(0x02928);
878 itv->yuv_info.reg_292c = read_reg(0x0292c); 885 yi->reg_292c = read_reg(0x0292c);
879 itv->yuv_info.reg_2930 = read_reg(0x02930); 886 yi->reg_2930 = read_reg(0x02930);
880 itv->yuv_info.reg_2934 = read_reg(0x02934); 887 yi->reg_2934 = read_reg(0x02934);
881 itv->yuv_info.reg_2938 = read_reg(0x02938); 888 yi->reg_2938 = read_reg(0x02938);
882 itv->yuv_info.reg_293c = read_reg(0x0293c); 889 yi->reg_293c = read_reg(0x0293c);
883 itv->yuv_info.reg_2940 = read_reg(0x02940); 890 yi->reg_2940 = read_reg(0x02940);
884 itv->yuv_info.reg_2944 = read_reg(0x02944); 891 yi->reg_2944 = read_reg(0x02944);
885 itv->yuv_info.reg_2948 = read_reg(0x02948); 892 yi->reg_2948 = read_reg(0x02948);
886 itv->yuv_info.reg_294c = read_reg(0x0294c); 893 yi->reg_294c = read_reg(0x0294c);
887 itv->yuv_info.reg_2950 = read_reg(0x02950); 894 yi->reg_2950 = read_reg(0x02950);
888 itv->yuv_info.reg_2954 = read_reg(0x02954); 895 yi->reg_2954 = read_reg(0x02954);
889 itv->yuv_info.reg_2958 = read_reg(0x02958); 896 yi->reg_2958 = read_reg(0x02958);
890 itv->yuv_info.reg_295c = read_reg(0x0295c); 897 yi->reg_295c = read_reg(0x0295c);
891 itv->yuv_info.reg_2960 = read_reg(0x02960); 898 yi->reg_2960 = read_reg(0x02960);
892 itv->yuv_info.reg_2964 = read_reg(0x02964); 899 yi->reg_2964 = read_reg(0x02964);
893 itv->yuv_info.reg_2968 = read_reg(0x02968); 900 yi->reg_2968 = read_reg(0x02968);
894 itv->yuv_info.reg_296c = read_reg(0x0296c); 901 yi->reg_296c = read_reg(0x0296c);
895 itv->yuv_info.reg_2970 = read_reg(0x02970); 902 yi->reg_2970 = read_reg(0x02970);
896 903
897 itv->yuv_info.v_filter_1 = -1; 904 yi->v_filter_1 = -1;
898 itv->yuv_info.v_filter_2 = -1; 905 yi->v_filter_2 = -1;
899 itv->yuv_info.h_filter = -1; 906 yi->h_filter = -1;
900 907
901 /* Set some valid size info */ 908 /* Set some valid size info */
902 itv->yuv_info.osd_x_offset = read_reg(0x02a04) & 0x00000FFF; 909 yi->osd_x_offset = read_reg(0x02a04) & 0x00000FFF;
903 itv->yuv_info.osd_y_offset = (read_reg(0x02a04) >> 16) & 0x00000FFF; 910 yi->osd_y_offset = (read_reg(0x02a04) >> 16) & 0x00000FFF;
904 911
905 /* Bit 2 of reg 2878 indicates current decoder output format 912 /* Bit 2 of reg 2878 indicates current decoder output format
906 0 : NTSC 1 : PAL */ 913 0 : NTSC 1 : PAL */
907 if (read_reg(0x2878) & 4) 914 if (read_reg(0x2878) & 4)
908 itv->yuv_info.decode_height = 576; 915 yi->decode_height = 576;
909 else 916 else
910 itv->yuv_info.decode_height = 480; 917 yi->decode_height = 480;
911 918
912 /* If no visible size set, assume full size */ 919 if (!itv->osd_info) {
913 if (!itv->yuv_info.osd_vis_w) 920 yi->osd_vis_w = 720 - yi->osd_x_offset;
914 itv->yuv_info.osd_vis_w = 720 - itv->yuv_info.osd_x_offset; 921 yi->osd_vis_h = yi->decode_height - yi->osd_y_offset;
915
916 if (!itv->yuv_info.osd_vis_h) {
917 itv->yuv_info.osd_vis_h = itv->yuv_info.decode_height - itv->yuv_info.osd_y_offset;
918 } else { 922 } else {
919 /* If output video standard has changed, requested height may 923 /* If no visible size set, assume full size */
920 not be legal */ 924 if (!yi->osd_vis_w)
921 if (itv->yuv_info.osd_vis_h + itv->yuv_info.osd_y_offset > itv->yuv_info.decode_height) { 925 yi->osd_vis_w = 720 - yi->osd_x_offset;
922 IVTV_DEBUG_WARN("Clipping yuv output - fb size (%d) exceeds video standard limit (%d)\n", 926
923 itv->yuv_info.osd_vis_h + itv->yuv_info.osd_y_offset, 927 if (!yi->osd_vis_h)
924 itv->yuv_info.decode_height); 928 yi->osd_vis_h = yi->decode_height - yi->osd_y_offset;
925 itv->yuv_info.osd_vis_h = itv->yuv_info.decode_height - itv->yuv_info.osd_y_offset; 929 else {
930 /* If output video standard has changed, requested height may
931 not be legal */
932 if (yi->osd_vis_h + yi->osd_y_offset > yi->decode_height) {
933 IVTV_DEBUG_WARN("Clipping yuv output - fb size (%d) exceeds video standard limit (%d)\n",
934 yi->osd_vis_h + yi->osd_y_offset,
935 yi->decode_height);
936 yi->osd_vis_h = yi->decode_height - yi->osd_y_offset;
937 }
926 } 938 }
927 } 939 }
928 940
929 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ 941 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */
930 itv->yuv_info.blanking_ptr = kzalloc(720*16,GFP_KERNEL); 942 yi->blanking_ptr = kzalloc(720*16, GFP_KERNEL);
931 if (itv->yuv_info.blanking_ptr) { 943 if (yi->blanking_ptr)
932 itv->yuv_info.blanking_dmaptr = pci_map_single(itv->dev, itv->yuv_info.blanking_ptr, 720*16, PCI_DMA_TODEVICE); 944 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE);
933 }
934 else { 945 else {
935 itv->yuv_info.blanking_dmaptr = 0; 946 yi->blanking_dmaptr = 0;
936 IVTV_DEBUG_WARN ("Failed to allocate yuv blanking buffer\n"); 947 IVTV_DEBUG_WARN("Failed to allocate yuv blanking buffer\n");
937 } 948 }
938 949
939 IVTV_DEBUG_WARN("Enable video output\n");
940 write_reg_sync(0x00108080, 0x2898);
941
942 /* Enable YUV decoder output */ 950 /* Enable YUV decoder output */
943 write_reg_sync(0x01, IVTV_REG_VDM); 951 write_reg_sync(0x01, IVTV_REG_VDM);
944 952
945 set_bit(IVTV_F_I_DECODING_YUV, &itv->i_flags); 953 set_bit(IVTV_F_I_DECODING_YUV, &itv->i_flags);
946 atomic_set(&itv->yuv_info.next_dma_frame,0); 954 atomic_set(&yi->next_dma_frame, 0);
947} 955}
948 956
949int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args) 957int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args)
diff --git a/drivers/media/video/ivtv/ivtv-yuv.h b/drivers/media/video/ivtv/ivtv-yuv.h
index f7215eeca018..3b966f0a204a 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.h
+++ b/drivers/media/video/ivtv/ivtv-yuv.h
@@ -34,6 +34,7 @@
34 34
35#define IVTV_YUV_UPDATE_HORIZONTAL 0x01 35#define IVTV_YUV_UPDATE_HORIZONTAL 0x01
36#define IVTV_YUV_UPDATE_VERTICAL 0x02 36#define IVTV_YUV_UPDATE_VERTICAL 0x02
37#define IVTV_YUV_UPDATE_INVALID 0x04
37 38
38extern const u32 yuv_offset[4]; 39extern const u32 yuv_offset[4];
39 40
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index 9684048fe56c..52ffd154a3d8 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -55,7 +55,6 @@
55static int ivtvfb_card_id = -1; 55static int ivtvfb_card_id = -1;
56static int ivtvfb_debug = 0; 56static int ivtvfb_debug = 0;
57static int osd_laced; 57static int osd_laced;
58static int osd_compat;
59static int osd_depth; 58static int osd_depth;
60static int osd_upper; 59static int osd_upper;
61static int osd_left; 60static int osd_left;
@@ -65,7 +64,6 @@ static int osd_xres;
65module_param(ivtvfb_card_id, int, 0444); 64module_param(ivtvfb_card_id, int, 0444);
66module_param_named(debug,ivtvfb_debug, int, 0644); 65module_param_named(debug,ivtvfb_debug, int, 0644);
67module_param(osd_laced, bool, 0444); 66module_param(osd_laced, bool, 0444);
68module_param(osd_compat, bool, 0444);
69module_param(osd_depth, int, 0444); 67module_param(osd_depth, int, 0444);
70module_param(osd_upper, int, 0444); 68module_param(osd_upper, int, 0444);
71module_param(osd_left, int, 0444); 69module_param(osd_left, int, 0444);
@@ -80,12 +78,6 @@ MODULE_PARM_DESC(debug,
80 "Debug level (bitmask). Default: errors only\n" 78 "Debug level (bitmask). Default: errors only\n"
81 "\t\t\t(debug = 3 gives full debugging)"); 79 "\t\t\t(debug = 3 gives full debugging)");
82 80
83MODULE_PARM_DESC(osd_compat,
84 "Compatibility mode - Display size is locked (use for old X drivers)\n"
85 "\t\t\t0=off\n"
86 "\t\t\t1=on\n"
87 "\t\t\tdefault off");
88
89/* Why upper, left, xres, yres, depth, laced ? To match terminology used 81/* Why upper, left, xres, yres, depth, laced ? To match terminology used
90 by fbset. 82 by fbset.
91 Why start at 1 for left & upper coordinate ? Because X doesn't allow 0 */ 83 Why start at 1 for left & upper coordinate ? Because X doesn't allow 0 */
@@ -166,9 +158,6 @@ struct osd_info {
166 unsigned long fb_end_aligned_physaddr; 158 unsigned long fb_end_aligned_physaddr;
167#endif 159#endif
168 160
169 /* Current osd mode */
170 int osd_mode;
171
172 /* Store the buffer offset */ 161 /* Store the buffer offset */
173 int set_osd_coords_x; 162 int set_osd_coords_x;
174 int set_osd_coords_y; 163 int set_osd_coords_y;
@@ -470,13 +459,11 @@ static int ivtvfb_set_var(struct ivtv *itv, struct fb_var_screeninfo *var)
470 IVTVFB_DEBUG_WARN("ivtvfb_set_var - Invalid bpp\n"); 459 IVTVFB_DEBUG_WARN("ivtvfb_set_var - Invalid bpp\n");
471 } 460 }
472 461
473 /* Change osd mode if needed. 462 /* Set video mode. Although rare, the display can become scrambled even
474 Although rare, things can go wrong. The extra mode 463 if we don't change mode. Always 'bounce' to osd_mode via mode 0 */
475 change seems to help... */ 464 if (osd_mode != -1) {
476 if (osd_mode != -1 && osd_mode != oi->osd_mode) {
477 ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, 0); 465 ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, 0);
478 ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, osd_mode); 466 ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, osd_mode);
479 oi->osd_mode = osd_mode;
480 } 467 }
481 468
482 oi->bits_per_pixel = var->bits_per_pixel; 469 oi->bits_per_pixel = var->bits_per_pixel;
@@ -579,14 +566,6 @@ static int _ivtvfb_check_var(struct fb_var_screeninfo *var, struct ivtv *itv)
579 osd_height_limit = 480; 566 osd_height_limit = 480;
580 } 567 }
581 568
582 /* Check the bits per pixel */
583 if (osd_compat) {
584 if (var->bits_per_pixel != 32) {
585 IVTVFB_DEBUG_WARN("Invalid colour mode: %d\n", var->bits_per_pixel);
586 return -EINVAL;
587 }
588 }
589
590 if (var->bits_per_pixel == 8 || var->bits_per_pixel == 32) { 569 if (var->bits_per_pixel == 8 || var->bits_per_pixel == 32) {
591 var->transp.offset = 24; 570 var->transp.offset = 24;
592 var->transp.length = 8; 571 var->transp.length = 8;
@@ -638,32 +617,20 @@ static int _ivtvfb_check_var(struct fb_var_screeninfo *var, struct ivtv *itv)
638 } 617 }
639 618
640 /* Check the resolution */ 619 /* Check the resolution */
641 if (osd_compat) { 620 if (var->xres > IVTV_OSD_MAX_WIDTH || var->yres > osd_height_limit) {
642 if (var->xres != oi->ivtvfb_defined.xres || 621 IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d\n",
643 var->yres != oi->ivtvfb_defined.yres || 622 var->xres, var->yres);
644 var->xres_virtual != oi->ivtvfb_defined.xres_virtual || 623 return -EINVAL;
645 var->yres_virtual != oi->ivtvfb_defined.yres_virtual) {
646 IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d (virtual %dx%d)\n",
647 var->xres, var->yres, var->xres_virtual, var->yres_virtual);
648 return -EINVAL;
649 }
650 } 624 }
651 else {
652 if (var->xres > IVTV_OSD_MAX_WIDTH || var->yres > osd_height_limit) {
653 IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d\n",
654 var->xres, var->yres);
655 return -EINVAL;
656 }
657 625
658 /* Max horizontal size is 1023 @ 32bpp, 2046 & 16bpp, 4092 @ 8bpp */ 626 /* Max horizontal size is 1023 @ 32bpp, 2046 & 16bpp, 4092 @ 8bpp */
659 if (var->xres_virtual > 4095 / (var->bits_per_pixel / 8) || 627 if (var->xres_virtual > 4095 / (var->bits_per_pixel / 8) ||
660 var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8) > oi->video_buffer_size || 628 var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8) > oi->video_buffer_size ||
661 var->xres_virtual < var->xres || 629 var->xres_virtual < var->xres ||
662 var->yres_virtual < var->yres) { 630 var->yres_virtual < var->yres) {
663 IVTVFB_DEBUG_WARN("Invalid virtual resolution: %dx%d\n", 631 IVTVFB_DEBUG_WARN("Invalid virtual resolution: %dx%d\n",
664 var->xres_virtual, var->yres_virtual); 632 var->xres_virtual, var->yres_virtual);
665 return -EINVAL; 633 return -EINVAL;
666 }
667 } 634 }
668 635
669 /* Some extra checks if in 8 bit mode */ 636 /* Some extra checks if in 8 bit mode */
@@ -877,17 +844,15 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
877 844
878 /* Color mode */ 845 /* Color mode */
879 846
880 if (osd_compat) osd_depth = 32; 847 if (osd_depth != 8 && osd_depth != 16 && osd_depth != 32)
881 if (osd_depth != 8 && osd_depth != 16 && osd_depth != 32) osd_depth = 8; 848 osd_depth = 8;
882 oi->bits_per_pixel = osd_depth; 849 oi->bits_per_pixel = osd_depth;
883 oi->bytes_per_pixel = oi->bits_per_pixel / 8; 850 oi->bytes_per_pixel = oi->bits_per_pixel / 8;
884 851
885 /* Invalidate current osd mode to force a mode switch later */
886 oi->osd_mode = -1;
887
888 /* Horizontal size & position */ 852 /* Horizontal size & position */
889 853
890 if (osd_xres > 720) osd_xres = 720; 854 if (osd_xres > 720)
855 osd_xres = 720;
891 856
892 /* Must be a multiple of 4 for 8bpp & 2 for 16bpp */ 857 /* Must be a multiple of 4 for 8bpp & 2 for 16bpp */
893 if (osd_depth == 8) 858 if (osd_depth == 8)
@@ -895,10 +860,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
895 else if (osd_depth == 16) 860 else if (osd_depth == 16)
896 osd_xres &= ~1; 861 osd_xres &= ~1;
897 862
898 if (osd_xres) 863 start_window.width = osd_xres ? osd_xres : 640;
899 start_window.width = osd_xres;
900 else
901 start_window.width = osd_compat ? 720: 640;
902 864
903 /* Check horizontal start (osd_left). */ 865 /* Check horizontal start (osd_left). */
904 if (osd_left && osd_left + start_window.width > 721) { 866 if (osd_left && osd_left + start_window.width > 721) {
@@ -921,10 +883,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
921 if (osd_yres > max_height) 883 if (osd_yres > max_height)
922 osd_yres = max_height; 884 osd_yres = max_height;
923 885
924 if (osd_yres) 886 start_window.height = osd_yres ? osd_yres : itv->is_50hz ? 480 : 400;
925 start_window.height = osd_yres;
926 else
927 start_window.height = osd_compat ? max_height : (itv->is_50hz ? 480 : 400);
928 887
929 /* Check vertical start (osd_upper). */ 888 /* Check vertical start (osd_upper). */
930 if (osd_upper + start_window.height > max_height + 1) { 889 if (osd_upper + start_window.height > max_height + 1) {
@@ -1127,10 +1086,6 @@ static int ivtvfb_init_card(struct ivtv *itv)
1127 /* Enable the osd */ 1086 /* Enable the osd */
1128 ivtvfb_blank(FB_BLANK_UNBLANK, &itv->osd_info->ivtvfb_info); 1087 ivtvfb_blank(FB_BLANK_UNBLANK, &itv->osd_info->ivtvfb_info);
1129 1088
1130 /* Note if we're running in compatibility mode */
1131 if (osd_compat)
1132 IVTVFB_INFO("Running in compatibility mode. Display resize & mode change disabled\n");
1133
1134 /* Allocate DMA */ 1089 /* Allocate DMA */
1135 ivtv_udma_alloc(itv); 1090 ivtv_udma_alloc(itv);
1136 return 0; 1091 return 0;
@@ -1177,9 +1132,12 @@ static void ivtvfb_cleanup(void)
1177 for (i = 0; i < ivtv_cards_active; i++) { 1132 for (i = 0; i < ivtv_cards_active; i++) {
1178 itv = ivtv_cards[i]; 1133 itv = ivtv_cards[i];
1179 if (itv && (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) && itv->osd_info) { 1134 if (itv && (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) && itv->osd_info) {
1135 if (unregister_framebuffer(&itv->osd_info->ivtvfb_info)) {
1136 IVTVFB_WARN("Framebuffer %d is in use, cannot unload\n", i);
1137 return;
1138 }
1180 IVTVFB_DEBUG_INFO("Unregister framebuffer %d\n", i); 1139 IVTVFB_DEBUG_INFO("Unregister framebuffer %d\n", i);
1181 ivtvfb_blank(FB_BLANK_POWERDOWN, &itv->osd_info->ivtvfb_info); 1140 ivtvfb_blank(FB_BLANK_POWERDOWN, &itv->osd_info->ivtvfb_info);
1182 unregister_framebuffer(&itv->osd_info->ivtvfb_info);
1183 ivtvfb_release_buffers(itv); 1141 ivtvfb_release_buffers(itv);
1184 itv->osd_video_pbase = 0; 1142 itv->osd_video_pbase = 0;
1185 } 1143 }
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 69283926a8dc..c31163290432 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1762,7 +1762,6 @@ static struct video_device meye_template = {
1762 .owner = THIS_MODULE, 1762 .owner = THIS_MODULE,
1763 .name = "meye", 1763 .name = "meye",
1764 .type = VID_TYPE_CAPTURE, 1764 .type = VID_TYPE_CAPTURE,
1765 .hardware = VID_HARDWARE_MEYE,
1766 .fops = &meye_fops, 1765 .fops = &meye_fops,
1767 .release = video_device_release, 1766 .release = video_device_release,
1768 .minor = -1, 1767 .minor = -1,
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index b8d4ac0d938e..d55d5800efb4 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -4668,7 +4668,6 @@ static struct video_device vdev_template = {
4668 .owner = THIS_MODULE, 4668 .owner = THIS_MODULE,
4669 .name = "OV511 USB Camera", 4669 .name = "OV511 USB Camera",
4670 .type = VID_TYPE_CAPTURE, 4670 .type = VID_TYPE_CAPTURE,
4671 .hardware = VID_HARDWARE_OV511,
4672 .fops = &ov511_fops, 4671 .fops = &ov511_fops,
4673 .release = video_device_release, 4672 .release = video_device_release,
4674 .minor = -1, 4673 .minor = -1,
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 0ef73d9d5848..ce4b2f9791ee 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -2013,7 +2013,6 @@ static struct video_device planb_template=
2013 .owner = THIS_MODULE, 2013 .owner = THIS_MODULE,
2014 .name = PLANB_DEVICE_NAME, 2014 .name = PLANB_DEVICE_NAME,
2015 .type = VID_TYPE_OVERLAY, 2015 .type = VID_TYPE_OVERLAY,
2016 .hardware = VID_HARDWARE_PLANB,
2017 .open = planb_open, 2016 .open = planb_open,
2018 .close = planb_close, 2017 .close = planb_close,
2019 .read = planb_read, 2018 .read = planb_read,
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index b5a67f0dd19f..6820c2aabd30 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -895,7 +895,6 @@ static struct video_device pms_template=
895 .owner = THIS_MODULE, 895 .owner = THIS_MODULE,
896 .name = "Mediavision PMS", 896 .name = "Mediavision PMS",
897 .type = VID_TYPE_CAPTURE, 897 .type = VID_TYPE_CAPTURE,
898 .hardware = VID_HARDWARE_PMS,
899 .fops = &pms_fops, 898 .fops = &pms_fops,
900}; 899};
901 900
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 20b614436d2c..205087a3e136 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -209,6 +209,11 @@ static int pvr2_encoder_cmd(void *ctxt,
209 209
210 LOCK_TAKE(hdw->ctl_lock); do { 210 LOCK_TAKE(hdw->ctl_lock); do {
211 211
212 if (!hdw->flag_encoder_ok) {
213 ret = -EIO;
214 break;
215 }
216
212 retry_flag = 0; 217 retry_flag = 0;
213 try_count++; 218 try_count++;
214 ret = 0; 219 ret = 0;
@@ -273,6 +278,7 @@ static int pvr2_encoder_cmd(void *ctxt,
273 ret = -EBUSY; 278 ret = -EBUSY;
274 } 279 }
275 if (ret) { 280 if (ret) {
281 hdw->flag_encoder_ok = 0;
276 pvr2_trace( 282 pvr2_trace(
277 PVR2_TRACE_ERROR_LEGS, 283 PVR2_TRACE_ERROR_LEGS,
278 "Giving up on command." 284 "Giving up on command."
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 985d9ae7f5ee..f873994b088c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -225,11 +225,12 @@ struct pvr2_hdw {
225 unsigned int cmd_debug_write_len; // 225 unsigned int cmd_debug_write_len; //
226 unsigned int cmd_debug_read_len; // 226 unsigned int cmd_debug_read_len; //
227 227
228 int flag_ok; // device in known good state 228 int flag_ok; /* device in known good state */
229 int flag_disconnected; // flag_ok == 0 due to disconnect 229 int flag_disconnected; /* flag_ok == 0 due to disconnect */
230 int flag_init_ok; // true if structure is fully initialized 230 int flag_init_ok; /* true if structure is fully initialized */
231 int flag_streaming_enabled; // true if streaming should be on 231 int flag_streaming_enabled; /* true if streaming should be on */
232 int fw1_state; // current situation with fw1 232 int fw1_state; /* current situation with fw1 */
233 int flag_encoder_ok; /* True if encoder is healthy */
233 234
234 int flag_decoder_is_tuned; 235 int flag_decoder_is_tuned;
235 236
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 27b12b4b5c88..402c59488253 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1248,6 +1248,8 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1248 time we configure the encoder, then we'll fully configure it. */ 1248 time we configure the encoder, then we'll fully configure it. */
1249 hdw->enc_cur_valid = 0; 1249 hdw->enc_cur_valid = 0;
1250 1250
1251 hdw->flag_encoder_ok = 0;
1252
1251 /* First prepare firmware loading */ 1253 /* First prepare firmware loading */
1252 ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ 1254 ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/
1253 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ 1255 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/
@@ -1346,6 +1348,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1346 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1348 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1347 "firmware2 upload post-proc failure"); 1349 "firmware2 upload post-proc failure");
1348 } else { 1350 } else {
1351 hdw->flag_encoder_ok = !0;
1349 hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_FIRMWARE); 1352 hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_FIRMWARE);
1350 } 1353 }
1351 return ret; 1354 return ret;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 4563b3df8a0d..7a596ea7cfe6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -1121,15 +1121,12 @@ static const struct file_operations vdev_fops = {
1121}; 1121};
1122 1122
1123 1123
1124#define VID_HARDWARE_PVRUSB2 38 /* FIXME : need a good value */
1125
1126static struct video_device vdev_template = { 1124static struct video_device vdev_template = {
1127 .owner = THIS_MODULE, 1125 .owner = THIS_MODULE,
1128 .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER, 1126 .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER,
1129 .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE 1127 .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE
1130 | V4L2_CAP_TUNER | V4L2_CAP_AUDIO 1128 | V4L2_CAP_TUNER | V4L2_CAP_AUDIO
1131 | V4L2_CAP_READWRITE), 1129 | V4L2_CAP_READWRITE),
1132 .hardware = VID_HARDWARE_PVRUSB2,
1133 .fops = &vdev_fops, 1130 .fops = &vdev_fops,
1134}; 1131};
1135 1132
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 950da2542148..7300ace8f44e 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -166,7 +166,6 @@ static struct video_device pwc_template = {
166 .owner = THIS_MODULE, 166 .owner = THIS_MODULE,
167 .name = "Philips Webcam", /* Filled in later */ 167 .name = "Philips Webcam", /* Filled in later */
168 .type = VID_TYPE_CAPTURE, 168 .type = VID_TYPE_CAPTURE,
169 .hardware = VID_HARDWARE_PWC,
170 .release = video_device_release, 169 .release = video_device_release,
171 .fops = &pwc_fops, 170 .fops = &pwc_fops,
172 .minor = -1, 171 .minor = -1,
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 57f1f5d409e0..002e70a33a4f 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -71,7 +71,6 @@ static const struct v4l2_format v4l2_format_table[] =
71 71
72struct saa6752hs_state { 72struct saa6752hs_state {
73 struct i2c_client client; 73 struct i2c_client client;
74 struct v4l2_mpeg_compression old_params;
75 struct saa6752hs_mpeg_params params; 74 struct saa6752hs_mpeg_params params;
76 enum saa6752hs_videoformat video_format; 75 enum saa6752hs_videoformat video_format;
77 v4l2_std_id standard; 76 v4l2_std_id standard;
@@ -161,35 +160,6 @@ static struct saa6752hs_mpeg_params param_defaults =
161 .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, 160 .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K,
162}; 161};
163 162
164static struct v4l2_mpeg_compression old_param_defaults =
165{
166 .st_type = V4L2_MPEG_TS_2,
167 .st_bitrate = {
168 .mode = V4L2_BITRATE_CBR,
169 .target = 7000,
170 },
171
172 .ts_pid_pmt = 16,
173 .ts_pid_video = 260,
174 .ts_pid_audio = 256,
175 .ts_pid_pcr = 259,
176
177 .vi_type = V4L2_MPEG_VI_2,
178 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
179 .vi_bitrate = {
180 .mode = V4L2_BITRATE_VBR,
181 .target = 4000,
182 .max = 6000,
183 },
184
185 .au_type = V4L2_MPEG_AU_2_II,
186 .au_bitrate = {
187 .mode = V4L2_BITRATE_CBR,
188 .target = 256,
189 },
190
191};
192
193/* ---------------------------------------------------------------------- */ 163/* ---------------------------------------------------------------------- */
194 164
195static int saa6752hs_chip_command(struct i2c_client* client, 165static int saa6752hs_chip_command(struct i2c_client* client,
@@ -362,74 +332,6 @@ static void saa6752hs_set_subsampling(struct i2c_client* client,
362} 332}
363 333
364 334
365static void saa6752hs_old_set_params(struct i2c_client* client,
366 struct v4l2_mpeg_compression* params)
367{
368 struct saa6752hs_state *h = i2c_get_clientdata(client);
369
370 /* check PIDs */
371 if (params->ts_pid_pmt <= MPEG_PID_MAX) {
372 h->old_params.ts_pid_pmt = params->ts_pid_pmt;
373 h->params.ts_pid_pmt = params->ts_pid_pmt;
374 }
375 if (params->ts_pid_pcr <= MPEG_PID_MAX) {
376 h->old_params.ts_pid_pcr = params->ts_pid_pcr;
377 h->params.ts_pid_pcr = params->ts_pid_pcr;
378 }
379 if (params->ts_pid_video <= MPEG_PID_MAX) {
380 h->old_params.ts_pid_video = params->ts_pid_video;
381 h->params.ts_pid_video = params->ts_pid_video;
382 }
383 if (params->ts_pid_audio <= MPEG_PID_MAX) {
384 h->old_params.ts_pid_audio = params->ts_pid_audio;
385 h->params.ts_pid_audio = params->ts_pid_audio;
386 }
387
388 /* check bitrate parameters */
389 if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
390 (params->vi_bitrate.mode == V4L2_BITRATE_VBR)) {
391 h->old_params.vi_bitrate.mode = params->vi_bitrate.mode;
392 h->params.vi_bitrate_mode = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ?
393 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR : V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
394 }
395 if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
396 h->old_params.st_bitrate.target = params->st_bitrate.target;
397 if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
398 h->old_params.vi_bitrate.target = params->vi_bitrate.target;
399 if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
400 h->old_params.vi_bitrate.max = params->vi_bitrate.max;
401 if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
402 h->old_params.au_bitrate.target = params->au_bitrate.target;
403
404 /* aspect ratio */
405 if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 ||
406 params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9) {
407 h->old_params.vi_aspect_ratio = params->vi_aspect_ratio;
408 if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3)
409 h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3;
410 else
411 h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_16x9;
412 }
413
414 /* range checks */
415 if (h->old_params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
416 h->old_params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
417 if (h->old_params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
418 h->old_params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
419 if (h->old_params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
420 h->old_params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
421 h->params.vi_bitrate = params->vi_bitrate.target;
422 h->params.vi_bitrate_peak = params->vi_bitrate.max;
423 if (h->old_params.au_bitrate.target <= 256) {
424 h->old_params.au_bitrate.target = 256;
425 h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K;
426 }
427 else {
428 h->old_params.au_bitrate.target = 384;
429 h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_384K;
430 }
431}
432
433static int handle_ctrl(struct saa6752hs_mpeg_params *params, 335static int handle_ctrl(struct saa6752hs_mpeg_params *params,
434 struct v4l2_ext_control *ctrl, unsigned int cmd) 336 struct v4l2_ext_control *ctrl, unsigned int cmd)
435{ 337{
@@ -697,7 +599,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
697 return -ENOMEM; 599 return -ENOMEM;
698 h->client = client_template; 600 h->client = client_template;
699 h->params = param_defaults; 601 h->params = param_defaults;
700 h->old_params = old_param_defaults;
701 h->client.adapter = adap; 602 h->client.adapter = adap;
702 h->client.addr = addr; 603 h->client.addr = addr;
703 604
@@ -734,23 +635,11 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
734{ 635{
735 struct saa6752hs_state *h = i2c_get_clientdata(client); 636 struct saa6752hs_state *h = i2c_get_clientdata(client);
736 struct v4l2_ext_controls *ctrls = arg; 637 struct v4l2_ext_controls *ctrls = arg;
737 struct v4l2_mpeg_compression *old_params = arg;
738 struct saa6752hs_mpeg_params params; 638 struct saa6752hs_mpeg_params params;
739 int err = 0; 639 int err = 0;
740 int i; 640 int i;
741 641
742 switch (cmd) { 642 switch (cmd) {
743 case VIDIOC_S_MPEGCOMP:
744 if (NULL == old_params) {
745 /* apply settings and start encoder */
746 saa6752hs_init(client);
747 break;
748 }
749 saa6752hs_old_set_params(client, old_params);
750 /* fall through */
751 case VIDIOC_G_MPEGCOMP:
752 *old_params = h->old_params;
753 break;
754 case VIDIOC_S_EXT_CTRLS: 643 case VIDIOC_S_EXT_CTRLS:
755 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) 644 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
756 return -EINVAL; 645 return -EINVAL;
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 1a4a24471f20..a499eea379e6 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -429,7 +429,7 @@ int saa7134_set_dmabits(struct saa7134_dev *dev)
429 429
430 assert_spin_locked(&dev->slock); 430 assert_spin_locked(&dev->slock);
431 431
432 if (dev->inresume) 432 if (dev->insuspend)
433 return 0; 433 return 0;
434 434
435 /* video capture -- dma 0 + video task A */ 435 /* video capture -- dma 0 + video task A */
@@ -563,6 +563,9 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id)
563 unsigned long report,status; 563 unsigned long report,status;
564 int loop, handled = 0; 564 int loop, handled = 0;
565 565
566 if (dev->insuspend)
567 goto out;
568
566 for (loop = 0; loop < 10; loop++) { 569 for (loop = 0; loop < 10; loop++) {
567 report = saa_readl(SAA7134_IRQ_REPORT); 570 report = saa_readl(SAA7134_IRQ_REPORT);
568 status = saa_readl(SAA7134_IRQ_STATUS); 571 status = saa_readl(SAA7134_IRQ_STATUS);
@@ -1163,6 +1166,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1163 kfree(dev); 1166 kfree(dev);
1164} 1167}
1165 1168
1169#ifdef CONFIG_PM
1166static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) 1170static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
1167{ 1171{
1168 1172
@@ -1176,6 +1180,19 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
1176 saa_writel(SAA7134_IRQ2, 0); 1180 saa_writel(SAA7134_IRQ2, 0);
1177 saa_writel(SAA7134_MAIN_CTRL, 0); 1181 saa_writel(SAA7134_MAIN_CTRL, 0);
1178 1182
1183 synchronize_irq(pci_dev->irq);
1184 dev->insuspend = 1;
1185
1186 /* Disable timeout timers - if we have active buffers, we will
1187 fill them on resume*/
1188
1189 del_timer(&dev->video_q.timeout);
1190 del_timer(&dev->vbi_q.timeout);
1191 del_timer(&dev->ts_q.timeout);
1192
1193 if (dev->remote)
1194 saa7134_ir_stop(dev);
1195
1179 pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); 1196 pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
1180 pci_save_state(pci_dev); 1197 pci_save_state(pci_dev);
1181 1198
@@ -1194,24 +1211,27 @@ static int saa7134_resume(struct pci_dev *pci_dev)
1194 /* Do things that are done in saa7134_initdev , 1211 /* Do things that are done in saa7134_initdev ,
1195 except of initializing memory structures.*/ 1212 except of initializing memory structures.*/
1196 1213
1197 dev->inresume = 1;
1198 saa7134_board_init1(dev); 1214 saa7134_board_init1(dev);
1199 1215
1216 /* saa7134_hwinit1 */
1200 if (saa7134_boards[dev->board].video_out) 1217 if (saa7134_boards[dev->board].video_out)
1201 saa7134_videoport_init(dev); 1218 saa7134_videoport_init(dev);
1202
1203 if (card_has_mpeg(dev)) 1219 if (card_has_mpeg(dev))
1204 saa7134_ts_init_hw(dev); 1220 saa7134_ts_init_hw(dev);
1205 1221 if (dev->remote)
1222 saa7134_ir_start(dev, dev->remote);
1206 saa7134_hw_enable1(dev); 1223 saa7134_hw_enable1(dev);
1207 saa7134_set_decoder(dev); 1224
1208 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); 1225
1209 saa7134_board_init2(dev); 1226 saa7134_board_init2(dev);
1210 saa7134_hw_enable2(dev);
1211 1227
1228 /*saa7134_hwinit2*/
1229 saa7134_set_tvnorm_hw(dev);
1212 saa7134_tvaudio_setmute(dev); 1230 saa7134_tvaudio_setmute(dev);
1213 saa7134_tvaudio_setvolume(dev, dev->ctl_volume); 1231 saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
1232 saa7134_tvaudio_do_scan(dev);
1214 saa7134_enable_i2s(dev); 1233 saa7134_enable_i2s(dev);
1234 saa7134_hw_enable2(dev);
1215 1235
1216 /*resume unfinished buffer(s)*/ 1236 /*resume unfinished buffer(s)*/
1217 spin_lock_irqsave(&dev->slock, flags); 1237 spin_lock_irqsave(&dev->slock, flags);
@@ -1219,13 +1239,19 @@ static int saa7134_resume(struct pci_dev *pci_dev)
1219 saa7134_buffer_requeue(dev, &dev->vbi_q); 1239 saa7134_buffer_requeue(dev, &dev->vbi_q);
1220 saa7134_buffer_requeue(dev, &dev->ts_q); 1240 saa7134_buffer_requeue(dev, &dev->ts_q);
1221 1241
1242 /* FIXME: Disable DMA audio sound - temporary till proper support
1243 is implemented*/
1244
1245 dev->dmasound.dma_running = 0;
1246
1222 /* start DMA now*/ 1247 /* start DMA now*/
1223 dev->inresume = 0; 1248 dev->insuspend = 0;
1224 saa7134_set_dmabits(dev); 1249 saa7134_set_dmabits(dev);
1225 spin_unlock_irqrestore(&dev->slock, flags); 1250 spin_unlock_irqrestore(&dev->slock, flags);
1226 1251
1227 return 0; 1252 return 0;
1228} 1253}
1254#endif
1229 1255
1230/* ----------------------------------------------------------- */ 1256/* ----------------------------------------------------------- */
1231 1257
@@ -1262,8 +1288,10 @@ static struct pci_driver saa7134_pci_driver = {
1262 .id_table = saa7134_pci_tbl, 1288 .id_table = saa7134_pci_tbl,
1263 .probe = saa7134_initdev, 1289 .probe = saa7134_initdev,
1264 .remove = __devexit_p(saa7134_finidev), 1290 .remove = __devexit_p(saa7134_finidev),
1291#ifdef CONFIG_PM
1265 .suspend = saa7134_suspend, 1292 .suspend = saa7134_suspend,
1266 .resume = saa7134_resume 1293 .resume = saa7134_resume
1294#endif
1267}; 1295};
1268 1296
1269static int saa7134_init(void) 1297static int saa7134_init(void)
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 34ca874dd7fe..75d0c5bf46d2 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -284,17 +284,6 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
284 case VIDIOC_S_CTRL: 284 case VIDIOC_S_CTRL:
285 return saa7134_common_ioctl(dev, cmd, arg); 285 return saa7134_common_ioctl(dev, cmd, arg);
286 286
287 case VIDIOC_S_MPEGCOMP:
288 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
289 "Replace with VIDIOC_S_EXT_CTRLS!");
290 saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg);
291 ts_init_encoder(dev);
292 return 0;
293 case VIDIOC_G_MPEGCOMP:
294 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
295 "Replace with VIDIOC_G_EXT_CTRLS!");
296 saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg);
297 return 0;
298 case VIDIOC_S_EXT_CTRLS: 287 case VIDIOC_S_EXT_CTRLS:
299 /* count == 0 is abused in saa6752hs.c, so that special 288 /* count == 0 is abused in saa6752hs.c, so that special
300 case is handled here explicitly. */ 289 case is handled here explicitly. */
@@ -342,7 +331,6 @@ static struct video_device saa7134_empress_template =
342 .name = "saa7134-empress", 331 .name = "saa7134-empress",
343 .type = 0 /* FIXME */, 332 .type = 0 /* FIXME */,
344 .type2 = 0 /* FIXME */, 333 .type2 = 0 /* FIXME */,
345 .hardware = 0,
346 .fops = &ts_fops, 334 .fops = &ts_fops,
347 .minor = -1, 335 .minor = -1,
348}; 336};
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 80d2644f765a..3abaa1b8ac9d 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -44,6 +44,14 @@ module_param(ir_rc5_remote_gap, int, 0644);
44static int ir_rc5_key_timeout = 115; 44static int ir_rc5_key_timeout = 115;
45module_param(ir_rc5_key_timeout, int, 0644); 45module_param(ir_rc5_key_timeout, int, 0644);
46 46
47static int repeat_delay = 500;
48module_param(repeat_delay, int, 0644);
49MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
50static int repeat_period = 33;
51module_param(repeat_period, int, 0644);
52MODULE_PARM_DESC(repeat_period, "repeat period between"
53 "keypresses when key is down");
54
47#define dprintk(fmt, arg...) if (ir_debug) \ 55#define dprintk(fmt, arg...) if (ir_debug) \
48 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) 56 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
49#define i2cdprintk(fmt, arg...) if (ir_debug) \ 57#define i2cdprintk(fmt, arg...) if (ir_debug) \
@@ -59,6 +67,13 @@ static int build_key(struct saa7134_dev *dev)
59 struct card_ir *ir = dev->remote; 67 struct card_ir *ir = dev->remote;
60 u32 gpio, data; 68 u32 gpio, data;
61 69
70 /* here comes the additional handshake steps for some cards */
71 switch (dev->board) {
72 case SAA7134_BOARD_GOTVIEW_7135:
73 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
74 saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
75 break;
76 }
62 /* rising SAA7134_GPIO_GPRESCAN reads the status */ 77 /* rising SAA7134_GPIO_GPRESCAN reads the status */
63 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); 78 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
64 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); 79 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
@@ -159,7 +174,7 @@ static void saa7134_input_timer(unsigned long data)
159 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); 174 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
160} 175}
161 176
162static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) 177void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
163{ 178{
164 if (ir->polling) { 179 if (ir->polling) {
165 setup_timer(&ir->timer, saa7134_input_timer, 180 setup_timer(&ir->timer, saa7134_input_timer,
@@ -182,7 +197,7 @@ static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
182 } 197 }
183} 198}
184 199
185static void saa7134_ir_stop(struct saa7134_dev *dev) 200void saa7134_ir_stop(struct saa7134_dev *dev)
186{ 201{
187 if (dev->remote->polling) 202 if (dev->remote->polling)
188 del_timer_sync(&dev->remote->timer); 203 del_timer_sync(&dev->remote->timer);
@@ -285,10 +300,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
285 break; 300 break;
286 case SAA7134_BOARD_GOTVIEW_7135: 301 case SAA7134_BOARD_GOTVIEW_7135:
287 ir_codes = ir_codes_gotview7135; 302 ir_codes = ir_codes_gotview7135;
288 mask_keycode = 0x0003EC; 303 mask_keycode = 0x0003CC;
289 mask_keyup = 0x008000;
290 mask_keydown = 0x000010; 304 mask_keydown = 0x000010;
291 polling = 50; // ms 305 polling = 5; /* ms */
306 saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
292 break; 307 break;
293 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 308 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
294 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 309 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
@@ -386,6 +401,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
386 if (err) 401 if (err)
387 goto err_out_stop; 402 goto err_out_stop;
388 403
404 /* the remote isn't as bouncy as a keyboard */
405 ir->dev->rep[REP_DELAY] = repeat_delay;
406 ir->dev->rep[REP_PERIOD] = repeat_period;
407
389 return 0; 408 return 0;
390 409
391 err_out_stop: 410 err_out_stop:
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 1b9e39a5ea47..f8e304c76232 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -27,6 +27,7 @@
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/freezer.h>
30#include <asm/div64.h> 31#include <asm/div64.h>
31 32
32#include "saa7134-reg.h" 33#include "saa7134-reg.h"
@@ -231,7 +232,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
231 } 232 }
232 233
233 if (dev->hw_mute == mute && 234 if (dev->hw_mute == mute &&
234 dev->hw_input == in && !dev->inresume) { 235 dev->hw_input == in && !dev->insuspend) {
235 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", 236 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
236 mute,in->name); 237 mute,in->name);
237 return; 238 return;
@@ -502,13 +503,17 @@ static int tvaudio_thread(void *data)
502 unsigned int i, audio, nscan; 503 unsigned int i, audio, nscan;
503 int max1,max2,carrier,rx,mode,lastmode,default_carrier; 504 int max1,max2,carrier,rx,mode,lastmode,default_carrier;
504 505
505 allow_signal(SIGTERM); 506
507 set_freezable();
508
506 for (;;) { 509 for (;;) {
507 tvaudio_sleep(dev,-1); 510 tvaudio_sleep(dev,-1);
508 if (kthread_should_stop() || signal_pending(current)) 511 if (kthread_should_stop())
509 goto done; 512 goto done;
510 513
511 restart: 514 restart:
515 try_to_freeze();
516
512 dev->thread.scan1 = dev->thread.scan2; 517 dev->thread.scan1 = dev->thread.scan2;
513 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); 518 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
514 dev->tvaudio = NULL; 519 dev->tvaudio = NULL;
@@ -612,9 +617,12 @@ static int tvaudio_thread(void *data)
612 617
613 lastmode = 42; 618 lastmode = 42;
614 for (;;) { 619 for (;;) {
620
621 try_to_freeze();
622
615 if (tvaudio_sleep(dev,5000)) 623 if (tvaudio_sleep(dev,5000))
616 goto restart; 624 goto restart;
617 if (kthread_should_stop() || signal_pending(current)) 625 if (kthread_should_stop())
618 break; 626 break;
619 if (UNSET == dev->thread.mode) { 627 if (UNSET == dev->thread.mode) {
620 rx = tvaudio_getstereo(dev,&tvaudio[i]); 628 rx = tvaudio_getstereo(dev,&tvaudio[i]);
@@ -630,6 +638,7 @@ static int tvaudio_thread(void *data)
630 } 638 }
631 639
632 done: 640 done:
641 dev->thread.stopped = 1;
633 return 0; 642 return 0;
634} 643}
635 644
@@ -777,7 +786,8 @@ static int tvaudio_thread_ddep(void *data)
777 struct saa7134_dev *dev = data; 786 struct saa7134_dev *dev = data;
778 u32 value, norms, clock; 787 u32 value, norms, clock;
779 788
780 allow_signal(SIGTERM); 789
790 set_freezable();
781 791
782 clock = saa7134_boards[dev->board].audio_clock; 792 clock = saa7134_boards[dev->board].audio_clock;
783 if (UNSET != audio_clock_override) 793 if (UNSET != audio_clock_override)
@@ -790,10 +800,13 @@ static int tvaudio_thread_ddep(void *data)
790 800
791 for (;;) { 801 for (;;) {
792 tvaudio_sleep(dev,-1); 802 tvaudio_sleep(dev,-1);
793 if (kthread_should_stop() || signal_pending(current)) 803 if (kthread_should_stop())
794 goto done; 804 goto done;
795 805
796 restart: 806 restart:
807
808 try_to_freeze();
809
797 dev->thread.scan1 = dev->thread.scan2; 810 dev->thread.scan1 = dev->thread.scan2;
798 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); 811 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
799 812
@@ -870,6 +883,7 @@ static int tvaudio_thread_ddep(void *data)
870 } 883 }
871 884
872 done: 885 done:
886 dev->thread.stopped = 1;
873 return 0; 887 return 0;
874} 888}
875 889
@@ -997,7 +1011,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
997int saa7134_tvaudio_fini(struct saa7134_dev *dev) 1011int saa7134_tvaudio_fini(struct saa7134_dev *dev)
998{ 1012{
999 /* shutdown tvaudio thread */ 1013 /* shutdown tvaudio thread */
1000 if (dev->thread.thread) 1014 if (dev->thread.thread && !dev->thread.stopped)
1001 kthread_stop(dev->thread.thread); 1015 kthread_stop(dev->thread.thread);
1002 1016
1003 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ 1017 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */
@@ -1013,7 +1027,9 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev)
1013 } else if (dev->thread.thread) { 1027 } else if (dev->thread.thread) {
1014 dev->thread.mode = UNSET; 1028 dev->thread.mode = UNSET;
1015 dev->thread.scan2++; 1029 dev->thread.scan2++;
1016 wake_up_process(dev->thread.thread); 1030
1031 if (!dev->insuspend && !dev->thread.stopped)
1032 wake_up_process(dev->thread.thread);
1017 } else { 1033 } else {
1018 dev->automute = 0; 1034 dev->automute = 0;
1019 saa7134_tvaudio_setmute(dev); 1035 saa7134_tvaudio_setmute(dev);
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 471b92793c12..3b9ffb4b648a 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -560,15 +560,8 @@ void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
560 560
561 dev->crop_current = dev->crop_defrect; 561 dev->crop_current = dev->crop_defrect;
562 562
563 saa7134_set_decoder(dev); 563 saa7134_set_tvnorm_hw(dev);
564 564
565 if (card_in(dev, dev->ctl_input).tv) {
566 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
567 && ((card(dev).tuner_config == 1)
568 || (card(dev).tuner_config == 2)))
569 saa7134_set_gpio(dev, 22, 5);
570 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &norm->id);
571 }
572} 565}
573 566
574static void video_mux(struct saa7134_dev *dev, int input) 567static void video_mux(struct saa7134_dev *dev, int input)
@@ -579,7 +572,8 @@ static void video_mux(struct saa7134_dev *dev, int input)
579 saa7134_tvaudio_setinput(dev, &card_in(dev, input)); 572 saa7134_tvaudio_setinput(dev, &card_in(dev, input));
580} 573}
581 574
582void saa7134_set_decoder(struct saa7134_dev *dev) 575
576static void saa7134_set_decoder(struct saa7134_dev *dev)
583{ 577{
584 int luma_control, sync_control, mux; 578 int luma_control, sync_control, mux;
585 579
@@ -630,6 +624,19 @@ void saa7134_set_decoder(struct saa7134_dev *dev)
630 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); 624 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
631} 625}
632 626
627void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
628{
629 saa7134_set_decoder(dev);
630
631 if (card_in(dev, dev->ctl_input).tv) {
632 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
633 && ((card(dev).tuner_config == 1)
634 || (card(dev).tuner_config == 2)))
635 saa7134_set_gpio(dev, 22, 5);
636 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id);
637 }
638}
639
633static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) 640static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale)
634{ 641{
635 static const struct { 642 static const struct {
@@ -2352,7 +2359,6 @@ struct video_device saa7134_video_template =
2352 .name = "saa7134-video", 2359 .name = "saa7134-video",
2353 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| 2360 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|
2354 VID_TYPE_CLIPPING|VID_TYPE_SCALES, 2361 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
2355 .hardware = 0,
2356 .fops = &video_fops, 2362 .fops = &video_fops,
2357 .minor = -1, 2363 .minor = -1,
2358}; 2364};
@@ -2361,7 +2367,6 @@ struct video_device saa7134_vbi_template =
2361{ 2367{
2362 .name = "saa7134-vbi", 2368 .name = "saa7134-vbi",
2363 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, 2369 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT,
2364 .hardware = 0,
2365 .fops = &video_fops, 2370 .fops = &video_fops,
2366 .minor = -1, 2371 .minor = -1,
2367}; 2372};
@@ -2370,7 +2375,6 @@ struct video_device saa7134_radio_template =
2370{ 2375{
2371 .name = "saa7134-radio", 2376 .name = "saa7134-radio",
2372 .type = VID_TYPE_TUNER, 2377 .type = VID_TYPE_TUNER,
2373 .hardware = 0,
2374 .fops = &radio_fops, 2378 .fops = &radio_fops,
2375 .minor = -1, 2379 .minor = -1,
2376}; 2380};
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 28ec6804bd5d..66a390c321a7 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -333,6 +333,7 @@ struct saa7134_thread {
333 unsigned int scan1; 333 unsigned int scan1;
334 unsigned int scan2; 334 unsigned int scan2;
335 unsigned int mode; 335 unsigned int mode;
336 unsigned int stopped;
336}; 337};
337 338
338/* buffer for one video/vbi/ts frame */ 339/* buffer for one video/vbi/ts frame */
@@ -524,7 +525,7 @@ struct saa7134_dev {
524 unsigned int hw_mute; 525 unsigned int hw_mute;
525 int last_carrier; 526 int last_carrier;
526 int nosignal; 527 int nosignal;
527 unsigned int inresume; 528 unsigned int insuspend;
528 529
529 /* SAA7134_MPEG_* */ 530 /* SAA7134_MPEG_* */
530 struct saa7134_ts ts; 531 struct saa7134_ts ts;
@@ -632,7 +633,7 @@ extern struct video_device saa7134_radio_template;
632 633
633void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm); 634void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm);
634int saa7134_videoport_init(struct saa7134_dev *dev); 635int saa7134_videoport_init(struct saa7134_dev *dev);
635void saa7134_set_decoder(struct saa7134_dev *dev); 636void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
636 637
637int saa7134_common_ioctl(struct saa7134_dev *dev, 638int saa7134_common_ioctl(struct saa7134_dev *dev,
638 unsigned int cmd, void *arg); 639 unsigned int cmd, void *arg);
@@ -706,6 +707,8 @@ int saa7134_input_init1(struct saa7134_dev *dev);
706void saa7134_input_fini(struct saa7134_dev *dev); 707void saa7134_input_fini(struct saa7134_dev *dev);
707void saa7134_input_irq(struct saa7134_dev *dev); 708void saa7134_input_irq(struct saa7134_dev *dev);
708void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); 709void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir);
710void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir);
711void saa7134_ir_stop(struct saa7134_dev *dev);
709 712
710 713
711/* 714/*
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index 93fb04ed99a0..d5d7d6cf734a 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -1231,7 +1231,6 @@ static struct video_device se401_template = {
1231 .owner = THIS_MODULE, 1231 .owner = THIS_MODULE,
1232 .name = "se401 USB camera", 1232 .name = "se401 USB camera",
1233 .type = VID_TYPE_CAPTURE, 1233 .type = VID_TYPE_CAPTURE,
1234 .hardware = VID_HARDWARE_SE401,
1235 .fops = &se401_fops, 1234 .fops = &se401_fops,
1236}; 1235};
1237 1236
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 6991e06f7651..511847912c48 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -3319,7 +3319,6 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3319 strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); 3319 strcpy(cam->v4ldev->name, "SN9C1xx PC Camera");
3320 cam->v4ldev->owner = THIS_MODULE; 3320 cam->v4ldev->owner = THIS_MODULE;
3321 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; 3321 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
3322 cam->v4ldev->hardware = 0;
3323 cam->v4ldev->fops = &sn9c102_fops; 3322 cam->v4ldev->fops = &sn9c102_fops;
3324 cam->v4ldev->minor = video_nr[dev_nr]; 3323 cam->v4ldev->minor = video_nr[dev_nr];
3325 cam->v4ldev->release = video_device_release; 3324 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index eb220461ac77..3fb85af5d1f2 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1917,7 +1917,6 @@ static const struct file_operations saa_fops = {
1917static struct video_device saa_template = { 1917static struct video_device saa_template = {
1918 .name = "SAA7146A", 1918 .name = "SAA7146A",
1919 .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, 1919 .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY,
1920 .hardware = VID_HARDWARE_SAA7146,
1921 .fops = &saa_fops, 1920 .fops = &saa_fops,
1922 .minor = -1, 1921 .minor = -1,
1923}; 1922};
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 9e009a7ab863..afc32aa56fde 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1398,7 +1398,6 @@ static struct video_device stv680_template = {
1398 .owner = THIS_MODULE, 1398 .owner = THIS_MODULE,
1399 .name = "STV0680 USB camera", 1399 .name = "STV0680 USB camera",
1400 .type = VID_TYPE_CAPTURE, 1400 .type = VID_TYPE_CAPTURE,
1401 .hardware = VID_HARDWARE_SE401,
1402 .fops = &stv680_fops, 1401 .fops = &stv680_fops,
1403 .release = video_device_release, 1402 .release = video_device_release,
1404 .minor = -1, 1403 .minor = -1,
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 94843086cda9..6a777604f070 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -113,7 +113,7 @@ static void fe_standby(struct tuner *t)
113static int fe_has_signal(struct tuner *t) 113static int fe_has_signal(struct tuner *t)
114{ 114{
115 struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; 115 struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops;
116 u16 strength; 116 u16 strength = 0;
117 117
118 if (fe_tuner_ops->get_rf_strength) 118 if (fe_tuner_ops->get_rf_strength)
119 fe_tuner_ops->get_rf_strength(&t->fe, &strength); 119 fe_tuner_ops->get_rf_strength(&t->fe, &strength);
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 37ce36b9e587..fb434b5602a3 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -952,7 +952,6 @@ static const struct file_operations usbvideo_fops = {
952static const struct video_device usbvideo_template = { 952static const struct video_device usbvideo_template = {
953 .owner = THIS_MODULE, 953 .owner = THIS_MODULE,
954 .type = VID_TYPE_CAPTURE, 954 .type = VID_TYPE_CAPTURE,
955 .hardware = VID_HARDWARE_CPIA,
956 .fops = &usbvideo_fops, 955 .fops = &usbvideo_fops,
957}; 956};
958 957
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index db3c9e3deb26..da1ba0211108 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -1074,7 +1074,6 @@ static struct video_device vicam_template = {
1074 .owner = THIS_MODULE, 1074 .owner = THIS_MODULE,
1075 .name = "ViCam-based USB Camera", 1075 .name = "ViCam-based USB Camera",
1076 .type = VID_TYPE_CAPTURE, 1076 .type = VID_TYPE_CAPTURE,
1077 .hardware = VID_HARDWARE_VICAM,
1078 .fops = &vicam_fops, 1077 .fops = &vicam_fops,
1079 .minor = -1, 1078 .minor = -1,
1080}; 1079};
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index e2f3c01cfa13..36e689fa16c0 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1400,7 +1400,6 @@ static const struct file_operations usbvision_fops = {
1400static struct video_device usbvision_video_template = { 1400static struct video_device usbvision_video_template = {
1401 .owner = THIS_MODULE, 1401 .owner = THIS_MODULE,
1402 .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE, 1402 .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE,
1403 .hardware = VID_HARDWARE_USBVISION,
1404 .fops = &usbvision_fops, 1403 .fops = &usbvision_fops,
1405 .name = "usbvision-video", 1404 .name = "usbvision-video",
1406 .release = video_device_release, 1405 .release = video_device_release,
@@ -1455,7 +1454,6 @@ static struct video_device usbvision_radio_template=
1455{ 1454{
1456 .owner = THIS_MODULE, 1455 .owner = THIS_MODULE,
1457 .type = VID_TYPE_TUNER, 1456 .type = VID_TYPE_TUNER,
1458 .hardware = VID_HARDWARE_USBVISION,
1459 .fops = &usbvision_radio_fops, 1457 .fops = &usbvision_radio_fops,
1460 .name = "usbvision-radio", 1458 .name = "usbvision-radio",
1461 .release = video_device_release, 1459 .release = video_device_release,
@@ -1492,7 +1490,6 @@ static struct video_device usbvision_vbi_template=
1492{ 1490{
1493 .owner = THIS_MODULE, 1491 .owner = THIS_MODULE,
1494 .type = VID_TYPE_TUNER, 1492 .type = VID_TYPE_TUNER,
1495 .hardware = VID_HARDWARE_USBVISION,
1496 .fops = &usbvision_vbi_fops, 1493 .fops = &usbvision_vbi_fops,
1497 .release = video_device_release, 1494 .release = video_device_release,
1498 .name = "usbvision-vbi", 1495 .name = "usbvision-vbi",
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 321249240d05..1141b4bf41ce 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -317,8 +317,6 @@ static const char *v4l2_ioctls[] = {
317 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", 317 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
318 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", 318 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
319 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", 319 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
320 [_IOC_NR(VIDIOC_G_MPEGCOMP)] = "VIDIOC_G_MPEGCOMP",
321 [_IOC_NR(VIDIOC_S_MPEGCOMP)] = "VIDIOC_S_MPEGCOMP",
322 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", 320 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
323 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", 321 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
324 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", 322 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 5599a36490fc..89a44f16f0ba 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -967,6 +967,7 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
967 967
968 return 0; 968 return 0;
969} 969}
970EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
970#endif 971#endif
971 972
972/* --------------------------------------------------------------------- */ 973/* --------------------------------------------------------------------- */
@@ -985,7 +986,6 @@ EXPORT_SYMBOL_GPL(videobuf_reqbufs);
985EXPORT_SYMBOL_GPL(videobuf_querybuf); 986EXPORT_SYMBOL_GPL(videobuf_querybuf);
986EXPORT_SYMBOL_GPL(videobuf_qbuf); 987EXPORT_SYMBOL_GPL(videobuf_qbuf);
987EXPORT_SYMBOL_GPL(videobuf_dqbuf); 988EXPORT_SYMBOL_GPL(videobuf_dqbuf);
988EXPORT_SYMBOL_GPL(videobuf_cgmbuf);
989EXPORT_SYMBOL_GPL(videobuf_streamon); 989EXPORT_SYMBOL_GPL(videobuf_streamon);
990EXPORT_SYMBOL_GPL(videobuf_streamoff); 990EXPORT_SYMBOL_GPL(videobuf_streamoff);
991 991
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c
index f2bbd7a4d562..87951ec8254f 100644
--- a/drivers/media/video/videocodec.c
+++ b/drivers/media/video/videocodec.c
@@ -86,8 +86,8 @@ videocodec_attach (struct videocodec_master *master)
86 } 86 }
87 87
88 dprintk(2, 88 dprintk(2,
89 "videocodec_attach: '%s', type: %x, flags %lx, magic %lx\n", 89 "videocodec_attach: '%s', flags %lx, magic %lx\n",
90 master->name, master->type, master->flags, master->magic); 90 master->name, master->flags, master->magic);
91 91
92 if (!h) { 92 if (!h) {
93 dprintk(1, 93 dprintk(1,
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 8d8e517b344f..9611c3990285 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -1313,48 +1313,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1313 ret=vfd->vidioc_cropcap(file, fh, p); 1313 ret=vfd->vidioc_cropcap(file, fh, p);
1314 break; 1314 break;
1315 } 1315 }
1316 case VIDIOC_G_MPEGCOMP:
1317 {
1318 struct v4l2_mpeg_compression *p=arg;
1319
1320 /*FIXME: Several fields not shown */
1321 if (!vfd->vidioc_g_mpegcomp)
1322 break;
1323 ret=vfd->vidioc_g_mpegcomp(file, fh, p);
1324 if (!ret)
1325 dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d,"
1326 " ts_pid_video=%d, ts_pid_pcr=%d, "
1327 "ps_size=%d, au_sample_rate=%d, "
1328 "au_pesid=%c, vi_frame_rate=%d, "
1329 "vi_frames_per_gop=%d, "
1330 "vi_bframes_count=%d, vi_pesid=%c\n",
1331 p->ts_pid_pmt,p->ts_pid_audio,
1332 p->ts_pid_video,p->ts_pid_pcr,
1333 p->ps_size, p->au_sample_rate,
1334 p->au_pesid, p->vi_frame_rate,
1335 p->vi_frames_per_gop,
1336 p->vi_bframes_count, p->vi_pesid);
1337 break;
1338 }
1339 case VIDIOC_S_MPEGCOMP:
1340 {
1341 struct v4l2_mpeg_compression *p=arg;
1342 /*FIXME: Several fields not shown */
1343 if (!vfd->vidioc_s_mpegcomp)
1344 break;
1345 dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d, "
1346 "ts_pid_video=%d, ts_pid_pcr=%d, ps_size=%d, "
1347 "au_sample_rate=%d, au_pesid=%c, "
1348 "vi_frame_rate=%d, vi_frames_per_gop=%d, "
1349 "vi_bframes_count=%d, vi_pesid=%c\n",
1350 p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video,
1351 p->ts_pid_pcr, p->ps_size, p->au_sample_rate,
1352 p->au_pesid, p->vi_frame_rate,
1353 p->vi_frames_per_gop, p->vi_bframes_count,
1354 p->vi_pesid);
1355 ret=vfd->vidioc_s_mpegcomp(file, fh, p);
1356 break;
1357 }
1358 case VIDIOC_G_JPEGCOMP: 1316 case VIDIOC_G_JPEGCOMP:
1359 { 1317 {
1360 struct v4l2_jpegcompression *p=arg; 1318 struct v4l2_jpegcompression *p=arg;
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index b532aa280a1b..ee73dc75131c 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -1119,7 +1119,6 @@ static const struct file_operations vivi_fops = {
1119static struct video_device vivi = { 1119static struct video_device vivi = {
1120 .name = "vivi", 1120 .name = "vivi",
1121 .type = VID_TYPE_CAPTURE, 1121 .type = VID_TYPE_CAPTURE,
1122 .hardware = 0,
1123 .fops = &vivi_fops, 1122 .fops = &vivi_fops,
1124 .minor = -1, 1123 .minor = -1,
1125// .release = video_device_release, 1124// .release = video_device_release,
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 47366408637c..08aaae07c7e0 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -196,7 +196,6 @@ static struct video_device w9966_template = {
196 .owner = THIS_MODULE, 196 .owner = THIS_MODULE,
197 .name = W9966_DRIVERNAME, 197 .name = W9966_DRIVERNAME,
198 .type = VID_TYPE_CAPTURE | VID_TYPE_SCALES, 198 .type = VID_TYPE_CAPTURE | VID_TYPE_SCALES,
199 .hardware = VID_HARDWARE_W9966,
200 .fops = &w9966_fops, 199 .fops = &w9966_fops,
201}; 200};
202 201
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 9e7f3e685d73..2ae1430f5f7d 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -3549,7 +3549,6 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3549 strcpy(cam->v4ldev->name, symbolic(camlist, mod_id)); 3549 strcpy(cam->v4ldev->name, symbolic(camlist, mod_id));
3550 cam->v4ldev->owner = THIS_MODULE; 3550 cam->v4ldev->owner = THIS_MODULE;
3551 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; 3551 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
3552 cam->v4ldev->hardware = VID_HARDWARE_W9968CF;
3553 cam->v4ldev->fops = &w9968cf_fops; 3552 cam->v4ldev->fops = &w9968cf_fops;
3554 cam->v4ldev->minor = video_nr[dev_nr]; 3553 cam->v4ldev->minor = video_nr[dev_nr];
3555 cam->v4ldev->release = video_device_release; 3554 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 08a93c31c0a0..2c5665c82442 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -1985,7 +1985,6 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
1985 strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera"); 1985 strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera");
1986 cam->v4ldev->owner = THIS_MODULE; 1986 cam->v4ldev->owner = THIS_MODULE;
1987 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; 1987 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
1988 cam->v4ldev->hardware = 0;
1989 cam->v4ldev->fops = &zc0301_fops; 1988 cam->v4ldev->fops = &zc0301_fops;
1990 cam->v4ldev->minor = video_nr[dev_nr]; 1989 cam->v4ldev->minor = video_nr[dev_nr];
1991 cam->v4ldev->release = video_device_release; 1990 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 48da36a15fca..6e0ac4c5c379 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -1235,8 +1235,14 @@ zoran_setup_videocodec (struct zoran *zr,
1235 return m; 1235 return m;
1236 } 1236 }
1237 1237
1238 m->magic = 0L; /* magic not used */ 1238 /* magic and type are unused for master struct. Makes sense only at
1239 m->type = VID_HARDWARE_ZR36067; 1239 codec structs.
1240 In the past, .type were initialized to the old V4L1 .hardware
1241 value, as VID_HARDWARE_ZR36067
1242 */
1243 m->magic = 0L;
1244 m->type = 0;
1245
1240 m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; 1246 m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER;
1241 strncpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); 1247 strncpy(m->name, ZR_DEVNAME(zr), sizeof(m->name));
1242 m->data = zr; 1248 m->data = zr;
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 419e5af78533..dd3d7d2c8b0e 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -60,7 +60,6 @@
60 60
61#include <linux/spinlock.h> 61#include <linux/spinlock.h>
62#define MAP_NR(x) virt_to_page(x) 62#define MAP_NR(x) virt_to_page(x)
63#define ZORAN_HARDWARE VID_HARDWARE_ZR36067
64#define ZORAN_VID_TYPE ( \ 63#define ZORAN_VID_TYPE ( \
65 VID_TYPE_CAPTURE | \ 64 VID_TYPE_CAPTURE | \
66 VID_TYPE_OVERLAY | \ 65 VID_TYPE_OVERLAY | \
@@ -4659,7 +4658,6 @@ struct video_device zoran_template __devinitdata = {
4659#ifdef CONFIG_VIDEO_V4L2 4658#ifdef CONFIG_VIDEO_V4L2
4660 .type2 = ZORAN_V4L2_VID_FLAGS, 4659 .type2 = ZORAN_V4L2_VID_FLAGS,
4661#endif 4660#endif
4662 .hardware = ZORAN_HARDWARE,
4663 .fops = &zoran_fops, 4661 .fops = &zoran_fops,
4664 .release = &zoran_vdev_release, 4662 .release = &zoran_vdev_release,
4665 .minor = -1 4663 .minor = -1