aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-11 22:36:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-11 22:36:32 -0500
commit593195f9b2309693f27b402f34573f7920b82c3e (patch)
tree54d55557665e72e90ef35a1e0f008d381c17ed98 /drivers
parent983d5dbdb2b38d024935f560a91cddcf704875f3 (diff)
parentf9cfc08d640e1586e76eee63cc2b0a9360bc7c7e (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/saa7146_core.c9
-rw-r--r--drivers/media/common/saa7146_fops.c6
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c6
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c8
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c3
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c152
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u-fe.c3
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c6
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c9
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c3
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045-fe.c3
-rw-r--r--drivers/media/dvb/frontends/bcm3510.c3
-rw-r--r--drivers/media/dvb/frontends/dib3000mb.c3
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c3
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c17
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h1
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.c3
-rw-r--r--drivers/media/dvb/frontends/mt352.c3
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c3
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c3
-rw-r--r--drivers/media/dvb/ttpci/av7110.c4
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c129
-rw-r--r--drivers/media/dvb/ttpci/budget.h1
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c4
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c4
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c3
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/adv7170.c6
-rw-r--r--drivers/media/video/adv7175.c6
-rw-r--r--drivers/media/video/bt819.c7
-rw-r--r--drivers/media/video/bt832.c7
-rw-r--r--drivers/media/video/bt856.c6
-rw-r--r--drivers/media/video/bttv-cards.c305
-rw-r--r--drivers/media/video/bttv-gpio.c3
-rw-r--r--drivers/media/video/bttv-input.c6
-rw-r--r--drivers/media/video/bttv.h1
-rw-r--r--drivers/media/video/compat_ioctl32.c371
-rw-r--r--drivers/media/video/cpia_pp.c3
-rw-r--r--drivers/media/video/cpia_usb.c4
-rw-r--r--drivers/media/video/cs53l32a.c7
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c19
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c6
-rw-r--r--drivers/media/video/cx88/cx88-cards.c5
-rw-r--r--drivers/media/video/cx88/cx88-core.c3
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c3
-rw-r--r--drivers/media/video/cx88/cx88-input.c1
-rw-r--r--drivers/media/video/cx88/cx88-video.c6
-rw-r--r--drivers/media/video/dpc7146.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c3
-rw-r--r--drivers/media/video/hexium_gemini.c3
-rw-r--r--drivers/media/video/hexium_orion.c3
-rw-r--r--drivers/media/video/indycam.c7
-rw-r--r--drivers/media/video/msp3400-driver.c64
-rw-r--r--drivers/media/video/msp3400-kthreads.c124
-rw-r--r--drivers/media/video/msp3400.h12
-rw-r--r--drivers/media/video/mt20xx.c8
-rw-r--r--drivers/media/video/mxb.c3
-rw-r--r--drivers/media/video/ovcamchip/ov6x20.c3
-rw-r--r--drivers/media/video/ovcamchip/ov6x30.c3
-rw-r--r--drivers/media/video/ovcamchip/ov76be.c3
-rw-r--r--drivers/media/video/ovcamchip/ov7x10.c3
-rw-r--r--drivers/media/video/ovcamchip/ov7x20.c3
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c3
-rw-r--r--drivers/media/video/saa5246a.c3
-rw-r--r--drivers/media/video/saa5249.c5
-rw-r--r--drivers/media/video/saa7110.c6
-rw-r--r--drivers/media/video/saa7111.c6
-rw-r--r--drivers/media/video/saa7114.c6
-rw-r--r--drivers/media/video/saa7115.c44
-rw-r--r--drivers/media/video/saa711x.c6
-rw-r--r--drivers/media/video/saa7127.c42
-rw-r--r--drivers/media/video/saa7134/Kconfig2
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c3
-rw-r--r--drivers/media/video/saa7146.h1
-rw-r--r--drivers/media/video/saa7185.c6
-rw-r--r--drivers/media/video/saa7191.c7
-rw-r--r--drivers/media/video/stradis.c1138
-rw-r--r--drivers/media/video/tda7432.c15
-rw-r--r--drivers/media/video/tda9875.c3
-rw-r--r--drivers/media/video/tda9887.c3
-rw-r--r--drivers/media/video/tea5767.c4
-rw-r--r--drivers/media/video/tea6420.c3
-rw-r--r--drivers/media/video/tuner-3036.c3
-rw-r--r--drivers/media/video/tuner-core.c19
-rw-r--r--drivers/media/video/tvaudio.c55
-rw-r--r--drivers/media/video/tveeprom.c6
-rw-r--r--drivers/media/video/tvp5150.c3
-rw-r--r--drivers/media/video/v4l1-compat.c24
-rw-r--r--drivers/media/video/video-buf.c9
-rw-r--r--drivers/media/video/videocodec.c11
-rw-r--r--drivers/media/video/videodev.c5
-rw-r--r--drivers/media/video/vino.c4
-rw-r--r--drivers/media/video/vpx3220.c7
-rw-r--r--drivers/media/video/wm8775.c3
-rw-r--r--drivers/media/video/zoran_card.c3
-rw-r--r--drivers/media/video/zoran_driver.c3
-rw-r--r--drivers/media/video/zr36016.c3
-rw-r--r--drivers/media/video/zr36050.c3
-rw-r--r--drivers/media/video/zr36060.c3
104 files changed, 1603 insertions, 1294 deletions
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 2899d34e5f7e..04c1938b9c91 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -109,10 +109,9 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
109 struct page *pg; 109 struct page *pg;
110 int i; 110 int i;
111 111
112 sglist = kmalloc(sizeof(struct scatterlist)*nr_pages, GFP_KERNEL); 112 sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL);
113 if (NULL == sglist) 113 if (NULL == sglist)
114 return NULL; 114 return NULL;
115 memset(sglist,0,sizeof(struct scatterlist)*nr_pages);
116 for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { 115 for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) {
117 pg = vmalloc_to_page(virt); 116 pg = vmalloc_to_page(virt);
118 if (NULL == pg) 117 if (NULL == pg)
@@ -306,15 +305,13 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
306 struct saa7146_dev *dev; 305 struct saa7146_dev *dev;
307 int err = -ENOMEM; 306 int err = -ENOMEM;
308 307
309 dev = kmalloc(sizeof(struct saa7146_dev), GFP_KERNEL); 308 /* clear out mem for sure */
309 dev = kzalloc(sizeof(struct saa7146_dev), GFP_KERNEL);
310 if (!dev) { 310 if (!dev) {
311 ERR(("out of memory.\n")); 311 ERR(("out of memory.\n"));
312 goto out; 312 goto out;
313 } 313 }
314 314
315 /* clear out mem for sure */
316 memset(dev, 0x0, sizeof(struct saa7146_dev));
317
318 DEB_EE(("pci:%p\n",pci)); 315 DEB_EE(("pci:%p\n",pci));
319 316
320 err = pci_enable_device(pci); 317 err = pci_enable_device(pci);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index b614612be7b4..f8cf73ed49ad 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -239,13 +239,12 @@ static int fops_open(struct inode *inode, struct file *file)
239 } 239 }
240 240
241 /* allocate per open data */ 241 /* allocate per open data */
242 fh = kmalloc(sizeof(*fh),GFP_KERNEL); 242 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
243 if (NULL == fh) { 243 if (NULL == fh) {
244 DEB_S(("cannot allocate memory for per open data.\n")); 244 DEB_S(("cannot allocate memory for per open data.\n"));
245 result = -ENOMEM; 245 result = -ENOMEM;
246 goto out; 246 goto out;
247 } 247 }
248 memset(fh,0,sizeof(*fh));
249 248
250 file->private_data = fh; 249 file->private_data = fh;
251 fh->dev = dev; 250 fh->dev = dev;
@@ -464,12 +463,11 @@ static struct video_device device_template =
464 463
465int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) 464int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
466{ 465{
467 struct saa7146_vv *vv = kmalloc (sizeof(struct saa7146_vv),GFP_KERNEL); 466 struct saa7146_vv *vv = kzalloc (sizeof(struct saa7146_vv),GFP_KERNEL);
468 if( NULL == vv ) { 467 if( NULL == vv ) {
469 ERR(("out of memory. aborting.\n")); 468 ERR(("out of memory. aborting.\n"));
470 return -1; 469 return -1;
471 } 470 }
472 memset(vv, 0x0, sizeof(*vv));
473 471
474 DEB_EE(("dev:%p\n",dev)); 472 DEB_EE(("dev:%p\n",dev));
475 473
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
index 123ed96f6faa..56ba52470676 100644
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -220,20 +220,18 @@ EXPORT_SYMBOL(flexcop_reset_block_300);
220struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len) 220struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
221{ 221{
222 void *bus; 222 void *bus;
223 struct flexcop_device *fc = kmalloc(sizeof(struct flexcop_device), GFP_KERNEL); 223 struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device), GFP_KERNEL);
224 if (!fc) { 224 if (!fc) {
225 err("no memory"); 225 err("no memory");
226 return NULL; 226 return NULL;
227 } 227 }
228 memset(fc, 0, sizeof(struct flexcop_device));
229 228
230 bus = kmalloc(bus_specific_len, GFP_KERNEL); 229 bus = kzalloc(bus_specific_len, GFP_KERNEL);
231 if (!bus) { 230 if (!bus) {
232 err("no memory"); 231 err("no memory");
233 kfree(fc); 232 kfree(fc);
234 return NULL; 233 return NULL;
235 } 234 }
236 memset(bus, 0, bus_specific_len);
237 235
238 fc->bus_specific = bus; 236 fc->bus_specific = bus;
239 237
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index 01b4e0aac049..f65f64b00ff3 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -786,10 +786,9 @@ static int dvb_bt8xx_probe(struct device *dev)
786 struct pci_dev* bttv_pci_dev; 786 struct pci_dev* bttv_pci_dev;
787 int ret; 787 int ret;
788 788
789 if (!(card = kmalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL))) 789 if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
790 return -ENOMEM; 790 return -ENOMEM;
791 791
792 memset(card, 0, sizeof(*card));
793 init_MUTEX(&card->lock); 792 init_MUTEX(&card->lock);
794 card->bttv_nr = sub->core->nr; 793 card->bttv_nr = sub->core->nr;
795 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); 794 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 4bb779aeff6a..00347a750681 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1649,21 +1649,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1649 return -EINVAL; 1649 return -EINVAL;
1650 1650
1651 /* initialise the system data */ 1651 /* initialise the system data */
1652 if ((ca = 1652 if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
1653 (struct dvb_ca_private *) kmalloc(sizeof(struct dvb_ca_private),
1654 GFP_KERNEL)) == NULL) {
1655 ret = -ENOMEM; 1653 ret = -ENOMEM;
1656 goto error; 1654 goto error;
1657 } 1655 }
1658 memset(ca, 0, sizeof(struct dvb_ca_private));
1659 ca->pub = pubca; 1656 ca->pub = pubca;
1660 ca->flags = flags; 1657 ca->flags = flags;
1661 ca->slot_count = slot_count; 1658 ca->slot_count = slot_count;
1662 if ((ca->slot_info = kmalloc(sizeof(struct dvb_ca_slot) * slot_count, GFP_KERNEL)) == NULL) { 1659 if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
1663 ret = -ENOMEM; 1660 ret = -ENOMEM;
1664 goto error; 1661 goto error;
1665 } 1662 }
1666 memset(ca->slot_info, 0, sizeof(struct dvb_ca_slot) * slot_count);
1667 init_waitqueue_head(&ca->wait_queue); 1663 init_waitqueue_head(&ca->wait_queue);
1668 ca->thread_pid = 0; 1664 ca->thread_pid = 0;
1669 init_waitqueue_head(&ca->thread_queue); 1665 init_waitqueue_head(&ca->thread_queue);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 4a08c4ab6730..771f32d889e6 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -1024,13 +1024,12 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
1024 if (down_interruptible (&frontend_mutex)) 1024 if (down_interruptible (&frontend_mutex))
1025 return -ERESTARTSYS; 1025 return -ERESTARTSYS;
1026 1026
1027 fe->frontend_priv = kmalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL); 1027 fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
1028 if (fe->frontend_priv == NULL) { 1028 if (fe->frontend_priv == NULL) {
1029 up(&frontend_mutex); 1029 up(&frontend_mutex);
1030 return -ENOMEM; 1030 return -ENOMEM;
1031 } 1031 }
1032 fepriv = fe->frontend_priv; 1032 fepriv = fe->frontend_priv;
1033 memset(fe->frontend_priv, 0, sizeof(struct dvb_frontend_private));
1034 1033
1035 init_MUTEX (&fepriv->sem); 1034 init_MUTEX (&fepriv->sem);
1036 init_waitqueue_head (&fepriv->wait_queue); 1035 init_waitqueue_head (&fepriv->wait_queue);
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 358ed153865f..18d169836c9c 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -253,6 +253,26 @@ static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
253 return 0; 253 return 0;
254} 254}
255 255
256static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
257{ /* used in both lgz201 and th7579 */
258 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
259 static u8 reset [] = { RESET, 0x80 };
260 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
261 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
262 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
263 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
264
265 mt352_write(fe, clock_config, sizeof(clock_config));
266 udelay(200);
267 mt352_write(fe, reset, sizeof(reset));
268 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
269
270 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
271 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
272 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
273 return 0;
274}
275
256struct cx22702_config cxusb_cx22702_config = { 276struct cx22702_config cxusb_cx22702_config = {
257 .demod_address = 0x63, 277 .demod_address = 0x63,
258 278
@@ -274,6 +294,13 @@ struct mt352_config cxusb_dee1601_config = {
274 .pll_set = dvb_usb_pll_set, 294 .pll_set = dvb_usb_pll_set,
275}; 295};
276 296
297struct mt352_config cxusb_mt352_config = {
298 /* used in both lgz201 and th7579 */
299 .demod_address = 0x0f,
300 .demod_init = cxusb_mt352_demod_init,
301 .pll_set = dvb_usb_pll_set,
302};
303
277/* Callbacks for DVB USB */ 304/* Callbacks for DVB USB */
278static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) 305static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d)
279{ 306{
@@ -302,6 +329,20 @@ static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d)
302 return 0; 329 return 0;
303} 330}
304 331
332static int cxusb_lgz201_tuner_attach(struct dvb_usb_device *d)
333{
334 d->pll_addr = 0x61;
335 d->pll_desc = &dvb_pll_lg_z201;
336 return 0;
337}
338
339static int cxusb_dtt7579_tuner_attach(struct dvb_usb_device *d)
340{
341 d->pll_addr = 0x60;
342 d->pll_desc = &dvb_pll_thomson_dtt7579;
343 return 0;
344}
345
305static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d) 346static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d)
306{ 347{
307 u8 b; 348 u8 b;
@@ -329,6 +370,19 @@ static int cxusb_lgdt330x_frontend_attach(struct dvb_usb_device *d)
329 return -EIO; 370 return -EIO;
330} 371}
331 372
373static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d)
374{ /* used in both lgz201 and th7579 */
375 if (usb_set_interface(d->udev,0,0) < 0)
376 err("set interface failed");
377
378 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
379
380 if ((d->fe = mt352_attach(&cxusb_mt352_config, &d->i2c_adap)) != NULL)
381 return 0;
382
383 return -EIO;
384}
385
332static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) 386static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d)
333{ 387{
334 if (usb_set_interface(d->udev,0,0) < 0) 388 if (usb_set_interface(d->udev,0,0) < 0)
@@ -370,13 +424,17 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const
370static struct dvb_usb_properties cxusb_medion_properties; 424static struct dvb_usb_properties cxusb_medion_properties;
371static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; 425static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties;
372static struct dvb_usb_properties cxusb_bluebird_dee1601_properties; 426static struct dvb_usb_properties cxusb_bluebird_dee1601_properties;
427static struct dvb_usb_properties cxusb_bluebird_lgz201_properties;
428static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties;
373 429
374static int cxusb_probe(struct usb_interface *intf, 430static int cxusb_probe(struct usb_interface *intf,
375 const struct usb_device_id *id) 431 const struct usb_device_id *id)
376{ 432{
377 if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 || 433 if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
378 dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 || 434 dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
379 dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0) { 435 dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
436 dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
437 dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0) {
380 return 0; 438 return 0;
381 } 439 }
382 440
@@ -389,6 +447,12 @@ static struct usb_device_id cxusb_table [] = {
389 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) }, 447 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
390 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) }, 448 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) },
391 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) }, 449 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) },
450 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
451 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
452 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
453 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
454 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD) },
455 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM) },
392 {} /* Terminating entry */ 456 {} /* Terminating entry */
393}; 457};
394MODULE_DEVICE_TABLE (usb, cxusb_table); 458MODULE_DEVICE_TABLE (usb, cxusb_table);
@@ -505,12 +569,96 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
505 } 569 }
506 }, 570 },
507 571
508 .num_device_descs = 1, 572 .num_device_descs = 2,
509 .devices = { 573 .devices = {
510 { "DViCO FusionHDTV DVB-T Dual USB", 574 { "DViCO FusionHDTV DVB-T Dual USB",
511 { &cxusb_table[3], NULL }, 575 { &cxusb_table[3], NULL },
512 { &cxusb_table[4], NULL }, 576 { &cxusb_table[4], NULL },
513 }, 577 },
578 { "DigitalNow DVB-T Dual USB",
579 { &cxusb_table[9], NULL },
580 { &cxusb_table[10], NULL },
581 },
582 }
583};
584
585static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
586 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
587
588 .usb_ctrl = DEVICE_SPECIFIC,
589 .firmware = "dvb-usb-bluebird-01.fw",
590 .download_firmware = bluebird_patch_dvico_firmware_download,
591 /* use usb alt setting 0 for EP4 transfer (dvb-t),
592 use usb alt setting 7 for EP2 transfer (atsc) */
593
594 .size_of_priv = sizeof(struct cxusb_state),
595
596 .streaming_ctrl = cxusb_streaming_ctrl,
597 .power_ctrl = cxusb_power_ctrl,
598 .frontend_attach = cxusb_mt352_frontend_attach,
599 .tuner_attach = cxusb_lgz201_tuner_attach,
600
601 .i2c_algo = &cxusb_i2c_algo,
602
603 .generic_bulk_ctrl_endpoint = 0x01,
604 /* parameter for the MPEG2-data transfer */
605 .urb = {
606 .type = DVB_USB_BULK,
607 .count = 5,
608 .endpoint = 0x04,
609 .u = {
610 .bulk = {
611 .buffersize = 8192,
612 }
613 }
614 },
615
616 .num_device_descs = 1,
617 .devices = {
618 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
619 { &cxusb_table[5], NULL },
620 { &cxusb_table[6], NULL },
621 },
622 }
623};
624
625static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
626 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
627
628 .usb_ctrl = DEVICE_SPECIFIC,
629 .firmware = "dvb-usb-bluebird-01.fw",
630 .download_firmware = bluebird_patch_dvico_firmware_download,
631 /* use usb alt setting 0 for EP4 transfer (dvb-t),
632 use usb alt setting 7 for EP2 transfer (atsc) */
633
634 .size_of_priv = sizeof(struct cxusb_state),
635
636 .streaming_ctrl = cxusb_streaming_ctrl,
637 .power_ctrl = cxusb_power_ctrl,
638 .frontend_attach = cxusb_mt352_frontend_attach,
639 .tuner_attach = cxusb_dtt7579_tuner_attach,
640
641 .i2c_algo = &cxusb_i2c_algo,
642
643 .generic_bulk_ctrl_endpoint = 0x01,
644 /* parameter for the MPEG2-data transfer */
645 .urb = {
646 .type = DVB_USB_BULK,
647 .count = 5,
648 .endpoint = 0x04,
649 .u = {
650 .bulk = {
651 .buffersize = 8192,
652 }
653 }
654 },
655
656 .num_device_descs = 1,
657 .devices = {
658 { "DViCO FusionHDTV DVB-T USB (TH7579)",
659 { &cxusb_table[7], NULL },
660 { &cxusb_table[8], NULL },
661 },
514 } 662 }
515}; 663};
516 664
diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c
index 0a94ec22aeb8..cd21ddbfd054 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c
@@ -156,10 +156,9 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d)
156 struct dtt200u_fe_state* state = NULL; 156 struct dtt200u_fe_state* state = NULL;
157 157
158 /* allocate memory for the internal state */ 158 /* allocate memory for the internal state */
159 state = (struct dtt200u_fe_state*) kmalloc(sizeof(struct dtt200u_fe_state), GFP_KERNEL); 159 state = kzalloc(sizeof(struct dtt200u_fe_state), GFP_KERNEL);
160 if (state == NULL) 160 if (state == NULL)
161 goto error; 161 goto error;
162 memset(state,0,sizeof(struct dtt200u_fe_state));
163 162
164 deb_info("attaching frontend dtt200u\n"); 163 deb_info("attaching frontend dtt200u\n");
165 164
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index d22934383226..4a1b9e77e339 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -95,6 +95,8 @@
95#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11 95#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11
96#define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50 96#define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50
97#define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51 97#define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51
98#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD 0xdb54
99#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM 0xdb55
98#define USB_PID_MEDION_MD95700 0x0932 100#define USB_PID_MEDION_MD95700 0x0932
99#define USB_PID_KYE_DVB_T_COLD 0x701e 101#define USB_PID_KYE_DVB_T_COLD 0x701e
100#define USB_PID_KYE_DVB_T_WARM 0x701f 102#define USB_PID_KYE_DVB_T_WARM 0x701f
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 2e23060cbbca..716f8bf528cd 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -154,12 +154,11 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
154 } 154 }
155 155
156 info("found a '%s' in warm state.",desc->name); 156 info("found a '%s' in warm state.",desc->name);
157 d = kmalloc(sizeof(struct dvb_usb_device),GFP_KERNEL); 157 d = kzalloc(sizeof(struct dvb_usb_device),GFP_KERNEL);
158 if (d == NULL) { 158 if (d == NULL) {
159 err("no memory for 'struct dvb_usb_device'"); 159 err("no memory for 'struct dvb_usb_device'");
160 return ret; 160 return ret;
161 } 161 }
162 memset(d,0,sizeof(struct dvb_usb_device));
163 162
164 d->udev = udev; 163 d->udev = udev;
165 memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 164 memcpy(&d->props,props,sizeof(struct dvb_usb_properties));
@@ -167,13 +166,12 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
167 d->owner = owner; 166 d->owner = owner;
168 167
169 if (d->props.size_of_priv > 0) { 168 if (d->props.size_of_priv > 0) {
170 d->priv = kmalloc(d->props.size_of_priv,GFP_KERNEL); 169 d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
171 if (d->priv == NULL) { 170 if (d->priv == NULL) {
172 err("no memory for priv in 'struct dvb_usb_device'"); 171 err("no memory for priv in 'struct dvb_usb_device'");
173 kfree(d); 172 kfree(d);
174 return -ENOMEM; 173 return -ENOMEM;
175 } 174 }
176 memset(d->priv,0,d->props.size_of_priv);
177 } 175 }
178 176
179 usb_set_intfdata(intf, d); 177 usb_set_intfdata(intf, d);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 36b7048c02d2..ee821974dc60 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -175,15 +175,13 @@ static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, un
175 175
176 deb_mem("all in all I will use %lu bytes for streaming\n",num*size); 176 deb_mem("all in all I will use %lu bytes for streaming\n",num*size);
177 177
178 if ((d->buf_list = kmalloc(num*sizeof(u8 *), GFP_ATOMIC)) == NULL) 178 if ((d->buf_list = kcalloc(num, sizeof(u8 *), GFP_ATOMIC)) == NULL)
179 return -ENOMEM; 179 return -ENOMEM;
180 180
181 if ((d->dma_addr = kmalloc(num*sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) { 181 if ((d->dma_addr = kcalloc(num, sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) {
182 kfree(d->buf_list); 182 kfree(d->buf_list);
183 return -ENOMEM; 183 return -ENOMEM;
184 } 184 }
185 memset(d->buf_list,0,num*sizeof(u8 *));
186 memset(d->dma_addr,0,num*sizeof(dma_addr_t));
187 185
188 d->state |= DVB_USB_STATE_URB_BUF; 186 d->state |= DVB_USB_STATE_URB_BUF;
189 187
@@ -285,10 +283,9 @@ int dvb_usb_urb_init(struct dvb_usb_device *d)
285 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.urb.endpoint)); 283 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.urb.endpoint));
286 284
287 /* allocate the array for the data transfer URBs */ 285 /* allocate the array for the data transfer URBs */
288 d->urb_list = kmalloc(d->props.urb.count * sizeof(struct urb *),GFP_KERNEL); 286 d->urb_list = kzalloc(d->props.urb.count * sizeof(struct urb *),GFP_KERNEL);
289 if (d->urb_list == NULL) 287 if (d->urb_list == NULL)
290 return -ENOMEM; 288 return -ENOMEM;
291 memset(d->urb_list,0,d->props.urb.count * sizeof(struct urb *));
292 d->state |= DVB_USB_STATE_URB_LIST; 289 d->state |= DVB_USB_STATE_URB_LIST;
293 290
294 switch (d->props.urb.type) { 291 switch (d->props.urb.type) {
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index 0885d9fb2bf2..b6d95e1c9c52 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -281,10 +281,9 @@ static struct dvb_frontend_ops vp702x_fe_ops;
281 281
282struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) 282struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d)
283{ 283{
284 struct vp702x_fe_state *s = kmalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL); 284 struct vp702x_fe_state *s = kzalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL);
285 if (s == NULL) 285 if (s == NULL)
286 goto error; 286 goto error;
287 memset(s,0,sizeof(struct vp702x_fe_state));
288 287
289 s->d = d; 288 s->d = d;
290 s->fe.ops = &vp702x_fe_ops; 289 s->fe.ops = &vp702x_fe_ops;
diff --git a/drivers/media/dvb/dvb-usb/vp7045-fe.c b/drivers/media/dvb/dvb-usb/vp7045-fe.c
index 83f1de1e7e57..5242cca5db4a 100644
--- a/drivers/media/dvb/dvb-usb/vp7045-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp7045-fe.c
@@ -145,10 +145,9 @@ static struct dvb_frontend_ops vp7045_fe_ops;
145 145
146struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d) 146struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d)
147{ 147{
148 struct vp7045_fe_state *s = kmalloc(sizeof(struct vp7045_fe_state), GFP_KERNEL); 148 struct vp7045_fe_state *s = kzalloc(sizeof(struct vp7045_fe_state), GFP_KERNEL);
149 if (s == NULL) 149 if (s == NULL)
150 goto error; 150 goto error;
151 memset(s,0,sizeof(struct vp7045_fe_state));
152 151
153 s->d = d; 152 s->d = d;
154 s->fe.ops = &vp7045_fe_ops; 153 s->fe.ops = &vp7045_fe_ops;
diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c
index 3b132bafd4de..caaee893ca76 100644
--- a/drivers/media/dvb/frontends/bcm3510.c
+++ b/drivers/media/dvb/frontends/bcm3510.c
@@ -782,10 +782,9 @@ struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config,
782 bcm3510_register_value v; 782 bcm3510_register_value v;
783 783
784 /* allocate memory for the internal state */ 784 /* allocate memory for the internal state */
785 state = kmalloc(sizeof(struct bcm3510_state), GFP_KERNEL); 785 state = kzalloc(sizeof(struct bcm3510_state), GFP_KERNEL);
786 if (state == NULL) 786 if (state == NULL)
787 goto error; 787 goto error;
788 memset(state,0,sizeof(struct bcm3510_state));
789 788
790 /* setup the state */ 789 /* setup the state */
791 790
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
index 6b0553608610..ae589adb1c0a 100644
--- a/drivers/media/dvb/frontends/dib3000mb.c
+++ b/drivers/media/dvb/frontends/dib3000mb.c
@@ -700,10 +700,9 @@ struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
700 struct dib3000_state* state = NULL; 700 struct dib3000_state* state = NULL;
701 701
702 /* allocate memory for the internal state */ 702 /* allocate memory for the internal state */
703 state = kmalloc(sizeof(struct dib3000_state), GFP_KERNEL); 703 state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL);
704 if (state == NULL) 704 if (state == NULL)
705 goto error; 705 goto error;
706 memset(state,0,sizeof(struct dib3000_state));
707 706
708 /* setup the state */ 707 /* setup the state */
709 state->i2c = i2c; 708 state->i2c = i2c;
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index c024fad17337..3b303dbb6156 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -832,10 +832,9 @@ struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
832 u16 devid; 832 u16 devid;
833 833
834 /* allocate memory for the internal state */ 834 /* allocate memory for the internal state */
835 state = kmalloc(sizeof(struct dib3000_state), GFP_KERNEL); 835 state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL);
836 if (state == NULL) 836 if (state == NULL)
837 goto error; 837 goto error;
838 memset(state,0,sizeof(struct dib3000_state));
839 838
840 /* setup the state */ 839 /* setup the state */
841 state->i2c = i2c; 840 state->i2c = i2c;
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index a3d57ce9dd12..757075f007c1 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -345,6 +345,23 @@ struct dvb_pll_desc dvb_pll_tbmv30111in = {
345}; 345};
346EXPORT_SYMBOL(dvb_pll_tbmv30111in); 346EXPORT_SYMBOL(dvb_pll_tbmv30111in);
347 347
348/*
349 * Philips SD1878 Tuner.
350 */
351struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
352 .name = "Philips SD1878",
353 .min = 950000,
354 .max = 2150000,
355 .count = 4,
356 .entries = {
357 { 1250000, 499, 500, 0xc4, 0x00},
358 { 1550000, 499, 500, 0xc4, 0x40},
359 { 2050000, 499, 500, 0xc4, 0x80},
360 { 2150000, 499, 500, 0xc4, 0xc0},
361 },
362};
363EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
364
348/* ----------------------------------------------------------- */ 365/* ----------------------------------------------------------- */
349/* code */ 366/* code */
350 367
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 24d4d2e9acd8..f682c09189b3 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -39,6 +39,7 @@ extern struct dvb_pll_desc dvb_pll_tded4;
39extern struct dvb_pll_desc dvb_pll_tuv1236d; 39extern struct dvb_pll_desc dvb_pll_tuv1236d;
40extern struct dvb_pll_desc dvb_pll_tdhu2; 40extern struct dvb_pll_desc dvb_pll_tdhu2;
41extern struct dvb_pll_desc dvb_pll_tbmv30111in; 41extern struct dvb_pll_desc dvb_pll_tbmv30111in;
42extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261;
42 43
43int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 44int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
44 u32 freq, int bandwidth); 45 u32 freq, int bandwidth);
diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c
index 9d214643b87a..4691ac54bc1d 100644
--- a/drivers/media/dvb/frontends/lgdt330x.c
+++ b/drivers/media/dvb/frontends/lgdt330x.c
@@ -714,10 +714,9 @@ struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
714 u8 buf[1]; 714 u8 buf[1];
715 715
716 /* Allocate memory for the internal state */ 716 /* Allocate memory for the internal state */
717 state = (struct lgdt330x_state*) kmalloc(sizeof(struct lgdt330x_state), GFP_KERNEL); 717 state = kzalloc(sizeof(struct lgdt330x_state), GFP_KERNEL);
718 if (state == NULL) 718 if (state == NULL)
719 goto error; 719 goto error;
720 memset(state,0,sizeof(*state));
721 720
722 /* Setup the state */ 721 /* Setup the state */
723 state->config = config; 722 state->config = config;
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
index f0c610f2c2df..aaaec909ddf8 100644
--- a/drivers/media/dvb/frontends/mt352.c
+++ b/drivers/media/dvb/frontends/mt352.c
@@ -535,9 +535,8 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config,
535 struct mt352_state* state = NULL; 535 struct mt352_state* state = NULL;
536 536
537 /* allocate memory for the internal state */ 537 /* allocate memory for the internal state */
538 state = kmalloc(sizeof(struct mt352_state), GFP_KERNEL); 538 state = kzalloc(sizeof(struct mt352_state), GFP_KERNEL);
539 if (state == NULL) goto error; 539 if (state == NULL) goto error;
540 memset(state,0,sizeof(*state));
541 540
542 /* setup the state */ 541 /* setup the state */
543 state->i2c = i2c; 542 state->i2c = i2c;
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index aeafef46e3eb..78d2b93d35b9 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -1110,10 +1110,9 @@ struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
1110 u8 buf [] = {0,0,0,0,0}; 1110 u8 buf [] = {0,0,0,0,0};
1111 1111
1112 /* allocate memory for the internal state */ 1112 /* allocate memory for the internal state */
1113 state = (struct nxt200x_state*) kmalloc(sizeof(struct nxt200x_state), GFP_KERNEL); 1113 state = kzalloc(sizeof(struct nxt200x_state), GFP_KERNEL);
1114 if (state == NULL) 1114 if (state == NULL)
1115 goto error; 1115 goto error;
1116 memset(state,0,sizeof(*state));
1117 1116
1118 /* setup the state */ 1117 /* setup the state */
1119 state->config = config; 1118 state->config = config;
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index bbebd1c4caca..1c5316e209ef 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -584,11 +584,10 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
584 struct dmx_demux *dmx; 584 struct dmx_demux *dmx;
585 int ret = -ENOMEM; 585 int ret = -ENOMEM;
586 586
587 pluto = kmalloc(sizeof(struct pluto), GFP_KERNEL); 587 pluto = kzalloc(sizeof(struct pluto), GFP_KERNEL);
588 if (!pluto) 588 if (!pluto)
589 goto out; 589 goto out;
590 590
591 memset(pluto, 0, sizeof(struct pluto));
592 pluto->pdev = pdev; 591 pluto->pdev = pdev;
593 592
594 ret = pci_enable_device(pdev); 593 ret = pci_enable_device(pdev);
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 8ce4146f55f1..327a8089193b 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2565,14 +2565,12 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2565 } 2565 }
2566 2566
2567 /* prepare the av7110 device struct */ 2567 /* prepare the av7110 device struct */
2568 av7110 = kmalloc(sizeof(struct av7110), GFP_KERNEL); 2568 av7110 = kzalloc(sizeof(struct av7110), GFP_KERNEL);
2569 if (!av7110) { 2569 if (!av7110) {
2570 dprintk(1, "out of memory\n"); 2570 dprintk(1, "out of memory\n");
2571 return -ENOMEM; 2571 return -ENOMEM;
2572 } 2572 }
2573 2573
2574 memset(av7110, 0, sizeof(struct av7110));
2575
2576 av7110->card_name = (char*) pci_ext->ext_priv; 2574 av7110->card_name = (char*) pci_ext->ext_priv;
2577 av7110->dev = dev; 2575 av7110->dev = dev;
2578 dev->ext_priv = av7110; 2576 dev->ext_priv = av7110;
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index f9d00452e639..1465c04e49aa 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -37,6 +37,7 @@
37#include "stv0299.h" 37#include "stv0299.h"
38#include "tda10021.h" 38#include "tda10021.h"
39#include "tda1004x.h" 39#include "tda1004x.h"
40#include "dvb-pll.h"
40#include <media/saa7146_vv.h> 41#include <media/saa7146_vv.h>
41#include <linux/module.h> 42#include <linux/module.h>
42#include <linux/errno.h> 43#include <linux/errno.h>
@@ -864,8 +865,117 @@ static struct tda1004x_config philips_tu1216_config = {
864 .request_firmware = philips_tu1216_request_firmware, 865 .request_firmware = philips_tu1216_request_firmware,
865}; 866};
866 867
868static u8 philips_sd1878_inittab[] = {
869 0x01, 0x15,
870 0x02, 0x30,
871 0x03, 0x00,
872 0x04, 0x7d,
873 0x05, 0x35,
874 0x06, 0x40,
875 0x07, 0x00,
876 0x08, 0x43,
877 0x09, 0x02,
878 0x0C, 0x51,
879 0x0D, 0x82,
880 0x0E, 0x23,
881 0x10, 0x3f,
882 0x11, 0x84,
883 0x12, 0xb9,
884 0x15, 0xc9,
885 0x16, 0x19,
886 0x17, 0x8c,
887 0x18, 0x59,
888 0x19, 0xf8,
889 0x1a, 0xfe,
890 0x1c, 0x7f,
891 0x1d, 0x00,
892 0x1e, 0x00,
893 0x1f, 0x50,
894 0x20, 0x00,
895 0x21, 0x00,
896 0x22, 0x00,
897 0x23, 0x00,
898 0x28, 0x00,
899 0x29, 0x28,
900 0x2a, 0x14,
901 0x2b, 0x0f,
902 0x2c, 0x09,
903 0x2d, 0x09,
904 0x31, 0x1f,
905 0x32, 0x19,
906 0x33, 0xfc,
907 0x34, 0x93,
908 0xff, 0xff
909};
910
911static int philips_sd1878_tda8261_pll_set(struct dvb_frontend *fe,
912 struct i2c_adapter *i2c,
913 struct dvb_frontend_parameters *params)
914{
915 u8 buf[4];
916 int rc;
917 struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)};
918
919 if((params->frequency < 950000) || (params->frequency > 2150000))
920 return -EINVAL;
921
922 rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf,
923 params->frequency, 0);
924 if(rc < 0) return rc;
925
926 if(i2c_transfer(i2c, &tuner_msg, 1) != 1)
927 return -EIO;
928
929 return 0;
930}
931
932static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
933 u32 srate, u32 ratio)
934{
935 u8 aclk = 0;
936 u8 bclk = 0;
937 u8 m1;
938
939 aclk = 0xb5;
940 if (srate < 2000000)
941 bclk = 0x86;
942 else if (srate < 5000000)
943 bclk = 0x89;
944 else if (srate < 15000000)
945 bclk = 0x8f;
946 else if (srate < 45000000)
947 bclk = 0x95;
948
949 m1 = 0x14;
950 if (srate < 4000000)
951 m1 = 0x10;
952
953 stv0299_writereg(fe, 0x0e, 0x23);
954 stv0299_writereg(fe, 0x0f, 0x94);
955 stv0299_writereg(fe, 0x10, 0x39);
956 stv0299_writereg(fe, 0x13, aclk);
957 stv0299_writereg(fe, 0x14, bclk);
958 stv0299_writereg(fe, 0x15, 0xc9);
959 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
960 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
961 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
962 stv0299_writereg(fe, 0x0f, 0x80 | m1);
867 963
964 return 0;
965}
868 966
967static struct stv0299_config philips_sd1878_config = {
968 .demod_address = 0x68,
969 .inittab = philips_sd1878_inittab,
970 .mclk = 88000000UL,
971 .invert = 0,
972 .skip_reinit = 0,
973 .lock_output = STV0229_LOCKOUTPUT_1,
974 .volt13_op0_op1 = STV0299_VOLT13_OP0,
975 .min_delay_ms = 100,
976 .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
977 .pll_set = philips_sd1878_tda8261_pll_set,
978};
869 979
870static u8 read_pwm(struct budget_av *budget_av) 980static u8 read_pwm(struct budget_av *budget_av)
871{ 981{
@@ -886,7 +996,10 @@ static u8 read_pwm(struct budget_av *budget_av)
886#define SUBID_DVBS_KNC1_PLUS 0x0011 996#define SUBID_DVBS_KNC1_PLUS 0x0011
887#define SUBID_DVBS_TYPHOON 0x4f56 997#define SUBID_DVBS_TYPHOON 0x4f56
888#define SUBID_DVBS_CINERGY1200 0x1154 998#define SUBID_DVBS_CINERGY1200 0x1154
999#define SUBID_DVBS_CYNERGY1200N 0x1155
889 1000
1001#define SUBID_DVBS_TV_STAR 0x0014
1002#define SUBID_DVBS_TV_STAR_CI 0x0016
890#define SUBID_DVBC_KNC1 0x0020 1003#define SUBID_DVBC_KNC1 0x0020
891#define SUBID_DVBC_KNC1_PLUS 0x0021 1004#define SUBID_DVBC_KNC1_PLUS 0x0021
892#define SUBID_DVBC_CINERGY1200 0x1156 1005#define SUBID_DVBC_CINERGY1200 0x1156
@@ -922,6 +1035,13 @@ static void frontend_init(struct budget_av *budget_av)
922 } 1035 }
923 break; 1036 break;
924 1037
1038 case SUBID_DVBS_TV_STAR:
1039 case SUBID_DVBS_TV_STAR_CI:
1040 case SUBID_DVBS_CYNERGY1200N:
1041 fe = stv0299_attach(&philips_sd1878_config,
1042 &budget_av->budget.i2c_adap);
1043 break;
1044
925 case SUBID_DVBS_KNC1_PLUS: 1045 case SUBID_DVBS_KNC1_PLUS:
926 case SUBID_DVBS_TYPHOON: 1046 case SUBID_DVBS_TYPHOON:
927 fe = stv0299_attach(&typhoon_config, 1047 fe = stv0299_attach(&typhoon_config,
@@ -1027,11 +1147,9 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
1027 1147
1028 dprintk(2, "dev: %p\n", dev); 1148 dprintk(2, "dev: %p\n", dev);
1029 1149
1030 if (!(budget_av = kmalloc(sizeof(struct budget_av), GFP_KERNEL))) 1150 if (!(budget_av = kzalloc(sizeof(struct budget_av), GFP_KERNEL)))
1031 return -ENOMEM; 1151 return -ENOMEM;
1032 1152
1033 memset(budget_av, 0, sizeof(struct budget_av));
1034
1035 budget_av->has_saa7113 = 0; 1153 budget_av->has_saa7113 = 0;
1036 budget_av->budget.ci_present = 0; 1154 budget_av->budget.ci_present = 0;
1037 1155
@@ -1166,10 +1284,12 @@ static struct saa7146_extension budget_extension;
1166MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S); 1284MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
1167MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C); 1285MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
1168MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T); 1286MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
1287MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
1169MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP); 1288MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
1170MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP); 1289MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
1171MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP); 1290MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
1172MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S); 1291MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
1292MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
1173MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C); 1293MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
1174MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T); 1294MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
1175 1295
@@ -1178,11 +1298,14 @@ static struct pci_device_id pci_tbl[] = {
1178 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1298 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1179 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010), 1299 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
1180 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), 1300 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
1301 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
1302 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
1181 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1303 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
1182 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021), 1304 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
1183 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030), 1305 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
1184 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031), 1306 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
1185 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154), 1307 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
1308 MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
1186 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156), 1309 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
1187 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157), 1310 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
1188 { 1311 {
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index c8d48cfba277..c7bb63c4d98d 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -95,6 +95,7 @@ static struct saa7146_pci_extension_data x_var = { \
95#define BUDGET_KNC1SP 11 95#define BUDGET_KNC1SP 11
96#define BUDGET_KNC1CP 12 96#define BUDGET_KNC1CP 12
97#define BUDGET_KNC1TP 13 97#define BUDGET_KNC1TP 13
98#define BUDGET_TVSTAR 14
98 99
99#define BUDGET_VIDEO_PORTA 0 100#define BUDGET_VIDEO_PORTA 0
100#define BUDGET_VIDEO_PORTB 1 101#define BUDGET_VIDEO_PORTB 1
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 104df610dbe1..5a13c4744f61 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1489,11 +1489,9 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1489 1489
1490 if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV; 1490 if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV;
1491 1491
1492 if (!(ttusb = kmalloc(sizeof(struct ttusb), GFP_KERNEL))) 1492 if (!(ttusb = kzalloc(sizeof(struct ttusb), GFP_KERNEL)))
1493 return -ENOMEM; 1493 return -ENOMEM;
1494 1494
1495 memset(ttusb, 0, sizeof(struct ttusb));
1496
1497 ttusb->dev = udev; 1495 ttusb->dev = udev;
1498 ttusb->c = 0; 1496 ttusb->c = 0;
1499 ttusb->mux_state = 0; 1497 ttusb->mux_state = 0;
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index d8966d1d25ee..df831171e03c 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1606,15 +1606,13 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1606 1606
1607 udev = interface_to_usbdev(intf); 1607 udev = interface_to_usbdev(intf);
1608 1608
1609 if (!(dec = kmalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { 1609 if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) {
1610 printk("%s: couldn't allocate memory.\n", __FUNCTION__); 1610 printk("%s: couldn't allocate memory.\n", __FUNCTION__);
1611 return -ENOMEM; 1611 return -ENOMEM;
1612 } 1612 }
1613 1613
1614 usb_set_intfdata(intf, (void *)dec); 1614 usb_set_intfdata(intf, (void *)dec);
1615 1615
1616 memset(dec, 0, sizeof(struct ttusb_dec));
1617
1618 switch (le16_to_cpu(id->idProduct)) { 1616 switch (le16_to_cpu(id->idProduct)) {
1619 case 0x1006: 1617 case 0x1006:
1620 ttusb_dec_set_model(dec, TTUSB_DEC3000S); 1618 ttusb_dec_set_model(dec, TTUSB_DEC3000S);
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 69ac8aa73eba..8e499b8f64c7 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -318,11 +318,10 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
318 struct gemtek_pci_card *card; 318 struct gemtek_pci_card *card;
319 struct video_device *devradio; 319 struct video_device *devradio;
320 320
321 if ( (card = kmalloc( sizeof( struct gemtek_pci_card ), GFP_KERNEL )) == NULL ) { 321 if ( (card = kzalloc( sizeof( struct gemtek_pci_card ), GFP_KERNEL )) == NULL ) {
322 printk( KERN_ERR "gemtek_pci: out of memory\n" ); 322 printk( KERN_ERR "gemtek_pci: out of memory\n" );
323 return -ENOMEM; 323 return -ENOMEM;
324 } 324 }
325 memset( card, 0, sizeof( struct gemtek_pci_card ) );
326 325
327 if ( pci_enable_device( pci_dev ) ) 326 if ( pci_enable_device( pci_dev ) )
328 goto err_pci; 327 goto err_pci;
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 2fe260fff85d..d82c8a30ba44 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -183,7 +183,7 @@ config VIDEO_STRADIS
183 help 183 help
184 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video 184 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video
185 driver for PCI. There is a product page at 185 driver for PCI. There is a product page at
186 <http://www.stradis.com/decoder.html>. 186 <http://www.stradis.com/>.
187 187
188config VIDEO_ZORAN 188config VIDEO_ZORAN
189 tristate "Zoran ZR36057/36067 Video For Linux" 189 tristate "Zoran ZR36057/36067 Video For Linux"
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index e61003de1d5f..4ce07ae62dac 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -413,10 +413,9 @@ adv7170_detect_client (struct i2c_adapter *adapter,
413 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 413 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
414 return 0; 414 return 0;
415 415
416 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 416 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
417 if (client == 0) 417 if (client == 0)
418 return -ENOMEM; 418 return -ENOMEM;
419 memset(client, 0, sizeof(struct i2c_client));
420 client->addr = address; 419 client->addr = address;
421 client->adapter = adapter; 420 client->adapter = adapter;
422 client->driver = &i2c_driver_adv7170; 421 client->driver = &i2c_driver_adv7170;
@@ -433,12 +432,11 @@ adv7170_detect_client (struct i2c_adapter *adapter,
433 } 432 }
434 strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); 433 strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client)));
435 434
436 encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL); 435 encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL);
437 if (encoder == NULL) { 436 if (encoder == NULL) {
438 kfree(client); 437 kfree(client);
439 return -ENOMEM; 438 return -ENOMEM;
440 } 439 }
441 memset(encoder, 0, sizeof(struct adv7170));
442 encoder->norm = VIDEO_MODE_NTSC; 440 encoder->norm = VIDEO_MODE_NTSC;
443 encoder->input = 0; 441 encoder->input = 0;
444 encoder->enable = 1; 442 encoder->enable = 1;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 6d9536a71ee4..4e218f22b214 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -463,10 +463,9 @@ adv7175_detect_client (struct i2c_adapter *adapter,
463 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 463 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
464 return 0; 464 return 0;
465 465
466 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 466 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
467 if (client == 0) 467 if (client == 0)
468 return -ENOMEM; 468 return -ENOMEM;
469 memset(client, 0, sizeof(struct i2c_client));
470 client->addr = address; 469 client->addr = address;
471 client->adapter = adapter; 470 client->adapter = adapter;
472 client->driver = &i2c_driver_adv7175; 471 client->driver = &i2c_driver_adv7175;
@@ -483,12 +482,11 @@ adv7175_detect_client (struct i2c_adapter *adapter,
483 } 482 }
484 strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); 483 strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client)));
485 484
486 encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL); 485 encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL);
487 if (encoder == NULL) { 486 if (encoder == NULL) {
488 kfree(client); 487 kfree(client);
489 return -ENOMEM; 488 return -ENOMEM;
490 } 489 }
491 memset(encoder, 0, sizeof(struct adv7175));
492 encoder->norm = VIDEO_MODE_PAL; 490 encoder->norm = VIDEO_MODE_PAL;
493 encoder->input = 0; 491 encoder->input = 0;
494 encoder->enable = 1; 492 encoder->enable = 1;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 560b99891753..d6447791d0e5 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -528,21 +528,18 @@ bt819_detect_client (struct i2c_adapter *adapter,
528 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 528 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
529 return 0; 529 return 0;
530 530
531 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 531 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
532 if (client == 0) 532 if (client == 0)
533 return -ENOMEM; 533 return -ENOMEM;
534 memset(client, 0, sizeof(struct i2c_client));
535 client->addr = address; 534 client->addr = address;
536 client->adapter = adapter; 535 client->adapter = adapter;
537 client->driver = &i2c_driver_bt819; 536 client->driver = &i2c_driver_bt819;
538 537
539 decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL); 538 decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL);
540 if (decoder == NULL) { 539 if (decoder == NULL) {
541 kfree(client); 540 kfree(client);
542 return -ENOMEM; 541 return -ENOMEM;
543 } 542 }
544
545 memset(decoder, 0, sizeof(struct bt819));
546 decoder->norm = VIDEO_MODE_NTSC; 543 decoder->norm = VIDEO_MODE_NTSC;
547 decoder->input = 0; 544 decoder->input = 0;
548 decoder->enable = 1; 545 decoder->enable = 1;
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index dda4aa6bef27..07c78f1f7a44 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -75,13 +75,13 @@ int bt832_hexdump(struct i2c_client *i2c_client_s, unsigned char *buf)
75 75
76 if(debug>1) { 76 if(debug>1) {
77 int i; 77 int i;
78 v4l_dbg(2,i2c_client_s,"hexdump:"); 78 v4l_dbg(2, debug,i2c_client_s,"hexdump:");
79 for(i=1;i<65;i++) { 79 for(i=1;i<65;i++) {
80 if(i!=1) { 80 if(i!=1) {
81 if(((i-1)%8)==0) printk(" "); 81 if(((i-1)%8)==0) printk(" ");
82 if(((i-1)%16)==0) { 82 if(((i-1)%16)==0) {
83 printk("\n"); 83 printk("\n");
84 v4l_dbg(2,i2c_client_s,"hexdump:"); 84 v4l_dbg(2, debug,i2c_client_s,"hexdump:");
85 } 85 }
86 } 86 }
87 printk(" %02x",buf[i]); 87 printk(" %02x",buf[i]);
@@ -167,9 +167,8 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
167 client_template.adapter = adap; 167 client_template.adapter = adap;
168 client_template.addr = addr; 168 client_template.addr = addr;
169 169
170 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 170 if (NULL == (t = kzalloc(sizeof(*t), GFP_KERNEL)))
171 return -ENOMEM; 171 return -ENOMEM;
172 memset(t,0,sizeof(*t));
173 t->client = client_template; 172 t->client = client_template;
174 i2c_set_clientdata(&t->client, t); 173 i2c_set_clientdata(&t->client, t);
175 i2c_attach_client(&t->client); 174 i2c_attach_client(&t->client);
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 60508069bbed..909b593530ed 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -316,21 +316,19 @@ bt856_detect_client (struct i2c_adapter *adapter,
316 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 316 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
317 return 0; 317 return 0;
318 318
319 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 319 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
320 if (client == 0) 320 if (client == 0)
321 return -ENOMEM; 321 return -ENOMEM;
322 memset(client, 0, sizeof(struct i2c_client));
323 client->addr = address; 322 client->addr = address;
324 client->adapter = adapter; 323 client->adapter = adapter;
325 client->driver = &i2c_driver_bt856; 324 client->driver = &i2c_driver_bt856;
326 strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client))); 325 strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client)));
327 326
328 encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL); 327 encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL);
329 if (encoder == NULL) { 328 if (encoder == NULL) {
330 kfree(client); 329 kfree(client);
331 return -ENOMEM; 330 return -ENOMEM;
332 } 331 }
333 memset(encoder, 0, sizeof(struct bt856));
334 encoder->norm = VIDEO_MODE_NTSC; 332 encoder->norm = VIDEO_MODE_NTSC;
335 encoder->enable = 1; 333 encoder->enable = 1;
336 i2c_set_clientdata(client, encoder); 334 i2c_set_clientdata(client, encoder);
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 1621ab133d23..65323e78d5fd 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -321,7 +321,7 @@ struct tvcard bttv_tvcards[] = {
321 .audio_inputs = 1, 321 .audio_inputs = 1,
322 .tuner = 0, 322 .tuner = 0,
323 .svhs = 2, 323 .svhs = 2,
324 .muxsel = { 2, 3, 1, 0}, 324 .muxsel = { 2, 3, 1, 0 },
325 .tuner_type = -1, 325 .tuner_type = -1,
326 .tuner_addr = ADDR_UNSET, 326 .tuner_addr = ADDR_UNSET,
327 .radio_addr = ADDR_UNSET, 327 .radio_addr = ADDR_UNSET,
@@ -333,8 +333,8 @@ struct tvcard bttv_tvcards[] = {
333 .tuner = 0, 333 .tuner = 0,
334 .svhs = 2, 334 .svhs = 2,
335 .gpiomask = 15, 335 .gpiomask = 15,
336 .muxsel = { 2, 3, 1, 1}, 336 .muxsel = { 2, 3, 1, 1 },
337 .audiomux = { 2, 0, 0, 0, 10}, 337 .audiomux = { 2, 0, 0, 0, 10 },
338 .needs_tvaudio = 1, 338 .needs_tvaudio = 1,
339 .tuner_type = -1, 339 .tuner_type = -1,
340 .tuner_addr = ADDR_UNSET, 340 .tuner_addr = ADDR_UNSET,
@@ -347,8 +347,8 @@ struct tvcard bttv_tvcards[] = {
347 .tuner = 0, 347 .tuner = 0,
348 .svhs = 2, 348 .svhs = 2,
349 .gpiomask = 7, 349 .gpiomask = 7,
350 .muxsel = { 2, 3, 1, 1}, 350 .muxsel = { 2, 3, 1, 1 },
351 .audiomux = { 0, 1, 2, 3, 4}, 351 .audiomux = { 0, 1, 2, 3, 4 },
352 .needs_tvaudio = 1, 352 .needs_tvaudio = 1,
353 .tuner_type = -1, 353 .tuner_type = -1,
354 .tuner_addr = ADDR_UNSET, 354 .tuner_addr = ADDR_UNSET,
@@ -361,8 +361,8 @@ struct tvcard bttv_tvcards[] = {
361 .tuner = 0, 361 .tuner = 0,
362 .svhs = 2, 362 .svhs = 2,
363 .gpiomask = 7, 363 .gpiomask = 7,
364 .muxsel = { 2, 3, 1, 1}, 364 .muxsel = { 2, 3, 1, 1 },
365 .audiomux = { 4, 0, 2, 3, 1}, 365 .audiomux = { 4, 0, 2, 3, 1 },
366 .no_msp34xx = 1, 366 .no_msp34xx = 1,
367 .needs_tvaudio = 1, 367 .needs_tvaudio = 1,
368 .tuner_type = TUNER_PHILIPS_NTSC, 368 .tuner_type = TUNER_PHILIPS_NTSC,
@@ -380,7 +380,7 @@ struct tvcard bttv_tvcards[] = {
380 .tuner = -1, 380 .tuner = -1,
381 .svhs = 2, 381 .svhs = 2,
382 .gpiomask = 0, 382 .gpiomask = 0,
383 .muxsel = { 2, 3, 1, 1}, 383 .muxsel = { 2, 3, 1, 1 },
384 .audiomux = { 0 }, 384 .audiomux = { 0 },
385 .needs_tvaudio = 0, 385 .needs_tvaudio = 0,
386 .tuner_type = 4, 386 .tuner_type = 4,
@@ -394,8 +394,8 @@ struct tvcard bttv_tvcards[] = {
394 .tuner = 0, 394 .tuner = 0,
395 .svhs = 2, 395 .svhs = 2,
396 .gpiomask = 3, 396 .gpiomask = 3,
397 .muxsel = { 2, 3, 1, 0}, 397 .muxsel = { 2, 3, 1, 0 },
398 .audiomux = { 0, 1, 0, 1, 3}, 398 .audiomux = { 0, 1, 0, 1, 3 },
399 .needs_tvaudio = 1, 399 .needs_tvaudio = 1,
400 .tuner_type = -1, 400 .tuner_type = -1,
401 .tuner_addr = ADDR_UNSET, 401 .tuner_addr = ADDR_UNSET,
@@ -407,9 +407,9 @@ struct tvcard bttv_tvcards[] = {
407 .audio_inputs = 1, 407 .audio_inputs = 1,
408 .tuner = 0, 408 .tuner = 0,
409 .svhs = 3, 409 .svhs = 3,
410 .muxsel = { 2, 3, 1, 1}, 410 .muxsel = { 2, 3, 1, 1 },
411 .gpiomask = 0x0f, 411 .gpiomask = 0x0f,
412 .audiomux = { 0x0c, 0x04, 0x08, 0x04, 0}, 412 .audiomux = { 0x0c, 0x04, 0x08, 0x04, 0 },
413 /* 0x04 for some cards ?? */ 413 /* 0x04 for some cards ?? */
414 .needs_tvaudio = 1, 414 .needs_tvaudio = 1,
415 .tuner_type = -1, 415 .tuner_type = -1,
@@ -425,8 +425,8 @@ struct tvcard bttv_tvcards[] = {
425 .tuner = -1, 425 .tuner = -1,
426 .svhs = 3, 426 .svhs = 3,
427 .gpiomask = 0, 427 .gpiomask = 0,
428 .muxsel = { 2, 3, 1, 0, 0}, 428 .muxsel = { 2, 3, 1, 0, 0 },
429 .audiomux = {0 }, 429 .audiomux = { 0 },
430 .needs_tvaudio = 1, 430 .needs_tvaudio = 1,
431 .tuner_type = -1, 431 .tuner_type = -1,
432 .tuner_addr = ADDR_UNSET, 432 .tuner_addr = ADDR_UNSET,
@@ -441,8 +441,8 @@ struct tvcard bttv_tvcards[] = {
441 .tuner = 0, 441 .tuner = 0,
442 .svhs = 2, 442 .svhs = 2,
443 .gpiomask = 0xc00, 443 .gpiomask = 0xc00,
444 .muxsel = { 2, 3, 1, 1}, 444 .muxsel = { 2, 3, 1, 1 },
445 .audiomux = { 0, 0xc00, 0x800, 0x400, 0xc00, 0}, 445 .audiomux = { 0, 0xc00, 0x800, 0x400, 0xc00, 0 },
446 .needs_tvaudio = 1, 446 .needs_tvaudio = 1,
447 .pll = PLL_28, 447 .pll = PLL_28,
448 .tuner_type = -1, 448 .tuner_type = -1,
@@ -456,8 +456,8 @@ struct tvcard bttv_tvcards[] = {
456 .tuner = 0, 456 .tuner = 0,
457 .svhs = 2, 457 .svhs = 2,
458 .gpiomask = 3, 458 .gpiomask = 3,
459 .muxsel = { 2, 3, 1, 1}, 459 .muxsel = { 2, 3, 1, 1 },
460 .audiomux = { 1, 1, 2, 3, 0}, 460 .audiomux = { 1, 1, 2, 3, 0 },
461 .needs_tvaudio = 0, 461 .needs_tvaudio = 0,
462 .pll = PLL_28, 462 .pll = PLL_28,
463 .tuner_type = TUNER_TEMIC_PAL, 463 .tuner_type = TUNER_TEMIC_PAL,
@@ -471,8 +471,8 @@ struct tvcard bttv_tvcards[] = {
471 .tuner = 0, 471 .tuner = 0,
472 .svhs = 2, 472 .svhs = 2,
473 .gpiomask = 0x0f, /* old: 7 */ 473 .gpiomask = 0x0f, /* old: 7 */
474 .muxsel = { 2, 0, 1, 1}, 474 .muxsel = { 2, 0, 1, 1 },
475 .audiomux = { 0, 1, 2, 3, 4}, 475 .audiomux = { 0, 1, 2, 3, 4 },
476 .needs_tvaudio = 1, 476 .needs_tvaudio = 1,
477 .pll = PLL_28, 477 .pll = PLL_28,
478 .tuner_type = -1, 478 .tuner_type = -1,
@@ -486,8 +486,8 @@ struct tvcard bttv_tvcards[] = {
486 .tuner = 0, 486 .tuner = 0,
487 .svhs = 2, 487 .svhs = 2,
488 .gpiomask = 0x3014f, 488 .gpiomask = 0x3014f,
489 .muxsel = { 2, 3, 1, 1}, 489 .muxsel = { 2, 3, 1, 1 },
490 .audiomux = { 0x20001,0x10001, 0, 0,10}, 490 .audiomux = { 0x20001,0x10001, 0, 0,10 },
491 .needs_tvaudio = 1, 491 .needs_tvaudio = 1,
492 .tuner_type = -1, 492 .tuner_type = -1,
493 .tuner_addr = ADDR_UNSET, 493 .tuner_addr = ADDR_UNSET,
@@ -502,8 +502,8 @@ struct tvcard bttv_tvcards[] = {
502 .tuner = 0, 502 .tuner = 0,
503 .svhs = 2, 503 .svhs = 2,
504 .gpiomask = 15, 504 .gpiomask = 15,
505 .muxsel = { 2, 3, 1, 1}, 505 .muxsel = { 2, 3, 1, 1 },
506 .audiomux = { 13, 14, 11, 7, 0, 0}, 506 .audiomux = { 13, 14, 11, 7, 0, 0 },
507 .needs_tvaudio = 1, 507 .needs_tvaudio = 1,
508 .tuner_type = -1, 508 .tuner_type = -1,
509 .tuner_addr = ADDR_UNSET, 509 .tuner_addr = ADDR_UNSET,
@@ -516,8 +516,8 @@ struct tvcard bttv_tvcards[] = {
516 .tuner = 0, 516 .tuner = 0,
517 .svhs = 2, 517 .svhs = 2,
518 .gpiomask = 15, 518 .gpiomask = 15,
519 .muxsel = { 2, 3, 1, 1}, 519 .muxsel = { 2, 3, 1, 1 },
520 .audiomux = { 13, 14, 11, 7, 0, 0}, 520 .audiomux = { 13, 14, 11, 7, 0, 0 },
521 .needs_tvaudio = 1, 521 .needs_tvaudio = 1,
522 .msp34xx_alt = 1, 522 .msp34xx_alt = 1,
523 .pll = PLL_28, 523 .pll = PLL_28,
@@ -534,8 +534,8 @@ struct tvcard bttv_tvcards[] = {
534 .tuner = 0, 534 .tuner = 0,
535 .svhs = 2, 535 .svhs = 2,
536 .gpiomask = 7, 536 .gpiomask = 7,
537 .muxsel = { 2, 3, 1, 1}, 537 .muxsel = { 2, 3, 1, 1 },
538 .audiomux = { 0, 2, 1, 3, 4}, /* old: { 0, 1, 2, 3, 4} */ 538 .audiomux = { 0, 2, 1, 3, 4 }, /* old: {0, 1, 2, 3, 4} */
539 .needs_tvaudio = 1, 539 .needs_tvaudio = 1,
540 .pll = PLL_28, 540 .pll = PLL_28,
541 .tuner_type = -1, 541 .tuner_type = -1,
@@ -549,8 +549,8 @@ struct tvcard bttv_tvcards[] = {
549 .tuner = 0, 549 .tuner = 0,
550 .svhs = 2, 550 .svhs = 2,
551 .gpiomask = 15, 551 .gpiomask = 15,
552 .muxsel = { 2, 3, 1, 1}, 552 .muxsel = { 2, 3, 1, 1 },
553 .audiomux = {0 , 0, 1 , 0, 10}, 553 .audiomux = { 0 , 0, 1 , 0, 10 },
554 .needs_tvaudio = 1, 554 .needs_tvaudio = 1,
555 .tuner_type = -1, 555 .tuner_type = -1,
556 .tuner_addr = ADDR_UNSET, 556 .tuner_addr = ADDR_UNSET,
@@ -565,7 +565,7 @@ struct tvcard bttv_tvcards[] = {
565 .tuner = 0, 565 .tuner = 0,
566 .svhs = 2, 566 .svhs = 2,
567 .gpiomask = 0x01fe00, 567 .gpiomask = 0x01fe00,
568 .muxsel = { 2, 3, 1, 1}, 568 .muxsel = { 2, 3, 1, 1 },
569 #if 0 569 #if 0
570 /* old */ 570 /* old */
571 .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 }, 571 .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
@@ -584,8 +584,8 @@ struct tvcard bttv_tvcards[] = {
584 .tuner = 0, 584 .tuner = 0,
585 .svhs = 2, 585 .svhs = 2,
586 .gpiomask = 0x8300f8, 586 .gpiomask = 0x8300f8,
587 .muxsel = { 2, 3, 1, 1,0}, 587 .muxsel = { 2, 3, 1, 1,0 },
588 .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007}, 588 .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007 },
589 .needs_tvaudio = 1, 589 .needs_tvaudio = 1,
590 .tuner_type = -1, 590 .tuner_type = -1,
591 .tuner_addr = ADDR_UNSET, 591 .tuner_addr = ADDR_UNSET,
@@ -600,8 +600,8 @@ struct tvcard bttv_tvcards[] = {
600 .tuner = 0, 600 .tuner = 0,
601 .svhs = 2, 601 .svhs = 2,
602 .gpiomask = 0, 602 .gpiomask = 0,
603 .muxsel = {2, 3, 1, 1}, 603 .muxsel = { 2, 3, 1, 1 },
604 .audiomux = {1, 0, 0, 0, 0}, 604 .audiomux = { 1, 0, 0, 0, 0 },
605 .needs_tvaudio = 1, 605 .needs_tvaudio = 1,
606 .tuner_type = -1, 606 .tuner_type = -1,
607 .tuner_addr = ADDR_UNSET, 607 .tuner_addr = ADDR_UNSET,
@@ -614,7 +614,7 @@ struct tvcard bttv_tvcards[] = {
614 .tuner = -1, 614 .tuner = -1,
615 .svhs = -1, 615 .svhs = -1,
616 .gpiomask = 0x8dff00, 616 .gpiomask = 0x8dff00,
617 .muxsel = { 2, 3, 1, 1}, 617 .muxsel = { 2, 3, 1, 1 },
618 .audiomux = { 0 }, 618 .audiomux = { 0 },
619 .no_msp34xx = 1, 619 .no_msp34xx = 1,
620 .tuner_type = -1, 620 .tuner_type = -1,
@@ -629,7 +629,7 @@ struct tvcard bttv_tvcards[] = {
629 .audio_inputs = 3, 629 .audio_inputs = 3,
630 .tuner = 0, 630 .tuner = 0,
631 .svhs = 2, 631 .svhs = 2,
632 .muxsel = {2, 3, 1, 1}, 632 .muxsel = { 2, 3, 1, 1 },
633 .tuner_type = -1, 633 .tuner_type = -1,
634 .tuner_addr = ADDR_UNSET, 634 .tuner_addr = ADDR_UNSET,
635 .radio_addr = ADDR_UNSET, 635 .radio_addr = ADDR_UNSET,
@@ -641,8 +641,8 @@ struct tvcard bttv_tvcards[] = {
641 .tuner = 0, 641 .tuner = 0,
642 .svhs = 2, 642 .svhs = 2,
643 .gpiomask = 0x1800, 643 .gpiomask = 0x1800,
644 .muxsel = { 2, 3, 1, 1}, 644 .muxsel = { 2, 3, 1, 1 },
645 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, 645 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
646 .pll = PLL_28, 646 .pll = PLL_28,
647 .tuner_type = TUNER_PHILIPS_PAL_I, 647 .tuner_type = TUNER_PHILIPS_PAL_I,
648 .tuner_addr = ADDR_UNSET, 648 .tuner_addr = ADDR_UNSET,
@@ -655,8 +655,8 @@ struct tvcard bttv_tvcards[] = {
655 .tuner = 0, 655 .tuner = 0,
656 .svhs = 2, 656 .svhs = 2,
657 .gpiomask = 0xc00, 657 .gpiomask = 0xc00,
658 .muxsel = { 2, 3, 1, 1}, 658 .muxsel = { 2, 3, 1, 1 },
659 .audiomux = {0, 1, 0x800, 0x400, 0xc00, 0}, 659 .audiomux = { 0, 1, 0x800, 0x400, 0xc00, 0 },
660 .needs_tvaudio = 1, 660 .needs_tvaudio = 1,
661 .pll = PLL_28, 661 .pll = PLL_28,
662 .tuner_type = -1, 662 .tuner_type = -1,
@@ -688,8 +688,8 @@ struct tvcard bttv_tvcards[] = {
688 .tuner = 0, 688 .tuner = 0,
689 .svhs = 2, 689 .svhs = 2,
690 .gpiomask = 0xe00, 690 .gpiomask = 0xe00,
691 .muxsel = { 2, 3, 1, 1}, 691 .muxsel = { 2, 3, 1, 1 },
692 .audiomux = {0x400, 0x400, 0x400, 0x400, 0xc00}, 692 .audiomux = {0x400, 0x400, 0x400, 0x400, 0xc00 },
693 .needs_tvaudio = 1, 693 .needs_tvaudio = 1,
694 .pll = PLL_28, 694 .pll = PLL_28,
695 .tuner_type = -1, 695 .tuner_type = -1,
@@ -704,8 +704,8 @@ struct tvcard bttv_tvcards[] = {
704 .tuner = 0, 704 .tuner = 0,
705 .svhs = 2, 705 .svhs = 2,
706 .gpiomask = 0x1f0fff, 706 .gpiomask = 0x1f0fff,
707 .muxsel = { 2, 3, 1, 1}, 707 .muxsel = { 2, 3, 1, 1 },
708 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000}, 708 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000 },
709 .needs_tvaudio = 0, 709 .needs_tvaudio = 0,
710 .tuner_type = TUNER_PHILIPS_PAL, 710 .tuner_type = TUNER_PHILIPS_PAL,
711 .tuner_addr = ADDR_UNSET, 711 .tuner_addr = ADDR_UNSET,
@@ -719,8 +719,8 @@ struct tvcard bttv_tvcards[] = {
719 .tuner = 0, 719 .tuner = 0,
720 .svhs = 3, 720 .svhs = 3,
721 .gpiomask = 7, 721 .gpiomask = 7,
722 .muxsel = { 2, 0, 1, 1}, 722 .muxsel = { 2, 0, 1, 1 },
723 .audiomux = { 0, 1, 2, 3, 4}, 723 .audiomux = { 0, 1, 2, 3, 4 },
724 .needs_tvaudio = 1, 724 .needs_tvaudio = 1,
725 .tuner_type = -1, 725 .tuner_type = -1,
726 .tuner_addr = ADDR_UNSET, 726 .tuner_addr = ADDR_UNSET,
@@ -733,8 +733,8 @@ struct tvcard bttv_tvcards[] = {
733 .tuner = 0, 733 .tuner = 0,
734 .svhs = 2, 734 .svhs = 2,
735 .gpiomask = 0x1800, 735 .gpiomask = 0x1800,
736 .muxsel = { 2, 3, 1, 1}, 736 .muxsel = { 2, 3, 1, 1 },
737 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, 737 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
738 .pll = PLL_28, 738 .pll = PLL_28,
739 .tuner_type = TUNER_PHILIPS_SECAM, 739 .tuner_type = TUNER_PHILIPS_SECAM,
740 .tuner_addr = ADDR_UNSET, 740 .tuner_addr = ADDR_UNSET,
@@ -749,8 +749,8 @@ struct tvcard bttv_tvcards[] = {
749 .tuner = 0, 749 .tuner = 0,
750 .svhs = 2, 750 .svhs = 2,
751 .gpiomask = 0x1f0fff, 751 .gpiomask = 0x1f0fff,
752 .muxsel = { 2, 3, 1, 1}, 752 .muxsel = { 2, 3, 1, 1 },
753 .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000}, 753 .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000 },
754 .needs_tvaudio = 0, 754 .needs_tvaudio = 0,
755 .tuner_type = TUNER_PHILIPS_PAL, 755 .tuner_type = TUNER_PHILIPS_PAL,
756 .tuner_addr = ADDR_UNSET, 756 .tuner_addr = ADDR_UNSET,
@@ -812,7 +812,7 @@ struct tvcard bttv_tvcards[] = {
812 .tuner = 0, 812 .tuner = 0,
813 .svhs = 2, 813 .svhs = 2,
814 .gpiomask = 0x1800, /* 0x8dfe00 */ 814 .gpiomask = 0x1800, /* 0x8dfe00 */
815 .muxsel = { 2, 3, 1, 1}, 815 .muxsel = { 2, 3, 1, 1 },
816 .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 }, 816 .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 },
817 .pll = PLL_28, 817 .pll = PLL_28,
818 .tuner_type = -1, 818 .tuner_type = -1,
@@ -826,7 +826,7 @@ struct tvcard bttv_tvcards[] = {
826 .tuner = 0, 826 .tuner = 0,
827 .svhs = 3, 827 .svhs = 3,
828 .gpiomask = 1, 828 .gpiomask = 1,
829 .muxsel = { 2, 3, 1, 1}, 829 .muxsel = { 2, 3, 1, 1 },
830 .audiomux = { 1, 0, 0, 0, 0 }, 830 .audiomux = { 1, 0, 0, 0, 0 },
831 .pll = PLL_28, 831 .pll = PLL_28,
832 .tuner_type = TUNER_PHILIPS_PAL, 832 .tuner_type = TUNER_PHILIPS_PAL,
@@ -842,7 +842,7 @@ struct tvcard bttv_tvcards[] = {
842 .tuner = -1, 842 .tuner = -1,
843 .svhs = 2, 843 .svhs = 2,
844 .gpiomask = 0, 844 .gpiomask = 0,
845 .muxsel = { 2, 3, 1, 1}, 845 .muxsel = { 2, 3, 1, 1 },
846 .audiomux = { 0 }, 846 .audiomux = { 0 },
847 .needs_tvaudio = 0, 847 .needs_tvaudio = 0,
848 .tuner_type = 4, 848 .tuner_type = 4,
@@ -856,8 +856,8 @@ struct tvcard bttv_tvcards[] = {
856 .tuner = 0, 856 .tuner = 0,
857 .svhs = 2, 857 .svhs = 2,
858 .gpiomask = 0xffff00, 858 .gpiomask = 0xffff00,
859 .muxsel = { 2, 3, 1, 1}, 859 .muxsel = { 2, 3, 1, 1 },
860 .audiomux = { 0x500, 0, 0x300, 0x900, 0x900}, 860 .audiomux = { 0x500, 0, 0x300, 0x900, 0x900 },
861 .needs_tvaudio = 1, 861 .needs_tvaudio = 1,
862 .pll = PLL_28, 862 .pll = PLL_28,
863 .tuner_type = TUNER_PHILIPS_PAL, 863 .tuner_type = TUNER_PHILIPS_PAL,
@@ -870,7 +870,7 @@ struct tvcard bttv_tvcards[] = {
870 .audio_inputs = 1, 870 .audio_inputs = 1,
871 .tuner = 0, 871 .tuner = 0,
872 .svhs = 2, 872 .svhs = 2,
873 .muxsel = { 2, 3, 1, 1, 0}, /* TV, CVid, SVid, CVid over SVid connector */ 873 .muxsel = { 2, 3, 1, 1, 0 }, /* TV, CVid, SVid, CVid over SVid connector */
874 #if 0 874 #if 0
875 .gpiomask = 0xc33000, 875 .gpiomask = 0xc33000,
876 .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 }, 876 .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
@@ -906,8 +906,8 @@ struct tvcard bttv_tvcards[] = {
906 .tuner = 0, 906 .tuner = 0,
907 .svhs = 2, 907 .svhs = 2,
908 .gpiomask = 0x1800, 908 .gpiomask = 0x1800,
909 .muxsel = { 2, 3, 1, 1}, 909 .muxsel = { 2, 3, 1, 1 },
910 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800}, 910 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
911 .pll = PLL_28, 911 .pll = PLL_28,
912 .tuner_type = -1, 912 .tuner_type = -1,
913 .tuner_addr = ADDR_UNSET, 913 .tuner_addr = ADDR_UNSET,
@@ -922,7 +922,7 @@ struct tvcard bttv_tvcards[] = {
922 .tuner = 0, 922 .tuner = 0,
923 .svhs = 2, 923 .svhs = 2,
924 .gpiomask = 0x1800, 924 .gpiomask = 0x1800,
925 .muxsel = { 2, 3, 1, 1}, 925 .muxsel = { 2, 3, 1, 1 },
926 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, 926 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
927 .pll = PLL_28, 927 .pll = PLL_28,
928 .tuner_type = -1, 928 .tuner_type = -1,
@@ -952,7 +952,7 @@ struct tvcard bttv_tvcards[] = {
952 .tuner = 0, 952 .tuner = 0,
953 .svhs = 2, 953 .svhs = 2,
954 .gpiomask = 0x551e00, 954 .gpiomask = 0x551e00,
955 .muxsel = { 2, 3, 1, 0}, 955 .muxsel = { 2, 3, 1, 0 },
956 .audiomux = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 }, 956 .audiomux = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 },
957 .needs_tvaudio = 1, 957 .needs_tvaudio = 1,
958 .pll = PLL_28, 958 .pll = PLL_28,
@@ -968,8 +968,8 @@ struct tvcard bttv_tvcards[] = {
968 .tuner = 0, 968 .tuner = 0,
969 .svhs = 2, 969 .svhs = 2,
970 .gpiomask = 0x03000F, 970 .gpiomask = 0x03000F,
971 .muxsel = { 2, 3, 1, 1}, 971 .muxsel = { 2, 3, 1, 1 },
972 .audiomux = { 2, 0xd0001, 0, 0, 1}, 972 .audiomux = { 2, 0xd0001, 0, 0, 1 },
973 .needs_tvaudio = 0, 973 .needs_tvaudio = 0,
974 .pll = PLL_28, 974 .pll = PLL_28,
975 .tuner_type = -1, 975 .tuner_type = -1,
@@ -985,8 +985,8 @@ struct tvcard bttv_tvcards[] = {
985 .tuner = 0, 985 .tuner = 0,
986 .svhs = 2, 986 .svhs = 2,
987 .gpiomask = 7, 987 .gpiomask = 7,
988 .muxsel = { 2, 3, 1, 1}, 988 .muxsel = { 2, 3, 1, 1 },
989 .audiomux = { 4, 0, 2, 3, 1}, 989 .audiomux = { 4, 0, 2, 3, 1 },
990 .no_msp34xx = 1, 990 .no_msp34xx = 1,
991 .needs_tvaudio = 1, 991 .needs_tvaudio = 1,
992 .tuner_type = TUNER_PHILIPS_NTSC, 992 .tuner_type = TUNER_PHILIPS_NTSC,
@@ -1002,8 +1002,8 @@ struct tvcard bttv_tvcards[] = {
1002 .tuner = 0, 1002 .tuner = 0,
1003 .svhs = 2, 1003 .svhs = 2,
1004 .gpiomask = 15, 1004 .gpiomask = 15,
1005 .muxsel = { 2, 3, 1, 1}, 1005 .muxsel = { 2, 3, 1, 1 },
1006 .audiomux = { 13, 4, 11, 7, 0, 0}, 1006 .audiomux = { 13, 4, 11, 7, 0, 0 },
1007 .needs_tvaudio = 1, 1007 .needs_tvaudio = 1,
1008 .pll = PLL_28, 1008 .pll = PLL_28,
1009 .tuner_type = -1, 1009 .tuner_type = -1,
@@ -1035,8 +1035,8 @@ struct tvcard bttv_tvcards[] = {
1035 .tuner = 0, 1035 .tuner = 0,
1036 .svhs = 2, 1036 .svhs = 2,
1037 .gpiomask = 0xe00b, 1037 .gpiomask = 0xe00b,
1038 .muxsel = {2, 3, 1, 1}, 1038 .muxsel = { 2, 3, 1, 1 },
1039 .audiomux = {0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc}, 1039 .audiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc },
1040 .no_msp34xx = 1, 1040 .no_msp34xx = 1,
1041 .tuner_type = -1, 1041 .tuner_type = -1,
1042 .tuner_addr = ADDR_UNSET, 1042 .tuner_addr = ADDR_UNSET,
@@ -1051,8 +1051,8 @@ struct tvcard bttv_tvcards[] = {
1051 .tuner = 0, 1051 .tuner = 0,
1052 .svhs = -1, 1052 .svhs = -1,
1053 .gpiomask = 3, 1053 .gpiomask = 3,
1054 .muxsel = {2, 3, 1, 1}, 1054 .muxsel = { 2, 3, 1, 1 },
1055 .audiomux = {1, 1, 0, 2, 3}, 1055 .audiomux = { 1, 1, 0, 2, 3 },
1056 .no_msp34xx = 1, 1056 .no_msp34xx = 1,
1057 .pll = PLL_NONE, 1057 .pll = PLL_NONE,
1058 .tuner_type = -1, 1058 .tuner_type = -1,
@@ -1066,8 +1066,8 @@ struct tvcard bttv_tvcards[] = {
1066 .tuner = -1, 1066 .tuner = -1,
1067 .svhs = 3, 1067 .svhs = 3,
1068 .gpiomask = 0, 1068 .gpiomask = 0,
1069 .muxsel = { 2, 3, 1, 0, 0}, 1069 .muxsel = { 2, 3, 1, 0, 0 },
1070 .audiomux = {0 }, 1070 .audiomux = { 0 },
1071 .no_msp34xx = 1, 1071 .no_msp34xx = 1,
1072 .pll = PLL_28, 1072 .pll = PLL_28,
1073 .tuner_type = -1, 1073 .tuner_type = -1,
@@ -1081,8 +1081,8 @@ struct tvcard bttv_tvcards[] = {
1081 .tuner = 0, 1081 .tuner = 0,
1082 .svhs = 2, 1082 .svhs = 2,
1083 .gpiomask = 0xbcf03f, 1083 .gpiomask = 0xbcf03f,
1084 .muxsel = { 2, 3, 1, 1}, 1084 .muxsel = { 2, 3, 1, 1 },
1085 .audiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f}, 1085 .audiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f },
1086 .no_msp34xx = 1, 1086 .no_msp34xx = 1,
1087 .pll = PLL_28, 1087 .pll = PLL_28,
1088 .tuner_type = 21, 1088 .tuner_type = 21,
@@ -1096,7 +1096,7 @@ struct tvcard bttv_tvcards[] = {
1096 .tuner = 0, 1096 .tuner = 0,
1097 .svhs = 2, 1097 .svhs = 2,
1098 .gpiomask = 0x70000, 1098 .gpiomask = 0x70000,
1099 .muxsel = { 2, 3, 1, 1}, 1099 .muxsel = { 2, 3, 1, 1 },
1100 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 }, 1100 .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 },
1101 .needs_tvaudio = 1, 1101 .needs_tvaudio = 1,
1102 .no_msp34xx = 1, 1102 .no_msp34xx = 1,
@@ -1115,8 +1115,8 @@ struct tvcard bttv_tvcards[] = {
1115 .tuner = 0, 1115 .tuner = 0,
1116 .svhs = 2, 1116 .svhs = 2,
1117 .gpiomask = 15, 1117 .gpiomask = 15,
1118 .muxsel = { 2, 3, 1, 1}, 1118 .muxsel = { 2, 3, 1, 1 },
1119 .audiomux = {2,0,0,0,1}, 1119 .audiomux = {2,0,0,0,1 },
1120 .needs_tvaudio = 1, 1120 .needs_tvaudio = 1,
1121 .pll = PLL_28, 1121 .pll = PLL_28,
1122 .tuner_type = -1, 1122 .tuner_type = -1,
@@ -1130,8 +1130,8 @@ struct tvcard bttv_tvcards[] = {
1130 .tuner = 0, 1130 .tuner = 0,
1131 .svhs = 2, 1131 .svhs = 2,
1132 .gpiomask = 0x010f00, 1132 .gpiomask = 0x010f00,
1133 .muxsel = {2, 3, 0, 0}, 1133 .muxsel = {2, 3, 0, 0 },
1134 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0}, 1134 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 },
1135 .no_msp34xx = 1, 1135 .no_msp34xx = 1,
1136 .pll = PLL_28, 1136 .pll = PLL_28,
1137 .tuner_type = TUNER_ALPS_TSHC6_NTSC, 1137 .tuner_type = TUNER_ALPS_TSHC6_NTSC,
@@ -1172,8 +1172,8 @@ struct tvcard bttv_tvcards[] = {
1172 .tuner = 0, 1172 .tuner = 0,
1173 .svhs = 2, 1173 .svhs = 2,
1174 .gpiomask = 7, 1174 .gpiomask = 7,
1175 .muxsel = { 2, 0, 1, 1}, 1175 .muxsel = { 2, 0, 1, 1 },
1176 .audiomux = { 0, 1, 2, 3, 4}, 1176 .audiomux = { 0, 1, 2, 3, 4 },
1177 .pll = PLL_28, 1177 .pll = PLL_28,
1178 .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */, 1178 .tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */,
1179 .tuner_addr = ADDR_UNSET, 1179 .tuner_addr = ADDR_UNSET,
@@ -1189,8 +1189,8 @@ struct tvcard bttv_tvcards[] = {
1189 .tuner = 0, 1189 .tuner = 0,
1190 .svhs = 3, 1190 .svhs = 3,
1191 .gpiomask = 0x03000F, 1191 .gpiomask = 0x03000F,
1192 .muxsel = { 2, 3, 1, 1}, 1192 .muxsel = { 2, 3, 1, 1 },
1193 .audiomux = { 1, 0xd0001, 0, 0, 10}, 1193 .audiomux = { 1, 0xd0001, 0, 0, 10 },
1194 /* sound path (5 sources): 1194 /* sound path (5 sources):
1195 MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) 1195 MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
1196 0= ext. Audio IN 1196 0= ext. Audio IN
@@ -1215,7 +1215,7 @@ struct tvcard bttv_tvcards[] = {
1215 .tuner = 0, 1215 .tuner = 0,
1216 .svhs = 2, 1216 .svhs = 2,
1217 .gpiomask = 0x1c, 1217 .gpiomask = 0x1c,
1218 .muxsel = { 2, 3, 1, 1}, 1218 .muxsel = { 2, 3, 1, 1 },
1219 .audiomux = { 0, 0, 0x10, 8, 4 }, 1219 .audiomux = { 0, 0, 0x10, 8, 4 },
1220 .needs_tvaudio = 1, 1220 .needs_tvaudio = 1,
1221 .pll = PLL_28, 1221 .pll = PLL_28,
@@ -1236,7 +1236,7 @@ struct tvcard bttv_tvcards[] = {
1236 .tuner = 0, 1236 .tuner = 0,
1237 .svhs = 2, 1237 .svhs = 2,
1238 .gpiomask = 0x18e0, 1238 .gpiomask = 0x18e0,
1239 .muxsel = { 2, 3, 1, 1}, 1239 .muxsel = { 2, 3, 1, 1 },
1240 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 }, 1240 .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 },
1241 /* For cards with tda9820/tda9821: 1241 /* For cards with tda9820/tda9821:
1242 0x0000: Tuner normal stereo 1242 0x0000: Tuner normal stereo
@@ -1256,8 +1256,8 @@ struct tvcard bttv_tvcards[] = {
1256 .tuner = 0, 1256 .tuner = 0,
1257 .svhs = 2, 1257 .svhs = 2,
1258 .gpiomask = 0xF, 1258 .gpiomask = 0xF,
1259 .muxsel = { 2, 3, 1, 0}, 1259 .muxsel = { 2, 3, 1, 0 },
1260 .audiomux = { 2, 0, 0, 0, 10}, 1260 .audiomux = { 2, 0, 0, 0, 10 },
1261 .needs_tvaudio = 0, 1261 .needs_tvaudio = 0,
1262 .pll = PLL_28, 1262 .pll = PLL_28,
1263 .tuner_type = TUNER_TEMIC_PAL, 1263 .tuner_type = TUNER_TEMIC_PAL,
@@ -1274,7 +1274,7 @@ struct tvcard bttv_tvcards[] = {
1274 .tuner = 0, 1274 .tuner = 0,
1275 .svhs = 2, 1275 .svhs = 2,
1276 .gpiomask = 0x1800, 1276 .gpiomask = 0x1800,
1277 .muxsel = { 2, 3, 1, 1}, 1277 .muxsel = { 2, 3, 1, 1 },
1278 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 }, 1278 .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
1279 .pll = PLL_28, 1279 .pll = PLL_28,
1280 .tuner_type = 5, 1280 .tuner_type = 5,
@@ -1324,8 +1324,8 @@ struct tvcard bttv_tvcards[] = {
1324 .tuner = 0, 1324 .tuner = 0,
1325 .svhs = 2, 1325 .svhs = 2,
1326 .gpiomask = 0x03000F, 1326 .gpiomask = 0x03000F,
1327 .muxsel = { 2, 3, 1, 0}, 1327 .muxsel = { 2, 3, 1, 0 },
1328 .audiomux = { 2,0,0,0,1 }, 1328 .audiomux = { 2, 0, 0, 0, 1 },
1329 .pll = PLL_28, 1329 .pll = PLL_28,
1330 .tuner_type = 0, 1330 .tuner_type = 0,
1331 .tuner_addr = ADDR_UNSET, 1331 .tuner_addr = ADDR_UNSET,
@@ -1341,8 +1341,8 @@ struct tvcard bttv_tvcards[] = {
1341 .tuner = 0, 1341 .tuner = 0,
1342 .svhs = -1, 1342 .svhs = -1,
1343 .gpiomask = 11, 1343 .gpiomask = 11,
1344 .muxsel = { 2, 3, 1, 1}, 1344 .muxsel = { 2, 3, 1, 1 },
1345 .audiomux = { 2, 0, 0, 1, 8}, 1345 .audiomux = { 2, 0, 0, 1, 8 },
1346 .pll = PLL_35, 1346 .pll = PLL_35,
1347 .tuner_type = TUNER_TEMIC_PAL, 1347 .tuner_type = TUNER_TEMIC_PAL,
1348 .tuner_addr = ADDR_UNSET, 1348 .tuner_addr = ADDR_UNSET,
@@ -1356,7 +1356,7 @@ struct tvcard bttv_tvcards[] = {
1356 .tuner = -1, 1356 .tuner = -1,
1357 .svhs = 1, 1357 .svhs = 1,
1358 .gpiomask = 0xF, 1358 .gpiomask = 0xF,
1359 .muxsel = { 2, 2}, 1359 .muxsel = { 2, 2 },
1360 .audiomux = { }, 1360 .audiomux = { },
1361 .no_msp34xx = 1, 1361 .no_msp34xx = 1,
1362 .needs_tvaudio = 0, 1362 .needs_tvaudio = 0,
@@ -1375,8 +1375,8 @@ struct tvcard bttv_tvcards[] = {
1375 .tuner = 0, 1375 .tuner = 0,
1376 .svhs = 2, 1376 .svhs = 2,
1377 .gpiomask = 0xFF, 1377 .gpiomask = 0xFF,
1378 .muxsel = { 2, 3, 1, 0}, 1378 .muxsel = { 2, 3, 1, 0 },
1379 .audiomux = { 1, 0, 4, 4, 9}, 1379 .audiomux = { 1, 0, 4, 4, 9 },
1380 .needs_tvaudio = 0, 1380 .needs_tvaudio = 0,
1381 .pll = PLL_28, 1381 .pll = PLL_28,
1382 .tuner_type = TUNER_PHILIPS_PAL, 1382 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1392,7 +1392,7 @@ struct tvcard bttv_tvcards[] = {
1392 .svhs = 2, 1392 .svhs = 2,
1393 .gpiomask = 0xf03f, 1393 .gpiomask = 0xf03f,
1394 .muxsel = { 2, 3, 1, 0 }, 1394 .muxsel = { 2, 3, 1, 0 },
1395 .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe}, 1395 .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe },
1396 .pll = PLL_28, 1396 .pll = PLL_28,
1397 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, 1397 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
1398 .tuner_addr = ADDR_UNSET, 1398 .tuner_addr = ADDR_UNSET,
@@ -1408,8 +1408,8 @@ struct tvcard bttv_tvcards[] = {
1408 .tuner = 0, 1408 .tuner = 0,
1409 .svhs = -1, 1409 .svhs = -1,
1410 .gpiomask = 1, 1410 .gpiomask = 1,
1411 .muxsel = { 2, 3, 0, 1}, 1411 .muxsel = { 2, 3, 0, 1 },
1412 .audiomux = { 0, 0, 1, 0, 0}, 1412 .audiomux = { 0, 0, 1, 0, 0 },
1413 .no_msp34xx = 1, 1413 .no_msp34xx = 1,
1414 .pll = PLL_28, 1414 .pll = PLL_28,
1415 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, 1415 .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
@@ -1424,7 +1424,7 @@ struct tvcard bttv_tvcards[] = {
1424 .tuner = 0, 1424 .tuner = 0,
1425 .svhs = 2, 1425 .svhs = 2,
1426 .gpiomask = 0x18e0, 1426 .gpiomask = 0x18e0,
1427 .muxsel = { 2, 3, 0, 1}, 1427 .muxsel = { 2, 3, 0, 1 },
1428 /* Radio changed from 1e80 to 0x800 to make 1428 /* Radio changed from 1e80 to 0x800 to make
1429 FlyVideo2000S in .hu happy (gm)*/ 1429 FlyVideo2000S in .hu happy (gm)*/
1430 /* -dk-???: set mute=0x1800 for tda9874h daughterboard */ 1430 /* -dk-???: set mute=0x1800 for tda9874h daughterboard */
@@ -1445,8 +1445,8 @@ struct tvcard bttv_tvcards[] = {
1445 .tuner = 0, 1445 .tuner = 0,
1446 .svhs = 2, 1446 .svhs = 2,
1447 .gpiomask = 0xffff00, 1447 .gpiomask = 0xffff00,
1448 .muxsel = { 2, 3, 1, 1}, 1448 .muxsel = { 2, 3, 1, 1 },
1449 .audiomux = { 0x500, 0x500, 0x300, 0x900, 0x900}, 1449 .audiomux = { 0x500, 0x500, 0x300, 0x900, 0x900 },
1450 .needs_tvaudio = 1, 1450 .needs_tvaudio = 1,
1451 .pll = PLL_28, 1451 .pll = PLL_28,
1452 .tuner_type = TUNER_PHILIPS_PAL, 1452 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1462,8 +1462,8 @@ struct tvcard bttv_tvcards[] = {
1462 .tuner = 0, 1462 .tuner = 0,
1463 .svhs = 2, 1463 .svhs = 2,
1464 .gpiomask = 0x010f00, 1464 .gpiomask = 0x010f00,
1465 .muxsel = {2, 3, 0, 0}, 1465 .muxsel = {2, 3, 0, 0 },
1466 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0}, 1466 .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 },
1467 .no_msp34xx = 1, 1467 .no_msp34xx = 1,
1468 .pll = PLL_28, 1468 .pll = PLL_28,
1469 .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, 1469 .tuner_type = TUNER_SHARP_2U5JF5540_NTSC,
@@ -1487,7 +1487,7 @@ struct tvcard bttv_tvcards[] = {
1487 .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff}, 1487 .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff},
1488 /* tvtuner, radio, external,internal, mute, stereo 1488 /* tvtuner, radio, external,internal, mute, stereo
1489 * tuner, Composit, SVid, Composit-on-Svid-adapter */ 1489 * tuner, Composit, SVid, Composit-on-Svid-adapter */
1490 .muxsel = { 2, 3 ,0 ,1}, 1490 .muxsel = { 2, 3 ,0 ,1 },
1491 .tuner_type = TUNER_MT2032, 1491 .tuner_type = TUNER_MT2032,
1492 .tuner_addr = ADDR_UNSET, 1492 .tuner_addr = ADDR_UNSET,
1493 .radio_addr = ADDR_UNSET, 1493 .radio_addr = ADDR_UNSET,
@@ -1515,8 +1515,8 @@ struct tvcard bttv_tvcards[] = {
1515 .tuner = 0, 1515 .tuner = 0,
1516 .svhs = 2, 1516 .svhs = 2,
1517 .gpiomask = 15, 1517 .gpiomask = 15,
1518 .muxsel = { 2, 3, 1, 1}, 1518 .muxsel = { 2, 3, 1, 1 },
1519 .audiomux = { 0, 0, 11, 7, 13, 0}, /* TV and Radio with same GPIO ! */ 1519 .audiomux = { 0, 0, 11, 7, 13, 0 }, /* TV and Radio with same GPIO ! */
1520 .needs_tvaudio = 1, 1520 .needs_tvaudio = 1,
1521 .pll = PLL_28, 1521 .pll = PLL_28,
1522 .tuner_type = 25, 1522 .tuner_type = 25,
@@ -1537,7 +1537,7 @@ struct tvcard bttv_tvcards[] = {
1537 .audio_inputs = 0, 1537 .audio_inputs = 0,
1538 .tuner = -1, 1538 .tuner = -1,
1539 .svhs = 2, 1539 .svhs = 2,
1540 .muxsel = { 2, 3, 1, 1}, /* AV1, AV2, SVHS, CVid adapter on SVHS */ 1540 .muxsel = { 2, 3, 1, 1 }, /* AV1, AV2, SVHS, CVid adapter on SVHS */
1541 .pll = PLL_28, 1541 .pll = PLL_28,
1542 .no_msp34xx = 1, 1542 .no_msp34xx = 1,
1543 .tuner_type = UNSET, 1543 .tuner_type = UNSET,
@@ -1583,7 +1583,7 @@ struct tvcard bttv_tvcards[] = {
1583 .tuner = -1, 1583 .tuner = -1,
1584 .svhs = 4, 1584 .svhs = 4,
1585 .gpiomask = 0, 1585 .gpiomask = 0,
1586 .muxsel = { 2, 3, 1, 0, 0}, 1586 .muxsel = { 2, 3, 1, 0, 0 },
1587 .audiomux = { 0 }, 1587 .audiomux = { 0 },
1588 .needs_tvaudio = 0, 1588 .needs_tvaudio = 0,
1589 .tuner_type = -1, 1589 .tuner_type = -1,
@@ -1696,7 +1696,7 @@ struct tvcard bttv_tvcards[] = {
1696 .name = "DSP Design TCVIDEO", 1696 .name = "DSP Design TCVIDEO",
1697 .video_inputs = 4, 1697 .video_inputs = 4,
1698 .svhs = -1, 1698 .svhs = -1,
1699 .muxsel = { 2, 3, 1, 0}, 1699 .muxsel = { 2, 3, 1, 0 },
1700 .pll = PLL_28, 1700 .pll = PLL_28,
1701 .tuner_type = -1, 1701 .tuner_type = -1,
1702 .tuner_addr = ADDR_UNSET, 1702 .tuner_addr = ADDR_UNSET,
@@ -1710,7 +1710,7 @@ struct tvcard bttv_tvcards[] = {
1710 .audio_inputs = 1, 1710 .audio_inputs = 1,
1711 .tuner = 0, 1711 .tuner = 0,
1712 .svhs = 2, 1712 .svhs = 2,
1713 .muxsel = { 2, 0, 1, 1}, 1713 .muxsel = { 2, 0, 1, 1 },
1714 .needs_tvaudio = 1, 1714 .needs_tvaudio = 1,
1715 .pll = PLL_28, 1715 .pll = PLL_28,
1716 .tuner_type = -1, 1716 .tuner_type = -1,
@@ -1727,7 +1727,7 @@ struct tvcard bttv_tvcards[] = {
1727 .tuner = 0, 1727 .tuner = 0,
1728 .svhs = 2, 1728 .svhs = 2,
1729 .gpiomask = 0x0f0f80, 1729 .gpiomask = 0x0f0f80,
1730 .muxsel = {2, 3, 1, 0}, 1730 .muxsel = {2, 3, 1, 0 },
1731 .audiomux = {0x030000, 0x010000, 0, 0, 0x020000, 0}, 1731 .audiomux = {0x030000, 0x010000, 0, 0, 0x020000, 0},
1732 .no_msp34xx = 1, 1732 .no_msp34xx = 1,
1733 .pll = PLL_28, 1733 .pll = PLL_28,
@@ -1944,7 +1944,7 @@ struct tvcard bttv_tvcards[] = {
1944 .no_msp34xx = 1, 1944 .no_msp34xx = 1,
1945 .no_tda9875 = 1, 1945 .no_tda9875 = 1,
1946 .no_tda7432 = 1, 1946 .no_tda7432 = 1,
1947 .muxsel = { 3, 0, 1, 2}, 1947 .muxsel = { 3, 0, 1, 2 },
1948 .pll = PLL_28, 1948 .pll = PLL_28,
1949 .no_gpioirq = 1, 1949 .no_gpioirq = 1,
1950 .has_dvb = 1, 1950 .has_dvb = 1,
@@ -1957,7 +1957,7 @@ struct tvcard bttv_tvcards[] = {
1957 .svhs = 3, 1957 .svhs = 3,
1958 .gpiomask = 2, 1958 .gpiomask = 2,
1959 /* TV, Comp1, Composite over SVID con, SVID */ 1959 /* TV, Comp1, Composite over SVID con, SVID */
1960 .muxsel = { 2, 3, 1, 1}, 1960 .muxsel = { 2, 3, 1, 1 },
1961 .audiomux = { 2, 2, 0, 0, 0 }, 1961 .audiomux = { 2, 2, 0, 0, 0 },
1962 .pll = PLL_28, 1962 .pll = PLL_28,
1963 .has_radio = 1, 1963 .has_radio = 1,
@@ -2074,7 +2074,7 @@ struct tvcard bttv_tvcards[] = {
2074 .audio_inputs = 1, 2074 .audio_inputs = 1,
2075 .tuner = 0, 2075 .tuner = 0,
2076 .svhs = 2, 2076 .svhs = 2,
2077 .muxsel = { 2, 3, 1, 1}, /* Tuner, CVid, SVid, CVid over SVid connector */ 2077 .muxsel = { 2, 3, 1, 1 }, /* Tuner, CVid, SVid, CVid over SVid connector */
2078 .gpiomask = 0, 2078 .gpiomask = 0,
2079 .no_tda9875 = 1, 2079 .no_tda9875 = 1,
2080 .no_tda7432 = 1, 2080 .no_tda7432 = 1,
@@ -2128,7 +2128,7 @@ struct tvcard bttv_tvcards[] = {
2128 .video_inputs = 1, 2128 .video_inputs = 1,
2129 .tuner = -1, 2129 .tuner = -1,
2130 .svhs = -1, 2130 .svhs = -1,
2131 .muxsel = { 2, 3, 1, 0}, 2131 .muxsel = { 2, 3, 1, 0 },
2132 .no_msp34xx = 1, 2132 .no_msp34xx = 1,
2133 .no_tda9875 = 1, 2133 .no_tda9875 = 1,
2134 .no_tda7432 = 1, 2134 .no_tda7432 = 1,
@@ -2166,7 +2166,7 @@ struct tvcard bttv_tvcards[] = {
2166 .tuner = -1, /* card has no tuner */ 2166 .tuner = -1, /* card has no tuner */
2167 .svhs = 3, 2167 .svhs = 3,
2168 .gpiomask = 0x00, 2168 .gpiomask = 0x00,
2169 .muxsel = { 2, 3, 1, 0}, 2169 .muxsel = { 2, 3, 1, 0 },
2170 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2170 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
2171 .needs_tvaudio = 1, 2171 .needs_tvaudio = 1,
2172 .pll = PLL_28, 2172 .pll = PLL_28,
@@ -2181,7 +2181,7 @@ struct tvcard bttv_tvcards[] = {
2181 .tuner = -1, /* card has no tuner */ 2181 .tuner = -1, /* card has no tuner */
2182 .svhs = 3, 2182 .svhs = 3,
2183 .gpiomask = 0x00, 2183 .gpiomask = 0x00,
2184 .muxsel = { 2, 3, 1, 1}, 2184 .muxsel = { 2, 3, 1, 1 },
2185 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */ 2185 .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
2186 .needs_tvaudio = 1, 2186 .needs_tvaudio = 1,
2187 .pll = PLL_28, 2187 .pll = PLL_28,
@@ -2268,7 +2268,7 @@ struct tvcard bttv_tvcards[] = {
2268 .audio_inputs = 1, 2268 .audio_inputs = 1,
2269 .tuner = 0, 2269 .tuner = 0,
2270 .svhs = 2, 2270 .svhs = 2,
2271 .muxsel = { 2, 3, 1, 0}, 2271 .muxsel = { 2, 3, 1, 0 },
2272 .tuner_type = TUNER_PHILIPS_ATSC, 2272 .tuner_type = TUNER_PHILIPS_ATSC,
2273 .tuner_addr = ADDR_UNSET, 2273 .tuner_addr = ADDR_UNSET,
2274 .radio_addr = ADDR_UNSET, 2274 .radio_addr = ADDR_UNSET,
@@ -2291,7 +2291,7 @@ struct tvcard bttv_tvcards[] = {
2291 .audio_inputs = 0, 2291 .audio_inputs = 0,
2292 .svhs = 1, 2292 .svhs = 1,
2293 .tuner = -1, 2293 .tuner = -1,
2294 .muxsel = { 3, 1, 1, 3}, /* Vid In, SVid In, Vid over SVid in connector */ 2294 .muxsel = { 3, 1, 1, 3 }, /* Vid In, SVid In, Vid over SVid in connector */
2295 .no_msp34xx = 1, 2295 .no_msp34xx = 1,
2296 .no_tda9875 = 1, 2296 .no_tda9875 = 1,
2297 .no_tda7432 = 1, 2297 .no_tda7432 = 1,
@@ -2307,8 +2307,8 @@ struct tvcard bttv_tvcards[] = {
2307 .tuner = 0, 2307 .tuner = 0,
2308 .svhs = 2, 2308 .svhs = 2,
2309 .gpiomask = 3, 2309 .gpiomask = 3,
2310 .muxsel = { 2, 3, 1, 1}, 2310 .muxsel = { 2, 3, 1, 1 },
2311 .audiomux = { 1, 1, 1, 1, 0}, 2311 .audiomux = { 1, 1, 1, 1, 0 },
2312 .needs_tvaudio = 1, 2312 .needs_tvaudio = 1,
2313 .tuner_type = TUNER_PHILIPS_PAL, 2313 .tuner_type = TUNER_PHILIPS_PAL,
2314 .tuner_addr = ADDR_UNSET, 2314 .tuner_addr = ADDR_UNSET,
@@ -2327,7 +2327,7 @@ struct tvcard bttv_tvcards[] = {
2327 .tuner_addr = ADDR_UNSET, 2327 .tuner_addr = ADDR_UNSET,
2328 .radio_addr = ADDR_UNSET, 2328 .radio_addr = ADDR_UNSET,
2329 .pll = PLL_28, 2329 .pll = PLL_28,
2330 .muxsel = { 2, 2, 2, 2}, 2330 .muxsel = { 2, 2, 2, 2 },
2331 .gpiomask = 0x3F, 2331 .gpiomask = 0x3F,
2332 .muxsel_hook = gvc1100_muxsel, 2332 .muxsel_hook = gvc1100_muxsel,
2333 }, 2333 },
@@ -2338,8 +2338,8 @@ struct tvcard bttv_tvcards[] = {
2338 .tuner = 0, 2338 .tuner = 0,
2339 .svhs = 2, 2339 .svhs = 2,
2340 .gpiomask = 0x008007, 2340 .gpiomask = 0x008007,
2341 .muxsel = {2, 3, 0, 0}, 2341 .muxsel = { 2, 3, 0, 0 },
2342 .audiomux = {0, 0, 0, 0, 0x000003, 0}, 2342 .audiomux = { 0, 0, 0, 0, 0x000003, 0 },
2343 .pll = PLL_28, 2343 .pll = PLL_28,
2344 .tuner_type = TUNER_PHILIPS_PAL, 2344 .tuner_type = TUNER_PHILIPS_PAL,
2345 .tuner_addr = ADDR_UNSET, 2345 .tuner_addr = ADDR_UNSET,
@@ -2374,7 +2374,7 @@ struct tvcard bttv_tvcards[] = {
2374 .svhs = 2, 2374 .svhs = 2,
2375 .needs_tvaudio = 0, 2375 .needs_tvaudio = 0,
2376 .gpiomask = 0x68, 2376 .gpiomask = 0x68,
2377 .muxsel = { 2, 3, 1}, 2377 .muxsel = { 2, 3, 1 },
2378 .audiomux = { 0x68, 0x68, 0x61, 0x61, 0x00 }, 2378 .audiomux = { 0x68, 0x68, 0x61, 0x61, 0x00 },
2379 .pll = PLL_28, 2379 .pll = PLL_28,
2380 }, 2380 },
@@ -2433,7 +2433,7 @@ struct tvcard bttv_tvcards[] = {
2433 .svhs = 2, 2433 .svhs = 2,
2434 .gpiomask = 0x0000000f, 2434 .gpiomask = 0x0000000f,
2435 .muxsel = { 2, 1, 1 }, 2435 .muxsel = { 2, 1, 1 },
2436 .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00}, 2436 .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00 },
2437 .tuner_type = TUNER_TEMIC_PAL, 2437 .tuner_type = TUNER_TEMIC_PAL,
2438 .tuner_addr = ADDR_UNSET, 2438 .tuner_addr = ADDR_UNSET,
2439 .radio_addr = ADDR_UNSET, 2439 .radio_addr = ADDR_UNSET,
@@ -2466,7 +2466,7 @@ struct tvcard bttv_tvcards[] = {
2466 .video_inputs = 2, 2466 .video_inputs = 2,
2467 .tuner = -1, 2467 .tuner = -1,
2468 .svhs = 1, 2468 .svhs = 1,
2469 .muxsel = { 3, 1, 2, 0}, /* Comp0, S-Video, ?, ? */ 2469 .muxsel = { 3, 1, 2, 0 }, /* Comp0, S-Video, ?, ? */
2470 .no_msp34xx = 1, 2470 .no_msp34xx = 1,
2471 .no_tda9875 = 1, 2471 .no_tda9875 = 1,
2472 .no_tda7432 = 1, 2472 .no_tda7432 = 1,
@@ -2523,8 +2523,8 @@ struct tvcard bttv_tvcards[] = {
2523 .tuner = 0, 2523 .tuner = 0,
2524 .svhs = -1, 2524 .svhs = -1,
2525 .gpiomask = 0xFF, 2525 .gpiomask = 0xFF,
2526 .muxsel = { 2, 3, 1, 1}, 2526 .muxsel = { 2, 3, 1, 1 },
2527 .audiomux = { 2, 0, 0, 0, 10}, 2527 .audiomux = { 2, 0, 0, 0, 10 },
2528 .needs_tvaudio = 0, 2528 .needs_tvaudio = 0,
2529 .pll = PLL_28, 2529 .pll = PLL_28,
2530 .tuner_type = TUNER_PHILIPS_PAL, 2530 .tuner_type = TUNER_PHILIPS_PAL,
@@ -2557,8 +2557,8 @@ struct tvcard bttv_tvcards[] = {
2557 .tuner = 0, 2557 .tuner = 0,
2558 .svhs = 2, 2558 .svhs = 2,
2559 .gpiomask = 0x3f, 2559 .gpiomask = 0x3f,
2560 .muxsel = {2, 3, 1, 0}, 2560 .muxsel = {2, 3, 1, 0 },
2561 .audiomux = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31}, 2561 .audiomux = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31 },
2562 .no_msp34xx = 1, 2562 .no_msp34xx = 1,
2563 .pll = PLL_28, 2563 .pll = PLL_28,
2564 .tuner_type = TUNER_PHILIPS_NTSC_M, 2564 .tuner_type = TUNER_PHILIPS_NTSC_M,
@@ -2576,12 +2576,12 @@ struct tvcard bttv_tvcards[] = {
2576 .audio_inputs = 1, 2576 .audio_inputs = 1,
2577 .tuner = 0, 2577 .tuner = 0,
2578 .svhs = 2, 2578 .svhs = 2,
2579 .muxsel = { 2, 3, 1, 0}, 2579 .muxsel = { 2, 3, 1, 0 },
2580 .tuner_type = TUNER_PHILIPS_NTSC, 2580 .tuner_type = TUNER_PHILIPS_NTSC,
2581 .tuner_addr = ADDR_UNSET, 2581 .tuner_addr = ADDR_UNSET,
2582 .radio_addr = ADDR_UNSET, 2582 .radio_addr = ADDR_UNSET,
2583 .gpiomask = 0x008007, 2583 .gpiomask = 0x008007,
2584 .audiomux = { 0, 0x000001,0,0, 0}, 2584 .audiomux = { 0, 0x000001,0,0, 0 },
2585 .needs_tvaudio = 1, 2585 .needs_tvaudio = 1,
2586 .has_radio = 1, 2586 .has_radio = 1,
2587 }, 2587 },
@@ -2672,7 +2672,7 @@ struct tvcard bttv_tvcards[] = {
2672 .audio_inputs = 1, 2672 .audio_inputs = 1,
2673 .tuner = 0, 2673 .tuner = 0,
2674 .svhs = 2, 2674 .svhs = 2,
2675 .muxsel = { 2, 3, 1, 0}, 2675 .muxsel = { 2, 3, 1, 0 },
2676 .tuner_type = -1, 2676 .tuner_type = -1,
2677 .tuner_addr = ADDR_UNSET, 2677 .tuner_addr = ADDR_UNSET,
2678 .radio_addr = ADDR_UNSET, 2678 .radio_addr = ADDR_UNSET,
@@ -2706,7 +2706,7 @@ struct tvcard bttv_tvcards[] = {
2706 .tuner = 0, 2706 .tuner = 0,
2707 .svhs = 2, 2707 .svhs = 2,
2708 .gpiomask = 0x01fe00, 2708 .gpiomask = 0x01fe00,
2709 .muxsel = { 2, 3, 1, 1}, 2709 .muxsel = { 2, 3, 1, 1 },
2710 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 }, 2710 .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
2711 .needs_tvaudio = 1, 2711 .needs_tvaudio = 1,
2712 .pll = PLL_28, 2712 .pll = PLL_28,
@@ -2794,8 +2794,8 @@ struct tvcard bttv_tvcards[] = {
2794 .tuner = 0, 2794 .tuner = 0,
2795 .svhs = 2, 2795 .svhs = 2,
2796 .gpiomask = 15, 2796 .gpiomask = 15,
2797 .muxsel = { 2, 3, 1, 1}, 2797 .muxsel = { 2, 3, 1, 1 },
2798 .audiomux = {2,0,0,0,1}, 2798 .audiomux = { 2, 0, 0, 0, 1 },
2799 .needs_tvaudio = 1, 2799 .needs_tvaudio = 1,
2800 .pll = PLL_28, 2800 .pll = PLL_28,
2801 .tuner_type = 2, 2801 .tuner_type = 2,
@@ -2810,8 +2810,8 @@ struct tvcard bttv_tvcards[] = {
2810 .tuner = 0, 2810 .tuner = 0,
2811 .svhs = 2, 2811 .svhs = 2,
2812 .gpiomask = 0x108007, 2812 .gpiomask = 0x108007,
2813 .muxsel = { 2, 3, 1, 1}, 2813 .muxsel = { 2, 3, 1, 1 },
2814 .audiomux = { 100000, 100002, 100002, 100000}, 2814 .audiomux = { 100000, 100002, 100002, 100000 },
2815 .no_msp34xx = 1, 2815 .no_msp34xx = 1,
2816 .no_tda9875 = 1, 2816 .no_tda9875 = 1,
2817 .no_tda7432 = 1, 2817 .no_tda7432 = 1,
@@ -2828,7 +2828,7 @@ struct tvcard bttv_tvcards[] = {
2828 .tuner = -1, 2828 .tuner = -1,
2829 .svhs = -1, 2829 .svhs = -1,
2830 .gpiomask = 0x0f, /* old: 7 */ 2830 .gpiomask = 0x0f, /* old: 7 */
2831 .muxsel = { 0, 1, 3, 2}, /* Composite 0-3 */ 2831 .muxsel = { 0, 1, 3, 2 }, /* Composite 0-3 */
2832 .no_msp34xx = 1, 2832 .no_msp34xx = 1,
2833 .no_tda9875 = 1, 2833 .no_tda9875 = 1,
2834 .no_tda7432 = 1, 2834 .no_tda7432 = 1,
@@ -2836,6 +2836,29 @@ struct tvcard bttv_tvcards[] = {
2836 .tuner_addr = ADDR_UNSET, 2836 .tuner_addr = ADDR_UNSET,
2837 .radio_addr = ADDR_UNSET, 2837 .radio_addr = ADDR_UNSET,
2838 }, 2838 },
2839 [BTTV_BOARD_MACHTV_MAGICTV] = {
2840 /* Julian Calaby <julian.calaby@gmail.com>
2841 * Slightly different from original MachTV definition (0x60)
2842
2843 * FIXME: RegSpy says gpiomask should be "0x001c800f", but it
2844 * stuffs up remote chip. Bug is a pin on the jaecs is not set
2845 * properly (methinks) causing no keyup bits being set */
2846
2847 .name = "MagicTV", /* rebranded MachTV */
2848 .video_inputs = 3,
2849 .audio_inputs = 1,
2850 .tuner = 0,
2851 .svhs = 2,
2852 .gpiomask = 7,
2853 .muxsel = { 2, 3, 1, 1 },
2854 .audiomux = { 0, 1, 2, 3, 4 },
2855 .tuner_type = TUNER_TEMIC_4009FR5_PAL,
2856 .tuner_addr = ADDR_UNSET,
2857 .radio_addr = ADDR_UNSET,
2858 .pll = PLL_28,
2859 .has_radio = 1,
2860 .has_remote = 1,
2861 },
2839}; 2862};
2840 2863
2841static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); 2864static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c
index 575ce8b8e714..d64accc17b0e 100644
--- a/drivers/media/video/bttv-gpio.c
+++ b/drivers/media/video/bttv-gpio.c
@@ -64,10 +64,9 @@ int bttv_sub_add_device(struct bttv_core *core, char *name)
64 struct bttv_sub_device *sub; 64 struct bttv_sub_device *sub;
65 int err; 65 int err;
66 66
67 sub = kmalloc(sizeof(*sub),GFP_KERNEL); 67 sub = kzalloc(sizeof(*sub),GFP_KERNEL);
68 if (NULL == sub) 68 if (NULL == sub)
69 return -ENOMEM; 69 return -ENOMEM;
70 memset(sub,0,sizeof(*sub));
71 70
72 sub->core = core; 71 sub->core = core;
73 sub->dev.parent = &core->pci->dev; 72 sub->dev.parent = &core->pci->dev;
diff --git a/drivers/media/video/bttv-input.c b/drivers/media/video/bttv-input.c
index 12197f1b2757..221b36e7f392 100644
--- a/drivers/media/video/bttv-input.c
+++ b/drivers/media/video/bttv-input.c
@@ -583,6 +583,12 @@ int bttv_input_init(struct bttv *btv)
583 btv->custom_irq = bttv_rc5_irq; 583 btv->custom_irq = bttv_rc5_irq;
584 ir->rc5_gpio = 1; 584 ir->rc5_gpio = 1;
585 break; 585 break;
586 case BTTV_BOARD_MACHTV_MAGICTV:
587 ir_codes = ir_codes_apac_viewcomp;
588 ir->mask_keycode = 0x001F00;
589 ir->mask_keyup = 0x004000;
590 ir->polling = 50; /* ms */
591 break;
586 } 592 }
587 if (NULL == ir_codes) { 593 if (NULL == ir_codes) {
588 dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n",btv->c.type); 594 dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n",btv->c.type);
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h
index 9feaa6bab207..e370d74f2a1b 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bttv.h
@@ -166,6 +166,7 @@
166#define BTTV_BOARD_ASOUND_SKYEYE 0x8d 166#define BTTV_BOARD_ASOUND_SKYEYE 0x8d
167#define BTTV_BOARD_SABRENT_TVFM 0x8e 167#define BTTV_BOARD_SABRENT_TVFM 0x8e
168#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f 168#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f
169#define BTTV_BOARD_MACHTV_MAGICTV 0x90
169 170
170/* i2c address list */ 171/* i2c address list */
171#define I2C_TSA5522 0xc2 172#define I2C_TSA5522 0xc2
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index 6194b0125576..297c32ab51e3 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -18,8 +18,11 @@
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
21#include <media/v4l2-common.h>
21 22
22#ifdef CONFIG_COMPAT 23#ifdef CONFIG_COMPAT
24
25
23struct video_tuner32 { 26struct video_tuner32 {
24 compat_int_t tuner; 27 compat_int_t tuner;
25 char name[32]; 28 char name[32];
@@ -30,27 +33,29 @@ struct video_tuner32 {
30 33
31static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 34static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
32{ 35{
33 if(get_user(kp->tuner, &up->tuner)) 36 if(!access_ok(VERIFY_READ, up, sizeof(struct video_tuner32)) ||
37 get_user(kp->tuner, &up->tuner) ||
38 copy_from_user(kp->name, up->name, 32) ||
39 get_user(kp->rangelow, &up->rangelow) ||
40 get_user(kp->rangehigh, &up->rangehigh) ||
41 get_user(kp->flags, &up->flags) ||
42 get_user(kp->mode, &up->mode) ||
43 get_user(kp->signal, &up->signal))
34 return -EFAULT; 44 return -EFAULT;
35 __copy_from_user(kp->name, up->name, 32);
36 __get_user(kp->rangelow, &up->rangelow);
37 __get_user(kp->rangehigh, &up->rangehigh);
38 __get_user(kp->flags, &up->flags);
39 __get_user(kp->mode, &up->mode);
40 __get_user(kp->signal, &up->signal);
41 return 0; 45 return 0;
42} 46}
43 47
44static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) 48static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)
45{ 49{
46 if(put_user(kp->tuner, &up->tuner)) 50 if(!access_ok(VERIFY_WRITE, up, sizeof(struct video_tuner32)) ||
47 return -EFAULT; 51 put_user(kp->tuner, &up->tuner) ||
48 __copy_to_user(up->name, kp->name, 32); 52 copy_to_user(up->name, kp->name, 32) ||
49 __put_user(kp->rangelow, &up->rangelow); 53 put_user(kp->rangelow, &up->rangelow) ||
50 __put_user(kp->rangehigh, &up->rangehigh); 54 put_user(kp->rangehigh, &up->rangehigh) ||
51 __put_user(kp->flags, &up->flags); 55 put_user(kp->flags, &up->flags) ||
52 __put_user(kp->mode, &up->mode); 56 put_user(kp->mode, &up->mode) ||
53 __put_user(kp->signal, &up->signal); 57 put_user(kp->signal, &up->signal))
58 return -EFAULT;
54 return 0; 59 return 0;
55} 60}
56 61
@@ -63,18 +68,19 @@ static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __u
63{ 68{
64 u32 tmp; 69 u32 tmp;
65 70
66 if (get_user(tmp, &up->base)) 71 if (!access_ok(VERIFY_READ, up, sizeof(struct video_buffer32)) ||
67 return -EFAULT; 72 get_user(tmp, &up->base) ||
73 get_user(kp->height, &up->height) ||
74 get_user(kp->width, &up->width) ||
75 get_user(kp->depth, &up->depth) ||
76 get_user(kp->bytesperline, &up->bytesperline))
77 return -EFAULT;
68 78
69 /* This is actually a physical address stored 79 /* This is actually a physical address stored
70 * as a void pointer. 80 * as a void pointer.
71 */ 81 */
72 kp->base = (void *)(unsigned long) tmp; 82 kp->base = (void *)(unsigned long) tmp;
73 83
74 __get_user(kp->height, &up->height);
75 __get_user(kp->width, &up->width);
76 __get_user(kp->depth, &up->depth);
77 __get_user(kp->bytesperline, &up->bytesperline);
78 return 0; 84 return 0;
79} 85}
80 86
@@ -82,12 +88,13 @@ static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __u
82{ 88{
83 u32 tmp = (u32)((unsigned long)kp->base); 89 u32 tmp = (u32)((unsigned long)kp->base);
84 90
85 if(put_user(tmp, &up->base)) 91 if(!access_ok(VERIFY_WRITE, up, sizeof(struct video_buffer32)) ||
86 return -EFAULT; 92 put_user(tmp, &up->base) ||
87 __put_user(kp->height, &up->height); 93 put_user(kp->height, &up->height) ||
88 __put_user(kp->width, &up->width); 94 put_user(kp->width, &up->width) ||
89 __put_user(kp->depth, &up->depth); 95 put_user(kp->depth, &up->depth) ||
90 __put_user(kp->bytesperline, &up->bytesperline); 96 put_user(kp->bytesperline, &up->bytesperline))
97 return -EFAULT;
91 return 0; 98 return 0;
92} 99}
93 100
@@ -121,14 +128,15 @@ static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
121/* You get back everything except the clips... */ 128/* You get back everything except the clips... */
122static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) 129static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
123{ 130{
124 if(put_user(kp->x, &up->x)) 131 if(!access_ok(VERIFY_WRITE, up, sizeof(struct video_window32)) ||
125 return -EFAULT; 132 put_user(kp->x, &up->x) ||
126 __put_user(kp->y, &up->y); 133 put_user(kp->y, &up->y) ||
127 __put_user(kp->width, &up->width); 134 put_user(kp->width, &up->width) ||
128 __put_user(kp->height, &up->height); 135 put_user(kp->height, &up->height) ||
129 __put_user(kp->chromakey, &up->chromakey); 136 put_user(kp->chromakey, &up->chromakey) ||
130 __put_user(kp->flags, &up->flags); 137 put_user(kp->flags, &up->flags) ||
131 __put_user(kp->clipcount, &up->clipcount); 138 put_user(kp->clipcount, &up->clipcount))
139 return -EFAULT;
132 return 0; 140 return 0;
133} 141}
134 142
@@ -150,11 +158,12 @@ struct v4l2_window32
150 158
151static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) 159static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
152{ 160{
153 if (copy_from_user(&kp->w, &up->w, sizeof(up->w))) 161 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_window32)) ||
154 return -EFAULT; 162 copy_from_user(&kp->w, &up->w, sizeof(up->w)) ||
155 __get_user(kp->field, &up->field); 163 get_user(kp->field, &up->field) ||
156 __get_user(kp->chromakey, &up->chromakey); 164 get_user(kp->chromakey, &up->chromakey) ||
157 __get_user(kp->clipcount, &up->clipcount); 165 get_user(kp->clipcount, &up->clipcount))
166 return -EFAULT;
158 if (kp->clipcount > 2048) 167 if (kp->clipcount > 2048)
159 return -EINVAL; 168 return -EINVAL;
160 if (kp->clipcount) { 169 if (kp->clipcount) {
@@ -165,7 +174,9 @@ static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
165 kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip)); 174 kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip));
166 kp->clips = kclips; 175 kp->clips = kclips;
167 while (--n >= 0) { 176 while (--n >= 0) {
168 copy_from_user(&kclips->c, &uclips->c, sizeof(uclips->c)); 177 if (!access_ok(VERIFY_READ, &uclips->c, sizeof(uclips->c)) ||
178 copy_from_user(&kclips->c, &uclips->c, sizeof(uclips->c)))
179 return -EFAULT;
169 kclips->next = n ? kclips + 1 : 0; 180 kclips->next = n ? kclips + 1 : 0;
170 uclips += 1; 181 uclips += 1;
171 kclips += 1; 182 kclips += 1;
@@ -177,32 +188,45 @@ static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
177 188
178static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) 189static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
179{ 190{
180 if (copy_to_user(&up->w, &kp->w, sizeof(up->w))) 191 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_window32)) ||
181 return -EFAULT; 192 copy_to_user(&up->w, &kp->w, sizeof(up->w)) ||
182 __put_user(kp->field, &up->field); 193 put_user(kp->field, &up->field) ||
183 __put_user(kp->chromakey, &up->chromakey); 194 put_user(kp->chromakey, &up->chromakey) ||
184 __put_user(kp->clipcount, &up->clipcount); 195 put_user(kp->clipcount, &up->clipcount))
196 return -EFAULT;
185 return 0; 197 return 0;
186} 198}
187 199
188static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) 200static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
189{ 201{
190 return copy_from_user(kp, up, sizeof(struct v4l2_pix_format)); 202 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_pix_format)) ||
203 copy_from_user(kp, up, sizeof(struct v4l2_pix_format)))
204 return -EFAULT;
205 return 0;
191} 206}
192 207
193static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) 208static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
194{ 209{
195 return copy_to_user(up, kp, sizeof(struct v4l2_pix_format)); 210 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_pix_format)) ||
211 copy_to_user(up, kp, sizeof(struct v4l2_pix_format)))
212 return -EFAULT;
213 return 0;
196} 214}
197 215
198static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) 216static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
199{ 217{
200 return copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)); 218 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_vbi_format)) ||
219 copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)))
220 return -EFAULT;
221 return 0;
201} 222}
202 223
203static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) 224static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
204{ 225{
205 return copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)); 226 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_vbi_format)) ||
227 copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)))
228 return -EFAULT;
229 return 0;
206} 230}
207 231
208struct v4l2_format32 232struct v4l2_format32
@@ -219,8 +243,9 @@ struct v4l2_format32
219 243
220static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 244static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
221{ 245{
222 if(get_user(kp->type, &up->type)) 246 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)) ||
223 return -EFAULT; 247 get_user(kp->type, &up->type))
248 return -EFAULT;
224 switch (kp->type) { 249 switch (kp->type) {
225 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 250 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
226 return get_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix); 251 return get_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix);
@@ -237,7 +262,8 @@ static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user
237 262
238static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 263static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
239{ 264{
240 if(put_user(kp->type, &up->type)) 265 if(!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_format32)) ||
266 put_user(kp->type, &up->type))
241 return -EFAULT; 267 return -EFAULT;
242 switch (kp->type) { 268 switch (kp->type) {
243 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 269 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -251,6 +277,23 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user
251 } 277 }
252} 278}
253 279
280static inline int get_v4l2_standard(struct v4l2_standard *kp, struct v4l2_standard __user *up)
281{
282 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_standard)) ||
283 copy_from_user(kp, up, sizeof(struct v4l2_standard)))
284 return -EFAULT;
285 return 0;
286
287}
288
289static inline int put_v4l2_standard(struct v4l2_standard *kp, struct v4l2_standard __user *up)
290{
291 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard)) ||
292 copy_to_user(up, kp, sizeof(struct v4l2_standard)))
293 return -EFAULT;
294 return 0;
295}
296
254struct v4l2_standard32 297struct v4l2_standard32
255{ 298{
256 __u32 index; 299 __u32 index;
@@ -264,18 +307,39 @@ struct v4l2_standard32
264static int get_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) 307static int get_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up)
265{ 308{
266 /* other fields are not set by the user, nor used by the driver */ 309 /* other fields are not set by the user, nor used by the driver */
267 return get_user(kp->index, &up->index); 310 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_standard32)) ||
311 get_user(kp->index, &up->index))
312 return -EFAULT;
313 return 0;
268} 314}
269 315
270static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) 316static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up)
271{ 317{
272 if(put_user(kp->index, &up->index)) 318 if(!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) ||
273 return -EFAULT; 319 put_user(kp->index, &up->index) ||
274 __copy_to_user(up->id, &kp->id, sizeof(__u64)); 320 copy_to_user(up->id, &kp->id, sizeof(__u64)) ||
275 __copy_to_user(up->name, kp->name, 24); 321 copy_to_user(up->name, kp->name, 24) ||
276 __put_user(kp->frameperiod, &up->frameperiod); 322 copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) ||
277 __put_user(kp->framelines, &up->framelines); 323 put_user(kp->framelines, &up->framelines) ||
278 __copy_to_user(up->reserved, kp->reserved, 4 * sizeof(__u32)); 324 copy_to_user(up->reserved, kp->reserved, 4 * sizeof(__u32)))
325 return -EFAULT;
326 return 0;
327}
328
329static inline int get_v4l2_tuner(struct v4l2_tuner *kp, struct v4l2_tuner __user *up)
330{
331 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_tuner)) ||
332 copy_from_user(kp, up, sizeof(struct v4l2_tuner)))
333 return -EFAULT;
334 return 0;
335
336}
337
338static inline int put_v4l2_tuner(struct v4l2_tuner *kp, struct v4l2_tuner __user *up)
339{
340 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_tuner)) ||
341 copy_to_user(up, kp, sizeof(struct v4l2_tuner)))
342 return -EFAULT;
279 return 0; 343 return 0;
280} 344}
281 345
@@ -304,12 +368,13 @@ struct v4l2_buffer32
304static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) 368static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up)
305{ 369{
306 370
307 if (get_user(kp->index, &up->index)) 371 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_buffer32)) ||
308 return -EFAULT; 372 get_user(kp->index, &up->index) ||
309 __get_user(kp->type, &up->type); 373 get_user(kp->type, &up->type) ||
310 __get_user(kp->flags, &up->flags); 374 get_user(kp->flags, &up->flags) ||
311 __get_user(kp->memory, &up->memory); 375 get_user(kp->memory, &up->memory) ||
312 __get_user(kp->input, &up->input); 376 get_user(kp->input, &up->input))
377 return -EFAULT;
313 switch(kp->memory) { 378 switch(kp->memory) {
314 case V4L2_MEMORY_MMAP: 379 case V4L2_MEMORY_MMAP:
315 break; 380 break;
@@ -317,12 +382,14 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
317 { 382 {
318 unsigned long tmp = (unsigned long)compat_ptr(up->m.userptr); 383 unsigned long tmp = (unsigned long)compat_ptr(up->m.userptr);
319 384
320 __get_user(kp->length, &up->length); 385 if(get_user(kp->length, &up->length) ||
321 __get_user(kp->m.userptr, &tmp); 386 get_user(kp->m.userptr, &tmp))
387 return -EFAULT;
322 } 388 }
323 break; 389 break;
324 case V4L2_MEMORY_OVERLAY: 390 case V4L2_MEMORY_OVERLAY:
325 __get_user(kp->m.offset, &up->m.offset); 391 if(get_user(kp->m.offset, &up->m.offset))
392 return -EFAULT;
326 break; 393 break;
327 } 394 }
328 return 0; 395 return 0;
@@ -330,32 +397,37 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
330 397
331static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) 398static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up)
332{ 399{
333 if (put_user(kp->index, &up->index)) 400 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_buffer32)) ||
334 return -EFAULT; 401 put_user(kp->index, &up->index) ||
335 __put_user(kp->type, &up->type); 402 put_user(kp->type, &up->type) ||
336 __put_user(kp->flags, &up->flags); 403 put_user(kp->flags, &up->flags) ||
337 __put_user(kp->memory, &up->memory); 404 put_user(kp->memory, &up->memory) ||
338 __put_user(kp->input, &up->input); 405 put_user(kp->input, &up->input))
406 return -EFAULT;
339 switch(kp->memory) { 407 switch(kp->memory) {
340 case V4L2_MEMORY_MMAP: 408 case V4L2_MEMORY_MMAP:
341 __put_user(kp->length, &up->length); 409 if (put_user(kp->length, &up->length) ||
342 __put_user(kp->m.offset, &up->m.offset); 410 put_user(kp->m.offset, &up->m.offset))
411 return -EFAULT;
343 break; 412 break;
344 case V4L2_MEMORY_USERPTR: 413 case V4L2_MEMORY_USERPTR:
345 __put_user(kp->length, &up->length); 414 if (put_user(kp->length, &up->length) ||
346 __put_user(kp->m.userptr, &up->m.userptr); 415 put_user(kp->m.userptr, &up->m.userptr))
416 return -EFAULT;
347 break; 417 break;
348 case V4L2_MEMORY_OVERLAY: 418 case V4L2_MEMORY_OVERLAY:
349 __put_user(kp->m.offset, &up->m.offset); 419 if (put_user(kp->m.offset, &up->m.offset))
420 return -EFAULT;
350 break; 421 break;
351 } 422 }
352 __put_user(kp->bytesused, &up->bytesused); 423 if (put_user(kp->bytesused, &up->bytesused) ||
353 __put_user(kp->field, &up->field); 424 put_user(kp->field, &up->field) ||
354 __put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec); 425 put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) ||
355 __put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec); 426 put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) ||
356 __copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)); 427 copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) ||
357 __put_user(kp->sequence, &up->sequence); 428 put_user(kp->sequence, &up->sequence) ||
358 __put_user(kp->reserved, &up->reserved); 429 put_user(kp->reserved, &up->reserved))
430 return -EFAULT;
359 return 0; 431 return 0;
360} 432}
361 433
@@ -371,11 +443,12 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
371{ 443{
372 u32 tmp; 444 u32 tmp;
373 445
374 if (get_user(tmp, &up->base)) 446 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) ||
375 return -EFAULT; 447 get_user(tmp, &up->base) ||
448 get_user(kp->capability, &up->capability) ||
449 get_user(kp->flags, &up->flags))
450 return -EFAULT;
376 kp->base = compat_ptr(tmp); 451 kp->base = compat_ptr(tmp);
377 __get_user(kp->capability, &up->capability);
378 __get_user(kp->flags, &up->flags);
379 get_v4l2_pix_format(&kp->fmt, &up->fmt); 452 get_v4l2_pix_format(&kp->fmt, &up->fmt);
380 return 0; 453 return 0;
381} 454}
@@ -384,25 +457,46 @@ static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
384{ 457{
385 u32 tmp = (u32)((unsigned long)kp->base); 458 u32 tmp = (u32)((unsigned long)kp->base);
386 459
387 if(put_user(tmp, &up->base)) 460 if(!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) ||
388 return -EFAULT; 461 put_user(tmp, &up->base) ||
389 __put_user(kp->capability, &up->capability); 462 put_user(kp->capability, &up->capability) ||
390 __put_user(kp->flags, &up->flags); 463 put_user(kp->flags, &up->flags))
464 return -EFAULT;
391 put_v4l2_pix_format(&kp->fmt, &up->fmt); 465 put_v4l2_pix_format(&kp->fmt, &up->fmt);
392 return 0; 466 return 0;
393} 467}
394 468
395struct v4l2_input32 /* identical layout, but different size */ 469static inline int get_v4l2_input32(struct v4l2_input *kp, struct v4l2_input __user *up)
396{ 470{
397 __u32 index; /* Which input */ 471 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_input) - 4) ||
398 __u8 name[32]; /* Label */ 472 copy_from_user(kp, up, sizeof(struct v4l2_input) - 4))
399 __u32 type; /* Type of input */ 473 return -EFAULT;
400 __u32 audioset; /* Associated audios (bitfield) */ 474 return 0;
401 __u32 tuner; /* Associated tuner */ 475}
402 __u32 std[2]; /* __u64 would get the padding wrong */ 476
403 __u32 status; 477static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input __user *up)
404 __u32 reserved[4]; 478{
405}; 479 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_input) - 4) ||
480 copy_to_user(up, kp, sizeof(struct v4l2_input) - 4))
481 return -EFAULT;
482 return 0;
483}
484
485static inline int get_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user *up)
486{
487 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_input)) ||
488 copy_from_user(kp, up, sizeof(struct v4l2_input)))
489 return -EFAULT;
490 return 0;
491}
492
493static inline int put_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user *up)
494{
495 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_input)) ||
496 copy_to_user(up, kp, sizeof(struct v4l2_input)))
497 return -EFAULT;
498 return 0;
499}
406 500
407#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) 501#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
408#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) 502#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
@@ -413,6 +507,8 @@ struct v4l2_input32 /* identical layout, but different size */
413#define VIDIOCGFREQ32 _IOR('v',14, u32) 507#define VIDIOCGFREQ32 _IOR('v',14, u32)
414#define VIDIOCSFREQ32 _IOW('v',15, u32) 508#define VIDIOCSFREQ32 _IOW('v',15, u32)
415 509
510/* VIDIOC_ENUMINPUT32 is VIDIOC_ENUMINPUT minus 4 bytes of padding alignement */
511#define VIDIOC_ENUMINPUT32 VIDIOC_ENUMINPUT - _IOC(0, 0, 0, 4)
416#define VIDIOC_G_FMT32 _IOWR ('V', 4, struct v4l2_format32) 512#define VIDIOC_G_FMT32 _IOWR ('V', 4, struct v4l2_format32)
417#define VIDIOC_S_FMT32 _IOWR ('V', 5, struct v4l2_format32) 513#define VIDIOC_S_FMT32 _IOWR ('V', 5, struct v4l2_format32)
418#define VIDIOC_QUERYBUF32 _IOWR ('V', 9, struct v4l2_buffer32) 514#define VIDIOC_QUERYBUF32 _IOWR ('V', 9, struct v4l2_buffer32)
@@ -425,7 +521,6 @@ struct v4l2_input32 /* identical layout, but different size */
425#define VIDIOC_STREAMON32 _IOW ('V', 18, compat_int_t) 521#define VIDIOC_STREAMON32 _IOW ('V', 18, compat_int_t)
426#define VIDIOC_STREAMOFF32 _IOW ('V', 19, compat_int_t) 522#define VIDIOC_STREAMOFF32 _IOW ('V', 19, compat_int_t)
427#define VIDIOC_ENUMSTD32 _IOWR ('V', 25, struct v4l2_standard32) 523#define VIDIOC_ENUMSTD32 _IOWR ('V', 25, struct v4l2_standard32)
428#define VIDIOC_ENUMINPUT32 _IOWR ('V', 26, struct v4l2_input32)
429/* VIDIOC_S_CTRL is now _IOWR, but was _IOW */ 524/* VIDIOC_S_CTRL is now _IOWR, but was _IOW */
430#define VIDIOC_S_CTRL32 _IOW ('V', 28, struct v4l2_control) 525#define VIDIOC_S_CTRL32 _IOW ('V', 28, struct v4l2_control)
431#define VIDIOC_G_INPUT32 _IOR ('V', 38, compat_int_t) 526#define VIDIOC_G_INPUT32 _IOR ('V', 38, compat_int_t)
@@ -444,6 +539,9 @@ static int do_set_window(struct file *file, unsigned int cmd, unsigned long arg)
444 int nclips; 539 int nclips;
445 u32 n; 540 u32 n;
446 541
542 if (!access_ok(VERIFY_READ, up, sizeof(struct video_window32)))
543 return -EFAULT;
544
447 if (get_user(nclips, &up->clipcount)) 545 if (get_user(nclips, &up->clipcount))
448 return -EFAULT; 546 return -EFAULT;
449 547
@@ -476,7 +574,9 @@ static int do_set_window(struct file *file, unsigned int cmd, unsigned long arg)
476 return -EINVAL; 574 return -EINVAL;
477 for (i = 0; i < nclips; i++, u++, p++) { 575 for (i = 0; i < nclips; i++, u++, p++) {
478 s32 v; 576 s32 v;
479 if (get_user(v, &u->x) || 577 if (!access_ok(VERIFY_READ, u, sizeof(struct video_clip32)) ||
578 !access_ok(VERIFY_WRITE, p, sizeof(struct video_clip32)) ||
579 get_user(v, &u->x) ||
480 put_user(v, &p->x) || 580 put_user(v, &p->x) ||
481 get_user(v, &u->y) || 581 get_user(v, &u->y) ||
482 put_user(v, &p->y) || 582 put_user(v, &p->y) ||
@@ -502,11 +602,14 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
502 struct v4l2_buffer v2b; 602 struct v4l2_buffer v2b;
503 struct v4l2_framebuffer v2fb; 603 struct v4l2_framebuffer v2fb;
504 struct v4l2_standard v2s; 604 struct v4l2_standard v2s;
605 struct v4l2_input v2i;
606 struct v4l2_tuner v2t;
505 unsigned long vx; 607 unsigned long vx;
506 } karg; 608 } karg;
507 void __user *up = compat_ptr(arg); 609 void __user *up = compat_ptr(arg);
508 int compatible_arg = 1; 610 int compatible_arg = 1;
509 int err = 0; 611 int err = 0;
612 int realcmd = cmd;
510 613
511 /* First, convert the command. */ 614 /* First, convert the command. */
512 switch(cmd) { 615 switch(cmd) {
@@ -527,8 +630,8 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
527 case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break; 630 case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break;
528 case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break; 631 case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break;
529 case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break; 632 case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break;
530 case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break; 633 case VIDIOC_ENUMSTD32: realcmd = VIDIOC_ENUMSTD; break;
531 case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break; 634 case VIDIOC_ENUMINPUT32: realcmd = VIDIOC_ENUMINPUT; break;
532 case VIDIOC_S_CTRL32: cmd = VIDIOC_S_CTRL; break; 635 case VIDIOC_S_CTRL32: cmd = VIDIOC_S_CTRL; break;
533 case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break; 636 case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break;
534 case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break; 637 case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break;
@@ -577,10 +680,31 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
577 break; 680 break;
578 681
579 case VIDIOC_ENUMSTD: 682 case VIDIOC_ENUMSTD:
683 err = get_v4l2_standard(&karg.v2s, up);
684 compatible_arg = 0;
685 break;
686
687 case VIDIOC_ENUMSTD32:
580 err = get_v4l2_standard32(&karg.v2s, up); 688 err = get_v4l2_standard32(&karg.v2s, up);
581 compatible_arg = 0; 689 compatible_arg = 0;
582 break; 690 break;
583 691
692 case VIDIOC_ENUMINPUT:
693 err = get_v4l2_input(&karg.v2i, up);
694 compatible_arg = 0;
695 break;
696
697 case VIDIOC_ENUMINPUT32:
698 err = get_v4l2_input32(&karg.v2i, up);
699 compatible_arg = 0;
700 break;
701
702 case VIDIOC_G_TUNER:
703 case VIDIOC_S_TUNER:
704 err = get_v4l2_tuner(&karg.v2t, up);
705 compatible_arg = 0;
706 break;
707
584 case VIDIOCGWIN: 708 case VIDIOCGWIN:
585 case VIDIOCGFBUF: 709 case VIDIOCGFBUF:
586 case VIDIOCGFREQ: 710 case VIDIOCGFREQ:
@@ -593,12 +717,12 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
593 goto out; 717 goto out;
594 718
595 if(compatible_arg) 719 if(compatible_arg)
596 err = native_ioctl(file, cmd, (unsigned long)up); 720 err = native_ioctl(file, realcmd, (unsigned long)up);
597 else { 721 else {
598 mm_segment_t old_fs = get_fs(); 722 mm_segment_t old_fs = get_fs();
599 723
600 set_fs(KERNEL_DS); 724 set_fs(KERNEL_DS);
601 err = native_ioctl(file, cmd, (unsigned long)&karg); 725 err = native_ioctl(file, realcmd, (unsigned long)&karg);
602 set_fs(old_fs); 726 set_fs(old_fs);
603 } 727 }
604 if(err == 0) { 728 if(err == 0) {
@@ -632,9 +756,26 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
632 break; 756 break;
633 757
634 case VIDIOC_ENUMSTD: 758 case VIDIOC_ENUMSTD:
759 err = put_v4l2_standard(&karg.v2s, up);
760 break;
761
762 case VIDIOC_ENUMSTD32:
635 err = put_v4l2_standard32(&karg.v2s, up); 763 err = put_v4l2_standard32(&karg.v2s, up);
636 break; 764 break;
637 765
766 case VIDIOC_G_TUNER:
767 case VIDIOC_S_TUNER:
768 err = put_v4l2_tuner(&karg.v2t, up);
769 break;
770
771 case VIDIOC_ENUMINPUT:
772 err = put_v4l2_input(&karg.v2i, up);
773 break;
774
775 case VIDIOC_ENUMINPUT32:
776 err = put_v4l2_input32(&karg.v2i, up);
777 break;
778
638 case VIDIOCGFREQ: 779 case VIDIOCGFREQ:
639 case VIDIOC_G_INPUT: 780 case VIDIOC_G_INPUT:
640 err = put_user(((u32)karg.vx), (u32 __user *)up); 781 err = put_user(((u32)karg.vx), (u32 __user *)up);
@@ -679,7 +820,11 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
679 case VIDIOC_G_PARM: 820 case VIDIOC_G_PARM:
680 case VIDIOC_G_STD: 821 case VIDIOC_G_STD:
681 case VIDIOC_S_STD: 822 case VIDIOC_S_STD:
823 case VIDIOC_G_TUNER:
824 case VIDIOC_S_TUNER:
825 case VIDIOC_ENUMSTD:
682 case VIDIOC_ENUMSTD32: 826 case VIDIOC_ENUMSTD32:
827 case VIDIOC_ENUMINPUT:
683 case VIDIOC_ENUMINPUT32: 828 case VIDIOC_ENUMINPUT32:
684 case VIDIOC_G_CTRL: 829 case VIDIOC_G_CTRL:
685 case VIDIOC_S_CTRL32: 830 case VIDIOC_S_CTRL32:
@@ -718,6 +863,8 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
718 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int): 863 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
719 ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 864 ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
720 break; 865 break;
866 default:
867 v4l_print_ioctl("compat_ioctl32", cmd);
721 } 868 }
722 return ret; 869 return ret;
723} 870}
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 6861d408f1b3..74cff626e044 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -702,12 +702,11 @@ static int cpia_pp_register(struct parport *port)
702 return -ENXIO; 702 return -ENXIO;
703 } 703 }
704 704
705 cam = kmalloc(sizeof(struct pp_cam_entry), GFP_KERNEL); 705 cam = kzalloc(sizeof(struct pp_cam_entry), GFP_KERNEL);
706 if (cam == NULL) { 706 if (cam == NULL) {
707 LOG("failed to allocate camera structure\n"); 707 LOG("failed to allocate camera structure\n");
708 return -ENOMEM; 708 return -ENOMEM;
709 } 709 }
710 memset(cam,0,sizeof(struct pp_cam_entry));
711 710
712 pdev = parport_register_device(port, "cpia_pp", NULL, NULL, 711 pdev = parport_register_device(port, "cpia_pp", NULL, NULL,
713 NULL, 0, cam); 712 NULL, 0, cam);
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 1439cb752874..03275c37c5d3 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -499,14 +499,12 @@ static int cpia_probe(struct usb_interface *intf,
499 499
500 printk(KERN_INFO "USB CPiA camera found\n"); 500 printk(KERN_INFO "USB CPiA camera found\n");
501 501
502 ucpia = kmalloc(sizeof(*ucpia), GFP_KERNEL); 502 ucpia = kzalloc(sizeof(*ucpia), GFP_KERNEL);
503 if (!ucpia) { 503 if (!ucpia) {
504 printk(KERN_ERR "couldn't kmalloc cpia struct\n"); 504 printk(KERN_ERR "couldn't kmalloc cpia struct\n");
505 return -ENOMEM; 505 return -ENOMEM;
506 } 506 }
507 507
508 memset(ucpia, 0, sizeof(*ucpia));
509
510 ucpia->dev = udev; 508 ucpia->dev = udev;
511 ucpia->iface = interface->desc.bInterfaceNumber; 509 ucpia->iface = interface->desc.bInterfaceNumber;
512 init_waitqueue_head(&ucpia->wq_stream); 510 init_waitqueue_head(&ucpia->wq_stream);
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index b421068f7ea3..8739c64785ef 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -141,11 +141,10 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
141 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 141 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
142 return 0; 142 return 0;
143 143
144 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 144 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
145 if (client == 0) 145 if (client == 0)
146 return -ENOMEM; 146 return -ENOMEM;
147 147
148 memset(client, 0, sizeof(struct i2c_client));
149 client->addr = address; 148 client->addr = address;
150 client->adapter = adapter; 149 client->adapter = adapter;
151 client->driver = &i2c_driver; 150 client->driver = &i2c_driver;
@@ -156,7 +155,7 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
156 for (i = 1; i <= 7; i++) { 155 for (i = 1; i <= 7; i++) {
157 u8 v = cs53l32a_read(client, i); 156 u8 v = cs53l32a_read(client, i);
158 157
159 v4l_dbg(1, client, "Read Reg %d %02x\n", i, v); 158 v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v);
160 } 159 }
161 160
162 /* Set cs53l32a internal register for Adaptec 2010/2410 setup */ 161 /* Set cs53l32a internal register for Adaptec 2010/2410 setup */
@@ -174,7 +173,7 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
174 for (i = 1; i <= 7; i++) { 173 for (i = 1; i <= 7; i++) {
175 u8 v = cs53l32a_read(client, i); 174 u8 v = cs53l32a_read(client, i);
176 175
177 v4l_dbg(1, client, "Read Reg %d %02x\n", i, v); 176 v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v);
178 } 177 }
179 178
180 i2c_attach_client(client); 179 i2c_attach_client(client);
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index d45237d508c4..1d75a42629d1 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -43,9 +43,9 @@ MODULE_LICENSE("GPL");
43static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 43static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
44 44
45 45
46int debug = 0; 46int cx25840_debug = 0;
47 47
48module_param(debug, bool, 0644); 48module_param_named(debug,cx25840_debug, int, 0644);
49 49
50MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]"); 50MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");
51 51
@@ -265,7 +265,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
265 vid_input <= CX25840_COMPOSITE8); 265 vid_input <= CX25840_COMPOSITE8);
266 u8 reg; 266 u8 reg;
267 267
268 v4l_dbg(1, client, "decoder set video input %d, audio input %d\n", 268 v4l_dbg(1, cx25840_debug, client, "decoder set video input %d, audio input %d\n",
269 vid_input, aud_input); 269 vid_input, aud_input);
270 270
271 if (is_composite) { 271 if (is_composite) {
@@ -533,7 +533,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
533 else 533 else
534 filter = 3; 534 filter = 3;
535 535
536 v4l_dbg(1, client, "decoder set size %dx%d -> scale %ux%u\n", 536 v4l_dbg(1, cx25840_debug, client, "decoder set size %dx%d -> scale %ux%u\n",
537 pix->width, pix->height, HSC, VSC); 537 pix->width, pix->height, HSC, VSC);
538 538
539 /* HSCALE=HSC */ 539 /* HSCALE=HSC */
@@ -687,13 +687,13 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
687 return cx25840_audio(client, cmd, arg); 687 return cx25840_audio(client, cmd, arg);
688 688
689 case VIDIOC_STREAMON: 689 case VIDIOC_STREAMON:
690 v4l_dbg(1, client, "enable output\n"); 690 v4l_dbg(1, cx25840_debug, client, "enable output\n");
691 cx25840_write(client, 0x115, 0x8c); 691 cx25840_write(client, 0x115, 0x8c);
692 cx25840_write(client, 0x116, 0x07); 692 cx25840_write(client, 0x116, 0x07);
693 break; 693 break;
694 694
695 case VIDIOC_STREAMOFF: 695 case VIDIOC_STREAMOFF:
696 v4l_dbg(1, client, "disable output\n"); 696 v4l_dbg(1, cx25840_debug, client, "disable output\n");
697 cx25840_write(client, 0x115, 0x00); 697 cx25840_write(client, 0x115, 0x00);
698 cx25840_write(client, 0x116, 0x00); 698 cx25840_write(client, 0x116, 0x00);
699 break; 699 break;
@@ -862,17 +862,16 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
862 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) 862 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
863 return 0; 863 return 0;
864 864
865 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 865 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
866 if (client == 0) 866 if (client == 0)
867 return -ENOMEM; 867 return -ENOMEM;
868 868
869 memset(client, 0, sizeof(struct i2c_client));
870 client->addr = address; 869 client->addr = address;
871 client->adapter = adapter; 870 client->adapter = adapter;
872 client->driver = &i2c_driver_cx25840; 871 client->driver = &i2c_driver_cx25840;
873 snprintf(client->name, sizeof(client->name) - 1, "cx25840"); 872 snprintf(client->name, sizeof(client->name) - 1, "cx25840");
874 873
875 v4l_dbg(1, client, "detecting cx25840 client on address 0x%x\n", address << 1); 874 v4l_dbg(1, cx25840_debug, client, "detecting cx25840 client on address 0x%x\n", address << 1);
876 875
877 device_id = cx25840_read(client, 0x101) << 8; 876 device_id = cx25840_read(client, 0x101) << 8;
878 device_id |= cx25840_read(client, 0x100); 877 device_id |= cx25840_read(client, 0x100);
@@ -880,7 +879,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
880 /* The high byte of the device ID should be 879 /* The high byte of the device ID should be
881 * 0x84 if chip is present */ 880 * 0x84 if chip is present */
882 if ((device_id & 0xff00) != 0x8400) { 881 if ((device_id & 0xff00) != 0x8400) {
883 v4l_dbg(1, client, "cx25840 not found\n"); 882 v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n");
884 kfree(client); 883 kfree(client);
885 return 0; 884 return 0;
886 } 885 }
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index a49062119313..a502a4d6e4ae 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1539,10 +1539,9 @@ static int mpeg_open(struct inode *inode, struct file *file)
1539 dprintk(1,"open minor=%d\n",minor); 1539 dprintk(1,"open minor=%d\n",minor);
1540 1540
1541 /* allocate + initialize per filehandle data */ 1541 /* allocate + initialize per filehandle data */
1542 fh = kmalloc(sizeof(*fh),GFP_KERNEL); 1542 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1543 if (NULL == fh) 1543 if (NULL == fh)
1544 return -ENOMEM; 1544 return -ENOMEM;
1545 memset(fh,0,sizeof(*fh));
1546 file->private_data = fh; 1545 file->private_data = fh;
1547 fh->dev = dev; 1546 fh->dev = dev;
1548 1547
@@ -1678,10 +1677,9 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev,
1678 goto fail_core; 1677 goto fail_core;
1679 1678
1680 err = -ENOMEM; 1679 err = -ENOMEM;
1681 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 1680 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
1682 if (NULL == dev) 1681 if (NULL == dev)
1683 goto fail_core; 1682 goto fail_core;
1684 memset(dev,0,sizeof(*dev));
1685 dev->pci = pci_dev; 1683 dev->pci = pci_dev;
1686 dev->core = core; 1684 dev->core = core;
1687 dev->width = 720; 1685 dev->width = 720;
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index a76d54503b6f..ad2f565f522c 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1244,6 +1244,11 @@ struct cx88_subid cx88_subids[] = {
1244 .subvendor = 0x18ac, 1244 .subvendor = 0x18ac,
1245 .subdevice = 0xdb50, 1245 .subdevice = 0xdb50,
1246 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL, 1246 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL,
1247 },{
1248 .subvendor = 0x18ac,
1249 .subdevice = 0xdb11,
1250 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
1251 /* Re-branded DViCO: UltraView DVB-T Plus */
1247 }, 1252 },
1248}; 1253};
1249const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1254const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 9975be1aca38..194446f28c55 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1050,11 +1050,10 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1050 up(&devlist); 1050 up(&devlist);
1051 return core; 1051 return core;
1052 } 1052 }
1053 core = kmalloc(sizeof(*core),GFP_KERNEL); 1053 core = kzalloc(sizeof(*core),GFP_KERNEL);
1054 if (NULL == core) 1054 if (NULL == core)
1055 goto fail_unlock; 1055 goto fail_unlock;
1056 1056
1057 memset(core,0,sizeof(*core));
1058 atomic_inc(&core->refcount); 1057 atomic_inc(&core->refcount);
1059 core->pci_bus = pci->bus->number; 1058 core->pci_bus = pci->bus->number;
1060 core->pci_slot = PCI_SLOT(pci->devfn); 1059 core->pci_slot = PCI_SLOT(pci->devfn);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 42c012aaa849..e48aa3f6e500 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -657,10 +657,9 @@ static int __devinit dvb_probe(struct pci_dev *pci_dev,
657 goto fail_core; 657 goto fail_core;
658 658
659 err = -ENOMEM; 659 err = -ENOMEM;
660 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 660 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
661 if (NULL == dev) 661 if (NULL == dev)
662 goto fail_core; 662 goto fail_core;
663 memset(dev,0,sizeof(*dev));
664 dev->pci = pci_dev; 663 dev->pci = pci_dev;
665 dev->core = core; 664 dev->core = core;
666 665
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 286c85b6bdf9..da2ad5c4b553 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -697,6 +697,7 @@ void cx88_ir_irq(struct cx88_core *core)
697 case CX88_BOARD_HAUPPAUGE_DVB_T1: 697 case CX88_BOARD_HAUPPAUGE_DVB_T1:
698 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 698 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
699 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 699 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
700 case CX88_BOARD_HAUPPAUGE_HVR1100:
700 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); 701 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
701 ir_dprintk("biphase decoded: %x\n", ircode); 702 ir_dprintk("biphase decoded: %x\n", ircode);
702 if ((ircode & 0xfffff000) != 0x3000) 703 if ((ircode & 0xfffff000) != 0x3000)
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 9a02515fe18b..073494ceab0f 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -750,10 +750,9 @@ static int video_open(struct inode *inode, struct file *file)
750 minor,radio,v4l2_type_names[type]); 750 minor,radio,v4l2_type_names[type]);
751 751
752 /* allocate + initialize per filehandle data */ 752 /* allocate + initialize per filehandle data */
753 fh = kmalloc(sizeof(*fh),GFP_KERNEL); 753 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
754 if (NULL == fh) 754 if (NULL == fh)
755 return -ENOMEM; 755 return -ENOMEM;
756 memset(fh,0,sizeof(*fh));
757 file->private_data = fh; 756 file->private_data = fh;
758 fh->dev = dev; 757 fh->dev = dev;
759 fh->radio = radio; 758 fh->radio = radio;
@@ -1809,10 +1808,9 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1809 struct cx88_core *core; 1808 struct cx88_core *core;
1810 int err; 1809 int err;
1811 1810
1812 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 1811 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
1813 if (NULL == dev) 1812 if (NULL == dev)
1814 return -ENOMEM; 1813 return -ENOMEM;
1815 memset(dev,0,sizeof(*dev));
1816 1814
1817 /* pci init */ 1815 /* pci init */
1818 dev->pci = pci_dev; 1816 dev->pci = pci_dev;
diff --git a/drivers/media/video/dpc7146.c b/drivers/media/video/dpc7146.c
index da9481198c53..2831bdd12057 100644
--- a/drivers/media/video/dpc7146.c
+++ b/drivers/media/video/dpc7146.c
@@ -94,12 +94,11 @@ static int dpc_probe(struct saa7146_dev* dev)
94 struct i2c_client *client; 94 struct i2c_client *client;
95 struct list_head *item; 95 struct list_head *item;
96 96
97 dpc = (struct dpc*)kmalloc(sizeof(struct dpc), GFP_KERNEL); 97 dpc = kzalloc(sizeof(struct dpc), GFP_KERNEL);
98 if( NULL == dpc ) { 98 if( NULL == dpc ) {
99 printk("dpc_v4l2.o: dpc_probe: not enough kernel memory.\n"); 99 printk("dpc_v4l2.o: dpc_probe: not enough kernel memory.\n");
100 return -ENOMEM; 100 return -ENOMEM;
101 } 101 }
102 memset(dpc, 0x0, sizeof(struct dpc));
103 102
104 /* FIXME: enable i2c-port pins, video-port-pins 103 /* FIXME: enable i2c-port pins, video-port-pins
105 video port pins should be enabled here ?! */ 104 video port pins should be enabled here ?! */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index fdc255918dde..3323dffe26a4 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1861,12 +1861,11 @@ static int em28xx_usb_probe(struct usb_interface *interface,
1861 } 1861 }
1862 1862
1863 /* allocate memory for our device state and initialize it */ 1863 /* allocate memory for our device state and initialize it */
1864 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 1864 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1865 if (dev == NULL) { 1865 if (dev == NULL) {
1866 em28xx_err(DRIVER_NAME ": out of memory!\n"); 1866 em28xx_err(DRIVER_NAME ": out of memory!\n");
1867 return -ENOMEM; 1867 return -ENOMEM;
1868 } 1868 }
1869 memset(dev, 0, sizeof(*dev));
1870 1869
1871 /* compute alternate max packet sizes */ 1870 /* compute alternate max packet sizes */
1872 uif = udev->actconfig->interface[0]; 1871 uif = udev->actconfig->interface[0];
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c
index c9b00eafefde..e7bbeb11553d 100644
--- a/drivers/media/video/hexium_gemini.c
+++ b/drivers/media/video/hexium_gemini.c
@@ -240,12 +240,11 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
240 240
241 DEB_EE((".\n")); 241 DEB_EE((".\n"));
242 242
243 hexium = (struct hexium *) kmalloc(sizeof(struct hexium), GFP_KERNEL); 243 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
244 if (NULL == hexium) { 244 if (NULL == hexium) {
245 printk("hexium_gemini: not enough kernel memory in hexium_attach().\n"); 245 printk("hexium_gemini: not enough kernel memory in hexium_attach().\n");
246 return -ENOMEM; 246 return -ENOMEM;
247 } 247 }
248 memset(hexium, 0x0, sizeof(struct hexium));
249 dev->ext_priv = hexium; 248 dev->ext_priv = hexium;
250 249
251 /* enable i2c-port pins */ 250 /* enable i2c-port pins */
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index 42a9414155c3..0b6c2096ec66 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -224,12 +224,11 @@ static int hexium_probe(struct saa7146_dev *dev)
224 return -EFAULT; 224 return -EFAULT;
225 } 225 }
226 226
227 hexium = (struct hexium *) kmalloc(sizeof(struct hexium), GFP_KERNEL); 227 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
228 if (NULL == hexium) { 228 if (NULL == hexium) {
229 printk("hexium_orion: hexium_probe: not enough kernel memory.\n"); 229 printk("hexium_orion: hexium_probe: not enough kernel memory.\n");
230 return -ENOMEM; 230 return -ENOMEM;
231 } 231 }
232 memset(hexium, 0x0, sizeof(struct hexium));
233 232
234 /* enable i2c-port pins */ 233 /* enable i2c-port pins */
235 saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); 234 saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c
index bb5cbecffcc3..7420b79e987a 100644
--- a/drivers/media/video/indycam.c
+++ b/drivers/media/video/indycam.c
@@ -289,18 +289,15 @@ static int indycam_attach(struct i2c_adapter *adap, int addr, int kind)
289 printk(KERN_INFO "SGI IndyCam driver version %s\n", 289 printk(KERN_INFO "SGI IndyCam driver version %s\n",
290 INDYCAM_MODULE_VERSION); 290 INDYCAM_MODULE_VERSION);
291 291
292 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 292 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
293 if (!client) 293 if (!client)
294 return -ENOMEM; 294 return -ENOMEM;
295 camera = kmalloc(sizeof(struct indycam), GFP_KERNEL); 295 camera = kzalloc(sizeof(struct indycam), GFP_KERNEL);
296 if (!camera) { 296 if (!camera) {
297 err = -ENOMEM; 297 err = -ENOMEM;
298 goto out_free_client; 298 goto out_free_client;
299 } 299 }
300 300
301 memset(client, 0, sizeof(struct i2c_client));
302 memset(camera, 0, sizeof(struct indycam));
303
304 client->addr = addr; 301 client->addr = addr;
305 client->adapter = adap; 302 client->adapter = adap;
306 client->driver = &i2c_driver_indycam; 303 client->driver = &i2c_driver_indycam;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index aa8c556b6ba1..9b05a0ab776d 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -66,26 +66,26 @@ MODULE_LICENSE("GPL");
66 66
67/* module parameters */ 67/* module parameters */
68static int opmode = OPMODE_AUTO; 68static int opmode = OPMODE_AUTO;
69int debug = 0; /* debug output */ 69int msp_debug = 0; /* msp_debug output */
70int once = 0; /* no continous stereo monitoring */ 70int msp_once = 0; /* no continous stereo monitoring */
71int amsound = 0; /* hard-wire AM sound at 6.5 Hz (france), 71int msp_amsound = 0; /* hard-wire AM sound at 6.5 Hz (france),
72 the autoscan seems work well only with FM... */ 72 the autoscan seems work well only with FM... */
73int standard = 1; /* Override auto detect of audio standard, if needed. */ 73int msp_standard = 1; /* Override auto detect of audio msp_standard, if needed. */
74int dolby = 0; 74int msp_dolby = 0;
75 75
76int stereo_threshold = 0x190; /* a2 threshold for stereo/bilingual 76int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual
77 (msp34xxg only) 0x00a0-0x03c0 */ 77 (msp34xxg only) 0x00a0-0x03c0 */
78 78
79/* read-only */ 79/* read-only */
80module_param(opmode, int, 0444); 80module_param(opmode, int, 0444);
81 81
82/* read-write */ 82/* read-write */
83module_param(once, bool, 0644); 83module_param_named(once,msp_once, bool, 0644);
84module_param(debug, int, 0644); 84module_param_named(debug,msp_debug, int, 0644);
85module_param(stereo_threshold, int, 0644); 85module_param_named(stereo_threshold,msp_stereo_thresh, int, 0644);
86module_param(standard, int, 0644); 86module_param_named(standard,msp_standard, int, 0644);
87module_param(amsound, bool, 0644); 87module_param_named(amsound,msp_amsound, bool, 0644);
88module_param(dolby, bool, 0644); 88module_param_named(dolby,msp_dolby, bool, 0644);
89 89
90MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect"); 90MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect");
91MODULE_PARM_DESC(once, "No continuous stereo monitoring"); 91MODULE_PARM_DESC(once, "No continuous stereo monitoring");
@@ -127,7 +127,7 @@ int msp_reset(struct i2c_client *client)
127 { client->addr, I2C_M_RD, 2, read }, 127 { client->addr, I2C_M_RD, 2, read },
128 }; 128 };
129 129
130 v4l_dbg(3, client, "msp_reset\n"); 130 v4l_dbg(3, msp_debug, client, "msp_reset\n");
131 if (i2c_transfer(client->adapter, &reset[0], 1) != 1 || 131 if (i2c_transfer(client->adapter, &reset[0], 1) != 1 ||
132 i2c_transfer(client->adapter, &reset[1], 1) != 1 || 132 i2c_transfer(client->adapter, &reset[1], 1) != 1 ||
133 i2c_transfer(client->adapter, test, 2) != 2) { 133 i2c_transfer(client->adapter, test, 2) != 2) {
@@ -165,7 +165,7 @@ static int msp_read(struct i2c_client *client, int dev, int addr)
165 return -1; 165 return -1;
166 } 166 }
167 retval = read[0] << 8 | read[1]; 167 retval = read[0] << 8 | read[1];
168 v4l_dbg(3, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); 168 v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval);
169 return retval; 169 return retval;
170} 170}
171 171
@@ -190,7 +190,7 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
190 buffer[3] = val >> 8; 190 buffer[3] = val >> 8;
191 buffer[4] = val & 0xff; 191 buffer[4] = val & 0xff;
192 192
193 v4l_dbg(3, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); 193 v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val);
194 for (err = 0; err < 3; err++) { 194 for (err = 0; err < 3; err++) {
195 if (i2c_master_send(client, buffer, 5) == 5) 195 if (i2c_master_send(client, buffer, 5) == 5)
196 break; 196 break;
@@ -273,7 +273,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
273 } else 273 } else
274 state->acb = 0xf60; /* Mute Input and SCART 1 Output */ 274 state->acb = 0xf60; /* Mute Input and SCART 1 Output */
275 275
276 v4l_dbg(1, client, "scart switch: %s => %d (ACB=0x%04x)\n", 276 v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n",
277 scart_names[in], out, state->acb); 277 scart_names[in], out, state->acb);
278 msp_write_dsp(client, 0x13, state->acb); 278 msp_write_dsp(client, 0x13, state->acb);
279 279
@@ -285,7 +285,7 @@ void msp_set_mute(struct i2c_client *client)
285{ 285{
286 struct msp_state *state = i2c_get_clientdata(client); 286 struct msp_state *state = i2c_get_clientdata(client);
287 287
288 v4l_dbg(1, client, "mute audio\n"); 288 v4l_dbg(1, msp_debug, client, "mute audio\n");
289 msp_write_dsp(client, 0x0000, 0); 289 msp_write_dsp(client, 0x0000, 0);
290 msp_write_dsp(client, 0x0007, 1); 290 msp_write_dsp(client, 0x0007, 1);
291 if (state->has_scart2_out_volume) 291 if (state->has_scart2_out_volume)
@@ -303,7 +303,7 @@ void msp_set_audio(struct i2c_client *client)
303 if (!state->muted) 303 if (!state->muted)
304 val = (state->volume * 0x7f / 65535) << 8; 304 val = (state->volume * 0x7f / 65535) << 8;
305 305
306 v4l_dbg(1, client, "mute=%s volume=%d\n", 306 v4l_dbg(1, msp_debug, client, "mute=%s volume=%d\n",
307 state->muted ? "on" : "off", state->volume); 307 state->muted ? "on" : "off", state->volume);
308 308
309 msp_write_dsp(client, 0x0000, val); 309 msp_write_dsp(client, 0x0000, val);
@@ -321,7 +321,7 @@ void msp_set_audio(struct i2c_client *client)
321 treble = ((state->treble - 32768) * 0x60 / 65535) << 8; 321 treble = ((state->treble - 32768) * 0x60 / 65535) << 8;
322 loudness = state->loudness ? ((5 * 4) << 8) : 0; 322 loudness = state->loudness ? ((5 * 4) << 8) : 0;
323 323
324 v4l_dbg(1, client, "balance=%d bass=%d treble=%d loudness=%d\n", 324 v4l_dbg(1, msp_debug, client, "balance=%d bass=%d treble=%d loudness=%d\n",
325 state->balance, state->bass, state->treble, state->loudness); 325 state->balance, state->bass, state->treble, state->loudness);
326 326
327 msp_write_dsp(client, 0x0001, bal << 8); 327 msp_write_dsp(client, 0x0001, bal << 8);
@@ -341,12 +341,12 @@ int msp_modus(struct i2c_client *client)
341 struct msp_state *state = i2c_get_clientdata(client); 341 struct msp_state *state = i2c_get_clientdata(client);
342 342
343 if (state->radio) { 343 if (state->radio) {
344 v4l_dbg(1, client, "video mode selected to Radio\n"); 344 v4l_dbg(1, msp_debug, client, "video mode selected to Radio\n");
345 return 0x0003; 345 return 0x0003;
346 } 346 }
347 347
348 if (state->v4l2_std & V4L2_STD_PAL) { 348 if (state->v4l2_std & V4L2_STD_PAL) {
349 v4l_dbg(1, client, "video mode selected to PAL\n"); 349 v4l_dbg(1, msp_debug, client, "video mode selected to PAL\n");
350 350
351#if 1 351#if 1
352 /* experimental: not sure this works with all chip versions */ 352 /* experimental: not sure this works with all chip versions */
@@ -357,11 +357,11 @@ int msp_modus(struct i2c_client *client)
357#endif 357#endif
358 } 358 }
359 if (state->v4l2_std & V4L2_STD_NTSC) { 359 if (state->v4l2_std & V4L2_STD_NTSC) {
360 v4l_dbg(1, client, "video mode selected to NTSC\n"); 360 v4l_dbg(1, msp_debug, client, "video mode selected to NTSC\n");
361 return 0x2003; 361 return 0x2003;
362 } 362 }
363 if (state->v4l2_std & V4L2_STD_SECAM) { 363 if (state->v4l2_std & V4L2_STD_SECAM) {
364 v4l_dbg(1, client, "video mode selected to SECAM\n"); 364 v4l_dbg(1, msp_debug, client, "video mode selected to SECAM\n");
365 return 0x0003; 365 return 0x0003;
366 } 366 }
367 return 0x0003; 367 return 0x0003;
@@ -619,7 +619,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
619 u16 *sarg = arg; 619 u16 *sarg = arg;
620 int scart = 0; 620 int scart = 0;
621 621
622 if (debug >= 2) 622 if (msp_debug >= 2)
623 v4l_i2c_print_ioctl(client, cmd); 623 v4l_i2c_print_ioctl(client, cmd);
624 624
625 switch (cmd) { 625 switch (cmd) {
@@ -666,7 +666,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
666 if (state->radio) 666 if (state->radio)
667 return 0; 667 return 0;
668 state->radio = 1; 668 state->radio = 1;
669 v4l_dbg(1, client, "switching to radio mode\n"); 669 v4l_dbg(1, msp_debug, client, "switching to radio mode\n");
670 state->watch_stereo = 0; 670 state->watch_stereo = 0;
671 switch (state->opmode) { 671 switch (state->opmode) {
672 case OPMODE_MANUAL: 672 case OPMODE_MANUAL:
@@ -937,7 +937,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
937 if (a->index < 0 || a->index > 2) 937 if (a->index < 0 || a->index > 2)
938 return -EINVAL; 938 return -EINVAL;
939 939
940 v4l_dbg(1, client, "Setting audio out on msp34xx to input %i\n", a->index); 940 v4l_dbg(1, msp_debug, client, "Setting audio out on msp34xx to input %i\n", a->index);
941 msp_set_scart(client, state->in_scart, a->index + 1); 941 msp_set_scart(client, state->in_scart, a->index + 1);
942 942
943 break; 943 break;
@@ -947,7 +947,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
947 { 947 {
948 u32 *a = (u32 *)arg; 948 u32 *a = (u32 *)arg;
949 949
950 v4l_dbg(1, client, "Setting I2S speed to %d\n", *a); 950 v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a);
951 951
952 switch (*a) { 952 switch (*a) {
953 case 1024000: 953 case 1024000:
@@ -1041,7 +1041,7 @@ static int msp_suspend(struct device * dev, pm_message_t state)
1041{ 1041{
1042 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1042 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
1043 1043
1044 v4l_dbg(1, client, "suspend\n"); 1044 v4l_dbg(1, msp_debug, client, "suspend\n");
1045 msp_reset(client); 1045 msp_reset(client);
1046 return 0; 1046 return 0;
1047} 1047}
@@ -1050,7 +1050,7 @@ static int msp_resume(struct device * dev)
1050{ 1050{
1051 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 1051 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
1052 1052
1053 v4l_dbg(1, client, "resume\n"); 1053 v4l_dbg(1, msp_debug, client, "resume\n");
1054 msp_wake_thread(client); 1054 msp_wake_thread(client);
1055 return 0; 1055 return 0;
1056} 1056}
@@ -1080,7 +1080,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
1080 snprintf(client->name, sizeof(client->name) - 1, "msp3400"); 1080 snprintf(client->name, sizeof(client->name) - 1, "msp3400");
1081 1081
1082 if (msp_reset(client) == -1) { 1082 if (msp_reset(client) == -1) {
1083 v4l_dbg(1, client, "msp3400 not found\n"); 1083 v4l_dbg(1, msp_debug, client, "msp3400 not found\n");
1084 kfree(client); 1084 kfree(client);
1085 return -1; 1085 return -1;
1086 } 1086 }
@@ -1107,9 +1107,9 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
1107 state->rev1 = msp_read_dsp(client, 0x1e); 1107 state->rev1 = msp_read_dsp(client, 0x1e);
1108 if (state->rev1 != -1) 1108 if (state->rev1 != -1)
1109 state->rev2 = msp_read_dsp(client, 0x1f); 1109 state->rev2 = msp_read_dsp(client, 0x1f);
1110 v4l_dbg(1, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); 1110 v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2);
1111 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { 1111 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
1112 v4l_dbg(1, client, "not an msp3400 (cannot read chip version)\n"); 1112 v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n");
1113 kfree(state); 1113 kfree(state);
1114 kfree(client); 1114 kfree(client);
1115 return -1; 1115 return -1;
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 2b59b6847535..2072c3efebb3 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -168,7 +168,7 @@ void msp3400c_setmode(struct i2c_client *client, int type)
168 struct msp_state *state = i2c_get_clientdata(client); 168 struct msp_state *state = i2c_get_clientdata(client);
169 int i; 169 int i;
170 170
171 v4l_dbg(1, client, "setmode: %d\n", type); 171 v4l_dbg(1, msp_debug, client, "setmode: %d\n", type);
172 state->mode = type; 172 state->mode = type;
173 state->audmode = V4L2_TUNER_MODE_MONO; 173 state->audmode = V4L2_TUNER_MODE_MONO;
174 state->rxsubchans = V4L2_TUNER_SUB_MONO; 174 state->rxsubchans = V4L2_TUNER_SUB_MONO;
@@ -191,7 +191,7 @@ void msp3400c_setmode(struct i2c_client *client, int type)
191 191
192 msp_write_dem(client, 0x0056, 0); /*LOAD_REG_1/2*/ 192 msp_write_dem(client, 0x0056, 0); /*LOAD_REG_1/2*/
193 193
194 if (dolby) { 194 if (msp_dolby) {
195 msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */ 195 msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */
196 msp_write_dsp(client, 0x0009, 0x0620); /* I2S2 */ 196 msp_write_dsp(client, 0x0009, 0x0620); /* I2S2 */
197 msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src); 197 msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src);
@@ -221,7 +221,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
221 /* this method would break everything, let's make sure 221 /* this method would break everything, let's make sure
222 * it's never called 222 * it's never called
223 */ 223 */
224 v4l_dbg(1, client, "setstereo called with mode=%d instead of set_source (ignored)\n", 224 v4l_dbg(1, msp_debug, client, "setstereo called with mode=%d instead of set_source (ignored)\n",
225 mode); 225 mode);
226 return; 226 return;
227 } 227 }
@@ -229,7 +229,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
229 /* switch demodulator */ 229 /* switch demodulator */
230 switch (state->mode) { 230 switch (state->mode) {
231 case MSP_MODE_FM_TERRA: 231 case MSP_MODE_FM_TERRA:
232 v4l_dbg(1, client, "FM setstereo: %s\n", strmode[mode]); 232 v4l_dbg(1, msp_debug, client, "FM setstereo: %s\n", strmode[mode]);
233 msp3400c_setcarrier(client, state->second, state->main); 233 msp3400c_setcarrier(client, state->second, state->main);
234 switch (mode) { 234 switch (mode) {
235 case V4L2_TUNER_MODE_STEREO: 235 case V4L2_TUNER_MODE_STEREO:
@@ -243,7 +243,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
243 } 243 }
244 break; 244 break;
245 case MSP_MODE_FM_SAT: 245 case MSP_MODE_FM_SAT:
246 v4l_dbg(1, client, "SAT setstereo: %s\n", strmode[mode]); 246 v4l_dbg(1, msp_debug, client, "SAT setstereo: %s\n", strmode[mode]);
247 switch (mode) { 247 switch (mode) {
248 case V4L2_TUNER_MODE_MONO: 248 case V4L2_TUNER_MODE_MONO:
249 msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); 249 msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
@@ -262,24 +262,24 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
262 case MSP_MODE_FM_NICAM1: 262 case MSP_MODE_FM_NICAM1:
263 case MSP_MODE_FM_NICAM2: 263 case MSP_MODE_FM_NICAM2:
264 case MSP_MODE_AM_NICAM: 264 case MSP_MODE_AM_NICAM:
265 v4l_dbg(1, client, "NICAM setstereo: %s\n",strmode[mode]); 265 v4l_dbg(1, msp_debug, client, "NICAM setstereo: %s\n",strmode[mode]);
266 msp3400c_setcarrier(client,state->second,state->main); 266 msp3400c_setcarrier(client,state->second,state->main);
267 if (state->nicam_on) 267 if (state->nicam_on)
268 nicam=0x0100; 268 nicam=0x0100;
269 break; 269 break;
270 case MSP_MODE_BTSC: 270 case MSP_MODE_BTSC:
271 v4l_dbg(1, client, "BTSC setstereo: %s\n",strmode[mode]); 271 v4l_dbg(1, msp_debug, client, "BTSC setstereo: %s\n",strmode[mode]);
272 nicam=0x0300; 272 nicam=0x0300;
273 break; 273 break;
274 case MSP_MODE_EXTERN: 274 case MSP_MODE_EXTERN:
275 v4l_dbg(1, client, "extern setstereo: %s\n",strmode[mode]); 275 v4l_dbg(1, msp_debug, client, "extern setstereo: %s\n",strmode[mode]);
276 nicam = 0x0200; 276 nicam = 0x0200;
277 break; 277 break;
278 case MSP_MODE_FM_RADIO: 278 case MSP_MODE_FM_RADIO:
279 v4l_dbg(1, client, "FM-Radio setstereo: %s\n",strmode[mode]); 279 v4l_dbg(1, msp_debug, client, "FM-Radio setstereo: %s\n",strmode[mode]);
280 break; 280 break;
281 default: 281 default:
282 v4l_dbg(1, client, "mono setstereo\n"); 282 v4l_dbg(1, msp_debug, client, "mono setstereo\n");
283 return; 283 return;
284 } 284 }
285 285
@@ -290,7 +290,7 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
290 break; 290 break;
291 case V4L2_TUNER_MODE_MONO: 291 case V4L2_TUNER_MODE_MONO:
292 if (state->mode == MSP_MODE_AM_NICAM) { 292 if (state->mode == MSP_MODE_AM_NICAM) {
293 v4l_dbg(1, client, "switching to AM mono\n"); 293 v4l_dbg(1, msp_debug, client, "switching to AM mono\n");
294 /* AM mono decoding is handled by tuner, not MSP chip */ 294 /* AM mono decoding is handled by tuner, not MSP chip */
295 /* SCART switching control register */ 295 /* SCART switching control register */
296 msp_set_scart(client, SCART_MONO, 0); 296 msp_set_scart(client, SCART_MONO, 0);
@@ -304,9 +304,9 @@ void msp3400c_setstereo(struct i2c_client *client, int mode)
304 src = 0x0010 | nicam; 304 src = 0x0010 | nicam;
305 break; 305 break;
306 } 306 }
307 v4l_dbg(1, client, "setstereo final source/matrix = 0x%x\n", src); 307 v4l_dbg(1, msp_debug, client, "setstereo final source/matrix = 0x%x\n", src);
308 308
309 if (dolby) { 309 if (msp_dolby) {
310 msp_write_dsp(client, 0x0008, 0x0520); 310 msp_write_dsp(client, 0x0008, 0x0520);
311 msp_write_dsp(client, 0x0009, 0x0620); 311 msp_write_dsp(client, 0x0009, 0x0620);
312 msp_write_dsp(client, 0x000a, src); 312 msp_write_dsp(client, 0x000a, src);
@@ -327,20 +327,20 @@ static void msp3400c_print_mode(struct i2c_client *client)
327 struct msp_state *state = i2c_get_clientdata(client); 327 struct msp_state *state = i2c_get_clientdata(client);
328 328
329 if (state->main == state->second) { 329 if (state->main == state->second) {
330 v4l_dbg(1, client, "mono sound carrier: %d.%03d MHz\n", 330 v4l_dbg(1, msp_debug, client, "mono sound carrier: %d.%03d MHz\n",
331 state->main / 910000, (state->main / 910) % 1000); 331 state->main / 910000, (state->main / 910) % 1000);
332 } else { 332 } else {
333 v4l_dbg(1, client, "main sound carrier: %d.%03d MHz\n", 333 v4l_dbg(1, msp_debug, client, "main sound carrier: %d.%03d MHz\n",
334 state->main / 910000, (state->main / 910) % 1000); 334 state->main / 910000, (state->main / 910) % 1000);
335 } 335 }
336 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2) 336 if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2)
337 v4l_dbg(1, client, "NICAM/FM carrier : %d.%03d MHz\n", 337 v4l_dbg(1, msp_debug, client, "NICAM/FM carrier : %d.%03d MHz\n",
338 state->second / 910000, (state->second/910) % 1000); 338 state->second / 910000, (state->second/910) % 1000);
339 if (state->mode == MSP_MODE_AM_NICAM) 339 if (state->mode == MSP_MODE_AM_NICAM)
340 v4l_dbg(1, client, "NICAM/AM carrier : %d.%03d MHz\n", 340 v4l_dbg(1, msp_debug, client, "NICAM/AM carrier : %d.%03d MHz\n",
341 state->second / 910000, (state->second / 910) % 1000); 341 state->second / 910000, (state->second / 910) % 1000);
342 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) { 342 if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
343 v4l_dbg(1, client, "FM-stereo carrier : %d.%03d MHz\n", 343 v4l_dbg(1, msp_debug, client, "FM-stereo carrier : %d.%03d MHz\n",
344 state->second / 910000, (state->second / 910) % 1000); 344 state->second / 910000, (state->second / 910) % 1000);
345 } 345 }
346} 346}
@@ -360,7 +360,7 @@ int autodetect_stereo(struct i2c_client *client)
360 val = msp_read_dsp(client, 0x18); 360 val = msp_read_dsp(client, 0x18);
361 if (val > 32767) 361 if (val > 32767)
362 val -= 65536; 362 val -= 65536;
363 v4l_dbg(2, client, "stereo detect register: %d\n", val); 363 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val);
364 if (val > 4096) { 364 if (val > 4096) {
365 rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO; 365 rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
366 } else if (val < -4096) { 366 } else if (val < -4096) {
@@ -374,7 +374,7 @@ int autodetect_stereo(struct i2c_client *client)
374 case MSP_MODE_FM_NICAM2: 374 case MSP_MODE_FM_NICAM2:
375 case MSP_MODE_AM_NICAM: 375 case MSP_MODE_AM_NICAM:
376 val = msp_read_dem(client, 0x23); 376 val = msp_read_dem(client, 0x23);
377 v4l_dbg(2, client, "nicam sync=%d, mode=%d\n", 377 v4l_dbg(2, msp_debug, client, "nicam sync=%d, mode=%d\n",
378 val & 1, (val & 0x1e) >> 1); 378 val & 1, (val & 0x1e) >> 1);
379 379
380 if (val & 1) { 380 if (val & 1) {
@@ -407,7 +407,7 @@ int autodetect_stereo(struct i2c_client *client)
407 break; 407 break;
408 case MSP_MODE_BTSC: 408 case MSP_MODE_BTSC:
409 val = msp_read_dem(client, 0x200); 409 val = msp_read_dem(client, 0x200);
410 v4l_dbg(2, client, "status=0x%x (pri=%s, sec=%s, %s%s%s)\n", 410 v4l_dbg(2, msp_debug, client, "status=0x%x (pri=%s, sec=%s, %s%s%s)\n",
411 val, 411 val,
412 (val & 0x0002) ? "no" : "yes", 412 (val & 0x0002) ? "no" : "yes",
413 (val & 0x0004) ? "no" : "yes", 413 (val & 0x0004) ? "no" : "yes",
@@ -421,13 +421,13 @@ int autodetect_stereo(struct i2c_client *client)
421 } 421 }
422 if (rxsubchans != state->rxsubchans) { 422 if (rxsubchans != state->rxsubchans) {
423 update = 1; 423 update = 1;
424 v4l_dbg(1, client, "watch: rxsubchans %d => %d\n", 424 v4l_dbg(1, msp_debug, client, "watch: rxsubchans %d => %d\n",
425 state->rxsubchans,rxsubchans); 425 state->rxsubchans,rxsubchans);
426 state->rxsubchans = rxsubchans; 426 state->rxsubchans = rxsubchans;
427 } 427 }
428 if (newnicam != state->nicam_on) { 428 if (newnicam != state->nicam_on) {
429 update = 1; 429 update = 1;
430 v4l_dbg(1, client, "watch: nicam %d => %d\n", 430 v4l_dbg(1, msp_debug, client, "watch: nicam %d => %d\n",
431 state->nicam_on,newnicam); 431 state->nicam_on,newnicam);
432 state->nicam_on = newnicam; 432 state->nicam_on = newnicam;
433 } 433 }
@@ -452,7 +452,7 @@ static void watch_stereo(struct i2c_client *client)
452 msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); 452 msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO);
453 } 453 }
454 454
455 if (once) 455 if (msp_once)
456 state->watch_stereo = 0; 456 state->watch_stereo = 0;
457} 457}
458 458
@@ -464,21 +464,21 @@ int msp3400c_thread(void *data)
464 int count, max1,max2,val1,val2, val,this; 464 int count, max1,max2,val1,val2, val,this;
465 465
466 466
467 v4l_dbg(1, client, "msp3400 daemon started\n"); 467 v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
468 for (;;) { 468 for (;;) {
469 v4l_dbg(2, client, "msp3400 thread: sleep\n"); 469 v4l_dbg(2, msp_debug, client, "msp3400 thread: sleep\n");
470 msp_sleep(state, -1); 470 msp_sleep(state, -1);
471 v4l_dbg(2, client, "msp3400 thread: wakeup\n"); 471 v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n");
472 472
473 restart: 473 restart:
474 v4l_dbg(1, client, "thread: restart scan\n"); 474 v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
475 state->restart = 0; 475 state->restart = 0;
476 if (kthread_should_stop()) 476 if (kthread_should_stop())
477 break; 477 break;
478 478
479 if (state->radio || MSP_MODE_EXTERN == state->mode) { 479 if (state->radio || MSP_MODE_EXTERN == state->mode) {
480 /* no carrier scan, just unmute */ 480 /* no carrier scan, just unmute */
481 v4l_dbg(1, client, "thread: no carrier scan\n"); 481 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
482 msp_set_audio(client); 482 msp_set_audio(client);
483 continue; 483 continue;
484 } 484 }
@@ -498,11 +498,11 @@ int msp3400c_thread(void *data)
498 cd = msp3400c_carrier_detect_main; 498 cd = msp3400c_carrier_detect_main;
499 count = ARRAY_SIZE(msp3400c_carrier_detect_main); 499 count = ARRAY_SIZE(msp3400c_carrier_detect_main);
500 500
501 if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { 501 if (msp_amsound && (state->v4l2_std & V4L2_STD_SECAM)) {
502 /* autodetect doesn't work well with AM ... */ 502 /* autodetect doesn't work well with AM ... */
503 max1 = 3; 503 max1 = 3;
504 count = 0; 504 count = 0;
505 v4l_dbg(1, client, "AM sound override\n"); 505 v4l_dbg(1, msp_debug, client, "AM sound override\n");
506 } 506 }
507 507
508 for (this = 0; this < count; this++) { 508 for (this = 0; this < count; this++) {
@@ -514,7 +514,7 @@ int msp3400c_thread(void *data)
514 val -= 65536; 514 val -= 65536;
515 if (val1 < val) 515 if (val1 < val)
516 val1 = val, max1 = this; 516 val1 = val, max1 = this;
517 v4l_dbg(1, client, "carrier1 val: %5d / %s\n", val,cd[this].name); 517 v4l_dbg(1, msp_debug, client, "carrier1 val: %5d / %s\n", val,cd[this].name);
518 } 518 }
519 519
520 /* carrier detect pass #2 -- second (stereo) carrier */ 520 /* carrier detect pass #2 -- second (stereo) carrier */
@@ -535,7 +535,7 @@ int msp3400c_thread(void *data)
535 break; 535 break;
536 } 536 }
537 537
538 if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { 538 if (msp_amsound && (state->v4l2_std & V4L2_STD_SECAM)) {
539 /* autodetect doesn't work well with AM ... */ 539 /* autodetect doesn't work well with AM ... */
540 cd = NULL; 540 cd = NULL;
541 count = 0; 541 count = 0;
@@ -550,7 +550,7 @@ int msp3400c_thread(void *data)
550 val -= 65536; 550 val -= 65536;
551 if (val2 < val) 551 if (val2 < val)
552 val2 = val, max2 = this; 552 val2 = val, max2 = this;
553 v4l_dbg(1, client, "carrier2 val: %5d / %s\n", val,cd[this].name); 553 v4l_dbg(1, msp_debug, client, "carrier2 val: %5d / %s\n", val,cd[this].name);
554 } 554 }
555 555
556 /* program the msp3400 according to the results */ 556 /* program the msp3400 according to the results */
@@ -627,7 +627,7 @@ int msp3400c_thread(void *data)
627 /* unmute */ 627 /* unmute */
628 msp_set_audio(client); 628 msp_set_audio(client);
629 629
630 if (debug) 630 if (msp_debug)
631 msp3400c_print_mode(client); 631 msp3400c_print_mode(client);
632 632
633 /* monitor tv audio mode */ 633 /* monitor tv audio mode */
@@ -637,7 +637,7 @@ int msp3400c_thread(void *data)
637 watch_stereo(client); 637 watch_stereo(client);
638 } 638 }
639 } 639 }
640 v4l_dbg(1, client, "thread: exit\n"); 640 v4l_dbg(1, msp_debug, client, "thread: exit\n");
641 return 0; 641 return 0;
642} 642}
643 643
@@ -648,22 +648,22 @@ int msp3410d_thread(void *data)
648 struct msp_state *state = i2c_get_clientdata(client); 648 struct msp_state *state = i2c_get_clientdata(client);
649 int val, i, std; 649 int val, i, std;
650 650
651 v4l_dbg(1, client, "msp3410 daemon started\n"); 651 v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
652 652
653 for (;;) { 653 for (;;) {
654 v4l_dbg(2, client, "msp3410 thread: sleep\n"); 654 v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n");
655 msp_sleep(state,-1); 655 msp_sleep(state,-1);
656 v4l_dbg(2, client, "msp3410 thread: wakeup\n"); 656 v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n");
657 657
658 restart: 658 restart:
659 v4l_dbg(1, client, "thread: restart scan\n"); 659 v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
660 state->restart = 0; 660 state->restart = 0;
661 if (kthread_should_stop()) 661 if (kthread_should_stop())
662 break; 662 break;
663 663
664 if (state->mode == MSP_MODE_EXTERN) { 664 if (state->mode == MSP_MODE_EXTERN) {
665 /* no carrier scan needed, just unmute */ 665 /* no carrier scan needed, just unmute */
666 v4l_dbg(1, client, "thread: no carrier scan\n"); 666 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
667 msp_set_audio(client); 667 msp_set_audio(client);
668 continue; 668 continue;
669 } 669 }
@@ -682,8 +682,8 @@ int msp3410d_thread(void *data)
682 std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1; 682 std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1;
683 state->watch_stereo = 0; 683 state->watch_stereo = 0;
684 684
685 if (debug) 685 if (msp_debug)
686 v4l_dbg(1, client, "setting standard: %s (0x%04x)\n", 686 v4l_dbg(1, msp_debug, client, "setting standard: %s (0x%04x)\n",
687 msp_standard_std_name(std), std); 687 msp_standard_std_name(std), std);
688 688
689 if (std != 1) { 689 if (std != 1) {
@@ -700,22 +700,22 @@ int msp3410d_thread(void *data)
700 val = msp_read_dem(client, 0x7e); 700 val = msp_read_dem(client, 0x7e);
701 if (val < 0x07ff) 701 if (val < 0x07ff)
702 break; 702 break;
703 v4l_dbg(1, client, "detection still in progress\n"); 703 v4l_dbg(1, msp_debug, client, "detection still in progress\n");
704 } 704 }
705 } 705 }
706 for (i = 0; msp_stdlist[i].name != NULL; i++) 706 for (i = 0; msp_stdlist[i].name != NULL; i++)
707 if (msp_stdlist[i].retval == val) 707 if (msp_stdlist[i].retval == val)
708 break; 708 break;
709 v4l_dbg(1, client, "current standard: %s (0x%04x)\n", 709 v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n",
710 msp_standard_std_name(val), val); 710 msp_standard_std_name(val), val);
711 state->main = msp_stdlist[i].main; 711 state->main = msp_stdlist[i].main;
712 state->second = msp_stdlist[i].second; 712 state->second = msp_stdlist[i].second;
713 state->std = val; 713 state->std = val;
714 714
715 if (amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && 715 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) &&
716 (val != 0x0009)) { 716 (val != 0x0009)) {
717 /* autodetection has failed, let backup */ 717 /* autodetection has failed, let backup */
718 v4l_dbg(1, client, "autodetection failed," 718 v4l_dbg(1, msp_debug, client, "autodetection failed,"
719 " switching to backup standard: %s (0x%04x)\n", 719 " switching to backup standard: %s (0x%04x)\n",
720 msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val); 720 msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val);
721 val = 0x0009; 721 val = 0x0009;
@@ -798,13 +798,13 @@ int msp3410d_thread(void *data)
798 watch_stereo(client); 798 watch_stereo(client);
799 } 799 }
800 } 800 }
801 v4l_dbg(1, client, "thread: exit\n"); 801 v4l_dbg(1, msp_debug, client, "thread: exit\n");
802 return 0; 802 return 0;
803} 803}
804 804
805/* ----------------------------------------------------------------------- */ 805/* ----------------------------------------------------------------------- */
806 806
807/* msp34xxG + (autoselect no-thread) */ 807/* msp34xxG + (autoselect no-thread) */
808/* this one uses both automatic standard detection and automatic sound */ 808/* this one uses both automatic standard detection and automatic sound */
809/* select which are available in the newer G versions */ 809/* select which are available in the newer G versions */
810/* struct msp: only norm, acb and source are really used in this mode */ 810/* struct msp: only norm, acb and source are really used in this mode */
@@ -825,7 +825,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
825 */ 825 */
826 int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20); 826 int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20);
827 827
828 v4l_dbg(1, client, "set source to %d (0x%x)\n", source, value); 828 v4l_dbg(1, msp_debug, client, "set source to %d (0x%x)\n", source, value);
829 /* Loudspeaker Output */ 829 /* Loudspeaker Output */
830 msp_write_dsp(client, 0x08, value); 830 msp_write_dsp(client, 0x08, value);
831 /* SCART1 DA Output */ 831 /* SCART1 DA Output */
@@ -840,7 +840,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
840 * 0x7f0 = forced mono mode 840 * 0x7f0 = forced mono mode
841 */ 841 */
842 /* a2 threshold for stereo/bilingual */ 842 /* a2 threshold for stereo/bilingual */
843 msp_write_dem(client, 0x22, stereo_threshold); 843 msp_write_dem(client, 0x22, msp_stereo_thresh);
844 state->source = source; 844 state->source = source;
845} 845}
846 846
@@ -897,28 +897,28 @@ int msp34xxg_thread(void *data)
897 struct msp_state *state = i2c_get_clientdata(client); 897 struct msp_state *state = i2c_get_clientdata(client);
898 int val, std, i; 898 int val, std, i;
899 899
900 v4l_dbg(1, client, "msp34xxg daemon started\n"); 900 v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
901 901
902 state->source = 1; /* default */ 902 state->source = 1; /* default */
903 for (;;) { 903 for (;;) {
904 v4l_dbg(2, client, "msp34xxg thread: sleep\n"); 904 v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n");
905 msp_sleep(state, -1); 905 msp_sleep(state, -1);
906 v4l_dbg(2, client, "msp34xxg thread: wakeup\n"); 906 v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n");
907 907
908 restart: 908 restart:
909 v4l_dbg(1, client, "thread: restart scan\n"); 909 v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
910 state->restart = 0; 910 state->restart = 0;
911 if (kthread_should_stop()) 911 if (kthread_should_stop())
912 break; 912 break;
913 913
914 /* setup the chip*/ 914 /* setup the chip*/
915 msp34xxg_reset(client); 915 msp34xxg_reset(client);
916 std = standard; 916 std = msp_standard;
917 if (std != 0x01) 917 if (std != 0x01)
918 goto unmute; 918 goto unmute;
919 919
920 /* watch autodetect */ 920 /* watch autodetect */
921 v4l_dbg(1, client, "triggered autodetect, waiting for result\n"); 921 v4l_dbg(1, msp_debug, client, "triggered autodetect, waiting for result\n");
922 for (i = 0; i < 10; i++) { 922 for (i = 0; i < 10; i++) {
923 if (msp_sleep(state, 100)) 923 if (msp_sleep(state, 100))
924 goto restart; 924 goto restart;
@@ -929,16 +929,16 @@ int msp34xxg_thread(void *data)
929 std = val; 929 std = val;
930 break; 930 break;
931 } 931 }
932 v4l_dbg(2, client, "detection still in progress\n"); 932 v4l_dbg(2, msp_debug, client, "detection still in progress\n");
933 } 933 }
934 if (std == 1) { 934 if (std == 1) {
935 v4l_dbg(1, client, "detection still in progress after 10 tries. giving up.\n"); 935 v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n");
936 continue; 936 continue;
937 } 937 }
938 938
939 unmute: 939 unmute:
940 state->std = std; 940 state->std = std;
941 v4l_dbg(1, client, "current standard: %s (0x%04x)\n", 941 v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n",
942 msp_standard_std_name(std), std); 942 msp_standard_std_name(std), std);
943 943
944 /* unmute: dispatch sound to scart output, set scart volume */ 944 /* unmute: dispatch sound to scart output, set scart volume */
@@ -950,7 +950,7 @@ int msp34xxg_thread(void *data)
950 950
951 msp_write_dem(client, 0x40, state->i2s_mode); 951 msp_write_dem(client, 0x40, state->i2s_mode);
952 } 952 }
953 v4l_dbg(1, client, "thread: exit\n"); 953 v4l_dbg(1, msp_debug, client, "thread: exit\n");
954 return 0; 954 return 0;
955} 955}
956 956
@@ -976,7 +976,7 @@ void msp34xxg_detect_stereo(struct i2c_client *client)
976 * this is a problem, I'll handle SAP just like lang1/lang2. 976 * this is a problem, I'll handle SAP just like lang1/lang2.
977 */ 977 */
978 } 978 }
979 v4l_dbg(1, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n", 979 v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
980 status, is_stereo, is_bilingual, state->rxsubchans); 980 status, is_stereo, is_bilingual, state->rxsubchans);
981} 981}
982 982
diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h
index 8a05cf500a8c..70a5ef8ba017 100644
--- a/drivers/media/video/msp3400.h
+++ b/drivers/media/video/msp3400.h
@@ -48,12 +48,12 @@ struct msp_matrix {
48#define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */ 48#define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */
49 49
50/* module parameters */ 50/* module parameters */
51extern int debug; 51extern int msp_debug;
52extern int once; 52extern int msp_once;
53extern int amsound; 53extern int msp_amsound;
54extern int standard; 54extern int msp_standard;
55extern int dolby; 55extern int msp_dolby;
56extern int stereo_threshold; 56extern int msp_stereo_thresh;
57 57
58struct msp_state { 58struct msp_state {
59 int rev1, rev2; 59 int rev1, rev2;
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 2c19c9588c02..0bf1caac5887 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -21,7 +21,7 @@ static unsigned int radio_antenna = 0;
21module_param(radio_antenna, int, 0644); 21module_param(radio_antenna, int, 0644);
22 22
23/* from tuner-core.c */ 23/* from tuner-core.c */
24extern int debug; 24extern int tuner_debug;
25 25
26/* ---------------------------------------------------------------------- */ 26/* ---------------------------------------------------------------------- */
27 27
@@ -404,7 +404,7 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
404 div2a=(lo2/8)-1; 404 div2a=(lo2/8)-1;
405 div2b=lo2-(div2a+1)*8; 405 div2b=lo2-(div2a+1)*8;
406 406
407 if (debug > 1) { 407 if (tuner_debug > 1) {
408 tuner_dbg("lo1 lo2 = %d %d\n", lo1, lo2); 408 tuner_dbg("lo1 lo2 = %d %d\n", lo1, lo2);
409 tuner_dbg("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n", 409 tuner_dbg("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",
410 num1,num2,div1a,div1b,div2a,div2b); 410 num1,num2,div1a,div1b,div2a,div2b);
@@ -420,7 +420,7 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
420 buf[5]=div2a; 420 buf[5]=div2a;
421 if(num2!=0) buf[5]=buf[5]|0x40; 421 if(num2!=0) buf[5]=buf[5]|0x40;
422 422
423 if (debug > 1) { 423 if (tuner_debug > 1) {
424 int i; 424 int i;
425 tuner_dbg("bufs is: "); 425 tuner_dbg("bufs is: ");
426 for(i=0;i<6;i++) 426 for(i=0;i<6;i++)
@@ -508,7 +508,7 @@ int microtune_init(struct i2c_client *c)
508 508
509 i2c_master_send(c,buf,1); 509 i2c_master_send(c,buf,1);
510 i2c_master_recv(c,buf,21); 510 i2c_master_recv(c,buf,21);
511 if (debug) { 511 if (tuner_debug) {
512 int i; 512 int i;
513 tuner_dbg("MT20xx hexdump:"); 513 tuner_dbg("MT20xx hexdump:");
514 for(i=0;i<21;i++) { 514 for(i=0;i<21;i++) {
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 91681aa6c657..8416ceff524b 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -177,12 +177,11 @@ static int mxb_probe(struct saa7146_dev* dev)
177 return -ENODEV; 177 return -ENODEV;
178 } 178 }
179 179
180 mxb = (struct mxb*)kmalloc(sizeof(struct mxb), GFP_KERNEL); 180 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL);
181 if( NULL == mxb ) { 181 if( NULL == mxb ) {
182 DEB_D(("not enough kernel memory.\n")); 182 DEB_D(("not enough kernel memory.\n"));
183 return -ENOMEM; 183 return -ENOMEM;
184 } 184 }
185 memset(mxb, 0x0, sizeof(struct mxb));
186 185
187 mxb->i2c_adapter = (struct i2c_adapter) { 186 mxb->i2c_adapter = (struct i2c_adapter) {
188 .class = I2C_CLASS_TV_ANALOG, 187 .class = I2C_CLASS_TV_ANALOG,
diff --git a/drivers/media/video/ovcamchip/ov6x20.c b/drivers/media/video/ovcamchip/ov6x20.c
index b3f4d266cede..c04130dab127 100644
--- a/drivers/media/video/ovcamchip/ov6x20.c
+++ b/drivers/media/video/ovcamchip/ov6x20.c
@@ -178,10 +178,9 @@ static int ov6x20_init(struct i2c_client *c)
178 if (rc < 0) 178 if (rc < 0)
179 return rc; 179 return rc;
180 180
181 ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); 181 ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL);
182 if (!s) 182 if (!s)
183 return -ENOMEM; 183 return -ENOMEM;
184 memset(s, 0, sizeof *s);
185 184
186 s->auto_brt = 1; 185 s->auto_brt = 1;
187 s->auto_exp = 1; 186 s->auto_exp = 1;
diff --git a/drivers/media/video/ovcamchip/ov6x30.c b/drivers/media/video/ovcamchip/ov6x30.c
index 6eab458ab792..73b94f51a85a 100644
--- a/drivers/media/video/ovcamchip/ov6x30.c
+++ b/drivers/media/video/ovcamchip/ov6x30.c
@@ -141,10 +141,9 @@ static int ov6x30_init(struct i2c_client *c)
141 if (rc < 0) 141 if (rc < 0)
142 return rc; 142 return rc;
143 143
144 ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); 144 ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL);
145 if (!s) 145 if (!s)
146 return -ENOMEM; 146 return -ENOMEM;
147 memset(s, 0, sizeof *s);
148 147
149 s->auto_brt = 1; 148 s->auto_brt = 1;
150 s->auto_exp = 1; 149 s->auto_exp = 1;
diff --git a/drivers/media/video/ovcamchip/ov76be.c b/drivers/media/video/ovcamchip/ov76be.c
index 29bbdc05e3b6..11f6be924d8b 100644
--- a/drivers/media/video/ovcamchip/ov76be.c
+++ b/drivers/media/video/ovcamchip/ov76be.c
@@ -105,10 +105,9 @@ static int ov76be_init(struct i2c_client *c)
105 if (rc < 0) 105 if (rc < 0)
106 return rc; 106 return rc;
107 107
108 ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); 108 ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL);
109 if (!s) 109 if (!s)
110 return -ENOMEM; 110 return -ENOMEM;
111 memset(s, 0, sizeof *s);
112 111
113 s->auto_brt = 1; 112 s->auto_brt = 1;
114 s->auto_exp = 1; 113 s->auto_exp = 1;
diff --git a/drivers/media/video/ovcamchip/ov7x10.c b/drivers/media/video/ovcamchip/ov7x10.c
index 6c383d4b14fa..5206e7913924 100644
--- a/drivers/media/video/ovcamchip/ov7x10.c
+++ b/drivers/media/video/ovcamchip/ov7x10.c
@@ -115,10 +115,9 @@ static int ov7x10_init(struct i2c_client *c)
115 if (rc < 0) 115 if (rc < 0)
116 return rc; 116 return rc;
117 117
118 ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); 118 ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL);
119 if (!s) 119 if (!s)
120 return -ENOMEM; 120 return -ENOMEM;
121 memset(s, 0, sizeof *s);
122 121
123 s->auto_brt = 1; 122 s->auto_brt = 1;
124 s->auto_exp = 1; 123 s->auto_exp = 1;
diff --git a/drivers/media/video/ovcamchip/ov7x20.c b/drivers/media/video/ovcamchip/ov7x20.c
index 3c8c48f338ba..8e26ae338f31 100644
--- a/drivers/media/video/ovcamchip/ov7x20.c
+++ b/drivers/media/video/ovcamchip/ov7x20.c
@@ -232,10 +232,9 @@ static int ov7x20_init(struct i2c_client *c)
232 if (rc < 0) 232 if (rc < 0)
233 return rc; 233 return rc;
234 234
235 ov->spriv = s = kmalloc(sizeof *s, GFP_KERNEL); 235 ov->spriv = s = kzalloc(sizeof *s, GFP_KERNEL);
236 if (!s) 236 if (!s)
237 return -ENOMEM; 237 return -ENOMEM;
238 memset(s, 0, sizeof *s);
239 238
240 s->auto_brt = 1; 239 s->auto_brt = 1;
241 s->auto_exp = DFL_AUTO_EXP; 240 s->auto_exp = DFL_AUTO_EXP;
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index 428f1bb75ec3..e76b53d5909c 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -316,12 +316,11 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
316 c->adapter = adap; 316 c->adapter = adap;
317 strcpy(c->name, "OV????"); 317 strcpy(c->name, "OV????");
318 318
319 ov = kmalloc(sizeof *ov, GFP_KERNEL); 319 ov = kzalloc(sizeof *ov, GFP_KERNEL);
320 if (!ov) { 320 if (!ov) {
321 rc = -ENOMEM; 321 rc = -ENOMEM;
322 goto no_ov; 322 goto no_ov;
323 } 323 }
324 memset(ov, 0, sizeof *ov);
325 i2c_set_clientdata(c, ov); 324 i2c_set_clientdata(c, ov);
326 325
327 rc = ovcamchip_detect(c); 326 rc = ovcamchip_detect(c);
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 0aa9e72f632c..2ce010201308 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -83,13 +83,12 @@ static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind)
83 client_template.adapter = adap; 83 client_template.adapter = adap;
84 client_template.addr = addr; 84 client_template.addr = addr;
85 memcpy(client, &client_template, sizeof(*client)); 85 memcpy(client, &client_template, sizeof(*client));
86 t = kmalloc(sizeof(*t), GFP_KERNEL); 86 t = kzalloc(sizeof(*t), GFP_KERNEL);
87 if(t==NULL) 87 if(t==NULL)
88 { 88 {
89 kfree(client); 89 kfree(client);
90 return -ENOMEM; 90 return -ENOMEM;
91 } 91 }
92 memset(t, 0, sizeof(*t));
93 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 92 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
94 init_MUTEX(&t->lock); 93 init_MUTEX(&t->lock);
95 94
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 73b4f0e2abf0..5694eb58c3a1 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -151,13 +151,12 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
151 client_template.adapter = adap; 151 client_template.adapter = adap;
152 client_template.addr = addr; 152 client_template.addr = addr;
153 memcpy(client, &client_template, sizeof(*client)); 153 memcpy(client, &client_template, sizeof(*client));
154 t = kmalloc(sizeof(*t), GFP_KERNEL); 154 t = kzalloc(sizeof(*t), GFP_KERNEL);
155 if(t==NULL) 155 if(t==NULL)
156 { 156 {
157 kfree(client); 157 kfree(client);
158 return -ENOMEM; 158 return -ENOMEM;
159 } 159 }
160 memset(t, 0, sizeof(*t));
161 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 160 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
162 init_MUTEX(&t->lock); 161 init_MUTEX(&t->lock);
163 162
@@ -165,7 +164,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
165 * Now create a video4linux device 164 * Now create a video4linux device
166 */ 165 */
167 166
168 vd = (struct video_device *)kmalloc(sizeof(struct video_device), GFP_KERNEL); 167 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
169 if(vd==NULL) 168 if(vd==NULL)
170 { 169 {
171 kfree(t); 170 kfree(t);
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 619ff0b7a1ff..7bb85a7b326e 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -494,21 +494,19 @@ saa7110_detect_client (struct i2c_adapter *adapter,
494 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 494 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
495 return 0; 495 return 0;
496 496
497 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 497 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
498 if (client == 0) 498 if (client == 0)
499 return -ENOMEM; 499 return -ENOMEM;
500 memset(client, 0, sizeof(struct i2c_client));
501 client->addr = address; 500 client->addr = address;
502 client->adapter = adapter; 501 client->adapter = adapter;
503 client->driver = &i2c_driver_saa7110; 502 client->driver = &i2c_driver_saa7110;
504 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); 503 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
505 504
506 decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL); 505 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL);
507 if (decoder == 0) { 506 if (decoder == 0) {
508 kfree(client); 507 kfree(client);
509 return -ENOMEM; 508 return -ENOMEM;
510 } 509 }
511 memset(decoder, 0, sizeof(struct saa7110));
512 decoder->norm = VIDEO_MODE_PAL; 510 decoder->norm = VIDEO_MODE_PAL;
513 decoder->input = 0; 511 decoder->input = 0;
514 decoder->enable = 1; 512 decoder->enable = 1;
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index acaeee592b54..8c06592b37ff 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -511,21 +511,19 @@ saa7111_detect_client (struct i2c_adapter *adapter,
511 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 511 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
512 return 0; 512 return 0;
513 513
514 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 514 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
515 if (client == 0) 515 if (client == 0)
516 return -ENOMEM; 516 return -ENOMEM;
517 memset(client, 0, sizeof(struct i2c_client));
518 client->addr = address; 517 client->addr = address;
519 client->adapter = adapter; 518 client->adapter = adapter;
520 client->driver = &i2c_driver_saa7111; 519 client->driver = &i2c_driver_saa7111;
521 strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client))); 520 strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client)));
522 521
523 decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL); 522 decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL);
524 if (decoder == NULL) { 523 if (decoder == NULL) {
525 kfree(client); 524 kfree(client);
526 return -ENOMEM; 525 return -ENOMEM;
527 } 526 }
528 memset(decoder, 0, sizeof(struct saa7111));
529 decoder->norm = VIDEO_MODE_NTSC; 527 decoder->norm = VIDEO_MODE_NTSC;
530 decoder->input = 0; 528 decoder->input = 0;
531 decoder->enable = 1; 529 decoder->enable = 1;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index b7ac0122f729..fd0a4b4ef014 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -852,21 +852,19 @@ saa7114_detect_client (struct i2c_adapter *adapter,
852 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 852 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
853 return 0; 853 return 0;
854 854
855 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 855 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
856 if (client == 0) 856 if (client == 0)
857 return -ENOMEM; 857 return -ENOMEM;
858 memset(client, 0, sizeof(struct i2c_client));
859 client->addr = address; 858 client->addr = address;
860 client->adapter = adapter; 859 client->adapter = adapter;
861 client->driver = &i2c_driver_saa7114; 860 client->driver = &i2c_driver_saa7114;
862 strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client))); 861 strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client)));
863 862
864 decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL); 863 decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL);
865 if (decoder == NULL) { 864 if (decoder == NULL) {
866 kfree(client); 865 kfree(client);
867 return -ENOMEM; 866 return -ENOMEM;
868 } 867 }
869 memset(decoder, 0, sizeof(struct saa7114));
870 decoder->norm = VIDEO_MODE_NTSC; 868 decoder->norm = VIDEO_MODE_NTSC;
871 decoder->input = -1; 869 decoder->input = -1;
872 decoder->enable = 1; 870 decoder->enable = 1;
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 4a4bc69fb0e9..048d000941c7 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -549,7 +549,7 @@ static int saa7115_set_audio_clock_freq(struct i2c_client *client, u32 freq)
549 u32 hz; 549 u32 hz;
550 u64 f; 550 u64 f;
551 551
552 v4l_dbg(1, client, "set audio clock freq: %d\n", freq); 552 v4l_dbg(1, debug, client, "set audio clock freq: %d\n", freq);
553 553
554 /* sanity check */ 554 /* sanity check */
555 if (freq < 32000 || freq > 48000) 555 if (freq < 32000 || freq > 48000)
@@ -670,10 +670,10 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
670 670
671 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. 671 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants.
672 if (std & V4L2_STD_525_60) { 672 if (std & V4L2_STD_525_60) {
673 v4l_dbg(1, client, "decoder set standard 60 Hz\n"); 673 v4l_dbg(1, debug, client, "decoder set standard 60 Hz\n");
674 saa7115_writeregs(client, saa7115_cfg_60hz_video); 674 saa7115_writeregs(client, saa7115_cfg_60hz_video);
675 } else { 675 } else {
676 v4l_dbg(1, client, "decoder set standard 50 Hz\n"); 676 v4l_dbg(1, debug, client, "decoder set standard 50 Hz\n");
677 saa7115_writeregs(client, saa7115_cfg_50hz_video); 677 saa7115_writeregs(client, saa7115_cfg_50hz_video);
678 } 678 }
679 679
@@ -863,7 +863,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
863 863
864 pix = &(fmt->fmt.pix); 864 pix = &(fmt->fmt.pix);
865 865
866 v4l_dbg(1, client, "decoder set size\n"); 866 v4l_dbg(1, debug, client, "decoder set size\n");
867 867
868 /* FIXME need better bounds checking here */ 868 /* FIXME need better bounds checking here */
869 if ((pix->width < 1) || (pix->width > 1440)) 869 if ((pix->width < 1) || (pix->width > 1440))
@@ -889,7 +889,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
889 HPSC = HPSC ? HPSC : 1; 889 HPSC = HPSC ? HPSC : 1;
890 HFSC = (int)((1024 * 720) / (HPSC * pix->width)); 890 HFSC = (int)((1024 * 720) / (HPSC * pix->width));
891 891
892 v4l_dbg(1, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); 892 v4l_dbg(1, debug, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC);
893 /* FIXME hardcodes to "Task B" 893 /* FIXME hardcodes to "Task B"
894 * write H prescaler integer */ 894 * write H prescaler integer */
895 saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f)); 895 saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f));
@@ -903,10 +903,10 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
903 saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff)); 903 saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff));
904 } else { 904 } else {
905 if (is_50hz) { 905 if (is_50hz) {
906 v4l_dbg(1, client, "Setting full 50hz width\n"); 906 v4l_dbg(1, debug, client, "Setting full 50hz width\n");
907 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x); 907 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x);
908 } else { 908 } else {
909 v4l_dbg(1, client, "Setting full 60hz width\n"); 909 v4l_dbg(1, debug, client, "Setting full 60hz width\n");
910 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); 910 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
911 } 911 }
912 } 912 }
@@ -915,7 +915,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
915 915
916 if (pix->height != Vsrc) { 916 if (pix->height != Vsrc) {
917 VSCY = (int)((1024 * Vsrc) / pix->height); 917 VSCY = (int)((1024 * Vsrc) / pix->height);
918 v4l_dbg(1, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); 918 v4l_dbg(1, debug, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY);
919 919
920 /* Correct Contrast and Luminance */ 920 /* Correct Contrast and Luminance */
921 saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY)); 921 saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY));
@@ -929,10 +929,10 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
929 saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff)); 929 saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff));
930 } else { 930 } else {
931 if (is_50hz) { 931 if (is_50hz) {
932 v4l_dbg(1, client, "Setting full 50Hz height\n"); 932 v4l_dbg(1, debug, client, "Setting full 50Hz height\n");
933 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y); 933 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y);
934 } else { 934 } else {
935 v4l_dbg(1, client, "Setting full 60hz height\n"); 935 v4l_dbg(1, debug, client, "Setting full 60hz height\n");
936 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); 936 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
937 } 937 }
938 } 938 }
@@ -1079,7 +1079,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1079 break; 1079 break;
1080 status = saa7115_read(client, 0x1f); 1080 status = saa7115_read(client, 0x1f);
1081 1081
1082 v4l_dbg(1, client, "status: 0x%02x\n", status); 1082 v4l_dbg(1, debug, client, "status: 0x%02x\n", status);
1083 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; 1083 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0;
1084 break; 1084 break;
1085 } 1085 }
@@ -1125,7 +1125,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1125 break; 1125 break;
1126 1126
1127 case VIDIOC_S_INPUT: 1127 case VIDIOC_S_INPUT:
1128 v4l_dbg(1, client, "decoder set input %d\n", *iarg); 1128 v4l_dbg(1, debug, client, "decoder set input %d\n", *iarg);
1129 /* inputs from 0-9 are available */ 1129 /* inputs from 0-9 are available */
1130 if (*iarg < 0 || *iarg > 9) { 1130 if (*iarg < 0 || *iarg > 9) {
1131 return -EINVAL; 1131 return -EINVAL;
@@ -1133,7 +1133,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1133 1133
1134 if (state->input == *iarg) 1134 if (state->input == *iarg)
1135 break; 1135 break;
1136 v4l_dbg(1, client, "now setting %s input\n", 1136 v4l_dbg(1, debug, client, "now setting %s input\n",
1137 *iarg >= 6 ? "S-Video" : "Composite"); 1137 *iarg >= 6 ? "S-Video" : "Composite");
1138 state->input = *iarg; 1138 state->input = *iarg;
1139 1139
@@ -1150,7 +1150,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1150 1150
1151 case VIDIOC_STREAMON: 1151 case VIDIOC_STREAMON:
1152 case VIDIOC_STREAMOFF: 1152 case VIDIOC_STREAMOFF:
1153 v4l_dbg(1, client, "%s output\n", 1153 v4l_dbg(1, debug, client, "%s output\n",
1154 (cmd == VIDIOC_STREAMON) ? "enable" : "disable"); 1154 (cmd == VIDIOC_STREAMON) ? "enable" : "disable");
1155 1155
1156 if (state->enable != (cmd == VIDIOC_STREAMON)) { 1156 if (state->enable != (cmd == VIDIOC_STREAMON)) {
@@ -1164,7 +1164,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1164 break; 1164 break;
1165 1165
1166 case VIDIOC_INT_RESET: 1166 case VIDIOC_INT_RESET:
1167 v4l_dbg(1, client, "decoder RESET\n"); 1167 v4l_dbg(1, debug, client, "decoder RESET\n");
1168 saa7115_writeregs(client, saa7115_cfg_reset_scaler); 1168 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1169 break; 1169 break;
1170 1170
@@ -1249,21 +1249,20 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1249 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1249 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1250 return 0; 1250 return 0;
1251 1251
1252 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 1252 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1253 if (client == 0) 1253 if (client == 0)
1254 return -ENOMEM; 1254 return -ENOMEM;
1255 memset(client, 0, sizeof(struct i2c_client));
1256 client->addr = address; 1255 client->addr = address;
1257 client->adapter = adapter; 1256 client->adapter = adapter;
1258 client->driver = &i2c_driver_saa7115; 1257 client->driver = &i2c_driver_saa7115;
1259 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1258 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1260 1259
1261 v4l_dbg(1, client, "detecting saa7115 client on address 0x%x\n", address << 1); 1260 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
1262 1261
1263 saa7115_write(client, 0, 5); 1262 saa7115_write(client, 0, 5);
1264 chip_id = saa7115_read(client, 0) & 0x0f; 1263 chip_id = saa7115_read(client, 0) & 0x0f;
1265 if (chip_id != 4 && chip_id != 5) { 1264 if (chip_id != 4 && chip_id != 5) {
1266 v4l_dbg(1, client, "saa7115 not found\n"); 1265 v4l_dbg(1, debug, client, "saa7115 not found\n");
1267 kfree(client); 1266 kfree(client);
1268 return 0; 1267 return 0;
1269 } 1268 }
@@ -1272,13 +1271,12 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1272 } 1271 }
1273 v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); 1272 v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name);
1274 1273
1275 state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL); 1274 state = kzalloc(sizeof(struct saa7115_state), GFP_KERNEL);
1276 i2c_set_clientdata(client, state); 1275 i2c_set_clientdata(client, state);
1277 if (state == NULL) { 1276 if (state == NULL) {
1278 kfree(client); 1277 kfree(client);
1279 return -ENOMEM; 1278 return -ENOMEM;
1280 } 1279 }
1281 memset(state, 0, sizeof(struct saa7115_state));
1282 state->std = V4L2_STD_NTSC; 1280 state->std = V4L2_STD_NTSC;
1283 state->input = -1; 1281 state->input = -1;
1284 state->enable = 1; 1282 state->enable = 1;
@@ -1290,7 +1288,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1290 state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115; 1288 state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115;
1291 state->audclk_freq = 48000; 1289 state->audclk_freq = 48000;
1292 1290
1293 v4l_dbg(1, client, "writing init values\n"); 1291 v4l_dbg(1, debug, client, "writing init values\n");
1294 1292
1295 /* init to 60hz/48khz */ 1293 /* init to 60hz/48khz */
1296 saa7115_writeregs(client, saa7115_init_auto_input); 1294 saa7115_writeregs(client, saa7115_init_auto_input);
@@ -1303,7 +1301,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1303 1301
1304 i2c_attach_client(client); 1302 i2c_attach_client(client);
1305 1303
1306 v4l_dbg(1, client, "status: (1E) 0x%02x, (1F) 0x%02x\n", 1304 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n",
1307 saa7115_read(client, 0x1e), saa7115_read(client, 0x1f)); 1305 saa7115_read(client, 0x1e), saa7115_read(client, 0x1f));
1308 1306
1309 return 0; 1307 return 0;
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index f39a7be08588..ae53063875f9 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -487,20 +487,18 @@ saa711x_detect_client (struct i2c_adapter *adapter,
487 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 487 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
488 return 0; 488 return 0;
489 489
490 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 490 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
491 if (client == 0) 491 if (client == 0)
492 return -ENOMEM; 492 return -ENOMEM;
493 memset(client, 0, sizeof(struct i2c_client));
494 client->addr = address; 493 client->addr = address;
495 client->adapter = adapter; 494 client->adapter = adapter;
496 client->driver = &i2c_driver_saa711x; 495 client->driver = &i2c_driver_saa711x;
497 strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client))); 496 strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client)));
498 decoder = kmalloc(sizeof(struct saa711x), GFP_KERNEL); 497 decoder = kzalloc(sizeof(struct saa711x), GFP_KERNEL);
499 if (decoder == NULL) { 498 if (decoder == NULL) {
500 kfree(client); 499 kfree(client);
501 return -ENOMEM; 500 return -ENOMEM;
502 } 501 }
503 memset(decoder, 0, sizeof(struct saa711x));
504 decoder->norm = VIDEO_MODE_NTSC; 502 decoder->norm = VIDEO_MODE_NTSC;
505 decoder->input = 0; 503 decoder->input = 0;
506 decoder->enable = 1; 504 decoder->enable = 1;
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 2009c1bc4720..992c71774f30 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -338,7 +338,7 @@ static int saa7127_set_vps(struct i2c_client *client, struct v4l2_sliced_vbi_dat
338 if (enable && (data->field != 0 || data->line != 16)) 338 if (enable && (data->field != 0 || data->line != 16))
339 return -EINVAL; 339 return -EINVAL;
340 if (state->vps_enable != enable) { 340 if (state->vps_enable != enable) {
341 v4l_dbg(1, client, "Turn VPS Signal %s\n", enable ? "on" : "off"); 341 v4l_dbg(1, debug, client, "Turn VPS Signal %s\n", enable ? "on" : "off");
342 saa7127_write(client, 0x54, enable << 7); 342 saa7127_write(client, 0x54, enable << 7);
343 state->vps_enable = enable; 343 state->vps_enable = enable;
344 } 344 }
@@ -350,7 +350,7 @@ static int saa7127_set_vps(struct i2c_client *client, struct v4l2_sliced_vbi_dat
350 state->vps_data[2] = data->data[11]; 350 state->vps_data[2] = data->data[11];
351 state->vps_data[3] = data->data[12]; 351 state->vps_data[3] = data->data[12];
352 state->vps_data[4] = data->data[13]; 352 state->vps_data[4] = data->data[13];
353 v4l_dbg(1, client, "Set VPS data %02x %02x %02x %02x %02x\n", 353 v4l_dbg(1, debug, client, "Set VPS data %02x %02x %02x %02x %02x\n",
354 state->vps_data[0], state->vps_data[1], 354 state->vps_data[0], state->vps_data[1],
355 state->vps_data[2], state->vps_data[3], 355 state->vps_data[2], state->vps_data[3],
356 state->vps_data[4]); 356 state->vps_data[4]);
@@ -373,7 +373,7 @@ static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data
373 if (enable && (data->field != 0 || data->line != 21)) 373 if (enable && (data->field != 0 || data->line != 21))
374 return -EINVAL; 374 return -EINVAL;
375 if (state->cc_enable != enable) { 375 if (state->cc_enable != enable) {
376 v4l_dbg(1, client, "Turn CC %s\n", enable ? "on" : "off"); 376 v4l_dbg(1, debug, client, "Turn CC %s\n", enable ? "on" : "off");
377 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 377 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
378 (state->xds_enable << 7) | (enable << 6) | 0x11); 378 (state->xds_enable << 7) | (enable << 6) | 0x11);
379 state->cc_enable = enable; 379 state->cc_enable = enable;
@@ -381,7 +381,7 @@ static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data
381 if (!enable) 381 if (!enable)
382 return 0; 382 return 0;
383 383
384 v4l_dbg(2, client, "CC data: %04x\n", cc); 384 v4l_dbg(2, debug, client, "CC data: %04x\n", cc);
385 saa7127_write(client, SAA7127_REG_LINE_21_ODD_0, cc & 0xff); 385 saa7127_write(client, SAA7127_REG_LINE_21_ODD_0, cc & 0xff);
386 saa7127_write(client, SAA7127_REG_LINE_21_ODD_1, cc >> 8); 386 saa7127_write(client, SAA7127_REG_LINE_21_ODD_1, cc >> 8);
387 state->cc_data = cc; 387 state->cc_data = cc;
@@ -399,7 +399,7 @@ static int saa7127_set_xds(struct i2c_client *client, struct v4l2_sliced_vbi_dat
399 if (enable && (data->field != 1 || data->line != 21)) 399 if (enable && (data->field != 1 || data->line != 21))
400 return -EINVAL; 400 return -EINVAL;
401 if (state->xds_enable != enable) { 401 if (state->xds_enable != enable) {
402 v4l_dbg(1, client, "Turn XDS %s\n", enable ? "on" : "off"); 402 v4l_dbg(1, debug, client, "Turn XDS %s\n", enable ? "on" : "off");
403 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 403 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
404 (enable << 7) | (state->cc_enable << 6) | 0x11); 404 (enable << 7) | (state->cc_enable << 6) | 0x11);
405 state->xds_enable = enable; 405 state->xds_enable = enable;
@@ -407,7 +407,7 @@ static int saa7127_set_xds(struct i2c_client *client, struct v4l2_sliced_vbi_dat
407 if (!enable) 407 if (!enable)
408 return 0; 408 return 0;
409 409
410 v4l_dbg(2, client, "XDS data: %04x\n", xds); 410 v4l_dbg(2, debug, client, "XDS data: %04x\n", xds);
411 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_0, xds & 0xff); 411 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_0, xds & 0xff);
412 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_1, xds >> 8); 412 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_1, xds >> 8);
413 state->xds_data = xds; 413 state->xds_data = xds;
@@ -424,7 +424,7 @@ static int saa7127_set_wss(struct i2c_client *client, struct v4l2_sliced_vbi_dat
424 if (enable && (data->field != 0 || data->line != 23)) 424 if (enable && (data->field != 0 || data->line != 23))
425 return -EINVAL; 425 return -EINVAL;
426 if (state->wss_enable != enable) { 426 if (state->wss_enable != enable) {
427 v4l_dbg(1, client, "Turn WSS %s\n", enable ? "on" : "off"); 427 v4l_dbg(1, debug, client, "Turn WSS %s\n", enable ? "on" : "off");
428 saa7127_write(client, 0x27, enable << 7); 428 saa7127_write(client, 0x27, enable << 7);
429 state->wss_enable = enable; 429 state->wss_enable = enable;
430 } 430 }
@@ -433,7 +433,7 @@ static int saa7127_set_wss(struct i2c_client *client, struct v4l2_sliced_vbi_dat
433 433
434 saa7127_write(client, 0x26, data->data[0]); 434 saa7127_write(client, 0x26, data->data[0]);
435 saa7127_write(client, 0x27, 0x80 | (data->data[1] & 0x3f)); 435 saa7127_write(client, 0x27, 0x80 | (data->data[1] & 0x3f));
436 v4l_dbg(1, client, "WSS mode: %s\n", wss_strs[data->data[0] & 0xf]); 436 v4l_dbg(1, debug, client, "WSS mode: %s\n", wss_strs[data->data[0] & 0xf]);
437 state->wss_mode = (data->data[1] & 0x3f) << 8 | data->data[0]; 437 state->wss_mode = (data->data[1] & 0x3f) << 8 | data->data[0];
438 return 0; 438 return 0;
439} 439}
@@ -445,11 +445,11 @@ static int saa7127_set_video_enable(struct i2c_client *client, int enable)
445 struct saa7127_state *state = i2c_get_clientdata(client); 445 struct saa7127_state *state = i2c_get_clientdata(client);
446 446
447 if (enable) { 447 if (enable) {
448 v4l_dbg(1, client, "Enable Video Output\n"); 448 v4l_dbg(1, debug, client, "Enable Video Output\n");
449 saa7127_write(client, 0x2d, state->reg_2d); 449 saa7127_write(client, 0x2d, state->reg_2d);
450 saa7127_write(client, 0x61, state->reg_61); 450 saa7127_write(client, 0x61, state->reg_61);
451 } else { 451 } else {
452 v4l_dbg(1, client, "Disable Video Output\n"); 452 v4l_dbg(1, debug, client, "Disable Video Output\n");
453 saa7127_write(client, 0x2d, (state->reg_2d & 0xf0)); 453 saa7127_write(client, 0x2d, (state->reg_2d & 0xf0));
454 saa7127_write(client, 0x61, (state->reg_61 | 0xc0)); 454 saa7127_write(client, 0x61, (state->reg_61 | 0xc0));
455 } 455 }
@@ -465,11 +465,11 @@ static int saa7127_set_std(struct i2c_client *client, v4l2_std_id std)
465 const struct i2c_reg_value *inittab; 465 const struct i2c_reg_value *inittab;
466 466
467 if (std & V4L2_STD_525_60) { 467 if (std & V4L2_STD_525_60) {
468 v4l_dbg(1, client, "Selecting 60 Hz video Standard\n"); 468 v4l_dbg(1, debug, client, "Selecting 60 Hz video Standard\n");
469 inittab = saa7127_init_config_60hz; 469 inittab = saa7127_init_config_60hz;
470 state->reg_61 = SAA7127_60HZ_DAC_CONTROL; 470 state->reg_61 = SAA7127_60HZ_DAC_CONTROL;
471 } else { 471 } else {
472 v4l_dbg(1, client, "Selecting 50 Hz video Standard\n"); 472 v4l_dbg(1, debug, client, "Selecting 50 Hz video Standard\n");
473 inittab = saa7127_init_config_50hz; 473 inittab = saa7127_init_config_50hz;
474 state->reg_61 = SAA7127_50HZ_DAC_CONTROL; 474 state->reg_61 = SAA7127_50HZ_DAC_CONTROL;
475 } 475 }
@@ -520,7 +520,7 @@ static int saa7127_set_output_type(struct i2c_client *client, int output)
520 default: 520 default:
521 return -EINVAL; 521 return -EINVAL;
522 } 522 }
523 v4l_dbg(1, client, "Selecting %s output type\n", output_strs[output]); 523 v4l_dbg(1, debug, client, "Selecting %s output type\n", output_strs[output]);
524 524
525 /* Configure Encoder */ 525 /* Configure Encoder */
526 saa7127_write(client, 0x2d, state->reg_2d); 526 saa7127_write(client, 0x2d, state->reg_2d);
@@ -537,12 +537,12 @@ static int saa7127_set_input_type(struct i2c_client *client, int input)
537 537
538 switch (input) { 538 switch (input) {
539 case SAA7127_INPUT_TYPE_NORMAL: /* avia */ 539 case SAA7127_INPUT_TYPE_NORMAL: /* avia */
540 v4l_dbg(1, client, "Selecting Normal Encoder Input\n"); 540 v4l_dbg(1, debug, client, "Selecting Normal Encoder Input\n");
541 state->reg_3a_cb = 0; 541 state->reg_3a_cb = 0;
542 break; 542 break;
543 543
544 case SAA7127_INPUT_TYPE_TEST_IMAGE: /* color bar */ 544 case SAA7127_INPUT_TYPE_TEST_IMAGE: /* color bar */
545 v4l_dbg(1, client, "Selecting Color Bar generator\n"); 545 v4l_dbg(1, debug, client, "Selecting Color Bar generator\n");
546 state->reg_3a_cb = 0x80; 546 state->reg_3a_cb = 0x80;
547 break; 547 break;
548 548
@@ -689,17 +689,16 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
689 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 689 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
690 return 0; 690 return 0;
691 691
692 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 692 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
693 if (client == 0) 693 if (client == 0)
694 return -ENOMEM; 694 return -ENOMEM;
695 695
696 memset(client, 0, sizeof(struct i2c_client));
697 client->addr = address; 696 client->addr = address;
698 client->adapter = adapter; 697 client->adapter = adapter;
699 client->driver = &i2c_driver_saa7127; 698 client->driver = &i2c_driver_saa7127;
700 snprintf(client->name, sizeof(client->name) - 1, "saa7127"); 699 snprintf(client->name, sizeof(client->name) - 1, "saa7127");
701 700
702 v4l_dbg(1, client, "detecting saa7127 client on address 0x%x\n", address << 1); 701 v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n", address << 1);
703 702
704 /* First test register 0: Bits 5-7 are a version ID (should be 0), 703 /* First test register 0: Bits 5-7 are a version ID (should be 0),
705 and bit 2 should also be 0. 704 and bit 2 should also be 0.
@@ -708,11 +707,11 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
708 0x1d after a reset and not expected to ever change. */ 707 0x1d after a reset and not expected to ever change. */
709 if ((saa7127_read(client, 0) & 0xe4) != 0 || 708 if ((saa7127_read(client, 0) & 0xe4) != 0 ||
710 (saa7127_read(client, 0x29) & 0x3f) != 0x1d) { 709 (saa7127_read(client, 0x29) & 0x3f) != 0x1d) {
711 v4l_dbg(1, client, "saa7127 not found\n"); 710 v4l_dbg(1, debug, client, "saa7127 not found\n");
712 kfree(client); 711 kfree(client);
713 return 0; 712 return 0;
714 } 713 }
715 state = kmalloc(sizeof(struct saa7127_state), GFP_KERNEL); 714 state = kzalloc(sizeof(struct saa7127_state), GFP_KERNEL);
716 715
717 if (state == NULL) { 716 if (state == NULL) {
718 kfree(client); 717 kfree(client);
@@ -720,11 +719,10 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
720 } 719 }
721 720
722 i2c_set_clientdata(client, state); 721 i2c_set_clientdata(client, state);
723 memset(state, 0, sizeof(struct saa7127_state));
724 722
725 /* Configure Encoder */ 723 /* Configure Encoder */
726 724
727 v4l_dbg(1, client, "Configuring encoder\n"); 725 v4l_dbg(1, debug, client, "Configuring encoder\n");
728 saa7127_write_inittab(client, saa7127_init_config_common); 726 saa7127_write_inittab(client, saa7127_init_config_common);
729 saa7127_set_std(client, V4L2_STD_NTSC); 727 saa7127_set_std(client, V4L2_STD_NTSC);
730 saa7127_set_output_type(client, SAA7127_OUTPUT_TYPE_BOTH); 728 saa7127_set_output_type(client, SAA7127_OUTPUT_TYPE_BOTH);
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 8a5c3e71b37d..86671a43e769 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -15,7 +15,7 @@ config VIDEO_SAA7134
15config VIDEO_SAA7134_ALSA 15config VIDEO_SAA7134_ALSA
16 tristate "Philips SAA7134 DMA audio support" 16 tristate "Philips SAA7134 DMA audio support"
17 depends on VIDEO_SAA7134 && SND 17 depends on VIDEO_SAA7134 && SND
18 select SND_PCM_OSS 18 select SND_PCM
19 ---help--- 19 ---help---
20 This is a video4linux driver for direct (DMA) audio in 20 This is a video4linux driver for direct (DMA) audio in
21 Philips SAA713x based TV cards using ALSA 21 Philips SAA713x based TV cards using ALSA
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index ad73c4a60f2b..0e0ba50946e8 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -511,9 +511,8 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
511 struct saa6752hs_state *h; 511 struct saa6752hs_state *h;
512 512
513 513
514 if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL))) 514 if (NULL == (h = kzalloc(sizeof(*h), GFP_KERNEL)))
515 return -ENOMEM; 515 return -ENOMEM;
516 memset(h,0,sizeof(*h));
517 h->client = client_template; 516 h->client = client_template;
518 h->params = param_defaults; 517 h->params = param_defaults;
519 h->client.adapter = adap; 518 h->client.adapter = adap;
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 77e5be98e4c6..275d06af69d2 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1666,7 +1666,7 @@ struct saa7134_board saa7134_boards[] = {
1666 .radio_type = UNSET, 1666 .radio_type = UNSET,
1667 .tuner_addr = ADDR_UNSET, 1667 .tuner_addr = ADDR_UNSET,
1668 .radio_addr = ADDR_UNSET, 1668 .radio_addr = ADDR_UNSET,
1669 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER, 1669 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_ACTIVE,
1670 .mpeg = SAA7134_MPEG_DVB, 1670 .mpeg = SAA7134_MPEG_DVB,
1671 .inputs = {{ 1671 .inputs = {{
1672 .name = name_tv, 1672 .name = name_tv,
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index accbc32725cf..3983a6524cac 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -803,10 +803,9 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
803 struct saa7134_mpeg_ops *mops; 803 struct saa7134_mpeg_ops *mops;
804 int err; 804 int err;
805 805
806 dev = kmalloc(sizeof(*dev),GFP_KERNEL); 806 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
807 if (NULL == dev) 807 if (NULL == dev)
808 return -ENOMEM; 808 return -ENOMEM;
809 memset(dev,0,sizeof(*dev));
810 809
811 /* pci init */ 810 /* pci init */
812 dev->pci = pci_dev; 811 dev->pci = pci_dev;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index adfa8fe49a11..e97426bc85df 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1264,10 +1264,9 @@ static int video_open(struct inode *inode, struct file *file)
1264 v4l2_type_names[type]); 1264 v4l2_type_names[type]);
1265 1265
1266 /* allocate + initialize per filehandle data */ 1266 /* allocate + initialize per filehandle data */
1267 fh = kmalloc(sizeof(*fh),GFP_KERNEL); 1267 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
1268 if (NULL == fh) 1268 if (NULL == fh)
1269 return -ENOMEM; 1269 return -ENOMEM;
1270 memset(fh,0,sizeof(*fh));
1271 file->private_data = fh; 1270 file->private_data = fh;
1272 fh->dev = dev; 1271 fh->dev = dev;
1273 fh->radio = radio; 1272 fh->radio = radio;
diff --git a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h
index f305ec802ea6..756963f01bbd 100644
--- a/drivers/media/video/saa7146.h
+++ b/drivers/media/video/saa7146.h
@@ -73,7 +73,6 @@ struct saa7146
73 unsigned int nr; 73 unsigned int nr;
74 unsigned long irq; /* IRQ used by SAA7146 card */ 74 unsigned long irq; /* IRQ used by SAA7146 card */
75 unsigned short id; 75 unsigned short id;
76 struct pci_dev *dev;
77 unsigned char revision; 76 unsigned char revision;
78 unsigned char boardcfg[64]; /* 64 bytes of config from eeprom */ 77 unsigned char boardcfg[64]; /* 64 bytes of config from eeprom */
79 unsigned long saa7146_adr; /* bus address of IO mem from PCI BIOS */ 78 unsigned long saa7146_adr; /* bus address of IO mem from PCI BIOS */
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index f72a9f796209..3ed0edb870a4 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -408,21 +408,19 @@ saa7185_detect_client (struct i2c_adapter *adapter,
408 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 408 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
409 return 0; 409 return 0;
410 410
411 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 411 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
412 if (client == 0) 412 if (client == 0)
413 return -ENOMEM; 413 return -ENOMEM;
414 memset(client, 0, sizeof(struct i2c_client));
415 client->addr = address; 414 client->addr = address;
416 client->adapter = adapter; 415 client->adapter = adapter;
417 client->driver = &i2c_driver_saa7185; 416 client->driver = &i2c_driver_saa7185;
418 strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client))); 417 strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client)));
419 418
420 encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL); 419 encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL);
421 if (encoder == NULL) { 420 if (encoder == NULL) {
422 kfree(client); 421 kfree(client);
423 return -ENOMEM; 422 return -ENOMEM;
424 } 423 }
425 memset(encoder, 0, sizeof(struct saa7185));
426 encoder->norm = VIDEO_MODE_NTSC; 424 encoder->norm = VIDEO_MODE_NTSC;
427 encoder->enable = 1; 425 encoder->enable = 1;
428 i2c_set_clientdata(client, encoder); 426 i2c_set_clientdata(client, encoder);
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c
index 41f6f05a0436..746cadb8f1c4 100644
--- a/drivers/media/video/saa7191.c
+++ b/drivers/media/video/saa7191.c
@@ -571,18 +571,15 @@ static int saa7191_attach(struct i2c_adapter *adap, int addr, int kind)
571 printk(KERN_INFO "Philips SAA7191 driver version %s\n", 571 printk(KERN_INFO "Philips SAA7191 driver version %s\n",
572 SAA7191_MODULE_VERSION); 572 SAA7191_MODULE_VERSION);
573 573
574 client = kmalloc(sizeof(*client), GFP_KERNEL); 574 client = kzalloc(sizeof(*client), GFP_KERNEL);
575 if (!client) 575 if (!client)
576 return -ENOMEM; 576 return -ENOMEM;
577 decoder = kmalloc(sizeof(*decoder), GFP_KERNEL); 577 decoder = kzalloc(sizeof(*decoder), GFP_KERNEL);
578 if (!decoder) { 578 if (!decoder) {
579 err = -ENOMEM; 579 err = -ENOMEM;
580 goto out_free_client; 580 goto out_free_client;
581 } 581 }
582 582
583 memset(client, 0, sizeof(struct i2c_client));
584 memset(decoder, 0, sizeof(struct saa7191));
585
586 client->addr = addr; 583 client->addr = addr;
587 client->adapter = adap; 584 client->adapter = adap;
588 client->driver = &i2c_driver_saa7191; 585 client->driver = &i2c_driver_saa7191;
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 6ee54a45411f..54fc33011ffb 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -49,9 +49,9 @@
49#include "saa7121.h" 49#include "saa7121.h"
50#include "cs8420.h" 50#include "cs8420.h"
51 51
52#define DEBUG(x) /* debug driver */ 52#define DEBUG(x) /* debug driver */
53#undef IDEBUG /* debug irq handler */ 53#undef IDEBUG /* debug irq handler */
54#undef MDEBUG /* debug memory management */ 54#undef MDEBUG /* debug memory management */
55 55
56#define SAA7146_MAX 6 56#define SAA7146_MAX 6
57 57
@@ -63,7 +63,6 @@ static int video_nr = -1;
63module_param(video_nr, int, 0); 63module_param(video_nr, int, 0);
64MODULE_LICENSE("GPL"); 64MODULE_LICENSE("GPL");
65 65
66
67#define nDebNormal 0x00480000 66#define nDebNormal 0x00480000
68#define nDebNoInc 0x00480000 67#define nDebNoInc 0x00480000
69#define nDebVideo 0xd0480000 68#define nDebVideo 0xd0480000
@@ -99,7 +98,12 @@ MODULE_LICENSE("GPL");
99 98
100#ifdef USE_RESCUE_EEPROM_SDM275 99#ifdef USE_RESCUE_EEPROM_SDM275
101static unsigned char rescue_eeprom[64] = { 100static unsigned char rescue_eeprom[64] = {
1020x00,0x01,0x04,0x13,0x26,0x0f,0x10,0x00,0x00,0x00,0x43,0x63,0x22,0x01,0x29,0x15,0x73,0x00,0x1f, 'd', 'e', 'c', 'x', 'l', 'd', 'v', 'a',0x02,0x00,0x01,0x00,0xcc,0xa4,0x63,0x09,0xe2,0x10,0x00,0x0a,0x00,0x02,0x02, 'd', 'e', 'c', 'x', 'l', 'a',0x00,0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 101 0x00, 0x01, 0x04, 0x13, 0x26, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x43, 0x63,
102 0x22, 0x01, 0x29, 0x15, 0x73, 0x00, 0x1f, 'd', 'e', 'c', 'x', 'l',
103 'd', 'v', 'a', 0x02, 0x00, 0x01, 0x00, 0xcc, 0xa4, 0x63, 0x09, 0xe2,
104 0x10, 0x00, 0x0a, 0x00, 0x02, 0x02, 'd', 'e', 'c', 'x', 'l', 'a',
105 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00,
103}; 107};
104#endif 108#endif
105 109
@@ -140,17 +144,18 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr,
140 144
141 if (saaread(SAA7146_I2C_STATUS) & 0x3c) 145 if (saaread(SAA7146_I2C_STATUS) & 0x3c)
142 I2CWipe(saa); 146 I2CWipe(saa);
143 for (i = 0; i < 1000 && 147 for (i = 0;
144 (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY); i++) 148 i < 1000 && (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY);
149 i++)
145 schedule(); 150 schedule();
146 if (i == 1000) 151 if (i == 1000)
147 I2CWipe(saa); 152 I2CWipe(saa);
148 if (dosub) 153 if (dosub)
149 saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 8) | 154 saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 8) |
150 ((subaddr & 0xff) << 16) | 0xed, SAA7146_I2C_TRANSFER); 155 ((subaddr & 0xff) << 16) | 0xed, SAA7146_I2C_TRANSFER);
151 else 156 else
152 saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 16) | 157 saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 16) |
153 0xf1, SAA7146_I2C_TRANSFER); 158 0xf1, SAA7146_I2C_TRANSFER);
154 saawrite((SAA7146_MC2_UPLD_I2C << 16) | 159 saawrite((SAA7146_MC2_UPLD_I2C << 16) |
155 SAA7146_MC2_UPLD_I2C, SAA7146_MC2); 160 SAA7146_MC2_UPLD_I2C, SAA7146_MC2);
156 /* wait for i2c registers to be programmed */ 161 /* wait for i2c registers to be programmed */
@@ -163,7 +168,7 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr,
163 schedule(); 168 schedule();
164 if (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_ERR) 169 if (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_ERR)
165 return -1; 170 return -1;
166 if (i == 1000) 171 if (i == 1000)
167 printk("i2c setup read timeout\n"); 172 printk("i2c setup read timeout\n");
168 saawrite(0x41, SAA7146_I2C_TRANSFER); 173 saawrite(0x41, SAA7146_I2C_TRANSFER);
169 saawrite((SAA7146_MC2_UPLD_I2C << 16) | 174 saawrite((SAA7146_MC2_UPLD_I2C << 16) |
@@ -178,7 +183,7 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr,
178 schedule(); 183 schedule();
179 if (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_ERR) 184 if (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_ERR)
180 return -1; 185 return -1;
181 if (i == 1000) 186 if (i == 1000)
182 printk("i2c read timeout\n"); 187 printk("i2c read timeout\n");
183 return ((saaread(SAA7146_I2C_TRANSFER) >> 24) & 0xff); 188 return ((saaread(SAA7146_I2C_TRANSFER) >> 24) & 0xff);
184} 189}
@@ -213,20 +218,22 @@ static void attach_inform(struct saa7146 *saa, int id)
213{ 218{
214 int i; 219 int i;
215 220
216 DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr, id)); 221 DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr,
217 if (id == 0xa0) { /* we have rev2 or later board, fill in info */ 222 id));
223 if (id == 0xa0) { /* we have rev2 or later board, fill in info */
218 for (i = 0; i < 64; i++) 224 for (i = 0; i < 64; i++)
219 saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1); 225 saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1);
220#ifdef USE_RESCUE_EEPROM_SDM275 226#ifdef USE_RESCUE_EEPROM_SDM275
221 if (saa->boardcfg[0] != 0) { 227 if (saa->boardcfg[0] != 0) {
222 printk("stradis%d: WARNING: EEPROM STORED VALUES HAVE BEEN IGNORED\n", saa->nr); 228 printk("stradis%d: WARNING: EEPROM STORED VALUES HAVE "
229 "BEEN IGNORED\n", saa->nr);
223 for (i = 0; i < 64; i++) 230 for (i = 0; i < 64; i++)
224 saa->boardcfg[i] = rescue_eeprom[i]; 231 saa->boardcfg[i] = rescue_eeprom[i];
225 } 232 }
226#endif 233#endif
227 printk("stradis%d: config =", saa->nr); 234 printk("stradis%d: config =", saa->nr);
228 for (i = 0; i < 51; i++) { 235 for (i = 0; i < 51; i++) {
229 printk(" %02x",saa->boardcfg[i]); 236 printk(" %02x", saa->boardcfg[i]);
230 } 237 }
231 printk("\n"); 238 printk("\n");
232 } 239 }
@@ -254,17 +261,19 @@ static int wait_for_debi_done(struct saa7146 *saa)
254 for (i = 0; i < 500000 && 261 for (i = 0; i < 500000 &&
255 (saaread(SAA7146_PSR) & SAA7146_PSR_DEBI_S); i++) 262 (saaread(SAA7146_PSR) & SAA7146_PSR_DEBI_S); i++)
256 saaread(SAA7146_MC2); 263 saaread(SAA7146_MC2);
264
257 if (i > debiwait_maxwait) 265 if (i > debiwait_maxwait)
258 printk("wait-for-debi-done maxwait: %d\n", 266 printk("wait-for-debi-done maxwait: %d\n",
259 debiwait_maxwait = i); 267 debiwait_maxwait = i);
260 268
261 if (i == 500000) 269 if (i == 500000)
262 return -1; 270 return -1;
271
263 return 0; 272 return 0;
264} 273}
265 274
266static int debiwrite(struct saa7146 *saa, u32 config, int addr, 275static int debiwrite(struct saa7146 *saa, u32 config, int addr,
267 u32 val, int count) 276 u32 val, int count)
268{ 277{
269 u32 cmd; 278 u32 cmd;
270 if (count <= 0 || count > 32764) 279 if (count <= 0 || count > 32764)
@@ -309,41 +318,6 @@ static u32 debiread(struct saa7146 *saa, u32 config, int addr, int count)
309 return result; 318 return result;
310} 319}
311 320
312#if 0 /* unused */
313/* MUST be a multiple of 8 bytes and 8-byte aligned and < 32768 bytes */
314/* data copied into saa->dmadebi buffer, caller must re-enable interrupts */
315static void ibm_block_dram_read(struct saa7146 *saa, int address, int bytes)
316{
317 int i, j;
318 u32 *buf;
319 buf = (u32 *) saa->dmadebi;
320 if (bytes > 0x7000)
321 bytes = 0x7000;
322 saawrite(0, SAA7146_IER); /* disable interrupts */
323 for (i=0; i < 10000 &&
324 (debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
325 & 0x8000); i++)
326 saaread(SAA7146_MC2);
327 if (i == 10000)
328 printk(KERN_ERR "stradis%d: dram_busy never cleared\n",
329 saa->nr);
330 debiwrite(saa, debNormal, IBM_MP2_SRC_ADDR, (address<<16) |
331 (address>>16), 4);
332 debiwrite(saa, debNormal, IBM_MP2_BLOCK_SIZE, bytes, 2);
333 debiwrite(saa, debNormal, IBM_MP2_CMD_STAT, 0x8a10, 2);
334 for (j = 0; j < bytes/4; j++) {
335 for (i = 0; i < 10000 &&
336 (!(debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
337 & 0x4000)); i++)
338 saaread(SAA7146_MC2);
339 if (i == 10000)
340 printk(KERN_ERR "stradis%d: dram_ready never set\n",
341 saa->nr);
342 buf[j] = debiread(saa, debNormal, IBM_MP2_DRAM_DATA, 4);
343 }
344}
345#endif /* unused */
346
347static void do_irq_send_data(struct saa7146 *saa) 321static void do_irq_send_data(struct saa7146 *saa)
348{ 322{
349 int split, audbytes, vidbytes; 323 int split, audbytes, vidbytes;
@@ -365,16 +339,15 @@ static void do_irq_send_data(struct saa7146 *saa)
365 return; 339 return;
366 } 340 }
367 /* if at least 1 block audio waiting and audio fifo isn't full */ 341 /* if at least 1 block audio waiting and audio fifo isn't full */
368 if (audbytes >= 2048 && (debiread(saa, debNormal, 342 if (audbytes >= 2048 && (debiread(saa, debNormal, IBM_MP2_AUD_FIFO, 2)
369 IBM_MP2_AUD_FIFO, 2) & 0xff) < 60) { 343 & 0xff) < 60) {
370 if (saa->audhead > saa->audtail) 344 if (saa->audhead > saa->audtail)
371 split = 65536 - saa->audhead; 345 split = 65536 - saa->audhead;
372 else 346 else
373 split = 0; 347 split = 0;
374 audbytes = 2048; 348 audbytes = 2048;
375 if (split > 0 && split < 2048) { 349 if (split > 0 && split < 2048) {
376 memcpy(saa->dmadebi, saa->audbuf + saa->audhead, 350 memcpy(saa->dmadebi, saa->audbuf + saa->audhead, split);
377 split);
378 saa->audhead = 0; 351 saa->audhead = 0;
379 audbytes -= split; 352 audbytes -= split;
380 } else 353 } else
@@ -383,20 +356,19 @@ static void do_irq_send_data(struct saa7146 *saa)
383 audbytes); 356 audbytes);
384 saa->audhead += audbytes; 357 saa->audhead += audbytes;
385 saa->audhead &= 0xffff; 358 saa->audhead &= 0xffff;
386 debiwrite(saa, debAudio, (NewCard? IBM_MP2_AUD_FIFO : 359 debiwrite(saa, debAudio, (NewCard ? IBM_MP2_AUD_FIFO :
387 IBM_MP2_AUD_FIFOW), 0, 2048); 360 IBM_MP2_AUD_FIFOW), 0, 2048);
388 wake_up_interruptible(&saa->audq); 361 wake_up_interruptible(&saa->audq);
389 /* if at least 1 block video waiting and video fifo isn't full */ 362 /* if at least 1 block video waiting and video fifo isn't full */
390 } else if (vidbytes >= 30720 && (debiread(saa, debNormal, 363 } else if (vidbytes >= 30720 && (debiread(saa, debNormal,
391 IBM_MP2_FIFO, 2)) < 16384) { 364 IBM_MP2_FIFO, 2)) < 16384) {
392 if (saa->vidhead > saa->vidtail) 365 if (saa->vidhead > saa->vidtail)
393 split = 524288 - saa->vidhead; 366 split = 524288 - saa->vidhead;
394 else 367 else
395 split = 0; 368 split = 0;
396 vidbytes = 30720; 369 vidbytes = 30720;
397 if (split > 0 && split < 30720) { 370 if (split > 0 && split < 30720) {
398 memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, 371 memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, split);
399 split);
400 saa->vidhead = 0; 372 saa->vidhead = 0;
401 vidbytes -= split; 373 vidbytes -= split;
402 } else 374 } else
@@ -406,7 +378,7 @@ static void do_irq_send_data(struct saa7146 *saa)
406 saa->vidhead += vidbytes; 378 saa->vidhead += vidbytes;
407 saa->vidhead &= 0x7ffff; 379 saa->vidhead &= 0x7ffff;
408 debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO : 380 debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO :
409 IBM_MP2_FIFOW), 0, 30720); 381 IBM_MP2_FIFOW), 0, 30720);
410 wake_up_interruptible(&saa->vidq); 382 wake_up_interruptible(&saa->vidq);
411 } 383 }
412 saawrite(SAA7146_PSR_DEBI_S | SAA7146_PSR_PIN1, SAA7146_IER); 384 saawrite(SAA7146_PSR_DEBI_S | SAA7146_PSR_PIN1, SAA7146_IER);
@@ -418,10 +390,10 @@ static void send_osd_data(struct saa7146 *saa)
418 if (size > 30720) 390 if (size > 30720)
419 size = 30720; 391 size = 30720;
420 /* ensure some multiple of 8 bytes is transferred */ 392 /* ensure some multiple of 8 bytes is transferred */
421 size = 8 * ((size + 8)>>3); 393 size = 8 * ((size + 8) >> 3);
422 if (size) { 394 if (size) {
423 debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR, 395 debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR,
424 (saa->osdhead>>3), 2); 396 (saa->osdhead >> 3), 2);
425 memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size); 397 memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size);
426 saa->osdhead += size; 398 saa->osdhead += size;
427 /* block transfer of next 8 bytes to ~32k bytes */ 399 /* block transfer of next 8 bytes to ~32k bytes */
@@ -435,7 +407,7 @@ static void send_osd_data(struct saa7146 *saa)
435 407
436static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs) 408static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
437{ 409{
438 struct saa7146 *saa = (struct saa7146 *) dev_id; 410 struct saa7146 *saa = dev_id;
439 u32 stat, astat; 411 u32 stat, astat;
440 int count; 412 int count;
441 int handled = 0; 413 int handled = 0;
@@ -484,7 +456,7 @@ static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
484 saa->vidinfo.v_size = 480; 456 saa->vidinfo.v_size = 480;
485#if 0 457#if 0
486 if (saa->endmarkhead != saa->endmarktail) { 458 if (saa->endmarkhead != saa->endmarktail) {
487 saa->audhead = 459 saa->audhead =
488 saa->endmark[saa->endmarkhead]; 460 saa->endmark[saa->endmarkhead];
489 saa->endmarkhead++; 461 saa->endmarkhead++;
490 if (saa->endmarkhead >= MAX_MARKS) 462 if (saa->endmarkhead >= MAX_MARKS)
@@ -494,7 +466,7 @@ static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs)
494 } 466 }
495 if (istat & 0x4000) { /* Sequence Error Code */ 467 if (istat & 0x4000) { /* Sequence Error Code */
496 if (saa->endmarkhead != saa->endmarktail) { 468 if (saa->endmarkhead != saa->endmarktail) {
497 saa->audhead = 469 saa->audhead =
498 saa->endmark[saa->endmarkhead]; 470 saa->endmark[saa->endmarkhead];
499 saa->endmarkhead++; 471 saa->endmarkhead++;
500 if (saa->endmarkhead >= MAX_MARKS) 472 if (saa->endmarkhead >= MAX_MARKS)
@@ -613,7 +585,7 @@ static int ibm_send_command(struct saa7146 *saa,
613 int i; 585 int i;
614 586
615 if (chain) 587 if (chain)
616 debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1) | 1, 2); 588 debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1)| 1,2);
617 else 589 else
618 debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2); 590 debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2);
619 debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2); 591 debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2);
@@ -663,11 +635,9 @@ static void initialize_cs8420(struct saa7146 *saa, int pro)
663 else 635 else
664 sequence = mode8420con; 636 sequence = mode8420con;
665 for (i = 0; i < INIT8420LEN; i++) 637 for (i = 0; i < INIT8420LEN; i++)
666 I2CWrite(saa, 0x20, init8420[i * 2], 638 I2CWrite(saa, 0x20, init8420[i * 2], init8420[i * 2 + 1], 2);
667 init8420[i * 2 + 1], 2);
668 for (i = 0; i < MODE8420LEN; i++) 639 for (i = 0; i < MODE8420LEN; i++)
669 I2CWrite(saa, 0x20, sequence[i * 2], 640 I2CWrite(saa, 0x20, sequence[i * 2], sequence[i * 2 + 1], 2);
670 sequence[i * 2 + 1], 2);
671 printk("stradis%d: CS8420 initialized\n", saa->nr); 641 printk("stradis%d: CS8420 initialized\n", saa->nr);
672} 642}
673 643
@@ -683,35 +653,36 @@ static void initialize_saa7121(struct saa7146 *saa, int dopal)
683 /* initialize PAL/NTSC video encoder */ 653 /* initialize PAL/NTSC video encoder */
684 for (i = 0; i < INIT7121LEN; i++) { 654 for (i = 0; i < INIT7121LEN; i++) {
685 if (NewCard) { /* handle new card encoder differences */ 655 if (NewCard) { /* handle new card encoder differences */
686 if (sequence[i*2] == 0x3a) 656 if (sequence[i * 2] == 0x3a)
687 I2CWrite(saa, 0x88, 0x3a, 0x13, 2); 657 I2CWrite(saa, 0x88, 0x3a, 0x13, 2);
688 else if (sequence[i*2] == 0x6b) 658 else if (sequence[i * 2] == 0x6b)
689 I2CWrite(saa, 0x88, 0x6b, 0x20, 2); 659 I2CWrite(saa, 0x88, 0x6b, 0x20, 2);
690 else if (sequence[i*2] == 0x6c) 660 else if (sequence[i * 2] == 0x6c)
691 I2CWrite(saa, 0x88, 0x6c, 661 I2CWrite(saa, 0x88, 0x6c,
692 dopal ? 0x09 : 0xf5, 2); 662 dopal ? 0x09 : 0xf5, 2);
693 else if (sequence[i*2] == 0x6d) 663 else if (sequence[i * 2] == 0x6d)
694 I2CWrite(saa, 0x88, 0x6d, 664 I2CWrite(saa, 0x88, 0x6d,
695 dopal ? 0x20 : 0x00, 2); 665 dopal ? 0x20 : 0x00, 2);
696 else if (sequence[i*2] == 0x7a) 666 else if (sequence[i * 2] == 0x7a)
697 I2CWrite(saa, 0x88, 0x7a, 667 I2CWrite(saa, 0x88, 0x7a,
698 dopal ? (PALFirstActive - 1) : 668 dopal ? (PALFirstActive - 1) :
699 (NTSCFirstActive - 4), 2); 669 (NTSCFirstActive - 4), 2);
700 else if (sequence[i*2] == 0x7b) 670 else if (sequence[i * 2] == 0x7b)
701 I2CWrite(saa, 0x88, 0x7b, 671 I2CWrite(saa, 0x88, 0x7b,
702 dopal ? PALLastActive : 672 dopal ? PALLastActive :
703 NTSCLastActive, 2); 673 NTSCLastActive, 2);
704 else I2CWrite(saa, 0x88, sequence[i * 2], 674 else
705 sequence[i * 2 + 1], 2); 675 I2CWrite(saa, 0x88, sequence[i * 2],
676 sequence[i * 2 + 1], 2);
706 } else { 677 } else {
707 if (sequence[i*2] == 0x6b && mod) 678 if (sequence[i * 2] == 0x6b && mod)
708 I2CWrite(saa, 0x88, 0x6b, 679 I2CWrite(saa, 0x88, 0x6b,
709 (sequence[i * 2 + 1] ^ 0x09), 2); 680 (sequence[i * 2 + 1] ^ 0x09), 2);
710 else if (sequence[i*2] == 0x7a) 681 else if (sequence[i * 2] == 0x7a)
711 I2CWrite(saa, 0x88, 0x7a, 682 I2CWrite(saa, 0x88, 0x7a,
712 dopal ? (PALFirstActive - 1) : 683 dopal ? (PALFirstActive - 1) :
713 (NTSCFirstActive - 4), 2); 684 (NTSCFirstActive - 4), 2);
714 else if (sequence[i*2] == 0x7b) 685 else if (sequence[i * 2] == 0x7b)
715 I2CWrite(saa, 0x88, 0x7b, 686 I2CWrite(saa, 0x88, 0x7b,
716 dopal ? PALLastActive : 687 dopal ? PALLastActive :
717 NTSCLastActive, 2); 688 NTSCLastActive, 2);
@@ -735,7 +706,8 @@ static void set_genlock_offset(struct saa7146 *saa, int noffset)
735 nCode = noffset + 0x100; 706 nCode = noffset + 0x100;
736 if (nCode == 1) 707 if (nCode == 1)
737 nCode = 0x401; 708 nCode = 0x401;
738 else if (nCode < 1) nCode = 0x400 + PixelsPerLine + nCode; 709 else if (nCode < 1)
710 nCode = 0x400 + PixelsPerLine + nCode;
739 debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2); 711 debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2);
740} 712}
741 713
@@ -745,33 +717,31 @@ static void set_out_format(struct saa7146 *saa, int mode)
745 saa->boardcfg[2] = mode; 717 saa->boardcfg[2] = mode;
746 /* do not adjust analog video parameters here, use saa7121 init */ 718 /* do not adjust analog video parameters here, use saa7121 init */
747 /* you will affect the SDI output on the new card */ 719 /* you will affect the SDI output on the new card */
748 if (mode == VIDEO_MODE_PAL) { /* PAL */ 720 if (mode == VIDEO_MODE_PAL) { /* PAL */
749 debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2); 721 debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2);
750 mdelay(50); 722 mdelay(50);
751 saawrite(0x012002c0, SAA7146_NUM_LINE_BYTE1); 723 saawrite(0x012002c0, SAA7146_NUM_LINE_BYTE1);
752 if (NewCard) { 724 if (NewCard) {
753 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 725 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 0xe100, 2);
754 0xe100, 2);
755 mdelay(50); 726 mdelay(50);
756 } 727 }
757 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 728 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
758 NewCard ? 0xe500: 0x6500, 2); 729 NewCard ? 0xe500 : 0x6500, 2);
759 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, 730 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
760 (1 << 8) | 731 (1 << 8) |
761 (NewCard ? PALFirstActive : PALFirstActive-6), 2); 732 (NewCard ? PALFirstActive : PALFirstActive - 6), 2);
762 } else { /* NTSC */ 733 } else { /* NTSC */
763 debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2); 734 debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2);
764 mdelay(50); 735 mdelay(50);
765 saawrite(0x00f002c0, SAA7146_NUM_LINE_BYTE1); 736 saawrite(0x00f002c0, SAA7146_NUM_LINE_BYTE1);
766 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 737 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
767 NewCard ? 0xe100: 0x6100, 2); 738 NewCard ? 0xe100 : 0x6100, 2);
768 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, 739 debiwrite(saa, debNormal, IBM_MP2_DISP_DLY,
769 (1 << 8) | 740 (1 << 8) |
770 (NewCard ? NTSCFirstActive : NTSCFirstActive-6), 2); 741 (NewCard ? NTSCFirstActive : NTSCFirstActive - 6), 2);
771 } 742 }
772} 743}
773 744
774
775/* Intialize bitmangler to map from a byte value to the mangled word that 745/* Intialize bitmangler to map from a byte value to the mangled word that
776 * must be output to program the Xilinx part through the DEBI port. 746 * must be output to program the Xilinx part through the DEBI port.
777 * Xilinx Data Bit->DEBI Bit: 0->15 1->7 2->6 3->12 4->11 5->2 6->1 7->0 747 * Xilinx Data Bit->DEBI Bit: 0->15 1->7 2->6 3->12 4->11 5->2 6->1 7->0
@@ -799,43 +769,41 @@ static int initialize_fpga(struct video_code *bitdata)
799 for (num = 0; num < saa_num; num++) { 769 for (num = 0; num < saa_num; num++) {
800 saa = &saa7146s[num]; 770 saa = &saa7146s[num];
801 if (saa->boardcfg[0] > 20) 771 if (saa->boardcfg[0] > 20)
802 continue; /* card was programmed */ 772 continue; /* card was programmed */
803 loadtwo = (saa->boardcfg[18] & 0x10); 773 loadtwo = (saa->boardcfg[18] & 0x10);
804 if (!NewCard) /* we have an old board */ 774 if (!NewCard) /* we have an old board */
805 for (i = 0; i < 256; i++) 775 for (i = 0; i < 256; i++)
806 bitmangler[i] = ((i & 0x01) << 15) | 776 bitmangler[i] = ((i & 0x01) << 15) |
807 ((i & 0x02) << 6) | ((i & 0x04) << 4) | 777 ((i & 0x02) << 6) | ((i & 0x04) << 4) |
808 ((i & 0x08) << 9) | ((i & 0x10) << 7) | 778 ((i & 0x08) << 9) | ((i & 0x10) << 7) |
809 ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | 779 ((i & 0x20) >> 3) | ((i & 0x40) >> 5) |
810 ((i & 0x80) >> 7); 780 ((i & 0x80) >> 7);
811 else /* else we have a new board */ 781 else /* else we have a new board */
812 for (i = 0; i < 256; i++) 782 for (i = 0; i < 256; i++)
813 bitmangler[i] = ((i & 0x01) << 7) | 783 bitmangler[i] = ((i & 0x01) << 7) |
814 ((i & 0x02) << 5) | ((i & 0x04) << 3) | 784 ((i & 0x02) << 5) | ((i & 0x04) << 3) |
815 ((i & 0x08) << 1) | ((i & 0x10) >> 1) | 785 ((i & 0x08) << 1) | ((i & 0x10) >> 1) |
816 ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | 786 ((i & 0x20) >> 3) | ((i & 0x40) >> 5) |
817 ((i & 0x80) >> 7); 787 ((i & 0x80) >> 7);
818 788
819 dmabuf = (u16 *) saa->dmadebi; 789 dmabuf = (u16 *) saa->dmadebi;
820 newdma = (u8 *) saa->dmadebi; 790 newdma = (u8 *) saa->dmadebi;
821 if (NewCard) { /* SDM2xxx */ 791 if (NewCard) { /* SDM2xxx */
822 if (!strncmp(bitdata->loadwhat, "decoder2", 8)) 792 if (!strncmp(bitdata->loadwhat, "decoder2", 8))
823 continue; /* fpga not for this card */ 793 continue; /* fpga not for this card */
824 if (!strncmp(&saa->boardcfg[42], 794 if (!strncmp(&saa->boardcfg[42], bitdata->loadwhat, 8))
825 bitdata->loadwhat, 8)) {
826 loadfile = 1; 795 loadfile = 1;
827 } else if (loadtwo && !strncmp(&saa->boardcfg[19], 796 else if (loadtwo && !strncmp(&saa->boardcfg[19],
828 bitdata->loadwhat, 8)) { 797 bitdata->loadwhat, 8))
829 loadfile = 2; 798 loadfile = 2;
830 } else if (!saa->boardcfg[42] && /* special */ 799 else if (!saa->boardcfg[42] && !strncmp("decxl",
831 !strncmp("decxl", bitdata->loadwhat, 8)) { 800 bitdata->loadwhat, 8))
832 loadfile = 1; 801 loadfile = 1; /* special */
833 } else 802 else
834 continue; /* fpga not for this card */ 803 continue; /* fpga not for this card */
835 if (loadfile != 1 && loadfile != 2) { 804 if (loadfile != 1 && loadfile != 2)
836 continue; /* skip to next card */ 805 continue; /* skip to next card */
837 } 806 if (saa->boardcfg[0] && loadfile == 1)
838 if (saa->boardcfg[0] && loadfile == 1 )
839 continue; /* skip to next card */ 807 continue; /* skip to next card */
840 if (saa->boardcfg[0] != 1 && loadfile == 2) 808 if (saa->boardcfg[0] != 1 && loadfile == 2)
841 continue; /* skip to next card */ 809 continue; /* skip to next card */
@@ -870,8 +838,9 @@ static int initialize_fpga(struct video_code *bitdata)
870 /* Release Xilinx INIT signal (WS2) */ 838 /* Release Xilinx INIT signal (WS2) */
871 saawrite(0x00000000, SAA7146_GPIO_CTRL); 839 saawrite(0x00000000, SAA7146_GPIO_CTRL);
872 /* Wait for the INIT to go High */ 840 /* Wait for the INIT to go High */
873 for (i = 0; i < 10000 && 841 for (i = 0;
874 !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); i++) 842 i < 10000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2);
843 i++)
875 schedule(); 844 schedule();
876 if (i == 1000) { 845 if (i == 1000) {
877 printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr); 846 printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr);
@@ -881,17 +850,13 @@ send_fpga_stuff:
881 if (NewCard) { 850 if (NewCard) {
882 for (i = startindex; i < bitdata->datasize; i++) 851 for (i = startindex; i < bitdata->datasize; i++)
883 newdma[i - startindex] = 852 newdma[i - startindex] =
884 bitmangler[bitdata->data[i]]; 853 bitmangler[bitdata->data[i]];
885 debiwrite(saa, 0x01420000, 0, 0, 854 debiwrite(saa, 0x01420000, 0, 0,
886 ((bitdata->datasize - startindex) + 5)); 855 ((bitdata->datasize - startindex) + 5));
887 if (loadtwo) { 856 if (loadtwo && loadfile == 1) {
888 if (loadfile == 1) { 857 printk("stradis%d: awaiting 2nd FPGA bitfile\n",
889 printk("stradis%d: " 858 saa->nr);
890 "awaiting 2nd FPGA bitfile\n", 859 continue; /* skip to next card */
891 saa->nr);
892 continue; /* skip to next card */
893 }
894
895 } 860 }
896 } else { 861 } else {
897 for (i = startindex; i < bitdata->datasize; i++) 862 for (i = startindex; i < bitdata->datasize; i++)
@@ -900,8 +865,9 @@ send_fpga_stuff:
900 debiwrite(saa, 0x014a0000, 0, 0, 865 debiwrite(saa, 0x014a0000, 0, 0,
901 ((bitdata->datasize - startindex) + 5) * 2); 866 ((bitdata->datasize - startindex) + 5) * 2);
902 } 867 }
903 for (i = 0; i < 1000 && 868 for (i = 0;
904 !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); i++) 869 i < 1000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2);
870 i++)
905 schedule(); 871 schedule();
906 if (i == 1000) { 872 if (i == 1000) {
907 printk(KERN_INFO "stradis%d: FPGA load failed\n", 873 printk(KERN_INFO "stradis%d: FPGA load failed\n",
@@ -925,14 +891,14 @@ send_fpga_stuff:
925 /* mute CS3310 */ 891 /* mute CS3310 */
926 if (HaveCS3310) 892 if (HaveCS3310)
927 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, 893 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
928 0, 2); 894 0, 2);
929 /* set VXCO to PWM mode, release reset, blank on */ 895 /* set VXCO to PWM mode, release reset, blank on */
930 debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2); 896 debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2);
931 mdelay(10); 897 mdelay(10);
932 /* unmute CS3310 */ 898 /* unmute CS3310 */
933 if (HaveCS3310) 899 if (HaveCS3310)
934 debiwrite(saa, debNormal, XILINX_CTL0, 900 debiwrite(saa, debNormal, XILINX_CTL0,
935 0x2020, 2); 901 0x2020, 2);
936 } 902 }
937 /* set source Black */ 903 /* set source Black */
938 debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2); 904 debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2);
@@ -958,10 +924,10 @@ send_fpga_stuff:
958 /* we must init CS8420 first since rev b pulls i2s */ 924 /* we must init CS8420 first since rev b pulls i2s */
959 /* master clock low and CS4341 needs i2s master to */ 925 /* master clock low and CS4341 needs i2s master to */
960 /* run the i2c port. */ 926 /* run the i2c port. */
961 if (HaveCS8420) { 927 if (HaveCS8420)
962 /* 0=consumer, 1=pro */ 928 /* 0=consumer, 1=pro */
963 initialize_cs8420(saa, 0); 929 initialize_cs8420(saa, 0);
964 } 930
965 mdelay(5); 931 mdelay(5);
966 if (HaveCS4341) 932 if (HaveCS4341)
967 initialize_cs4341(saa); 933 initialize_cs4341(saa);
@@ -981,6 +947,7 @@ send_fpga_stuff:
981 debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2); 947 debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2);
982#endif 948#endif
983 } 949 }
950
984 return failure; 951 return failure;
985} 952}
986 953
@@ -1021,10 +988,10 @@ static int do_ibm_reset(struct saa7146 *saa)
1021 /* we must init CS8420 first since rev b pulls i2s */ 988 /* we must init CS8420 first since rev b pulls i2s */
1022 /* master clock low and CS4341 needs i2s master to */ 989 /* master clock low and CS4341 needs i2s master to */
1023 /* run the i2c port. */ 990 /* run the i2c port. */
1024 if (HaveCS8420) { 991 if (HaveCS8420)
1025 /* 0=consumer, 1=pro */ 992 /* 0=consumer, 1=pro */
1026 initialize_cs8420(saa, 1); 993 initialize_cs8420(saa, 1);
1027 } 994
1028 mdelay(5); 995 mdelay(5);
1029 if (HaveCS4341) 996 if (HaveCS4341)
1030 initialize_cs4341(saa); 997 initialize_cs4341(saa);
@@ -1039,12 +1006,12 @@ static int do_ibm_reset(struct saa7146 *saa)
1039 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); 1006 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
1040 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); 1007 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
1041 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, 1008 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
1042 (ChipControl == 0x43 ? 0xe800 : 0xe000), 1)) { 1009 (ChipControl == 0x43 ? 0xe800 : 0xe000), 1)) {
1043 printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr); 1010 printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr);
1044 } 1011 }
1045 if (HaveCS3310) { 1012 if (HaveCS3310) {
1046 int i = CS3310MaxLvl; 1013 int i = CS3310MaxLvl;
1047 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i<<8)|i), 2); 1014 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i << 8)| i),2);
1048 } 1015 }
1049 /* start video decoder */ 1016 /* start video decoder */
1050 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2); 1017 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2);
@@ -1057,6 +1024,7 @@ static int do_ibm_reset(struct saa7146 *saa)
1057 /* clear pending interrupts */ 1024 /* clear pending interrupts */
1058 debiread(saa, debNormal, IBM_MP2_HOST_INT, 2); 1025 debiread(saa, debNormal, IBM_MP2_HOST_INT, 2);
1059 debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2); 1026 debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2);
1027
1060 return 0; 1028 return 0;
1061} 1029}
1062 1030
@@ -1070,8 +1038,8 @@ static int initialize_ibmmpeg2(struct video_code *microcode)
1070 saa = &saa7146s[num]; 1038 saa = &saa7146s[num];
1071 /* check that FPGA is loaded */ 1039 /* check that FPGA is loaded */
1072 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2); 1040 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2);
1073 if ((i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2)) != 1041 i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2);
1074 0xa55a) { 1042 if (i != 0xa55a) {
1075 printk(KERN_INFO "stradis%d: %04x != 0xa55a\n", 1043 printk(KERN_INFO "stradis%d: %04x != 0xa55a\n",
1076 saa->nr, i); 1044 saa->nr, i);
1077#if 0 1045#if 0
@@ -1082,17 +1050,17 @@ static int initialize_ibmmpeg2(struct video_code *microcode)
1082 if (saa->boardcfg[0] > 27) 1050 if (saa->boardcfg[0] > 27)
1083 continue; /* skip to next card */ 1051 continue; /* skip to next card */
1084 /* load video control store */ 1052 /* load video control store */
1085 saa->boardcfg[1] = 0x13; /* no-sync default */ 1053 saa->boardcfg[1] = 0x13; /* no-sync default */
1086 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2); 1054 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2);
1087 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); 1055 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
1088 for (i = 0; i < microcode->datasize / 2; i++) 1056 for (i = 0; i < microcode->datasize / 2; i++)
1089 debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA, 1057 debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA,
1090 (microcode->data[i * 2] << 8) | 1058 (microcode->data[i * 2] << 8) |
1091 microcode->data[i * 2 + 1], 2); 1059 microcode->data[i * 2 + 1], 2);
1092 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); 1060 debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2);
1093 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2); 1061 debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2);
1094 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 1062 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1095 ChipControl, 2); 1063 ChipControl, 2);
1096 saa->boardcfg[0] = 28; 1064 saa->boardcfg[0] = 28;
1097 } 1065 }
1098 if (!strncmp(microcode->loadwhat, "decoder.aud", 11)) { 1066 if (!strncmp(microcode->loadwhat, "decoder.aud", 11)) {
@@ -1109,34 +1077,32 @@ static int initialize_ibmmpeg2(struct video_code *microcode)
1109 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); 1077 debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2);
1110 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); 1078 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2);
1111 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, 1079 if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER,
1112 0xe000, 1)) { 1080 0xe000, 1)) {
1113 printk(KERN_ERR 1081 printk(KERN_ERR "stradis%d: IBM config "
1114 "stradis%d: IBM config failed\n", 1082 "failed\n", saa->nr);
1115 saa->nr);
1116 return -1; 1083 return -1;
1117 } 1084 }
1118 /* set PWM to center value */ 1085 /* set PWM to center value */
1119 if (NewCard) { 1086 if (NewCard) {
1120 debiwrite(saa, debNormal, XILINX_PWM, 1087 debiwrite(saa, debNormal, XILINX_PWM,
1121 saa->boardcfg[14] + 1088 saa->boardcfg[14] +
1122 (saa->boardcfg[13]<<8), 2); 1089 (saa->boardcfg[13] << 8), 2);
1123 } else 1090 } else
1124 debiwrite(saa, debNormal, XILINX_PWM, 1091 debiwrite(saa, debNormal, XILINX_PWM, 0x46, 2);
1125 0x46, 2); 1092
1126 if (HaveCS3310) { 1093 if (HaveCS3310) {
1127 i = CS3310MaxLvl; 1094 i = CS3310MaxLvl;
1128 debiwrite(saa, debNormal, 1095 debiwrite(saa, debNormal, XILINX_CS3310_CMPLT,
1129 XILINX_CS3310_CMPLT, ((i<<8)|i), 2); 1096 (i << 8) | i, 2);
1130 } 1097 }
1131 printk(KERN_INFO 1098 printk(KERN_INFO "stradis%d: IBM MPEGCD%d Inited\n",
1132 "stradis%d: IBM MPEGCD%d Initialized\n", 1099 saa->nr, 18 + (debiread(saa, debNormal,
1133 saa->nr, 18 + (debiread(saa, debNormal, 1100 IBM_MP2_CHIP_CONTROL, 2) >> 12));
1134 IBM_MP2_CHIP_CONTROL, 2) >> 12));
1135 /* start video decoder */ 1101 /* start video decoder */
1136 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, 1102 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1137 ChipControl, 2); 1103 ChipControl, 2);
1138 debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 1104 debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037,
1139 0x4037, 2); /* 256k vid, 3520 bytes aud */ 1105 2); /* 256k vid, 3520 bytes aud */
1140 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2); 1106 debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2);
1141 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0); 1107 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1142 /* enable buffer threshold irq */ 1108 /* enable buffer threshold irq */
@@ -1149,52 +1115,48 @@ static int initialize_ibmmpeg2(struct video_code *microcode)
1149 saa->boardcfg[0] = 37; 1115 saa->boardcfg[0] = 37;
1150 } 1116 }
1151 } 1117 }
1118
1152 return 0; 1119 return 0;
1153} 1120}
1154 1121
1155static u32 palette2fmt[] = 1122static u32 palette2fmt[] = { /* some of these YUV translations are wrong */
1156{ /* some of these YUV translations are wrong */ 1123 0xffffffff, 0x86000000, 0x87000000, 0x80000000, 0x8100000, 0x82000000,
1157 0xffffffff, 0x86000000, 0x87000000, 0x80000000, 0x8100000, 0x82000000, 1124 0x83000000, 0x00000000, 0x03000000, 0x03000000, 0x0a00000, 0x03000000,
1158 0x83000000, 0x00000000, 0x03000000, 0x03000000, 0x0a00000, 0x03000000, 1125 0x06000000, 0x00000000, 0x03000000, 0x0a000000, 0x0300000
1159 0x06000000, 0x00000000, 0x03000000, 0x0a000000, 0x0300000
1160}; 1126};
1161static int bpp2fmt[4] = 1127static int bpp2fmt[4] = {
1162{
1163 VIDEO_PALETTE_HI240, VIDEO_PALETTE_RGB565, VIDEO_PALETTE_RGB24, 1128 VIDEO_PALETTE_HI240, VIDEO_PALETTE_RGB565, VIDEO_PALETTE_RGB24,
1164 VIDEO_PALETTE_RGB32 1129 VIDEO_PALETTE_RGB32
1165}; 1130};
1166 1131
1167/* I wish I could find a formula to calculate these... */ 1132/* I wish I could find a formula to calculate these... */
1168static u32 h_prescale[64] = 1133static u32 h_prescale[64] = {
1169{ 1134 0x10000000, 0x18040202, 0x18080000, 0x380c0606, 0x38100204, 0x38140808,
1170 0x10000000, 0x18040202, 0x18080000, 0x380c0606, 0x38100204, 0x38140808, 1135 0x38180000, 0x381c0000, 0x3820161c, 0x38242a3b, 0x38281230, 0x382c4460,
1171 0x38180000, 0x381c0000, 0x3820161c, 0x38242a3b, 0x38281230, 0x382c4460, 1136 0x38301040, 0x38340080, 0x38380000, 0x383c0000, 0x3840fefe, 0x3844ee9f,
1172 0x38301040, 0x38340080, 0x38380000, 0x383c0000, 0x3840fefe, 0x3844ee9f, 1137 0x3848ee9f, 0x384cee9f, 0x3850ee9f, 0x38542a3b, 0x38581230, 0x385c0000,
1173 0x3848ee9f, 0x384cee9f, 0x3850ee9f, 0x38542a3b, 0x38581230, 0x385c0000, 1138 0x38600000, 0x38640000, 0x38680000, 0x386c0000, 0x38700000, 0x38740000,
1174 0x38600000, 0x38640000, 0x38680000, 0x386c0000, 0x38700000, 0x38740000, 1139 0x38780000, 0x387c0000, 0x30800000, 0x38840000, 0x38880000, 0x388c0000,
1175 0x38780000, 0x387c0000, 0x30800000, 0x38840000, 0x38880000, 0x388c0000, 1140 0x38900000, 0x38940000, 0x38980000, 0x389c0000, 0x38a00000, 0x38a40000,
1176 0x38900000, 0x38940000, 0x38980000, 0x389c0000, 0x38a00000, 0x38a40000, 1141 0x38a80000, 0x38ac0000, 0x38b00000, 0x38b40000, 0x38b80000, 0x38bc0000,
1177 0x38a80000, 0x38ac0000, 0x38b00000, 0x38b40000, 0x38b80000, 0x38bc0000, 1142 0x38c00000, 0x38c40000, 0x38c80000, 0x38cc0000, 0x38d00000, 0x38d40000,
1178 0x38c00000, 0x38c40000, 0x38c80000, 0x38cc0000, 0x38d00000, 0x38d40000, 1143 0x38d80000, 0x38dc0000, 0x38e00000, 0x38e40000, 0x38e80000, 0x38ec0000,
1179 0x38d80000, 0x38dc0000, 0x38e00000, 0x38e40000, 0x38e80000, 0x38ec0000, 1144 0x38f00000, 0x38f40000, 0x38f80000, 0x38fc0000,
1180 0x38f00000, 0x38f40000, 0x38f80000, 0x38fc0000,
1181}; 1145};
1182static u32 v_gain[64] = 1146static u32 v_gain[64] = {
1183{ 1147 0x016000ff, 0x016100ff, 0x016100ff, 0x016200ff, 0x016200ff, 0x016200ff,
1184 0x016000ff, 0x016100ff, 0x016100ff, 0x016200ff, 0x016200ff, 0x016200ff, 1148 0x016200ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff,
1185 0x016200ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 1149 0x016300ff, 0x016300ff, 0x016300ff, 0x016400ff, 0x016400ff, 0x016400ff,
1186 0x016300ff, 0x016300ff, 0x016300ff, 0x016400ff, 0x016400ff, 0x016400ff, 1150 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1187 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1151 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1188 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1152 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1189 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1153 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1190 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1154 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1191 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1155 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1192 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1156 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1193 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 1157 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1194 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff,
1195}; 1158};
1196 1159
1197
1198static void saa7146_set_winsize(struct saa7146 *saa) 1160static void saa7146_set_winsize(struct saa7146 *saa)
1199{ 1161{
1200 u32 format; 1162 u32 format;
@@ -1209,24 +1171,23 @@ static void saa7146_set_winsize(struct saa7146 *saa)
1209 saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight, 1171 saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight,
1210 SAA7146_PROT_ADDR1); 1172 SAA7146_PROT_ADDR1);
1211 saawrite(0, SAA7146_PAGE1); 1173 saawrite(0, SAA7146_PAGE1);
1212 saawrite(format|0x60, SAA7146_CLIP_FORMAT_CTRL); 1174 saawrite(format | 0x60, SAA7146_CLIP_FORMAT_CTRL);
1213 offset = (704 / (saa->win.width - 1)) & 0x3f; 1175 offset = (704 / (saa->win.width - 1)) & 0x3f;
1214 saawrite(h_prescale[offset], SAA7146_HPS_H_PRESCALE); 1176 saawrite(h_prescale[offset], SAA7146_HPS_H_PRESCALE);
1215 offset = (720896 / saa->win.width) / (offset + 1); 1177 offset = (720896 / saa->win.width) / (offset + 1);
1216 saawrite((offset<<12)|0x0c, SAA7146_HPS_H_SCALE); 1178 saawrite((offset << 12) | 0x0c, SAA7146_HPS_H_SCALE);
1217 if (CurrentMode == VIDEO_MODE_NTSC) { 1179 if (CurrentMode == VIDEO_MODE_NTSC) {
1218 yacl = /*(480 / saa->win.height - 1) & 0x3f*/ 0; 1180 yacl = /*(480 / saa->win.height - 1) & 0x3f */ 0;
1219 ysci = 1024 - (saa->win.height * 1024 / 480); 1181 ysci = 1024 - (saa->win.height * 1024 / 480);
1220 } else { 1182 } else {
1221 yacl = /*(576 / saa->win.height - 1) & 0x3f*/ 0; 1183 yacl = /*(576 / saa->win.height - 1) & 0x3f */ 0;
1222 ysci = 1024 - (saa->win.height * 1024 / 576); 1184 ysci = 1024 - (saa->win.height * 1024 / 576);
1223 } 1185 }
1224 saawrite((1<<31)|(ysci<<21)|(yacl<<15), SAA7146_HPS_V_SCALE); 1186 saawrite((1 << 31) | (ysci << 21) | (yacl << 15), SAA7146_HPS_V_SCALE);
1225 saawrite(v_gain[yacl], SAA7146_HPS_V_GAIN); 1187 saawrite(v_gain[yacl], SAA7146_HPS_V_GAIN);
1226 saawrite(((SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_HPS_V | 1188 saawrite(((SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_HPS_V |
1227 SAA7146_MC2_UPLD_HPS_H) << 16) | (SAA7146_MC2_UPLD_DMA1 | 1189 SAA7146_MC2_UPLD_HPS_H) << 16) | (SAA7146_MC2_UPLD_DMA1 |
1228 SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_HPS_H), 1190 SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_HPS_H), SAA7146_MC2);
1229 SAA7146_MC2);
1230} 1191}
1231 1192
1232/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area 1193/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area
@@ -1261,8 +1222,8 @@ static void clip_draw_rectangle(u32 *clipmap, int x, int y, int w, int h)
1261 startword = (x >> 5); 1222 startword = (x >> 5);
1262 endword = ((x + w) >> 5); 1223 endword = ((x + w) >> 5);
1263 bitsleft = (0xffffffff >> (x & 31)); 1224 bitsleft = (0xffffffff >> (x & 31));
1264 bitsright = (0xffffffff << (~((x + w) - (endword<<5)))); 1225 bitsright = (0xffffffff << (~((x + w) - (endword << 5))));
1265 temp = &clipmap[(y<<5) + startword]; 1226 temp = &clipmap[(y << 5) + startword];
1266 w = endword - startword; 1227 w = endword - startword;
1267 if (!w) { 1228 if (!w) {
1268 bitsleft |= bitsright; 1229 bitsleft |= bitsright;
@@ -1287,13 +1248,13 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
1287 u32 *clipmap; 1248 u32 *clipmap;
1288 1249
1289 clipmap = saa->dmavid2; 1250 clipmap = saa->dmavid2;
1290 if((width=saa->win.width)>1023) 1251 if ((width = saa->win.width) > 1023)
1291 width = 1023; /* sanity check */ 1252 width = 1023; /* sanity check */
1292 if((height=saa->win.height)>640) 1253 if ((height = saa->win.height) > 640)
1293 height = 639; /* sanity check */ 1254 height = 639; /* sanity check */
1294 if (ncr > 0) { /* rectangles pased */ 1255 if (ncr > 0) { /* rectangles pased */
1295 /* convert rectangular clips to a bitmap */ 1256 /* convert rectangular clips to a bitmap */
1296 memset(clipmap, 0, VIDEO_CLIPMAP_SIZE); /* clear map */ 1257 memset(clipmap, 0, VIDEO_CLIPMAP_SIZE); /* clear map */
1297 for (i = 0; i < ncr; i++) 1258 for (i = 0; i < ncr; i++)
1298 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y, 1259 clip_draw_rectangle(clipmap, cr[i].x, cr[i].y,
1299 cr[i].width, cr[i].height); 1260 cr[i].width, cr[i].height);
@@ -1301,14 +1262,15 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
1301 /* clip against viewing window AND screen 1262 /* clip against viewing window AND screen
1302 so we do not have to rely on the user program 1263 so we do not have to rely on the user program
1303 */ 1264 */
1304 clip_draw_rectangle(clipmap,(saa->win.x+width>saa->win.swidth) ? 1265 clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ?
1305 (saa->win.swidth-saa->win.x) : width, 0, 1024, 768); 1266 (saa->win.swidth - saa->win.x) : width, 0, 1024, 768);
1306 clip_draw_rectangle(clipmap,0,(saa->win.y+height>saa->win.sheight) ? 1267 clip_draw_rectangle(clipmap, 0,
1307 (saa->win.sheight-saa->win.y) : height,1024,768); 1268 (saa->win.y + height > saa->win.sheight) ?
1308 if (saa->win.x<0) 1269 (saa->win.sheight - saa->win.y) : height, 1024, 768);
1309 clip_draw_rectangle(clipmap, 0, 0, -(saa->win.x), 768); 1270 if (saa->win.x < 0)
1310 if (saa->win.y<0) 1271 clip_draw_rectangle(clipmap, 0, 0, -saa->win.x, 768);
1311 clip_draw_rectangle(clipmap, 0, 0, 1024, -(saa->win.y)); 1272 if (saa->win.y < 0)
1273 clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y);
1312} 1274}
1313 1275
1314static int saa_ioctl(struct inode *inode, struct file *file, 1276static int saa_ioctl(struct inode *inode, struct file *file,
@@ -1322,11 +1284,9 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1322 { 1284 {
1323 struct video_capability b; 1285 struct video_capability b;
1324 strcpy(b.name, saa->video_dev.name); 1286 strcpy(b.name, saa->video_dev.name);
1325 b.type = VID_TYPE_CAPTURE | 1287 b.type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY |
1326 VID_TYPE_OVERLAY | 1288 VID_TYPE_CLIPPING | VID_TYPE_FRAMERAM |
1327 VID_TYPE_CLIPPING | 1289 VID_TYPE_SCALES;
1328 VID_TYPE_FRAMERAM |
1329 VID_TYPE_SCALES;
1330 b.channels = 1; 1290 b.channels = 1;
1331 b.audios = 1; 1291 b.audios = 1;
1332 b.maxwidth = 768; 1292 b.maxwidth = 768;
@@ -1363,17 +1323,18 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1363 if (p.palette < sizeof(palette2fmt) / sizeof(u32)) { 1323 if (p.palette < sizeof(palette2fmt) / sizeof(u32)) {
1364 format = palette2fmt[p.palette]; 1324 format = palette2fmt[p.palette];
1365 saa->win.color_fmt = format; 1325 saa->win.color_fmt = format;
1366 saawrite(format|0x60, SAA7146_CLIP_FORMAT_CTRL); 1326 saawrite(format | 0x60,
1327 SAA7146_CLIP_FORMAT_CTRL);
1367 } 1328 }
1368 saawrite(((p.brightness & 0xff00) << 16) | 1329 saawrite(((p.brightness & 0xff00) << 16) |
1369 ((p.contrast & 0xfe00) << 7) | 1330 ((p.contrast & 0xfe00) << 7) |
1370 ((p.colour & 0xfe00) >> 9), SAA7146_BCS_CTRL); 1331 ((p.colour & 0xfe00) >> 9), SAA7146_BCS_CTRL);
1371 saa->picture = p; 1332 saa->picture = p;
1372 /* upload changed registers */ 1333 /* upload changed registers */
1373 saawrite(((SAA7146_MC2_UPLD_HPS_H | 1334 saawrite(((SAA7146_MC2_UPLD_HPS_H |
1374 SAA7146_MC2_UPLD_HPS_V) << 16) | 1335 SAA7146_MC2_UPLD_HPS_V) << 16) |
1375 SAA7146_MC2_UPLD_HPS_H | SAA7146_MC2_UPLD_HPS_V, 1336 SAA7146_MC2_UPLD_HPS_H |
1376 SAA7146_MC2); 1337 SAA7146_MC2_UPLD_HPS_V, SAA7146_MC2);
1377 return 0; 1338 return 0;
1378 } 1339 }
1379 case VIDIOCSWIN: 1340 case VIDIOCSWIN:
@@ -1384,11 +1345,14 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1384 if (copy_from_user(&vw, arg, sizeof(vw))) 1345 if (copy_from_user(&vw, arg, sizeof(vw)))
1385 return -EFAULT; 1346 return -EFAULT;
1386 1347
1387 if (vw.flags || vw.width < 16 || vw.height < 16) { /* stop capture */ 1348 /* stop capture */
1388 saawrite((SAA7146_MC1_TR_E_1 << 16), SAA7146_MC1); 1349 if (vw.flags || vw.width < 16 || vw.height < 16) {
1350 saawrite((SAA7146_MC1_TR_E_1 << 16),
1351 SAA7146_MC1);
1389 return -EINVAL; 1352 return -EINVAL;
1390 } 1353 }
1391 if (saa->win.bpp < 4) { /* 32-bit align start and adjust width */ 1354 /* 32-bit align start and adjust width */
1355 if (saa->win.bpp < 4) {
1392 int i = vw.x; 1356 int i = vw.x;
1393 vw.x = (vw.x + 3) & ~3; 1357 vw.x = (vw.x + 3) & ~3;
1394 i = vw.x - i; 1358 i = vw.x - i;
@@ -1417,23 +1381,24 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1417 */ 1381 */
1418 if (vw.clipcount < 0) { 1382 if (vw.clipcount < 0) {
1419 if (copy_from_user(saa->dmavid2, vw.clips, 1383 if (copy_from_user(saa->dmavid2, vw.clips,
1420 VIDEO_CLIPMAP_SIZE)) 1384 VIDEO_CLIPMAP_SIZE))
1421 return -EFAULT; 1385 return -EFAULT;
1422 } 1386 } else if (vw.clipcount > 16384) {
1423 else if (vw.clipcount > 16384) {
1424 return -EINVAL; 1387 return -EINVAL;
1425 } else if (vw.clipcount > 0) { 1388 } else if (vw.clipcount > 0) {
1426 if ((vcp = vmalloc(sizeof(struct video_clip) * 1389 vcp = vmalloc(sizeof(struct video_clip) *
1427 (vw.clipcount))) == NULL) 1390 vw.clipcount);
1428 return -ENOMEM; 1391 if (vcp == NULL)
1392 return -ENOMEM;
1429 if (copy_from_user(vcp, vw.clips, 1393 if (copy_from_user(vcp, vw.clips,
1430 sizeof(struct video_clip) * 1394 sizeof(struct video_clip) *
1431 vw.clipcount)) { 1395 vw.clipcount)) {
1432 vfree(vcp); 1396 vfree(vcp);
1433 return -EFAULT; 1397 return -EFAULT;
1434 } 1398 }
1435 } else /* nothing clipped */ 1399 } else /* nothing clipped */
1436 memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE); 1400 memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE);
1401
1437 make_clip_tab(saa, vcp, vw.clipcount); 1402 make_clip_tab(saa, vcp, vw.clipcount);
1438 if (vw.clipcount > 0) 1403 if (vw.clipcount > 0)
1439 vfree(vcp); 1404 vfree(vcp);
@@ -1466,21 +1431,21 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1466 if (v == 0) { 1431 if (v == 0) {
1467 saa->cap &= ~1; 1432 saa->cap &= ~1;
1468 saawrite((SAA7146_MC1_TR_E_1 << 16), 1433 saawrite((SAA7146_MC1_TR_E_1 << 16),
1469 SAA7146_MC1); 1434 SAA7146_MC1);
1470 } else { 1435 } else {
1471 if (saa->win.vidadr == 0 || saa->win.width == 0 1436 if (saa->win.vidadr == 0 || saa->win.width == 0
1472 || saa->win.height == 0) 1437 || saa->win.height == 0)
1473 return -EINVAL; 1438 return -EINVAL;
1474 saa->cap |= 1; 1439 saa->cap |= 1;
1475 saawrite((SAA7146_MC1_TR_E_1 << 16) | 0xffff, 1440 saawrite((SAA7146_MC1_TR_E_1 << 16) | 0xffff,
1476 SAA7146_MC1); 1441 SAA7146_MC1);
1477 } 1442 }
1478 return 0; 1443 return 0;
1479 } 1444 }
1480 case VIDIOCGFBUF: 1445 case VIDIOCGFBUF:
1481 { 1446 {
1482 struct video_buffer v; 1447 struct video_buffer v;
1483 v.base = (void *) saa->win.vidadr; 1448 v.base = (void *)saa->win.vidadr;
1484 v.height = saa->win.sheight; 1449 v.height = saa->win.sheight;
1485 v.width = saa->win.swidth; 1450 v.width = saa->win.swidth;
1486 v.depth = saa->win.depth; 1451 v.depth = saa->win.depth;
@@ -1498,19 +1463,20 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1498 if (copy_from_user(&v, arg, sizeof(v))) 1463 if (copy_from_user(&v, arg, sizeof(v)))
1499 return -EFAULT; 1464 return -EFAULT;
1500 if (v.depth != 8 && v.depth != 15 && v.depth != 16 && 1465 if (v.depth != 8 && v.depth != 15 && v.depth != 16 &&
1501 v.depth != 24 && v.depth != 32 && v.width > 16 && 1466 v.depth != 24 && v.depth != 32 && v.width > 16 &&
1502 v.height > 16 && v.bytesperline > 16) 1467 v.height > 16 && v.bytesperline > 16)
1503 return -EINVAL; 1468 return -EINVAL;
1504 if (v.base) 1469 if (v.base)
1505 saa->win.vidadr = (unsigned long) v.base; 1470 saa->win.vidadr = (unsigned long)v.base;
1506 saa->win.sheight = v.height; 1471 saa->win.sheight = v.height;
1507 saa->win.swidth = v.width; 1472 saa->win.swidth = v.width;
1508 saa->win.bpp = ((v.depth + 7) & 0x38) / 8; 1473 saa->win.bpp = ((v.depth + 7) & 0x38) / 8;
1509 saa->win.depth = v.depth; 1474 saa->win.depth = v.depth;
1510 saa->win.bpl = v.bytesperline; 1475 saa->win.bpl = v.bytesperline;
1511 1476
1512 DEBUG(printk("Display at %p is %d by %d, bytedepth %d, bpl %d\n", 1477 DEBUG(printk("Display at %p is %d by %d, bytedepth %d, "
1513 v.base, v.width, v.height, saa->win.bpp, saa->win.bpl)); 1478 "bpl %d\n", v.base, v.width, v.height,
1479 saa->win.bpp, saa->win.bpl));
1514 saa7146_set_winsize(saa); 1480 saa7146_set_winsize(saa);
1515 return 0; 1481 return 0;
1516 } 1482 }
@@ -1538,21 +1504,18 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1538 int i; 1504 int i;
1539 if (copy_from_user(&v, arg, sizeof(v))) 1505 if (copy_from_user(&v, arg, sizeof(v)))
1540 return -EFAULT; 1506 return -EFAULT;
1541 i = (~(v.volume>>8))&0xff; 1507 i = (~(v.volume >> 8)) & 0xff;
1542 if (!HaveCS4341) { 1508 if (!HaveCS4341) {
1543 if (v.flags & VIDEO_AUDIO_MUTE) { 1509 if (v.flags & VIDEO_AUDIO_MUTE)
1544 debiwrite(saa, debNormal, 1510 debiwrite(saa, debNormal,
1545 IBM_MP2_FRNT_ATTEN, 1511 IBM_MP2_FRNT_ATTEN, 0xffff, 2);
1546 0xffff, 2);
1547 }
1548 if (!(v.flags & VIDEO_AUDIO_MUTE)) 1512 if (!(v.flags & VIDEO_AUDIO_MUTE))
1549 debiwrite(saa, debNormal, 1513 debiwrite(saa, debNormal,
1550 IBM_MP2_FRNT_ATTEN, 1514 IBM_MP2_FRNT_ATTEN, 0x0000, 2);
1551 0x0000, 2);
1552 if (v.flags & VIDEO_AUDIO_VOLUME) 1515 if (v.flags & VIDEO_AUDIO_VOLUME)
1553 debiwrite(saa, debNormal, 1516 debiwrite(saa, debNormal,
1554 IBM_MP2_FRNT_ATTEN, 1517 IBM_MP2_FRNT_ATTEN,
1555 (i<<8)|i, 2); 1518 (i << 8) | i, 2);
1556 } else { 1519 } else {
1557 if (v.flags & VIDEO_AUDIO_MUTE) 1520 if (v.flags & VIDEO_AUDIO_MUTE)
1558 cs4341_setlevel(saa, 0xff, 0xff); 1521 cs4341_setlevel(saa, 0xff, 0xff);
@@ -1580,163 +1543,138 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1580 case VIDIOCSPLAYMODE: 1543 case VIDIOCSPLAYMODE:
1581 { 1544 {
1582 struct video_play_mode pmode; 1545 struct video_play_mode pmode;
1583 if (copy_from_user((void *) &pmode, arg, 1546 if (copy_from_user((void *)&pmode, arg,
1584 sizeof(struct video_play_mode))) 1547 sizeof(struct video_play_mode)))
1585 return -EFAULT; 1548 return -EFAULT;
1586 switch (pmode.mode) { 1549 switch (pmode.mode) {
1587 case VID_PLAY_VID_OUT_MODE: 1550 case VID_PLAY_VID_OUT_MODE:
1588 if (pmode.p1 != VIDEO_MODE_NTSC && 1551 if (pmode.p1 != VIDEO_MODE_NTSC &&
1589 pmode.p1 != VIDEO_MODE_PAL) 1552 pmode.p1 != VIDEO_MODE_PAL)
1590 return -EINVAL; 1553 return -EINVAL;
1591 set_out_format(saa, pmode.p1); 1554 set_out_format(saa, pmode.p1);
1592 return 0; 1555 return 0;
1593 case VID_PLAY_GENLOCK: 1556 case VID_PLAY_GENLOCK:
1594 debiwrite(saa, debNormal, 1557 debiwrite(saa, debNormal, XILINX_CTL0,
1595 XILINX_CTL0, 1558 pmode.p1 ? 0x8000 : 0x8080, 2);
1596 (pmode.p1 ? 0x8000 : 0x8080), 1559 if (NewCard)
1597 2); 1560 set_genlock_offset(saa, pmode.p2);
1598 if (NewCard) 1561 return 0;
1599 set_genlock_offset(saa, 1562 case VID_PLAY_NORMAL:
1600 pmode.p2); 1563 debiwrite(saa, debNormal,
1601 return 0; 1564 IBM_MP2_CHIP_CONTROL, ChipControl, 2);
1602 case VID_PLAY_NORMAL: 1565 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1603 debiwrite(saa, debNormal, 1566 saa->playmode = pmode.mode;
1604 IBM_MP2_CHIP_CONTROL, 1567 return 0;
1605 ChipControl, 2); 1568 case VID_PLAY_PAUSE:
1606 ibm_send_command(saa, 1569 /* IBM removed the PAUSE command */
1607 IBM_MP2_PLAY, 0, 0); 1570 /* they say use SINGLE_FRAME now */
1608 saa->playmode = pmode.mode; 1571 case VID_PLAY_SINGLE_FRAME:
1609 return 0; 1572 ibm_send_command(saa, IBM_MP2_SINGLE_FRAME,0,0);
1610 case VID_PLAY_PAUSE: 1573 if (saa->playmode == pmode.mode) {
1611 /* IBM removed the PAUSE command */
1612 /* they say use SINGLE_FRAME now */
1613 case VID_PLAY_SINGLE_FRAME:
1614 ibm_send_command(saa,
1615 IBM_MP2_SINGLE_FRAME,
1616 0, 0);
1617 if (saa->playmode == pmode.mode) {
1618 debiwrite(saa, debNormal,
1619 IBM_MP2_CHIP_CONTROL,
1620 ChipControl, 2);
1621 }
1622 saa->playmode = pmode.mode;
1623 return 0;
1624 case VID_PLAY_FAST_FORWARD:
1625 ibm_send_command(saa,
1626 IBM_MP2_FAST_FORWARD, 0, 0);
1627 saa->playmode = pmode.mode;
1628 return 0;
1629 case VID_PLAY_SLOW_MOTION:
1630 ibm_send_command(saa,
1631 IBM_MP2_SLOW_MOTION,
1632 pmode.p1, 0);
1633 saa->playmode = pmode.mode;
1634 return 0;
1635 case VID_PLAY_IMMEDIATE_NORMAL:
1636 /* ensure transfers resume */
1637 debiwrite(saa, debNormal,
1638 IBM_MP2_CHIP_CONTROL,
1639 ChipControl, 2);
1640 ibm_send_command(saa,
1641 IBM_MP2_IMED_NORM_PLAY, 0, 0);
1642 saa->playmode = VID_PLAY_NORMAL;
1643 return 0;
1644 case VID_PLAY_SWITCH_CHANNELS:
1645 saa->audhead = saa->audtail = 0;
1646 saa->vidhead = saa->vidtail = 0;
1647 ibm_send_command(saa,
1648 IBM_MP2_FREEZE_FRAME, 0, 1);
1649 ibm_send_command(saa,
1650 IBM_MP2_RESET_AUD_RATE, 0, 1);
1651 debiwrite(saa, debNormal,
1652 IBM_MP2_CHIP_CONTROL, 0, 2);
1653 ibm_send_command(saa,
1654 IBM_MP2_CHANNEL_SWITCH, 0, 1);
1655 debiwrite(saa, debNormal, 1574 debiwrite(saa, debNormal,
1656 IBM_MP2_CHIP_CONTROL, 1575 IBM_MP2_CHIP_CONTROL,
1657 ChipControl, 2); 1576 ChipControl, 2);
1658 ibm_send_command(saa, 1577 }
1659 IBM_MP2_PLAY, 0, 0); 1578 saa->playmode = pmode.mode;
1660 saa->playmode = VID_PLAY_NORMAL; 1579 return 0;
1661 return 0; 1580 case VID_PLAY_FAST_FORWARD:
1662 case VID_PLAY_FREEZE_FRAME: 1581 ibm_send_command(saa, IBM_MP2_FAST_FORWARD,0,0);
1663 ibm_send_command(saa, 1582 saa->playmode = pmode.mode;
1664 IBM_MP2_FREEZE_FRAME, 0, 0); 1583 return 0;
1665 saa->playmode = pmode.mode; 1584 case VID_PLAY_SLOW_MOTION:
1666 return 0; 1585 ibm_send_command(saa, IBM_MP2_SLOW_MOTION,
1667 case VID_PLAY_STILL_MODE: 1586 pmode.p1, 0);
1668 ibm_send_command(saa, 1587 saa->playmode = pmode.mode;
1669 IBM_MP2_SET_STILL_MODE, 0, 0); 1588 return 0;
1670 saa->playmode = pmode.mode; 1589 case VID_PLAY_IMMEDIATE_NORMAL:
1671 return 0; 1590 /* ensure transfers resume */
1672 case VID_PLAY_MASTER_MODE: 1591 debiwrite(saa, debNormal,
1673 if (pmode.p1 == VID_PLAY_MASTER_NONE) 1592 IBM_MP2_CHIP_CONTROL, ChipControl, 2);
1674 saa->boardcfg[1] = 0x13; 1593 ibm_send_command(saa, IBM_MP2_IMED_NORM_PLAY,
1675 else if (pmode.p1 == 1594 0, 0);
1676 VID_PLAY_MASTER_VIDEO) 1595 saa->playmode = VID_PLAY_NORMAL;
1677 saa->boardcfg[1] = 0x23; 1596 return 0;
1678 else if (pmode.p1 == 1597 case VID_PLAY_SWITCH_CHANNELS:
1679 VID_PLAY_MASTER_AUDIO) 1598 saa->audhead = saa->audtail = 0;
1680 saa->boardcfg[1] = 0x43; 1599 saa->vidhead = saa->vidtail = 0;
1681 else 1600 ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,1);
1601 ibm_send_command(saa, IBM_MP2_RESET_AUD_RATE,
1602 0, 1);
1603 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1604 0, 2);
1605 ibm_send_command(saa, IBM_MP2_CHANNEL_SWITCH,
1606 0, 1);
1607 debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL,
1608 ChipControl, 2);
1609 ibm_send_command(saa, IBM_MP2_PLAY, 0, 0);
1610 saa->playmode = VID_PLAY_NORMAL;
1611 return 0;
1612 case VID_PLAY_FREEZE_FRAME:
1613 ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,0);
1614 saa->playmode = pmode.mode;
1615 return 0;
1616 case VID_PLAY_STILL_MODE:
1617 ibm_send_command(saa, IBM_MP2_SET_STILL_MODE,
1618 0, 0);
1619 saa->playmode = pmode.mode;
1620 return 0;
1621 case VID_PLAY_MASTER_MODE:
1622 if (pmode.p1 == VID_PLAY_MASTER_NONE)
1623 saa->boardcfg[1] = 0x13;
1624 else if (pmode.p1 == VID_PLAY_MASTER_VIDEO)
1625 saa->boardcfg[1] = 0x23;
1626 else if (pmode.p1 == VID_PLAY_MASTER_AUDIO)
1627 saa->boardcfg[1] = 0x43;
1628 else
1629 return -EINVAL;
1630 debiwrite(saa, debNormal,
1631 IBM_MP2_CHIP_CONTROL, ChipControl, 2);
1632 return 0;
1633 case VID_PLAY_ACTIVE_SCANLINES:
1634 if (CurrentMode == VIDEO_MODE_PAL) {
1635 if (pmode.p1 < 1 || pmode.p2 > 625)
1682 return -EINVAL; 1636 return -EINVAL;
1683 debiwrite(saa, debNormal, 1637 saa->boardcfg[5] = pmode.p1;
1684 IBM_MP2_CHIP_CONTROL, 1638 saa->boardcfg[55] = (pmode.p1 +
1685 ChipControl, 2); 1639 (pmode.p2 / 2) - 1) & 0xff;
1686 return 0; 1640 } else {
1687 case VID_PLAY_ACTIVE_SCANLINES: 1641 if (pmode.p1 < 4 || pmode.p2 > 525)
1688 if (CurrentMode == VIDEO_MODE_PAL) { 1642 return -EINVAL;
1689 if (pmode.p1 < 1 || 1643 saa->boardcfg[4] = pmode.p1;
1690 pmode.p2 > 625) 1644 saa->boardcfg[54] = (pmode.p1 +
1691 return -EINVAL; 1645 (pmode.p2 / 2) - 4) & 0xff;
1692 saa->boardcfg[5] = pmode.p1; 1646 }
1693 saa->boardcfg[55] = (pmode.p1 + 1647 set_out_format(saa, CurrentMode);
1694 (pmode.p2/2) - 1) & 1648 case VID_PLAY_RESET:
1695 0xff; 1649 return do_ibm_reset(saa);
1696 } else { 1650 case VID_PLAY_END_MARK:
1697 if (pmode.p1 < 4 || 1651 if (saa->endmarktail < saa->endmarkhead) {
1698 pmode.p2 > 525) 1652 if (saa->endmarkhead -
1699 return -EINVAL;
1700 saa->boardcfg[4] = pmode.p1;
1701 saa->boardcfg[54] = (pmode.p1 +
1702 (pmode.p2/2) - 4) &
1703 0xff;
1704 }
1705 set_out_format(saa, CurrentMode);
1706 case VID_PLAY_RESET:
1707 return do_ibm_reset(saa);
1708 case VID_PLAY_END_MARK:
1709 if (saa->endmarktail <
1710 saa->endmarkhead) {
1711 if (saa->endmarkhead -
1712 saa->endmarktail < 2) 1653 saa->endmarktail < 2)
1713 return -ENOSPC;
1714 } else if (saa->endmarkhead <=
1715 saa->endmarktail) {
1716 if (saa->endmarktail -
1717 saa->endmarkhead >
1718 (MAX_MARKS - 2))
1719 return -ENOSPC;
1720 } else
1721 return -ENOSPC; 1654 return -ENOSPC;
1722 saa->endmark[saa->endmarktail] = 1655 } else if (saa->endmarkhead <=saa->endmarktail){
1723 saa->audtail; 1656 if (saa->endmarktail - saa->endmarkhead
1724 saa->endmarktail++; 1657 > (MAX_MARKS - 2))
1725 if (saa->endmarktail >= MAX_MARKS) 1658 return -ENOSPC;
1726 saa->endmarktail = 0; 1659 } else
1660 return -ENOSPC;
1661 saa->endmark[saa->endmarktail] = saa->audtail;
1662 saa->endmarktail++;
1663 if (saa->endmarktail >= MAX_MARKS)
1664 saa->endmarktail = 0;
1727 } 1665 }
1728 return -EINVAL; 1666 return -EINVAL;
1729 } 1667 }
1730 case VIDIOCSWRITEMODE: 1668 case VIDIOCSWRITEMODE:
1731 { 1669 {
1732 int mode; 1670 int mode;
1733 if (copy_from_user((void *) &mode, arg, sizeof(int))) 1671 if (copy_from_user((void *)&mode, arg, sizeof(int)))
1734 return -EFAULT; 1672 return -EFAULT;
1735 if (mode == VID_WRITE_MPEG_AUD || 1673 if (mode == VID_WRITE_MPEG_AUD ||
1736 mode == VID_WRITE_MPEG_VID || 1674 mode == VID_WRITE_MPEG_VID ||
1737 mode == VID_WRITE_CC || 1675 mode == VID_WRITE_CC ||
1738 mode == VID_WRITE_TTX || 1676 mode == VID_WRITE_TTX ||
1739 mode == VID_WRITE_OSD) { 1677 mode == VID_WRITE_OSD) {
1740 saa->writemode = mode; 1678 saa->writemode = mode;
1741 return 0; 1679 return 0;
1742 } 1680 }
@@ -1750,7 +1688,7 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1750 if (copy_from_user(&ucode, arg, sizeof(ucode))) 1688 if (copy_from_user(&ucode, arg, sizeof(ucode)))
1751 return -EFAULT; 1689 return -EFAULT;
1752 if (ucode.datasize > 65536 || ucode.datasize < 1024 || 1690 if (ucode.datasize > 65536 || ucode.datasize < 1024 ||
1753 strncmp(ucode.loadwhat, "dec", 3)) 1691 strncmp(ucode.loadwhat, "dec", 3))
1754 return -EINVAL; 1692 return -EINVAL;
1755 if ((udata = vmalloc(ucode.datasize)) == NULL) 1693 if ((udata = vmalloc(ucode.datasize)) == NULL)
1756 return -ENOMEM; 1694 return -ENOMEM;
@@ -1759,8 +1697,8 @@ static int saa_ioctl(struct inode *inode, struct file *file,
1759 return -EFAULT; 1697 return -EFAULT;
1760 } 1698 }
1761 ucode.data = udata; 1699 ucode.data = udata;
1762 if (!strncmp(ucode.loadwhat, "decoder.aud", 11) 1700 if (!strncmp(ucode.loadwhat, "decoder.aud", 11) ||
1763 || !strncmp(ucode.loadwhat, "decoder.vid", 11)) 1701 !strncmp(ucode.loadwhat, "decoder.vid", 11))
1764 i = initialize_ibmmpeg2(&ucode); 1702 i = initialize_ibmmpeg2(&ucode);
1765 else 1703 else
1766 i = initialize_fpga(&ucode); 1704 i = initialize_fpga(&ucode);
@@ -1805,14 +1743,14 @@ static int saa_mmap(struct file *file, struct vm_area_struct *vma)
1805 return -EINVAL; 1743 return -EINVAL;
1806} 1744}
1807 1745
1808static ssize_t saa_read(struct file *file, char __user *buf, 1746static ssize_t saa_read(struct file *file, char __user * buf,
1809 size_t count, loff_t *ppos) 1747 size_t count, loff_t * ppos)
1810{ 1748{
1811 return -EINVAL; 1749 return -EINVAL;
1812} 1750}
1813 1751
1814static ssize_t saa_write(struct file *file, const char __user *buf, 1752static ssize_t saa_write(struct file *file, const char __user * buf,
1815 size_t count, loff_t *ppos) 1753 size_t count, loff_t * ppos)
1816{ 1754{
1817 struct saa7146 *saa = file->private_data; 1755 struct saa7146 *saa = file->private_data;
1818 unsigned long todo = count; 1756 unsigned long todo = count;
@@ -1823,20 +1761,22 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1823 if (saa->writemode == VID_WRITE_MPEG_AUD) { 1761 if (saa->writemode == VID_WRITE_MPEG_AUD) {
1824 spin_lock_irqsave(&saa->lock, flags); 1762 spin_lock_irqsave(&saa->lock, flags);
1825 if (saa->audhead <= saa->audtail) 1763 if (saa->audhead <= saa->audtail)
1826 blocksize = 65536-(saa->audtail - saa->audhead); 1764 blocksize = 65536 -
1765 (saa->audtail - saa->audhead);
1827 else 1766 else
1828 blocksize = saa->audhead - saa->audtail; 1767 blocksize = saa->audhead - saa->audtail;
1829 spin_unlock_irqrestore(&saa->lock, flags); 1768 spin_unlock_irqrestore(&saa->lock, flags);
1830 if (blocksize < 16384) { 1769 if (blocksize < 16384) {
1831 saawrite(SAA7146_PSR_DEBI_S | 1770 saawrite(SAA7146_PSR_DEBI_S |
1832 SAA7146_PSR_PIN1, SAA7146_IER); 1771 SAA7146_PSR_PIN1, SAA7146_IER);
1833 saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); 1772 saawrite(SAA7146_PSR_PIN1, SAA7146_PSR);
1834 /* wait for buffer space to open */ 1773 /* wait for buffer space to open */
1835 interruptible_sleep_on(&saa->audq); 1774 interruptible_sleep_on(&saa->audq);
1836 } 1775 }
1837 spin_lock_irqsave(&saa->lock, flags); 1776 spin_lock_irqsave(&saa->lock, flags);
1838 if (saa->audhead <= saa->audtail) { 1777 if (saa->audhead <= saa->audtail) {
1839 blocksize = 65536-(saa->audtail - saa->audhead); 1778 blocksize = 65536 -
1779 (saa->audtail - saa->audhead);
1840 split = 65536 - saa->audtail; 1780 split = 65536 - saa->audtail;
1841 } else { 1781 } else {
1842 blocksize = saa->audhead - saa->audtail; 1782 blocksize = saa->audhead - saa->audtail;
@@ -1851,7 +1791,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1851 return -ENOSPC; 1791 return -ENOSPC;
1852 if (split < blocksize) { 1792 if (split < blocksize) {
1853 if (copy_from_user(saa->audbuf + 1793 if (copy_from_user(saa->audbuf +
1854 saa->audtail, buf, split)) 1794 saa->audtail, buf, split))
1855 return -EFAULT; 1795 return -EFAULT;
1856 buf += split; 1796 buf += split;
1857 todo -= split; 1797 todo -= split;
@@ -1859,7 +1799,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1859 saa->audtail = 0; 1799 saa->audtail = 0;
1860 } 1800 }
1861 if (copy_from_user(saa->audbuf + saa->audtail, buf, 1801 if (copy_from_user(saa->audbuf + saa->audtail, buf,
1862 blocksize)) 1802 blocksize))
1863 return -EFAULT; 1803 return -EFAULT;
1864 saa->audtail += blocksize; 1804 saa->audtail += blocksize;
1865 todo -= blocksize; 1805 todo -= blocksize;
@@ -1868,20 +1808,22 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1868 } else if (saa->writemode == VID_WRITE_MPEG_VID) { 1808 } else if (saa->writemode == VID_WRITE_MPEG_VID) {
1869 spin_lock_irqsave(&saa->lock, flags); 1809 spin_lock_irqsave(&saa->lock, flags);
1870 if (saa->vidhead <= saa->vidtail) 1810 if (saa->vidhead <= saa->vidtail)
1871 blocksize=524288-(saa->vidtail - saa->vidhead); 1811 blocksize = 524288 -
1812 (saa->vidtail - saa->vidhead);
1872 else 1813 else
1873 blocksize = saa->vidhead - saa->vidtail; 1814 blocksize = saa->vidhead - saa->vidtail;
1874 spin_unlock_irqrestore(&saa->lock, flags); 1815 spin_unlock_irqrestore(&saa->lock, flags);
1875 if (blocksize < 65536) { 1816 if (blocksize < 65536) {
1876 saawrite(SAA7146_PSR_DEBI_S | 1817 saawrite(SAA7146_PSR_DEBI_S |
1877 SAA7146_PSR_PIN1, SAA7146_IER); 1818 SAA7146_PSR_PIN1, SAA7146_IER);
1878 saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); 1819 saawrite(SAA7146_PSR_PIN1, SAA7146_PSR);
1879 /* wait for buffer space to open */ 1820 /* wait for buffer space to open */
1880 interruptible_sleep_on(&saa->vidq); 1821 interruptible_sleep_on(&saa->vidq);
1881 } 1822 }
1882 spin_lock_irqsave(&saa->lock, flags); 1823 spin_lock_irqsave(&saa->lock, flags);
1883 if (saa->vidhead <= saa->vidtail) { 1824 if (saa->vidhead <= saa->vidtail) {
1884 blocksize=524288-(saa->vidtail - saa->vidhead); 1825 blocksize = 524288 -
1826 (saa->vidtail - saa->vidhead);
1885 split = 524288 - saa->vidtail; 1827 split = 524288 - saa->vidtail;
1886 } else { 1828 } else {
1887 blocksize = saa->vidhead - saa->vidtail; 1829 blocksize = saa->vidhead - saa->vidtail;
@@ -1896,7 +1838,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1896 return -ENOSPC; 1838 return -ENOSPC;
1897 if (split < blocksize) { 1839 if (split < blocksize) {
1898 if (copy_from_user(saa->vidbuf + 1840 if (copy_from_user(saa->vidbuf +
1899 saa->vidtail, buf, split)) 1841 saa->vidtail, buf, split))
1900 return -EFAULT; 1842 return -EFAULT;
1901 buf += split; 1843 buf += split;
1902 todo -= split; 1844 todo -= split;
@@ -1904,7 +1846,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1904 saa->vidtail = 0; 1846 saa->vidtail = 0;
1905 } 1847 }
1906 if (copy_from_user(saa->vidbuf + saa->vidtail, buf, 1848 if (copy_from_user(saa->vidbuf + saa->vidtail, buf,
1907 blocksize)) 1849 blocksize))
1908 return -EFAULT; 1850 return -EFAULT;
1909 saa->vidtail += blocksize; 1851 saa->vidtail += blocksize;
1910 todo -= blocksize; 1852 todo -= blocksize;
@@ -1922,8 +1864,8 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1922 debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2); 1864 debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2);
1923 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2); 1865 debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2);
1924 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 1866 debiwrite(saa, debNormal, IBM_MP2_DISP_MODE,
1925 debiread(saa, debNormal, 1867 debiread(saa, debNormal,
1926 IBM_MP2_DISP_MODE, 2) | 1, 2); 1868 IBM_MP2_DISP_MODE, 2) | 1, 2);
1927 /* trigger osd data transfer */ 1869 /* trigger osd data transfer */
1928 saawrite(SAA7146_PSR_DEBI_S | 1870 saawrite(SAA7146_PSR_DEBI_S |
1929 SAA7146_PSR_PIN1, SAA7146_IER); 1871 SAA7146_PSR_PIN1, SAA7146_IER);
@@ -1935,21 +1877,11 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1935 1877
1936static int saa_open(struct inode *inode, struct file *file) 1878static int saa_open(struct inode *inode, struct file *file)
1937{ 1879{
1938 struct saa7146 *saa = NULL; 1880 struct video_device *vdev = video_devdata(file);
1939 unsigned int minor = iminor(inode); 1881 struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
1940 int i;
1941 1882
1942 for (i = 0; i < SAA7146_MAX; i++) {
1943 if (saa7146s[i].video_dev.minor == minor) {
1944 saa = &saa7146s[i];
1945 }
1946 }
1947 if (saa == NULL) {
1948 return -ENODEV;
1949 }
1950 file->private_data = saa; 1883 file->private_data = saa;
1951 1884
1952 //saa->video_dev.busy = 0; /* old hack to support multiple open */
1953 saa->user++; 1885 saa->user++;
1954 if (saa->user > 1) 1886 if (saa->user > 1)
1955 return 0; /* device open already, don't reset */ 1887 return 0; /* device open already, don't reset */
@@ -1961,43 +1893,39 @@ static int saa_release(struct inode *inode, struct file *file)
1961{ 1893{
1962 struct saa7146 *saa = file->private_data; 1894 struct saa7146 *saa = file->private_data;
1963 saa->user--; 1895 saa->user--;
1964 //saa->video_dev.busy = 0; /* old hack to support multiple open */ 1896
1965 if (saa->user > 0) /* still someone using device */ 1897 if (saa->user > 0) /* still someone using device */
1966 return 0; 1898 return 0;
1967 saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */ 1899 saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */
1968 return 0; 1900 return 0;
1969} 1901}
1970 1902
1971static struct file_operations saa_fops = 1903static struct file_operations saa_fops = {
1972{ 1904 .owner = THIS_MODULE,
1973 .owner = THIS_MODULE, 1905 .open = saa_open,
1974 .open = saa_open, 1906 .release = saa_release,
1975 .release = saa_release, 1907 .ioctl = saa_ioctl,
1976 .ioctl = saa_ioctl, 1908 .compat_ioctl = v4l_compat_ioctl32,
1977 .compat_ioctl = v4l_compat_ioctl32, 1909 .read = saa_read,
1978 .read = saa_read, 1910 .llseek = no_llseek,
1979 .llseek = no_llseek, 1911 .write = saa_write,
1980 .write = saa_write, 1912 .mmap = saa_mmap,
1981 .mmap = saa_mmap,
1982}; 1913};
1983 1914
1984/* template for video_device-structure */ 1915/* template for video_device-structure */
1985static struct video_device saa_template = 1916static struct video_device saa_template = {
1986{ 1917 .name = "SAA7146A",
1987 .name = "SAA7146A", 1918 .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY,
1988 .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, 1919 .hardware = VID_HARDWARE_SAA7146,
1989 .hardware = VID_HARDWARE_SAA7146, 1920 .fops = &saa_fops,
1990 .fops = &saa_fops, 1921 .minor = -1,
1991 .minor = -1,
1992}; 1922};
1993 1923
1994static int configure_saa7146(struct pci_dev *dev, int num) 1924static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
1995{ 1925{
1996 int result; 1926 int retval;
1997 struct saa7146 *saa; 1927 struct saa7146 *saa = pci_get_drvdata(pdev);
1998 1928
1999 saa = &saa7146s[num];
2000
2001 saa->endmarkhead = saa->endmarktail = 0; 1929 saa->endmarkhead = saa->endmarktail = 0;
2002 saa->win.x = saa->win.y = 0; 1930 saa->win.x = saa->win.y = 0;
2003 saa->win.width = saa->win.cropwidth = 720; 1931 saa->win.width = saa->win.cropwidth = 720;
@@ -2013,7 +1941,6 @@ static int configure_saa7146(struct pci_dev *dev, int num)
2013 saa->picture.contrast = 38768; 1941 saa->picture.contrast = 38768;
2014 saa->picture.colour = 32768; 1942 saa->picture.colour = 32768;
2015 saa->cap = 0; 1943 saa->cap = 0;
2016 saa->dev = dev;
2017 saa->nr = num; 1944 saa->nr = num;
2018 saa->playmode = VID_PLAY_NORMAL; 1945 saa->playmode = VID_PLAY_NORMAL;
2019 memset(saa->boardcfg, 0, 64); /* clear board config area */ 1946 memset(saa->boardcfg, 0, 64); /* clear board config area */
@@ -2033,45 +1960,59 @@ static int configure_saa7146(struct pci_dev *dev, int num)
2033 init_waitqueue_head(&saa->vidq); 1960 init_waitqueue_head(&saa->vidq);
2034 spin_lock_init(&saa->lock); 1961 spin_lock_init(&saa->lock);
2035 1962
2036 if (pci_enable_device(dev)) 1963 retval = pci_enable_device(pdev);
2037 return -EIO; 1964 if (retval) {
2038 1965 dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num);
2039 saa->id = dev->device; 1966 goto err;
2040 saa->irq = dev->irq; 1967 }
1968
1969 saa->id = pdev->device;
1970 saa->irq = pdev->irq;
2041 saa->video_dev.minor = -1; 1971 saa->video_dev.minor = -1;
2042 saa->saa7146_adr = pci_resource_start(dev, 0); 1972 saa->saa7146_adr = pci_resource_start(pdev, 0);
2043 pci_read_config_byte(dev, PCI_CLASS_REVISION, &saa->revision); 1973 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
2044 1974
2045 saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200); 1975 saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
2046 if (!saa->saa7146_mem) 1976 if (saa->saa7146_mem == NULL) {
2047 return -EIO; 1977 dev_err(&pdev->dev, "%d: ioremap failed!\n", num);
1978 retval = -EIO;
1979 goto err;
1980 }
2048 1981
2049 memcpy(&saa->video_dev, &saa_template, sizeof(saa_template)); 1982 memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
2050 saawrite(0, SAA7146_IER); /* turn off all interrupts */ 1983 saawrite(0, SAA7146_IER); /* turn off all interrupts */
2051 result = request_irq(saa->irq, saa7146_irq, 1984
2052 SA_SHIRQ | SA_INTERRUPT, "stradis", (void *) saa); 1985 retval = request_irq(saa->irq, saa7146_irq, SA_SHIRQ | SA_INTERRUPT,
2053 if (result == -EINVAL) 1986 "stradis", saa);
2054 printk(KERN_ERR "stradis%d: Bad irq number or handler\n", 1987 if (retval == -EINVAL)
2055 num); 1988 dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num);
2056 if (result == -EBUSY) 1989 else if (retval == -EBUSY)
2057 printk(KERN_ERR "stradis%d: IRQ %ld busy, change your PnP" 1990 dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config "
2058 " config in BIOS\n", num, saa->irq); 1991 "in BIOS\n", num, saa->irq);
2059 if (result < 0) { 1992 if (retval < 0)
2060 iounmap(saa->saa7146_mem); 1993 goto errio;
2061 return result; 1994
2062 } 1995 pci_set_master(pdev);
2063 pci_set_master(dev); 1996 retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER,
2064 if (video_register_device(&saa->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) { 1997 video_nr);
2065 iounmap(saa->saa7146_mem); 1998 if (retval < 0) {
2066 return -1; 1999 dev_err(&pdev->dev, "%d: error in registering video device!\n",
2000 num);
2001 goto errio;
2067 } 2002 }
2003
2068 return 0; 2004 return 0;
2005errio:
2006 iounmap(saa->saa7146_mem);
2007err:
2008 return retval;
2069} 2009}
2070 2010
2071static int init_saa7146(int i) 2011static int __devinit init_saa7146(struct pci_dev *pdev)
2072{ 2012{
2073 struct saa7146 *saa = &saa7146s[i]; 2013 struct saa7146 *saa = pci_get_drvdata(pdev);
2074 2014
2015 memset(saa, 0, sizeof(*saa));
2075 saa->user = 0; 2016 saa->user = 0;
2076 /* reset the saa7146 */ 2017 /* reset the saa7146 */
2077 saawrite(0xffff0000, SAA7146_MC1); 2018 saawrite(0xffff0000, SAA7146_MC1);
@@ -2089,23 +2030,23 @@ static int init_saa7146(int i)
2089 saawrite(0x00000000, SAA7146_DD1_STREAM_A); 2030 saawrite(0x00000000, SAA7146_DD1_STREAM_A);
2090 saawrite(0x00000000, SAA7146_BRS_CTRL); 2031 saawrite(0x00000000, SAA7146_BRS_CTRL);
2091 saawrite(0x80400040, SAA7146_BCS_CTRL); 2032 saawrite(0x80400040, SAA7146_BCS_CTRL);
2092 saawrite(0x0000e000 /*| (1<<29)*/, SAA7146_HPS_CTRL); 2033 saawrite(0x0000e000 /*| (1<<29) */ , SAA7146_HPS_CTRL);
2093 saawrite(0x00000060, SAA7146_CLIP_FORMAT_CTRL); 2034 saawrite(0x00000060, SAA7146_CLIP_FORMAT_CTRL);
2094 saawrite(0x00000000, SAA7146_ACON1); 2035 saawrite(0x00000000, SAA7146_ACON1);
2095 saawrite(0x00000000, SAA7146_ACON2); 2036 saawrite(0x00000000, SAA7146_ACON2);
2096 saawrite(0x00000600, SAA7146_I2C_STATUS); 2037 saawrite(0x00000600, SAA7146_I2C_STATUS);
2097 saawrite(((SAA7146_MC2_UPLD_D1_B | SAA7146_MC2_UPLD_D1_A | 2038 saawrite(((SAA7146_MC2_UPLD_D1_B | SAA7146_MC2_UPLD_D1_A |
2098 SAA7146_MC2_UPLD_BRS | SAA7146_MC2_UPLD_HPS_H | 2039 SAA7146_MC2_UPLD_BRS | SAA7146_MC2_UPLD_HPS_H |
2099 SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_DMA2 | 2040 SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_DMA2 |
2100 SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_I2C) << 16) | 0xffff, 2041 SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_I2C) << 16) | 0xffff,
2101 SAA7146_MC2); 2042 SAA7146_MC2);
2102 /* setup arbitration control registers */ 2043 /* setup arbitration control registers */
2103 saawrite(0x1412121a, SAA7146_PCI_BT_V1); 2044 saawrite(0x1412121a, SAA7146_PCI_BT_V1);
2104 2045
2105 /* allocate 32k dma buffer + 4k for page table */ 2046 /* allocate 32k dma buffer + 4k for page table */
2106 if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) { 2047 if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
2107 printk(KERN_ERR "stradis%d: debi kmalloc failed\n", i); 2048 dev_err(&pdev->dev, "%d: debi kmalloc failed\n", saa->nr);
2108 return -1; 2049 goto err;
2109 } 2050 }
2110#if 0 2051#if 0
2111 saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */ 2052 saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */
@@ -2115,133 +2056,162 @@ static int init_saa7146(int i)
2115#endif 2056#endif
2116 saa->audhead = saa->vidhead = saa->osdhead = 0; 2057 saa->audhead = saa->vidhead = saa->osdhead = 0;
2117 saa->audtail = saa->vidtail = saa->osdtail = 0; 2058 saa->audtail = saa->vidtail = saa->osdtail = 0;
2118 if (saa->vidbuf == NULL) 2059 if (saa->vidbuf == NULL && (saa->vidbuf = vmalloc(524288)) == NULL) {
2119 if ((saa->vidbuf = vmalloc(524288)) == NULL) { 2060 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2120 printk(KERN_ERR "stradis%d: malloc failed\n", saa->nr); 2061 goto err;
2121 return -ENOMEM; 2062 }
2122 } 2063 if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
2123 if (saa->audbuf == NULL) 2064 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2124 if ((saa->audbuf = vmalloc(65536)) == NULL) { 2065 goto errvid;
2125 printk(KERN_ERR "stradis%d: malloc failed\n", saa->nr); 2066 }
2126 vfree(saa->vidbuf); 2067 if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
2127 saa->vidbuf = NULL; 2068 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2128 return -ENOMEM; 2069 goto erraud;
2129 } 2070 }
2130 if (saa->osdbuf == NULL)
2131 if ((saa->osdbuf = vmalloc(131072)) == NULL) {
2132 printk(KERN_ERR "stradis%d: malloc failed\n", saa->nr);
2133 vfree(saa->vidbuf);
2134 vfree(saa->audbuf);
2135 saa->vidbuf = saa->audbuf = NULL;
2136 return -ENOMEM;
2137 }
2138 /* allocate 81920 byte buffer for clipping */ 2071 /* allocate 81920 byte buffer for clipping */
2139 if ((saa->dmavid2 = kmalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) { 2072 if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
2140 printk(KERN_ERR "stradis%d: clip kmalloc failed\n", saa->nr); 2073 dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
2141 vfree(saa->vidbuf); 2074 goto errosd;
2142 vfree(saa->audbuf);
2143 vfree(saa->osdbuf);
2144 saa->vidbuf = saa->audbuf = saa->osdbuf = NULL;
2145 saa->dmavid2 = NULL;
2146 return -1;
2147 } 2075 }
2148 memset(saa->dmavid2, 0x00, VIDEO_CLIPMAP_SIZE); /* clip everything */
2149 /* setup clipping registers */ 2076 /* setup clipping registers */
2150 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2); 2077 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
2151 saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2); 2078 saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
2152 saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE, 2079 saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE,
2153 SAA7146_PROT_ADDR2); 2080 SAA7146_PROT_ADDR2);
2154 saawrite(256, SAA7146_PITCH2); 2081 saawrite(256, SAA7146_PITCH2);
2155 saawrite(4, SAA7146_PAGE2); /* dma direction: read, no byteswap */ 2082 saawrite(4, SAA7146_PAGE2); /* dma direction: read, no byteswap */
2156 saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2, 2083 saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2,
2157 SAA7146_MC2); 2084 SAA7146_MC2);
2158 I2CBusScan(saa); 2085 I2CBusScan(saa);
2086
2159 return 0; 2087 return 0;
2088errosd:
2089 vfree(saa->osdbuf);
2090 saa->osdbuf = NULL;
2091erraud:
2092 vfree(saa->audbuf);
2093 saa->audbuf = NULL;
2094errvid:
2095 vfree(saa->vidbuf);
2096 saa->vidbuf = NULL;
2097err:
2098 return -ENOMEM;
2160} 2099}
2161 2100
2162static void release_saa(void) 2101static void stradis_release_saa(struct pci_dev *pdev)
2163{ 2102{
2164 u8 command; 2103 u8 command;
2165 int i; 2104 struct saa7146 *saa = pci_get_drvdata(pdev);
2166 struct saa7146 *saa;
2167 2105
2168 for (i = 0; i < saa_num; i++) { 2106 /* turn off all capturing, DMA and IRQs */
2169 saa = &saa7146s[i]; 2107 saawrite(0xffff0000, SAA7146_MC1); /* reset chip */
2108 saawrite(0, SAA7146_MC2);
2109 saawrite(0, SAA7146_IER);
2110 saawrite(0xffffffffUL, SAA7146_ISR);
2111
2112 /* disable PCI bus-mastering */
2113 pci_read_config_byte(pdev, PCI_COMMAND, &command);
2114 command &= ~PCI_COMMAND_MASTER;
2115 pci_write_config_byte(pdev, PCI_COMMAND, command);
2116
2117 /* unmap and free memory */
2118 saa->audhead = saa->audtail = saa->osdhead = 0;
2119 saa->vidhead = saa->vidtail = saa->osdtail = 0;
2120 vfree(saa->vidbuf);
2121 vfree(saa->audbuf);
2122 vfree(saa->osdbuf);
2123 kfree(saa->dmavid2);
2124 saa->audbuf = saa->vidbuf = saa->osdbuf = NULL;
2125 saa->dmavid2 = NULL;
2126 kfree(saa->dmadebi);
2127 kfree(saa->dmavid1);
2128 kfree(saa->dmavid3);
2129 kfree(saa->dmaa1in);
2130 kfree(saa->dmaa1out);
2131 kfree(saa->dmaa2in);
2132 kfree(saa->dmaa2out);
2133 kfree(saa->dmaRPS1);
2134 kfree(saa->dmaRPS2);
2135 free_irq(saa->irq, saa);
2136 if (saa->saa7146_mem)
2137 iounmap(saa->saa7146_mem);
2138 if (saa->video_dev.minor != -1)
2139 video_unregister_device(&saa->video_dev);
2140}
2170 2141
2171 /* turn off all capturing, DMA and IRQs */ 2142static int __devinit stradis_probe(struct pci_dev *pdev,
2172 saawrite(0xffff0000, SAA7146_MC1); /* reset chip */ 2143 const struct pci_device_id *ent)
2173 saawrite(0, SAA7146_MC2); 2144{
2174 saawrite(0, SAA7146_IER); 2145 int retval = -EINVAL;
2175 saawrite(0xffffffffUL, SAA7146_ISR); 2146
2176 2147 if (saa_num >= SAA7146_MAX)
2177 /* disable PCI bus-mastering */ 2148 goto err;
2178 pci_read_config_byte(saa->dev, PCI_COMMAND, &command); 2149
2179 command &= ~PCI_COMMAND_MASTER; 2150 if (!pdev->subsystem_vendor)
2180 pci_write_config_byte(saa->dev, PCI_COMMAND, command); 2151 dev_info(&pdev->dev, "%d: rev1 decoder\n", saa_num);
2181 2152 else
2182 /* unmap and free memory */ 2153 dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num);
2183 saa->audhead = saa->audtail = saa->osdhead = 0; 2154
2184 saa->vidhead = saa->vidtail = saa->osdtail = 0; 2155 pci_set_drvdata(pdev, &saa7146s[saa_num]);
2185 vfree(saa->vidbuf); 2156
2186 vfree(saa->audbuf); 2157 retval = configure_saa7146(pdev, saa_num);
2187 vfree(saa->osdbuf); 2158 if (retval) {
2188 kfree(saa->dmavid2); 2159 dev_err(&pdev->dev, "%d: error in configuring\n", saa_num);
2189 saa->audbuf = saa->vidbuf = saa->osdbuf = NULL; 2160 goto err;
2190 saa->dmavid2 = NULL; 2161 }
2191 kfree(saa->dmadebi); 2162
2192 kfree(saa->dmavid1); 2163 if (init_saa7146(pdev) < 0) {
2193 kfree(saa->dmavid3); 2164 dev_err(&pdev->dev, "%d: error in initialization\n", saa_num);
2194 kfree(saa->dmaa1in); 2165 retval = -EIO;
2195 kfree(saa->dmaa1out); 2166 goto errrel;
2196 kfree(saa->dmaa2in);
2197 kfree(saa->dmaa2out);
2198 kfree(saa->dmaRPS1);
2199 kfree(saa->dmaRPS2);
2200 free_irq(saa->irq, saa);
2201 if (saa->saa7146_mem)
2202 iounmap(saa->saa7146_mem);
2203 if (saa->video_dev.minor != -1)
2204 video_unregister_device(&saa->video_dev);
2205 } 2167 }
2168
2169 saa_num++;
2170
2171 return 0;
2172errrel:
2173 stradis_release_saa(pdev);
2174err:
2175 return retval;
2176}
2177
2178static void __devexit stradis_remove(struct pci_dev *pdev)
2179{
2180 stradis_release_saa(pdev);
2206} 2181}
2207 2182
2183static struct pci_device_id stradis_pci_tbl[] = {
2184 { PCI_DEVICE(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146) },
2185 { 0 }
2186};
2187
2188MODULE_DEVICE_TABLE(pci, stradis_pci_tbl);
2189
2190static struct pci_driver stradis_driver = {
2191 .name = "stradis",
2192 .id_table = stradis_pci_tbl,
2193 .probe = stradis_probe,
2194 .remove = __devexit_p(stradis_remove)
2195};
2208 2196
2209static int __init stradis_init (void) 2197int __init stradis_init(void)
2210{ 2198{
2211 struct pci_dev *dev = NULL; 2199 int retval;
2212 int result = 0, i;
2213 2200
2214 saa_num = 0; 2201 saa_num = 0;
2215 2202
2216 while ((dev = pci_find_device(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, dev))) { 2203 retval = pci_register_driver(&stradis_driver);
2217 if (!dev->subsystem_vendor) 2204 if (retval)
2218 printk(KERN_INFO "stradis%d: rev1 decoder\n", saa_num); 2205 printk(KERN_ERR "stradis: Unable to register pci driver.\n");
2219 else
2220 printk(KERN_INFO "stradis%d: SDM2xx found\n", saa_num);
2221 result = configure_saa7146(dev, saa_num++);
2222 if (result)
2223 return result;
2224 }
2225 if (saa_num)
2226 printk(KERN_INFO "stradis: %d card(s) found.\n", saa_num);
2227 else
2228 return -EINVAL;
2229 for (i = 0; i < saa_num; i++)
2230 if (init_saa7146(i) < 0) {
2231 release_saa();
2232 return -EIO;
2233 }
2234 return 0;
2235}
2236 2206
2207 return retval;
2208}
2237 2209
2238static void __exit stradis_exit (void) 2210void __exit stradis_exit(void)
2239{ 2211{
2240 release_saa(); 2212 pci_unregister_driver(&stradis_driver);
2241 printk(KERN_INFO "stradis: module cleanup complete\n"); 2213 printk(KERN_INFO "stradis: module cleanup complete\n");
2242} 2214}
2243 2215
2244
2245module_init(stradis_init); 2216module_init(stradis_init);
2246module_exit(stradis_exit); 2217module_exit(stradis_exit);
2247
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 99261f15e66e..fc3d5824efff 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -227,8 +227,8 @@ static struct i2c_client client_template;
227static int tda7432_write(struct i2c_client *client, int subaddr, int val) 227static int tda7432_write(struct i2c_client *client, int subaddr, int val)
228{ 228{
229 unsigned char buffer[2]; 229 unsigned char buffer[2];
230 v4l_dbg(2,client,"In tda7432_write\n"); 230 v4l_dbg(2, debug,client,"In tda7432_write\n");
231 v4l_dbg(1,client,"Writing %d 0x%x\n", subaddr, val); 231 v4l_dbg(1, debug,client,"Writing %d 0x%x\n", subaddr, val);
232 buffer[0] = subaddr; 232 buffer[0] = subaddr;
233 buffer[1] = val; 233 buffer[1] = val;
234 if (2 != i2c_master_send(client,buffer,2)) { 234 if (2 != i2c_master_send(client,buffer,2)) {
@@ -245,9 +245,9 @@ static int tda7432_set(struct i2c_client *client)
245{ 245{
246 struct tda7432 *t = i2c_get_clientdata(client); 246 struct tda7432 *t = i2c_get_clientdata(client);
247 unsigned char buf[16]; 247 unsigned char buf[16];
248 v4l_dbg(2,client,"In tda7432_set\n"); 248 v4l_dbg(2, debug,client,"In tda7432_set\n");
249 249
250 v4l_dbg(1,client, 250 v4l_dbg(1, debug,client,
251 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n", 251 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
252 t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud); 252 t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud);
253 buf[0] = TDA7432_IN; 253 buf[0] = TDA7432_IN;
@@ -271,7 +271,7 @@ static int tda7432_set(struct i2c_client *client)
271static void do_tda7432_init(struct i2c_client *client) 271static void do_tda7432_init(struct i2c_client *client)
272{ 272{
273 struct tda7432 *t = i2c_get_clientdata(client); 273 struct tda7432 *t = i2c_get_clientdata(client);
274 v4l_dbg(2,client,"In tda7432_init\n"); 274 v4l_dbg(2, debug,client,"In tda7432_init\n");
275 275
276 t->input = TDA7432_STEREO_IN | /* Main (stereo) input */ 276 t->input = TDA7432_STEREO_IN | /* Main (stereo) input */
277 TDA7432_BASS_SYM | /* Symmetric bass cut */ 277 TDA7432_BASS_SYM | /* Symmetric bass cut */
@@ -300,10 +300,9 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
300 struct tda7432 *t; 300 struct tda7432 *t;
301 struct i2c_client *client; 301 struct i2c_client *client;
302 302
303 t = kmalloc(sizeof *t,GFP_KERNEL); 303 t = kzalloc(sizeof *t,GFP_KERNEL);
304 if (!t) 304 if (!t)
305 return -ENOMEM; 305 return -ENOMEM;
306 memset(t,0,sizeof *t);
307 306
308 client = &t->c; 307 client = &t->c;
309 memcpy(client,&client_template,sizeof(struct i2c_client)); 308 memcpy(client,&client_template,sizeof(struct i2c_client));
@@ -340,7 +339,7 @@ static int tda7432_command(struct i2c_client *client,
340 unsigned int cmd, void *arg) 339 unsigned int cmd, void *arg)
341{ 340{
342 struct tda7432 *t = i2c_get_clientdata(client); 341 struct tda7432 *t = i2c_get_clientdata(client);
343 v4l_dbg(2,client,"In tda7432_command\n"); 342 v4l_dbg(2, debug,client,"In tda7432_command\n");
344 if (debug>1) 343 if (debug>1)
345 v4l_i2c_print_ioctl(client,cmd); 344 v4l_i2c_print_ioctl(client,cmd);
346 345
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 299393bf900a..ef98c4982250 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -232,10 +232,9 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
232 struct i2c_client *client; 232 struct i2c_client *client;
233 dprintk("In tda9875_attach\n"); 233 dprintk("In tda9875_attach\n");
234 234
235 t = kmalloc(sizeof *t,GFP_KERNEL); 235 t = kzalloc(sizeof *t,GFP_KERNEL);
236 if (!t) 236 if (!t)
237 return -ENOMEM; 237 return -ENOMEM;
238 memset(t,0,sizeof *t);
239 238
240 client = &t->c; 239 client = &t->c;
241 memcpy(client,&client_template,sizeof(struct i2c_client)); 240 memcpy(client,&client_template,sizeof(struct i2c_client));
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 9cf47dc65579..5815649bdc78 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -696,9 +696,8 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
696 client_template.adapter = adap; 696 client_template.adapter = adap;
697 client_template.addr = addr; 697 client_template.addr = addr;
698 698
699 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 699 if (NULL == (t = kzalloc(sizeof(*t), GFP_KERNEL)))
700 return -ENOMEM; 700 return -ENOMEM;
701 memset(t,0,sizeof(*t));
702 701
703 t->client = client_template; 702 t->client = client_template;
704 t->std = 0; 703 t->std = 0;
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index 261b7a3c0417..921fe72f23d5 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -18,7 +18,7 @@
18#define PREFIX "TEA5767 " 18#define PREFIX "TEA5767 "
19 19
20/* from tuner-core.c */ 20/* from tuner-core.c */
21extern int debug; 21extern int tuner_debug;
22 22
23/*****************************************************************************/ 23/*****************************************************************************/
24 24
@@ -249,7 +249,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
249 if (5 != (rc = i2c_master_send(c, buffer, 5))) 249 if (5 != (rc = i2c_master_send(c, buffer, 5)))
250 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 250 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
251 251
252 if (debug) { 252 if (tuner_debug) {
253 if (5 != (rc = i2c_master_recv(c, buffer, 5))) 253 if (5 != (rc = i2c_master_recv(c, buffer, 5)))
254 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 254 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
255 else 255 else
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index c4ba3742f5c7..4dcba5a4fff0 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -99,11 +99,10 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
99 } 99 }
100 100
101 /* allocate memory for client structure */ 101 /* allocate memory for client structure */
102 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 102 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
103 if (0 == client) { 103 if (0 == client) {
104 return -ENOMEM; 104 return -ENOMEM;
105 } 105 }
106 memset(client, 0x0, sizeof(struct i2c_client));
107 106
108 /* fill client structure */ 107 /* fill client structure */
109 memcpy(client, &client_template, sizeof(struct i2c_client)); 108 memcpy(client, &client_template, sizeof(struct i2c_client));
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index d97f66804c37..c4a78e7a5a58 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -193,8 +193,7 @@ static struct i2c_client client_template =
193static int __init 193static int __init
194tuner3036_init(void) 194tuner3036_init(void)
195{ 195{
196 i2c_add_driver(&i2c_driver_tuner); 196 return i2c_add_driver(&i2c_driver_tuner);
197 return 0;
198} 197}
199 198
200static void __exit 199static void __exit
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 57bc585a6955..f30ef79d795e 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -41,8 +41,8 @@ static unsigned int no_autodetect = 0;
41static unsigned int show_i2c = 0; 41static unsigned int show_i2c = 0;
42 42
43/* insmod options used at runtime => read/write */ 43/* insmod options used at runtime => read/write */
44static unsigned int tuner_debug = 0; 44static unsigned int tuner_debug_old = 0;
45int debug = 0; 45int tuner_debug = 0;
46 46
47static unsigned int tv_range[2] = { 44, 958 }; 47static unsigned int tv_range[2] = { 44, 958 };
48static unsigned int radio_range[2] = { 65, 108 }; 48static unsigned int radio_range[2] = { 65, 108 };
@@ -51,13 +51,13 @@ static char pal[] = "--";
51static char secam[] = "--"; 51static char secam[] = "--";
52static char ntsc[] = "-"; 52static char ntsc[] = "-";
53 53
54
54module_param(addr, int, 0444); 55module_param(addr, int, 0444);
55module_param(no_autodetect, int, 0444); 56module_param(no_autodetect, int, 0444);
56module_param(show_i2c, int, 0444); 57module_param(show_i2c, int, 0444);
57/* Note: tuner_debug is deprecated and will be removed in 2.6.17 */ 58/* Note: tuner_debug is deprecated and will be removed in 2.6.17 */
58module_param(tuner_debug, int, 0444); 59module_param_named(tuner_debug,tuner_debug_old, int, 0444);
59module_param(debug, int, 0644); 60module_param_named(debug,tuner_debug, int, 0644);
60
61module_param_string(pal, pal, sizeof(pal), 0644); 61module_param_string(pal, pal, sizeof(pal), 0644);
62module_param_string(secam, secam, sizeof(secam), 0644); 62module_param_string(secam, secam, sizeof(secam), 0644);
63module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); 63module_param_string(ntsc, ntsc, sizeof(ntsc), 0644);
@@ -410,18 +410,17 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
410 client_template.adapter = adap; 410 client_template.adapter = adap;
411 client_template.addr = addr; 411 client_template.addr = addr;
412 412
413 t = kmalloc(sizeof(struct tuner), GFP_KERNEL); 413 t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
414 if (NULL == t) 414 if (NULL == t)
415 return -ENOMEM; 415 return -ENOMEM;
416 memset(t, 0, sizeof(struct tuner));
417 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); 416 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client));
418 i2c_set_clientdata(&t->i2c, t); 417 i2c_set_clientdata(&t->i2c, t);
419 t->type = UNSET; 418 t->type = UNSET;
420 t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ 419 t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
421 t->audmode = V4L2_TUNER_MODE_STEREO; 420 t->audmode = V4L2_TUNER_MODE_STEREO;
422 t->mode_mask = T_UNINITIALIZED; 421 t->mode_mask = T_UNINITIALIZED;
423 if (tuner_debug) { 422 if (tuner_debug_old) {
424 debug = tuner_debug; 423 tuner_debug = tuner_debug_old;
425 printk(KERN_ERR "tuner: tuner_debug is deprecated and will be removed in 2.6.17.\n"); 424 printk(KERN_ERR "tuner: tuner_debug is deprecated and will be removed in 2.6.17.\n");
426 printk(KERN_ERR "tuner: use the debug option instead.\n"); 425 printk(KERN_ERR "tuner: use the debug option instead.\n");
427 } 426 }
@@ -552,7 +551,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
552{ 551{
553 struct tuner *t = i2c_get_clientdata(client); 552 struct tuner *t = i2c_get_clientdata(client);
554 553
555 if (debug>1) 554 if (tuner_debug>1)
556 v4l_i2c_print_ioctl(&(t->i2c),cmd); 555 v4l_i2c_print_ioctl(&(t->i2c),cmd);
557 556
558 switch (cmd) { 557 switch (cmd) {
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index b582943a0d3e..6d03b9b05c6e 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -159,7 +159,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
159 unsigned char buffer[2]; 159 unsigned char buffer[2];
160 160
161 if (-1 == subaddr) { 161 if (-1 == subaddr) {
162 v4l_dbg(1, &chip->c, "%s: chip_write: 0x%x\n", 162 v4l_dbg(1, debug, &chip->c, "%s: chip_write: 0x%x\n",
163 chip->c.name, val); 163 chip->c.name, val);
164 chip->shadow.bytes[1] = val; 164 chip->shadow.bytes[1] = val;
165 buffer[0] = val; 165 buffer[0] = val;
@@ -169,7 +169,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
169 return -1; 169 return -1;
170 } 170 }
171 } else { 171 } else {
172 v4l_dbg(1, &chip->c, "%s: chip_write: reg%d=0x%x\n", 172 v4l_dbg(1, debug, &chip->c, "%s: chip_write: reg%d=0x%x\n",
173 chip->c.name, subaddr, val); 173 chip->c.name, subaddr, val);
174 chip->shadow.bytes[subaddr+1] = val; 174 chip->shadow.bytes[subaddr+1] = val;
175 buffer[0] = subaddr; 175 buffer[0] = subaddr;
@@ -204,7 +204,7 @@ static int chip_read(struct CHIPSTATE *chip)
204 chip->c.name); 204 chip->c.name);
205 return -1; 205 return -1;
206 } 206 }
207 v4l_dbg(1, &chip->c, "%s: chip_read: 0x%x\n",chip->c.name, buffer); 207 v4l_dbg(1, debug, &chip->c, "%s: chip_read: 0x%x\n",chip->c.name, buffer);
208 return buffer; 208 return buffer;
209} 209}
210 210
@@ -222,7 +222,7 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr)
222 v4l_warn(&chip->c, "%s: I/O error (read2)\n", chip->c.name); 222 v4l_warn(&chip->c, "%s: I/O error (read2)\n", chip->c.name);
223 return -1; 223 return -1;
224 } 224 }
225 v4l_dbg(1, &chip->c, "%s: chip_read2: reg%d=0x%x\n", 225 v4l_dbg(1, debug, &chip->c, "%s: chip_read2: reg%d=0x%x\n",
226 chip->c.name, subaddr,read[0]); 226 chip->c.name, subaddr,read[0]);
227 return read[0]; 227 return read[0];
228} 228}
@@ -235,7 +235,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
235 return 0; 235 return 0;
236 236
237 /* update our shadow register set; print bytes if (debug > 0) */ 237 /* update our shadow register set; print bytes if (debug > 0) */
238 v4l_dbg(1, &chip->c, "%s: chip_cmd(%s): reg=%d, data:", 238 v4l_dbg(1, debug, &chip->c, "%s: chip_cmd(%s): reg=%d, data:",
239 chip->c.name, name,cmd->bytes[0]); 239 chip->c.name, name,cmd->bytes[0]);
240 for (i = 1; i < cmd->count; i++) { 240 for (i = 1; i < cmd->count; i++) {
241 if (debug) 241 if (debug)
@@ -274,7 +274,7 @@ static int chip_thread(void *data)
274 274
275 daemonize("%s", chip->c.name); 275 daemonize("%s", chip->c.name);
276 allow_signal(SIGTERM); 276 allow_signal(SIGTERM);
277 v4l_dbg(1, &chip->c, "%s: thread started\n", chip->c.name); 277 v4l_dbg(1, debug, &chip->c, "%s: thread started\n", chip->c.name);
278 278
279 for (;;) { 279 for (;;) {
280 add_wait_queue(&chip->wq, &wait); 280 add_wait_queue(&chip->wq, &wait);
@@ -286,7 +286,7 @@ static int chip_thread(void *data)
286 try_to_freeze(); 286 try_to_freeze();
287 if (chip->done || signal_pending(current)) 287 if (chip->done || signal_pending(current))
288 break; 288 break;
289 v4l_dbg(1, &chip->c, "%s: thread wakeup\n", chip->c.name); 289 v4l_dbg(1, debug, &chip->c, "%s: thread wakeup\n", chip->c.name);
290 290
291 /* don't do anything for radio or if mode != auto */ 291 /* don't do anything for radio or if mode != auto */
292 if (chip->radio || chip->mode != 0) 292 if (chip->radio || chip->mode != 0)
@@ -299,7 +299,7 @@ static int chip_thread(void *data)
299 mod_timer(&chip->wt, jiffies+2*HZ); 299 mod_timer(&chip->wt, jiffies+2*HZ);
300 } 300 }
301 301
302 v4l_dbg(1, &chip->c, "%s: thread exiting\n", chip->c.name); 302 v4l_dbg(1, debug, &chip->c, "%s: thread exiting\n", chip->c.name);
303 complete_and_exit(&chip->texit, 0); 303 complete_and_exit(&chip->texit, 0);
304 return 0; 304 return 0;
305} 305}
@@ -312,7 +312,7 @@ static void generic_checkmode(struct CHIPSTATE *chip)
312 if (mode == chip->prevmode) 312 if (mode == chip->prevmode)
313 return; 313 return;
314 314
315 v4l_dbg(1, &chip->c, "%s: thread checkmode\n", chip->c.name); 315 v4l_dbg(1, debug, &chip->c, "%s: thread checkmode\n", chip->c.name);
316 chip->prevmode = mode; 316 chip->prevmode = mode;
317 317
318 if (mode & VIDEO_SOUND_STEREO) 318 if (mode & VIDEO_SOUND_STEREO)
@@ -359,7 +359,7 @@ static int tda9840_getmode(struct CHIPSTATE *chip)
359 if (val & TDA9840_ST_STEREO) 359 if (val & TDA9840_ST_STEREO)
360 mode |= VIDEO_SOUND_STEREO; 360 mode |= VIDEO_SOUND_STEREO;
361 361
362 v4l_dbg(1, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n", 362 v4l_dbg(1, debug, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n",
363 val, mode); 363 val, mode);
364 return mode; 364 return mode;
365} 365}
@@ -655,7 +655,7 @@ static int tda9873_getmode(struct CHIPSTATE *chip)
655 mode |= VIDEO_SOUND_STEREO; 655 mode |= VIDEO_SOUND_STEREO;
656 if (val & TDA9873_DUAL) 656 if (val & TDA9873_DUAL)
657 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 657 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
658 v4l_dbg(1, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n", 658 v4l_dbg(1, debug, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n",
659 val, mode); 659 val, mode);
660 return mode; 660 return mode;
661} 661}
@@ -666,12 +666,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
666 /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ 666 /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */
667 667
668 if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { 668 if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) {
669 v4l_dbg(1, &chip->c, "tda9873_setmode(): external input\n"); 669 v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): external input\n");
670 return; 670 return;
671 } 671 }
672 672
673 v4l_dbg(1, &chip->c, "tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); 673 v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]);
674 v4l_dbg(1, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); 674 v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data);
675 675
676 switch (mode) { 676 switch (mode) {
677 case VIDEO_SOUND_MONO: 677 case VIDEO_SOUND_MONO:
@@ -692,7 +692,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
692 } 692 }
693 693
694 chip_write(chip, TDA9873_SW, sw_data); 694 chip_write(chip, TDA9873_SW, sw_data);
695 v4l_dbg(1, &chip->c, "tda9873_setmode(): req. mode %d; chip_write: %d\n", 695 v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): req. mode %d; chip_write: %d\n",
696 mode, sw_data); 696 mode, sw_data);
697} 697}
698 698
@@ -831,7 +831,7 @@ static int tda9874a_setup(struct CHIPSTATE *chip)
831 chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); 831 chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80);
832 chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ 832 chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */
833 } 833 }
834 v4l_dbg(1, &chip->c, "tda9874a_setup(): %s [0x%02X].\n", 834 v4l_dbg(1, debug, &chip->c, "tda9874a_setup(): %s [0x%02X].\n",
835 tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); 835 tda9874a_modelist[tda9874a_STD].name,tda9874a_STD);
836 return 1; 836 return 1;
837} 837}
@@ -874,7 +874,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip)
874 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 874 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
875 } 875 }
876 876
877 v4l_dbg(1, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", 877 v4l_dbg(1, debug, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n",
878 dsr, nsr, necr, mode); 878 dsr, nsr, necr, mode);
879 return mode; 879 return mode;
880} 880}
@@ -920,7 +920,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
920 chip_write(chip, TDA9874A_AOSR, aosr); 920 chip_write(chip, TDA9874A_AOSR, aosr);
921 chip_write(chip, TDA9874A_MDACOSR, mdacosr); 921 chip_write(chip, TDA9874A_MDACOSR, mdacosr);
922 922
923 v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", 923 v4l_dbg(1, debug, &chip->c, "tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n",
924 mode, aosr, mdacosr); 924 mode, aosr, mdacosr);
925 925
926 } else { /* dic == 0x07 */ 926 } else { /* dic == 0x07 */
@@ -955,7 +955,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
955 chip_write(chip, TDA9874A_FMMR, fmmr); 955 chip_write(chip, TDA9874A_FMMR, fmmr);
956 chip_write(chip, TDA9874A_AOSR, aosr); 956 chip_write(chip, TDA9874A_AOSR, aosr);
957 957
958 v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", 958 v4l_dbg(1, debug, &chip->c, "tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n",
959 mode, fmmr, aosr); 959 mode, fmmr, aosr);
960 } 960 }
961} 961}
@@ -969,7 +969,7 @@ static int tda9874a_checkit(struct CHIPSTATE *chip)
969 if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) 969 if(-1 == (sic = chip_read2(chip,TDA9874A_SIC)))
970 return 0; 970 return 0;
971 971
972 v4l_dbg(1, &chip->c, "tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); 972 v4l_dbg(1, debug, &chip->c, "tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic);
973 973
974 if((dic == 0x11)||(dic == 0x07)) { 974 if((dic == 0x11)||(dic == 0x07)) {
975 v4l_info(&chip->c, "found tda9874%s.\n", (dic == 0x11) ? "a":"h"); 975 v4l_info(&chip->c, "found tda9874%s.\n", (dic == 0x11) ? "a":"h");
@@ -1184,7 +1184,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip)
1184 }else if (!(val & TA8874Z_B0)){ 1184 }else if (!(val & TA8874Z_B0)){
1185 mode |= VIDEO_SOUND_STEREO; 1185 mode |= VIDEO_SOUND_STEREO;
1186 } 1186 }
1187 /* v4l_dbg(1, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ 1187 /* v4l_dbg(1, debug, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */
1188 return mode; 1188 return mode;
1189} 1189}
1190 1190
@@ -1197,7 +1197,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode)
1197{ 1197{
1198 int update = 1; 1198 int update = 1;
1199 audiocmd *t = NULL; 1199 audiocmd *t = NULL;
1200 v4l_dbg(1, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); 1200 v4l_dbg(1, debug, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode);
1201 1201
1202 switch(mode){ 1202 switch(mode){
1203 case VIDEO_SOUND_MONO: 1203 case VIDEO_SOUND_MONO:
@@ -1468,17 +1468,16 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1468 struct CHIPSTATE *chip; 1468 struct CHIPSTATE *chip;
1469 struct CHIPDESC *desc; 1469 struct CHIPDESC *desc;
1470 1470
1471 chip = kmalloc(sizeof(*chip),GFP_KERNEL); 1471 chip = kzalloc(sizeof(*chip),GFP_KERNEL);
1472 if (!chip) 1472 if (!chip)
1473 return -ENOMEM; 1473 return -ENOMEM;
1474 memset(chip,0,sizeof(*chip));
1475 memcpy(&chip->c,&client_template,sizeof(struct i2c_client)); 1474 memcpy(&chip->c,&client_template,sizeof(struct i2c_client));
1476 chip->c.adapter = adap; 1475 chip->c.adapter = adap;
1477 chip->c.addr = addr; 1476 chip->c.addr = addr;
1478 i2c_set_clientdata(&chip->c, chip); 1477 i2c_set_clientdata(&chip->c, chip);
1479 1478
1480 /* find description for the chip */ 1479 /* find description for the chip */
1481 v4l_dbg(1, &chip->c, "chip found @ 0x%x\n", addr<<1); 1480 v4l_dbg(1, debug, &chip->c, "chip found @ 0x%x\n", addr<<1);
1482 for (desc = chiplist; desc->name != NULL; desc++) { 1481 for (desc = chiplist; desc->name != NULL; desc++) {
1483 if (0 == *(desc->insmodopt)) 1482 if (0 == *(desc->insmodopt))
1484 continue; 1483 continue;
@@ -1490,12 +1489,12 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1490 break; 1489 break;
1491 } 1490 }
1492 if (desc->name == NULL) { 1491 if (desc->name == NULL) {
1493 v4l_dbg(1, &chip->c, "no matching chip description found\n"); 1492 v4l_dbg(1, debug, &chip->c, "no matching chip description found\n");
1494 return -EIO; 1493 return -EIO;
1495 } 1494 }
1496 v4l_info(&chip->c, "%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); 1495 v4l_info(&chip->c, "%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name);
1497 if (desc->flags) { 1496 if (desc->flags) {
1498 v4l_dbg(1, &chip->c, "matches:%s%s%s.\n", 1497 v4l_dbg(1, debug, &chip->c, "matches:%s%s%s.\n",
1499 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", 1498 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "",
1500 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", 1499 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "",
1501 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); 1500 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
@@ -1583,7 +1582,7 @@ static int chip_command(struct i2c_client *client,
1583 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1582 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1584 struct CHIPDESC *desc = chiplist + chip->type; 1583 struct CHIPDESC *desc = chiplist + chip->type;
1585 1584
1586 v4l_dbg(1, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd); 1585 v4l_dbg(1, debug, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd);
1587 1586
1588 switch (cmd) { 1587 switch (cmd) {
1589 case AUDC_SET_INPUT: 1588 case AUDC_SET_INPUT:
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index fd0acc5da667..5e71a354e879 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -719,8 +719,7 @@ tveeprom_command(struct i2c_client *client,
719 719
720 switch (cmd) { 720 switch (cmd) {
721 case 0: 721 case 0:
722 buf = kmalloc(256,GFP_KERNEL); 722 buf = kzalloc(256,GFP_KERNEL);
723 memset(buf,0,256);
724 tveeprom_read(client,buf,256); 723 tveeprom_read(client,buf,256);
725 tveeprom_hauppauge_analog(client, &eeprom,buf); 724 tveeprom_hauppauge_analog(client, &eeprom,buf);
726 kfree(buf); 725 kfree(buf);
@@ -743,10 +742,9 @@ tveeprom_detect_client(struct i2c_adapter *adapter,
743{ 742{
744 struct i2c_client *client; 743 struct i2c_client *client;
745 744
746 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 745 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
747 if (NULL == client) 746 if (NULL == client)
748 return -ENOMEM; 747 return -ENOMEM;
749 memset(client, 0, sizeof(struct i2c_client));
750 client->addr = address; 748 client->addr = address;
751 client->adapter = adapter; 749 client->adapter = adapter;
752 client->driver = &i2c_driver_tveeprom; 750 client->driver = &i2c_driver_tveeprom;
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index c35b8042eee5..e86b522938fd 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -1074,12 +1074,11 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
1074 return -ENOMEM; 1074 return -ENOMEM;
1075 memcpy(c, &client_template, sizeof(struct i2c_client)); 1075 memcpy(c, &client_template, sizeof(struct i2c_client));
1076 1076
1077 core = kmalloc(sizeof(struct tvp5150), GFP_KERNEL); 1077 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
1078 if (core == 0) { 1078 if (core == 0) {
1079 kfree(c); 1079 kfree(c);
1080 return -ENOMEM; 1080 return -ENOMEM;
1081 } 1081 }
1082 memset(core, 0, sizeof(struct tvp5150));
1083 i2c_set_clientdata(c, core); 1082 i2c_set_clientdata(c, core);
1084 1083
1085 rv = i2c_attach_client(c); 1084 rv = i2c_attach_client(c);
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 2ab5b4093800..474a29bc1760 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -305,9 +305,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
305 { 305 {
306 struct video_capability *cap = arg; 306 struct video_capability *cap = arg;
307 307
308 cap2 = kmalloc(sizeof(*cap2),GFP_KERNEL); 308 cap2 = kzalloc(sizeof(*cap2),GFP_KERNEL);
309 memset(cap, 0, sizeof(*cap)); 309 memset(cap, 0, sizeof(*cap));
310 memset(cap2, 0, sizeof(*cap2));
311 memset(&fbuf2, 0, sizeof(fbuf2)); 310 memset(&fbuf2, 0, sizeof(fbuf2));
312 311
313 err = drv(inode, file, VIDIOC_QUERYCAP, cap2); 312 err = drv(inode, file, VIDIOC_QUERYCAP, cap2);
@@ -422,9 +421,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
422 { 421 {
423 struct video_window *win = arg; 422 struct video_window *win = arg;
424 423
425 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 424 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
426 memset(win,0,sizeof(*win)); 425 memset(win,0,sizeof(*win));
427 memset(fmt2,0,sizeof(*fmt2));
428 426
429 fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 427 fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
430 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 428 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -461,8 +459,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
461 struct video_window *win = arg; 459 struct video_window *win = arg;
462 int err1,err2; 460 int err1,err2;
463 461
464 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 462 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
465 memset(fmt2,0,sizeof(*fmt2));
466 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 463 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
467 drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type); 464 drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type);
468 err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); 465 err1 = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -595,8 +592,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
595 pict->whiteness = get_v4l_control(inode, file, 592 pict->whiteness = get_v4l_control(inode, file,
596 V4L2_CID_WHITENESS, drv); 593 V4L2_CID_WHITENESS, drv);
597 594
598 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 595 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
599 memset(fmt2,0,sizeof(*fmt2));
600 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 596 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
601 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 597 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
602 if (err < 0) { 598 if (err < 0) {
@@ -622,8 +618,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
622 set_v4l_control(inode, file, 618 set_v4l_control(inode, file,
623 V4L2_CID_WHITENESS, pict->whiteness, drv); 619 V4L2_CID_WHITENESS, pict->whiteness, drv);
624 620
625 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 621 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
626 memset(fmt2,0,sizeof(*fmt2));
627 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 622 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
628 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 623 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
629 if (err < 0) 624 if (err < 0)
@@ -846,9 +841,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
846 { 841 {
847 struct video_mmap *mm = arg; 842 struct video_mmap *mm = arg;
848 843
849 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 844 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
850 memset(&buf2,0,sizeof(buf2)); 845 memset(&buf2,0,sizeof(buf2));
851 memset(fmt2,0,sizeof(*fmt2));
852 846
853 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 847 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
854 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 848 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -942,8 +936,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
942 { 936 {
943 struct vbi_format *fmt = arg; 937 struct vbi_format *fmt = arg;
944 938
945 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 939 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
946 memset(fmt2, 0, sizeof(*fmt2));
947 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 940 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
948 941
949 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 942 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -975,8 +968,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
975 break; 968 break;
976 } 969 }
977 970
978 fmt2 = kmalloc(sizeof(*fmt2),GFP_KERNEL); 971 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
979 memset(fmt2, 0, sizeof(*fmt2));
980 972
981 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 973 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
982 fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; 974 fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line;
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 9a6bf287e26a..9ef477523d27 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -52,10 +52,9 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
52 struct page *pg; 52 struct page *pg;
53 int i; 53 int i;
54 54
55 sglist = kmalloc(sizeof(struct scatterlist)*nr_pages, GFP_KERNEL); 55 sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL);
56 if (NULL == sglist) 56 if (NULL == sglist)
57 return NULL; 57 return NULL;
58 memset(sglist,0,sizeof(struct scatterlist)*nr_pages);
59 for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { 58 for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) {
60 pg = vmalloc_to_page(virt); 59 pg = vmalloc_to_page(virt);
61 if (NULL == pg) 60 if (NULL == pg)
@@ -80,10 +79,9 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset)
80 79
81 if (NULL == pages[0]) 80 if (NULL == pages[0])
82 return NULL; 81 return NULL;
83 sglist = kmalloc(sizeof(*sglist) * nr_pages, GFP_KERNEL); 82 sglist = kcalloc(nr_pages, sizeof(*sglist), GFP_KERNEL);
84 if (NULL == sglist) 83 if (NULL == sglist)
85 return NULL; 84 return NULL;
86 memset(sglist, 0, sizeof(*sglist) * nr_pages);
87 85
88 if (NULL == pages[0]) 86 if (NULL == pages[0])
89 goto nopage; 87 goto nopage;
@@ -284,9 +282,8 @@ void* videobuf_alloc(unsigned int size)
284{ 282{
285 struct videobuf_buffer *vb; 283 struct videobuf_buffer *vb;
286 284
287 vb = kmalloc(size,GFP_KERNEL); 285 vb = kzalloc(size,GFP_KERNEL);
288 if (NULL != vb) { 286 if (NULL != vb) {
289 memset(vb,0,size);
290 videobuf_dma_init(&vb->dma); 287 videobuf_dma_init(&vb->dma);
291 init_waitqueue_head(&vb->done); 288 init_waitqueue_head(&vb->done);
292 vb->magic = MAGIC_BUFFER; 289 vb->magic = MAGIC_BUFFER;
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c
index 839db622040d..8f271de57fd6 100644
--- a/drivers/media/video/videocodec.c
+++ b/drivers/media/video/videocodec.c
@@ -124,17 +124,13 @@ videocodec_attach (struct videocodec_master *master)
124 if (res == 0) { 124 if (res == 0) {
125 dprintk(3, "videocodec_attach '%s'\n", 125 dprintk(3, "videocodec_attach '%s'\n",
126 codec->name); 126 codec->name);
127 ptr = (struct attached_list *) 127 ptr = kzalloc(sizeof(struct attached_list), GFP_KERNEL);
128 kmalloc(sizeof(struct attached_list),
129 GFP_KERNEL);
130 if (!ptr) { 128 if (!ptr) {
131 dprintk(1, 129 dprintk(1,
132 KERN_ERR 130 KERN_ERR
133 "videocodec_attach: no memory\n"); 131 "videocodec_attach: no memory\n");
134 goto out_kfree; 132 goto out_kfree;
135 } 133 }
136 memset(ptr, 0,
137 sizeof(struct attached_list));
138 ptr->codec = codec; 134 ptr->codec = codec;
139 135
140 a = h->list; 136 a = h->list;
@@ -249,14 +245,11 @@ videocodec_register (const struct videocodec *codec)
249 "videocodec: register '%s', type: %x, flags %lx, magic %lx\n", 245 "videocodec: register '%s', type: %x, flags %lx, magic %lx\n",
250 codec->name, codec->type, codec->flags, codec->magic); 246 codec->name, codec->type, codec->flags, codec->magic);
251 247
252 ptr = 248 ptr = kzalloc(sizeof(struct codec_list), GFP_KERNEL);
253 (struct codec_list *) kmalloc(sizeof(struct codec_list),
254 GFP_KERNEL);
255 if (!ptr) { 249 if (!ptr) {
256 dprintk(1, KERN_ERR "videocodec_register: no memory\n"); 250 dprintk(1, KERN_ERR "videocodec_register: no memory\n");
257 return -ENOMEM; 251 return -ENOMEM;
258 } 252 }
259 memset(ptr, 0, sizeof(struct codec_list));
260 ptr->codec = codec; 253 ptr->codec = codec;
261 254
262 if (!h) { 255 if (!h) {
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 9a9902c56ae7..d5be25987142 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -52,10 +52,7 @@ struct video_device *video_device_alloc(void)
52{ 52{
53 struct video_device *vfd; 53 struct video_device *vfd;
54 54
55 vfd = kmalloc(sizeof(*vfd),GFP_KERNEL); 55 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
56 if (NULL == vfd)
57 return NULL;
58 memset(vfd,0,sizeof(*vfd));
59 return vfd; 56 return vfd;
60} 57}
61 58
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 71b28e9e0850..c8fd8238904d 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -4499,13 +4499,11 @@ static int vino_init(void)
4499 dma_addr_t dma_dummy_address; 4499 dma_addr_t dma_dummy_address;
4500 int i; 4500 int i;
4501 4501
4502 vino_drvdata = (struct vino_settings *) 4502 vino_drvdata = kzalloc(sizeof(struct vino_settings), GFP_KERNEL);
4503 kmalloc(sizeof(struct vino_settings), GFP_KERNEL);
4504 if (!vino_drvdata) { 4503 if (!vino_drvdata) {
4505 vino_module_cleanup(vino_init_stage); 4504 vino_module_cleanup(vino_init_stage);
4506 return -ENOMEM; 4505 return -ENOMEM;
4507 } 4506 }
4508 memset(vino_drvdata, 0, sizeof(struct vino_settings));
4509 vino_init_stage++; 4507 vino_init_stage++;
4510 4508
4511 /* create a dummy dma descriptor */ 4509 /* create a dummy dma descriptor */
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 8dcee8b60e21..d0a1e72ea8c4 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -621,13 +621,11 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
621 (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) 621 (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
622 return 0; 622 return 0;
623 623
624 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 624 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
625 if (client == NULL) { 625 if (client == NULL) {
626 return -ENOMEM; 626 return -ENOMEM;
627 } 627 }
628 628
629 memset(client, 0, sizeof(struct i2c_client));
630
631 client->addr = address; 629 client->addr = address;
632 client->adapter = adapter; 630 client->adapter = adapter;
633 client->driver = &vpx3220_i2c_driver; 631 client->driver = &vpx3220_i2c_driver;
@@ -675,12 +673,11 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
675 sizeof(I2C_NAME(client))); 673 sizeof(I2C_NAME(client)));
676 } 674 }
677 675
678 decoder = kmalloc(sizeof(struct vpx3220), GFP_KERNEL); 676 decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL);
679 if (decoder == NULL) { 677 if (decoder == NULL) {
680 kfree(client); 678 kfree(client);
681 return -ENOMEM; 679 return -ENOMEM;
682 } 680 }
683 memset(decoder, 0, sizeof(struct vpx3220));
684 decoder->norm = VIDEO_MODE_PAL; 681 decoder->norm = VIDEO_MODE_PAL;
685 decoder->input = 0; 682 decoder->input = 0;
686 decoder->enable = 1; 683 decoder->enable = 1;
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index c2e6d2e9f5f1..8cb64f8a8a91 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -166,11 +166,10 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
166 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 166 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
167 return 0; 167 return 0;
168 168
169 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 169 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
170 if (client == 0) 170 if (client == 0)
171 return -ENOMEM; 171 return -ENOMEM;
172 172
173 memset(client, 0, sizeof(struct i2c_client));
174 client->addr = address; 173 client->addr = address;
175 client->adapter = adapter; 174 client->adapter = adapter;
176 client->driver = &i2c_driver; 175 client->driver = &i2c_driver;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 39a0d238900e..ea3288661a34 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -1050,7 +1050,7 @@ zr36057_init (struct zoran *zr)
1050 /* allocate memory *before* doing anything to the hardware 1050 /* allocate memory *before* doing anything to the hardware
1051 * in case allocation fails */ 1051 * in case allocation fails */
1052 mem_needed = BUZ_NUM_STAT_COM * 4; 1052 mem_needed = BUZ_NUM_STAT_COM * 4;
1053 mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL); 1053 mem = kzalloc(mem_needed, GFP_KERNEL);
1054 vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL); 1054 vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
1055 if (!mem || !vdev) { 1055 if (!mem || !vdev) {
1056 dprintk(1, 1056 dprintk(1,
@@ -1061,7 +1061,6 @@ zr36057_init (struct zoran *zr)
1061 kfree((void *)mem); 1061 kfree((void *)mem);
1062 return -ENOMEM; 1062 return -ENOMEM;
1063 } 1063 }
1064 memset((void *) mem, 0, mem_needed);
1065 zr->stat_com = (u32 *) mem; 1064 zr->stat_com = (u32 *) mem;
1066 for (j = 0; j < BUZ_NUM_STAT_COM; j++) { 1065 for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
1067 zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ 1066 zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 15283f44e79f..485553be190b 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -1345,7 +1345,7 @@ zoran_open (struct inode *inode,
1345 ZR_DEVNAME(zr), current->comm, current->pid, zr->user); 1345 ZR_DEVNAME(zr), current->comm, current->pid, zr->user);
1346 1346
1347 /* now, create the open()-specific file_ops struct */ 1347 /* now, create the open()-specific file_ops struct */
1348 fh = kmalloc(sizeof(struct zoran_fh), GFP_KERNEL); 1348 fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL);
1349 if (!fh) { 1349 if (!fh) {
1350 dprintk(1, 1350 dprintk(1,
1351 KERN_ERR 1351 KERN_ERR
@@ -1354,7 +1354,6 @@ zoran_open (struct inode *inode,
1354 res = -ENOMEM; 1354 res = -ENOMEM;
1355 goto open_unlock_and_return; 1355 goto open_unlock_and_return;
1356 } 1356 }
1357 memset(fh, 0, sizeof(struct zoran_fh));
1358 /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows 1357 /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
1359 * on norm-change! */ 1358 * on norm-change! */
1360 fh->overlay_mask = 1359 fh->overlay_mask =
diff --git a/drivers/media/video/zr36016.c b/drivers/media/video/zr36016.c
index 4ed898585c70..10130ef67ea7 100644
--- a/drivers/media/video/zr36016.c
+++ b/drivers/media/video/zr36016.c
@@ -451,12 +451,11 @@ zr36016_setup (struct videocodec *codec)
451 return -ENOSPC; 451 return -ENOSPC;
452 } 452 }
453 //mem structure init 453 //mem structure init
454 codec->data = ptr = kmalloc(sizeof(struct zr36016), GFP_KERNEL); 454 codec->data = ptr = kzalloc(sizeof(struct zr36016), GFP_KERNEL);
455 if (NULL == ptr) { 455 if (NULL == ptr) {
456 dprintk(1, KERN_ERR "zr36016: Can't get enough memory!\n"); 456 dprintk(1, KERN_ERR "zr36016: Can't get enough memory!\n");
457 return -ENOMEM; 457 return -ENOMEM;
458 } 458 }
459 memset(ptr, 0, sizeof(struct zr36016));
460 459
461 snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]", 460 snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]",
462 zr36016_codecs); 461 zr36016_codecs);
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c
index 0144576a6123..bd0cd28543ca 100644
--- a/drivers/media/video/zr36050.c
+++ b/drivers/media/video/zr36050.c
@@ -813,12 +813,11 @@ zr36050_setup (struct videocodec *codec)
813 return -ENOSPC; 813 return -ENOSPC;
814 } 814 }
815 //mem structure init 815 //mem structure init
816 codec->data = ptr = kmalloc(sizeof(struct zr36050), GFP_KERNEL); 816 codec->data = ptr = kzalloc(sizeof(struct zr36050), GFP_KERNEL);
817 if (NULL == ptr) { 817 if (NULL == ptr) {
818 dprintk(1, KERN_ERR "zr36050: Can't get enough memory!\n"); 818 dprintk(1, KERN_ERR "zr36050: Can't get enough memory!\n");
819 return -ENOMEM; 819 return -ENOMEM;
820 } 820 }
821 memset(ptr, 0, sizeof(struct zr36050));
822 821
823 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]", 822 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]",
824 zr36050_codecs); 823 zr36050_codecs);
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c
index 129744a07abd..28fa31a5f150 100644
--- a/drivers/media/video/zr36060.c
+++ b/drivers/media/video/zr36060.c
@@ -919,12 +919,11 @@ zr36060_setup (struct videocodec *codec)
919 return -ENOSPC; 919 return -ENOSPC;
920 } 920 }
921 //mem structure init 921 //mem structure init
922 codec->data = ptr = kmalloc(sizeof(struct zr36060), GFP_KERNEL); 922 codec->data = ptr = kzalloc(sizeof(struct zr36060), GFP_KERNEL);
923 if (NULL == ptr) { 923 if (NULL == ptr) {
924 dprintk(1, KERN_ERR "zr36060: Can't get enough memory!\n"); 924 dprintk(1, KERN_ERR "zr36060: Can't get enough memory!\n");
925 return -ENOMEM; 925 return -ENOMEM;
926 } 926 }
927 memset(ptr, 0, sizeof(struct zr36060));
928 927
929 snprintf(ptr->name, sizeof(ptr->name), "zr36060[%d]", 928 snprintf(ptr->name, sizeof(ptr->name), "zr36060[%d]",
930 zr36060_codecs); 929 zr36060_codecs);