aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/Kconfig12
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/au0828/Kconfig3
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c12
-rw-r--r--drivers/media/video/bt8xx/Kconfig3
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c5
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c8
-rw-r--r--drivers/media/video/btcx-risc.c2
-rw-r--r--drivers/media/video/btcx-risc.h4
-rw-r--r--drivers/media/video/cs5345.c7
-rw-r--r--drivers/media/video/cs53l32a.c10
-rw-r--r--drivers/media/video/cx18/Kconfig5
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c81
-rw-r--r--drivers/media/video/cx18/cx18-cards.c27
-rw-r--r--drivers/media/video/cx18/cx18-cards.h5
-rw-r--r--drivers/media/video/cx18/cx18-controls.c6
-rw-r--r--drivers/media/video/cx18/cx18-driver.c55
-rw-r--r--drivers/media/video/cx18/cx18-driver.h12
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c40
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c19
-rw-r--r--drivers/media/video/cx18/cx18-fileops.h9
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c48
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c10
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c12
-rw-r--r--drivers/media/video/cx18/cx18-irq.c12
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.c8
-rw-r--r--drivers/media/video/cx18/cx18-queue.c22
-rw-r--r--drivers/media/video/cx18/cx18-queue.h4
-rw-r--r--drivers/media/video/cx18/cx18-streams.c50
-rw-r--r--drivers/media/video/cx18/cx18-streams.h2
-rw-r--r--drivers/media/video/cx23885/Kconfig6
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c36
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c8
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c7
-rw-r--r--drivers/media/video/cx25840/Kconfig1
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c7
-rw-r--r--drivers/media/video/cx88/Kconfig6
-rw-r--r--drivers/media/video/cx88/cx88-cards.c13
-rw-r--r--drivers/media/video/cx88/cx88-core.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c253
-rw-r--r--drivers/media/video/em28xx/Kconfig3
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c8
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c2
-rw-r--r--drivers/media/video/ivtv/Kconfig4
-rw-r--r--drivers/media/video/ivtv/ivtv-controls.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h10
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.h6
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c14
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c43
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-version.h4
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.h2
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c6
-rw-r--r--drivers/media/video/m52790.c9
-rw-r--r--drivers/media/video/msp3400-driver.c17
-rw-r--r--drivers/media/video/mt9m001.c5
-rw-r--r--drivers/media/video/mt9v022.c7
-rw-r--r--drivers/media/video/pvrusb2/Kconfig4
-rw-r--r--drivers/media/video/saa7115.c40
-rw-r--r--drivers/media/video/saa7127.c9
-rw-r--r--drivers/media/video/saa7134/Kconfig3
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c140
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c3
-rw-r--r--drivers/media/video/saa717x.c9
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c2
-rw-r--r--drivers/media/video/stk-webcam.c7
-rw-r--r--drivers/media/video/tuner-core.c103
-rw-r--r--drivers/media/video/tveeprom.c10
-rw-r--r--drivers/media/video/upd64031a.c6
-rw-r--r--drivers/media/video/upd64083.c6
-rw-r--r--drivers/media/video/usbvideo/quickcam_messenger.c2
-rw-r--r--drivers/media/video/usbvision/Kconfig2
-rw-r--r--drivers/media/video/videobuf-core.c3
-rw-r--r--drivers/media/video/vp27smpx.c9
-rw-r--r--drivers/media/video/wm8739.c7
-rw-r--r--drivers/media/video/wm8775.c7
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c2
-rw-r--r--drivers/media/video/zoran.h4
-rw-r--r--drivers/media/video/zoran_device.c4
-rw-r--r--drivers/media/video/zoran_driver.c12
91 files changed, 860 insertions, 593 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fe743aa7f645..3b26fbd3e558 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -44,6 +44,10 @@ config VIDEO_TVEEPROM
44 tristate 44 tristate
45 depends on I2C 45 depends on I2C
46 46
47config VIDEO_TUNER
48 tristate
49 depends on MEDIA_TUNER
50
47# 51#
48# Multimedia Video device configuration 52# Multimedia Video device configuration
49# 53#
@@ -690,7 +694,7 @@ config VIDEO_MXB
690 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" 694 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
691 depends on PCI && VIDEO_V4L1 && I2C 695 depends on PCI && VIDEO_V4L1 && I2C
692 select VIDEO_SAA7146_VV 696 select VIDEO_SAA7146_VV
693 select MEDIA_TUNER 697 select VIDEO_TUNER
694 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO 698 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
695 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO 699 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
696 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO 700 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
@@ -897,7 +901,7 @@ endif # V4L_USB_DRIVERS
897 901
898config SOC_CAMERA 902config SOC_CAMERA
899 tristate "SoC camera support" 903 tristate "SoC camera support"
900 depends on VIDEO_V4L2 904 depends on VIDEO_V4L2 && HAS_DMA
901 select VIDEOBUF_DMA_SG 905 select VIDEOBUF_DMA_SG
902 help 906 help
903 SoC Camera is a common API to several cameras, not connecting 907 SoC Camera is a common API to several cameras, not connecting
@@ -906,7 +910,7 @@ config SOC_CAMERA
906 910
907config SOC_CAMERA_MT9M001 911config SOC_CAMERA_MT9M001
908 tristate "mt9m001 support" 912 tristate "mt9m001 support"
909 depends on SOC_CAMERA 913 depends on SOC_CAMERA && I2C
910 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH 914 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH
911 help 915 help
912 This driver supports MT9M001 cameras from Micron, monochrome 916 This driver supports MT9M001 cameras from Micron, monochrome
@@ -921,7 +925,7 @@ config MT9M001_PCA9536_SWITCH
921 925
922config SOC_CAMERA_MT9V022 926config SOC_CAMERA_MT9V022
923 tristate "mt9v022 support" 927 tristate "mt9v022 support"
924 depends on SOC_CAMERA 928 depends on SOC_CAMERA && I2C
925 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH 929 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH
926 help 930 help
927 This driver supports MT9V022 cameras from Micron 931 This driver supports MT9V022 cameras from Micron
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index a352c6e31f0c..dff0d6abe917 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -84,7 +84,7 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o 84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o
85obj-$(CONFIG_TUNER_3036) += tuner-3036.o 85obj-$(CONFIG_TUNER_3036) += tuner-3036.o
86 86
87obj-$(CONFIG_MEDIA_TUNER) += tuner.o 87obj-$(CONFIG_VIDEO_TUNER) += tuner.o
88 88
89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o 89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o 90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig
index cab277fafa63..52b2491581a8 100644
--- a/drivers/media/video/au0828/Kconfig
+++ b/drivers/media/video/au0828/Kconfig
@@ -1,8 +1,9 @@
1 1
2config VIDEO_AU0828 2config VIDEO_AU0828
3 tristate "Auvitek AU0828 support" 3 tristate "Auvitek AU0828 support"
4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE 4 depends on I2C && INPUT && DVB_CORE && USB
5 select I2C_ALGOBIT 5 select I2C_ALGOBIT
6 select VIDEO_TVEEPROM
6 select DVB_AU8522 if !DVB_FE_CUSTOMIZE 7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE
7 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE 8 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
8 ---help--- 9 ---help---
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index 1371b4e4b5f1..c6d470590380 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -337,12 +337,10 @@ int au0828_dvb_register(struct au0828_dev *dev)
337 dvb->frontend = dvb_attach(au8522_attach, 337 dvb->frontend = dvb_attach(au8522_attach,
338 &hauppauge_hvr950q_config, 338 &hauppauge_hvr950q_config,
339 &dev->i2c_adap); 339 &dev->i2c_adap);
340 if (dvb->frontend != NULL) { 340 if (dvb->frontend != NULL)
341 hauppauge_hvr950q_tunerconfig.priv = dev;
342 dvb_attach(xc5000_attach, dvb->frontend, 341 dvb_attach(xc5000_attach, dvb->frontend,
343 &dev->i2c_adap, 342 &dev->i2c_adap,
344 &hauppauge_hvr950q_tunerconfig); 343 &hauppauge_hvr950q_tunerconfig, dev);
345 }
346 break; 344 break;
347 default: 345 default:
348 printk(KERN_WARNING "The frontend of your DVB/ATSC card " 346 printk(KERN_WARNING "The frontend of your DVB/ATSC card "
@@ -355,12 +353,6 @@ int au0828_dvb_register(struct au0828_dev *dev)
355 return -1; 353 return -1;
356 } 354 }
357 355
358 /* Put the analog decoder in standby to keep it quiet */
359 au0828_call_i2c_clients(dev, TUNER_SET_STANDBY, NULL);
360
361 if (dvb->frontend->ops.analog_ops.standby)
362 dvb->frontend->ops.analog_ops.standby(dvb->frontend);
363
364 /* register everything */ 356 /* register everything */
365 ret = dvb_register(dev); 357 ret = dvb_register(dev);
366 if (ret < 0) { 358 if (ret < 0) {
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 7431ef6de9f1..24a34fc1f2b3 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,12 +1,13 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 8 select VIDEOBUF_DMA_SG
8 select VIDEO_IR 9 select VIDEO_IR
9 select MEDIA_TUNER 10 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 11 select VIDEO_TVEEPROM
11 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO 12 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO
12 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO 13 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index f20a01cfc73e..8ef0424c26c4 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -34,6 +34,7 @@
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <net/checksum.h> 35#include <net/checksum.h>
36 36
37#include <asm/unaligned.h>
37#include <asm/io.h> 38#include <asm/io.h>
38 39
39#include "bttvp.h" 40#include "bttvp.h"
@@ -3858,7 +3859,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
3858 ee += i; 3859 ee += i;
3859 3860
3860 /* found a valid descriptor */ 3861 /* found a valid descriptor */
3861 type = be16_to_cpup((u16*)(ee+4)); 3862 type = get_unaligned_be16((__be16 *)(ee+4));
3862 3863
3863 switch(type) { 3864 switch(type) {
3864 /* 848 based */ 3865 /* 848 based */
@@ -3918,7 +3919,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
3918 btv->c.nr, type); 3919 btv->c.nr, type);
3919 break; 3920 break;
3920 } 3921 }
3921 serial = be32_to_cpup((u32*)(ee+6)); 3922 serial = get_unaligned_be32((__be32 *)(ee+6));
3922 } 3923 }
3923 3924
3924 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n", 3925 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n",
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 2ca3e9cfb2bb..0165aac533bf 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2613,7 +2613,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2613 struct bttv_fh *fh = priv; 2613 struct bttv_fh *fh = priv;
2614 2614
2615 mutex_lock(&fh->cap.vb_lock); 2615 mutex_lock(&fh->cap.vb_lock);
2616 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2616 retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
2617 V4L2_MEMORY_MMAP); 2617 V4L2_MEMORY_MMAP);
2618 if (retval < 0) { 2618 if (retval < 0) {
2619 mutex_unlock(&fh->cap.vb_lock); 2619 mutex_unlock(&fh->cap.vb_lock);
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index e5979f77504c..0af586876e72 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -48,7 +48,7 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
48{ 48{
49 u32 instructions,line,todo; 49 u32 instructions,line,todo;
50 struct scatterlist *sg; 50 struct scatterlist *sg;
51 u32 *rp; 51 __le32 *rp;
52 int rc; 52 int rc;
53 53
54 /* estimate risc mem: worst case is one write per page border + 54 /* estimate risc mem: worst case is one write per page border +
@@ -128,7 +128,8 @@ bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc,
128 unsigned int cpadding) 128 unsigned int cpadding)
129{ 129{
130 unsigned int instructions,line,todo,ylen,chroma; 130 unsigned int instructions,line,todo,ylen,chroma;
131 u32 *rp,ri; 131 __le32 *rp;
132 u32 ri;
132 struct scatterlist *ysg; 133 struct scatterlist *ysg;
133 struct scatterlist *usg; 134 struct scatterlist *usg;
134 struct scatterlist *vsg; 135 struct scatterlist *vsg;
@@ -244,7 +245,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
244{ 245{
245 int dwords,rc,line,maxy,start,end,skip,nskips; 246 int dwords,rc,line,maxy,start,end,skip,nskips;
246 struct btcx_skiplist *skips; 247 struct btcx_skiplist *skips;
247 u32 *rp,ri,ra; 248 __le32 *rp;
249 u32 ri,ra;
248 u32 addr; 250 u32 addr;
249 251
250 /* skip list for window clipping */ 252 /* skip list for window clipping */
diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c
index ce0840ccd594..f42701f82e7f 100644
--- a/drivers/media/video/btcx-risc.c
+++ b/drivers/media/video/btcx-risc.c
@@ -63,7 +63,7 @@ int btcx_riscmem_alloc(struct pci_dev *pci,
63 struct btcx_riscmem *risc, 63 struct btcx_riscmem *risc,
64 unsigned int size) 64 unsigned int size)
65{ 65{
66 u32 *cpu; 66 __le32 *cpu;
67 dma_addr_t dma; 67 dma_addr_t dma;
68 68
69 if (NULL != risc->cpu && risc->size < size) 69 if (NULL != risc->cpu && risc->size < size)
diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h
index 503e6c6d7b69..861bc8112824 100644
--- a/drivers/media/video/btcx-risc.h
+++ b/drivers/media/video/btcx-risc.h
@@ -2,8 +2,8 @@
2 */ 2 */
3struct btcx_riscmem { 3struct btcx_riscmem {
4 unsigned int size; 4 unsigned int size;
5 u32 *cpu; 5 __le32 *cpu;
6 u32 *jmp; 6 __le32 *jmp;
7 dma_addr_t dma; 7 dma_addr_t dma;
8}; 8};
9 9
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 2a429f9e32cd..03411503457e 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -160,10 +160,17 @@ static int cs5345_probe(struct i2c_client *client,
160 160
161/* ----------------------------------------------------------------------- */ 161/* ----------------------------------------------------------------------- */
162 162
163static const struct i2c_device_id cs5345_id[] = {
164 { "cs5345", 0 },
165 { }
166};
167MODULE_DEVICE_TABLE(i2c, cs5345_id);
168
163static struct v4l2_i2c_driver_data v4l2_i2c_data = { 169static struct v4l2_i2c_driver_data v4l2_i2c_data = {
164 .name = "cs5345", 170 .name = "cs5345",
165 .driverid = I2C_DRIVERID_CS5345, 171 .driverid = I2C_DRIVERID_CS5345,
166 .command = cs5345_command, 172 .command = cs5345_command,
167 .probe = cs5345_probe, 173 .probe = cs5345_probe,
174 .id_table = cs5345_id,
168}; 175};
169 176
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 2dfd0afc62db..d965af860ab2 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -144,7 +144,8 @@ static int cs53l32a_probe(struct i2c_client *client,
144 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 144 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
145 return -EIO; 145 return -EIO;
146 146
147 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); 147 if (!id)
148 strlcpy(client->name, "cs53l32a", sizeof(client->name));
148 149
149 v4l_info(client, "chip found @ 0x%x (%s)\n", 150 v4l_info(client, "chip found @ 0x%x (%s)\n",
150 client->addr << 1, client->adapter->name); 151 client->addr << 1, client->adapter->name);
@@ -175,10 +176,17 @@ static int cs53l32a_probe(struct i2c_client *client,
175 return 0; 176 return 0;
176} 177}
177 178
179static const struct i2c_device_id cs53l32a_id[] = {
180 { "cs53l32a", 0 },
181 { }
182};
183MODULE_DEVICE_TABLE(i2c, cs53l32a_id);
184
178static struct v4l2_i2c_driver_data v4l2_i2c_data = { 185static struct v4l2_i2c_driver_data v4l2_i2c_data = {
179 .name = "cs53l32a", 186 .name = "cs53l32a",
180 .driverid = I2C_DRIVERID_CS53L32A, 187 .driverid = I2C_DRIVERID_CS53L32A,
181 .command = cs53l32a_command, 188 .command = cs53l32a_command,
182 .probe = cs53l32a_probe, 189 .probe = cs53l32a_probe,
190 .id_table = cs53l32a_id,
183}; 191};
184 192
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig
index acc4b47f1d1d..5f942690570c 100644
--- a/drivers/media/video/cx18/Kconfig
+++ b/drivers/media/video/cx18/Kconfig
@@ -1,14 +1,17 @@
1config VIDEO_CX18 1config VIDEO_CX18
2 tristate "Conexant cx23418 MPEG encoder support" 2 tristate "Conexant cx23418 MPEG encoder support"
3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CS5345 12 select VIDEO_CS5345
11 select DVB_S5H1409 13 select DVB_S5H1409
14 select MEDIA_TUNER_MXL5005S
12 ---help--- 15 ---help---
13 This is a video4linux driver for Conexant cx23418 based 16 This is a video4linux driver for Conexant cx23418 based
14 PCI combo video recorder devices. 17 PCI combo video recorder devices.
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index 66864904c99b..9a26751615c6 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -182,14 +182,16 @@ static void input_change(struct cx18 *cx)
182 if (std == V4L2_STD_NTSC_M_JP) { 182 if (std == V4L2_STD_NTSC_M_JP) {
183 /* Japan uses EIAJ audio standard */ 183 /* Japan uses EIAJ audio standard */
184 cx18_av_write(cx, 0x808, 0xf7); 184 cx18_av_write(cx, 0x808, 0xf7);
185 cx18_av_write(cx, 0x80b, 0x02);
185 } else if (std == V4L2_STD_NTSC_M_KR) { 186 } else if (std == V4L2_STD_NTSC_M_KR) {
186 /* South Korea uses A2 audio standard */ 187 /* South Korea uses A2 audio standard */
187 cx18_av_write(cx, 0x808, 0xf8); 188 cx18_av_write(cx, 0x808, 0xf8);
189 cx18_av_write(cx, 0x80b, 0x03);
188 } else { 190 } else {
189 /* Others use the BTSC audio standard */ 191 /* Others use the BTSC audio standard */
190 cx18_av_write(cx, 0x808, 0xf6); 192 cx18_av_write(cx, 0x808, 0xf6);
193 cx18_av_write(cx, 0x80b, 0x01);
191 } 194 }
192 cx18_av_write(cx, 0x80b, 0x00);
193 } else if (std & V4L2_STD_PAL) { 195 } else if (std & V4L2_STD_PAL) {
194 /* Follow tuner change procedure for PAL */ 196 /* Follow tuner change procedure for PAL */
195 cx18_av_write(cx, 0x808, 0xff); 197 cx18_av_write(cx, 0x808, 0xff);
@@ -741,8 +743,8 @@ static void log_audio_status(struct cx18 *cx)
741{ 743{
742 struct cx18_av_state *state = &cx->av_state; 744 struct cx18_av_state *state = &cx->av_state;
743 u8 download_ctl = cx18_av_read(cx, 0x803); 745 u8 download_ctl = cx18_av_read(cx, 0x803);
744 u8 mod_det_stat0 = cx18_av_read(cx, 0x805); 746 u8 mod_det_stat0 = cx18_av_read(cx, 0x804);
745 u8 mod_det_stat1 = cx18_av_read(cx, 0x804); 747 u8 mod_det_stat1 = cx18_av_read(cx, 0x805);
746 u8 audio_config = cx18_av_read(cx, 0x808); 748 u8 audio_config = cx18_av_read(cx, 0x808);
747 u8 pref_mode = cx18_av_read(cx, 0x809); 749 u8 pref_mode = cx18_av_read(cx, 0x809);
748 u8 afc0 = cx18_av_read(cx, 0x80b); 750 u8 afc0 = cx18_av_read(cx, 0x80b);
@@ -760,12 +762,12 @@ static void log_audio_status(struct cx18 *cx)
760 case 0x12: p = "dual with SAP"; break; 762 case 0x12: p = "dual with SAP"; break;
761 case 0x14: p = "tri with SAP"; break; 763 case 0x14: p = "tri with SAP"; break;
762 case 0xfe: p = "forced mode"; break; 764 case 0xfe: p = "forced mode"; break;
763 default: p = "not defined"; 765 default: p = "not defined"; break;
764 } 766 }
765 CX18_INFO("Detected audio mode: %s\n", p); 767 CX18_INFO("Detected audio mode: %s\n", p);
766 768
767 switch (mod_det_stat1) { 769 switch (mod_det_stat1) {
768 case 0x00: p = "BTSC"; break; 770 case 0x00: p = "not defined"; break;
769 case 0x01: p = "EIAJ"; break; 771 case 0x01: p = "EIAJ"; break;
770 case 0x02: p = "A2-M"; break; 772 case 0x02: p = "A2-M"; break;
771 case 0x03: p = "A2-BG"; break; 773 case 0x03: p = "A2-BG"; break;
@@ -779,8 +781,13 @@ static void log_audio_status(struct cx18 *cx)
779 case 0x0b: p = "NICAM-I"; break; 781 case 0x0b: p = "NICAM-I"; break;
780 case 0x0c: p = "NICAM-L"; break; 782 case 0x0c: p = "NICAM-L"; break;
781 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; 783 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
784 case 0x0e: p = "IF FM Radio"; break;
785 case 0x0f: p = "BTSC"; break;
786 case 0x10: p = "detected chrominance"; break;
787 case 0xfd: p = "unknown audio standard"; break;
788 case 0xfe: p = "forced audio standard"; break;
782 case 0xff: p = "no detected audio standard"; break; 789 case 0xff: p = "no detected audio standard"; break;
783 default: p = "not defined"; 790 default: p = "not defined"; break;
784 } 791 }
785 CX18_INFO("Detected audio standard: %s\n", p); 792 CX18_INFO("Detected audio standard: %s\n", p);
786 CX18_INFO("Audio muted: %s\n", 793 CX18_INFO("Audio muted: %s\n",
@@ -789,22 +796,23 @@ static void log_audio_status(struct cx18 *cx)
789 (download_ctl & 0x10) ? "running" : "stopped"); 796 (download_ctl & 0x10) ? "running" : "stopped");
790 797
791 switch (audio_config >> 4) { 798 switch (audio_config >> 4) {
792 case 0x00: p = "BTSC"; break; 799 case 0x00: p = "undefined"; break;
793 case 0x01: p = "EIAJ"; break; 800 case 0x01: p = "BTSC"; break;
794 case 0x02: p = "A2-M"; break; 801 case 0x02: p = "EIAJ"; break;
795 case 0x03: p = "A2-BG"; break; 802 case 0x03: p = "A2-M"; break;
796 case 0x04: p = "A2-DK1"; break; 803 case 0x04: p = "A2-BG"; break;
797 case 0x05: p = "A2-DK2"; break; 804 case 0x05: p = "A2-DK1"; break;
798 case 0x06: p = "A2-DK3"; break; 805 case 0x06: p = "A2-DK2"; break;
799 case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; 806 case 0x07: p = "A2-DK3"; break;
800 case 0x08: p = "AM-L"; break; 807 case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
801 case 0x09: p = "NICAM-BG"; break; 808 case 0x09: p = "AM-L"; break;
802 case 0x0a: p = "NICAM-DK"; break; 809 case 0x0a: p = "NICAM-BG"; break;
803 case 0x0b: p = "NICAM-I"; break; 810 case 0x0b: p = "NICAM-DK"; break;
804 case 0x0c: p = "NICAM-L"; break; 811 case 0x0c: p = "NICAM-I"; break;
805 case 0x0d: p = "FM radio"; break; 812 case 0x0d: p = "NICAM-L"; break;
813 case 0x0e: p = "FM radio"; break;
806 case 0x0f: p = "automatic detection"; break; 814 case 0x0f: p = "automatic detection"; break;
807 default: p = "undefined"; 815 default: p = "undefined"; break;
808 } 816 }
809 CX18_INFO("Configured audio standard: %s\n", p); 817 CX18_INFO("Configured audio standard: %s\n", p);
810 818
@@ -815,12 +823,9 @@ static void log_audio_status(struct cx18 *cx)
815 case 0x02: p = "MONO3 (STEREO forced MONO)"; break; 823 case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
816 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; 824 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
817 case 0x04: p = "STEREO"; break; 825 case 0x04: p = "STEREO"; break;
818 case 0x05: p = "DUAL1 (AB)"; break; 826 case 0x05: p = "DUAL1 (AC)"; break;
819 case 0x06: p = "DUAL2 (AC) (FM)"; break; 827 case 0x06: p = "DUAL2 (BC)"; break;
820 case 0x07: p = "DUAL3 (BC) (FM)"; break; 828 case 0x07: p = "DUAL3 (AB)"; break;
821 case 0x08: p = "DUAL4 (AC) (AM)"; break;
822 case 0x09: p = "DUAL5 (BC) (AM)"; break;
823 case 0x0a: p = "SAP"; break;
824 default: p = "undefined"; 829 default: p = "undefined";
825 } 830 }
826 CX18_INFO("Configured audio mode: %s\n", p); 831 CX18_INFO("Configured audio mode: %s\n", p);
@@ -835,9 +840,11 @@ static void log_audio_status(struct cx18 *cx)
835 case 0x06: p = "BTSC"; break; 840 case 0x06: p = "BTSC"; break;
836 case 0x07: p = "EIAJ"; break; 841 case 0x07: p = "EIAJ"; break;
837 case 0x08: p = "A2-M"; break; 842 case 0x08: p = "A2-M"; break;
838 case 0x09: p = "FM Radio"; break; 843 case 0x09: p = "FM Radio (4.5 MHz)"; break;
844 case 0x0a: p = "FM Radio (5.5 MHz)"; break;
845 case 0x0b: p = "S-Video"; break;
839 case 0x0f: p = "automatic standard and mode detection"; break; 846 case 0x0f: p = "automatic standard and mode detection"; break;
840 default: p = "undefined"; 847 default: p = "undefined"; break;
841 } 848 }
842 CX18_INFO("Configured audio system: %s\n", p); 849 CX18_INFO("Configured audio system: %s\n", p);
843 } 850 }
@@ -857,22 +864,24 @@ static void log_audio_status(struct cx18 *cx)
857 case 5: p = "language AC"; break; 864 case 5: p = "language AC"; break;
858 case 6: p = "language BC"; break; 865 case 6: p = "language BC"; break;
859 case 7: p = "language AB"; break; 866 case 7: p = "language AB"; break;
860 default: p = "undefined"; 867 default: p = "undefined"; break;
861 } 868 }
862 CX18_INFO("Preferred audio mode: %s\n", p); 869 CX18_INFO("Preferred audio mode: %s\n", p);
863 870
864 if ((audio_config & 0xf) == 0xf) { 871 if ((audio_config & 0xf) == 0xf) {
865 switch ((afc0 >> 2) & 0x1) { 872 switch ((afc0 >> 3) & 0x1) {
866 case 0: p = "system DK"; break; 873 case 0: p = "system DK"; break;
867 case 1: p = "system L"; break; 874 case 1: p = "system L"; break;
868 } 875 }
869 CX18_INFO("Selected 65 MHz format: %s\n", p); 876 CX18_INFO("Selected 65 MHz format: %s\n", p);
870 877
871 switch (afc0 & 0x3) { 878 switch (afc0 & 0x7) {
872 case 0: p = "BTSC"; break; 879 case 0: p = "Chroma"; break;
873 case 1: p = "EIAJ"; break; 880 case 1: p = "BTSC"; break;
874 case 2: p = "A2-M"; break; 881 case 2: p = "EIAJ"; break;
875 default: p = "undefined"; 882 case 3: p = "A2-M"; break;
883 case 4: p = "autodetect"; break;
884 default: p = "undefined"; break;
876 } 885 }
877 CX18_INFO("Selected 45 MHz format: %s\n", p); 886 CX18_INFO("Selected 45 MHz format: %s\n", p);
878 } 887 }
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index f5e3ba1f5354..baccd079243d 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -47,11 +47,12 @@ static struct cx18_card_tuner_i2c cx18_i2c_std = {
47static const struct cx18_card cx18_card_hvr1600_esmt = { 47static const struct cx18_card cx18_card_hvr1600_esmt = {
48 .type = CX18_CARD_HVR_1600_ESMT, 48 .type = CX18_CARD_HVR_1600_ESMT,
49 .name = "Hauppauge HVR-1600", 49 .name = "Hauppauge HVR-1600",
50 .comment = "DVB & VBI are not yet supported\n", 50 .comment = "VBI is not yet supported\n",
51 .v4l2_capabilities = CX18_CAP_ENCODER, 51 .v4l2_capabilities = CX18_CAP_ENCODER,
52 .hw_audio_ctrl = CX18_HW_CX23418, 52 .hw_audio_ctrl = CX18_HW_CX23418,
53 .hw_muxer = CX18_HW_CS5345, 53 .hw_muxer = CX18_HW_CS5345,
54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
55 CX18_HW_CS5345 | CX18_HW_DVB,
55 .video_inputs = { 56 .video_inputs = {
56 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 57 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
57 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 58 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -86,11 +87,12 @@ static const struct cx18_card cx18_card_hvr1600_esmt = {
86static const struct cx18_card cx18_card_hvr1600_samsung = { 87static const struct cx18_card cx18_card_hvr1600_samsung = {
87 .type = CX18_CARD_HVR_1600_SAMSUNG, 88 .type = CX18_CARD_HVR_1600_SAMSUNG,
88 .name = "Hauppauge HVR-1600 (Preproduction)", 89 .name = "Hauppauge HVR-1600 (Preproduction)",
89 .comment = "DVB & VBI are not yet supported\n", 90 .comment = "VBI is not yet supported\n",
90 .v4l2_capabilities = CX18_CAP_ENCODER, 91 .v4l2_capabilities = CX18_CAP_ENCODER,
91 .hw_audio_ctrl = CX18_HW_CX23418, 92 .hw_audio_ctrl = CX18_HW_CX23418,
92 .hw_muxer = CX18_HW_CS5345, 93 .hw_muxer = CX18_HW_CS5345,
93 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 94 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
95 CX18_HW_CS5345 | CX18_HW_DVB,
94 .video_inputs = { 96 .video_inputs = {
95 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 97 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
96 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 98 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -124,7 +126,7 @@ static const struct cx18_card cx18_card_hvr1600_samsung = {
124 126
125/* ------------------------------------------------------------------------- */ 127/* ------------------------------------------------------------------------- */
126 128
127/* Compro VideoMate H900: not working at the moment! */ 129/* Compro VideoMate H900: note that this card is analog only! */
128 130
129static const struct cx18_card_pci_info cx18_pci_h900[] = { 131static const struct cx18_card_pci_info cx18_pci_h900[] = {
130 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 }, 132 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
@@ -134,14 +136,15 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = {
134static const struct cx18_card cx18_card_h900 = { 136static const struct cx18_card cx18_card_h900 = {
135 .type = CX18_CARD_COMPRO_H900, 137 .type = CX18_CARD_COMPRO_H900,
136 .name = "Compro VideoMate H900", 138 .name = "Compro VideoMate H900",
137 .comment = "Not yet supported!\n", 139 .comment = "VBI is not yet supported\n",
138 .v4l2_capabilities = 0, 140 .v4l2_capabilities = CX18_CAP_ENCODER,
139 .hw_audio_ctrl = CX18_HW_CX23418, 141 .hw_audio_ctrl = CX18_HW_CX23418,
140 .hw_all = CX18_HW_TUNER, 142 .hw_all = CX18_HW_TUNER,
141 .video_inputs = { 143 .video_inputs = {
142 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 144 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 },
143 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 145 { CX18_CARD_INPUT_SVIDEO1, 1,
144 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, 146 CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 },
147 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 },
145 }, 148 },
146 .audio_inputs = { 149 .audio_inputs = {
147 { CX18_CARD_INPUT_AUD_TUNER, 150 { CX18_CARD_INPUT_AUD_TUNER,
@@ -163,6 +166,7 @@ static const struct cx18_card cx18_card_h900 = {
163 .tune_lane = 0, 166 .tune_lane = 0,
164 .initial_emrs = 0, 167 .initial_emrs = 0,
165 }, 168 },
169 .xceive_pin = 15,
166 .pci_list = cx18_pci_h900, 170 .pci_list = cx18_pci_h900,
167 .i2c = &cx18_i2c_std, 171 .i2c = &cx18_i2c_std,
168}; 172};
@@ -200,8 +204,6 @@ static const struct cx18_card cx18_card_mpc718 = {
200 /* XC3028 tuner */ 204 /* XC3028 tuner */
201 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 205 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
202 }, 206 },
203 /* tuner reset */
204 .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 },
205 .ddr = { 207 .ddr = {
206 /* Probably Samsung K4D263238G-VC33 memory */ 208 /* Probably Samsung K4D263238G-VC33 memory */
207 .chip_config = 0x003, 209 .chip_config = 0x003,
@@ -211,6 +213,7 @@ static const struct cx18_card cx18_card_mpc718 = {
211 .tune_lane = 0, 213 .tune_lane = 0,
212 .initial_emrs = 2, 214 .initial_emrs = 2,
213 }, 215 },
216 .xceive_pin = 15,
214 .pci_list = cx18_pci_mpc718, 217 .pci_list = cx18_pci_mpc718,
215 .i2c = &cx18_i2c_std, 218 .i2c = &cx18_i2c_std,
216}; 219};
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h
index bca249bdd337..bccb67f0db16 100644
--- a/drivers/media/video/cx18/cx18-cards.h
+++ b/drivers/media/video/cx18/cx18-cards.h
@@ -114,8 +114,8 @@ struct cx18_card_pci_info {
114/* The mask is the set of bits used by the operation */ 114/* The mask is the set of bits used by the operation */
115 115
116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ 116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */
117 u16 direction; /* DIR setting. Leave to 0 if no init is needed */ 117 u32 direction; /* DIR setting. Leave to 0 if no init is needed */
118 u16 initial_value; 118 u32 initial_value;
119}; 119};
120 120
121struct cx18_card_tuner { 121struct cx18_card_tuner {
@@ -153,6 +153,7 @@ struct cx18_card {
153 struct cx18_card_audio_input radio_input; 153 struct cx18_card_audio_input radio_input;
154 154
155 /* GPIO card-specific settings */ 155 /* GPIO card-specific settings */
156 u8 xceive_pin; /* XCeive tuner GPIO reset pin */
156 struct cx18_gpio_init gpio_init; 157 struct cx18_gpio_init gpio_init;
157 158
158 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; 159 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c
index 2bdac5ebbb0d..87cf41021665 100644
--- a/drivers/media/video/cx18/cx18-controls.c
+++ b/drivers/media/video/cx18/cx18-controls.c
@@ -159,7 +159,7 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt
159{ 159{
160 if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) 160 if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE))
161 return -EINVAL; 161 return -EINVAL;
162 if (atomic_read(&cx->capturing) > 0) 162 if (atomic_read(&cx->ana_capturing) > 0)
163 return -EBUSY; 163 return -EBUSY;
164 164
165 /* First try to allocate sliced VBI buffers if needed. */ 165 /* First try to allocate sliced VBI buffers if needed. */
@@ -235,7 +235,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
235 CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); 235 CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
236 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { 236 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
237 struct cx2341x_mpeg_params p = cx->params; 237 struct cx2341x_mpeg_params p = cx->params;
238 int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->capturing), arg, cmd); 238 int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), arg, cmd);
239 239
240 if (err) 240 if (err)
241 return err; 241 return err;
@@ -295,7 +295,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
295 CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); 295 CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
296 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) 296 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
297 return cx2341x_ext_ctrls(&cx->params, 297 return cx2341x_ext_ctrls(&cx->params,
298 atomic_read(&cx->capturing), arg, cmd); 298 atomic_read(&cx->ana_capturing), arg, cmd);
299 return -EINVAL; 299 return -EINVAL;
300 } 300 }
301 301
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 3f55d47bc4b9..2b810bb2a4c7 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -164,16 +164,6 @@ MODULE_LICENSE("GPL");
164 164
165MODULE_VERSION(CX18_VERSION); 165MODULE_VERSION(CX18_VERSION);
166 166
167int cx18_waitq(wait_queue_head_t *waitq)
168{
169 DEFINE_WAIT(wait);
170
171 prepare_to_wait(waitq, &wait, TASK_INTERRUPTIBLE);
172 schedule();
173 finish_wait(waitq, &wait);
174 return signal_pending(current) ? -EINTR : 0;
175}
176
177/* Generic utility functions */ 167/* Generic utility functions */
178int cx18_msleep_timeout(unsigned int msecs, int intr) 168int cx18_msleep_timeout(unsigned int msecs, int intr)
179{ 169{
@@ -220,13 +210,13 @@ static void cx18_process_eeprom(struct cx18 *cx)
220 210
221 /* Many thanks to Steven Toth from Hauppauge for providing the 211 /* Many thanks to Steven Toth from Hauppauge for providing the
222 model numbers */ 212 model numbers */
213 /* Note: the Samsung memory models cannot be reliably determined
214 from the model number. Use the cardtype module option if you
215 have one of these preproduction models. */
223 switch (tv.model) { 216 switch (tv.model) {
224 case 74000 ... 74099: 217 case 74000 ... 74999:
225 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); 218 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
226 break; 219 break;
227 case 74700 ... 74799:
228 cx->card = cx18_get_card(CX18_CARD_HVR_1600_SAMSUNG);
229 break;
230 case 0: 220 case 0:
231 CX18_ERR("Invalid EEPROM\n"); 221 CX18_ERR("Invalid EEPROM\n");
232 return; 222 return;
@@ -548,6 +538,7 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *dev,
548 return 0; 538 return 0;
549} 539}
550 540
541#ifdef MODULE
551static u32 cx18_request_module(struct cx18 *cx, u32 hw, 542static u32 cx18_request_module(struct cx18 *cx, u32 hw,
552 const char *name, u32 id) 543 const char *name, u32 id)
553{ 544{
@@ -560,12 +551,14 @@ static u32 cx18_request_module(struct cx18 *cx, u32 hw,
560 CX18_DEBUG_INFO("Loaded module %s\n", name); 551 CX18_DEBUG_INFO("Loaded module %s\n", name);
561 return hw; 552 return hw;
562} 553}
554#endif
563 555
564static void cx18_load_and_init_modules(struct cx18 *cx) 556static void cx18_load_and_init_modules(struct cx18 *cx)
565{ 557{
566 u32 hw = cx->card->hw_all; 558 u32 hw = cx->card->hw_all;
567 int i; 559 int i;
568 560
561#ifdef MODULE
569 /* load modules */ 562 /* load modules */
570#ifndef CONFIG_MEDIA_TUNER 563#ifndef CONFIG_MEDIA_TUNER
571 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); 564 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER);
@@ -573,6 +566,7 @@ static void cx18_load_and_init_modules(struct cx18 *cx)
573#ifndef CONFIG_VIDEO_CS5345 566#ifndef CONFIG_VIDEO_CS5345
574 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); 567 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345);
575#endif 568#endif
569#endif
576 570
577 /* check which i2c devices are actually found */ 571 /* check which i2c devices are actually found */
578 for (i = 0; i < 32; i++) { 572 for (i = 0; i < 32; i++) {
@@ -676,7 +670,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
676 cx18_init_power(cx, 1); 670 cx18_init_power(cx, 1);
677 cx18_init_memory(cx); 671 cx18_init_memory(cx);
678 672
679 cx->scb = (struct cx18_scb *)(cx->enc_mem + SCB_OFFSET); 673 cx->scb = (struct cx18_scb __iomem *)(cx->enc_mem + SCB_OFFSET);
680 cx18_init_scb(cx); 674 cx18_init_scb(cx);
681 675
682 cx18_gpio_init(cx); 676 cx18_gpio_init(cx);
@@ -757,17 +751,6 @@ static int __devinit cx18_probe(struct pci_dev *dev,
757 if (cx->options.radio > 0) 751 if (cx->options.radio > 0)
758 cx->v4l2_cap |= V4L2_CAP_RADIO; 752 cx->v4l2_cap |= V4L2_CAP_RADIO;
759 753
760 retval = cx18_streams_setup(cx);
761 if (retval) {
762 CX18_ERR("Error %d setting up streams\n", retval);
763 goto free_irq;
764 }
765 retval = cx18_streams_register(cx);
766 if (retval) {
767 CX18_ERR("Error %d registering devices\n", retval);
768 goto free_streams;
769 }
770
771 if (cx->options.tuner > -1) { 754 if (cx->options.tuner > -1) {
772 struct tuner_setup setup; 755 struct tuner_setup setup;
773 756
@@ -794,14 +777,23 @@ static int __devinit cx18_probe(struct pci_dev *dev,
794 are not. */ 777 are not. */
795 cx->tuner_std = cx->std; 778 cx->tuner_std = cx->std;
796 779
797 cx18_init_on_first_open(cx); 780 retval = cx18_streams_setup(cx);
781 if (retval) {
782 CX18_ERR("Error %d setting up streams\n", retval);
783 goto free_irq;
784 }
785 retval = cx18_streams_register(cx);
786 if (retval) {
787 CX18_ERR("Error %d registering devices\n", retval);
788 goto free_streams;
789 }
798 790
799 CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); 791 CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name);
800 792
801 return 0; 793 return 0;
802 794
803free_streams: 795free_streams:
804 cx18_streams_cleanup(cx); 796 cx18_streams_cleanup(cx, 1);
805free_irq: 797free_irq:
806 free_irq(cx->dev->irq, (void *)cx); 798 free_irq(cx->dev->irq, (void *)cx);
807free_i2c: 799free_i2c:
@@ -895,7 +887,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
895 887
896 /* Stop all captures */ 888 /* Stop all captures */
897 CX18_DEBUG_INFO("Stopping all streams\n"); 889 CX18_DEBUG_INFO("Stopping all streams\n");
898 if (atomic_read(&cx->capturing) > 0) 890 if (atomic_read(&cx->tot_capturing) > 0)
899 cx18_stop_all_captures(cx); 891 cx18_stop_all_captures(cx);
900 892
901 /* Interrupts */ 893 /* Interrupts */
@@ -904,14 +896,13 @@ static void cx18_remove(struct pci_dev *pci_dev)
904 896
905 cx18_halt_firmware(cx); 897 cx18_halt_firmware(cx);
906 898
907 cx18_streams_cleanup(cx); 899 cx18_streams_cleanup(cx, 1);
908 900
909 exit_cx18_i2c(cx); 901 exit_cx18_i2c(cx);
910 902
911 free_irq(cx->dev->irq, (void *)cx); 903 free_irq(cx->dev->irq, (void *)cx);
912 904
913 if (cx->dev) 905 cx18_iounmap(cx);
914 cx18_iounmap(cx);
915 906
916 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 907 release_mem_region(cx->base_addr, CX18_MEM_SIZE);
917 908
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 2ee939193bb7..de14ab59a206 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -358,7 +358,7 @@ struct cx18 {
358 u32 v4l2_cap; /* V4L2 capabilities of card */ 358 u32 v4l2_cap; /* V4L2 capabilities of card */
359 u32 hw_flags; /* Hardware description of the board */ 359 u32 hw_flags; /* Hardware description of the board */
360 unsigned mdl_offset; 360 unsigned mdl_offset;
361 struct cx18_scb *scb; /* pointer to SCB */ 361 struct cx18_scb __iomem *scb; /* pointer to SCB */
362 362
363 struct cx18_av_state av_state; 363 struct cx18_av_state av_state;
364 364
@@ -380,7 +380,8 @@ struct cx18 {
380 int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */ 380 int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */
381 struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */ 381 struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */
382 unsigned long i_flags; /* global cx18 flags */ 382 unsigned long i_flags; /* global cx18 flags */
383 atomic_t capturing; /* count number of active capture streams */ 383 atomic_t ana_capturing; /* count number of active analog capture streams */
384 atomic_t tot_capturing; /* total count number of active capture streams */
384 spinlock_t lock; /* lock access to this struct */ 385 spinlock_t lock; /* lock access to this struct */
385 int search_pack_header; 386 int search_pack_header;
386 387
@@ -423,6 +424,10 @@ struct cx18 {
423 struct mutex i2c_bus_lock[2]; 424 struct mutex i2c_bus_lock[2];
424 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; 425 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
425 426
427 /* gpio */
428 u32 gpio_dir;
429 u32 gpio_val;
430
426 /* v4l2 and User settings */ 431 /* v4l2 and User settings */
427 432
428 /* codec settings */ 433 /* codec settings */
@@ -444,9 +449,6 @@ extern spinlock_t cx18_cards_lock;
444/* Return non-zero if a signal is pending */ 449/* Return non-zero if a signal is pending */
445int cx18_msleep_timeout(unsigned int msecs, int intr); 450int cx18_msleep_timeout(unsigned int msecs, int intr);
446 451
447/* Wait on queue, returns -EINTR if interrupted */
448int cx18_waitq(wait_queue_head_t *waitq);
449
450/* Read Hauppauge eeprom */ 452/* Read Hauppauge eeprom */
451struct tveeprom; /* forward reference */ 453struct tveeprom; /* forward reference */
452void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); 454void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv);
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 65efe69d939a..c9744173f969 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -24,25 +24,27 @@
24#include "cx18-streams.h" 24#include "cx18-streams.h"
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "s5h1409.h" 26#include "s5h1409.h"
27 27#include "mxl5005s.h"
28/* Wait until the MXL500X driver is merged */
29#ifdef HAVE_MXL500X
30#include "mxl500x.h"
31#endif
32 28
33DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 29DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
34 30
35#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 31#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000
36 32
37#ifdef HAVE_MXL500X 33static struct mxl5005s_config hauppauge_hvr1600_tuner = {
38static struct mxl500x_config hauppauge_hvr1600_tuner = { 34 .i2c_address = 0xC6 >> 1,
39 .delsys = MXL500x_MODE_ATSC, 35 .if_freq = IF_FREQ_5380000HZ,
40 .octf = MXL500x_OCTF_CH, 36 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
41 .xtal_freq = 16000000, 37 .agc_mode = MXL_SINGLE_AGC,
42 .iflo_freq = 5380000, 38 .tracking_filter = MXL_TF_C_H,
43 .ref_freq = 322800000, 39 .rssi_enable = MXL_RSSI_ENABLE,
44 .rssi_ena = MXL_RSSI_ENABLE, 40 .cap_select = MXL_CAP_SEL_ENABLE,
45 .addr = 0xC6 >> 1, 41 .div_out = MXL_DIV_OUT_4,
42 .clock_out = MXL_CLOCK_OUT_DISABLE,
43 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
44 .top = MXL5005S_TOP_25P2,
45 .mod_mode = MXL_DIGITAL_MODE,
46 .if_mode = MXL_ZERO_IF,
47 .AgcMasterByte = 0x00,
46}; 48};
47 49
48static struct s5h1409_config hauppauge_hvr1600_config = { 50static struct s5h1409_config hauppauge_hvr1600_config = {
@@ -55,7 +57,6 @@ static struct s5h1409_config hauppauge_hvr1600_config = {
55 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 57 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
56 58
57}; 59};
58#endif
59 60
60static int dvb_register(struct cx18_stream *stream); 61static int dvb_register(struct cx18_stream *stream);
61 62
@@ -252,21 +253,18 @@ static int dvb_register(struct cx18_stream *stream)
252 int ret = 0; 253 int ret = 0;
253 254
254 switch (cx->card->type) { 255 switch (cx->card->type) {
255/* Wait until the MXL500X driver is merged */
256#ifdef HAVE_MXL500X
257 case CX18_CARD_HVR_1600_ESMT: 256 case CX18_CARD_HVR_1600_ESMT:
258 case CX18_CARD_HVR_1600_SAMSUNG: 257 case CX18_CARD_HVR_1600_SAMSUNG:
259 dvb->fe = dvb_attach(s5h1409_attach, 258 dvb->fe = dvb_attach(s5h1409_attach,
260 &hauppauge_hvr1600_config, 259 &hauppauge_hvr1600_config,
261 &cx->i2c_adap[0]); 260 &cx->i2c_adap[0]);
262 if (dvb->fe != NULL) { 261 if (dvb->fe != NULL) {
263 dvb_attach(mxl500x_attach, dvb->fe, 262 dvb_attach(mxl5005s_attach, dvb->fe,
264 &hauppauge_hvr1600_tuner, 263 &cx->i2c_adap[0],
265 &cx->i2c_adap[0]); 264 &hauppauge_hvr1600_tuner);
266 ret = 0; 265 ret = 0;
267 } 266 }
268 break; 267 break;
269#endif
270 default: 268 default:
271 /* No Digital Tv Support */ 269 /* No Digital Tv Support */
272 break; 270 break;
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 69303065a294..1e537fe04a23 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -39,7 +39,7 @@
39 associated VBI streams are also automatically claimed. 39 associated VBI streams are also automatically claimed.
40 Possible error returns: -EBUSY if someone else has claimed 40 Possible error returns: -EBUSY if someone else has claimed
41 the stream or 0 on success. */ 41 the stream or 0 on success. */
42int cx18_claim_stream(struct cx18_open_id *id, int type) 42static int cx18_claim_stream(struct cx18_open_id *id, int type)
43{ 43{
44 struct cx18 *cx = id->cx; 44 struct cx18 *cx = id->cx;
45 struct cx18_stream *s = &cx->streams[type]; 45 struct cx18_stream *s = &cx->streams[type];
@@ -87,7 +87,7 @@ int cx18_claim_stream(struct cx18_open_id *id, int type)
87 87
88/* This function releases a previously claimed stream. It will take into 88/* This function releases a previously claimed stream. It will take into
89 account associated VBI streams. */ 89 account associated VBI streams. */
90void cx18_release_stream(struct cx18_stream *s) 90static void cx18_release_stream(struct cx18_stream *s)
91{ 91{
92 struct cx18 *cx = s->cx; 92 struct cx18 *cx = s->cx;
93 struct cx18_stream *s_vbi; 93 struct cx18_stream *s_vbi;
@@ -318,7 +318,7 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf,
318 size_t tot_written = 0; 318 size_t tot_written = 0;
319 int single_frame = 0; 319 int single_frame = 0;
320 320
321 if (atomic_read(&cx->capturing) == 0 && s->id == -1) { 321 if (atomic_read(&cx->ana_capturing) == 0 && s->id == -1) {
322 /* shouldn't happen */ 322 /* shouldn't happen */
323 CX18_DEBUG_WARN("Stream %s not initialized before read\n", 323 CX18_DEBUG_WARN("Stream %s not initialized before read\n",
324 s->name); 324 s->name);
@@ -361,7 +361,8 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf,
361 cx18_enqueue(s, buf, &s->q_free); 361 cx18_enqueue(s, buf, &s->q_free);
362 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, 362 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5,
363 s->handle, 363 s->handle,
364 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 364 (void __iomem *)&cx->scb->cpu_mdl[buf->id] -
365 cx->enc_mem,
365 1, buf->id, s->buf_size); 366 1, buf->id, s->buf_size);
366 } else 367 } else
367 cx18_enqueue(s, buf, &s->q_io); 368 cx18_enqueue(s, buf, &s->q_io);
@@ -581,7 +582,7 @@ int cx18_v4l2_close(struct inode *inode, struct file *filp)
581 cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); 582 cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std);
582 /* Select correct audio input (i.e. TV tuner or Line in) */ 583 /* Select correct audio input (i.e. TV tuner or Line in) */
583 cx18_audio_set_io(cx); 584 cx18_audio_set_io(cx);
584 if (atomic_read(&cx->capturing) > 0) { 585 if (atomic_read(&cx->ana_capturing) > 0) {
585 /* Undo video mute */ 586 /* Undo video mute */
586 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, 587 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle,
587 cx->params.video_mute | 588 cx->params.video_mute |
@@ -627,7 +628,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
627 } 628 }
628 629
629 if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { 630 if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
630 if (atomic_read(&cx->capturing) > 0) { 631 if (atomic_read(&cx->ana_capturing) > 0) {
631 /* switching to radio while capture is 632 /* switching to radio while capture is
632 in progress is not polite */ 633 in progress is not polite */
633 cx18_release_stream(s); 634 cx18_release_stream(s);
@@ -662,6 +663,8 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) { 663 for (x = 0; cx == NULL && x < cx18_cards_active; x++) {
663 /* find out which stream this open was on */ 664 /* find out which stream this open was on */
664 for (y = 0; y < CX18_MAX_STREAMS; y++) { 665 for (y = 0; y < CX18_MAX_STREAMS; y++) {
666 if (cx18_cards[x] == NULL)
667 continue;
665 s = &cx18_cards[x]->streams[y]; 668 s = &cx18_cards[x]->streams[y];
666 if (s->v4l2dev && s->v4l2dev->minor == minor) { 669 if (s->v4l2dev && s->v4l2dev->minor == minor) {
667 cx = cx18_cards[x]; 670 cx = cx18_cards[x];
@@ -692,7 +695,7 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
692 695
693void cx18_mute(struct cx18 *cx) 696void cx18_mute(struct cx18 *cx)
694{ 697{
695 if (atomic_read(&cx->capturing)) 698 if (atomic_read(&cx->ana_capturing))
696 cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, 699 cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2,
697 cx18_find_handle(cx), 1); 700 cx18_find_handle(cx), 1);
698 CX18_DEBUG_INFO("Mute\n"); 701 CX18_DEBUG_INFO("Mute\n");
@@ -700,7 +703,7 @@ void cx18_mute(struct cx18 *cx)
700 703
701void cx18_unmute(struct cx18 *cx) 704void cx18_unmute(struct cx18 *cx)
702{ 705{
703 if (atomic_read(&cx->capturing)) { 706 if (atomic_read(&cx->ana_capturing)) {
704 cx18_msleep_timeout(100, 0); 707 cx18_msleep_timeout(100, 0);
705 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, 708 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2,
706 cx18_find_handle(cx), 12); 709 cx18_find_handle(cx), 12);
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h
index 16cdafbd24c5..46da0282fc7d 100644
--- a/drivers/media/video/cx18/cx18-fileops.h
+++ b/drivers/media/video/cx18/cx18-fileops.h
@@ -34,12 +34,3 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end);
34void cx18_mute(struct cx18 *cx); 34void cx18_mute(struct cx18 *cx);
35void cx18_unmute(struct cx18 *cx); 35void cx18_unmute(struct cx18 *cx);
36 36
37/* Utilities */
38
39/* Try to claim a stream for the filehandle. Return 0 on success,
40 -EBUSY if stream already claimed. Once a stream is claimed, it
41 remains claimed until the associated filehandle is closed. */
42int cx18_claim_stream(struct cx18_open_id *id, int type);
43
44/* Release a previously claimed stream. */
45void cx18_release_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index 19253e6b8673..ceb63653c926 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -44,31 +44,57 @@
44 * gpio13: cs5345 reset pin 44 * gpio13: cs5345 reset pin
45*/ 45*/
46 46
47static void gpio_write(struct cx18 *cx)
48{
49 u32 dir = cx->gpio_dir;
50 u32 val = cx->gpio_val;
51
52 write_reg((dir & 0xffff) << 16, CX18_REG_GPIO_DIR1);
53 write_reg(((dir & 0xffff) << 16) | (val & 0xffff),
54 CX18_REG_GPIO_OUT1);
55 write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2);
56 write_reg((dir & 0xffff0000) | ((val & 0xffff0000) >> 16),
57 CX18_REG_GPIO_OUT2);
58}
59
47void cx18_gpio_init(struct cx18 *cx) 60void cx18_gpio_init(struct cx18 *cx)
48{ 61{
49 if (cx->card->gpio_init.direction == 0) 62 cx->gpio_dir = cx->card->gpio_init.direction;
63 cx->gpio_val = cx->card->gpio_init.initial_value;
64
65 if (cx->card->tuners[0].tuner == TUNER_XC2028) {
66 cx->gpio_dir |= 1 << cx->card->xceive_pin;
67 cx->gpio_val |= 1 << cx->card->xceive_pin;
68 }
69
70 if (cx->gpio_dir == 0)
50 return; 71 return;
51 72
52 CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n", 73 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n",
53 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1)); 74 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2),
75 read_reg(CX18_REG_GPIO_OUT1), read_reg(CX18_REG_GPIO_OUT2));
54 76
55 /* init output data then direction */ 77 gpio_write(cx);
56 write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1);
57 write_reg(0, CX18_REG_GPIO_DIR2);
58 write_reg((cx->card->gpio_init.direction << 16) |
59 cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1);
60 write_reg(0, CX18_REG_GPIO_OUT2);
61} 78}
62 79
63/* Xceive tuner reset function */ 80/* Xceive tuner reset function */
64int cx18_reset_tuner_gpio(void *dev, int cmd, int value) 81int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
65{ 82{
66 struct i2c_algo_bit_data *algo = dev; 83 struct i2c_algo_bit_data *algo = dev;
67 struct cx18 *cx = algo->data; 84 struct cx18_i2c_algo_callback_data *cb_data = algo->data;
68/* int curdir, curout;*/ 85 struct cx18 *cx = cb_data->cx;
69 86
70 if (cmd != XC2028_TUNER_RESET) 87 if (cmd != XC2028_TUNER_RESET)
71 return 0; 88 return 0;
72 CX18_DEBUG_INFO("Resetting tuner\n"); 89 CX18_DEBUG_INFO("Resetting tuner\n");
90
91 cx->gpio_val &= ~(1 << cx->card->xceive_pin);
92
93 gpio_write(cx);
94 schedule_timeout_interruptible(msecs_to_jiffies(1));
95
96 cx->gpio_val |= 1 << cx->card->xceive_pin;
97 gpio_write(cx);
98 schedule_timeout_interruptible(msecs_to_jiffies(1));
73 return 0; 99 return 0;
74} 100}
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 18c88d1e4833..1d6c51a75313 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -25,6 +25,7 @@
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "cx18-gpio.h" 26#include "cx18-gpio.h"
27#include "cx18-av-core.h" 27#include "cx18-av-core.h"
28#include "cx18-i2c.h"
28 29
29#include <media/ir-kbd-i2c.h> 30#include <media/ir-kbd-i2c.h>
30 31
@@ -73,7 +74,7 @@ static const u8 hw_bus[] = {
73}; 74};
74 75
75/* This array should match the CX18_HW_ defines */ 76/* This array should match the CX18_HW_ defines */
76static const char * const hw_drivernames[] = { 77static const char * const hw_devicenames[] = {
77 "tuner", 78 "tuner",
78 "tveeprom", 79 "tveeprom",
79 "cs5345", 80 "cs5345",
@@ -94,8 +95,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
94 id = hw_driverids[idx]; 95 id = hw_driverids[idx];
95 bus = hw_bus[idx]; 96 bus = hw_bus[idx];
96 memset(&info, 0, sizeof(info)); 97 memset(&info, 0, sizeof(info));
97 strlcpy(info.driver_name, hw_drivernames[idx], 98 strlcpy(info.type, hw_devicenames[idx], sizeof(info.type));
98 sizeof(info.driver_name));
99 info.addr = hw_addrs[idx]; 99 info.addr = hw_addrs[idx];
100 for (i = 0; i < I2C_CLIENTS_MAX; i++) 100 for (i = 0; i < I2C_CLIENTS_MAX; i++)
101 if (cx->i2c_clients[i] == NULL) 101 if (cx->i2c_clients[i] == NULL)
@@ -278,7 +278,7 @@ static const char *cx18_i2c_id_name(u32 id)
278 278
279 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) 279 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
280 if (hw_driverids[i] == id) 280 if (hw_driverids[i] == id)
281 return hw_drivernames[i]; 281 return hw_devicenames[i];
282 return "unknown device"; 282 return "unknown device";
283} 283}
284 284
@@ -289,7 +289,7 @@ static const char *cx18_i2c_hw_name(u32 hw)
289 289
290 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) 290 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
291 if (1 << i == hw) 291 if (1 << i == hw)
292 return hw_drivernames[i]; 292 return hw_devicenames[i];
293 return "unknown device"; 293 return "unknown device";
294} 294}
295 295
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index dbdcb86ec5aa..4151f1e5493f 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -247,7 +247,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
247 247
248 if (!set_fmt || (cx->params.width == w && cx->params.height == h)) 248 if (!set_fmt || (cx->params.width == w && cx->params.height == h))
249 return 0; 249 return 0;
250 if (atomic_read(&cx->capturing) > 0) 250 if (atomic_read(&cx->ana_capturing) > 0)
251 return -EBUSY; 251 return -EBUSY;
252 252
253 cx->params.width = w; 253 cx->params.width = w;
@@ -264,7 +264,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
264 if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 264 if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
265 if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI && 265 if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI &&
266 cx->vbi.sliced_in->service_set && 266 cx->vbi.sliced_in->service_set &&
267 atomic_read(&cx->capturing) > 0) 267 atomic_read(&cx->ana_capturing) > 0)
268 return -EBUSY; 268 return -EBUSY;
269 if (set_fmt) { 269 if (set_fmt) {
270 cx->vbi.sliced_in->service_set = 0; 270 cx->vbi.sliced_in->service_set = 0;
@@ -293,7 +293,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
293 return 0; 293 return 0;
294 if (set == 0) 294 if (set == 0)
295 return -EINVAL; 295 return -EINVAL;
296 if (atomic_read(&cx->capturing) > 0 && cx->vbi.sliced_in->service_set == 0) 296 if (atomic_read(&cx->ana_capturing) > 0 && cx->vbi.sliced_in->service_set == 0)
297 return -EBUSY; 297 return -EBUSY;
298 cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); 298 cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
299 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); 299 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in));
@@ -581,7 +581,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
581 break; 581 break;
582 582
583 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || 583 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
584 atomic_read(&cx->capturing) > 0) { 584 atomic_read(&cx->ana_capturing) > 0) {
585 /* Switching standard would turn off the radio or mess 585 /* Switching standard would turn off the radio or mess
586 with already running streams, prevent that by 586 with already running streams, prevent that by
587 returning EBUSY. */ 587 returning EBUSY. */
@@ -677,7 +677,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
677 enc->flags = 0; 677 enc->flags = 0;
678 if (try) 678 if (try)
679 return 0; 679 return 0;
680 if (!atomic_read(&cx->capturing)) 680 if (!atomic_read(&cx->ana_capturing))
681 return -EPERM; 681 return -EPERM;
682 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 682 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
683 return 0; 683 return 0;
@@ -689,7 +689,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
689 enc->flags = 0; 689 enc->flags = 0;
690 if (try) 690 if (try)
691 return 0; 691 return 0;
692 if (!atomic_read(&cx->capturing)) 692 if (!atomic_read(&cx->ana_capturing))
693 return -EPERM; 693 return -EPERM;
694 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 694 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
695 return 0; 695 return 0;
diff --git a/drivers/media/video/cx18/cx18-irq.c b/drivers/media/video/cx18/cx18-irq.c
index 6e14f8bda559..25114a5cbd57 100644
--- a/drivers/media/video/cx18/cx18-irq.c
+++ b/drivers/media/video/cx18/cx18-irq.c
@@ -75,7 +75,7 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb)
75 75
76 cx18_buf_sync_for_device(s, buf); 76 cx18_buf_sync_for_device(s, buf);
77 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, 77 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
78 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 78 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
79 1, buf->id, s->buf_size); 79 1, buf->id, s->buf_size);
80 } else 80 } else
81 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); 81 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags);
@@ -161,13 +161,15 @@ irqreturn_t cx18_irq_handler(int irq, void *dev_id)
161 */ 161 */
162 162
163 if (sw2) { 163 if (sw2) {
164 if (sw2 & (cx->scb->cpu2hpu_irq_ack | cx->scb->cpu2epu_irq_ack)) 164 if (sw2 & (readl(&cx->scb->cpu2hpu_irq_ack) |
165 readl(&cx->scb->cpu2epu_irq_ack)))
165 wake_up(&cx->mb_cpu_waitq); 166 wake_up(&cx->mb_cpu_waitq);
166 if (sw2 & (cx->scb->apu2hpu_irq_ack | cx->scb->apu2epu_irq_ack)) 167 if (sw2 & (readl(&cx->scb->apu2hpu_irq_ack) |
168 readl(&cx->scb->apu2epu_irq_ack)))
167 wake_up(&cx->mb_apu_waitq); 169 wake_up(&cx->mb_apu_waitq);
168 if (sw2 & cx->scb->epu2hpu_irq_ack) 170 if (sw2 & readl(&cx->scb->epu2hpu_irq_ack))
169 wake_up(&cx->mb_epu_waitq); 171 wake_up(&cx->mb_epu_waitq);
170 if (sw2 & cx->scb->hpu2epu_irq_ack) 172 if (sw2 & readl(&cx->scb->hpu2epu_irq_ack))
171 wake_up(&cx->mb_hpu_waitq); 173 wake_up(&cx->mb_hpu_waitq);
172 } 174 }
173 175
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c
index 0c5f328bca54..2a5ccef9185b 100644
--- a/drivers/media/video/cx18/cx18-mailbox.c
+++ b/drivers/media/video/cx18/cx18-mailbox.c
@@ -94,10 +94,10 @@ static const struct cx18_api_info *find_api_info(u32 cmd)
94 return NULL; 94 return NULL;
95} 95}
96 96
97static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu, 97static struct cx18_mailbox __iomem *cx18_mb_is_complete(struct cx18 *cx, int rpu,
98 u32 *state, u32 *irq, u32 *req) 98 u32 *state, u32 *irq, u32 *req)
99{ 99{
100 struct cx18_mailbox *mb = NULL; 100 struct cx18_mailbox __iomem *mb = NULL;
101 int wait_count = 0; 101 int wait_count = 0;
102 u32 ack; 102 u32 ack;
103 103
@@ -142,7 +142,7 @@ static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu,
142long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb) 142long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb)
143{ 143{
144 const struct cx18_api_info *info = find_api_info(mb->cmd); 144 const struct cx18_api_info *info = find_api_info(mb->cmd);
145 struct cx18_mailbox *ack_mb; 145 struct cx18_mailbox __iomem *ack_mb;
146 u32 ack_irq; 146 u32 ack_irq;
147 u8 rpu = CPU; 147 u8 rpu = CPU;
148 148
@@ -182,7 +182,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
182{ 182{
183 const struct cx18_api_info *info = find_api_info(cmd); 183 const struct cx18_api_info *info = find_api_info(cmd);
184 u32 state = 0, irq = 0, req, oldreq, err; 184 u32 state = 0, irq = 0, req, oldreq, err;
185 struct cx18_mailbox *mb; 185 struct cx18_mailbox __iomem *mb;
186 wait_queue_head_t *waitq; 186 wait_queue_head_t *waitq;
187 int timeout = 100; 187 int timeout = 100;
188 int cnt = 0; 188 int cnt = 0;
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 65af1bb507ca..6990b77c6200 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -26,17 +26,6 @@
26#include "cx18-queue.h" 26#include "cx18-queue.h"
27#include "cx18-scb.h" 27#include "cx18-scb.h"
28 28
29int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
30 const char __user *src, int copybytes)
31{
32 if (s->buf_size - buf->bytesused < copybytes)
33 copybytes = s->buf_size - buf->bytesused;
34 if (copy_from_user(buf->buf + buf->bytesused, src, copybytes))
35 return -EFAULT;
36 buf->bytesused += copybytes;
37 return copybytes;
38}
39
40void cx18_buf_swap(struct cx18_buffer *buf) 29void cx18_buf_swap(struct cx18_buffer *buf)
41{ 30{
42 int i; 31 int i;
@@ -159,8 +148,9 @@ static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from,
159 -ENOMEM is returned if the buffers could not be obtained, 0 if all 148 -ENOMEM is returned if the buffers could not be obtained, 0 if all
160 buffers where obtained from the 'from' list and if non-zero then 149 buffers where obtained from the 'from' list and if non-zero then
161 the number of stolen buffers is returned. */ 150 the number of stolen buffers is returned. */
162int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, 151static int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
163 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes) 152 struct cx18_queue *steal, struct cx18_queue *to,
153 int needed_bytes)
164{ 154{
165 unsigned long flags; 155 unsigned long flags;
166 int rc = 0; 156 int rc = 0;
@@ -239,12 +229,12 @@ int cx18_stream_alloc(struct cx18_stream *s)
239 229
240 /* allocate stream buffers. Initially all buffers are in q_free. */ 230 /* allocate stream buffers. Initially all buffers are in q_free. */
241 for (i = 0; i < s->buffers; i++) { 231 for (i = 0; i < s->buffers; i++) {
242 struct cx18_buffer *buf = 232 struct cx18_buffer *buf = kzalloc(sizeof(struct cx18_buffer),
243 kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); 233 GFP_KERNEL|__GFP_NOWARN);
244 234
245 if (buf == NULL) 235 if (buf == NULL)
246 break; 236 break;
247 buf->buf = kmalloc(s->buf_size, GFP_KERNEL); 237 buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN);
248 if (buf->buf == NULL) { 238 if (buf->buf == NULL) {
249 kfree(buf); 239 kfree(buf);
250 break; 240 break;
diff --git a/drivers/media/video/cx18/cx18-queue.h b/drivers/media/video/cx18/cx18-queue.h
index f86c8a6fa6e7..91423b9863a4 100644
--- a/drivers/media/video/cx18/cx18-queue.h
+++ b/drivers/media/video/cx18/cx18-queue.h
@@ -39,8 +39,6 @@ static inline void cx18_buf_sync_for_device(struct cx18_stream *s,
39 s->buf_size, s->dma); 39 s->buf_size, s->dma);
40} 40}
41 41
42int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
43 const char __user *src, int copybytes);
44void cx18_buf_swap(struct cx18_buffer *buf); 42void cx18_buf_swap(struct cx18_buffer *buf);
45 43
46/* cx18_queue utility functions */ 44/* cx18_queue utility functions */
@@ -48,8 +46,6 @@ void cx18_queue_init(struct cx18_queue *q);
48void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 46void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
49 struct cx18_queue *q); 47 struct cx18_queue *q);
50struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); 48struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q);
51int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
52 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes);
53struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, 49struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id,
54 u32 bytesused); 50 u32 bytesused);
55void cx18_flush_queues(struct cx18_stream *s); 51void cx18_flush_queues(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index afb141b2027a..1b921a336092 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -36,12 +36,13 @@
36#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 36#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
37 37
38static struct file_operations cx18_v4l2_enc_fops = { 38static struct file_operations cx18_v4l2_enc_fops = {
39 .owner = THIS_MODULE, 39 .owner = THIS_MODULE,
40 .read = cx18_v4l2_read, 40 .read = cx18_v4l2_read,
41 .open = cx18_v4l2_open, 41 .open = cx18_v4l2_open,
42 .ioctl = cx18_v4l2_ioctl, 42 .ioctl = cx18_v4l2_ioctl,
43 .release = cx18_v4l2_close, 43 .compat_ioctl = v4l_compat_ioctl32,
44 .poll = cx18_v4l2_enc_poll, 44 .release = cx18_v4l2_close,
45 .poll = cx18_v4l2_enc_poll,
45}; 46};
46 47
47/* offset from 0 to register ts v4l2 minors on */ 48/* offset from 0 to register ts v4l2 minors on */
@@ -218,7 +219,7 @@ int cx18_streams_setup(struct cx18 *cx)
218 return 0; 219 return 0;
219 220
220 /* One or more streams could not be initialized. Clean 'em all up. */ 221 /* One or more streams could not be initialized. Clean 'em all up. */
221 cx18_streams_cleanup(cx); 222 cx18_streams_cleanup(cx, 0);
222 return -ENOMEM; 223 return -ENOMEM;
223} 224}
224 225
@@ -296,12 +297,12 @@ int cx18_streams_register(struct cx18 *cx)
296 return 0; 297 return 0;
297 298
298 /* One or more streams could not be initialized. Clean 'em all up. */ 299 /* One or more streams could not be initialized. Clean 'em all up. */
299 cx18_streams_cleanup(cx); 300 cx18_streams_cleanup(cx, 1);
300 return -ENOMEM; 301 return -ENOMEM;
301} 302}
302 303
303/* Unregister v4l2 devices */ 304/* Unregister v4l2 devices */
304void cx18_streams_cleanup(struct cx18 *cx) 305void cx18_streams_cleanup(struct cx18 *cx, int unregister)
305{ 306{
306 struct video_device *vdev; 307 struct video_device *vdev;
307 int type; 308 int type;
@@ -319,8 +320,11 @@ void cx18_streams_cleanup(struct cx18 *cx)
319 320
320 cx18_stream_free(&cx->streams[type]); 321 cx18_stream_free(&cx->streams[type]);
321 322
322 /* Unregister device */ 323 /* Unregister or release device */
323 video_unregister_device(vdev); 324 if (unregister)
325 video_unregister_device(vdev);
326 else
327 video_device_release(vdev);
324 } 328 }
325} 329}
326 330
@@ -440,7 +444,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
440 s->handle = data[0]; 444 s->handle = data[0];
441 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); 445 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype);
442 446
443 if (atomic_read(&cx->capturing) == 0 && !ts) { 447 if (atomic_read(&cx->ana_capturing) == 0 && !ts) {
444 /* Stuff from Windows, we don't know what it is */ 448 /* Stuff from Windows, we don't know what it is */
445 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); 449 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0);
446 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); 450 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1);
@@ -463,14 +467,14 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
463 cx2341x_update(cx, cx18_api_func, NULL, &cx->params); 467 cx2341x_update(cx, cx18_api_func, NULL, &cx->params);
464 } 468 }
465 469
466 if (atomic_read(&cx->capturing) == 0) { 470 if (atomic_read(&cx->tot_capturing) == 0) {
467 clear_bit(CX18_F_I_EOS, &cx->i_flags); 471 clear_bit(CX18_F_I_EOS, &cx->i_flags);
468 write_reg(7, CX18_DSP0_INTERRUPT_MASK); 472 write_reg(7, CX18_DSP0_INTERRUPT_MASK);
469 } 473 }
470 474
471 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, 475 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle,
472 (void *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, 476 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem,
473 (void *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); 477 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem);
474 478
475 list_for_each(p, &s->q_free.list) { 479 list_for_each(p, &s->q_free.list) {
476 struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list); 480 struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list);
@@ -478,8 +482,8 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
478 writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr); 482 writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr);
479 writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length); 483 writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length);
480 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, 484 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
481 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 1, 485 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
482 buf->id, s->buf_size); 486 1, buf->id, s->buf_size);
483 } 487 }
484 /* begin_capture */ 488 /* begin_capture */
485 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { 489 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) {
@@ -489,7 +493,9 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
489 } 493 }
490 494
491 /* you're live! sit back and await interrupts :) */ 495 /* you're live! sit back and await interrupts :) */
492 atomic_inc(&cx->capturing); 496 if (!ts)
497 atomic_inc(&cx->ana_capturing);
498 atomic_inc(&cx->tot_capturing);
493 return 0; 499 return 0;
494} 500}
495 501
@@ -520,7 +526,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
520 526
521 CX18_DEBUG_INFO("Stop Capture\n"); 527 CX18_DEBUG_INFO("Stop Capture\n");
522 528
523 if (atomic_read(&cx->capturing) == 0) 529 if (atomic_read(&cx->tot_capturing) == 0)
524 return 0; 530 return 0;
525 531
526 if (s->type == CX18_ENC_STREAM_TYPE_MPG) 532 if (s->type == CX18_ENC_STREAM_TYPE_MPG)
@@ -534,7 +540,9 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
534 CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n"); 540 CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n");
535 } 541 }
536 542
537 atomic_dec(&cx->capturing); 543 if (s->type != CX18_ENC_STREAM_TYPE_TS)
544 atomic_dec(&cx->ana_capturing);
545 atomic_dec(&cx->tot_capturing);
538 546
539 /* Clear capture and no-read bits */ 547 /* Clear capture and no-read bits */
540 clear_bit(CX18_F_S_STREAMING, &s->s_flags); 548 clear_bit(CX18_F_S_STREAMING, &s->s_flags);
@@ -542,7 +550,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
542 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); 550 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle);
543 s->handle = 0xffffffff; 551 s->handle = 0xffffffff;
544 552
545 if (atomic_read(&cx->capturing) > 0) 553 if (atomic_read(&cx->tot_capturing) > 0)
546 return 0; 554 return 0;
547 555
548 write_reg(5, CX18_DSP0_INTERRUPT_MASK); 556 write_reg(5, CX18_DSP0_INTERRUPT_MASK);
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 8c7ba7d2fa79..f327e947b24f 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -24,7 +24,7 @@
24u32 cx18_find_handle(struct cx18 *cx); 24u32 cx18_find_handle(struct cx18 *cx);
25int cx18_streams_setup(struct cx18 *cx); 25int cx18_streams_setup(struct cx18 *cx);
26int cx18_streams_register(struct cx18 *cx); 26int cx18_streams_register(struct cx18 *cx);
27void cx18_streams_cleanup(struct cx18 *cx); 27void cx18_streams_cleanup(struct cx18 *cx, int unregister);
28 28
29/* Capture related */ 29/* Capture related */
30int cx18_start_v4l2_encode_stream(struct cx18_stream *s); 30int cx18_start_v4l2_encode_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index cadf936c3673..7bf14c9a15c7 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -1,18 +1,20 @@
1config VIDEO_CX23885 1config VIDEO_CX23885
2 tristate "Conexant cx23885 (2388x successor) support" 2 tristate "Conexant cx23885 (2388x successor) support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select MEDIA_TUNER 8 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 9 select VIDEO_TVEEPROM
9 select VIDEO_IR 10 select VIDEO_IR
10 select VIDEOBUF_DVB 11 select VIDEOBUF_DVB
11 select VIDEO_CX25840 12 select VIDEO_CX25840
13 select VIDEO_CX2341X
14 select DVB_DIB7000P if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE 15 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE
13 select DVB_S5H1409 if !DVB_FE_CUSTOMISE 16 select DVB_S5H1409 if !DVB_FE_CUSTOMISE
14 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 17 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
15 select DVB_PLL if !DVB_FE_CUSTOMISE
16 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE 18 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE
17 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE 19 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE
18 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE 20 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 6ebf58724a01..20e05f230546 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -200,6 +200,10 @@ struct cx23885_subid cx23885_subids[] = {
200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200, 200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
201 }, { 201 }, {
202 .subvendor = 0x0070, 202 .subvendor = 0x0070,
203 .subdevice = 0x71d3,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
205 }, {
206 .subvendor = 0x0070,
203 .subdevice = 0x8101, 207 .subdevice = 0x8101,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1700, 208 .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
205 }, { 209 }, {
@@ -245,6 +249,33 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
245 /* Make sure we support the board model */ 249 /* Make sure we support the board model */
246 switch (tv.model) 250 switch (tv.model)
247 { 251 {
252 case 71009:
253 /* WinTV-HVR1200 (PCIe, Retail, full height)
254 * DVB-T and basic analog */
255 case 71359:
256 /* WinTV-HVR1200 (PCIe, OEM, half height)
257 * DVB-T and basic analog */
258 case 71439:
259 /* WinTV-HVR1200 (PCIe, OEM, half height)
260 * DVB-T and basic analog */
261 case 71449:
262 /* WinTV-HVR1200 (PCIe, OEM, full height)
263 * DVB-T and basic analog */
264 case 71939:
265 /* WinTV-HVR1200 (PCIe, OEM, half height)
266 * DVB-T and basic analog */
267 case 71949:
268 /* WinTV-HVR1200 (PCIe, OEM, full height)
269 * DVB-T and basic analog */
270 case 71959:
271 /* WinTV-HVR1200 (PCIe, OEM, full height)
272 * DVB-T and basic analog */
273 case 71979:
274 /* WinTV-HVR1200 (PCIe, OEM, half height)
275 * DVB-T and basic analog */
276 case 71999:
277 /* WinTV-HVR1200 (PCIe, OEM, full height)
278 * DVB-T and basic analog */
248 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ 279 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
249 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ 280 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */
250 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ 281 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
@@ -263,8 +294,11 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
263 case 80019: 294 case 80019:
264 /* WinTV-HVR1400 (Express Card, Retail, IR, 295 /* WinTV-HVR1400 (Express Card, Retail, IR,
265 * DVB-T and Basic analog */ 296 * DVB-T and Basic analog */
297 case 81509:
298 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
299 * DVB-T and MPEG2 HW Encoder */
266 case 81519: 300 case 81519:
267 /* WinTV-HVR1700 (PCIe, Retail, No IR, half height, 301 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
268 * DVB-T and MPEG2 HW Encoder */ 302 * DVB-T and MPEG2 HW Encoder */
269 break; 303 break;
270 default: 304 default:
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index f24abcd06dea..c4cc2f3b8876 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -823,7 +823,7 @@ static void cx23885_dev_unregister(struct cx23885_dev *dev)
823 iounmap(dev->lmmio); 823 iounmap(dev->lmmio);
824} 824}
825 825
826static u32* cx23885_risc_field(u32 *rp, struct scatterlist *sglist, 826static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
827 unsigned int offset, u32 sync_line, 827 unsigned int offset, u32 sync_line,
828 unsigned int bpl, unsigned int padding, 828 unsigned int bpl, unsigned int padding,
829 unsigned int lines) 829 unsigned int lines)
@@ -883,7 +883,7 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
883 unsigned int padding, unsigned int lines) 883 unsigned int padding, unsigned int lines)
884{ 884{
885 u32 instructions, fields; 885 u32 instructions, fields;
886 u32 *rp; 886 __le32 *rp;
887 int rc; 887 int rc;
888 888
889 fields = 0; 889 fields = 0;
@@ -924,7 +924,7 @@ static int cx23885_risc_databuffer(struct pci_dev *pci,
924 unsigned int lines) 924 unsigned int lines)
925{ 925{
926 u32 instructions; 926 u32 instructions;
927 u32 *rp; 927 __le32 *rp;
928 int rc; 928 int rc;
929 929
930 /* estimate risc mem: worst case is one write per page border + 930 /* estimate risc mem: worst case is one write per page border +
@@ -951,7 +951,7 @@ static int cx23885_risc_databuffer(struct pci_dev *pci,
951int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 951int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
952 u32 reg, u32 mask, u32 value) 952 u32 reg, u32 mask, u32 value)
953{ 953{
954 u32 *rp; 954 __le32 *rp;
955 int rc; 955 int rc;
956 956
957 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 957 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index f05649727b60..022aa391937a 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -37,7 +37,6 @@
37#include "lgdt330x.h" 37#include "lgdt330x.h"
38#include "xc5000.h" 38#include "xc5000.h"
39#include "tda10048.h" 39#include "tda10048.h"
40#include "dvb-pll.h"
41#include "tuner-xc2028.h" 40#include "tuner-xc2028.h"
42#include "tuner-simple.h" 41#include "tuner-simple.h"
43#include "dib7000p.h" 42#include "dib7000p.h"
@@ -385,12 +384,10 @@ static int dvb_register(struct cx23885_tsport *port)
385 port->dvb.frontend = dvb_attach(s5h1409_attach, 384 port->dvb.frontend = dvb_attach(s5h1409_attach,
386 &hauppauge_hvr1500q_config, 385 &hauppauge_hvr1500q_config,
387 &dev->i2c_bus[0].i2c_adap); 386 &dev->i2c_bus[0].i2c_adap);
388 if (port->dvb.frontend != NULL) { 387 if (port->dvb.frontend != NULL)
389 hauppauge_hvr1500q_tunerconfig.priv = i2c_bus;
390 dvb_attach(xc5000_attach, port->dvb.frontend, 388 dvb_attach(xc5000_attach, port->dvb.frontend,
391 &i2c_bus->i2c_adap, 389 &i2c_bus->i2c_adap,
392 &hauppauge_hvr1500q_tunerconfig); 390 &hauppauge_hvr1500q_tunerconfig, i2c_bus);
393 }
394 break; 391 break;
395 case CX23885_BOARD_HAUPPAUGE_HVR1500: 392 case CX23885_BOARD_HAUPPAUGE_HVR1500:
396 i2c_bus = &dev->i2c_bus[1]; 393 i2c_bus = &dev->i2c_bus[1];
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig
index 7cf29a03ed63..448f4cd0ce34 100644
--- a/drivers/media/video/cx25840/Kconfig
+++ b/drivers/media/video/cx25840/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_CX25840 1config VIDEO_CX25840
2 tristate "Conexant CX2584x audio/video decoders" 2 tristate "Conexant CX2584x audio/video decoders"
3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 ---help--- 6 ---help---
6 Support for the Conexant CX2584x audio/video decoders. 7 Support for the Conexant CX2584x audio/video decoders.
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 88823810497c..607efdcd22f8 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1284,10 +1284,17 @@ static int cx25840_remove(struct i2c_client *client)
1284 return 0; 1284 return 0;
1285} 1285}
1286 1286
1287static const struct i2c_device_id cx25840_id[] = {
1288 { "cx25840", 0 },
1289 { }
1290};
1291MODULE_DEVICE_TABLE(i2c, cx25840_id);
1292
1287static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1293static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1288 .name = "cx25840", 1294 .name = "cx25840",
1289 .driverid = I2C_DRIVERID_CX25840, 1295 .driverid = I2C_DRIVERID_CX25840,
1290 .command = cx25840_command, 1296 .command = cx25840_command,
1291 .probe = cx25840_probe, 1297 .probe = cx25840_probe,
1292 .remove = cx25840_remove, 1298 .remove = cx25840_remove,
1299 .id_table = cx25840_id,
1293}; 1300};
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index b0d7d6a7a4cc..10e20d8196dc 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -2,10 +2,9 @@ config VIDEO_CX88
2 tristate "Conexant 2388x (bt878 successor) support" 2 tristate "Conexant 2388x (bt878 successor) support"
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER
6 select VIDEO_BTCX 5 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 6 select VIDEOBUF_DMA_SG
8 select MEDIA_TUNER 7 select VIDEO_TUNER
9 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
10 select VIDEO_IR 9 select VIDEO_IR
11 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO 10 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO
@@ -34,8 +33,9 @@ config VIDEO_CX88_ALSA
34 33
35config VIDEO_CX88_BLACKBIRD 34config VIDEO_CX88_BLACKBIRD
36 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" 35 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)"
37 depends on VIDEO_CX88 36 depends on VIDEO_CX88 && HOTPLUG
38 select VIDEO_CX2341X 37 select VIDEO_CX2341X
38 select FW_LOADER
39 ---help--- 39 ---help---
40 This adds support for MPEG encoder cards based on the 40 This adds support for MPEG encoder cards based on the
41 Blackbird reference design, using the Conexant 2388x 41 Blackbird reference design, using the Conexant 2388x
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index aeba26dc0a37..fa6d398e97b9 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1493,10 +1493,16 @@ static const struct cx88_board cx88_boards[] = {
1493 }, 1493 },
1494 }, 1494 },
1495 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { 1495 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = {
1496 .name = "PowerColor Real Angel 330", 1496 .name = "PowerColor RA330", /* Long names may confuse LIRC. */
1497 .tuner_type = TUNER_XC2028, 1497 .tuner_type = TUNER_XC2028,
1498 .tuner_addr = 0x61, 1498 .tuner_addr = 0x61,
1499 .input = { { 1499 .input = { {
1500 .type = CX88_VMUX_DEBUG,
1501 .vmux = 3, /* Due to the way the cx88 driver is written, */
1502 .gpio0 = 0x00ff, /* there is no way to deactivate audio pass- */
1503 .gpio1 = 0xf39d, /* through without this entry. Furthermore, if */
1504 .gpio3 = 0x0000, /* the TV mux entry is first, you get audio */
1505 }, { /* from the tuner on boot for a little while. */
1500 .type = CX88_VMUX_TELEVISION, 1506 .type = CX88_VMUX_TELEVISION,
1501 .vmux = 0, 1507 .vmux = 0,
1502 .gpio0 = 0x00ff, 1508 .gpio0 = 0x00ff,
@@ -2424,8 +2430,9 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
2424 2430
2425 switch (core->boardnr) { 2431 switch (core->boardnr) {
2426 case CX88_BOARD_POWERCOLOR_REAL_ANGEL: 2432 case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
2427 /* Doesn't work with firmware version 2.7 */ 2433 /* Now works with firmware version 2.7 */
2428 ctl->fname = "xc3028-v25.fw"; 2434 if (core->i2c_algo.udelay < 16)
2435 core->i2c_algo.udelay = 16;
2429 break; 2436 break;
2430 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 2437 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
2431 ctl->scode_table = XC3028_FE_ZARLINK456; 2438 ctl->scode_table = XC3028_FE_ZARLINK456;
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index c4d1aff1fdb4..60eeda3057e9 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -70,7 +70,7 @@ static DEFINE_MUTEX(devlist);
70 70
71/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be 71/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
72 generated _after_ lpi lines are transferred. */ 72 generated _after_ lpi lines are transferred. */
73static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist, 73static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
74 unsigned int offset, u32 sync_line, 74 unsigned int offset, u32 sync_line,
75 unsigned int bpl, unsigned int padding, 75 unsigned int bpl, unsigned int padding,
76 unsigned int lines, unsigned int lpi) 76 unsigned int lines, unsigned int lpi)
@@ -130,7 +130,7 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
130 unsigned int bpl, unsigned int padding, unsigned int lines) 130 unsigned int bpl, unsigned int padding, unsigned int lines)
131{ 131{
132 u32 instructions,fields; 132 u32 instructions,fields;
133 u32 *rp; 133 __le32 *rp;
134 int rc; 134 int rc;
135 135
136 fields = 0; 136 fields = 0;
@@ -168,7 +168,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
168 unsigned int lines, unsigned int lpi) 168 unsigned int lines, unsigned int lpi)
169{ 169{
170 u32 instructions; 170 u32 instructions;
171 u32 *rp; 171 __le32 *rp;
172 int rc; 172 int rc;
173 173
174 /* estimate risc mem: worst case is one write per page border + 174 /* estimate risc mem: worst case is one write per page border +
@@ -193,7 +193,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
193int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 193int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
194 u32 reg, u32 mask, u32 value) 194 u32 reg, u32 mask, u32 value)
195{ 195{
196 u32 *rp; 196 __le32 *rp;
197 int rc; 197 int rc;
198 198
199 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 199 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 1c7fe6862a60..d96173ff1dba 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -509,9 +509,6 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
509 if (!fe) { 509 if (!fe) {
510 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 510 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
511 dev->core->name); 511 dev->core->name);
512 dvb_frontend_detach(dev->dvb.frontend);
513 dvb_unregister_frontend(dev->dvb.frontend);
514 dev->dvb.frontend = NULL;
515 return -EINVAL; 512 return -EINVAL;
516 } 513 }
517 514
@@ -523,20 +520,23 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
523 520
524static int dvb_register(struct cx8802_dev *dev) 521static int dvb_register(struct cx8802_dev *dev)
525{ 522{
523 struct cx88_core *core = dev->core;
524
526 /* init struct videobuf_dvb */ 525 /* init struct videobuf_dvb */
527 dev->dvb.name = dev->core->name; 526 dev->dvb.name = core->name;
528 dev->ts_gen_cntrl = 0x0c; 527 dev->ts_gen_cntrl = 0x0c;
529 528
530 /* init frontend */ 529 /* init frontend */
531 switch (dev->core->boardnr) { 530 switch (core->boardnr) {
532 case CX88_BOARD_HAUPPAUGE_DVB_T1: 531 case CX88_BOARD_HAUPPAUGE_DVB_T1:
533 dev->dvb.frontend = dvb_attach(cx22702_attach, 532 dev->dvb.frontend = dvb_attach(cx22702_attach,
534 &connexant_refboard_config, 533 &connexant_refboard_config,
535 &dev->core->i2c_adap); 534 &core->i2c_adap);
536 if (dev->dvb.frontend != NULL) { 535 if (dev->dvb.frontend != NULL) {
537 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 536 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
538 &dev->core->i2c_adap, 537 0x61, &core->i2c_adap,
539 DVB_PLL_THOMSON_DTT759X); 538 DVB_PLL_THOMSON_DTT759X))
539 goto frontend_detach;
540 } 540 }
541 break; 541 break;
542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
@@ -545,11 +545,12 @@ static int dvb_register(struct cx8802_dev *dev)
545 case CX88_BOARD_WINFAST_DTV1000: 545 case CX88_BOARD_WINFAST_DTV1000:
546 dev->dvb.frontend = dvb_attach(cx22702_attach, 546 dev->dvb.frontend = dvb_attach(cx22702_attach,
547 &connexant_refboard_config, 547 &connexant_refboard_config,
548 &dev->core->i2c_adap); 548 &core->i2c_adap);
549 if (dev->dvb.frontend != NULL) { 549 if (dev->dvb.frontend != NULL) {
550 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 550 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
551 &dev->core->i2c_adap, 551 0x60, &core->i2c_adap,
552 DVB_PLL_THOMSON_DTT7579); 552 DVB_PLL_THOMSON_DTT7579))
553 goto frontend_detach;
553 } 554 }
554 break; 555 break;
555 case CX88_BOARD_WINFAST_DTV2000H: 556 case CX88_BOARD_WINFAST_DTV2000H:
@@ -559,29 +560,32 @@ static int dvb_register(struct cx8802_dev *dev)
559 case CX88_BOARD_HAUPPAUGE_HVR3000: 560 case CX88_BOARD_HAUPPAUGE_HVR3000:
560 dev->dvb.frontend = dvb_attach(cx22702_attach, 561 dev->dvb.frontend = dvb_attach(cx22702_attach,
561 &hauppauge_hvr_config, 562 &hauppauge_hvr_config,
562 &dev->core->i2c_adap); 563 &core->i2c_adap);
563 if (dev->dvb.frontend != NULL) { 564 if (dev->dvb.frontend != NULL) {
564 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 565 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
565 &dev->core->i2c_adap, 0x61, 566 &core->i2c_adap, 0x61,
566 TUNER_PHILIPS_FMD1216ME_MK3); 567 TUNER_PHILIPS_FMD1216ME_MK3))
568 goto frontend_detach;
567 } 569 }
568 break; 570 break;
569 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 571 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
570 dev->dvb.frontend = dvb_attach(mt352_attach, 572 dev->dvb.frontend = dvb_attach(mt352_attach,
571 &dvico_fusionhdtv, 573 &dvico_fusionhdtv,
572 &dev->core->i2c_adap); 574 &core->i2c_adap);
573 if (dev->dvb.frontend != NULL) { 575 if (dev->dvb.frontend != NULL) {
574 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 576 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
575 NULL, DVB_PLL_THOMSON_DTT7579); 577 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
578 goto frontend_detach;
576 break; 579 break;
577 } 580 }
578 /* ZL10353 replaces MT352 on later cards */ 581 /* ZL10353 replaces MT352 on later cards */
579 dev->dvb.frontend = dvb_attach(zl10353_attach, 582 dev->dvb.frontend = dvb_attach(zl10353_attach,
580 &dvico_fusionhdtv_plus_v1_1, 583 &dvico_fusionhdtv_plus_v1_1,
581 &dev->core->i2c_adap); 584 &core->i2c_adap);
582 if (dev->dvb.frontend != NULL) { 585 if (dev->dvb.frontend != NULL) {
583 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 586 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
584 NULL, DVB_PLL_THOMSON_DTT7579); 587 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
588 goto frontend_detach;
585 } 589 }
586 break; 590 break;
587 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 591 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
@@ -589,28 +593,31 @@ static int dvb_register(struct cx8802_dev *dev)
589 * compatible, with a slightly different MT352 AGC gain. */ 593 * compatible, with a slightly different MT352 AGC gain. */
590 dev->dvb.frontend = dvb_attach(mt352_attach, 594 dev->dvb.frontend = dvb_attach(mt352_attach,
591 &dvico_fusionhdtv_dual, 595 &dvico_fusionhdtv_dual,
592 &dev->core->i2c_adap); 596 &core->i2c_adap);
593 if (dev->dvb.frontend != NULL) { 597 if (dev->dvb.frontend != NULL) {
594 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 598 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
595 NULL, DVB_PLL_THOMSON_DTT7579); 599 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
600 goto frontend_detach;
596 break; 601 break;
597 } 602 }
598 /* ZL10353 replaces MT352 on later cards */ 603 /* ZL10353 replaces MT352 on later cards */
599 dev->dvb.frontend = dvb_attach(zl10353_attach, 604 dev->dvb.frontend = dvb_attach(zl10353_attach,
600 &dvico_fusionhdtv_plus_v1_1, 605 &dvico_fusionhdtv_plus_v1_1,
601 &dev->core->i2c_adap); 606 &core->i2c_adap);
602 if (dev->dvb.frontend != NULL) { 607 if (dev->dvb.frontend != NULL) {
603 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 608 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
604 NULL, DVB_PLL_THOMSON_DTT7579); 609 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
610 goto frontend_detach;
605 } 611 }
606 break; 612 break;
607 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 613 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
608 dev->dvb.frontend = dvb_attach(mt352_attach, 614 dev->dvb.frontend = dvb_attach(mt352_attach,
609 &dvico_fusionhdtv, 615 &dvico_fusionhdtv,
610 &dev->core->i2c_adap); 616 &core->i2c_adap);
611 if (dev->dvb.frontend != NULL) { 617 if (dev->dvb.frontend != NULL) {
612 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 618 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
613 NULL, DVB_PLL_LG_Z201); 619 0x61, NULL, DVB_PLL_LG_Z201))
620 goto frontend_detach;
614 } 621 }
615 break; 622 break;
616 case CX88_BOARD_KWORLD_DVB_T: 623 case CX88_BOARD_KWORLD_DVB_T:
@@ -618,10 +625,11 @@ static int dvb_register(struct cx8802_dev *dev)
618 case CX88_BOARD_ADSTECH_DVB_T_PCI: 625 case CX88_BOARD_ADSTECH_DVB_T_PCI:
619 dev->dvb.frontend = dvb_attach(mt352_attach, 626 dev->dvb.frontend = dvb_attach(mt352_attach,
620 &dntv_live_dvbt_config, 627 &dntv_live_dvbt_config,
621 &dev->core->i2c_adap); 628 &core->i2c_adap);
622 if (dev->dvb.frontend != NULL) { 629 if (dev->dvb.frontend != NULL) {
623 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 630 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
624 NULL, DVB_PLL_UNKNOWN_1); 631 0x61, NULL, DVB_PLL_UNKNOWN_1))
632 goto frontend_detach;
625 } 633 }
626 break; 634 break;
627 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 635 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
@@ -630,32 +638,35 @@ static int dvb_register(struct cx8802_dev *dev)
630 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 638 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
631 &dev->vp3054->adap); 639 &dev->vp3054->adap);
632 if (dev->dvb.frontend != NULL) { 640 if (dev->dvb.frontend != NULL) {
633 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 641 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
634 &dev->core->i2c_adap, 0x61, 642 &core->i2c_adap, 0x61,
635 TUNER_PHILIPS_FMD1216ME_MK3); 643 TUNER_PHILIPS_FMD1216ME_MK3))
644 goto frontend_detach;
636 } 645 }
637#else 646#else
638 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); 647 printk(KERN_ERR "%s/2: built without vp3054 support\n",
648 core->name);
639#endif 649#endif
640 break; 650 break;
641 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
642 dev->dvb.frontend = dvb_attach(zl10353_attach, 652 dev->dvb.frontend = dvb_attach(zl10353_attach,
643 &dvico_fusionhdtv_hybrid, 653 &dvico_fusionhdtv_hybrid,
644 &dev->core->i2c_adap); 654 &core->i2c_adap);
645 if (dev->dvb.frontend != NULL) { 655 if (dev->dvb.frontend != NULL) {
646 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 656 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
647 &dev->core->i2c_adap, 0x61, 657 &core->i2c_adap, 0x61,
648 TUNER_THOMSON_FE6600); 658 TUNER_THOMSON_FE6600))
659 goto frontend_detach;
649 } 660 }
650 break; 661 break;
651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 662 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
652 dev->dvb.frontend = dvb_attach(zl10353_attach, 663 dev->dvb.frontend = dvb_attach(zl10353_attach,
653 &dvico_fusionhdtv_xc3028, 664 &dvico_fusionhdtv_xc3028,
654 &dev->core->i2c_adap); 665 &core->i2c_adap);
655 if (dev->dvb.frontend == NULL) 666 if (dev->dvb.frontend == NULL)
656 dev->dvb.frontend = dvb_attach(mt352_attach, 667 dev->dvb.frontend = dvb_attach(mt352_attach,
657 &dvico_fusionhdtv_mt352_xc3028, 668 &dvico_fusionhdtv_mt352_xc3028,
658 &dev->core->i2c_adap); 669 &core->i2c_adap);
659 /* 670 /*
660 * On this board, the demod provides the I2C bus pullup. 671 * On this board, the demod provides the I2C bus pullup.
661 * We must not permit gate_ctrl to be performed, or 672 * We must not permit gate_ctrl to be performed, or
@@ -668,19 +679,18 @@ static int dvb_register(struct cx8802_dev *dev)
668 break; 679 break;
669 case CX88_BOARD_PCHDTV_HD3000: 680 case CX88_BOARD_PCHDTV_HD3000:
670 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 681 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
671 &dev->core->i2c_adap); 682 &core->i2c_adap);
672 if (dev->dvb.frontend != NULL) { 683 if (dev->dvb.frontend != NULL) {
673 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 684 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
674 &dev->core->i2c_adap, 0x61, 685 &core->i2c_adap, 0x61,
675 TUNER_THOMSON_DTT761X); 686 TUNER_THOMSON_DTT761X))
687 goto frontend_detach;
676 } 688 }
677 break; 689 break;
678 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 690 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
679 dev->ts_gen_cntrl = 0x08; 691 dev->ts_gen_cntrl = 0x08;
680 {
681 /* Do a hardware reset of chip before using it. */
682 struct cx88_core *core = dev->core;
683 692
693 /* Do a hardware reset of chip before using it. */
684 cx_clear(MO_GP0_IO, 1); 694 cx_clear(MO_GP0_IO, 1);
685 mdelay(100); 695 mdelay(100);
686 cx_set(MO_GP0_IO, 1); 696 cx_set(MO_GP0_IO, 1);
@@ -690,139 +700,137 @@ static int dvb_register(struct cx8802_dev *dev)
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 700 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 701 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
692 &fusionhdtv_3_gold, 702 &fusionhdtv_3_gold,
693 &dev->core->i2c_adap); 703 &core->i2c_adap);
694 if (dev->dvb.frontend != NULL) { 704 if (dev->dvb.frontend != NULL) {
695 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 705 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
696 &dev->core->i2c_adap, 0x61, 706 &core->i2c_adap, 0x61,
697 TUNER_MICROTUNE_4042FI5); 707 TUNER_MICROTUNE_4042FI5))
698 } 708 goto frontend_detach;
699 } 709 }
700 break; 710 break;
701 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 711 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
702 dev->ts_gen_cntrl = 0x08; 712 dev->ts_gen_cntrl = 0x08;
703 {
704 /* Do a hardware reset of chip before using it. */
705 struct cx88_core *core = dev->core;
706 713
714 /* Do a hardware reset of chip before using it. */
707 cx_clear(MO_GP0_IO, 1); 715 cx_clear(MO_GP0_IO, 1);
708 mdelay(100); 716 mdelay(100);
709 cx_set(MO_GP0_IO, 9); 717 cx_set(MO_GP0_IO, 9);
710 mdelay(200); 718 mdelay(200);
711 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 719 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
712 &fusionhdtv_3_gold, 720 &fusionhdtv_3_gold,
713 &dev->core->i2c_adap); 721 &core->i2c_adap);
714 if (dev->dvb.frontend != NULL) { 722 if (dev->dvb.frontend != NULL) {
715 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 723 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
716 &dev->core->i2c_adap, 0x61, 724 &core->i2c_adap, 0x61,
717 TUNER_THOMSON_DTT761X); 725 TUNER_THOMSON_DTT761X))
718 } 726 goto frontend_detach;
719 } 727 }
720 break; 728 break;
721 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 729 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
722 dev->ts_gen_cntrl = 0x08; 730 dev->ts_gen_cntrl = 0x08;
723 {
724 /* Do a hardware reset of chip before using it. */
725 struct cx88_core *core = dev->core;
726 731
732 /* Do a hardware reset of chip before using it. */
727 cx_clear(MO_GP0_IO, 1); 733 cx_clear(MO_GP0_IO, 1);
728 mdelay(100); 734 mdelay(100);
729 cx_set(MO_GP0_IO, 1); 735 cx_set(MO_GP0_IO, 1);
730 mdelay(200); 736 mdelay(200);
731 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 737 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
732 &fusionhdtv_5_gold, 738 &fusionhdtv_5_gold,
733 &dev->core->i2c_adap); 739 &core->i2c_adap);
734 if (dev->dvb.frontend != NULL) { 740 if (dev->dvb.frontend != NULL) {
735 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 741 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
736 &dev->core->i2c_adap, 0x61, 742 &core->i2c_adap, 0x61,
737 TUNER_LG_TDVS_H06XF); 743 TUNER_LG_TDVS_H06XF))
738 dvb_attach(tda9887_attach, dev->dvb.frontend, 744 goto frontend_detach;
739 &dev->core->i2c_adap, 0x43); 745 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
740 } 746 &core->i2c_adap, 0x43))
747 goto frontend_detach;
741 } 748 }
742 break; 749 break;
743 case CX88_BOARD_PCHDTV_HD5500: 750 case CX88_BOARD_PCHDTV_HD5500:
744 dev->ts_gen_cntrl = 0x08; 751 dev->ts_gen_cntrl = 0x08;
745 {
746 /* Do a hardware reset of chip before using it. */
747 struct cx88_core *core = dev->core;
748 752
753 /* Do a hardware reset of chip before using it. */
749 cx_clear(MO_GP0_IO, 1); 754 cx_clear(MO_GP0_IO, 1);
750 mdelay(100); 755 mdelay(100);
751 cx_set(MO_GP0_IO, 1); 756 cx_set(MO_GP0_IO, 1);
752 mdelay(200); 757 mdelay(200);
753 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 758 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
754 &pchdtv_hd5500, 759 &pchdtv_hd5500,
755 &dev->core->i2c_adap); 760 &core->i2c_adap);
756 if (dev->dvb.frontend != NULL) { 761 if (dev->dvb.frontend != NULL) {
757 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 762 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
758 &dev->core->i2c_adap, 0x61, 763 &core->i2c_adap, 0x61,
759 TUNER_LG_TDVS_H06XF); 764 TUNER_LG_TDVS_H06XF))
760 dvb_attach(tda9887_attach, dev->dvb.frontend, 765 goto frontend_detach;
761 &dev->core->i2c_adap, 0x43); 766 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
762 } 767 &core->i2c_adap, 0x43))
768 goto frontend_detach;
763 } 769 }
764 break; 770 break;
765 case CX88_BOARD_ATI_HDTVWONDER: 771 case CX88_BOARD_ATI_HDTVWONDER:
766 dev->dvb.frontend = dvb_attach(nxt200x_attach, 772 dev->dvb.frontend = dvb_attach(nxt200x_attach,
767 &ati_hdtvwonder, 773 &ati_hdtvwonder,
768 &dev->core->i2c_adap); 774 &core->i2c_adap);
769 if (dev->dvb.frontend != NULL) { 775 if (dev->dvb.frontend != NULL) {
770 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 776 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
771 &dev->core->i2c_adap, 0x61, 777 &core->i2c_adap, 0x61,
772 TUNER_PHILIPS_TUV1236D); 778 TUNER_PHILIPS_TUV1236D))
779 goto frontend_detach;
773 } 780 }
774 break; 781 break;
775 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 782 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
776 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 783 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
777 dev->dvb.frontend = dvb_attach(cx24123_attach, 784 dev->dvb.frontend = dvb_attach(cx24123_attach,
778 &hauppauge_novas_config, 785 &hauppauge_novas_config,
779 &dev->core->i2c_adap); 786 &core->i2c_adap);
780 if (dev->dvb.frontend) { 787 if (dev->dvb.frontend) {
781 dvb_attach(isl6421_attach, dev->dvb.frontend, 788 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
782 &dev->core->i2c_adap, 0x08, 0x00, 0x00); 789 &core->i2c_adap, 0x08, 0x00, 0x00))
790 goto frontend_detach;
783 } 791 }
784 break; 792 break;
785 case CX88_BOARD_KWORLD_DVBS_100: 793 case CX88_BOARD_KWORLD_DVBS_100:
786 dev->dvb.frontend = dvb_attach(cx24123_attach, 794 dev->dvb.frontend = dvb_attach(cx24123_attach,
787 &kworld_dvbs_100_config, 795 &kworld_dvbs_100_config,
788 &dev->core->i2c_adap); 796 &core->i2c_adap);
789 if (dev->dvb.frontend) { 797 if (dev->dvb.frontend) {
790 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 798 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
791 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 799 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
792 } 800 }
793 break; 801 break;
794 case CX88_BOARD_GENIATECH_DVBS: 802 case CX88_BOARD_GENIATECH_DVBS:
795 dev->dvb.frontend = dvb_attach(cx24123_attach, 803 dev->dvb.frontend = dvb_attach(cx24123_attach,
796 &geniatech_dvbs_config, 804 &geniatech_dvbs_config,
797 &dev->core->i2c_adap); 805 &core->i2c_adap);
798 if (dev->dvb.frontend) { 806 if (dev->dvb.frontend) {
799 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 807 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
800 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 808 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
801 } 809 }
802 break; 810 break;
803 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 811 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
804 dev->dvb.frontend = dvb_attach(s5h1409_attach, 812 dev->dvb.frontend = dvb_attach(s5h1409_attach,
805 &pinnacle_pctv_hd_800i_config, 813 &pinnacle_pctv_hd_800i_config,
806 &dev->core->i2c_adap); 814 &core->i2c_adap);
807 if (dev->dvb.frontend != NULL) { 815 if (dev->dvb.frontend != NULL) {
808 /* tuner_config.video_dev must point to 816 /* tuner_config.video_dev must point to
809 * i2c_adap.algo_data 817 * i2c_adap.algo_data
810 */ 818 */
811 pinnacle_pctv_hd_800i_tuner_config.priv = 819 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
812 dev->core->i2c_adap.algo_data; 820 &core->i2c_adap,
813 dvb_attach(xc5000_attach, dev->dvb.frontend, 821 &pinnacle_pctv_hd_800i_tuner_config,
814 &dev->core->i2c_adap, 822 core->i2c_adap.algo_data))
815 &pinnacle_pctv_hd_800i_tuner_config); 823 goto frontend_detach;
816 } 824 }
817 break; 825 break;
818 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 826 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
819 dev->dvb.frontend = dvb_attach(s5h1409_attach, 827 dev->dvb.frontend = dvb_attach(s5h1409_attach,
820 &dvico_hdtv5_pci_nano_config, 828 &dvico_hdtv5_pci_nano_config,
821 &dev->core->i2c_adap); 829 &core->i2c_adap);
822 if (dev->dvb.frontend != NULL) { 830 if (dev->dvb.frontend != NULL) {
823 struct dvb_frontend *fe; 831 struct dvb_frontend *fe;
824 struct xc2028_config cfg = { 832 struct xc2028_config cfg = {
825 .i2c_adap = &dev->core->i2c_adap, 833 .i2c_adap = &core->i2c_adap,
826 .i2c_addr = 0x61, 834 .i2c_addr = 0x61,
827 .callback = cx88_pci_nano_callback, 835 .callback = cx88_pci_nano_callback,
828 }; 836 };
@@ -841,50 +849,50 @@ static int dvb_register(struct cx8802_dev *dev)
841 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 849 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
842 dev->dvb.frontend = dvb_attach(zl10353_attach, 850 dev->dvb.frontend = dvb_attach(zl10353_attach,
843 &cx88_geniatech_x8000_mt, 851 &cx88_geniatech_x8000_mt,
844 &dev->core->i2c_adap); 852 &core->i2c_adap);
845 if (attach_xc3028(0x61, dev) < 0) 853 if (attach_xc3028(0x61, dev) < 0)
846 return -EINVAL; 854 goto frontend_detach;
847 break; 855 break;
848 case CX88_BOARD_GENIATECH_X8000_MT: 856 case CX88_BOARD_GENIATECH_X8000_MT:
849 dev->ts_gen_cntrl = 0x00; 857 dev->ts_gen_cntrl = 0x00;
850 858
851 dev->dvb.frontend = dvb_attach(zl10353_attach, 859 dev->dvb.frontend = dvb_attach(zl10353_attach,
852 &cx88_geniatech_x8000_mt, 860 &cx88_geniatech_x8000_mt,
853 &dev->core->i2c_adap); 861 &core->i2c_adap);
854 if (attach_xc3028(0x61, dev) < 0) 862 if (attach_xc3028(0x61, dev) < 0)
855 return -EINVAL; 863 goto frontend_detach;
856 break; 864 break;
857 case CX88_BOARD_KWORLD_ATSC_120: 865 case CX88_BOARD_KWORLD_ATSC_120:
858 dev->dvb.frontend = dvb_attach(s5h1409_attach, 866 dev->dvb.frontend = dvb_attach(s5h1409_attach,
859 &kworld_atsc_120_config, 867 &kworld_atsc_120_config,
860 &dev->core->i2c_adap); 868 &core->i2c_adap);
861 if (attach_xc3028(0x61, dev) < 0) 869 if (attach_xc3028(0x61, dev) < 0)
862 return -EINVAL; 870 goto frontend_detach;
863 break; 871 break;
864 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 872 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
865 dev->dvb.frontend = dvb_attach(s5h1411_attach, 873 dev->dvb.frontend = dvb_attach(s5h1411_attach,
866 &dvico_fusionhdtv7_config, 874 &dvico_fusionhdtv7_config,
867 &dev->core->i2c_adap); 875 &core->i2c_adap);
868 if (dev->dvb.frontend != NULL) { 876 if (dev->dvb.frontend != NULL) {
869 /* tuner_config.video_dev must point to 877 /* tuner_config.video_dev must point to
870 * i2c_adap.algo_data 878 * i2c_adap.algo_data
871 */ 879 */
872 dvico_fusionhdtv7_tuner_config.priv = 880 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
873 dev->core->i2c_adap.algo_data; 881 &core->i2c_adap,
874 dvb_attach(xc5000_attach, dev->dvb.frontend, 882 &dvico_fusionhdtv7_tuner_config,
875 &dev->core->i2c_adap, 883 core->i2c_adap.algo_data))
876 &dvico_fusionhdtv7_tuner_config); 884 goto frontend_detach;
877 } 885 }
878 break; 886 break;
879 default: 887 default:
880 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 888 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
881 dev->core->name); 889 core->name);
882 break; 890 break;
883 } 891 }
884 if (NULL == dev->dvb.frontend) { 892 if (NULL == dev->dvb.frontend) {
885 printk(KERN_ERR 893 printk(KERN_ERR
886 "%s/2: frontend initialization failed\n", 894 "%s/2: frontend initialization failed\n",
887 dev->core->name); 895 core->name);
888 return -EINVAL; 896 return -EINVAL;
889 } 897 }
890 898
@@ -892,11 +900,18 @@ static int dvb_register(struct cx8802_dev *dev)
892 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 900 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
893 901
894 /* Put the analog decoder in standby to keep it quiet */ 902 /* Put the analog decoder in standby to keep it quiet */
895 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); 903 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
896 904
897 /* register everything */ 905 /* register everything */
898 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 906 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
899 &dev->pci->dev, adapter_nr); 907 &dev->pci->dev, adapter_nr);
908
909frontend_detach:
910 if (dev->dvb.frontend) {
911 dvb_frontend_detach(dev->dvb.frontend);
912 dev->dvb.frontend = NULL;
913 }
914 return -EINVAL;
900} 915}
901 916
902/* ----------------------------------------------------------- */ 917/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index c7c2896bbd8b..16a5af30e9d1 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM28xx USB video capture support" 2 tristate "Empia EM28xx USB video capture support"
3 depends on VIDEO_DEV && I2C && INPUT 3 depends on VIDEO_DEV && I2C && INPUT
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_TVEEPROM 5 select VIDEO_TVEEPROM
6 select VIDEO_IR 6 select VIDEO_IR
7 select VIDEOBUF_VMALLOC 7 select VIDEOBUF_VMALLOC
@@ -35,7 +35,6 @@ config VIDEO_EM28XX_DVB
35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
37 select VIDEOBUF_DVB 37 select VIDEOBUF_DVB
38 select FW_LOADER
39 ---help--- 38 ---help---
40 This adds support for DVB cards based on the 39 This adds support for DVB cards based on the
41 Empiatech em28xx chips. 40 Empiatech em28xx chips.
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 50ccf3771204..3e4f3c7e92e7 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -420,7 +420,13 @@ struct usb_device_id em28xx_id_table [] = {
420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
421 { USB_DEVICE(0x2040, 0x6502), 421 { USB_DEVICE(0x2040, 0x6502),
422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
423 { USB_DEVICE(0x2040, 0x6513), 423 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
426 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
427 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
428 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
429 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 430 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x0ccd, 0x0042), 431 { USB_DEVICE(0x0ccd, 0x0042),
426 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, 432 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 7df81575b7f2..8cf4983f0039 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -251,7 +251,6 @@ static int attach_xc3028(u8 addr, struct em28xx *dev)
251 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 251 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
252 dev->name); 252 dev->name);
253 dvb_frontend_detach(dev->dvb->frontend); 253 dvb_frontend_detach(dev->dvb->frontend);
254 dvb_unregister_frontend(dev->dvb->frontend);
255 dev->dvb->frontend = NULL; 254 dev->dvb->frontend = NULL;
256 return -EINVAL; 255 return -EINVAL;
257 } 256 }
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 8996175cc950..fb163ecd9216 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1166,13 +1166,13 @@ static int vidioc_g_register(struct file *file, void *priv,
1166 1166
1167 reg->val = ret; 1167 reg->val = ret;
1168 } else { 1168 } else {
1169 u64 val = 0; 1169 __le64 val = 0;
1170 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, 1170 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
1171 reg->reg, (char *)&val, 2); 1171 reg->reg, (char *)&val, 2);
1172 if (ret < 0) 1172 if (ret < 0)
1173 return ret; 1173 return ret;
1174 1174
1175 reg->val = cpu_to_le64((__u64)val); 1175 reg->val = le64_to_cpu(val);
1176 } 1176 }
1177 1177
1178 return 0; 1178 return 0;
@@ -1183,9 +1183,9 @@ static int vidioc_s_register(struct file *file, void *priv,
1183{ 1183{
1184 struct em28xx_fh *fh = priv; 1184 struct em28xx_fh *fh = priv;
1185 struct em28xx *dev = fh->dev; 1185 struct em28xx *dev = fh->dev;
1186 u64 buf; 1186 __le64 buf;
1187 1187
1188 buf = le64_to_cpu((__u64)reg->val); 1188 buf = cpu_to_le64(reg->val);
1189 1189
1190 return em28xx_write_regs(dev, reg->reg, (char *)&buf, 1190 return em28xx_write_regs(dev, reg->reg, (char *)&buf,
1191 em28xx_reg_len(reg->reg)); 1191 em28xx_reg_len(reg->reg));
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 5e749c528a62..15d037ae25c5 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -34,7 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/page-flags.h> 36#include <linux/page-flags.h>
37#include <linux/byteorder/generic.h> 37#include <asm/byteorder.h>
38#include <asm/page.h> 38#include <asm/page.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index eec115bf9517..5d7ee8fcdd50 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,10 +1,12 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CX25840 12 select VIDEO_CX25840
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c
index 8c02fa661591..c7e449f6397b 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -181,12 +181,12 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm
181 return 0; 181 return 0;
182 } 182 }
183 /* Need sliced data for mpeg insertion */ 183 /* Need sliced data for mpeg insertion */
184 if (get_service_set(itv->vbi.sliced_in) == 0) { 184 if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
185 if (itv->is_60hz) 185 if (itv->is_60hz)
186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; 186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;
187 else 187 else
188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; 188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
189 expand_service_set(itv->vbi.sliced_in, itv->is_50hz); 189 ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
190 } 190 }
191 return 0; 191 return 0;
192} 192}
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index ed020f722b05..797e636771da 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -853,6 +853,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
853 return 0; 853 return 0;
854} 854}
855 855
856#ifdef MODULE
856static u32 ivtv_request_module(struct ivtv *itv, u32 hw, 857static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
857 const char *name, u32 id) 858 const char *name, u32 id)
858{ 859{
@@ -865,12 +866,14 @@ static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
865 IVTV_DEBUG_INFO("Loaded module %s\n", name); 866 IVTV_DEBUG_INFO("Loaded module %s\n", name);
866 return hw; 867 return hw;
867} 868}
869#endif
868 870
869static void ivtv_load_and_init_modules(struct ivtv *itv) 871static void ivtv_load_and_init_modules(struct ivtv *itv)
870{ 872{
871 u32 hw = itv->card->hw_all; 873 u32 hw = itv->card->hw_all;
872 unsigned i; 874 unsigned i;
873 875
876#ifdef MODULE
874 /* load modules */ 877 /* load modules */
875#ifndef CONFIG_MEDIA_TUNER 878#ifndef CONFIG_MEDIA_TUNER
876 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); 879 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
@@ -911,6 +914,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
911#ifndef CONFIG_VIDEO_M52790 914#ifndef CONFIG_VIDEO_M52790
912 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); 915 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
913#endif 916#endif
917#endif
914 918
915 /* check which i2c devices are actually found */ 919 /* check which i2c devices are actually found */
916 for (i = 0; i < 32; i++) { 920 for (i = 0; i < 32; i++) {
@@ -1228,7 +1232,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1228 return 0; 1232 return 0;
1229 1233
1230free_streams: 1234free_streams:
1231 ivtv_streams_cleanup(itv); 1235 ivtv_streams_cleanup(itv, 1);
1232free_irq: 1236free_irq:
1233 free_irq(itv->dev->irq, (void *)itv); 1237 free_irq(itv->dev->irq, (void *)itv);
1234free_i2c: 1238free_i2c:
@@ -1373,7 +1377,7 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1373 flush_workqueue(itv->irq_work_queues); 1377 flush_workqueue(itv->irq_work_queues);
1374 destroy_workqueue(itv->irq_work_queues); 1378 destroy_workqueue(itv->irq_work_queues);
1375 1379
1376 ivtv_streams_cleanup(itv); 1380 ivtv_streams_cleanup(itv, 1);
1377 ivtv_udma_free(itv); 1381 ivtv_udma_free(itv);
1378 1382
1379 exit_ivtv_i2c(itv); 1383 exit_ivtv_i2c(itv);
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index ba06e813c58c..9d23b1efd36d 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -259,6 +259,12 @@ struct ivtv_mailbox_data {
259 259
260/* Scatter-Gather array element, used in DMA transfers */ 260/* Scatter-Gather array element, used in DMA transfers */
261struct ivtv_sg_element { 261struct ivtv_sg_element {
262 __le32 src;
263 __le32 dst;
264 __le32 size;
265};
266
267struct ivtv_sg_host_element {
262 u32 src; 268 u32 src;
263 u32 dst; 269 u32 dst;
264 u32 size; 270 u32 size;
@@ -349,8 +355,8 @@ struct ivtv_stream {
349 u16 dma_xfer_cnt; 355 u16 dma_xfer_cnt;
350 356
351 /* Base Dev SG Array for cx23415/6 */ 357 /* Base Dev SG Array for cx23415/6 */
352 struct ivtv_sg_element *sg_pending; 358 struct ivtv_sg_host_element *sg_pending;
353 struct ivtv_sg_element *sg_processing; 359 struct ivtv_sg_host_element *sg_processing;
354 struct ivtv_sg_element *sg_dma; 360 struct ivtv_sg_element *sg_dma;
355 dma_addr_t sg_handle; 361 dma_addr_t sg_handle;
356 int sg_pending_size; 362 int sg_pending_size;
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 2b74b0ab1477..db813e071ce6 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -587,7 +587,7 @@ retry:
587 since we may get here before the stream has been fully set-up */ 587 since we may get here before the stream has been fully set-up */
588 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { 588 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) {
589 while (count >= itv->dma_data_req_size) { 589 while (count >= itv->dma_data_req_size) {
590 if (!ivtv_yuv_udma_stream_frame (itv, (void *)user_buf)) { 590 if (!ivtv_yuv_udma_stream_frame (itv, (void __user *)user_buf)) {
591 bytes_written += itv->dma_data_req_size; 591 bytes_written += itv->dma_data_req_size;
592 user_buf += itv->dma_data_req_size; 592 user_buf += itv->dma_data_req_size;
593 count -= itv->dma_data_req_size; 593 count -= itv->dma_data_req_size;
@@ -987,6 +987,8 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
987 /* Find which card this open was on */ 987 /* Find which card this open was on */
988 spin_lock(&ivtv_cards_lock); 988 spin_lock(&ivtv_cards_lock);
989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { 989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) {
990 if (ivtv_cards[x] == NULL)
991 continue;
990 /* find out which stream this open was on */ 992 /* find out which stream this open was on */
991 for (y = 0; y < IVTV_MAX_STREAMS; y++) { 993 for (y = 0; y < IVTV_MAX_STREAMS; y++) {
992 s = &ivtv_cards[x]->streams[y]; 994 s = &ivtv_cards[x]->streams[y];
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 771adf47e944..32129f3ea836 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -136,7 +136,7 @@ static const u8 hw_addrs[] = {
136}; 136};
137 137
138/* This array should match the IVTV_HW_ defines */ 138/* This array should match the IVTV_HW_ defines */
139static const char * const hw_drivernames[] = { 139static const char * const hw_devicenames[] = {
140 "cx25840", 140 "cx25840",
141 "saa7115", 141 "saa7115",
142 "saa7127", 142 "saa7127",
@@ -145,7 +145,7 @@ static const char * const hw_drivernames[] = {
145 "wm8775", 145 "wm8775",
146 "cs53l32a", 146 "cs53l32a",
147 "tveeprom", 147 "tveeprom",
148 "saa7115", 148 "saa7114",
149 "upd64031a", 149 "upd64031a",
150 "upd64083", 150 "upd64083",
151 "saa717x", 151 "saa717x",
@@ -167,8 +167,7 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
167 return -1; 167 return -1;
168 id = hw_driverids[idx]; 168 id = hw_driverids[idx];
169 memset(&info, 0, sizeof(info)); 169 memset(&info, 0, sizeof(info));
170 strlcpy(info.driver_name, hw_drivernames[idx], 170 strlcpy(info.type, hw_devicenames[idx], sizeof(info.type));
171 sizeof(info.driver_name));
172 info.addr = hw_addrs[idx]; 171 info.addr = hw_addrs[idx];
173 for (i = 0; itv->i2c_clients[i] && i < I2C_CLIENTS_MAX; i++) {} 172 for (i = 0; itv->i2c_clients[i] && i < I2C_CLIENTS_MAX; i++) {}
174 173
@@ -657,7 +656,7 @@ static const char *ivtv_i2c_id_name(u32 id)
657 656
658 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) 657 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
659 if (hw_driverids[i] == id) 658 if (hw_driverids[i] == id)
660 return hw_drivernames[i]; 659 return hw_devicenames[i];
661 return "unknown device"; 660 return "unknown device";
662} 661}
663 662
@@ -668,7 +667,7 @@ static const char *ivtv_i2c_hw_name(u32 hw)
668 667
669 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) 668 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
670 if (1 << i == hw) 669 if (1 << i == hw)
671 return hw_drivernames[i]; 670 return hw_devicenames[i];
672 return "unknown device"; 671 return "unknown device";
673} 672}
674 673
@@ -770,7 +769,7 @@ int init_ivtv_i2c(struct ivtv *itv)
770 * same size and GPIO must be the last entry. 769 * same size and GPIO must be the last entry.
771 */ 770 */
772 if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) || 771 if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) ||
773 ARRAY_SIZE(hw_drivernames) != ARRAY_SIZE(hw_addrs) || 772 ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) ||
774 IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1)) || 773 IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1)) ||
775 hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) { 774 hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) {
776 IVTV_ERR("Mismatched I2C hardware arrays\n"); 775 IVTV_ERR("Mismatched I2C hardware arrays\n");
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index d508b5d0538c..26cc0f6699fd 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -38,7 +38,7 @@
38#include <linux/dvb/audio.h> 38#include <linux/dvb/audio.h>
39#include <linux/i2c-id.h> 39#include <linux/i2c-id.h>
40 40
41u16 service2vbi(int type) 41u16 ivtv_service2vbi(int type)
42{ 42{
43 switch (type) { 43 switch (type) {
44 case V4L2_SLICED_TELETEXT_B: 44 case V4L2_SLICED_TELETEXT_B:
@@ -88,7 +88,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
88 return 0; 88 return 0;
89} 89}
90 90
91void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) 91void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
92{ 92{
93 u16 set = fmt->service_set; 93 u16 set = fmt->service_set;
94 int f, l; 94 int f, l;
@@ -115,7 +115,7 @@ static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
115 return set != 0; 115 return set != 0;
116} 116}
117 117
118u16 get_service_set(struct v4l2_sliced_vbi_format *fmt) 118u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt)
119{ 119{
120 int f, l; 120 int f, l;
121 u16 set = 0; 121 u16 set = 0;
@@ -466,7 +466,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; 466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625;
467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; 467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS;
468 } 468 }
469 vbifmt->service_set = get_service_set(vbifmt); 469 vbifmt->service_set = ivtv_get_service_set(vbifmt);
470 break; 470 break;
471 } 471 }
472 472
@@ -481,12 +481,12 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) { 481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) {
482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : 482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 :
483 V4L2_SLICED_VBI_525; 483 V4L2_SLICED_VBI_525;
484 expand_service_set(vbifmt, itv->is_50hz); 484 ivtv_expand_service_set(vbifmt, itv->is_50hz);
485 break; 485 break;
486 } 486 }
487 487
488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); 488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt);
489 vbifmt->service_set = get_service_set(vbifmt); 489 vbifmt->service_set = ivtv_get_service_set(vbifmt);
490 break; 490 break;
491 } 491 }
492 case V4L2_BUF_TYPE_VBI_OUTPUT: 492 case V4L2_BUF_TYPE_VBI_OUTPUT:
@@ -640,9 +640,9 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); 640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved));
641 641
642 if (vbifmt->service_set) 642 if (vbifmt->service_set)
643 expand_service_set(vbifmt, itv->is_50hz); 643 ivtv_expand_service_set(vbifmt, itv->is_50hz);
644 set = check_service_set(vbifmt, itv->is_50hz); 644 set = check_service_set(vbifmt, itv->is_50hz);
645 vbifmt->service_set = get_service_set(vbifmt); 645 vbifmt->service_set = ivtv_get_service_set(vbifmt);
646 646
647 if (!set_fmt) 647 if (!set_fmt)
648 return 0; 648 return 0;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h
index a03351b6853d..4e67f0ed1fc0 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.h
+++ b/drivers/media/video/ivtv/ivtv-ioctl.h
@@ -21,9 +21,9 @@
21#ifndef IVTV_IOCTL_H 21#ifndef IVTV_IOCTL_H
22#define IVTV_IOCTL_H 22#define IVTV_IOCTL_H
23 23
24u16 service2vbi(int type); 24u16 ivtv_service2vbi(int type);
25void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); 25void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
26u16 get_service_set(struct v4l2_sliced_vbi_format *fmt); 26u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
28 unsigned long arg); 28 unsigned long arg);
29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg); 29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg);
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index d8ba3a4a8761..fba150a6cd23 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -231,14 +231,14 @@ static void dma_post(struct ivtv_stream *s)
231 struct ivtv_buffer *buf = NULL; 231 struct ivtv_buffer *buf = NULL;
232 struct list_head *p; 232 struct list_head *p;
233 u32 offset; 233 u32 offset;
234 u32 *u32buf; 234 __le32 *u32buf;
235 int x = 0; 235 int x = 0;
236 236
237 IVTV_DEBUG_HI_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA", 237 IVTV_DEBUG_HI_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA",
238 s->name, s->dma_offset); 238 s->name, s->dma_offset);
239 list_for_each(p, &s->q_dma.list) { 239 list_for_each(p, &s->q_dma.list) {
240 buf = list_entry(p, struct ivtv_buffer, list); 240 buf = list_entry(p, struct ivtv_buffer, list);
241 u32buf = (u32 *)buf->buf; 241 u32buf = (__le32 *)buf->buf;
242 242
243 /* Sync Buffer */ 243 /* Sync Buffer */
244 ivtv_buf_sync_for_cpu(s, buf); 244 ivtv_buf_sync_for_cpu(s, buf);
@@ -444,7 +444,7 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
444 } 444 }
445 445
446 s->dma_xfer_cnt++; 446 s->dma_xfer_cnt++;
447 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_element) * s->sg_pending_size); 447 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_host_element) * s->sg_pending_size);
448 s->sg_processing_size = s->sg_pending_size; 448 s->sg_processing_size = s->sg_pending_size;
449 s->sg_pending_size = 0; 449 s->sg_pending_size = 0;
450 s->sg_processed = 0; 450 s->sg_processed = 0;
@@ -473,7 +473,7 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s)
473 if (s->q_predma.bytesused) 473 if (s->q_predma.bytesused)
474 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused); 474 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
475 s->dma_xfer_cnt++; 475 s->dma_xfer_cnt++;
476 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_element) * s->sg_pending_size); 476 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_host_element) * s->sg_pending_size);
477 s->sg_processing_size = s->sg_pending_size; 477 s->sg_processing_size = s->sg_pending_size;
478 s->sg_pending_size = 0; 478 s->sg_pending_size = 0;
479 s->sg_processed = 0; 479 s->sg_processed = 0;
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index 3e1deec67a5e..71bd13e22e2e 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -193,7 +193,7 @@ void ivtv_flush_queues(struct ivtv_stream *s)
193int ivtv_stream_alloc(struct ivtv_stream *s) 193int ivtv_stream_alloc(struct ivtv_stream *s)
194{ 194{
195 struct ivtv *itv = s->itv; 195 struct ivtv *itv = s->itv;
196 int SGsize = sizeof(struct ivtv_sg_element) * s->buffers; 196 int SGsize = sizeof(struct ivtv_sg_host_element) * s->buffers;
197 int i; 197 int i;
198 198
199 if (s->buffers == 0) 199 if (s->buffers == 0)
@@ -203,14 +203,14 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
203 s->dma != PCI_DMA_NONE ? "DMA " : "", 203 s->dma != PCI_DMA_NONE ? "DMA " : "",
204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); 204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
205 205
206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL); 206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
207 if (s->sg_pending == NULL) { 207 if (s->sg_pending == NULL) {
208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); 208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name);
209 return -ENOMEM; 209 return -ENOMEM;
210 } 210 }
211 s->sg_pending_size = 0; 211 s->sg_pending_size = 0;
212 212
213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL); 213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
214 if (s->sg_processing == NULL) { 214 if (s->sg_processing == NULL) {
215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); 215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name);
216 kfree(s->sg_pending); 216 kfree(s->sg_pending);
@@ -219,7 +219,8 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
219 } 219 }
220 s->sg_processing_size = 0; 220 s->sg_processing_size = 0;
221 221
222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), GFP_KERNEL); 222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element),
223 GFP_KERNEL|__GFP_NOWARN);
223 if (s->sg_dma == NULL) { 224 if (s->sg_dma == NULL) {
224 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); 225 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name);
225 kfree(s->sg_pending); 226 kfree(s->sg_pending);
@@ -235,11 +236,12 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
235 236
236 /* allocate stream buffers. Initially all buffers are in q_free. */ 237 /* allocate stream buffers. Initially all buffers are in q_free. */
237 for (i = 0; i < s->buffers; i++) { 238 for (i = 0; i < s->buffers; i++) {
238 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer), GFP_KERNEL); 239 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer),
240 GFP_KERNEL|__GFP_NOWARN);
239 241
240 if (buf == NULL) 242 if (buf == NULL)
241 break; 243 break;
242 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL); 244 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN);
243 if (buf->buf == NULL) { 245 if (buf->buf == NULL) {
244 kfree(buf); 246 kfree(buf);
245 break; 247 break;
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 4ab8d36831ba..c854285a4371 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -44,23 +44,25 @@
44#include "ivtv-streams.h" 44#include "ivtv-streams.h"
45 45
46static const struct file_operations ivtv_v4l2_enc_fops = { 46static const struct file_operations ivtv_v4l2_enc_fops = {
47 .owner = THIS_MODULE, 47 .owner = THIS_MODULE,
48 .read = ivtv_v4l2_read, 48 .read = ivtv_v4l2_read,
49 .write = ivtv_v4l2_write, 49 .write = ivtv_v4l2_write,
50 .open = ivtv_v4l2_open, 50 .open = ivtv_v4l2_open,
51 .ioctl = ivtv_v4l2_ioctl, 51 .ioctl = ivtv_v4l2_ioctl,
52 .release = ivtv_v4l2_close, 52 .compat_ioctl = v4l_compat_ioctl32,
53 .poll = ivtv_v4l2_enc_poll, 53 .release = ivtv_v4l2_close,
54 .poll = ivtv_v4l2_enc_poll,
54}; 55};
55 56
56static const struct file_operations ivtv_v4l2_dec_fops = { 57static const struct file_operations ivtv_v4l2_dec_fops = {
57 .owner = THIS_MODULE, 58 .owner = THIS_MODULE,
58 .read = ivtv_v4l2_read, 59 .read = ivtv_v4l2_read,
59 .write = ivtv_v4l2_write, 60 .write = ivtv_v4l2_write,
60 .open = ivtv_v4l2_open, 61 .open = ivtv_v4l2_open,
61 .ioctl = ivtv_v4l2_ioctl, 62 .ioctl = ivtv_v4l2_ioctl,
62 .release = ivtv_v4l2_close, 63 .compat_ioctl = v4l_compat_ioctl32,
63 .poll = ivtv_v4l2_dec_poll, 64 .release = ivtv_v4l2_close,
65 .poll = ivtv_v4l2_dec_poll,
64}; 66};
65 67
66#define IVTV_V4L2_DEC_MPG_OFFSET 16 /* offset from 0 to register decoder mpg v4l2 minors on */ 68#define IVTV_V4L2_DEC_MPG_OFFSET 16 /* offset from 0 to register decoder mpg v4l2 minors on */
@@ -244,7 +246,7 @@ int ivtv_streams_setup(struct ivtv *itv)
244 return 0; 246 return 0;
245 247
246 /* One or more streams could not be initialized. Clean 'em all up. */ 248 /* One or more streams could not be initialized. Clean 'em all up. */
247 ivtv_streams_cleanup(itv); 249 ivtv_streams_cleanup(itv, 0);
248 return -ENOMEM; 250 return -ENOMEM;
249} 251}
250 252
@@ -304,12 +306,12 @@ int ivtv_streams_register(struct ivtv *itv)
304 return 0; 306 return 0;
305 307
306 /* One or more streams could not be initialized. Clean 'em all up. */ 308 /* One or more streams could not be initialized. Clean 'em all up. */
307 ivtv_streams_cleanup(itv); 309 ivtv_streams_cleanup(itv, 1);
308 return -ENOMEM; 310 return -ENOMEM;
309} 311}
310 312
311/* Unregister v4l2 devices */ 313/* Unregister v4l2 devices */
312void ivtv_streams_cleanup(struct ivtv *itv) 314void ivtv_streams_cleanup(struct ivtv *itv, int unregister)
313{ 315{
314 int type; 316 int type;
315 317
@@ -322,8 +324,11 @@ void ivtv_streams_cleanup(struct ivtv *itv)
322 continue; 324 continue;
323 325
324 ivtv_stream_free(&itv->streams[type]); 326 ivtv_stream_free(&itv->streams[type]);
325 /* Unregister device */ 327 /* Unregister or release device */
326 video_unregister_device(vdev); 328 if (unregister)
329 video_unregister_device(vdev);
330 else
331 video_device_release(vdev);
327 } 332 }
328} 333}
329 334
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h
index 3d76a415fbd8..a653a5136417 100644
--- a/drivers/media/video/ivtv/ivtv-streams.h
+++ b/drivers/media/video/ivtv/ivtv-streams.h
@@ -23,7 +23,7 @@
23 23
24int ivtv_streams_setup(struct ivtv *itv); 24int ivtv_streams_setup(struct ivtv *itv);
25int ivtv_streams_register(struct ivtv *itv); 25int ivtv_streams_register(struct ivtv *itv);
26void ivtv_streams_cleanup(struct ivtv *itv); 26void ivtv_streams_cleanup(struct ivtv *itv, int unregister);
27 27
28/* Capture related */ 28/* Capture related */
29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s); 29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s);
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c
index c151bcf5519a..71798f0da27f 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.c
+++ b/drivers/media/video/ivtv/ivtv-vbi.c
@@ -169,7 +169,8 @@ static void copy_vbi_data(struct ivtv *itv, int lines, u32 pts_stamp)
169 linemask[0] |= (1 << l); 169 linemask[0] |= (1 << l);
170 else 170 else
171 linemask[1] |= (1 << (l - 32)); 171 linemask[1] |= (1 << (l - 32));
172 dst[sd + 12 + line * 43] = service2vbi(itv->vbi.sliced_data[i].id); 172 dst[sd + 12 + line * 43] =
173 ivtv_service2vbi(itv->vbi.sliced_data[i].id);
173 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); 174 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42);
174 line++; 175 line++;
175 } 176 }
diff --git a/drivers/media/video/ivtv/ivtv-version.h b/drivers/media/video/ivtv/ivtv-version.h
index 02c5ab071d1b..442f43f11b73 100644
--- a/drivers/media/video/ivtv/ivtv-version.h
+++ b/drivers/media/video/ivtv/ivtv-version.h
@@ -22,8 +22,8 @@
22 22
23#define IVTV_DRIVER_NAME "ivtv" 23#define IVTV_DRIVER_NAME "ivtv"
24#define IVTV_DRIVER_VERSION_MAJOR 1 24#define IVTV_DRIVER_VERSION_MAJOR 1
25#define IVTV_DRIVER_VERSION_MINOR 2 25#define IVTV_DRIVER_VERSION_MINOR 3
26#define IVTV_DRIVER_VERSION_PATCHLEVEL 1 26#define IVTV_DRIVER_VERSION_PATCHLEVEL 0
27 27
28#define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL) 28#define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL)
29#define IVTV_DRIVER_VERSION KERNEL_VERSION(IVTV_DRIVER_VERSION_MAJOR,IVTV_DRIVER_VERSION_MINOR,IVTV_DRIVER_VERSION_PATCHLEVEL) 29#define IVTV_DRIVER_VERSION KERNEL_VERSION(IVTV_DRIVER_VERSION_MAJOR,IVTV_DRIVER_VERSION_MINOR,IVTV_DRIVER_VERSION_PATCHLEVEL)
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index 62f70bd5e3cb..3092ff1d00a0 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -908,7 +908,7 @@ static void ivtv_yuv_init(struct ivtv *itv)
908 } 908 }
909 909
910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ 910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */
911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL); 911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL|__GFP_NOWARN);
912 if (yi->blanking_ptr) { 912 if (yi->blanking_ptr) {
913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); 913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE);
914 } else { 914 } else {
@@ -1116,7 +1116,7 @@ void ivtv_yuv_setup_stream_frame(struct ivtv *itv)
1116} 1116}
1117 1117
1118/* Attempt to dma a frame from a user buffer */ 1118/* Attempt to dma a frame from a user buffer */
1119int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void *src) 1119int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void __user *src)
1120{ 1120{
1121 struct yuv_playback_info *yi = &itv->yuv_info; 1121 struct yuv_playback_info *yi = &itv->yuv_info;
1122 struct ivtv_dma_frame dma_args; 1122 struct ivtv_dma_frame dma_args;
diff --git a/drivers/media/video/ivtv/ivtv-yuv.h b/drivers/media/video/ivtv/ivtv-yuv.h
index 2fe5f1250762..ca5173fbf006 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.h
+++ b/drivers/media/video/ivtv/ivtv-yuv.h
@@ -35,7 +35,7 @@ extern const u32 yuv_offset[IVTV_YUV_BUFFERS];
35 35
36int ivtv_yuv_filter_check(struct ivtv *itv); 36int ivtv_yuv_filter_check(struct ivtv *itv);
37void ivtv_yuv_setup_stream_frame(struct ivtv *itv); 37void ivtv_yuv_setup_stream_frame(struct ivtv *itv);
38int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void *src); 38int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void __user *src);
39void ivtv_yuv_frame_complete(struct ivtv *itv); 39void ivtv_yuv_frame_complete(struct ivtv *itv);
40int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args); 40int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args);
41void ivtv_yuv_close(struct ivtv *itv); 41void ivtv_yuv_close(struct ivtv *itv);
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index df789f683e63..73be154f7f05 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -948,7 +948,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
948 } 948 }
949 949
950 /* Allocate the pseudo palette */ 950 /* Allocate the pseudo palette */
951 oi->ivtvfb_info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 951 oi->ivtvfb_info.pseudo_palette =
952 kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN);
952 953
953 if (!oi->ivtvfb_info.pseudo_palette) { 954 if (!oi->ivtvfb_info.pseudo_palette) {
954 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n"); 955 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n");
@@ -1056,7 +1057,8 @@ static int ivtvfb_init_card(struct ivtv *itv)
1056 return -EBUSY; 1057 return -EBUSY;
1057 } 1058 }
1058 1059
1059 itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC); 1060 itv->osd_info = kzalloc(sizeof(struct osd_info),
1061 GFP_ATOMIC|__GFP_NOWARN);
1060 if (itv->osd_info == NULL) { 1062 if (itv->osd_info == NULL) {
1061 IVTVFB_ERR("Failed to allocate memory for osd_info\n"); 1063 IVTVFB_ERR("Failed to allocate memory for osd_info\n");
1062 return -ENOMEM; 1064 return -ENOMEM;
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index 5b9dfa2c51b4..8e0160d275ca 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -135,8 +135,6 @@ static int m52790_probe(struct i2c_client *client,
135 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 135 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
136 return -EIO; 136 return -EIO;
137 137
138 snprintf(client->name, sizeof(client->name) - 1, "m52790");
139
140 v4l_info(client, "chip found @ 0x%x (%s)\n", 138 v4l_info(client, "chip found @ 0x%x (%s)\n",
141 client->addr << 1, client->adapter->name); 139 client->addr << 1, client->adapter->name);
142 140
@@ -159,11 +157,18 @@ static int m52790_remove(struct i2c_client *client)
159 157
160/* ----------------------------------------------------------------------- */ 158/* ----------------------------------------------------------------------- */
161 159
160static const struct i2c_device_id m52790_id[] = {
161 { "m52790", 0 },
162 { }
163};
164MODULE_DEVICE_TABLE(i2c, m52790_id);
165
162static struct v4l2_i2c_driver_data v4l2_i2c_data = { 166static struct v4l2_i2c_driver_data v4l2_i2c_data = {
163 .name = "m52790", 167 .name = "m52790",
164 .driverid = I2C_DRIVERID_M52790, 168 .driverid = I2C_DRIVERID_M52790,
165 .command = m52790_command, 169 .command = m52790_command,
166 .probe = m52790_probe, 170 .probe = m52790_probe,
167 .remove = m52790_remove, 171 .remove = m52790_remove,
172 .id_table = m52790_id,
168}; 173};
169 174
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index e6273162e123..310dbaba55ff 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -815,7 +815,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
815 int msp_product, msp_prod_hi, msp_prod_lo; 815 int msp_product, msp_prod_hi, msp_prod_lo;
816 int msp_rom; 816 int msp_rom;
817 817
818 snprintf(client->name, sizeof(client->name) - 1, "msp3400"); 818 if (!id)
819 strlcpy(client->name, "msp3400", sizeof(client->name));
819 820
820 if (msp_reset(client) == -1) { 821 if (msp_reset(client) == -1) {
821 v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); 822 v4l_dbg(1, msp_debug, client, "msp3400 not found\n");
@@ -864,9 +865,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
864 msp_revision = (state->rev1 & 0x0f) + '@'; 865 msp_revision = (state->rev1 & 0x0f) + '@';
865 msp_hard = ((state->rev1 >> 8) & 0xff) + '@'; 866 msp_hard = ((state->rev1 >> 8) & 0xff) + '@';
866 msp_rom = state->rev2 & 0x1f; 867 msp_rom = state->rev2 & 0x1f;
867 snprintf(client->name, sizeof(client->name), "MSP%d4%02d%c-%c%d",
868 msp_family, msp_product,
869 msp_revision, msp_hard, msp_rom);
870 /* Rev B=2, C=3, D=4, G=7 */ 868 /* Rev B=2, C=3, D=4, G=7 */
871 state->ident = msp_family * 10000 + 4000 + msp_product * 10 + 869 state->ident = msp_family * 10000 + 4000 + msp_product * 10 +
872 msp_revision - '@'; 870 msp_revision - '@';
@@ -931,7 +929,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
931 } 929 }
932 930
933 /* hello world :-) */ 931 /* hello world :-) */
934 v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, 932 v4l_info(client, "MSP%d4%02d%c-%c%d found @ 0x%x (%s)\n",
933 msp_family, msp_product,
934 msp_revision, msp_hard, msp_rom,
935 client->addr << 1, client->adapter->name); 935 client->addr << 1, client->adapter->name);
936 v4l_info(client, "%s ", client->name); 936 v4l_info(client, "%s ", client->name);
937 if (state->has_nicam && state->has_radio) 937 if (state->has_nicam && state->has_radio)
@@ -987,6 +987,12 @@ static int msp_remove(struct i2c_client *client)
987 987
988/* ----------------------------------------------------------------------- */ 988/* ----------------------------------------------------------------------- */
989 989
990static const struct i2c_device_id msp_id[] = {
991 { "msp3400", 0 },
992 { }
993};
994MODULE_DEVICE_TABLE(i2c, msp_id);
995
990static struct v4l2_i2c_driver_data v4l2_i2c_data = { 996static struct v4l2_i2c_driver_data v4l2_i2c_data = {
991 .name = "msp3400", 997 .name = "msp3400",
992 .driverid = I2C_DRIVERID_MSP3400, 998 .driverid = I2C_DRIVERID_MSP3400,
@@ -995,6 +1001,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
995 .remove = msp_remove, 1001 .remove = msp_remove,
996 .suspend = msp_suspend, 1002 .suspend = msp_suspend,
997 .resume = msp_resume, 1003 .resume = msp_resume,
1004 .id_table = msp_id,
998}; 1005};
999 1006
1000 1007
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 179e47049a45..ee43499544c1 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -12,15 +12,12 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/log2.h> 14#include <linux/log2.h>
15#include <linux/gpio.h>
15 16
16#include <media/v4l2-common.h> 17#include <media/v4l2-common.h>
17#include <media/v4l2-chip-ident.h> 18#include <media/v4l2-chip-ident.h>
18#include <media/soc_camera.h> 19#include <media/soc_camera.h>
19 20
20#ifdef CONFIG_MT9M001_PCA9536_SWITCH
21#include <asm/gpio.h>
22#endif
23
24/* mt9m001 i2c address 0x5d 21/* mt9m001 i2c address 0x5d
25 * The platform has to define i2c_board_info 22 * The platform has to define i2c_board_info
26 * and call i2c_register_board_info() */ 23 * and call i2c_register_board_info() */
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index d1391ac55096..1658fe590392 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -13,15 +13,12 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/log2.h> 15#include <linux/log2.h>
16#include <linux/gpio.h>
16 17
17#include <media/v4l2-common.h> 18#include <media/v4l2-common.h>
18#include <media/v4l2-chip-ident.h> 19#include <media/v4l2-chip-ident.h>
19#include <media/soc_camera.h> 20#include <media/soc_camera.h>
20 21
21#ifdef CONFIG_MT9M001_PCA9536_SWITCH
22#include <asm/gpio.h>
23#endif
24
25/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c 22/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
26 * The platform has to define i2c_board_info 23 * The platform has to define i2c_board_info
27 * and call i2c_register_board_info() */ 24 * and call i2c_register_board_info() */
@@ -91,7 +88,7 @@ static const struct soc_camera_data_format mt9v022_monochrome_formats[] = {
91struct mt9v022 { 88struct mt9v022 {
92 struct i2c_client *client; 89 struct i2c_client *client;
93 struct soc_camera_device icd; 90 struct soc_camera_device icd;
94 int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ 91 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
95 int switch_gpio; 92 int switch_gpio;
96 u16 chip_control; 93 u16 chip_control;
97 unsigned char datawidth; 94 unsigned char datawidth;
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 9620c67fae77..4482b2c72ced 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -1,8 +1,10 @@
1config VIDEO_PVRUSB2 1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && I2C 3 depends on VIDEO_V4L2 && I2C
4 depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M
5 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 6 select FW_LOADER
5 select MEDIA_TUNER 7 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
7 select VIDEO_CX2341X 9 select VIDEO_CX2341X
8 select VIDEO_SAA711X 10 select VIDEO_SAA711X
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index e684108637ad..435c083cc542 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1456,14 +1456,13 @@ static int saa7115_probe(struct i2c_client *client,
1456 struct saa711x_state *state; 1456 struct saa711x_state *state;
1457 int i; 1457 int i;
1458 char name[17]; 1458 char name[17];
1459 u8 chip_id; 1459 char chip_id;
1460 int autodetect = !id || id->driver_data == 1;
1460 1461
1461 /* Check if the adapter supports the needed features */ 1462 /* Check if the adapter supports the needed features */
1462 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1463 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1463 return -EIO; 1464 return -EIO;
1464 1465
1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1466
1467 for (i = 0; i < 0x0f; i++) { 1466 for (i = 0; i < 0x0f; i++) {
1468 saa711x_write(client, 0, i); 1467 saa711x_write(client, 0, i);
1469 name[i] = (saa711x_read(client, 0) & 0x0f) + '0'; 1468 name[i] = (saa711x_read(client, 0) & 0x0f) + '0';
@@ -1472,8 +1471,7 @@ static int saa7115_probe(struct i2c_client *client,
1472 } 1471 }
1473 name[i] = '\0'; 1472 name[i] = '\0';
1474 1473
1475 saa711x_write(client, 0, 5); 1474 chip_id = name[5];
1476 chip_id = saa711x_read(client, 0) & 0x0f;
1477 1475
1478 /* Check whether this chip is part of the saa711x series */ 1476 /* Check whether this chip is part of the saa711x series */
1479 if (memcmp(name, "1f711", 5)) { 1477 if (memcmp(name, "1f711", 5)) {
@@ -1482,8 +1480,14 @@ static int saa7115_probe(struct i2c_client *client,
1482 return -ENODEV; 1480 return -ENODEV;
1483 } 1481 }
1484 1482
1485 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id); 1483 /* Safety check */
1486 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, client->addr << 1, client->adapter->name); 1484 if (!autodetect && id->name[6] != chip_id) {
1485 v4l_warn(client, "found saa711%c while %s was expected\n",
1486 chip_id, id->name);
1487 }
1488 snprintf(client->name, sizeof(client->name), "saa711%c", chip_id);
1489 v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name,
1490 client->addr << 1, client->adapter->name);
1487 1491
1488 state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); 1492 state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL);
1489 i2c_set_clientdata(client, state); 1493 i2c_set_clientdata(client, state);
@@ -1499,19 +1503,19 @@ static int saa7115_probe(struct i2c_client *client,
1499 state->hue = 0; 1503 state->hue = 0;
1500 state->sat = 64; 1504 state->sat = 64;
1501 switch (chip_id) { 1505 switch (chip_id) {
1502 case 1: 1506 case '1':
1503 state->ident = V4L2_IDENT_SAA7111; 1507 state->ident = V4L2_IDENT_SAA7111;
1504 break; 1508 break;
1505 case 3: 1509 case '3':
1506 state->ident = V4L2_IDENT_SAA7113; 1510 state->ident = V4L2_IDENT_SAA7113;
1507 break; 1511 break;
1508 case 4: 1512 case '4':
1509 state->ident = V4L2_IDENT_SAA7114; 1513 state->ident = V4L2_IDENT_SAA7114;
1510 break; 1514 break;
1511 case 5: 1515 case '5':
1512 state->ident = V4L2_IDENT_SAA7115; 1516 state->ident = V4L2_IDENT_SAA7115;
1513 break; 1517 break;
1514 case 8: 1518 case '8':
1515 state->ident = V4L2_IDENT_SAA7118; 1519 state->ident = V4L2_IDENT_SAA7118;
1516 break; 1520 break;
1517 default: 1521 default:
@@ -1553,6 +1557,17 @@ static int saa7115_remove(struct i2c_client *client)
1553 return 0; 1557 return 0;
1554} 1558}
1555 1559
1560static const struct i2c_device_id saa7115_id[] = {
1561 { "saa711x", 1 }, /* autodetect */
1562 { "saa7111", 0 },
1563 { "saa7113", 0 },
1564 { "saa7114", 0 },
1565 { "saa7115", 0 },
1566 { "saa7118", 0 },
1567 { }
1568};
1569MODULE_DEVICE_TABLE(i2c, saa7115_id);
1570
1556static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1571static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1557 .name = "saa7115", 1572 .name = "saa7115",
1558 .driverid = I2C_DRIVERID_SAA711X, 1573 .driverid = I2C_DRIVERID_SAA711X,
@@ -1560,5 +1575,6 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1560 .probe = saa7115_probe, 1575 .probe = saa7115_probe,
1561 .remove = saa7115_remove, 1576 .remove = saa7115_remove,
1562 .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL, 1577 .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL,
1578 .id_table = saa7115_id,
1563}; 1579};
1564 1580
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index e750cd65c1c3..79d11a658bdf 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -672,8 +672,6 @@ static int saa7127_probe(struct i2c_client *client,
672 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 672 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
673 return -EIO; 673 return -EIO;
674 674
675 snprintf(client->name, sizeof(client->name) - 1, "saa7127");
676
677 v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n", 675 v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n",
678 client->addr << 1); 676 client->addr << 1);
679 677
@@ -741,11 +739,18 @@ static int saa7127_remove(struct i2c_client *client)
741 739
742/* ----------------------------------------------------------------------- */ 740/* ----------------------------------------------------------------------- */
743 741
742static struct i2c_device_id saa7127_id[] = {
743 { "saa7127", 0 },
744 { }
745};
746MODULE_DEVICE_TABLE(i2c, saa7127_id);
747
744static struct v4l2_i2c_driver_data v4l2_i2c_data = { 748static struct v4l2_i2c_driver_data v4l2_i2c_data = {
745 .name = "saa7127", 749 .name = "saa7127",
746 .driverid = I2C_DRIVERID_SAA7127, 750 .driverid = I2C_DRIVERID_SAA7127,
747 .command = saa7127_command, 751 .command = saa7127_command,
748 .probe = saa7127_probe, 752 .probe = saa7127_probe,
749 .remove = saa7127_remove, 753 .remove = saa7127_remove,
754 .id_table = saa7127_id,
750}; 755};
751 756
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 40e4c3bd2cb9..83f076abce35 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_SAA7134
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select VIDEOBUF_DMA_SG 4 select VIDEOBUF_DMA_SG
5 select VIDEO_IR 5 select VIDEO_IR
6 select MEDIA_TUNER 6 select VIDEO_TUNER
7 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
8 select CRC32 8 select CRC32
9 ---help--- 9 ---help---
@@ -27,6 +27,7 @@ config VIDEO_SAA7134_ALSA
27config VIDEO_SAA7134_DVB 27config VIDEO_SAA7134_DVB
28 tristate "DVB/ATSC Support for saa7134 based TV cards" 28 tristate "DVB/ATSC Support for saa7134 based TV cards"
29 depends on VIDEO_SAA7134 && DVB_CORE 29 depends on VIDEO_SAA7134 && DVB_CORE
30 depends on HOTPLUG # due to FW_LOADER
30 select VIDEOBUF_DVB 31 select VIDEOBUF_DVB
31 select FW_LOADER 32 select FW_LOADER
32 select DVB_PLL if !DVB_FE_CUSTOMISE 33 select DVB_PLL if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index eec127864fe3..2c19cd0113c8 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -864,7 +864,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
864 struct saa7134_dev *dev; 864 struct saa7134_dev *dev;
865 struct saa7134_mpeg_ops *mops; 865 struct saa7134_mpeg_ops *mops;
866 int err; 866 int err;
867 int mask;
868 867
869 if (saa7134_devcount == SAA7134_MAXBOARDS) 868 if (saa7134_devcount == SAA7134_MAXBOARDS)
870 return -ENOMEM; 869 return -ENOMEM;
@@ -1065,11 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1065 if (TUNER_ABSENT != dev->tuner_type) 1064 if (TUNER_ABSENT != dev->tuner_type)
1066 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); 1065 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL);
1067 1066
1068 if (card(dev).gpiomask != 0) {
1069 mask = card(dev).gpiomask;
1070 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
1071 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, 0);
1072 }
1073 return 0; 1067 return 0;
1074 1068
1075 fail4: 1069 fail4:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 2d16be2259db..469f93aac008 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -538,19 +538,23 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
538 return 0; 538 return 0;
539} 539}
540 540
541static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf, 541static int configure_tda827x_fe(struct saa7134_dev *dev,
542 struct tda827x_config *tuner_conf) 542 struct tda1004x_config *cdec_conf,
543 struct tda827x_config *tuner_conf)
543{ 544{
544 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 545 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
545 if (dev->dvb.frontend) { 546 if (dev->dvb.frontend) {
546 if (cdec_conf->i2c_gate) 547 if (cdec_conf->i2c_gate)
547 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 548 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
548 if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address, 549 if (dvb_attach(tda827x_attach, dev->dvb.frontend,
549 &dev->i2c_adap, tuner_conf) == NULL) { 550 cdec_conf->tuner_address,
550 wprintk("no tda827x tuner found at addr: %02x\n", 551 &dev->i2c_adap, tuner_conf))
552 return 0;
553
554 wprintk("no tda827x tuner found at addr: %02x\n",
551 cdec_conf->tuner_address); 555 cdec_conf->tuner_address);
552 }
553 } 556 }
557 return -EINVAL;
554} 558}
555 559
556/* ------------------------------------------------------------------ */ 560/* ------------------------------------------------------------------ */
@@ -997,7 +1001,9 @@ static int dvb_init(struct saa7134_dev *dev)
997 break; 1001 break;
998 case SAA7134_BOARD_FLYDVBTDUO: 1002 case SAA7134_BOARD_FLYDVBTDUO:
999 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1003 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1000 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1004 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1005 &tda827x_cfg_0) < 0)
1006 goto dettach_frontend;
1001 break; 1007 break;
1002 case SAA7134_BOARD_PHILIPS_EUROPA: 1008 case SAA7134_BOARD_PHILIPS_EUROPA:
1003 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1009 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
@@ -1022,36 +1028,52 @@ static int dvb_init(struct saa7134_dev *dev)
1022 } 1028 }
1023 break; 1029 break;
1024 case SAA7134_BOARD_KWORLD_DVBT_210: 1030 case SAA7134_BOARD_KWORLD_DVBT_210:
1025 configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2); 1031 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1032 &tda827x_cfg_2) < 0)
1033 goto dettach_frontend;
1026 break; 1034 break;
1027 case SAA7134_BOARD_PHILIPS_TIGER: 1035 case SAA7134_BOARD_PHILIPS_TIGER:
1028 configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0); 1036 if (configure_tda827x_fe(dev, &philips_tiger_config,
1037 &tda827x_cfg_0) < 0)
1038 goto dettach_frontend;
1029 break; 1039 break;
1030 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1040 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1031 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1); 1041 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1042 &tda827x_cfg_1) < 0)
1043 goto dettach_frontend;
1032 break; 1044 break;
1033 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1045 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1034 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1); 1046 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1047 &tda827x_cfg_1) < 0)
1048 goto dettach_frontend;
1035 break; 1049 break;
1036 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1050 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1037 configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0); 1051 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1052 &tda827x_cfg_0) < 0)
1053 goto dettach_frontend;
1038 break; 1054 break;
1039 case SAA7134_BOARD_FLYDVBT_LR301: 1055 case SAA7134_BOARD_FLYDVBT_LR301:
1040 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1056 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1057 &tda827x_cfg_0) < 0)
1058 goto dettach_frontend;
1041 break; 1059 break;
1042 case SAA7134_BOARD_FLYDVB_TRIO: 1060 case SAA7134_BOARD_FLYDVB_TRIO:
1043 if(! use_frontend) { /* terrestrial */ 1061 if (!use_frontend) { /* terrestrial */
1044 configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0); 1062 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1063 &tda827x_cfg_0) < 0)
1064 goto dettach_frontend;
1045 } else { /* satellite */ 1065 } else { /* satellite */
1046 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1066 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1047 if (dev->dvb.frontend) { 1067 if (dev->dvb.frontend) {
1048 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1068 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1049 &dev->i2c_adap, 0) == NULL) { 1069 &dev->i2c_adap, 0) == NULL) {
1050 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1070 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1071 goto dettach_frontend;
1051 } 1072 }
1052 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1073 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1053 0x08, 0, 0) == NULL) { 1074 0x08, 0, 0) == NULL) {
1054 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1075 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1076 goto dettach_frontend;
1055 } 1077 }
1056 } 1078 }
1057 } 1079 }
@@ -1067,15 +1089,20 @@ static int dvb_init(struct saa7134_dev *dev)
1067 &ads_duo_cfg) == NULL) { 1089 &ads_duo_cfg) == NULL) {
1068 wprintk("no tda827x tuner found at addr: %02x\n", 1090 wprintk("no tda827x tuner found at addr: %02x\n",
1069 ads_tech_duo_config.tuner_address); 1091 ads_tech_duo_config.tuner_address);
1092 goto dettach_frontend;
1070 } 1093 }
1071 } 1094 }
1072 break; 1095 break;
1073 case SAA7134_BOARD_TEVION_DVBT_220RF: 1096 case SAA7134_BOARD_TEVION_DVBT_220RF:
1074 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0); 1097 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1098 &tda827x_cfg_0) < 0)
1099 goto dettach_frontend;
1075 break; 1100 break;
1076 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1101 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1077 if (!use_frontend) { /* terrestrial */ 1102 if (!use_frontend) { /* terrestrial */
1078 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1103 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1104 &tda827x_cfg_0) < 0)
1105 goto dettach_frontend;
1079 } else { /* satellite */ 1106 } else { /* satellite */
1080 dev->dvb.frontend = dvb_attach(tda10086_attach, 1107 dev->dvb.frontend = dvb_attach(tda10086_attach,
1081 &flydvbs, &dev->i2c_adap); 1108 &flydvbs, &dev->i2c_adap);
@@ -1086,16 +1113,20 @@ static int dvb_init(struct saa7134_dev *dev)
1086 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1113 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1087 1114
1088 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 1115 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1089 0x60, &dev->i2c_adap, 0) == NULL) 1116 0x60, &dev->i2c_adap, 0) == NULL) {
1090 wprintk("%s: Medion Quadro, no tda826x " 1117 wprintk("%s: Medion Quadro, no tda826x "
1091 "found !\n", __func__); 1118 "found !\n", __func__);
1119 goto dettach_frontend;
1120 }
1092 if (dev_id != 0x08) { 1121 if (dev_id != 0x08) {
1093 /* we need to open the i2c gate (we know it exists) */ 1122 /* we need to open the i2c gate (we know it exists) */
1094 fe->ops.i2c_gate_ctrl(fe, 1); 1123 fe->ops.i2c_gate_ctrl(fe, 1);
1095 if (dvb_attach(isl6405_attach, fe, 1124 if (dvb_attach(isl6405_attach, fe,
1096 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1125 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1097 wprintk("%s: Medion Quadro, no ISL6405 " 1126 wprintk("%s: Medion Quadro, no ISL6405 "
1098 "found !\n", __func__); 1127 "found !\n", __func__);
1128 goto dettach_frontend;
1129 }
1099 if (dev_id == 0x07) { 1130 if (dev_id == 0x07) {
1100 /* fire up the 2nd section of the LNB supply since 1131 /* fire up the 2nd section of the LNB supply since
1101 we can't do this from the other section */ 1132 we can't do this from the other section */
@@ -1117,19 +1148,17 @@ static int dvb_init(struct saa7134_dev *dev)
1117 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1148 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1118 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1149 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1119 &dev->i2c_adap); 1150 &dev->i2c_adap);
1120 if (dev->dvb.frontend) { 1151 if (dev->dvb.frontend)
1121 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1152 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1122 NULL, DVB_PLL_TDHU2); 1153 NULL, DVB_PLL_TDHU2);
1123 }
1124 break; 1154 break;
1125 case SAA7134_BOARD_KWORLD_ATSC110: 1155 case SAA7134_BOARD_KWORLD_ATSC110:
1126 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1156 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1127 &dev->i2c_adap); 1157 &dev->i2c_adap);
1128 if (dev->dvb.frontend) { 1158 if (dev->dvb.frontend)
1129 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1159 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1130 &dev->i2c_adap, 0x61, 1160 &dev->i2c_adap, 0x61,
1131 TUNER_PHILIPS_TUV1236D); 1161 TUNER_PHILIPS_TUV1236D);
1132 }
1133 break; 1162 break;
1134 case SAA7134_BOARD_FLYDVBS_LR300: 1163 case SAA7134_BOARD_FLYDVBS_LR300:
1135 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1164 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
@@ -1138,10 +1167,12 @@ static int dvb_init(struct saa7134_dev *dev)
1138 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1167 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1139 &dev->i2c_adap, 0) == NULL) { 1168 &dev->i2c_adap, 0) == NULL) {
1140 wprintk("%s: No tda826x found!\n", __func__); 1169 wprintk("%s: No tda826x found!\n", __func__);
1170 goto dettach_frontend;
1141 } 1171 }
1142 if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1172 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1143 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1173 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1144 wprintk("%s: No ISL6421 found!\n", __func__); 1174 wprintk("%s: No ISL6421 found!\n", __func__);
1175 goto dettach_frontend;
1145 } 1176 }
1146 } 1177 }
1147 break; 1178 break;
@@ -1168,43 +1199,65 @@ static int dvb_init(struct saa7134_dev *dev)
1168 } 1199 }
1169 break; 1200 break;
1170 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1201 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1171 configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0); 1202 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1203 &tda827x_cfg_0) < 0)
1204 goto dettach_frontend;
1172 break; 1205 break;
1173 case SAA7134_BOARD_CINERGY_HT_PCI: 1206 case SAA7134_BOARD_CINERGY_HT_PCI:
1174 configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0); 1207 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1208 &tda827x_cfg_0) < 0)
1209 goto dettach_frontend;
1175 break; 1210 break;
1176 case SAA7134_BOARD_PHILIPS_TIGER_S: 1211 case SAA7134_BOARD_PHILIPS_TIGER_S:
1177 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1212 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1213 &tda827x_cfg_2) < 0)
1214 goto dettach_frontend;
1178 break; 1215 break;
1179 case SAA7134_BOARD_ASUS_P7131_4871: 1216 case SAA7134_BOARD_ASUS_P7131_4871:
1180 configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2); 1217 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1218 &tda827x_cfg_2) < 0)
1219 goto dettach_frontend;
1181 break; 1220 break;
1182 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 1221 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1183 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2); 1222 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1223 &tda827x_cfg_2) < 0)
1224 goto dettach_frontend;
1184 break; 1225 break;
1185 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 1226 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1186 configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0); 1227 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1228 &tda827x_cfg_0) < 0)
1229 goto dettach_frontend;
1187 break; 1230 break;
1188 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: 1231 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1189 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42); 1232 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1233 &tda827x_cfg_2_sw42) < 0)
1234 goto dettach_frontend;
1190 break; 1235 break;
1191 case SAA7134_BOARD_PHILIPS_SNAKE: 1236 case SAA7134_BOARD_PHILIPS_SNAKE:
1192 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1237 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1193 &dev->i2c_adap); 1238 &dev->i2c_adap);
1194 if (dev->dvb.frontend) { 1239 if (dev->dvb.frontend) {
1195 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1240 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1196 &dev->i2c_adap, 0) == NULL) 1241 &dev->i2c_adap, 0) == NULL) {
1197 wprintk("%s: No tda826x found!\n", __func__); 1242 wprintk("%s: No tda826x found!\n", __func__);
1243 goto dettach_frontend;
1244 }
1198 if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1245 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1199 &dev->i2c_adap, 0, 0) == NULL) 1246 &dev->i2c_adap, 0, 0) == NULL) {
1200 wprintk("%s: No lnbp21 found!\n", __func__); 1247 wprintk("%s: No lnbp21 found!\n", __func__);
1248 goto dettach_frontend;
1249 }
1201 } 1250 }
1202 break; 1251 break;
1203 case SAA7134_BOARD_CREATIX_CTX953: 1252 case SAA7134_BOARD_CREATIX_CTX953:
1204 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1253 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1254 &tda827x_cfg_0) < 0)
1255 goto dettach_frontend;
1205 break; 1256 break;
1206 case SAA7134_BOARD_MSI_TVANYWHERE_AD11: 1257 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1207 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1258 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1259 &tda827x_cfg_2) < 0)
1260 goto dettach_frontend;
1208 break; 1261 break;
1209 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: 1262 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1210 dev->dvb.frontend = dvb_attach(mt352_attach, 1263 dev->dvb.frontend = dvb_attach(mt352_attach,
@@ -1218,16 +1271,20 @@ static int dvb_init(struct saa7134_dev *dev)
1218 if (dev->dvb.frontend) { 1271 if (dev->dvb.frontend) {
1219 struct dvb_frontend *fe; 1272 struct dvb_frontend *fe;
1220 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1273 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1221 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) 1274 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1222 wprintk("%s: MD7134 DVB-S, no SD1878 " 1275 wprintk("%s: MD7134 DVB-S, no SD1878 "
1223 "found !\n", __func__); 1276 "found !\n", __func__);
1277 goto dettach_frontend;
1278 }
1224 /* we need to open the i2c gate (we know it exists) */ 1279 /* we need to open the i2c gate (we know it exists) */
1225 fe = dev->dvb.frontend; 1280 fe = dev->dvb.frontend;
1226 fe->ops.i2c_gate_ctrl(fe, 1); 1281 fe->ops.i2c_gate_ctrl(fe, 1);
1227 if (dvb_attach(isl6405_attach, fe, 1282 if (dvb_attach(isl6405_attach, fe,
1228 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1283 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1229 wprintk("%s: MD7134 DVB-S, no ISL6405 " 1284 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1230 "found !\n", __func__); 1285 "found !\n", __func__);
1286 goto dettach_frontend;
1287 }
1231 fe->ops.i2c_gate_ctrl(fe, 0); 1288 fe->ops.i2c_gate_ctrl(fe, 0);
1232 dev->original_set_voltage = fe->ops.set_voltage; 1289 dev->original_set_voltage = fe->ops.set_voltage;
1233 fe->ops.set_voltage = md8800_set_voltage; 1290 fe->ops.set_voltage = md8800_set_voltage;
@@ -1254,10 +1311,7 @@ static int dvb_init(struct saa7134_dev *dev)
1254 if (!fe) { 1311 if (!fe) {
1255 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1312 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1256 dev->name); 1313 dev->name);
1257 dvb_frontend_detach(dev->dvb.frontend); 1314 goto dettach_frontend;
1258 dvb_unregister_frontend(dev->dvb.frontend);
1259 dev->dvb.frontend = NULL;
1260 return -1;
1261 } 1315 }
1262 } 1316 }
1263 1317
@@ -1282,6 +1336,12 @@ static int dvb_init(struct saa7134_dev *dev)
1282 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); 1336 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1283 } 1337 }
1284 return ret; 1338 return ret;
1339
1340dettach_frontend:
1341 dvb_frontend_detach(dev->dvb.frontend);
1342 dev->dvb.frontend = NULL;
1343
1344 return -1;
1285} 1345}
1286 1346
1287static int dvb_fini(struct saa7134_dev *dev) 1347static int dvb_fini(struct saa7134_dev *dev)
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 1314522a8130..81431ee41842 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -163,8 +163,7 @@ ts_mmap(struct file *file, struct vm_area_struct * vma)
163static int empress_querycap(struct file *file, void *priv, 163static int empress_querycap(struct file *file, void *priv,
164 struct v4l2_capability *cap) 164 struct v4l2_capability *cap)
165{ 165{
166 struct saa7134_fh *fh = priv; 166 struct saa7134_dev *dev = file->private_data;
167 struct saa7134_dev *dev = fh->dev;
168 167
169 strcpy(cap->driver, "saa7134"); 168 strcpy(cap->driver, "saa7134");
170 strlcpy(cap->card, saa7134_boards[dev->board].name, 169 strlcpy(cap->card, saa7134_boards[dev->board].name,
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 72c4081feff5..2220f9569941 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -1429,8 +1429,6 @@ static int saa717x_probe(struct i2c_client *client,
1429 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1429 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1430 return -EIO; 1430 return -EIO;
1431 1431
1432 snprintf(client->name, sizeof(client->name) - 1, "saa717x");
1433
1434 if (saa717x_write(client, 0x5a4, 0xfe) && 1432 if (saa717x_write(client, 0x5a4, 0xfe) &&
1435 saa717x_write(client, 0x5a5, 0x0f) && 1433 saa717x_write(client, 0x5a5, 0x0f) &&
1436 saa717x_write(client, 0x5a6, 0x00) && 1434 saa717x_write(client, 0x5a6, 0x00) &&
@@ -1507,6 +1505,12 @@ static int saa717x_remove(struct i2c_client *client)
1507 1505
1508/* ----------------------------------------------------------------------- */ 1506/* ----------------------------------------------------------------------- */
1509 1507
1508static const struct i2c_device_id saa717x_id[] = {
1509 { "saa717x", 0 },
1510 { }
1511};
1512MODULE_DEVICE_TABLE(i2c, saa717x_id);
1513
1510static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1514static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1511 .name = "saa717x", 1515 .name = "saa717x",
1512 .driverid = I2C_DRIVERID_SAA717X, 1516 .driverid = I2C_DRIVERID_SAA717X,
@@ -1514,4 +1518,5 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1514 .probe = saa717x_probe, 1518 .probe = saa717x_probe,
1515 .remove = saa717x_remove, 1519 .remove = saa717x_remove,
1516 .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL, 1520 .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL,
1521 .id_table = saa717x_id,
1517}; 1522};
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 5748b1e1a128..7f9c7bcf3c85 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -34,7 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/page-flags.h> 36#include <linux/page-flags.h>
37#include <linux/byteorder/generic.h> 37#include <asm/byteorder.h>
38#include <asm/page.h> 38#include <asm/page.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 9276ed997388..b12c60cf5a09 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -30,6 +30,7 @@
30#include <linux/kref.h> 30#include <linux/kref.h>
31 31
32#include <linux/usb.h> 32#include <linux/usb.h>
33#include <linux/mm.h>
33#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
34#include <linux/videodev2.h> 35#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
@@ -245,6 +246,8 @@ static int stk_initialise(struct stk_camera *dev)
245 return -1; 246 return -1;
246} 247}
247 248
249#ifdef CONFIG_VIDEO_V4L1_COMPAT
250
248/* sysfs functions */ 251/* sysfs functions */
249/*FIXME cleanup this */ 252/*FIXME cleanup this */
250 253
@@ -350,6 +353,10 @@ static void stk_remove_sysfs_files(struct video_device *vdev)
350 video_device_remove_file(vdev, &dev_attr_vflip); 353 video_device_remove_file(vdev, &dev_attr_vflip);
351} 354}
352 355
356#else
357#define stk_create_sysfs_files(a)
358#define stk_remove_sysfs_files(a)
359#endif
353 360
354/* *********************************************** */ 361/* *********************************************** */
355/* 362/*
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6bf104ea051d..0d12ace61665 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -40,11 +40,11 @@
40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ 40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
41 if (__a) { \ 41 if (__a) { \
42 __r = (int) __a(ARGS); \ 42 __r = (int) __a(ARGS); \
43 symbol_put(FUNCTION); \
43 } else { \ 44 } else { \
44 printk(KERN_ERR "TUNER: Unable to find " \ 45 printk(KERN_ERR "TUNER: Unable to find " \
45 "symbol "#FUNCTION"()\n"); \ 46 "symbol "#FUNCTION"()\n"); \
46 } \ 47 } \
47 symbol_put(FUNCTION); \
48 __r; \ 48 __r; \
49}) 49})
50 50
@@ -92,6 +92,7 @@ struct tuner {
92 unsigned int type; /* chip type id */ 92 unsigned int type; /* chip type id */
93 unsigned int config; 93 unsigned int config;
94 int (*tuner_callback) (void *dev, int command, int arg); 94 int (*tuner_callback) (void *dev, int command, int arg);
95 const char *name;
95}; 96};
96 97
97/* standard i2c insmod options */ 98/* standard i2c insmod options */
@@ -330,26 +331,16 @@ static void tuner_i2c_address_check(struct tuner *t)
330 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n"); 331 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n");
331 tuner_warn("will soon be dropped. This message indicates that your\n"); 332 tuner_warn("will soon be dropped. This message indicates that your\n");
332 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n", 333 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n",
333 t->i2c->name, t->i2c->addr); 334 t->name, t->i2c->addr);
334 tuner_warn("To ensure continued support for your device, please\n"); 335 tuner_warn("To ensure continued support for your device, please\n");
335 tuner_warn("send a copy of this message, along with full dmesg\n"); 336 tuner_warn("send a copy of this message, along with full dmesg\n");
336 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); 337 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n");
337 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); 338 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n");
338 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", 339 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n",
339 t->i2c->adapter->name, t->i2c->addr, t->type, t->i2c->name); 340 t->i2c->adapter->name, t->i2c->addr, t->type, t->name);
340 tuner_warn("====================== WARNING! ======================\n"); 341 tuner_warn("====================== WARNING! ======================\n");
341} 342}
342 343
343static void attach_tda829x(struct tuner *t)
344{
345 struct tda829x_config cfg = {
346 .lna_cfg = t->config,
347 .tuner_callback = t->tuner_callback,
348 };
349 dvb_attach(tda829x_attach,
350 &t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
351}
352
353static struct xc5000_config xc5000_cfg; 344static struct xc5000_config xc5000_cfg;
354 345
355static void set_type(struct i2c_client *c, unsigned int type, 346static void set_type(struct i2c_client *c, unsigned int type,
@@ -385,12 +376,19 @@ static void set_type(struct i2c_client *c, unsigned int type,
385 376
386 switch (t->type) { 377 switch (t->type) {
387 case TUNER_MT2032: 378 case TUNER_MT2032:
388 dvb_attach(microtune_attach, 379 if (!dvb_attach(microtune_attach,
389 &t->fe, t->i2c->adapter, t->i2c->addr); 380 &t->fe, t->i2c->adapter, t->i2c->addr))
381 goto attach_failed;
390 break; 382 break;
391 case TUNER_PHILIPS_TDA8290: 383 case TUNER_PHILIPS_TDA8290:
392 { 384 {
393 attach_tda829x(t); 385 struct tda829x_config cfg = {
386 .lna_cfg = t->config,
387 .tuner_callback = t->tuner_callback,
388 };
389 if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter,
390 t->i2c->addr, &cfg))
391 goto attach_failed;
394 break; 392 break;
395 } 393 }
396 case TUNER_TEA5767: 394 case TUNER_TEA5767:
@@ -441,8 +439,9 @@ static void set_type(struct i2c_client *c, unsigned int type,
441 break; 439 break;
442 } 440 }
443 case TUNER_TDA9887: 441 case TUNER_TDA9887:
444 dvb_attach(tda9887_attach, 442 if (!dvb_attach(tda9887_attach,
445 &t->fe, t->i2c->adapter, t->i2c->addr); 443 &t->fe, t->i2c->adapter, t->i2c->addr))
444 goto attach_failed;
446 break; 445 break;
447 case TUNER_XC5000: 446 case TUNER_XC5000:
448 { 447 {
@@ -450,10 +449,10 @@ static void set_type(struct i2c_client *c, unsigned int type,
450 449
451 xc5000_cfg.i2c_address = t->i2c->addr; 450 xc5000_cfg.i2c_address = t->i2c->addr;
452 xc5000_cfg.if_khz = 5380; 451 xc5000_cfg.if_khz = 5380;
453 xc5000_cfg.priv = c->adapter->algo_data;
454 xc5000_cfg.tuner_callback = t->tuner_callback; 452 xc5000_cfg.tuner_callback = t->tuner_callback;
455 if (!dvb_attach(xc5000_attach, 453 if (!dvb_attach(xc5000_attach,
456 &t->fe, t->i2c->adapter, &xc5000_cfg)) 454 &t->fe, t->i2c->adapter, &xc5000_cfg,
455 c->adapter->algo_data))
457 goto attach_failed; 456 goto attach_failed;
458 457
459 xc_tuner_ops = &t->fe.ops.tuner_ops; 458 xc_tuner_ops = &t->fe.ops.tuner_ops;
@@ -472,19 +471,17 @@ static void set_type(struct i2c_client *c, unsigned int type,
472 if ((NULL == analog_ops->set_params) && 471 if ((NULL == analog_ops->set_params) &&
473 (fe_tuner_ops->set_analog_params)) { 472 (fe_tuner_ops->set_analog_params)) {
474 473
475 strlcpy(t->i2c->name, fe_tuner_ops->info.name, 474 t->name = fe_tuner_ops->info.name;
476 sizeof(t->i2c->name));
477 475
478 t->fe.analog_demod_priv = t; 476 t->fe.analog_demod_priv = t;
479 memcpy(analog_ops, &tuner_core_ops, 477 memcpy(analog_ops, &tuner_core_ops,
480 sizeof(struct analog_demod_ops)); 478 sizeof(struct analog_demod_ops));
481 479
482 } else { 480 } else {
483 strlcpy(t->i2c->name, analog_ops->info.name, 481 t->name = analog_ops->info.name;
484 sizeof(t->i2c->name));
485 } 482 }
486 483
487 tuner_dbg("type set to %s\n", t->i2c->name); 484 tuner_dbg("type set to %s\n", t->name);
488 485
489 if (t->mode_mask == T_UNINITIALIZED) 486 if (t->mode_mask == T_UNINITIALIZED)
490 t->mode_mask = new_mode_mask; 487 t->mode_mask = new_mode_mask;
@@ -539,7 +536,7 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
539static inline int check_mode(struct tuner *t, char *cmd) 536static inline int check_mode(struct tuner *t, char *cmd)
540{ 537{
541 if ((1 << t->mode & t->mode_mask) == 0) { 538 if ((1 << t->mode & t->mode_mask) == 0) {
542 return EINVAL; 539 return -EINVAL;
543 } 540 }
544 541
545 switch (t->mode) { 542 switch (t->mode) {
@@ -733,11 +730,11 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
733 730
734 t->mode = mode; 731 t->mode = mode;
735 732
736 if (check_mode(t, cmd) == EINVAL) { 733 if (check_mode(t, cmd) == -EINVAL) {
737 t->mode = T_STANDBY; 734 t->mode = T_STANDBY;
738 if (analog_ops->standby) 735 if (analog_ops->standby)
739 analog_ops->standby(&t->fe); 736 analog_ops->standby(&t->fe);
740 return EINVAL; 737 return -EINVAL;
741 } 738 }
742 return 0; 739 return 0;
743} 740}
@@ -779,13 +776,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
779 break; 776 break;
780 case AUDC_SET_RADIO: 777 case AUDC_SET_RADIO:
781 if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO") 778 if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO")
782 == EINVAL) 779 == -EINVAL)
783 return 0; 780 return 0;
784 if (t->radio_freq) 781 if (t->radio_freq)
785 set_freq(client, t->radio_freq); 782 set_freq(client, t->radio_freq);
786 break; 783 break;
787 case TUNER_SET_STANDBY: 784 case TUNER_SET_STANDBY:
788 if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) 785 if (check_mode(t, "TUNER_SET_STANDBY") == -EINVAL)
789 return 0; 786 return 0;
790 t->mode = T_STANDBY; 787 t->mode = T_STANDBY;
791 if (analog_ops->standby) 788 if (analog_ops->standby)
@@ -793,9 +790,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
793 break; 790 break;
794#ifdef CONFIG_VIDEO_ALLOW_V4L1 791#ifdef CONFIG_VIDEO_ALLOW_V4L1
795 case VIDIOCSAUDIO: 792 case VIDIOCSAUDIO:
796 if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) 793 if (check_mode(t, "VIDIOCSAUDIO") == -EINVAL)
797 return 0; 794 return 0;
798 if (check_v4l2(t) == EINVAL) 795 if (check_v4l2(t) == -EINVAL)
799 return 0; 796 return 0;
800 797
801 /* Should be implemented, since bttv calls it */ 798 /* Should be implemented, since bttv calls it */
@@ -813,10 +810,10 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
813 }; 810 };
814 struct video_channel *vc = arg; 811 struct video_channel *vc = arg;
815 812
816 if (check_v4l2(t) == EINVAL) 813 if (check_v4l2(t) == -EINVAL)
817 return 0; 814 return 0;
818 815
819 if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL) 816 if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==-EINVAL)
820 return 0; 817 return 0;
821 818
822 if (vc->norm < ARRAY_SIZE(map)) 819 if (vc->norm < ARRAY_SIZE(map))
@@ -830,9 +827,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
830 { 827 {
831 unsigned long *v = arg; 828 unsigned long *v = arg;
832 829
833 if (check_mode(t, "VIDIOCSFREQ") == EINVAL) 830 if (check_mode(t, "VIDIOCSFREQ") == -EINVAL)
834 return 0; 831 return 0;
835 if (check_v4l2(t) == EINVAL) 832 if (check_v4l2(t) == -EINVAL)
836 return 0; 833 return 0;
837 834
838 set_freq(client, *v); 835 set_freq(client, *v);
@@ -842,9 +839,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
842 { 839 {
843 struct video_tuner *vt = arg; 840 struct video_tuner *vt = arg;
844 841
845 if (check_mode(t, "VIDIOCGTUNER") == EINVAL) 842 if (check_mode(t, "VIDIOCGTUNER") == -EINVAL)
846 return 0; 843 return 0;
847 if (check_v4l2(t) == EINVAL) 844 if (check_v4l2(t) == -EINVAL)
848 return 0; 845 return 0;
849 846
850 if (V4L2_TUNER_RADIO == t->mode) { 847 if (V4L2_TUNER_RADIO == t->mode) {
@@ -886,9 +883,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
886 { 883 {
887 struct video_audio *va = arg; 884 struct video_audio *va = arg;
888 885
889 if (check_mode(t, "VIDIOCGAUDIO") == EINVAL) 886 if (check_mode(t, "VIDIOCGAUDIO") == -EINVAL)
890 return 0; 887 return 0;
891 if (check_v4l2(t) == EINVAL) 888 if (check_v4l2(t) == -EINVAL)
892 return 0; 889 return 0;
893 890
894 if (V4L2_TUNER_RADIO == t->mode) { 891 if (V4L2_TUNER_RADIO == t->mode) {
@@ -928,7 +925,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
928 v4l2_std_id *id = arg; 925 v4l2_std_id *id = arg;
929 926
930 if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD") 927 if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD")
931 == EINVAL) 928 == -EINVAL)
932 return 0; 929 return 0;
933 930
934 switch_v4l2(); 931 switch_v4l2();
@@ -944,7 +941,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
944 struct v4l2_frequency *f = arg; 941 struct v4l2_frequency *f = arg;
945 942
946 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY") 943 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
947 == EINVAL) 944 == -EINVAL)
948 return 0; 945 return 0;
949 switch_v4l2(); 946 switch_v4l2();
950 set_freq(client,f->frequency); 947 set_freq(client,f->frequency);
@@ -955,7 +952,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
955 { 952 {
956 struct v4l2_frequency *f = arg; 953 struct v4l2_frequency *f = arg;
957 954
958 if (check_mode(t, "VIDIOC_G_FREQUENCY") == EINVAL) 955 if (check_mode(t, "VIDIOC_G_FREQUENCY") == -EINVAL)
959 return 0; 956 return 0;
960 switch_v4l2(); 957 switch_v4l2();
961 f->type = t->mode; 958 f->type = t->mode;
@@ -976,7 +973,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
976 { 973 {
977 struct v4l2_tuner *tuner = arg; 974 struct v4l2_tuner *tuner = arg;
978 975
979 if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL) 976 if (check_mode(t, "VIDIOC_G_TUNER") == -EINVAL)
980 return 0; 977 return 0;
981 switch_v4l2(); 978 switch_v4l2();
982 979
@@ -1023,7 +1020,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
1023 { 1020 {
1024 struct v4l2_tuner *tuner = arg; 1021 struct v4l2_tuner *tuner = arg;
1025 1022
1026 if (check_mode(t, "VIDIOC_S_TUNER") == EINVAL) 1023 if (check_mode(t, "VIDIOC_S_TUNER") == -EINVAL)
1027 return 0; 1024 return 0;
1028 1025
1029 switch_v4l2(); 1026 switch_v4l2();
@@ -1117,7 +1114,7 @@ static int tuner_probe(struct i2c_client *client,
1117 if (NULL == t) 1114 if (NULL == t)
1118 return -ENOMEM; 1115 return -ENOMEM;
1119 t->i2c = client; 1116 t->i2c = client;
1120 strlcpy(client->name, "(tuner unset)", sizeof(client->name)); 1117 t->name = "(tuner unset)";
1121 i2c_set_clientdata(client, t); 1118 i2c_set_clientdata(client, t);
1122 t->type = UNSET; 1119 t->type = UNSET;
1123 t->audmode = V4L2_TUNER_MODE_STEREO; 1120 t->audmode = V4L2_TUNER_MODE_STEREO;
@@ -1167,7 +1164,7 @@ static int tuner_probe(struct i2c_client *client,
1167 /* If chip is not tda8290, don't register. 1164 /* If chip is not tda8290, don't register.
1168 since it can be tda9887*/ 1165 since it can be tda9887*/
1169 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, 1166 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter,
1170 t->i2c->addr) == 0) { 1167 t->i2c->addr) >= 0) {
1171 tuner_dbg("tda829x detected\n"); 1168 tuner_dbg("tda829x detected\n");
1172 } else { 1169 } else {
1173 /* Default is being tda9887 */ 1170 /* Default is being tda9887 */
@@ -1181,7 +1178,7 @@ static int tuner_probe(struct i2c_client *client,
1181 case 0x60: 1178 case 0x60:
1182 if (tuner_symbol_probe(tea5767_autodetection, 1179 if (tuner_symbol_probe(tea5767_autodetection,
1183 t->i2c->adapter, t->i2c->addr) 1180 t->i2c->adapter, t->i2c->addr)
1184 != EINVAL) { 1181 >= 0) {
1185 t->type = TUNER_TEA5767; 1182 t->type = TUNER_TEA5767;
1186 t->mode_mask = T_RADIO; 1183 t->mode_mask = T_RADIO;
1187 t->mode = T_STANDBY; 1184 t->mode = T_STANDBY;
@@ -1280,6 +1277,15 @@ static int tuner_remove(struct i2c_client *client)
1280 1277
1281/* ----------------------------------------------------------------------- */ 1278/* ----------------------------------------------------------------------- */
1282 1279
1280/* This driver supports many devices and the idea is to let the driver
1281 detect which device is present. So rather than listing all supported
1282 devices here, we pretend to support a single, fake device type. */
1283static const struct i2c_device_id tuner_id[] = {
1284 { "tuner", }, /* autodetect */
1285 { }
1286};
1287MODULE_DEVICE_TABLE(i2c, tuner_id);
1288
1283static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1289static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1284 .name = "tuner", 1290 .name = "tuner",
1285 .driverid = I2C_DRIVERID_TUNER, 1291 .driverid = I2C_DRIVERID_TUNER,
@@ -1289,6 +1295,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1289 .suspend = tuner_suspend, 1295 .suspend = tuner_suspend,
1290 .resume = tuner_resume, 1296 .resume = tuner_resume,
1291 .legacy_probe = tuner_legacy_probe, 1297 .legacy_probe = tuner_legacy_probe,
1298 .id_table = tuner_id,
1292}; 1299};
1293 1300
1294 1301
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 3cf8a8e801e5..9da0e1807ffb 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -319,10 +319,12 @@ audioIC[] =
319 {AUDIO_CHIP_INTERNAL, "CX25843"}, 319 {AUDIO_CHIP_INTERNAL, "CX25843"},
320 {AUDIO_CHIP_INTERNAL, "CX23418"}, 320 {AUDIO_CHIP_INTERNAL, "CX23418"},
321 {AUDIO_CHIP_INTERNAL, "CX23885"}, 321 {AUDIO_CHIP_INTERNAL, "CX23885"},
322 /* 40-42 */ 322 /* 40-44 */
323 {AUDIO_CHIP_INTERNAL, "CX23888"}, 323 {AUDIO_CHIP_INTERNAL, "CX23888"},
324 {AUDIO_CHIP_INTERNAL, "SAA7131"}, 324 {AUDIO_CHIP_INTERNAL, "SAA7131"},
325 {AUDIO_CHIP_INTERNAL, "CX23887"}, 325 {AUDIO_CHIP_INTERNAL, "CX23887"},
326 {AUDIO_CHIP_INTERNAL, "SAA7164"},
327 {AUDIO_CHIP_INTERNAL, "AU8522"},
326}; 328};
327 329
328/* This list is supplied by Hauppauge. Thanks! */ 330/* This list is supplied by Hauppauge. Thanks! */
@@ -341,8 +343,10 @@ static const char *decoderIC[] = {
341 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", 343 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842",
342 /* 30-34 */ 344 /* 30-34 */
343 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", 345 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888",
344 /* 35-37 */ 346 /* 35-39 */
345 "SAA7131", "CX25837", "CX23887" 347 "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A",
348 /* 40-42 */
349 "SAA7164", "CX23885B", "AU8522"
346}; 350};
347 351
348static int hasRadioTuner(int tunerType) 352static int hasRadioTuner(int tunerType)
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index 93bfd19dec7d..b4628874933b 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -228,6 +228,11 @@ static int upd64031a_remove(struct i2c_client *client)
228 228
229/* ----------------------------------------------------------------------- */ 229/* ----------------------------------------------------------------------- */
230 230
231static const struct i2c_device_id upd64031a_id[] = {
232 { "upd64031a", 0 },
233 { }
234};
235MODULE_DEVICE_TABLE(i2c, upd64031a_id);
231 236
232static struct v4l2_i2c_driver_data v4l2_i2c_data = { 237static struct v4l2_i2c_driver_data v4l2_i2c_data = {
233 .name = "upd64031a", 238 .name = "upd64031a",
@@ -235,4 +240,5 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
235 .command = upd64031a_command, 240 .command = upd64031a_command,
236 .probe = upd64031a_probe, 241 .probe = upd64031a_probe,
237 .remove = upd64031a_remove, 242 .remove = upd64031a_remove,
243 .id_table = upd64031a_id,
238}; 244};
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 9ab712a56ce0..9521ce004dcc 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -205,6 +205,11 @@ static int upd64083_remove(struct i2c_client *client)
205 205
206/* ----------------------------------------------------------------------- */ 206/* ----------------------------------------------------------------------- */
207 207
208static const struct i2c_device_id upd64083_id[] = {
209 { "upd64083", 0 },
210 { }
211};
212MODULE_DEVICE_TABLE(i2c, upd64083_id);
208 213
209static struct v4l2_i2c_driver_data v4l2_i2c_data = { 214static struct v4l2_i2c_driver_data v4l2_i2c_data = {
210 .name = "upd64083", 215 .name = "upd64083",
@@ -212,4 +217,5 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
212 .command = upd64083_command, 217 .command = upd64083_command,
213 .probe = upd64083_probe, 218 .probe = upd64083_probe,
214 .remove = upd64083_remove, 219 .remove = upd64083_remove,
220 .id_table = upd64083_id,
215}; 221};
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
index 32e536edf09d..3d26a30abe1e 100644
--- a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -210,7 +210,7 @@ static int qcm_stv_setb(struct usb_device *dev, u16 reg, u8 val)
210 return ret; 210 return ret;
211} 211}
212 212
213static int qcm_stv_setw(struct usb_device *dev, u16 reg, u16 val) 213static int qcm_stv_setw(struct usb_device *dev, u16 reg, __le16 val)
214{ 214{
215 int ret; 215 int ret;
216 216
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig
index 74e1d3075a20..fc24ef05b3f3 100644
--- a/drivers/media/video/usbvision/Kconfig
+++ b/drivers/media/video/usbvision/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_USBVISION 1config VIDEO_USBVISION
2 tristate "USB video devices based on Nogatech NT1003/1004/1005" 2 tristate "USB video devices based on Nogatech NT1003/1004/1005"
3 depends on I2C && VIDEO_V4L2 3 depends on I2C && VIDEO_V4L2
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
6 ---help--- 6 ---help---
7 There are more than 50 different USB video devices based on 7 There are more than 50 different USB video devices based on
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 982f4463896c..0a88c44ace00 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -331,7 +331,7 @@ int videobuf_mmap_free(struct videobuf_queue *q)
331} 331}
332 332
333/* Locking: Caller holds q->vb_lock */ 333/* Locking: Caller holds q->vb_lock */
334static int __videobuf_mmap_setup(struct videobuf_queue *q, 334int __videobuf_mmap_setup(struct videobuf_queue *q,
335 unsigned int bcount, unsigned int bsize, 335 unsigned int bcount, unsigned int bsize,
336 enum v4l2_memory memory) 336 enum v4l2_memory memory)
337{ 337{
@@ -1129,6 +1129,7 @@ EXPORT_SYMBOL_GPL(videobuf_read_stream);
1129EXPORT_SYMBOL_GPL(videobuf_read_one); 1129EXPORT_SYMBOL_GPL(videobuf_read_one);
1130EXPORT_SYMBOL_GPL(videobuf_poll_stream); 1130EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1131 1131
1132EXPORT_SYMBOL_GPL(__videobuf_mmap_setup);
1132EXPORT_SYMBOL_GPL(videobuf_mmap_setup); 1133EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1133EXPORT_SYMBOL_GPL(videobuf_mmap_free); 1134EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1134EXPORT_SYMBOL_GPL(videobuf_mmap_mapper); 1135EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c
index fac0deba24af..a1f76ee032e7 100644
--- a/drivers/media/video/vp27smpx.c
+++ b/drivers/media/video/vp27smpx.c
@@ -130,8 +130,6 @@ static int vp27smpx_probe(struct i2c_client *client,
130 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 130 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
131 return -EIO; 131 return -EIO;
132 132
133 snprintf(client->name, sizeof(client->name) - 1, "vp27smpx");
134
135 v4l_info(client, "chip found @ 0x%x (%s)\n", 133 v4l_info(client, "chip found @ 0x%x (%s)\n",
136 client->addr << 1, client->adapter->name); 134 client->addr << 1, client->adapter->name);
137 135
@@ -154,11 +152,18 @@ static int vp27smpx_remove(struct i2c_client *client)
154 152
155/* ----------------------------------------------------------------------- */ 153/* ----------------------------------------------------------------------- */
156 154
155static const struct i2c_device_id vp27smpx_id[] = {
156 { "vp27smpx", 0 },
157 { }
158};
159MODULE_DEVICE_TABLE(i2c, vp27smpx_id);
160
157static struct v4l2_i2c_driver_data v4l2_i2c_data = { 161static struct v4l2_i2c_driver_data v4l2_i2c_data = {
158 .name = "vp27smpx", 162 .name = "vp27smpx",
159 .driverid = I2C_DRIVERID_VP27SMPX, 163 .driverid = I2C_DRIVERID_VP27SMPX,
160 .command = vp27smpx_command, 164 .command = vp27smpx_command,
161 .probe = vp27smpx_probe, 165 .probe = vp27smpx_probe,
162 .remove = vp27smpx_remove, 166 .remove = vp27smpx_remove,
167 .id_table = vp27smpx_id,
163}; 168};
164 169
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 0f8ed8461fba..fc50299caa36 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -313,11 +313,18 @@ static int wm8739_remove(struct i2c_client *client)
313 return 0; 313 return 0;
314} 314}
315 315
316static const struct i2c_device_id wm8739_id[] = {
317 { "wm8739", 0 },
318 { }
319};
320MODULE_DEVICE_TABLE(i2c, wm8739_id);
321
316static struct v4l2_i2c_driver_data v4l2_i2c_data = { 322static struct v4l2_i2c_driver_data v4l2_i2c_data = {
317 .name = "wm8739", 323 .name = "wm8739",
318 .driverid = I2C_DRIVERID_WM8739, 324 .driverid = I2C_DRIVERID_WM8739,
319 .command = wm8739_command, 325 .command = wm8739_command,
320 .probe = wm8739_probe, 326 .probe = wm8739_probe,
321 .remove = wm8739_remove, 327 .remove = wm8739_remove,
328 .id_table = wm8739_id,
322}; 329};
323 330
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index 67a409e60c46..506378a508b9 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -216,11 +216,18 @@ static int wm8775_remove(struct i2c_client *client)
216 return 0; 216 return 0;
217} 217}
218 218
219static const struct i2c_device_id wm8775_id[] = {
220 { "wm8775", 0 },
221 { }
222};
223MODULE_DEVICE_TABLE(i2c, wm8775_id);
224
219static struct v4l2_i2c_driver_data v4l2_i2c_data = { 225static struct v4l2_i2c_driver_data v4l2_i2c_data = {
220 .name = "wm8775", 226 .name = "wm8775",
221 .driverid = I2C_DRIVERID_WM8775, 227 .driverid = I2C_DRIVERID_WM8775,
222 .command = wm8775_command, 228 .command = wm8775_command,
223 .probe = wm8775_probe, 229 .probe = wm8775_probe,
224 .remove = wm8775_remove, 230 .remove = wm8775_remove,
231 .id_table = wm8775_id,
225}; 232};
226 233
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 363dd2b9475c..e5c4e9f5193f 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -38,7 +38,7 @@
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/vmalloc.h> 39#include <linux/vmalloc.h>
40#include <linux/page-flags.h> 40#include <linux/page-flags.h>
41#include <linux/byteorder/generic.h> 41#include <asm/byteorder.h>
42#include <asm/page.h> 42#include <asm/page.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44 44
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 81cc3b00a079..46b7ad477ceb 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -285,7 +285,7 @@ struct zoran_mapping {
285 285
286struct zoran_jpg_buffer { 286struct zoran_jpg_buffer {
287 struct zoran_mapping *map; 287 struct zoran_mapping *map;
288 u32 *frag_tab; /* addresses of frag table */ 288 __le32 *frag_tab; /* addresses of frag table */
289 u32 frag_tab_bus; /* same value cached to save time in ISR */ 289 u32 frag_tab_bus; /* same value cached to save time in ISR */
290 enum zoran_buffer_state state; /* non-zero if corresponding buffer is in use in grab queue */ 290 enum zoran_buffer_state state; /* non-zero if corresponding buffer is in use in grab queue */
291 struct zoran_sync bs; /* DONE: info to return to application */ 291 struct zoran_sync bs; /* DONE: info to return to application */
@@ -450,7 +450,7 @@ struct zoran {
450 unsigned long jpg_queued_num; /* count of frames queued since grab/play started */ 450 unsigned long jpg_queued_num; /* count of frames queued since grab/play started */
451 451
452 /* zr36057's code buffer table */ 452 /* zr36057's code buffer table */
453 u32 *stat_com; /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */ 453 __le32 *stat_com; /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
454 454
455 /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */ 455 /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */
456 int jpg_pend[BUZ_MAX_FRAME]; 456 int jpg_pend[BUZ_MAX_FRAME];
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 7b60533efe45..88d369708e4c 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
34#include <linux/byteorder/generic.h>
35 34
36#include <linux/interrupt.h> 35#include <linux/interrupt.h>
37#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
@@ -47,6 +46,7 @@
47#include <linux/delay.h> 46#include <linux/delay.h>
48#include <linux/wait.h> 47#include <linux/wait.h>
49 48
49#include <asm/byteorder.h>
50#include <asm/io.h> 50#include <asm/io.h>
51 51
52#include "videocodec.h" 52#include "videocodec.h"
@@ -1320,7 +1320,7 @@ error_handler (struct zoran *zr,
1320 if (i) { 1320 if (i) {
1321 /* Rotate stat_comm entries to make current entry first */ 1321 /* Rotate stat_comm entries to make current entry first */
1322 int j; 1322 int j;
1323 u32 bus_addr[BUZ_NUM_STAT_COM]; 1323 __le32 bus_addr[BUZ_NUM_STAT_COM];
1324 1324
1325 /* Here we are copying the stat_com array, which 1325 /* Here we are copying the stat_com array, which
1326 * is already in little endian format, so 1326 * is already in little endian format, so
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 0134bec1e399..5394d7a5cfee 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -52,7 +52,6 @@
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/vmalloc.h> 53#include <linux/vmalloc.h>
54#include <linux/wait.h> 54#include <linux/wait.h>
55#include <linux/byteorder/generic.h>
56 55
57#include <linux/interrupt.h> 56#include <linux/interrupt.h>
58#include <linux/i2c.h> 57#include <linux/i2c.h>
@@ -74,6 +73,7 @@
74#include <media/v4l2-common.h> 73#include <media/v4l2-common.h>
75#include "videocodec.h" 74#include "videocodec.h"
76 75
76#include <asm/byteorder.h>
77#include <asm/io.h> 77#include <asm/io.h>
78#include <asm/uaccess.h> 78#include <asm/uaccess.h>
79#include <linux/proc_fs.h> 79#include <linux/proc_fs.h>
@@ -495,7 +495,7 @@ jpg_fbuffer_alloc (struct file *file)
495 jpg_fbuffer_free(file); 495 jpg_fbuffer_free(file);
496 return -ENOBUFS; 496 return -ENOBUFS;
497 } 497 }
498 fh->jpg_buffers.buffer[i].frag_tab = (u32 *) mem; 498 fh->jpg_buffers.buffer[i].frag_tab = (__le32 *) mem;
499 fh->jpg_buffers.buffer[i].frag_tab_bus = 499 fh->jpg_buffers.buffer[i].frag_tab_bus =
500 virt_to_bus((void *) mem); 500 virt_to_bus((void *) mem);
501 501
@@ -1167,7 +1167,7 @@ zoran_close_end_session (struct file *file)
1167 1167
1168 /* v4l capture */ 1168 /* v4l capture */
1169 if (fh->v4l_buffers.active != ZORAN_FREE) { 1169 if (fh->v4l_buffers.active != ZORAN_FREE) {
1170 long flags; 1170 unsigned long flags;
1171 1171
1172 spin_lock_irqsave(&zr->spinlock, flags); 1172 spin_lock_irqsave(&zr->spinlock, flags);
1173 zr36057_set_memgrab(zr, 0); 1173 zr36057_set_memgrab(zr, 0);
@@ -3436,7 +3436,7 @@ zoran_do_ioctl (struct inode *inode,
3436 3436
3437 /* unload capture */ 3437 /* unload capture */
3438 if (zr->v4l_memgrab_active) { 3438 if (zr->v4l_memgrab_active) {
3439 long flags; 3439 unsigned long flags;
3440 3440
3441 spin_lock_irqsave(&zr->spinlock, flags); 3441 spin_lock_irqsave(&zr->spinlock, flags);
3442 zr36057_set_memgrab(zr, 0); 3442 zr36057_set_memgrab(zr, 0);
@@ -4375,7 +4375,7 @@ zoran_vm_close (struct vm_area_struct *vma)
4375 mutex_lock(&zr->resource_lock); 4375 mutex_lock(&zr->resource_lock);
4376 4376
4377 if (fh->v4l_buffers.active != ZORAN_FREE) { 4377 if (fh->v4l_buffers.active != ZORAN_FREE) {
4378 long flags; 4378 unsigned long flags;
4379 4379
4380 spin_lock_irqsave(&zr->spinlock, flags); 4380 spin_lock_irqsave(&zr->spinlock, flags);
4381 zr36057_set_memgrab(zr, 0); 4381 zr36057_set_memgrab(zr, 0);
@@ -4506,7 +4506,7 @@ zoran_mmap (struct file *file,
4506 if (todo > fraglen) 4506 if (todo > fraglen)
4507 todo = fraglen; 4507 todo = fraglen;
4508 pos = 4508 pos =
4509 le32_to_cpu((unsigned long) fh->jpg_buffers. 4509 le32_to_cpu(fh->jpg_buffers.
4510 buffer[i].frag_tab[2 * j]); 4510 buffer[i].frag_tab[2 * j]);
4511 /* should just be pos on i386 */ 4511 /* should just be pos on i386 */
4512 page = virt_to_phys(bus_to_virt(pos)) 4512 page = virt_to_phys(bus_to_virt(pos))