Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'media_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6

* 'media_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (101 commits)
[media] staging/lirc: fix mem leaks and ptr err usage
[media] hdpvr: reduce latency of i2c read/write w/recycled buffer
[media] hdpvr: enable IR part
[media] rc/mceusb: timeout should be in ns, not us
[media] v4l2-device: fix 'use-after-freed' oops
[media] v4l2-dev: don't memset video_device.dev
[media] zoran: use video_device_alloc instead of kmalloc
[media] w9966: zero device state after a detach
[media] v4l: Fix a use-before-set in the control framework
[media] v4l: Include linux/videodev2.h in media/v4l2-ctrls.h
[media] DocBook/v4l: update V4L2 revision and update copyright years
[media] DocBook/v4l: fix validation error in dev-rds.xml
[media] v4l2-ctrls: queryctrl shouldn't attempt to replace V4L2_CID_PRIVATE_BASE IDs
[media] v4l2-ctrls: fix missing 'read-only' check
[media] pvrusb2: Provide more information about IR units to lirc_zilog and ir-kbd-i2c
[media] ir-kbd-i2c: Add back defaults setting for Zilog Z8's at addr 0x71
[media] lirc_zilog: Update TODO.lirc_zilog
[media] lirc_zilog: Add Andy Walls to copyright notice and authors list
[media] lirc_zilog: Remove useless struct i2c_driver.command function
[media] lirc_zilog: Remove unneeded tests for existence of the IR Tx function
...

+2461 -2680
+1 -1
Documentation/DocBook/dvb/dvbapi.xml
··· 28 28 <holder>Convergence GmbH</holder> 29 29 </copyright> 30 30 <copyright> 31 - <year>2009-2010</year> 31 + <year>2009-2011</year> 32 32 <holder>Mauro Carvalho Chehab</holder> 33 33 </copyright> 34 34
+2 -2
Documentation/DocBook/media.tmpl
··· 28 28 <title>LINUX MEDIA INFRASTRUCTURE API</title> 29 29 30 30 <copyright> 31 - <year>2009-2010</year> 31 + <year>2009-2011</year> 32 32 <holder>LinuxTV Developers</holder> 33 33 </copyright> 34 34 ··· 86 86 </author> 87 87 </authorgroup> 88 88 <copyright> 89 - <year>2009-2010</year> 89 + <year>2009-2011</year> 90 90 <holder>Mauro Carvalho Chehab</holder> 91 91 </copyright> 92 92
+4 -2
Documentation/DocBook/v4l/dev-rds.xml
··· 75 75 </section> 76 76 77 77 <section> 78 + <title>RDS datastructures</title> 78 79 <table frame="none" pgwide="1" id="v4l2-rds-data"> 79 80 <title>struct 80 81 <structname>v4l2_rds_data</structname></title> ··· 130 129 131 130 <table frame="none" pgwide="1" id="v4l2-rds-block-codes"> 132 131 <title>Block defines</title> 133 - <tgroup cols="3"> 132 + <tgroup cols="4"> 134 133 <colspec colname="c1" colwidth="1*" /> 135 134 <colspec colname="c2" colwidth="1*" /> 136 - <colspec colname="c3" colwidth="5*" /> 135 + <colspec colname="c3" colwidth="1*" /> 136 + <colspec colname="c4" colwidth="5*" /> 137 137 <tbody valign="top"> 138 138 <row> 139 139 <entry>V4L2_RDS_BLOCK_MSK</entry>
+2 -1
Documentation/DocBook/v4l/v4l2.xml
··· 100 100 <year>2008</year> 101 101 <year>2009</year> 102 102 <year>2010</year> 103 + <year>2011</year> 103 104 <holder>Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin 104 105 Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho Chehab</holder> 105 106 </copyright> ··· 382 381 </partinfo> 383 382 384 383 <title>Video for Linux Two API Specification</title> 385 - <subtitle>Revision 2.6.33</subtitle> 384 + <subtitle>Revision 2.6.38</subtitle> 386 385 387 386 <chapter id="common"> 388 387 &sub-common;
+12
Documentation/video4linux/v4l2-controls.txt
··· 285 285 The 'new value' union is not used in g_volatile_ctrl. In general controls 286 286 that need to implement g_volatile_ctrl are read-only controls. 287 287 288 + Note that if one or more controls in a control cluster are marked as volatile, 289 + then all the controls in the cluster are seen as volatile. 290 + 288 291 To mark a control as volatile you have to set the is_volatile flag: 289 292 290 293 ctrl = v4l2_ctrl_new_std(&sd->ctrl_handler, ...); ··· 464 461 465 462 Obviously, all controls in the cluster array must be initialized to either 466 463 a valid control or to NULL. 464 + 465 + In rare cases you might want to know which controls of a cluster actually 466 + were set explicitly by the user. For this you can check the 'is_new' flag of 467 + each control. For example, in the case of a volume/mute cluster the 'is_new' 468 + flag of the mute control would be set if the user called VIDIOC_S_CTRL for 469 + mute only. If the user would call VIDIOC_S_EXT_CTRLS for both mute and volume 470 + controls, then the 'is_new' flag would be 1 for both controls. 471 + 472 + The 'is_new' flag is always 1 when called from v4l2_ctrl_handler_setup(). 467 473 468 474 469 475 VIDIOC_LOG_STATUS Support
+1 -1
drivers/media/common/saa7146_core.c
··· 452 452 INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); 453 453 dev->ext = ext; 454 454 455 - mutex_init(&dev->lock); 455 + mutex_init(&dev->v4l2_lock); 456 456 spin_lock_init(&dev->int_slock); 457 457 spin_lock_init(&dev->slock); 458 458
+2 -6
drivers/media/common/saa7146_fops.c
··· 15 15 } 16 16 17 17 /* is it free? */ 18 - mutex_lock(&dev->lock); 19 18 if (vv->resources & bit) { 20 19 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); 21 20 /* no, someone else uses it */ 22 - mutex_unlock(&dev->lock); 23 21 return 0; 24 22 } 25 23 /* it's free, grab it */ 26 24 fh->resources |= bit; 27 25 vv->resources |= bit; 28 26 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources)); 29 - mutex_unlock(&dev->lock); 30 27 return 1; 31 28 } 32 29 ··· 34 37 35 38 BUG_ON((fh->resources & bits) != bits); 36 39 37 - mutex_lock(&dev->lock); 38 40 fh->resources &= ~bits; 39 41 vv->resources &= ~bits; 40 42 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); 41 - mutex_unlock(&dev->lock); 42 43 } 43 44 44 45 ··· 391 396 .write = fops_write, 392 397 .poll = fops_poll, 393 398 .mmap = fops_mmap, 394 - .ioctl = video_ioctl2, 399 + .unlocked_ioctl = video_ioctl2, 395 400 }; 396 401 397 402 static void vv_callback(struct saa7146_dev *dev, unsigned long status) ··· 500 505 vfd->fops = &video_fops; 501 506 vfd->ioctl_ops = &dev->ext_vv_data->ops; 502 507 vfd->release = video_device_release; 508 + vfd->lock = &dev->v4l2_lock; 503 509 vfd->tvnorms = 0; 504 510 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 505 511 vfd->tvnorms |= dev->ext_vv_data->stds[i].id;
+1 -1
drivers/media/common/saa7146_vbi.c
··· 412 412 V4L2_BUF_TYPE_VBI_CAPTURE, 413 413 V4L2_FIELD_SEQ_TB, // FIXME: does this really work? 414 414 sizeof(struct saa7146_buf), 415 - file, NULL); 415 + file, &dev->v4l2_lock); 416 416 417 417 init_timer(&fh->vbi_read_timeout); 418 418 fh->vbi_read_timeout.function = vbi_read_timeout;
+1 -19
drivers/media/common/saa7146_video.c
··· 553 553 } 554 554 } 555 555 556 - mutex_lock(&dev->lock); 557 - 558 556 /* ok, accept it */ 559 557 vv->ov_fb = *fb; 560 558 vv->ov_fmt = fmt; ··· 561 563 vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8; 562 564 DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline)); 563 565 } 564 - 565 - mutex_unlock(&dev->lock); 566 566 return 0; 567 567 } 568 568 ··· 645 649 return -EINVAL; 646 650 } 647 651 648 - mutex_lock(&dev->lock); 649 - 650 652 switch (ctrl->type) { 651 653 case V4L2_CTRL_TYPE_BOOLEAN: 652 654 case V4L2_CTRL_TYPE_MENU: ··· 687 693 /* fixme: we can support changing VFLIP and HFLIP here... */ 688 694 if (IS_CAPTURE_ACTIVE(fh) != 0) { 689 695 DEB_D(("V4L2_CID_HFLIP while active capture.\n")); 690 - mutex_unlock(&dev->lock); 691 696 return -EBUSY; 692 697 } 693 698 vv->hflip = c->value; ··· 694 701 case V4L2_CID_VFLIP: 695 702 if (IS_CAPTURE_ACTIVE(fh) != 0) { 696 703 DEB_D(("V4L2_CID_VFLIP while active capture.\n")); 697 - mutex_unlock(&dev->lock); 698 704 return -EBUSY; 699 705 } 700 706 vv->vflip = c->value; 701 707 break; 702 708 default: 703 - mutex_unlock(&dev->lock); 704 709 return -EINVAL; 705 710 } 706 - mutex_unlock(&dev->lock); 707 711 708 712 if (IS_OVERLAY_ACTIVE(fh) != 0) { 709 713 saa7146_stop_preview(fh); ··· 892 902 err = vidioc_try_fmt_vid_overlay(file, fh, f); 893 903 if (0 != err) 894 904 return err; 895 - mutex_lock(&dev->lock); 896 905 fh->ov.win = f->fmt.win; 897 906 fh->ov.nclips = f->fmt.win.clipcount; 898 907 if (fh->ov.nclips > 16) 899 908 fh->ov.nclips = 16; 900 909 if (copy_from_user(fh->ov.clips, f->fmt.win.clips, 901 910 sizeof(struct v4l2_clip) * fh->ov.nclips)) { 902 - mutex_unlock(&dev->lock); 903 911 return -EFAULT; 904 912 } 905 913 906 914 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ 907 915 fh->ov.fh = fh; 908 - 909 - mutex_unlock(&dev->lock); 910 916 911 917 /* check if our current overlay is active */ 912 918 if (IS_OVERLAY_ACTIVE(fh) != 0) { ··· 962 976 } 963 977 } 964 978 965 - mutex_lock(&dev->lock); 966 - 967 979 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 968 980 if (*id & dev->ext_vv_data->stds[i].id) 969 981 break; ··· 971 987 dev->ext_vv_data->std_callback(dev, vv->standard); 972 988 found = 1; 973 989 } 974 - 975 - mutex_unlock(&dev->lock); 976 990 977 991 if (vv->ov_suspend != NULL) { 978 992 saa7146_start_preview(vv->ov_suspend); ··· 1336 1354 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1337 1355 V4L2_FIELD_INTERLACED, 1338 1356 sizeof(struct saa7146_buf), 1339 - file, NULL); 1357 + file, &dev->v4l2_lock); 1340 1358 1341 1359 return 0; 1342 1360 }
+74 -56
drivers/media/common/tuners/tda8290.c
··· 95 95 msleep(20); 96 96 } else { 97 97 msg = disable; 98 - tuner_i2c_xfer_send(&priv->i2c_props, msg, 1); 99 - tuner_i2c_xfer_recv(&priv->i2c_props, &msg[1], 1); 98 + tuner_i2c_xfer_send_recv(&priv->i2c_props, msg, 1, &msg[1], 1); 100 99 101 100 buf[2] = msg[1]; 102 101 buf[2] &= ~0x04; ··· 232 233 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); 233 234 } 234 235 236 + 235 237 tda8290_i2c_bridge(fe, 1); 236 238 237 239 if (fe->ops.tuner_ops.set_analog_params) 238 240 fe->ops.tuner_ops.set_analog_params(fe, params); 239 241 240 242 for (i = 0; i < 3; i++) { 241 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 242 - tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 243 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 244 + &addr_pll_stat, 1, &pll_stat, 1); 243 245 if (pll_stat & 0x80) { 244 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); 245 - tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); 246 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 247 - tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 246 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 247 + &addr_adc_sat, 1, 248 + &adc_sat, 1); 249 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 250 + &addr_agc_stat, 1, 251 + &agc_stat, 1); 248 252 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat); 249 253 break; 250 254 } else { ··· 261 259 agc_stat, adc_sat, pll_stat & 0x80); 262 260 tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2); 263 261 msleep(100); 264 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 265 - tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 266 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 267 - tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 262 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 263 + &addr_agc_stat, 1, &agc_stat, 1); 264 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 265 + &addr_pll_stat, 1, &pll_stat, 1); 268 266 if ((agc_stat > 115) || !(pll_stat & 0x80)) { 269 267 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", 270 268 agc_stat, pll_stat & 0x80); 271 269 if (priv->cfg.agcf) 272 270 priv->cfg.agcf(fe); 273 271 msleep(100); 274 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 275 - tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 276 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 277 - tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 272 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 273 + &addr_agc_stat, 1, 274 + &agc_stat, 1); 275 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 276 + &addr_pll_stat, 1, 277 + &pll_stat, 1); 278 278 if((agc_stat > 115) || !(pll_stat & 0x80)) { 279 279 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat); 280 280 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2); ··· 288 284 289 285 /* l/ l' deadlock? */ 290 286 if(priv->tda8290_easy_mode & 0x60) { 291 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); 292 - tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); 293 - tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 294 - tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 287 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 288 + &addr_adc_sat, 1, 289 + &adc_sat, 1); 290 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 291 + &addr_pll_stat, 1, 292 + &pll_stat, 1); 295 293 if ((adc_sat > 20) || !(pll_stat & 0x80)) { 296 294 tuner_dbg("trying to resolve SECAM L deadlock\n"); 297 295 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2); ··· 313 307 struct tda8290_priv *priv = fe->analog_demod_priv; 314 308 unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ 315 309 316 - tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 317 - tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); 310 + tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1); 318 311 319 312 if (enable) 320 313 buf[1] = 0x01; ··· 328 323 struct tda8290_priv *priv = fe->analog_demod_priv; 329 324 unsigned char buf[] = { 0x01, 0x00 }; 330 325 331 - tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 332 - tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); 326 + tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1); 333 327 334 328 if (enable) 335 329 buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */ ··· 357 353 struct tda8290_priv *priv = fe->analog_demod_priv; 358 354 unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ 359 355 360 - tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 361 - tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); 356 + tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1); 362 357 363 358 if (enable) 364 359 buf[1] &= ~0x40; ··· 373 370 unsigned char set_gpio_cf[] = { 0x44, 0x00 }; 374 371 unsigned char set_gpio_val[] = { 0x46, 0x00 }; 375 372 376 - tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_cf[0], 1); 377 - tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_cf[1], 1); 378 - tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_val[0], 1); 379 - tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_val[1], 1); 373 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 374 + &set_gpio_cf[0], 1, &set_gpio_cf[1], 1); 375 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 376 + &set_gpio_val[0], 1, &set_gpio_val[1], 1); 380 377 381 378 set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */ 382 379 ··· 395 392 unsigned char hvpll_stat = 0x26; 396 393 unsigned char ret; 397 394 398 - tuner_i2c_xfer_send(&priv->i2c_props, &hvpll_stat, 1); 399 - tuner_i2c_xfer_recv(&priv->i2c_props, &ret, 1); 395 + tuner_i2c_xfer_send_recv(&priv->i2c_props, &hvpll_stat, 1, &ret, 1); 400 396 return (ret & 0x01) ? 65535 : 0; 401 397 } 402 398 ··· 415 413 tda8295_power(fe, 1); 416 414 tda8295_agc1_out(fe, 1); 417 415 418 - tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); 419 - tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); 416 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 417 + &blanking_mode[0], 1, &blanking_mode[1], 1); 420 418 421 419 tda8295_set_video_std(fe); 422 420 ··· 449 447 unsigned char i2c_get_afc[1] = { 0x1B }; 450 448 unsigned char afc = 0; 451 449 452 - tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc)); 453 - tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1); 450 + tuner_i2c_xfer_send_recv(&priv->i2c_props, 451 + i2c_get_afc, ARRAY_SIZE(i2c_get_afc), &afc, 1); 454 452 return (afc & 0x80)? 65535:0; 455 453 } 456 454 ··· 656 654 static int tda8290_probe(struct tuner_i2c_props *i2c_props) 657 655 { 658 656 #define TDA8290_ID 0x89 659 - unsigned char tda8290_id[] = { 0x1f, 0x00 }; 657 + u8 reg = 0x1f, id; 658 + struct i2c_msg msg_read[] = { 659 + { .addr = 0x4b, .flags = 0, .len = 1, .buf = &reg }, 660 + { .addr = 0x4b, .flags = I2C_M_RD, .len = 1, .buf = &id }, 661 + }; 660 662 661 663 /* detect tda8290 */ 662 - tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1); 663 - tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); 664 + if (i2c_transfer(i2c_props->adap, msg_read, 2) != 2) { 665 + printk(KERN_WARNING "%s: tda8290 couldn't read register 0x%02x\n", 666 + __func__, reg); 667 + return -ENODEV; 668 + } 664 669 665 - if (tda8290_id[1] == TDA8290_ID) { 670 + if (id == TDA8290_ID) { 666 671 if (debug) 667 672 printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", 668 673 __func__, i2c_adapter_id(i2c_props->adap), 669 674 i2c_props->addr); 670 675 return 0; 671 676 } 672 - 673 677 return -ENODEV; 674 678 } 675 679 ··· 683 675 { 684 676 #define TDA8295_ID 0x8a 685 677 #define TDA8295C2_ID 0x8b 686 - unsigned char tda8295_id[] = { 0x2f, 0x00 }; 678 + u8 reg = 0x2f, id; 679 + struct i2c_msg msg_read[] = { 680 + { .addr = 0x4b, .flags = 0, .len = 1, .buf = &reg }, 681 + { .addr = 0x4b, .flags = I2C_M_RD, .len = 1, .buf = &id }, 682 + }; 687 683 688 - /* detect tda8295 */ 689 - tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1); 690 - tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); 684 + /* detect tda8290 */ 685 + if (i2c_transfer(i2c_props->adap, msg_read, 2) != 2) { 686 + printk(KERN_WARNING "%s: tda8290 couldn't read register 0x%02x\n", 687 + __func__, reg); 688 + return -ENODEV; 689 + } 691 690 692 - if ((tda8295_id[1] & 0xfe) == TDA8295_ID) { 691 + if ((id & 0xfe) == TDA8295_ID) { 693 692 if (debug) 694 693 printk(KERN_DEBUG "%s: %s detected @ %d-%04x\n", 695 - __func__, (tda8295_id[1] == TDA8295_ID) ? 694 + __func__, (id == TDA8295_ID) ? 696 695 "tda8295c1" : "tda8295c2", 697 696 i2c_adapter_id(i2c_props->adap), 698 697 i2c_props->addr); ··· 755 740 sizeof(struct analog_demod_ops)); 756 741 } 757 742 758 - if ((!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) && 759 - (tda829x_find_tuner(fe) < 0)) 760 - goto fail; 743 + if (!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) { 744 + tda8295_power(fe, 1); 745 + if (tda829x_find_tuner(fe) < 0) 746 + goto fail; 747 + } 761 748 762 749 switch (priv->ver) { 763 750 case TDA8290: ··· 803 786 return fe; 804 787 805 788 fail: 789 + memset(&fe->ops.analog_ops, 0, sizeof(struct analog_demod_ops)); 790 + 806 791 tda829x_release(fe); 807 792 return NULL; 808 793 } ··· 828 809 int i; 829 810 830 811 /* rule out tda9887, which would return the same byte repeatedly */ 831 - tuner_i2c_xfer_send(&i2c_props, soft_reset, 1); 832 - tuner_i2c_xfer_recv(&i2c_props, buf, PROBE_BUFFER_SIZE); 812 + tuner_i2c_xfer_send_recv(&i2c_props, 813 + soft_reset, 1, buf, PROBE_BUFFER_SIZE); 833 814 for (i = 1; i < PROBE_BUFFER_SIZE; i++) { 834 815 if (buf[i] != buf[0]) 835 816 break; ··· 846 827 /* fall back to old probing method */ 847 828 tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2); 848 829 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); 849 - tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); 850 - tuner_i2c_xfer_recv(&i2c_props, &data, 1); 830 + tuner_i2c_xfer_send_recv(&i2c_props, &addr_dto_lsb, 1, &data, 1); 851 831 if (data == 0) { 852 832 tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2); 853 833 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); 854 - tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); 855 - tuner_i2c_xfer_recv(&i2c_props, &data, 1); 834 + tuner_i2c_xfer_send_recv(&i2c_props, 835 + &addr_dto_lsb, 1, &data, 1); 856 836 if (data == 0x7b) { 857 837 return 0; 858 838 }
+3 -3
drivers/media/dvb/dvb-usb/dib0700_core.c
··· 514 514 union { 515 515 u16 system16; 516 516 struct { 517 - u8 system; 518 517 u8 not_system; 518 + u8 system; 519 519 }; 520 520 }; 521 521 u8 data; ··· 575 575 if ((poll_reply->system ^ poll_reply->not_system) != 0xff) { 576 576 deb_data("NEC extended protocol\n"); 577 577 /* NEC extended code - 24 bits */ 578 - keycode = poll_reply->system16 << 8 | poll_reply->data; 578 + keycode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data; 579 579 } else { 580 580 deb_data("NEC normal protocol\n"); 581 581 /* normal NEC code - 16 bits */ ··· 587 587 deb_data("RC5 protocol\n"); 588 588 /* RC5 Protocol */ 589 589 toggle = poll_reply->report_id; 590 - keycode = poll_reply->system16 << 8 | poll_reply->data; 590 + keycode = poll_reply->system << 8 | poll_reply->data; 591 591 592 592 break; 593 593 }
+6 -3
drivers/media/dvb/firewire/firedtv-rc.c
··· 172 172 173 173 void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code) 174 174 { 175 - u16 *keycode = fdtv->remote_ctrl_dev->keycode; 175 + struct input_dev *idev = fdtv->remote_ctrl_dev; 176 + u16 *keycode = idev->keycode; 176 177 177 178 if (code >= 0x0300 && code <= 0x031f) 178 179 code = keycode[code - 0x0300]; ··· 189 188 return; 190 189 } 191 190 192 - input_report_key(fdtv->remote_ctrl_dev, code, 1); 193 - input_report_key(fdtv->remote_ctrl_dev, code, 0); 191 + input_report_key(idev, code, 1); 192 + input_sync(idev); 193 + input_report_key(idev, code, 0); 194 + input_sync(idev); 194 195 }
+2 -2
drivers/media/dvb/frontends/af9013.c
··· 334 334 if_sample_freq = 3300000; /* 3.3 MHz */ 335 335 break; 336 336 case BANDWIDTH_7_MHZ: 337 - if_sample_freq = 3800000; /* 3.8 MHz */ 337 + if_sample_freq = 3500000; /* 3.5 MHz */ 338 338 break; 339 339 case BANDWIDTH_8_MHZ: 340 340 default: 341 - if_sample_freq = 4300000; /* 4.3 MHz */ 341 + if_sample_freq = 4000000; /* 4.0 MHz */ 342 342 break; 343 343 } 344 344 } else if (state->config.tuner == AF9013_TUNER_TDA18218) {
+1 -1
drivers/media/dvb/frontends/ix2505v.c
··· 311 311 return fe; 312 312 313 313 error: 314 - ix2505v_release(fe); 314 + kfree(state); 315 315 return NULL; 316 316 } 317 317 EXPORT_SYMBOL(ix2505v_attach);
+30 -6
drivers/media/dvb/frontends/mb86a20s.c
··· 43 43 const struct mb86a20s_config *config; 44 44 45 45 struct dvb_frontend frontend; 46 + 47 + bool need_init; 46 48 }; 47 49 48 50 struct regdata { ··· 320 318 321 319 rc = i2c_transfer(state->i2c, &msg, 1); 322 320 if (rc != 1) { 323 - printk("%s: writereg rcor(rc == %i, reg == 0x%02x," 321 + printk("%s: writereg error (rc == %i, reg == 0x%02x," 324 322 " data == 0x%02x)\n", __func__, rc, reg, data); 325 323 return rc; 326 324 } ··· 355 353 rc = i2c_transfer(state->i2c, msg, 2); 356 354 357 355 if (rc != 2) { 358 - rc("%s: reg=0x%x (rcor=%d)\n", __func__, reg, rc); 356 + rc("%s: reg=0x%x (error=%d)\n", __func__, reg, rc); 359 357 return rc; 360 358 } 361 359 ··· 384 382 /* Initialize the frontend */ 385 383 rc = mb86a20s_writeregdata(state, mb86a20s_init); 386 384 if (rc < 0) 387 - return rc; 385 + goto err; 388 386 389 387 if (!state->config->is_serial) { 390 388 regD5 &= ~1; 391 389 392 390 rc = mb86a20s_writereg(state, 0x50, 0xd5); 393 391 if (rc < 0) 394 - return rc; 392 + goto err; 395 393 rc = mb86a20s_writereg(state, 0x51, regD5); 396 394 if (rc < 0) 397 - return rc; 395 + goto err; 398 396 } 399 397 400 398 if (fe->ops.i2c_gate_ctrl) 401 399 fe->ops.i2c_gate_ctrl(fe, 1); 402 400 403 - return 0; 401 + err: 402 + if (rc < 0) { 403 + state->need_init = true; 404 + printk(KERN_INFO "mb86a20s: Init failed. Will try again later\n"); 405 + } else { 406 + state->need_init = false; 407 + dprintk("Initialization succeded.\n"); 408 + } 409 + return rc; 404 410 } 405 411 406 412 static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) ··· 495 485 496 486 if (fe->ops.i2c_gate_ctrl) 497 487 fe->ops.i2c_gate_ctrl(fe, 1); 488 + dprintk("Calling tuner set parameters\n"); 498 489 fe->ops.tuner_ops.set_params(fe, p); 490 + 491 + /* 492 + * Make it more reliable: if, for some reason, the initial 493 + * device initialization doesn't happen, initialize it when 494 + * a SBTVD parameters are adjusted. 495 + * 496 + * Unfortunately, due to a hard to track bug at tda829x/tda18271, 497 + * the agc callback logic is not called during DVB attach time, 498 + * causing mb86a20s to not be initialized with Kworld SBTVD. 499 + * So, this hack is needed, in order to make Kworld SBTVD to work. 500 + */ 501 + if (state->need_init) 502 + mb86a20s_initfe(fe); 499 503 500 504 if (fe->ops.i2c_gate_ctrl) 501 505 fe->ops.i2c_gate_ctrl(fe, 0);
+1 -1
drivers/media/dvb/ttpci/av7110_ca.c
··· 277 277 { 278 278 ca_slot_info_t *info=(ca_slot_info_t *)parg; 279 279 280 - if (info->num > 1) 280 + if (info->num < 0 || info->num > 1) 281 281 return -EINVAL; 282 282 av7110->ci_slot[info->num].num = info->num; 283 283 av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ?
-14
drivers/media/radio/Kconfig
··· 151 151 following ports will be probed: 0x20c, 0x30c, 0x24c, 0x34c, 0x248 and 152 152 0x28c. 153 153 154 - config RADIO_GEMTEK_PCI 155 - tristate "GemTek PCI Radio Card support" 156 - depends on VIDEO_V4L2 && PCI 157 - ---help--- 158 - Choose Y here if you have this PCI FM radio card. 159 - 160 - In order to control your radio card, you will need to use programs 161 - that are compatible with the Video for Linux API. Information on 162 - this API and pointers to "v4l" programs may be found at 163 - <file:Documentation/video4linux/API.html>. 164 - 165 - To compile this driver as a module, choose M here: the 166 - module will be called radio-gemtek-pci. 167 - 168 154 config RADIO_MAXIRADIO 169 155 tristate "Guillemot MAXI Radio FM 2000 radio" 170 156 depends on VIDEO_V4L2 && PCI
-1
drivers/media/radio/Makefile
··· 13 13 obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o 14 14 obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o 15 15 obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o 16 - obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o 17 16 obj-$(CONFIG_RADIO_TRUST) += radio-trust.o 18 17 obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o 19 18 obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
+1
drivers/media/radio/radio-aimslab.c
··· 31 31 #include <linux/module.h> /* Modules */ 32 32 #include <linux/init.h> /* Initdata */ 33 33 #include <linux/ioport.h> /* request_region */ 34 + #include <linux/delay.h> /* msleep */ 34 35 #include <linux/videodev2.h> /* kernel radio structs */ 35 36 #include <linux/version.h> /* for KERNEL_VERSION MACRO */ 36 37 #include <linux/io.h> /* outb, outb_p */
-478
drivers/media/radio/radio-gemtek-pci.c
··· 1 - /* 2 - *************************************************************************** 3 - * 4 - * radio-gemtek-pci.c - Gemtek PCI Radio driver 5 - * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru> 6 - * 7 - *************************************************************************** 8 - * 9 - * This program is free software; you can redistribute it and/or 10 - * modify it under the terms of the GNU General Public License as 11 - * published by the Free Software Foundation; either version 2 of 12 - * the License, or (at your option) any later version. 13 - * 14 - * This program is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - * GNU General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU General Public 20 - * License along with this program; if not, write to the Free 21 - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 22 - * USA. 23 - * 24 - *************************************************************************** 25 - * 26 - * Gemtek Corp still silently refuses to release any specifications 27 - * of their multimedia devices, so the protocol still has to be 28 - * reverse engineered. 29 - * 30 - * The v4l code was inspired by Jonas Munsin's Gemtek serial line 31 - * radio device driver. 32 - * 33 - * Please, let me know if this piece of code was useful :) 34 - * 35 - * TODO: multiple device support and portability were not tested 36 - * 37 - * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> 38 - * 39 - *************************************************************************** 40 - */ 41 - 42 - #include <linux/types.h> 43 - #include <linux/list.h> 44 - #include <linux/module.h> 45 - #include <linux/init.h> 46 - #include <linux/pci.h> 47 - #include <linux/videodev2.h> 48 - #include <linux/errno.h> 49 - #include <linux/version.h> /* for KERNEL_VERSION MACRO */ 50 - #include <linux/io.h> 51 - #include <linux/slab.h> 52 - #include <media/v4l2-device.h> 53 - #include <media/v4l2-ioctl.h> 54 - 55 - MODULE_AUTHOR("Vladimir Shebordaev <vshebordaev@mail.ru>"); 56 - MODULE_DESCRIPTION("The video4linux driver for the Gemtek PCI Radio Card"); 57 - MODULE_LICENSE("GPL"); 58 - 59 - static int nr_radio = -1; 60 - static int mx = 1; 61 - 62 - module_param(mx, bool, 0); 63 - MODULE_PARM_DESC(mx, "single digit: 1 - turn off the turner upon module exit (default), 0 - do not"); 64 - module_param(nr_radio, int, 0); 65 - MODULE_PARM_DESC(nr_radio, "video4linux device number to use"); 66 - 67 - #define RADIO_VERSION KERNEL_VERSION(0, 0, 2) 68 - 69 - #ifndef PCI_VENDOR_ID_GEMTEK 70 - #define PCI_VENDOR_ID_GEMTEK 0x5046 71 - #endif 72 - 73 - #ifndef PCI_DEVICE_ID_GEMTEK_PR103 74 - #define PCI_DEVICE_ID_GEMTEK_PR103 0x1001 75 - #endif 76 - 77 - #ifndef GEMTEK_PCI_RANGE_LOW 78 - #define GEMTEK_PCI_RANGE_LOW (87*16000) 79 - #endif 80 - 81 - #ifndef GEMTEK_PCI_RANGE_HIGH 82 - #define GEMTEK_PCI_RANGE_HIGH (108*16000) 83 - #endif 84 - 85 - struct gemtek_pci { 86 - struct v4l2_device v4l2_dev; 87 - struct video_device vdev; 88 - struct mutex lock; 89 - struct pci_dev *pdev; 90 - 91 - u32 iobase; 92 - u32 length; 93 - 94 - u32 current_frequency; 95 - u8 mute; 96 - }; 97 - 98 - static inline struct gemtek_pci *to_gemtek_pci(struct v4l2_device *v4l2_dev) 99 - { 100 - return container_of(v4l2_dev, struct gemtek_pci, v4l2_dev); 101 - } 102 - 103 - static inline u8 gemtek_pci_out(u16 value, u32 port) 104 - { 105 - outw(value, port); 106 - 107 - return (u8)value; 108 - } 109 - 110 - #define _b0(v) (*((u8 *)&v)) 111 - 112 - static void __gemtek_pci_cmd(u16 value, u32 port, u8 *last_byte, int keep) 113 - { 114 - u8 byte = *last_byte; 115 - 116 - if (!value) { 117 - if (!keep) 118 - value = (u16)port; 119 - byte &= 0xfd; 120 - } else 121 - byte |= 2; 122 - 123 - _b0(value) = byte; 124 - outw(value, port); 125 - byte |= 1; 126 - _b0(value) = byte; 127 - outw(value, port); 128 - byte &= 0xfe; 129 - _b0(value) = byte; 130 - outw(value, port); 131 - 132 - *last_byte = byte; 133 - } 134 - 135 - static inline void gemtek_pci_nil(u32 port, u8 *last_byte) 136 - { 137 - __gemtek_pci_cmd(0x00, port, last_byte, false); 138 - } 139 - 140 - static inline void gemtek_pci_cmd(u16 cmd, u32 port, u8 *last_byte) 141 - { 142 - __gemtek_pci_cmd(cmd, port, last_byte, true); 143 - } 144 - 145 - static void gemtek_pci_setfrequency(struct gemtek_pci *card, unsigned long frequency) 146 - { 147 - int i; 148 - u32 value = frequency / 200 + 856; 149 - u16 mask = 0x8000; 150 - u8 last_byte; 151 - u32 port = card->iobase; 152 - 153 - mutex_lock(&card->lock); 154 - card->current_frequency = frequency; 155 - last_byte = gemtek_pci_out(0x06, port); 156 - 157 - i = 0; 158 - do { 159 - gemtek_pci_nil(port, &last_byte); 160 - i++; 161 - } while (i < 9); 162 - 163 - i = 0; 164 - do { 165 - gemtek_pci_cmd(value & mask, port, &last_byte); 166 - mask >>= 1; 167 - i++; 168 - } while (i < 16); 169 - 170 - outw(0x10, port); 171 - mutex_unlock(&card->lock); 172 - } 173 - 174 - 175 - static void gemtek_pci_mute(struct gemtek_pci *card) 176 - { 177 - mutex_lock(&card->lock); 178 - outb(0x1f, card->iobase); 179 - card->mute = true; 180 - mutex_unlock(&card->lock); 181 - } 182 - 183 - static void gemtek_pci_unmute(struct gemtek_pci *card) 184 - { 185 - if (card->mute) { 186 - gemtek_pci_setfrequency(card, card->current_frequency); 187 - card->mute = false; 188 - } 189 - } 190 - 191 - static int gemtek_pci_getsignal(struct gemtek_pci *card) 192 - { 193 - int sig; 194 - 195 - mutex_lock(&card->lock); 196 - sig = (inb(card->iobase) & 0x08) ? 0 : 1; 197 - mutex_unlock(&card->lock); 198 - return sig; 199 - } 200 - 201 - static int vidioc_querycap(struct file *file, void *priv, 202 - struct v4l2_capability *v) 203 - { 204 - struct gemtek_pci *card = video_drvdata(file); 205 - 206 - strlcpy(v->driver, "radio-gemtek-pci", sizeof(v->driver)); 207 - strlcpy(v->card, "GemTek PCI Radio", sizeof(v->card)); 208 - snprintf(v->bus_info, sizeof(v->bus_info), "PCI:%s", pci_name(card->pdev)); 209 - v->version = RADIO_VERSION; 210 - v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; 211 - return 0; 212 - } 213 - 214 - static int vidioc_g_tuner(struct file *file, void *priv, 215 - struct v4l2_tuner *v) 216 - { 217 - struct gemtek_pci *card = video_drvdata(file); 218 - 219 - if (v->index > 0) 220 - return -EINVAL; 221 - 222 - strlcpy(v->name, "FM", sizeof(v->name)); 223 - v->type = V4L2_TUNER_RADIO; 224 - v->rangelow = GEMTEK_PCI_RANGE_LOW; 225 - v->rangehigh = GEMTEK_PCI_RANGE_HIGH; 226 - v->rxsubchans = V4L2_TUNER_SUB_MONO; 227 - v->capability = V4L2_TUNER_CAP_LOW; 228 - v->audmode = V4L2_TUNER_MODE_MONO; 229 - v->signal = 0xffff * gemtek_pci_getsignal(card); 230 - return 0; 231 - } 232 - 233 - static int vidioc_s_tuner(struct file *file, void *priv, 234 - struct v4l2_tuner *v) 235 - { 236 - return v->index ? -EINVAL : 0; 237 - } 238 - 239 - static int vidioc_s_frequency(struct file *file, void *priv, 240 - struct v4l2_frequency *f) 241 - { 242 - struct gemtek_pci *card = video_drvdata(file); 243 - 244 - if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) 245 - return -EINVAL; 246 - if (f->frequency < GEMTEK_PCI_RANGE_LOW || 247 - f->frequency > GEMTEK_PCI_RANGE_HIGH) 248 - return -EINVAL; 249 - gemtek_pci_setfrequency(card, f->frequency); 250 - card->mute = false; 251 - return 0; 252 - } 253 - 254 - static int vidioc_g_frequency(struct file *file, void *priv, 255 - struct v4l2_frequency *f) 256 - { 257 - struct gemtek_pci *card = video_drvdata(file); 258 - 259 - if (f->tuner != 0) 260 - return -EINVAL; 261 - f->type = V4L2_TUNER_RADIO; 262 - f->frequency = card->current_frequency; 263 - return 0; 264 - } 265 - 266 - static int vidioc_queryctrl(struct file *file, void *priv, 267 - struct v4l2_queryctrl *qc) 268 - { 269 - switch (qc->id) { 270 - case V4L2_CID_AUDIO_MUTE: 271 - return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); 272 - case V4L2_CID_AUDIO_VOLUME: 273 - return v4l2_ctrl_query_fill(qc, 0, 65535, 65535, 65535); 274 - } 275 - return -EINVAL; 276 - } 277 - 278 - static int vidioc_g_ctrl(struct file *file, void *priv, 279 - struct v4l2_control *ctrl) 280 - { 281 - struct gemtek_pci *card = video_drvdata(file); 282 - 283 - switch (ctrl->id) { 284 - case V4L2_CID_AUDIO_MUTE: 285 - ctrl->value = card->mute; 286 - return 0; 287 - case V4L2_CID_AUDIO_VOLUME: 288 - if (card->mute) 289 - ctrl->value = 0; 290 - else 291 - ctrl->value = 65535; 292 - return 0; 293 - } 294 - return -EINVAL; 295 - } 296 - 297 - static int vidioc_s_ctrl(struct file *file, void *priv, 298 - struct v4l2_control *ctrl) 299 - { 300 - struct gemtek_pci *card = video_drvdata(file); 301 - 302 - switch (ctrl->id) { 303 - case V4L2_CID_AUDIO_MUTE: 304 - if (ctrl->value) 305 - gemtek_pci_mute(card); 306 - else 307 - gemtek_pci_unmute(card); 308 - return 0; 309 - case V4L2_CID_AUDIO_VOLUME: 310 - if (ctrl->value) 311 - gemtek_pci_unmute(card); 312 - else 313 - gemtek_pci_mute(card); 314 - return 0; 315 - } 316 - return -EINVAL; 317 - } 318 - 319 - static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) 320 - { 321 - *i = 0; 322 - return 0; 323 - } 324 - 325 - static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) 326 - { 327 - return i ? -EINVAL : 0; 328 - } 329 - 330 - static int vidioc_g_audio(struct file *file, void *priv, 331 - struct v4l2_audio *a) 332 - { 333 - a->index = 0; 334 - strlcpy(a->name, "Radio", sizeof(a->name)); 335 - a->capability = V4L2_AUDCAP_STEREO; 336 - return 0; 337 - } 338 - 339 - static int vidioc_s_audio(struct file *file, void *priv, 340 - struct v4l2_audio *a) 341 - { 342 - return a->index ? -EINVAL : 0; 343 - } 344 - 345 - enum { 346 - GEMTEK_PR103 347 - }; 348 - 349 - static char *card_names[] __devinitdata = { 350 - "GEMTEK_PR103" 351 - }; 352 - 353 - static struct pci_device_id gemtek_pci_id[] = 354 - { 355 - { PCI_VENDOR_ID_GEMTEK, PCI_DEVICE_ID_GEMTEK_PR103, 356 - PCI_ANY_ID, PCI_ANY_ID, 0, 0, GEMTEK_PR103 }, 357 - { 0 } 358 - }; 359 - 360 - MODULE_DEVICE_TABLE(pci, gemtek_pci_id); 361 - 362 - static const struct v4l2_file_operations gemtek_pci_fops = { 363 - .owner = THIS_MODULE, 364 - .unlocked_ioctl = video_ioctl2, 365 - }; 366 - 367 - static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { 368 - .vidioc_querycap = vidioc_querycap, 369 - .vidioc_g_tuner = vidioc_g_tuner, 370 - .vidioc_s_tuner = vidioc_s_tuner, 371 - .vidioc_g_audio = vidioc_g_audio, 372 - .vidioc_s_audio = vidioc_s_audio, 373 - .vidioc_g_input = vidioc_g_input, 374 - .vidioc_s_input = vidioc_s_input, 375 - .vidioc_g_frequency = vidioc_g_frequency, 376 - .vidioc_s_frequency = vidioc_s_frequency, 377 - .vidioc_queryctrl = vidioc_queryctrl, 378 - .vidioc_g_ctrl = vidioc_g_ctrl, 379 - .vidioc_s_ctrl = vidioc_s_ctrl, 380 - }; 381 - 382 - static int __devinit gemtek_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) 383 - { 384 - struct gemtek_pci *card; 385 - struct v4l2_device *v4l2_dev; 386 - int res; 387 - 388 - card = kzalloc(sizeof(struct gemtek_pci), GFP_KERNEL); 389 - if (card == NULL) { 390 - dev_err(&pdev->dev, "out of memory\n"); 391 - return -ENOMEM; 392 - } 393 - 394 - v4l2_dev = &card->v4l2_dev; 395 - mutex_init(&card->lock); 396 - card->pdev = pdev; 397 - 398 - strlcpy(v4l2_dev->name, "gemtek_pci", sizeof(v4l2_dev->name)); 399 - 400 - res = v4l2_device_register(&pdev->dev, v4l2_dev); 401 - if (res < 0) { 402 - v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); 403 - kfree(card); 404 - return res; 405 - } 406 - 407 - if (pci_enable_device(pdev)) 408 - goto err_pci; 409 - 410 - card->iobase = pci_resource_start(pdev, 0); 411 - card->length = pci_resource_len(pdev, 0); 412 - 413 - if (request_region(card->iobase, card->length, card_names[pci_id->driver_data]) == NULL) { 414 - v4l2_err(v4l2_dev, "i/o port already in use\n"); 415 - goto err_pci; 416 - } 417 - 418 - strlcpy(card->vdev.name, v4l2_dev->name, sizeof(card->vdev.name)); 419 - card->vdev.v4l2_dev = v4l2_dev; 420 - card->vdev.fops = &gemtek_pci_fops; 421 - card->vdev.ioctl_ops = &gemtek_pci_ioctl_ops; 422 - card->vdev.release = video_device_release_empty; 423 - video_set_drvdata(&card->vdev, card); 424 - 425 - gemtek_pci_mute(card); 426 - 427 - if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0) 428 - goto err_video; 429 - 430 - v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 431 - pdev->revision, card->iobase, card->iobase + card->length - 1); 432 - 433 - return 0; 434 - 435 - err_video: 436 - release_region(card->iobase, card->length); 437 - 438 - err_pci: 439 - v4l2_device_unregister(v4l2_dev); 440 - kfree(card); 441 - return -ENODEV; 442 - } 443 - 444 - static void __devexit gemtek_pci_remove(struct pci_dev *pdev) 445 - { 446 - struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev); 447 - struct gemtek_pci *card = to_gemtek_pci(v4l2_dev); 448 - 449 - video_unregister_device(&card->vdev); 450 - v4l2_device_unregister(v4l2_dev); 451 - 452 - release_region(card->iobase, card->length); 453 - 454 - if (mx) 455 - gemtek_pci_mute(card); 456 - 457 - kfree(card); 458 - } 459 - 460 - static struct pci_driver gemtek_pci_driver = { 461 - .name = "gemtek_pci", 462 - .id_table = gemtek_pci_id, 463 - .probe = gemtek_pci_probe, 464 - .remove = __devexit_p(gemtek_pci_remove), 465 - }; 466 - 467 - static int __init gemtek_pci_init(void) 468 - { 469 - return pci_register_driver(&gemtek_pci_driver); 470 - } 471 - 472 - static void __exit gemtek_pci_exit(void) 473 - { 474 - pci_unregister_driver(&gemtek_pci_driver); 475 - } 476 - 477 - module_init(gemtek_pci_init); 478 - module_exit(gemtek_pci_exit);
+2 -2
drivers/media/radio/radio-maxiradio.c
··· 77 77 /* TEA5757 pin mappings */ 78 78 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16; 79 79 80 - #define FREQ_LO (50 * 16000) 81 - #define FREQ_HI (150 * 16000) 80 + #define FREQ_LO (87 * 16000) 81 + #define FREQ_HI (108 * 16000) 82 82 83 83 #define FREQ_IF 171200 /* 10.7*16000 */ 84 84 #define FREQ_STEP 200 /* 12.5*16 */
+1 -1
drivers/media/radio/radio-wl1273.c
··· 1407 1407 .read = wl1273_fm_fops_read, 1408 1408 .write = wl1273_fm_fops_write, 1409 1409 .poll = wl1273_fm_fops_poll, 1410 - .ioctl = video_ioctl2, 1410 + .unlocked_ioctl = video_ioctl2, 1411 1411 .open = wl1273_fm_fops_open, 1412 1412 .release = wl1273_fm_fops_release, 1413 1413 };
+2 -7
drivers/media/radio/si470x/radio-si470x-common.c
··· 357 357 goto done; 358 358 359 359 /* sysconfig 1 */ 360 - radio->registers[SYSCONFIG1] = SYSCONFIG1_DE; 360 + radio->registers[SYSCONFIG1] = 361 + (de << 11) & SYSCONFIG1_DE; /* DE*/ 361 362 retval = si470x_set_register(radio, SYSCONFIG1); 362 363 if (retval < 0) 363 364 goto done; ··· 688 687 /* driver constants */ 689 688 strcpy(tuner->name, "FM"); 690 689 tuner->type = V4L2_TUNER_RADIO; 691 - #if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE) 692 690 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | 693 691 V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO; 694 - #else 695 - tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; 696 - #endif 697 692 698 693 /* range limits */ 699 694 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { ··· 715 718 tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 716 719 else 717 720 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 718 - #if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE) 719 721 /* If there is a reliable method of detecting an RDS channel, 720 722 then this code should check for that before setting this 721 723 RDS subchannel. */ 722 724 tuner->rxsubchans |= V4L2_TUNER_SUB_RDS; 723 - #endif 724 725 725 726 /* mono/stereo selector */ 726 727 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0)
+14 -9
drivers/media/rc/ene_ir.c
··· 446 446 447 447 select_timeout: 448 448 if (dev->rx_fan_input_inuse) { 449 - dev->rdev->rx_resolution = MS_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); 449 + dev->rdev->rx_resolution = US_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); 450 450 451 451 /* Fan input doesn't support timeouts, it just ends the 452 452 input with a maximum sample */ 453 453 dev->rdev->min_timeout = dev->rdev->max_timeout = 454 - MS_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * 454 + US_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * 455 455 ENE_FW_SAMPLE_PERIOD_FAN); 456 456 } else { 457 - dev->rdev->rx_resolution = MS_TO_NS(sample_period); 457 + dev->rdev->rx_resolution = US_TO_NS(sample_period); 458 458 459 459 /* Theoreticly timeout is unlimited, but we cap it 460 460 * because it was seen that on one device, it 461 461 * would stop sending spaces after around 250 msec. 462 462 * Besides, this is close to 2^32 anyway and timeout is u32. 463 463 */ 464 - dev->rdev->min_timeout = MS_TO_NS(127 * sample_period); 465 - dev->rdev->max_timeout = MS_TO_NS(200000); 464 + dev->rdev->min_timeout = US_TO_NS(127 * sample_period); 465 + dev->rdev->max_timeout = US_TO_NS(200000); 466 466 } 467 467 468 468 if (dev->hw_learning_and_tx_capable) 469 - dev->rdev->tx_resolution = MS_TO_NS(sample_period); 469 + dev->rdev->tx_resolution = US_TO_NS(sample_period); 470 470 471 471 if (dev->rdev->timeout > dev->rdev->max_timeout) 472 472 dev->rdev->timeout = dev->rdev->max_timeout; ··· 801 801 802 802 dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space"); 803 803 804 - ev.duration = MS_TO_NS(hw_sample); 804 + ev.duration = US_TO_NS(hw_sample); 805 805 ev.pulse = pulse; 806 806 ir_raw_event_store_with_filter(dev->rdev, &ev); 807 807 } ··· 821 821 dev->learning_mode_enabled = learning_mode_force; 822 822 823 823 /* Set reasonable default timeout */ 824 - dev->rdev->timeout = MS_TO_NS(150000); 824 + dev->rdev->timeout = US_TO_NS(150000); 825 825 } 826 826 827 827 /* Upload all hardware settings at once. Used at load and resume time */ ··· 1004 1004 /* validate resources */ 1005 1005 error = -ENODEV; 1006 1006 1007 + /* init these to -1, as 0 is valid for both */ 1008 + dev->hw_io = -1; 1009 + dev->irq = -1; 1010 + 1007 1011 if (!pnp_port_valid(pnp_dev, 0) || 1008 1012 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1009 1013 goto error; ··· 1076 1072 rdev->input_name = "ENE eHome Infrared Remote Transceiver"; 1077 1073 } 1078 1074 1075 + dev->rdev = rdev; 1076 + 1079 1077 ene_rx_setup_hw_buffer(dev); 1080 1078 ene_setup_default_settings(dev); 1081 1079 ene_setup_hw_settings(dev); ··· 1089 1083 if (error < 0) 1090 1084 goto error; 1091 1085 1092 - dev->rdev = rdev; 1093 1086 ene_notice("driver has been succesfully loaded"); 1094 1087 return 0; 1095 1088 error:
-2
drivers/media/rc/ene_ir.h
··· 201 201 #define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__) 202 202 #define dbg_regs(format, ...) __dbg(3, format, ## __VA_ARGS__) 203 203 204 - #define MS_TO_NS(msec) ((msec) * 1000) 205 - 206 204 struct ene_device { 207 205 struct pnp_dev *pnp_dev; 208 206 struct rc_dev *rdev;
+26 -34
drivers/media/rc/imon.c
··· 988 988 int retval; 989 989 struct imon_context *ictx = rc->priv; 990 990 struct device *dev = ictx->dev; 991 - bool pad_mouse; 992 991 unsigned char ir_proto_packet[] = { 993 992 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 994 993 ··· 999 1000 case RC_TYPE_RC6: 1000 1001 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); 1001 1002 ir_proto_packet[0] = 0x01; 1002 - pad_mouse = false; 1003 1003 break; 1004 1004 case RC_TYPE_UNKNOWN: 1005 1005 case RC_TYPE_OTHER: 1006 1006 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); 1007 - if (pad_stabilize && !nomouse) 1008 - pad_mouse = true; 1009 - else { 1007 + if (!pad_stabilize) 1010 1008 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1011 - pad_mouse = false; 1012 - } 1013 1009 /* ir_proto_packet[0] = 0x00; // already the default */ 1014 1010 rc_type = RC_TYPE_OTHER; 1015 1011 break; 1016 1012 default: 1017 1013 dev_warn(dev, "Unsupported IR protocol specified, overriding " 1018 1014 "to iMON IR protocol\n"); 1019 - if (pad_stabilize && !nomouse) 1020 - pad_mouse = true; 1021 - else { 1015 + if (!pad_stabilize) 1022 1016 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1023 - pad_mouse = false; 1024 - } 1025 1017 /* ir_proto_packet[0] = 0x00; // already the default */ 1026 1018 rc_type = RC_TYPE_OTHER; 1027 1019 break; ··· 1025 1035 goto out; 1026 1036 1027 1037 ictx->rc_type = rc_type; 1028 - ictx->pad_mouse = pad_mouse; 1038 + ictx->pad_mouse = false; 1029 1039 1030 1040 out: 1031 1041 return retval; ··· 1507 1517 spin_unlock_irqrestore(&ictx->kc_lock, flags); 1508 1518 return; 1509 1519 } else { 1510 - ictx->pad_mouse = 0; 1520 + ictx->pad_mouse = false; 1511 1521 dev_dbg(dev, "mouse mode disabled, passing key value\n"); 1512 1522 } 1513 1523 } ··· 1746 1756 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); 1747 1757 1748 1758 ictx->display_type = detected_display_type; 1749 - ictx->rdev->allowed_protos = allowed_protos; 1750 1759 ictx->rc_type = allowed_protos; 1751 1760 } 1752 1761 ··· 1828 1839 rdev->allowed_protos = RC_TYPE_OTHER | RC_TYPE_RC6; /* iMON PAD or MCE */ 1829 1840 rdev->change_protocol = imon_ir_change_protocol; 1830 1841 rdev->driver_name = MOD_NAME; 1831 - if (ictx->rc_type == RC_TYPE_RC6) 1832 - rdev->map_name = RC_MAP_IMON_MCE; 1833 - else 1834 - rdev->map_name = RC_MAP_IMON_PAD; 1835 1842 1836 1843 /* Enable front-panel buttons and/or knobs */ 1837 1844 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); ··· 1836 1851 if (ret) 1837 1852 dev_info(ictx->dev, "panel buttons/knobs setup failed\n"); 1838 1853 1839 - if (ictx->product == 0xffdc) 1854 + if (ictx->product == 0xffdc) { 1840 1855 imon_get_ffdc_type(ictx); 1856 + rdev->allowed_protos = ictx->rc_type; 1857 + } 1841 1858 1842 1859 imon_set_display_type(ictx); 1860 + 1861 + if (ictx->rc_type == RC_TYPE_RC6) 1862 + rdev->map_name = RC_MAP_IMON_MCE; 1863 + else 1864 + rdev->map_name = RC_MAP_IMON_PAD; 1843 1865 1844 1866 ret = rc_register_device(rdev); 1845 1867 if (ret < 0) { ··· 2100 2108 goto find_endpoint_failed; 2101 2109 } 2102 2110 2103 - ictx->idev = imon_init_idev(ictx); 2104 - if (!ictx->idev) { 2105 - dev_err(dev, "%s: input device setup failed\n", __func__); 2106 - goto idev_setup_failed; 2107 - } 2108 - 2109 - ictx->rdev = imon_init_rdev(ictx); 2110 - if (!ictx->rdev) { 2111 - dev_err(dev, "%s: rc device setup failed\n", __func__); 2112 - goto rdev_setup_failed; 2113 - } 2114 - 2115 2111 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, 2116 2112 usb_rcvintpipe(ictx->usbdev_intf0, 2117 2113 ictx->rx_endpoint_intf0->bEndpointAddress), ··· 2113 2133 goto urb_submit_failed; 2114 2134 } 2115 2135 2136 + ictx->idev = imon_init_idev(ictx); 2137 + if (!ictx->idev) { 2138 + dev_err(dev, "%s: input device setup failed\n", __func__); 2139 + goto idev_setup_failed; 2140 + } 2141 + 2142 + ictx->rdev = imon_init_rdev(ictx); 2143 + if (!ictx->rdev) { 2144 + dev_err(dev, "%s: rc device setup failed\n", __func__); 2145 + goto rdev_setup_failed; 2146 + } 2147 + 2116 2148 return ictx; 2117 2149 2118 - urb_submit_failed: 2119 - rc_unregister_device(ictx->rdev); 2120 2150 rdev_setup_failed: 2121 2151 input_unregister_device(ictx->idev); 2122 2152 idev_setup_failed: 2153 + usb_kill_urb(ictx->rx_urb_intf0); 2154 + urb_submit_failed: 2123 2155 find_endpoint_failed: 2124 2156 mutex_unlock(&ictx->lock); 2125 2157 usb_free_urb(tx_urb);
+1 -1
drivers/media/rc/ir-raw.c
··· 233 233 234 234 /* used internally by the sysfs interface */ 235 235 u64 236 - ir_raw_get_allowed_protocols() 236 + ir_raw_get_allowed_protocols(void) 237 237 { 238 238 u64 protocols; 239 239 mutex_lock(&ir_raw_handler_lock);
+26 -26
drivers/media/rc/keymaps/rc-dib0700-nec.c
··· 19 19 20 20 static struct rc_map_table dib0700_nec_table[] = { 21 21 /* Key codes for the Pixelview SBTVD remote */ 22 - { 0x8613, KEY_MUTE }, 23 - { 0x8612, KEY_POWER }, 24 - { 0x8601, KEY_1 }, 25 - { 0x8602, KEY_2 }, 26 - { 0x8603, KEY_3 }, 27 - { 0x8604, KEY_4 }, 28 - { 0x8605, KEY_5 }, 29 - { 0x8606, KEY_6 }, 30 - { 0x8607, KEY_7 }, 31 - { 0x8608, KEY_8 }, 32 - { 0x8609, KEY_9 }, 33 - { 0x8600, KEY_0 }, 34 - { 0x860d, KEY_CHANNELUP }, 35 - { 0x8619, KEY_CHANNELDOWN }, 36 - { 0x8610, KEY_VOLUMEUP }, 37 - { 0x860c, KEY_VOLUMEDOWN }, 22 + { 0x866b13, KEY_MUTE }, 23 + { 0x866b12, KEY_POWER }, 24 + { 0x866b01, KEY_1 }, 25 + { 0x866b02, KEY_2 }, 26 + { 0x866b03, KEY_3 }, 27 + { 0x866b04, KEY_4 }, 28 + { 0x866b05, KEY_5 }, 29 + { 0x866b06, KEY_6 }, 30 + { 0x866b07, KEY_7 }, 31 + { 0x866b08, KEY_8 }, 32 + { 0x866b09, KEY_9 }, 33 + { 0x866b00, KEY_0 }, 34 + { 0x866b0d, KEY_CHANNELUP }, 35 + { 0x866b19, KEY_CHANNELDOWN }, 36 + { 0x866b10, KEY_VOLUMEUP }, 37 + { 0x866b0c, KEY_VOLUMEDOWN }, 38 38 39 - { 0x860a, KEY_CAMERA }, 40 - { 0x860b, KEY_ZOOM }, 41 - { 0x861b, KEY_BACKSPACE }, 42 - { 0x8615, KEY_ENTER }, 39 + { 0x866b0a, KEY_CAMERA }, 40 + { 0x866b0b, KEY_ZOOM }, 41 + { 0x866b1b, KEY_BACKSPACE }, 42 + { 0x866b15, KEY_ENTER }, 43 43 44 - { 0x861d, KEY_UP }, 45 - { 0x861e, KEY_DOWN }, 46 - { 0x860e, KEY_LEFT }, 47 - { 0x860f, KEY_RIGHT }, 44 + { 0x866b1d, KEY_UP }, 45 + { 0x866b1e, KEY_DOWN }, 46 + { 0x866b0e, KEY_LEFT }, 47 + { 0x866b0f, KEY_RIGHT }, 48 48 49 - { 0x8618, KEY_RECORD }, 50 - { 0x861a, KEY_STOP }, 49 + { 0x866b18, KEY_RECORD }, 50 + { 0x866b1a, KEY_STOP }, 51 51 52 52 /* Key codes for the EvolutePC TVWay+ remote */ 53 53 { 0x7a00, KEY_MENU },
+1 -2
drivers/media/rc/mceusb.c
··· 48 48 #define USB_BUFLEN 32 /* USB reception buffer length */ 49 49 #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ 50 50 #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ 51 - #define MS_TO_NS(msec) ((msec) * 1000) 52 51 53 52 /* MCE constants */ 54 53 #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ ··· 857 858 ir->rem--; 858 859 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); 859 860 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) 860 - * MS_TO_NS(MCE_TIME_UNIT); 861 + * MS_TO_US(MCE_TIME_UNIT); 861 862 862 863 dev_dbg(ir->dev, "Storing %s with duration %d\n", 863 864 rawir.pulse ? "pulse" : "space",
-9
drivers/media/video/Kconfig
··· 141 141 To compile this driver as a module, choose M here: the 142 142 module will be called tda9840. 143 143 144 - config VIDEO_TDA9875 145 - tristate "Philips TDA9875 audio processor" 146 - depends on VIDEO_V4L2 && I2C 147 - ---help--- 148 - Support for tda9875 audio decoder chip found on some bt8xx boards. 149 - 150 - To compile this driver as a module, choose M here: the 151 - module will be called tda9875. 152 - 153 144 config VIDEO_TEA6415C 154 145 tristate "Philips TEA6415C audio processor" 155 146 depends on I2C
-1
drivers/media/video/Makefile
··· 27 27 obj-$(CONFIG_VIDEO_TUNER) += tuner.o 28 28 obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o 29 29 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o 30 - obj-$(CONFIG_VIDEO_TDA9875) += tda9875.o 31 30 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o 32 31 obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o 33 32 obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
+11
drivers/media/video/adv7175.c
··· 303 303 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7175, 0); 304 304 } 305 305 306 + static int adv7175_s_power(struct v4l2_subdev *sd, int on) 307 + { 308 + if (on) 309 + adv7175_write(sd, 0x01, 0x00); 310 + else 311 + adv7175_write(sd, 0x01, 0x78); 312 + 313 + return 0; 314 + } 315 + 306 316 /* ----------------------------------------------------------------------- */ 307 317 308 318 static const struct v4l2_subdev_core_ops adv7175_core_ops = { 309 319 .g_chip_ident = adv7175_g_chip_ident, 310 320 .init = adv7175_init, 321 + .s_power = adv7175_s_power, 311 322 }; 312 323 313 324 static const struct v4l2_subdev_video_ops adv7175_video_ops = {
-39
drivers/media/video/bt8xx/bttv-cards.c
··· 1373 1373 .gpiomute = 0x1800, 1374 1374 .audio_mode_gpio= fv2000s_audio, 1375 1375 .no_msp34xx = 1, 1376 - .no_tda9875 = 1, 1377 1376 .needs_tvaudio = 1, 1378 1377 .pll = PLL_28, 1379 1378 .tuner_type = TUNER_PHILIPS_PAL, ··· 1510 1511 .gpiomute = 0x09, 1511 1512 .needs_tvaudio = 1, 1512 1513 .no_msp34xx = 1, 1513 - .no_tda9875 = 1, 1514 1514 .pll = PLL_28, 1515 1515 .tuner_type = TUNER_PHILIPS_PAL, 1516 1516 .tuner_addr = ADDR_UNSET, ··· 1548 1550 .gpiomask2 = 0x07ff, 1549 1551 .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), 1550 1552 .no_msp34xx = 1, 1551 - .no_tda9875 = 1, 1552 1553 .tuner_type = TUNER_ABSENT, 1553 1554 .tuner_addr = ADDR_UNSET, 1554 1555 .muxsel_hook = rv605_muxsel, ··· 1683 1686 .tuner_type = TUNER_ABSENT, 1684 1687 .tuner_addr = ADDR_UNSET, 1685 1688 .no_msp34xx = 1, 1686 - .no_tda9875 = 1, 1687 1689 .no_tda7432 = 1, 1688 1690 }, 1689 1691 [BTTV_BOARD_OSPREY1x0_848] = { ··· 1695 1699 .tuner_type = TUNER_ABSENT, 1696 1700 .tuner_addr = ADDR_UNSET, 1697 1701 .no_msp34xx = 1, 1698 - .no_tda9875 = 1, 1699 1702 .no_tda7432 = 1, 1700 1703 }, 1701 1704 ··· 1709 1714 .tuner_type = TUNER_ABSENT, 1710 1715 .tuner_addr = ADDR_UNSET, 1711 1716 .no_msp34xx = 1, 1712 - .no_tda9875 = 1, 1713 1717 .no_tda7432 = 1, 1714 1718 }, 1715 1719 [BTTV_BOARD_OSPREY1x1] = { ··· 1721 1727 .tuner_type = TUNER_ABSENT, 1722 1728 .tuner_addr = ADDR_UNSET, 1723 1729 .no_msp34xx = 1, 1724 - .no_tda9875 = 1, 1725 1730 .no_tda7432 = 1, 1726 1731 }, 1727 1732 [BTTV_BOARD_OSPREY1x1_SVID] = { ··· 1733 1740 .tuner_type = TUNER_ABSENT, 1734 1741 .tuner_addr = ADDR_UNSET, 1735 1742 .no_msp34xx = 1, 1736 - .no_tda9875 = 1, 1737 1743 .no_tda7432 = 1, 1738 1744 }, 1739 1745 [BTTV_BOARD_OSPREY2xx] = { ··· 1745 1753 .tuner_type = TUNER_ABSENT, 1746 1754 .tuner_addr = ADDR_UNSET, 1747 1755 .no_msp34xx = 1, 1748 - .no_tda9875 = 1, 1749 1756 .no_tda7432 = 1, 1750 1757 }, 1751 1758 ··· 1759 1768 .tuner_type = TUNER_ABSENT, 1760 1769 .tuner_addr = ADDR_UNSET, 1761 1770 .no_msp34xx = 1, 1762 - .no_tda9875 = 1, 1763 1771 .no_tda7432 = 1, 1764 1772 }, 1765 1773 [BTTV_BOARD_OSPREY2x0] = { ··· 1771 1781 .tuner_type = TUNER_ABSENT, 1772 1782 .tuner_addr = ADDR_UNSET, 1773 1783 .no_msp34xx = 1, 1774 - .no_tda9875 = 1, 1775 1784 .no_tda7432 = 1, 1776 1785 }, 1777 1786 [BTTV_BOARD_OSPREY500] = { ··· 1783 1794 .tuner_type = TUNER_ABSENT, 1784 1795 .tuner_addr = ADDR_UNSET, 1785 1796 .no_msp34xx = 1, 1786 - .no_tda9875 = 1, 1787 1797 .no_tda7432 = 1, 1788 1798 }, 1789 1799 [BTTV_BOARD_OSPREY540] = { ··· 1793 1805 .tuner_type = TUNER_ABSENT, 1794 1806 .tuner_addr = ADDR_UNSET, 1795 1807 .no_msp34xx = 1, 1796 - .no_tda9875 = 1, 1797 1808 .no_tda7432 = 1, 1798 1809 }, 1799 1810 ··· 1807 1820 .tuner_type = TUNER_ABSENT, 1808 1821 .tuner_addr = ADDR_UNSET, 1809 1822 .no_msp34xx = 1, 1810 - .no_tda9875 = 1, 1811 1823 .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ 1812 1824 }, 1813 1825 [BTTV_BOARD_IDS_EAGLE] = { ··· 1821 1835 .muxsel = MUXSEL(2, 2, 2, 2), 1822 1836 .muxsel_hook = eagle_muxsel, 1823 1837 .no_msp34xx = 1, 1824 - .no_tda9875 = 1, 1825 1838 .pll = PLL_28, 1826 1839 }, 1827 1840 [BTTV_BOARD_PINNACLESAT] = { ··· 1831 1846 .tuner_type = TUNER_ABSENT, 1832 1847 .tuner_addr = ADDR_UNSET, 1833 1848 .no_msp34xx = 1, 1834 - .no_tda9875 = 1, 1835 1849 .no_tda7432 = 1, 1836 1850 .muxsel = MUXSEL(3, 1), 1837 1851 .pll = PLL_28, ··· 1881 1897 .svhs = 2, 1882 1898 .gpiomask = 0, 1883 1899 .no_msp34xx = 1, 1884 - .no_tda9875 = 1, 1885 1900 .no_tda7432 = 1, 1886 1901 .muxsel = MUXSEL(2, 0, 1), 1887 1902 .pll = PLL_28, ··· 1953 1970 /* Tuner, CVid, SVid, CVid over SVid connector */ 1954 1971 .muxsel = MUXSEL(2, 3, 1, 1), 1955 1972 .gpiomask = 0, 1956 - .no_tda9875 = 1, 1957 1973 .no_tda7432 = 1, 1958 1974 .tuner_type = TUNER_PHILIPS_PAL_I, 1959 1975 .tuner_addr = ADDR_UNSET, ··· 1999 2017 .muxsel = MUXSEL(2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0), 2000 2018 .muxsel_hook = xguard_muxsel, 2001 2019 .no_msp34xx = 1, 2002 - .no_tda9875 = 1, 2003 2020 .no_tda7432 = 1, 2004 2021 .pll = PLL_28, 2005 2022 }, ··· 2010 2029 .svhs = NO_SVHS, 2011 2030 .muxsel = MUXSEL(2, 3, 1, 0), 2012 2031 .no_msp34xx = 1, 2013 - .no_tda9875 = 1, 2014 2032 .no_tda7432 = 1, 2015 2033 .pll = PLL_28, 2016 2034 .tuner_type = TUNER_ABSENT, ··· 2114 2134 .svhs = NO_SVHS, /* card has no svhs */ 2115 2135 .needs_tvaudio = 0, 2116 2136 .no_msp34xx = 1, 2117 - .no_tda9875 = 1, 2118 2137 .no_tda7432 = 1, 2119 2138 .gpiomask = 0x00, 2120 2139 .muxsel = MUXSEL(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ··· 2135 2156 [BTTV_BOARD_TWINHAN_DST] = { 2136 2157 .name = "Twinhan DST + clones", 2137 2158 .no_msp34xx = 1, 2138 - .no_tda9875 = 1, 2139 2159 .no_tda7432 = 1, 2140 2160 .tuner_type = TUNER_ABSENT, 2141 2161 .tuner_addr = ADDR_UNSET, ··· 2149 2171 /* Vid In, SVid In, Vid over SVid in connector */ 2150 2172 .muxsel = MUXSEL(3, 1, 1, 3), 2151 2173 .no_msp34xx = 1, 2152 - .no_tda9875 = 1, 2153 2174 .no_tda7432 = 1, 2154 2175 .tuner_type = TUNER_ABSENT, 2155 2176 .tuner_addr = ADDR_UNSET, ··· 2203 2226 .svhs = NO_SVHS, 2204 2227 .muxsel = MUXSEL(2, 3, 1, 0), 2205 2228 .no_msp34xx = 1, 2206 - .no_tda9875 = 1, 2207 2229 .no_tda7432 = 1, 2208 2230 .needs_tvaudio = 0, 2209 2231 .tuner_type = TUNER_ABSENT, ··· 2254 2278 .gpiomask = 0, 2255 2279 .gpiomask2 = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/ 2256 2280 .no_msp34xx = 1, 2257 - .no_tda9875 = 1, 2258 2281 .no_tda7432 = 1, 2259 2282 /*878A input is always MUX0, see above.*/ 2260 2283 .muxsel = MUXSEL(2, 2, 2, 2), ··· 2277 2302 .tuner_type = TUNER_TEMIC_PAL, 2278 2303 .tuner_addr = ADDR_UNSET, 2279 2304 .no_msp34xx = 1, 2280 - .no_tda9875 = 1, 2281 2305 }, 2282 2306 [BTTV_BOARD_AVDVBT_771] = { 2283 2307 /* Wolfram Joost <wojo@frokaschwei.de> */ ··· 2287 2313 .tuner_addr = ADDR_UNSET, 2288 2314 .muxsel = MUXSEL(3, 3), 2289 2315 .no_msp34xx = 1, 2290 - .no_tda9875 = 1, 2291 2316 .no_tda7432 = 1, 2292 2317 .pll = PLL_28, 2293 2318 .has_dvb = 1, ··· 2302 2329 .svhs = 1, 2303 2330 .muxsel = MUXSEL(3, 1, 2, 0), /* Comp0, S-Video, ?, ? */ 2304 2331 .no_msp34xx = 1, 2305 - .no_tda9875 = 1, 2306 2332 .no_tda7432 = 1, 2307 2333 .pll = PLL_28, 2308 2334 .tuner_type = TUNER_ABSENT, ··· 2365 2393 /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */ 2366 2394 .name = "DViCO FusionHDTV DVB-T Lite", 2367 2395 .no_msp34xx = 1, 2368 - .no_tda9875 = 1, 2369 2396 .no_tda7432 = 1, 2370 2397 .pll = PLL_28, 2371 2398 .no_video = 1, ··· 2411 2440 .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), 2412 2441 .pll = PLL_28, 2413 2442 .no_msp34xx = 1, 2414 - .no_tda9875 = 1, 2415 2443 .no_tda7432 = 1, 2416 2444 .tuner_type = TUNER_ABSENT, 2417 2445 .tuner_addr = ADDR_UNSET, ··· 2448 2478 .pll = PLL_28, 2449 2479 .no_msp34xx = 1, 2450 2480 .no_tda7432 = 1, 2451 - .no_tda9875 = 1, 2452 2481 .muxsel_hook = kodicom4400r_muxsel, 2453 2482 }, 2454 2483 [BTTV_BOARD_KODICOM_4400R_SL] = { ··· 2469 2500 .pll = PLL_28, 2470 2501 .no_msp34xx = 1, 2471 2502 .no_tda7432 = 1, 2472 - .no_tda9875 = 1, 2473 2503 .muxsel_hook = kodicom4400r_muxsel, 2474 2504 }, 2475 2505 /* ---- card 0x86---------------------------------- */ ··· 2498 2530 .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, 2499 2531 .gpiomute = 0x00c00007, 2500 2532 .no_msp34xx = 1, 2501 - .no_tda9875 = 1, 2502 2533 .no_tda7432 = 1, 2503 2534 .has_dvb = 1, 2504 2535 }, ··· 2597 2630 .tuner_type = TUNER_ABSENT, 2598 2631 .tuner_addr = ADDR_UNSET, 2599 2632 .no_msp34xx = 1, 2600 - .no_tda9875 = 1, 2601 2633 .no_tda7432 = 1, 2602 2634 }, 2603 2635 /* ---- card 0x8d ---------------------------------- */ ··· 2624 2658 .muxsel = MUXSEL(2, 3, 1, 1), 2625 2659 .gpiomux = { 100000, 100002, 100002, 100000 }, 2626 2660 .no_msp34xx = 1, 2627 - .no_tda9875 = 1, 2628 2661 .no_tda7432 = 1, 2629 2662 .pll = PLL_28, 2630 2663 .tuner_type = TUNER_TNF_5335MF, ··· 2639 2674 .gpiomask = 0x0f, /* old: 7 */ 2640 2675 .muxsel = MUXSEL(0, 1, 3, 2), /* Composite 0-3 */ 2641 2676 .no_msp34xx = 1, 2642 - .no_tda9875 = 1, 2643 2677 .no_tda7432 = 1, 2644 2678 .tuner_type = TUNER_ABSENT, 2645 2679 .tuner_addr = ADDR_UNSET, ··· 2696 2732 .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, 2697 2733 .gpiomute = 0x00c00007, 2698 2734 .no_msp34xx = 1, 2699 - .no_tda9875 = 1, 2700 2735 .no_tda7432 = 1, 2701 2736 }, 2702 2737 /* ---- card 0x95---------------------------------- */ ··· 2837 2874 .pll = PLL_28, 2838 2875 .no_msp34xx = 1, 2839 2876 .no_tda7432 = 1, 2840 - .no_tda9875 = 1, 2841 2877 .muxsel_hook = gv800s_muxsel, 2842 2878 }, 2843 2879 [BTTV_BOARD_GEOVISION_GV800S_SL] = { ··· 2861 2899 .pll = PLL_28, 2862 2900 .no_msp34xx = 1, 2863 2901 .no_tda7432 = 1, 2864 - .no_tda9875 = 1, 2865 2902 .muxsel_hook = gv800s_muxsel, 2866 2903 }, 2867 2904 [BTTV_BOARD_PV183] = {
-1
drivers/media/video/bt8xx/bttv.h
··· 234 234 235 235 /* i2c audio flags */ 236 236 unsigned int no_msp34xx:1; 237 - unsigned int no_tda9875:1; 238 237 unsigned int no_tda7432:1; 239 238 unsigned int needs_tvaudio:1; 240 239 unsigned int msp34xx_alt:1;
+8 -3
drivers/media/video/cafe_ccic.c
··· 2001 2001 .min_width = 320, 2002 2002 .min_height = 240, 2003 2003 }; 2004 + struct i2c_board_info ov7670_info = { 2005 + .type = "ov7670", 2006 + .addr = 0x42, 2007 + .platform_data = &sensor_cfg, 2008 + }; 2004 2009 2005 2010 /* 2006 2011 * Start putting together one of our big camera structures. ··· 2067 2062 if (dmi_check_system(olpc_xo1_dmi)) 2068 2063 sensor_cfg.clock_speed = 45; 2069 2064 2070 - cam->sensor_addr = 0x42; 2071 - cam->sensor = v4l2_i2c_new_subdev_cfg(&cam->v4l2_dev, &cam->i2c_adapter, 2072 - "ov7670", 0, &sensor_cfg, cam->sensor_addr, NULL); 2065 + cam->sensor_addr = ov7670_info.addr; 2066 + cam->sensor = v4l2_i2c_new_subdev_board(&cam->v4l2_dev, &cam->i2c_adapter, 2067 + &ov7670_info, NULL); 2073 2068 if (cam->sensor == NULL) { 2074 2069 ret = -ENODEV; 2075 2070 goto out_smbus;
+1 -1
drivers/media/video/cpia2/cpia2.h
··· 378 378 379 379 struct camera_data { 380 380 /* locks */ 381 - struct mutex busy_lock; /* guard against SMP multithreading */ 381 + struct mutex v4l2_lock; /* serialize file operations */ 382 382 struct v4l2_prio_state prio; 383 383 384 384 /* camera status */
+15 -50
drivers/media/video/cpia2/cpia2_core.c
··· 2247 2247 2248 2248 2249 2249 cam->present = 1; 2250 - mutex_init(&cam->busy_lock); 2250 + mutex_init(&cam->v4l2_lock); 2251 2251 init_waitqueue_head(&cam->wq_stream); 2252 2252 2253 2253 return cam; ··· 2365 2365 char __user *buf, unsigned long count, int noblock) 2366 2366 { 2367 2367 struct framebuf *frame; 2368 - if (!count) { 2368 + 2369 + if (!count) 2369 2370 return 0; 2370 - } 2371 2371 2372 2372 if (!buf) { 2373 2373 ERR("%s: buffer NULL\n",__func__); ··· 2379 2379 return -EINVAL; 2380 2380 } 2381 2381 2382 - /* make this _really_ smp and multithread-safe */ 2383 - if (mutex_lock_interruptible(&cam->busy_lock)) 2384 - return -ERESTARTSYS; 2385 - 2386 2382 if (!cam->present) { 2387 2383 LOG("%s: camera removed\n",__func__); 2388 - mutex_unlock(&cam->busy_lock); 2389 2384 return 0; /* EOF */ 2390 2385 } 2391 2386 2392 - if(!cam->streaming) { 2387 + if (!cam->streaming) { 2393 2388 /* Start streaming */ 2394 2389 cpia2_usb_stream_start(cam, 2395 2390 cam->params.camera_state.stream_mode); ··· 2393 2398 /* Copy cam->curbuff in case it changes while we're processing */ 2394 2399 frame = cam->curbuff; 2395 2400 if (noblock && frame->status != FRAME_READY) { 2396 - mutex_unlock(&cam->busy_lock); 2397 2401 return -EAGAIN; 2398 2402 } 2399 2403 2400 - if(frame->status != FRAME_READY) { 2401 - mutex_unlock(&cam->busy_lock); 2404 + if (frame->status != FRAME_READY) { 2405 + mutex_unlock(&cam->v4l2_lock); 2402 2406 wait_event_interruptible(cam->wq_stream, 2403 2407 !cam->present || 2404 2408 (frame = cam->curbuff)->status == FRAME_READY); 2409 + mutex_lock(&cam->v4l2_lock); 2405 2410 if (signal_pending(current)) 2406 2411 return -ERESTARTSYS; 2407 - /* make this _really_ smp and multithread-safe */ 2408 - if (mutex_lock_interruptible(&cam->busy_lock)) { 2409 - return -ERESTARTSYS; 2410 - } 2411 - if(!cam->present) { 2412 - mutex_unlock(&cam->busy_lock); 2412 + if (!cam->present) 2413 2413 return 0; 2414 - } 2415 2414 } 2416 2415 2417 2416 /* copy data to user space */ 2418 - if (frame->length > count) { 2419 - mutex_unlock(&cam->busy_lock); 2417 + if (frame->length > count) 2420 2418 return -EFAULT; 2421 - } 2422 - if (copy_to_user(buf, frame->data, frame->length)) { 2423 - mutex_unlock(&cam->busy_lock); 2419 + if (copy_to_user(buf, frame->data, frame->length)) 2424 2420 return -EFAULT; 2425 - } 2426 2421 2427 2422 count = frame->length; 2428 2423 2429 2424 frame->status = FRAME_EMPTY; 2430 2425 2431 - mutex_unlock(&cam->busy_lock); 2432 2426 return count; 2433 2427 } 2434 2428 ··· 2431 2447 { 2432 2448 unsigned int status=0; 2433 2449 2434 - if(!cam) { 2450 + if (!cam) { 2435 2451 ERR("%s: Internal error, camera_data not found!\n",__func__); 2436 2452 return POLLERR; 2437 2453 } 2438 2454 2439 - mutex_lock(&cam->busy_lock); 2440 - 2441 - if(!cam->present) { 2442 - mutex_unlock(&cam->busy_lock); 2455 + if (!cam->present) 2443 2456 return POLLHUP; 2444 - } 2445 2457 2446 2458 if(!cam->streaming) { 2447 2459 /* Start streaming */ ··· 2445 2465 cam->params.camera_state.stream_mode); 2446 2466 } 2447 2467 2448 - mutex_unlock(&cam->busy_lock); 2449 2468 poll_wait(filp, &cam->wq_stream, wait); 2450 - mutex_lock(&cam->busy_lock); 2451 2469 2452 2470 if(!cam->present) 2453 2471 status = POLLHUP; 2454 2472 else if(cam->curbuff->status == FRAME_READY) 2455 2473 status = POLLIN | POLLRDNORM; 2456 2474 2457 - mutex_unlock(&cam->busy_lock); 2458 2475 return status; 2459 2476 } 2460 2477 ··· 2473 2496 2474 2497 DBG("mmap offset:%ld size:%ld\n", start_offset, size); 2475 2498 2476 - /* make this _really_ smp-safe */ 2477 - if (mutex_lock_interruptible(&cam->busy_lock)) 2478 - return -ERESTARTSYS; 2479 - 2480 - if (!cam->present) { 2481 - mutex_unlock(&cam->busy_lock); 2499 + if (!cam->present) 2482 2500 return -ENODEV; 2483 - } 2484 2501 2485 2502 if (size > cam->frame_size*cam->num_frames || 2486 2503 (start_offset % cam->frame_size) != 0 || 2487 - (start_offset+size > cam->frame_size*cam->num_frames)) { 2488 - mutex_unlock(&cam->busy_lock); 2504 + (start_offset+size > cam->frame_size*cam->num_frames)) 2489 2505 return -EINVAL; 2490 - } 2491 2506 2492 2507 pos = ((unsigned long) (cam->frame_buffer)) + start_offset; 2493 2508 while (size > 0) { 2494 2509 page = kvirt_to_pa(pos); 2495 - if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) { 2496 - mutex_unlock(&cam->busy_lock); 2510 + if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) 2497 2511 return -EAGAIN; 2498 - } 2499 2512 start += PAGE_SIZE; 2500 2513 pos += PAGE_SIZE; 2501 2514 if (size > PAGE_SIZE) ··· 2495 2528 } 2496 2529 2497 2530 cam->mmapped = true; 2498 - mutex_unlock(&cam->busy_lock); 2499 2531 return 0; 2500 2532 } 2501 -
+36 -72
drivers/media/video/cpia2/cpia2_v4l.c
··· 238 238 static int cpia2_open(struct file *file) 239 239 { 240 240 struct camera_data *cam = video_drvdata(file); 241 - int retval = 0; 241 + struct cpia2_fh *fh; 242 242 243 243 if (!cam) { 244 244 ERR("Internal error, camera_data not found!\n"); 245 245 return -ENODEV; 246 246 } 247 247 248 - if(mutex_lock_interruptible(&cam->busy_lock)) 249 - return -ERESTARTSYS; 248 + if (!cam->present) 249 + return -ENODEV; 250 250 251 - if(!cam->present) { 252 - retval = -ENODEV; 253 - goto err_return; 251 + if (cam->open_count == 0) { 252 + if (cpia2_allocate_buffers(cam)) 253 + return -ENOMEM; 254 + 255 + /* reset the camera */ 256 + if (cpia2_reset_camera(cam) < 0) 257 + return -EIO; 258 + 259 + cam->APP_len = 0; 260 + cam->COM_len = 0; 254 261 } 255 262 256 - if (cam->open_count > 0) { 257 - goto skip_init; 258 - } 259 - 260 - if (cpia2_allocate_buffers(cam)) { 261 - retval = -ENOMEM; 262 - goto err_return; 263 - } 264 - 265 - /* reset the camera */ 266 - if (cpia2_reset_camera(cam) < 0) { 267 - retval = -EIO; 268 - goto err_return; 269 - } 270 - 271 - cam->APP_len = 0; 272 - cam->COM_len = 0; 273 - 274 - skip_init: 275 - { 276 - struct cpia2_fh *fh = kmalloc(sizeof(*fh),GFP_KERNEL); 277 - if(!fh) { 278 - retval = -ENOMEM; 279 - goto err_return; 280 - } 281 - file->private_data = fh; 282 - fh->prio = V4L2_PRIORITY_UNSET; 283 - v4l2_prio_open(&cam->prio, &fh->prio); 284 - fh->mmapped = 0; 285 - } 263 + fh = kmalloc(sizeof(*fh), GFP_KERNEL); 264 + if (!fh) 265 + return -ENOMEM; 266 + file->private_data = fh; 267 + fh->prio = V4L2_PRIORITY_UNSET; 268 + v4l2_prio_open(&cam->prio, &fh->prio); 269 + fh->mmapped = 0; 286 270 287 271 ++cam->open_count; 288 272 289 273 cpia2_dbg_dump_registers(cam); 290 - 291 - err_return: 292 - mutex_unlock(&cam->busy_lock); 293 - return retval; 274 + return 0; 294 275 } 295 276 296 277 /****************************************************************************** ··· 285 304 struct camera_data *cam = video_get_drvdata(dev); 286 305 struct cpia2_fh *fh = file->private_data; 287 306 288 - mutex_lock(&cam->busy_lock); 289 - 290 307 if (cam->present && 291 - (cam->open_count == 1 292 - || fh->prio == V4L2_PRIORITY_RECORD 293 - )) { 308 + (cam->open_count == 1 || fh->prio == V4L2_PRIORITY_RECORD)) { 294 309 cpia2_usb_stream_stop(cam); 295 310 296 - if(cam->open_count == 1) { 311 + if (cam->open_count == 1) { 297 312 /* save camera state for later open */ 298 313 cpia2_save_camera_state(cam); 299 314 ··· 298 321 } 299 322 } 300 323 301 - { 302 - if(fh->mmapped) 303 - cam->mmapped = 0; 304 - v4l2_prio_close(&cam->prio, fh->prio); 305 - file->private_data = NULL; 306 - kfree(fh); 307 - } 324 + if (fh->mmapped) 325 + cam->mmapped = 0; 326 + v4l2_prio_close(&cam->prio, fh->prio); 327 + file->private_data = NULL; 328 + kfree(fh); 308 329 309 330 if (--cam->open_count == 0) { 310 331 cpia2_free_buffers(cam); 311 332 if (!cam->present) { 312 333 video_unregister_device(dev); 313 - mutex_unlock(&cam->busy_lock); 314 334 kfree(cam); 315 335 return 0; 316 336 } 317 337 } 318 - 319 - mutex_unlock(&cam->busy_lock); 320 338 321 339 return 0; 322 340 } ··· 377 405 return 0; 378 406 } 379 407 380 - mutex_unlock(&cam->busy_lock); 408 + mutex_unlock(&cam->v4l2_lock); 381 409 wait_event_interruptible(cam->wq_stream, 382 410 !cam->streaming || 383 411 frame->status == FRAME_READY); 384 - mutex_lock(&cam->busy_lock); 412 + mutex_lock(&cam->v4l2_lock); 385 413 if (signal_pending(current)) 386 414 return -ERESTARTSYS; 387 415 if(!cam->present) ··· 1265 1293 if(frame < 0) { 1266 1294 /* Wait for a frame to become available */ 1267 1295 struct framebuf *cb=cam->curbuff; 1268 - mutex_unlock(&cam->busy_lock); 1296 + mutex_unlock(&cam->v4l2_lock); 1269 1297 wait_event_interruptible(cam->wq_stream, 1270 1298 !cam->present || 1271 1299 (cb=cam->curbuff)->status == FRAME_READY); 1272 - mutex_lock(&cam->busy_lock); 1300 + mutex_lock(&cam->v4l2_lock); 1273 1301 if (signal_pending(current)) 1274 1302 return -ERESTARTSYS; 1275 1303 if(!cam->present) ··· 1309 1337 if (!cam) 1310 1338 return -ENOTTY; 1311 1339 1312 - /* make this _really_ smp-safe */ 1313 - if (mutex_lock_interruptible(&cam->busy_lock)) 1314 - return -ERESTARTSYS; 1315 - 1316 - if (!cam->present) { 1317 - mutex_unlock(&cam->busy_lock); 1340 + if (!cam->present) 1318 1341 return -ENODEV; 1319 - } 1320 1342 1321 1343 /* Priority check */ 1322 1344 switch (cmd) { ··· 1318 1352 { 1319 1353 struct cpia2_fh *fh = file->private_data; 1320 1354 retval = v4l2_prio_check(&cam->prio, fh->prio); 1321 - if(retval) { 1322 - mutex_unlock(&cam->busy_lock); 1355 + if (retval) 1323 1356 return retval; 1324 - } 1325 1357 break; 1326 1358 } 1327 1359 default: ··· 1493 1529 break; 1494 1530 } 1495 1531 1496 - mutex_unlock(&cam->busy_lock); 1497 1532 return retval; 1498 1533 } 1499 1534 ··· 1559 1596 .release = cpia2_close, 1560 1597 .read = cpia2_v4l_read, 1561 1598 .poll = cpia2_v4l_poll, 1562 - .ioctl = cpia2_ioctl, 1599 + .unlocked_ioctl = cpia2_ioctl, 1563 1600 .mmap = cpia2_mmap, 1564 1601 }; 1565 1602 ··· 1583 1620 1584 1621 memcpy(cam->vdev, &cpia2_template, sizeof(cpia2_template)); 1585 1622 video_set_drvdata(cam->vdev, cam); 1623 + cam->vdev->lock = &cam->v4l2_lock; 1586 1624 1587 1625 reset_camera_struct_v4l(cam); 1588 1626
+2 -22
drivers/media/video/cx18/cx18-driver.c
··· 664 664 { 665 665 snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in", 666 666 cx->v4l2_dev.name); 667 - cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name); 667 + cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0); 668 668 if (cx->in_work_queue == NULL) { 669 669 CX18_ERR("Unable to create incoming mailbox handler thread\n"); 670 - return -ENOMEM; 671 - } 672 - return 0; 673 - } 674 - 675 - static int __devinit cx18_create_out_workq(struct cx18 *cx) 676 - { 677 - snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out", 678 - cx->v4l2_dev.name); 679 - cx->out_work_queue = create_workqueue(cx->out_workq_name); 680 - if (cx->out_work_queue == NULL) { 681 - CX18_ERR("Unable to create outgoing mailbox handler threads\n"); 682 670 return -ENOMEM; 683 671 } 684 672 return 0; ··· 698 710 mutex_init(&cx->epu2apu_mb_lock); 699 711 mutex_init(&cx->epu2cpu_mb_lock); 700 712 701 - ret = cx18_create_out_workq(cx); 713 + ret = cx18_create_in_workq(cx); 702 714 if (ret) 703 715 return ret; 704 - 705 - ret = cx18_create_in_workq(cx); 706 - if (ret) { 707 - destroy_workqueue(cx->out_work_queue); 708 - return ret; 709 - } 710 716 711 717 cx18_init_in_work_orders(cx); 712 718 ··· 1089 1107 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 1090 1108 free_workqueues: 1091 1109 destroy_workqueue(cx->in_work_queue); 1092 - destroy_workqueue(cx->out_work_queue); 1093 1110 err: 1094 1111 if (retval == 0) 1095 1112 retval = -ENODEV; ··· 1240 1259 cx18_halt_firmware(cx); 1241 1260 1242 1261 destroy_workqueue(cx->in_work_queue); 1243 - destroy_workqueue(cx->out_work_queue); 1244 1262 1245 1263 cx18_streams_cleanup(cx, 1); 1246 1264
-3
drivers/media/video/cx18/cx18-driver.h
··· 617 617 struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS]; 618 618 char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */ 619 619 620 - struct workqueue_struct *out_work_queue; 621 - char out_workq_name[12]; /* "cx18-NN-out" */ 622 - 623 620 /* i2c */ 624 621 struct i2c_adapter i2c_adap[2]; 625 622 struct i2c_algo_bit_data i2c_algo[2];
+1 -2
drivers/media/video/cx18/cx18-streams.h
··· 42 42 /* Related to submission of mdls to firmware */ 43 43 static inline void cx18_stream_load_fw_queue(struct cx18_stream *s) 44 44 { 45 - struct cx18 *cx = s->cx; 46 - queue_work(cx->out_work_queue, &s->out_work_order); 45 + schedule_work(&s->out_work_order); 47 46 } 48 47 49 48 static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s,
+2 -3
drivers/media/video/cx231xx/cx231xx-dvb.c
··· 28 28 #include <media/videobuf-vmalloc.h> 29 29 30 30 #include "xc5000.h" 31 - #include "dvb_dummy_fe.h" 32 31 #include "s5h1432.h" 33 32 #include "tda18271.h" 34 33 #include "s5h1411.h" ··· 618 619 619 620 if (dev->dvb->frontend == NULL) { 620 621 printk(DRIVER_NAME 621 - ": Failed to attach dummy front end\n"); 622 + ": Failed to attach s5h1411 front end\n"); 622 623 result = -EINVAL; 623 624 goto out_free; 624 625 } ··· 664 665 665 666 if (dev->dvb->frontend == NULL) { 666 667 printk(DRIVER_NAME 667 - ": Failed to attach dummy front end\n"); 668 + ": Failed to attach s5h1411 front end\n"); 668 669 result = -EINVAL; 669 670 goto out_free; 670 671 }
+6 -16
drivers/media/video/cx25840/cx25840-core.c
··· 1682 1682 return 0; 1683 1683 } 1684 1684 1685 - static int cx25840_s_config(struct v4l2_subdev *sd, int irq, void *platform_data) 1686 - { 1687 - struct cx25840_state *state = to_state(sd); 1688 - struct i2c_client *client = v4l2_get_subdevdata(sd); 1689 - 1690 - if (platform_data) { 1691 - struct cx25840_platform_data *pdata = platform_data; 1692 - 1693 - state->pvr150_workaround = pdata->pvr150_workaround; 1694 - set_input(client, state->vid_input, state->aud_input); 1695 - } 1696 - return 0; 1697 - } 1698 - 1699 1685 static int cx23885_irq_handler(struct v4l2_subdev *sd, u32 status, 1700 1686 bool *handled) 1701 1687 { ··· 1773 1787 1774 1788 static const struct v4l2_subdev_core_ops cx25840_core_ops = { 1775 1789 .log_status = cx25840_log_status, 1776 - .s_config = cx25840_s_config, 1777 1790 .g_chip_ident = cx25840_g_chip_ident, 1778 1791 .g_ctrl = v4l2_subdev_g_ctrl, 1779 1792 .s_ctrl = v4l2_subdev_s_ctrl, ··· 1959 1974 state->vid_input = CX25840_COMPOSITE7; 1960 1975 state->aud_input = CX25840_AUDIO8; 1961 1976 state->audclk_freq = 48000; 1962 - state->pvr150_workaround = 0; 1963 1977 state->audmode = V4L2_TUNER_MODE_LANG1; 1964 1978 state->vbi_line_offset = 8; 1965 1979 state->id = id; ··· 2017 2033 } 2018 2034 v4l2_ctrl_cluster(2, &state->volume); 2019 2035 v4l2_ctrl_handler_setup(&state->hdl); 2036 + 2037 + if (client->dev.platform_data) { 2038 + struct cx25840_platform_data *pdata = client->dev.platform_data; 2039 + 2040 + state->pvr150_workaround = pdata->pvr150_workaround; 2041 + } 2020 2042 2021 2043 cx25840_ir_probe(sd); 2022 2044 return 0;
+177
drivers/media/video/davinci/vpif.c
··· 41 41 42 42 void __iomem *vpif_base; 43 43 44 + /** 45 + * ch_params: video standard configuration parameters for vpif 46 + * The table must include all presets from supported subdevices. 47 + */ 48 + const struct vpif_channel_config_params ch_params[] = { 49 + /* HDTV formats */ 50 + { 51 + .name = "480p59_94", 52 + .width = 720, 53 + .height = 480, 54 + .frm_fmt = 1, 55 + .ycmux_mode = 0, 56 + .eav2sav = 138-8, 57 + .sav2eav = 720, 58 + .l1 = 1, 59 + .l3 = 43, 60 + .l5 = 523, 61 + .vsize = 525, 62 + .capture_format = 0, 63 + .vbi_supported = 0, 64 + .hd_sd = 1, 65 + .dv_preset = V4L2_DV_480P59_94, 66 + }, 67 + { 68 + .name = "576p50", 69 + .width = 720, 70 + .height = 576, 71 + .frm_fmt = 1, 72 + .ycmux_mode = 0, 73 + .eav2sav = 144-8, 74 + .sav2eav = 720, 75 + .l1 = 1, 76 + .l3 = 45, 77 + .l5 = 621, 78 + .vsize = 625, 79 + .capture_format = 0, 80 + .vbi_supported = 0, 81 + .hd_sd = 1, 82 + .dv_preset = V4L2_DV_576P50, 83 + }, 84 + { 85 + .name = "720p50", 86 + .width = 1280, 87 + .height = 720, 88 + .frm_fmt = 1, 89 + .ycmux_mode = 0, 90 + .eav2sav = 700-8, 91 + .sav2eav = 1280, 92 + .l1 = 1, 93 + .l3 = 26, 94 + .l5 = 746, 95 + .vsize = 750, 96 + .capture_format = 0, 97 + .vbi_supported = 0, 98 + .hd_sd = 1, 99 + .dv_preset = V4L2_DV_720P50, 100 + }, 101 + { 102 + .name = "720p60", 103 + .width = 1280, 104 + .height = 720, 105 + .frm_fmt = 1, 106 + .ycmux_mode = 0, 107 + .eav2sav = 370 - 8, 108 + .sav2eav = 1280, 109 + .l1 = 1, 110 + .l3 = 26, 111 + .l5 = 746, 112 + .vsize = 750, 113 + .capture_format = 0, 114 + .vbi_supported = 0, 115 + .hd_sd = 1, 116 + .dv_preset = V4L2_DV_720P60, 117 + }, 118 + { 119 + .name = "1080I50", 120 + .width = 1920, 121 + .height = 1080, 122 + .frm_fmt = 0, 123 + .ycmux_mode = 0, 124 + .eav2sav = 720 - 8, 125 + .sav2eav = 1920, 126 + .l1 = 1, 127 + .l3 = 21, 128 + .l5 = 561, 129 + .l7 = 563, 130 + .l9 = 584, 131 + .l11 = 1124, 132 + .vsize = 1125, 133 + .capture_format = 0, 134 + .vbi_supported = 0, 135 + .hd_sd = 1, 136 + .dv_preset = V4L2_DV_1080I50, 137 + }, 138 + { 139 + .name = "1080I60", 140 + .width = 1920, 141 + .height = 1080, 142 + .frm_fmt = 0, 143 + .ycmux_mode = 0, 144 + .eav2sav = 280 - 8, 145 + .sav2eav = 1920, 146 + .l1 = 1, 147 + .l3 = 21, 148 + .l5 = 561, 149 + .l7 = 563, 150 + .l9 = 584, 151 + .l11 = 1124, 152 + .vsize = 1125, 153 + .capture_format = 0, 154 + .vbi_supported = 0, 155 + .hd_sd = 1, 156 + .dv_preset = V4L2_DV_1080I60, 157 + }, 158 + { 159 + .name = "1080p60", 160 + .width = 1920, 161 + .height = 1080, 162 + .frm_fmt = 1, 163 + .ycmux_mode = 0, 164 + .eav2sav = 280 - 8, 165 + .sav2eav = 1920, 166 + .l1 = 1, 167 + .l3 = 42, 168 + .l5 = 1122, 169 + .vsize = 1125, 170 + .capture_format = 0, 171 + .vbi_supported = 0, 172 + .hd_sd = 1, 173 + .dv_preset = V4L2_DV_1080P60, 174 + }, 175 + 176 + /* SDTV formats */ 177 + { 178 + .name = "NTSC_M", 179 + .width = 720, 180 + .height = 480, 181 + .frm_fmt = 0, 182 + .ycmux_mode = 1, 183 + .eav2sav = 268, 184 + .sav2eav = 1440, 185 + .l1 = 1, 186 + .l3 = 23, 187 + .l5 = 263, 188 + .l7 = 266, 189 + .l9 = 286, 190 + .l11 = 525, 191 + .vsize = 525, 192 + .capture_format = 0, 193 + .vbi_supported = 1, 194 + .hd_sd = 0, 195 + .stdid = V4L2_STD_525_60, 196 + }, 197 + { 198 + .name = "PAL_BDGHIK", 199 + .width = 720, 200 + .height = 576, 201 + .frm_fmt = 0, 202 + .ycmux_mode = 1, 203 + .eav2sav = 280, 204 + .sav2eav = 1440, 205 + .l1 = 1, 206 + .l3 = 23, 207 + .l5 = 311, 208 + .l7 = 313, 209 + .l9 = 336, 210 + .l11 = 624, 211 + .vsize = 625, 212 + .capture_format = 0, 213 + .vbi_supported = 1, 214 + .hd_sd = 0, 215 + .stdid = V4L2_STD_625_50, 216 + }, 217 + }; 218 + 219 + const unsigned int vpif_ch_params_count = ARRAY_SIZE(ch_params); 220 + 44 221 static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val) 45 222 { 46 223 if (val)
+10 -8
drivers/media/video/davinci/vpif.h
··· 577 577 char name[VPIF_MAX_NAME]; /* Name of the mode */ 578 578 u16 width; /* Indicates width of the image */ 579 579 u16 height; /* Indicates height of the image */ 580 - u8 fps; 581 - u8 frm_fmt; /* Indicates whether this is interlaced 582 - * or progressive format */ 583 - u8 ycmux_mode; /* Indicates whether this mode requires 584 - * single or two channels */ 585 - u16 eav2sav; /* length of sav 2 eav */ 580 + u8 frm_fmt; /* Interlaced (0) or progressive (1) */ 581 + u8 ycmux_mode; /* This mode requires one (0) or two (1) 582 + channels */ 583 + u16 eav2sav; /* length of eav 2 sav */ 586 584 u16 sav2eav; /* length of sav 2 eav */ 587 585 u16 l1, l3, l5, l7, l9, l11; /* Other parameter configurations */ 588 586 u16 vsize; /* Vertical size of the image */ ··· 588 590 * is in BT or in CCD/CMOS */ 589 591 u8 vbi_supported; /* Indicates whether this mode 590 592 * supports capturing vbi or not */ 591 - u8 hd_sd; 592 - v4l2_std_id stdid; 593 + u8 hd_sd; /* HDTV (1) or SDTV (0) format */ 594 + v4l2_std_id stdid; /* SDTV format */ 595 + u32 dv_preset; /* HDTV format */ 593 596 }; 597 + 598 + extern const unsigned int vpif_ch_params_count; 599 + extern const struct vpif_channel_config_params ch_params[]; 594 600 595 601 struct vpif_video_params; 596 602 struct vpif_params;
+349 -102
drivers/media/video/davinci/vpif_capture.c
··· 37 37 #include <linux/slab.h> 38 38 #include <media/v4l2-device.h> 39 39 #include <media/v4l2-ioctl.h> 40 + #include <media/v4l2-chip-ident.h> 40 41 41 42 #include "vpif_capture.h" 42 43 #include "vpif.h" ··· 80 79 /* global variables */ 81 80 static struct vpif_device vpif_obj = { {NULL} }; 82 81 static struct device *vpif_dev; 83 - 84 - /** 85 - * ch_params: video standard configuration parameters for vpif 86 - */ 87 - static const struct vpif_channel_config_params ch_params[] = { 88 - { 89 - "NTSC_M", 720, 480, 30, 0, 1, 268, 1440, 1, 23, 263, 266, 90 - 286, 525, 525, 0, 1, 0, V4L2_STD_525_60, 91 - }, 92 - { 93 - "PAL_BDGHIK", 720, 576, 25, 0, 1, 280, 1440, 1, 23, 311, 313, 94 - 336, 624, 625, 0, 1, 0, V4L2_STD_625_50, 95 - }, 96 - }; 97 82 98 83 /** 99 84 * vpif_uservirt_to_phys : translate user/virtual address to phy address ··· 329 342 * @dev_id: dev_id ptr 330 343 * 331 344 * It changes status of the captured buffer, takes next buffer from the queue 332 - * and sets its address in VPIF registers 345 + * and sets its address in VPIF registers 333 346 */ 334 347 static irqreturn_t vpif_channel_isr(int irq, void *dev_id) 335 348 { ··· 422 435 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 423 436 struct vpif_params *vpifparams = &ch->vpifparams; 424 437 const struct vpif_channel_config_params *config; 425 - struct vpif_channel_config_params *std_info; 438 + struct vpif_channel_config_params *std_info = &vpifparams->std_info; 426 439 struct video_obj *vid_ch = &ch->video; 427 440 int index; 428 441 429 442 vpif_dbg(2, debug, "vpif_update_std_info\n"); 430 443 431 - std_info = &vpifparams->std_info; 432 - 433 - for (index = 0; index < ARRAY_SIZE(ch_params); index++) { 444 + for (index = 0; index < vpif_ch_params_count; index++) { 434 445 config = &ch_params[index]; 435 - if (config->stdid & vid_ch->stdid) { 436 - memcpy(std_info, config, sizeof(*config)); 437 - break; 446 + if (config->hd_sd == 0) { 447 + vpif_dbg(2, debug, "SD format\n"); 448 + if (config->stdid & vid_ch->stdid) { 449 + memcpy(std_info, config, sizeof(*config)); 450 + break; 451 + } 452 + } else { 453 + vpif_dbg(2, debug, "HD format\n"); 454 + if (config->dv_preset == vid_ch->dv_preset) { 455 + memcpy(std_info, config, sizeof(*config)); 456 + break; 457 + } 438 458 } 439 459 } 440 460 441 461 /* standard not found */ 442 - if (index == ARRAY_SIZE(ch_params)) 462 + if (index == vpif_ch_params_count) 443 463 return -EINVAL; 444 464 445 465 common->fmt.fmt.pix.width = std_info->width; ··· 456 462 common->fmt.fmt.pix.bytesperline = std_info->width; 457 463 vpifparams->video_params.hpitch = std_info->width; 458 464 vpifparams->video_params.storage_mode = std_info->frm_fmt; 465 + 459 466 return 0; 460 467 } 461 468 ··· 752 757 struct video_obj *vid_ch; 753 758 struct channel_obj *ch; 754 759 struct vpif_fh *fh; 755 - int i, ret = 0; 760 + int i; 756 761 757 762 vpif_dbg(2, debug, "vpif_open\n"); 758 763 ··· 760 765 761 766 vid_ch = &ch->video; 762 767 common = &ch->common[VPIF_VIDEO_INDEX]; 763 - 764 - if (mutex_lock_interruptible(&common->lock)) 765 - return -ERESTARTSYS; 766 768 767 769 if (NULL == ch->curr_subdev_info) { 768 770 /** ··· 777 785 } 778 786 if (i == config->subdev_count) { 779 787 vpif_err("No sub device registered\n"); 780 - ret = -ENOENT; 781 - goto exit; 788 + return -ENOENT; 782 789 } 783 790 } 784 791 ··· 785 794 fh = kzalloc(sizeof(struct vpif_fh), GFP_KERNEL); 786 795 if (NULL == fh) { 787 796 vpif_err("unable to allocate memory for file handle object\n"); 788 - ret = -ENOMEM; 789 - goto exit; 797 + return -ENOMEM; 790 798 } 791 799 792 800 /* store pointer to fh in private_data member of filep */ ··· 805 815 /* Initialize priority of this instance to default priority */ 806 816 fh->prio = V4L2_PRIORITY_UNSET; 807 817 v4l2_prio_open(&ch->prio, &fh->prio); 808 - exit: 809 - mutex_unlock(&common->lock); 810 - return ret; 818 + return 0; 811 819 } 812 820 813 821 /** ··· 824 836 vpif_dbg(2, debug, "vpif_release\n"); 825 837 826 838 common = &ch->common[VPIF_VIDEO_INDEX]; 827 - 828 - if (mutex_lock_interruptible(&common->lock)) 829 - return -ERESTARTSYS; 830 839 831 840 /* if this instance is doing IO */ 832 841 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { ··· 847 862 848 863 /* Decrement channel usrs counter */ 849 864 ch->usrs--; 850 - 851 - /* unlock mutex on channel object */ 852 - mutex_unlock(&common->lock); 853 865 854 866 /* Close the priority */ 855 867 v4l2_prio_close(&ch->prio, fh->prio); ··· 872 890 struct channel_obj *ch = fh->channel; 873 891 struct common_obj *common; 874 892 u8 index = 0; 875 - int ret = 0; 876 893 877 894 vpif_dbg(2, debug, "vpif_reqbufs\n"); 878 895 ··· 894 913 895 914 common = &ch->common[index]; 896 915 897 - if (mutex_lock_interruptible(&common->lock)) 898 - return -ERESTARTSYS; 899 - 900 - if (0 != common->io_usrs) { 901 - ret = -EBUSY; 902 - goto reqbuf_exit; 903 - } 916 + if (0 != common->io_usrs) 917 + return -EBUSY; 904 918 905 919 /* Initialize videobuf queue as per the buffer type */ 906 920 videobuf_queue_dma_contig_init(&common->buffer_queue, ··· 904 928 reqbuf->type, 905 929 common->fmt.fmt.pix.field, 906 930 sizeof(struct videobuf_buffer), fh, 907 - NULL); 931 + &common->lock); 908 932 909 933 /* Set io allowed member of file handle to TRUE */ 910 934 fh->io_allowed[index] = 1; ··· 915 939 INIT_LIST_HEAD(&common->dma_queue); 916 940 917 941 /* Allocate buffers */ 918 - ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); 919 - 920 - reqbuf_exit: 921 - mutex_unlock(&common->lock); 922 - return ret; 942 + return videobuf_reqbufs(&common->buffer_queue, reqbuf); 923 943 } 924 944 925 945 /** ··· 1129 1157 return ret; 1130 1158 } 1131 1159 1132 - if (mutex_lock_interruptible(&common->lock)) { 1133 - ret = -ERESTARTSYS; 1134 - goto streamoff_exit; 1135 - } 1136 - 1137 1160 /* If buffer queue is empty, return error */ 1138 1161 if (list_empty(&common->dma_queue)) { 1139 1162 vpif_dbg(1, debug, "buffer queue is empty\n"); ··· 1207 1240 enable_channel1(1); 1208 1241 } 1209 1242 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; 1210 - mutex_unlock(&common->lock); 1211 1243 return ret; 1212 1244 1213 1245 exit: 1214 - mutex_unlock(&common->lock); 1215 - streamoff_exit: 1216 - ret = videobuf_streamoff(&common->buffer_queue); 1246 + videobuf_streamoff(&common->buffer_queue); 1217 1247 return ret; 1218 1248 } 1219 1249 ··· 1248 1284 return -EINVAL; 1249 1285 } 1250 1286 1251 - if (mutex_lock_interruptible(&common->lock)) 1252 - return -ERESTARTSYS; 1253 - 1254 1287 /* disable channel */ 1255 1288 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { 1256 1289 enable_channel0(0); ··· 1264 1303 1265 1304 if (ret && (ret != -ENOIOCTLCMD)) 1266 1305 vpif_dbg(1, debug, "stream off failed in subdev\n"); 1267 - 1268 - mutex_unlock(&common->lock); 1269 1306 1270 1307 return videobuf_streamoff(&common->buffer_queue); 1271 1308 } ··· 1340 1381 { 1341 1382 struct vpif_fh *fh = priv; 1342 1383 struct channel_obj *ch = fh->channel; 1343 - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 1344 1384 int ret = 0; 1345 1385 1346 1386 vpif_dbg(2, debug, "vpif_querystd\n"); 1347 - 1348 - if (mutex_lock_interruptible(&common->lock)) 1349 - return -ERESTARTSYS; 1350 1387 1351 1388 /* Call querystd function of decoder device */ 1352 1389 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], video, ··· 1350 1395 if (ret < 0) 1351 1396 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1352 1397 1353 - mutex_unlock(&common->lock); 1354 1398 return ret; 1355 1399 } 1356 1400 ··· 1405 1451 fh->initialized = 1; 1406 1452 1407 1453 /* Call encoder subdevice function to set the standard */ 1408 - if (mutex_lock_interruptible(&common->lock)) 1409 - return -ERESTARTSYS; 1410 - 1411 1454 ch->video.stdid = *std_id; 1455 + ch->video.dv_preset = V4L2_DV_INVALID; 1456 + memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); 1412 1457 1413 1458 /* Get the information about the standard */ 1414 1459 if (vpif_update_std_info(ch)) { 1415 - ret = -EINVAL; 1416 1460 vpif_err("Error getting the standard info\n"); 1417 - goto s_std_exit; 1461 + return -EINVAL; 1418 1462 } 1419 1463 1420 1464 /* Configure the default format information */ ··· 1423 1471 s_std, *std_id); 1424 1472 if (ret < 0) 1425 1473 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1426 - 1427 - s_std_exit: 1428 - mutex_unlock(&common->lock); 1429 1474 return ret; 1430 1475 } 1431 1476 ··· 1516 1567 return -EINVAL; 1517 1568 } 1518 1569 1519 - if (mutex_lock_interruptible(&common->lock)) 1520 - return -ERESTARTSYS; 1521 - 1522 1570 /* first setup input path from sub device to vpif */ 1523 1571 if (config->setup_input_path) { 1524 1572 ret = config->setup_input_path(ch->channel_id, ··· 1524 1578 vpif_dbg(1, debug, "couldn't setup input path for the" 1525 1579 " sub device %s, for input index %d\n", 1526 1580 subdev_info->name, index); 1527 - goto exit; 1581 + return ret; 1528 1582 } 1529 1583 } 1530 1584 ··· 1535 1589 input, output, 0); 1536 1590 if (ret < 0) { 1537 1591 vpif_dbg(1, debug, "Failed to set input\n"); 1538 - goto exit; 1592 + return ret; 1539 1593 } 1540 1594 } 1541 1595 vid_ch->input_idx = index; ··· 1546 1600 1547 1601 /* update tvnorms from the sub device input info */ 1548 1602 ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std; 1549 - 1550 - exit: 1551 - mutex_unlock(&common->lock); 1552 1603 return ret; 1553 1604 } 1554 1605 ··· 1614 1671 return -EINVAL; 1615 1672 1616 1673 /* Fill in the information about format */ 1617 - if (mutex_lock_interruptible(&common->lock)) 1618 - return -ERESTARTSYS; 1619 - 1620 1674 *fmt = common->fmt; 1621 - mutex_unlock(&common->lock); 1622 1675 return 0; 1623 1676 } 1624 1677 ··· 1633 1694 struct v4l2_pix_format *pixfmt; 1634 1695 int ret = 0; 1635 1696 1636 - vpif_dbg(2, debug, "VIDIOC_S_FMT\n"); 1697 + vpif_dbg(2, debug, "%s\n", __func__); 1637 1698 1638 1699 /* If streaming is started, return error */ 1639 1700 if (common->started) { ··· 1662 1723 if (ret) 1663 1724 return ret; 1664 1725 /* store the format in the channel object */ 1665 - if (mutex_lock_interruptible(&common->lock)) 1666 - return -ERESTARTSYS; 1667 - 1668 1726 common->fmt = *fmt; 1669 - mutex_unlock(&common->lock); 1670 - 1671 1727 return 0; 1672 1728 } 1673 1729 ··· 1741 1807 return 0; 1742 1808 } 1743 1809 1810 + /** 1811 + * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler 1812 + * @file: file ptr 1813 + * @priv: file handle 1814 + * @preset: input preset 1815 + */ 1816 + static int vpif_enum_dv_presets(struct file *file, void *priv, 1817 + struct v4l2_dv_enum_preset *preset) 1818 + { 1819 + struct vpif_fh *fh = priv; 1820 + struct channel_obj *ch = fh->channel; 1821 + 1822 + return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], 1823 + video, enum_dv_presets, preset); 1824 + } 1825 + 1826 + /** 1827 + * vpif_query_dv_presets() - QUERY_DV_PRESET handler 1828 + * @file: file ptr 1829 + * @priv: file handle 1830 + * @preset: input preset 1831 + */ 1832 + static int vpif_query_dv_preset(struct file *file, void *priv, 1833 + struct v4l2_dv_preset *preset) 1834 + { 1835 + struct vpif_fh *fh = priv; 1836 + struct channel_obj *ch = fh->channel; 1837 + 1838 + return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], 1839 + video, query_dv_preset, preset); 1840 + } 1841 + /** 1842 + * vpif_s_dv_presets() - S_DV_PRESETS handler 1843 + * @file: file ptr 1844 + * @priv: file handle 1845 + * @preset: input preset 1846 + */ 1847 + static int vpif_s_dv_preset(struct file *file, void *priv, 1848 + struct v4l2_dv_preset *preset) 1849 + { 1850 + struct vpif_fh *fh = priv; 1851 + struct channel_obj *ch = fh->channel; 1852 + struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 1853 + int ret = 0; 1854 + 1855 + if (common->started) { 1856 + vpif_dbg(1, debug, "streaming in progress\n"); 1857 + return -EBUSY; 1858 + } 1859 + 1860 + if ((VPIF_CHANNEL0_VIDEO == ch->channel_id) || 1861 + (VPIF_CHANNEL1_VIDEO == ch->channel_id)) { 1862 + if (!fh->initialized) { 1863 + vpif_dbg(1, debug, "Channel Busy\n"); 1864 + return -EBUSY; 1865 + } 1866 + } 1867 + 1868 + ret = v4l2_prio_check(&ch->prio, fh->prio); 1869 + if (ret) 1870 + return ret; 1871 + 1872 + fh->initialized = 1; 1873 + 1874 + /* Call encoder subdevice function to set the standard */ 1875 + if (mutex_lock_interruptible(&common->lock)) 1876 + return -ERESTARTSYS; 1877 + 1878 + ch->video.dv_preset = preset->preset; 1879 + ch->video.stdid = V4L2_STD_UNKNOWN; 1880 + memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); 1881 + 1882 + /* Get the information about the standard */ 1883 + if (vpif_update_std_info(ch)) { 1884 + vpif_dbg(1, debug, "Error getting the standard info\n"); 1885 + ret = -EINVAL; 1886 + } else { 1887 + /* Configure the default format information */ 1888 + vpif_config_format(ch); 1889 + 1890 + ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], 1891 + video, s_dv_preset, preset); 1892 + } 1893 + 1894 + mutex_unlock(&common->lock); 1895 + 1896 + return ret; 1897 + } 1898 + /** 1899 + * vpif_g_dv_presets() - G_DV_PRESETS handler 1900 + * @file: file ptr 1901 + * @priv: file handle 1902 + * @preset: input preset 1903 + */ 1904 + static int vpif_g_dv_preset(struct file *file, void *priv, 1905 + struct v4l2_dv_preset *preset) 1906 + { 1907 + struct vpif_fh *fh = priv; 1908 + struct channel_obj *ch = fh->channel; 1909 + 1910 + preset->preset = ch->video.dv_preset; 1911 + 1912 + return 0; 1913 + } 1914 + 1915 + /** 1916 + * vpif_s_dv_timings() - S_DV_TIMINGS handler 1917 + * @file: file ptr 1918 + * @priv: file handle 1919 + * @timings: digital video timings 1920 + */ 1921 + static int vpif_s_dv_timings(struct file *file, void *priv, 1922 + struct v4l2_dv_timings *timings) 1923 + { 1924 + struct vpif_fh *fh = priv; 1925 + struct channel_obj *ch = fh->channel; 1926 + struct vpif_params *vpifparams = &ch->vpifparams; 1927 + struct vpif_channel_config_params *std_info = &vpifparams->std_info; 1928 + struct video_obj *vid_ch = &ch->video; 1929 + struct v4l2_bt_timings *bt = &vid_ch->bt_timings; 1930 + int ret; 1931 + 1932 + if (timings->type != V4L2_DV_BT_656_1120) { 1933 + vpif_dbg(2, debug, "Timing type not defined\n"); 1934 + return -EINVAL; 1935 + } 1936 + 1937 + /* Configure subdevice timings, if any */ 1938 + ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], 1939 + video, s_dv_timings, timings); 1940 + if (ret == -ENOIOCTLCMD) { 1941 + vpif_dbg(2, debug, "Custom DV timings not supported by " 1942 + "subdevice\n"); 1943 + return -EINVAL; 1944 + } 1945 + if (ret < 0) { 1946 + vpif_dbg(2, debug, "Error setting custom DV timings\n"); 1947 + return ret; 1948 + } 1949 + 1950 + if (!(timings->bt.width && timings->bt.height && 1951 + (timings->bt.hbackporch || 1952 + timings->bt.hfrontporch || 1953 + timings->bt.hsync) && 1954 + timings->bt.vfrontporch && 1955 + (timings->bt.vbackporch || 1956 + timings->bt.vsync))) { 1957 + vpif_dbg(2, debug, "Timings for width, height, " 1958 + "horizontal back porch, horizontal sync, " 1959 + "horizontal front porch, vertical back porch, " 1960 + "vertical sync and vertical back porch " 1961 + "must be defined\n"); 1962 + return -EINVAL; 1963 + } 1964 + 1965 + *bt = timings->bt; 1966 + 1967 + /* Configure video port timings */ 1968 + 1969 + std_info->eav2sav = bt->hbackporch + bt->hfrontporch + 1970 + bt->hsync - 8; 1971 + std_info->sav2eav = bt->width; 1972 + 1973 + std_info->l1 = 1; 1974 + std_info->l3 = bt->vsync + bt->vbackporch + 1; 1975 + 1976 + if (bt->interlaced) { 1977 + if (bt->il_vbackporch || bt->il_vfrontporch || bt->il_vsync) { 1978 + std_info->vsize = bt->height * 2 + 1979 + bt->vfrontporch + bt->vsync + bt->vbackporch + 1980 + bt->il_vfrontporch + bt->il_vsync + 1981 + bt->il_vbackporch; 1982 + std_info->l5 = std_info->vsize/2 - 1983 + (bt->vfrontporch - 1); 1984 + std_info->l7 = std_info->vsize/2 + 1; 1985 + std_info->l9 = std_info->l7 + bt->il_vsync + 1986 + bt->il_vbackporch + 1; 1987 + std_info->l11 = std_info->vsize - 1988 + (bt->il_vfrontporch - 1); 1989 + } else { 1990 + vpif_dbg(2, debug, "Required timing values for " 1991 + "interlaced BT format missing\n"); 1992 + return -EINVAL; 1993 + } 1994 + } else { 1995 + std_info->vsize = bt->height + bt->vfrontporch + 1996 + bt->vsync + bt->vbackporch; 1997 + std_info->l5 = std_info->vsize - (bt->vfrontporch - 1); 1998 + } 1999 + strncpy(std_info->name, "Custom timings BT656/1120", VPIF_MAX_NAME); 2000 + std_info->width = bt->width; 2001 + std_info->height = bt->height; 2002 + std_info->frm_fmt = bt->interlaced ? 0 : 1; 2003 + std_info->ycmux_mode = 0; 2004 + std_info->capture_format = 0; 2005 + std_info->vbi_supported = 0; 2006 + std_info->hd_sd = 1; 2007 + std_info->stdid = 0; 2008 + std_info->dv_preset = V4L2_DV_INVALID; 2009 + 2010 + vid_ch->stdid = 0; 2011 + vid_ch->dv_preset = V4L2_DV_INVALID; 2012 + return 0; 2013 + } 2014 + 2015 + /** 2016 + * vpif_g_dv_timings() - G_DV_TIMINGS handler 2017 + * @file: file ptr 2018 + * @priv: file handle 2019 + * @timings: digital video timings 2020 + */ 2021 + static int vpif_g_dv_timings(struct file *file, void *priv, 2022 + struct v4l2_dv_timings *timings) 2023 + { 2024 + struct vpif_fh *fh = priv; 2025 + struct channel_obj *ch = fh->channel; 2026 + struct video_obj *vid_ch = &ch->video; 2027 + struct v4l2_bt_timings *bt = &vid_ch->bt_timings; 2028 + 2029 + timings->bt = *bt; 2030 + 2031 + return 0; 2032 + } 2033 + 2034 + /* 2035 + * vpif_g_chip_ident() - Identify the chip 2036 + * @file: file ptr 2037 + * @priv: file handle 2038 + * @chip: chip identity 2039 + * 2040 + * Returns zero or -EINVAL if read operations fails. 2041 + */ 2042 + static int vpif_g_chip_ident(struct file *file, void *priv, 2043 + struct v4l2_dbg_chip_ident *chip) 2044 + { 2045 + chip->ident = V4L2_IDENT_NONE; 2046 + chip->revision = 0; 2047 + if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && 2048 + chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) { 2049 + vpif_dbg(2, debug, "match_type is invalid.\n"); 2050 + return -EINVAL; 2051 + } 2052 + 2053 + return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core, 2054 + g_chip_ident, chip); 2055 + } 2056 + 2057 + #ifdef CONFIG_VIDEO_ADV_DEBUG 2058 + /* 2059 + * vpif_dbg_g_register() - Read register 2060 + * @file: file ptr 2061 + * @priv: file handle 2062 + * @reg: register to be read 2063 + * 2064 + * Debugging only 2065 + * Returns zero or -EINVAL if read operations fails. 2066 + */ 2067 + static int vpif_dbg_g_register(struct file *file, void *priv, 2068 + struct v4l2_dbg_register *reg){ 2069 + struct vpif_fh *fh = priv; 2070 + struct channel_obj *ch = fh->channel; 2071 + 2072 + return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], core, 2073 + g_register, reg); 2074 + } 2075 + 2076 + /* 2077 + * vpif_dbg_s_register() - Write to register 2078 + * @file: file ptr 2079 + * @priv: file handle 2080 + * @reg: register to be modified 2081 + * 2082 + * Debugging only 2083 + * Returns zero or -EINVAL if write operations fails. 2084 + */ 2085 + static int vpif_dbg_s_register(struct file *file, void *priv, 2086 + struct v4l2_dbg_register *reg){ 2087 + struct vpif_fh *fh = priv; 2088 + struct channel_obj *ch = fh->channel; 2089 + 2090 + return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], core, 2091 + s_register, reg); 2092 + } 2093 + #endif 2094 + 2095 + /* 2096 + * vpif_log_status() - Status information 2097 + * @file: file ptr 2098 + * @priv: file handle 2099 + * 2100 + * Returns zero. 2101 + */ 2102 + static int vpif_log_status(struct file *filep, void *priv) 2103 + { 2104 + /* status for sub devices */ 2105 + v4l2_device_call_all(&vpif_obj.v4l2_dev, 0, core, log_status); 2106 + 2107 + return 0; 2108 + } 2109 + 1744 2110 /* vpif capture ioctl operations */ 1745 2111 static const struct v4l2_ioctl_ops vpif_ioctl_ops = { 1746 2112 .vidioc_querycap = vpif_querycap, ··· 2063 1829 .vidioc_streamon = vpif_streamon, 2064 1830 .vidioc_streamoff = vpif_streamoff, 2065 1831 .vidioc_cropcap = vpif_cropcap, 1832 + .vidioc_enum_dv_presets = vpif_enum_dv_presets, 1833 + .vidioc_s_dv_preset = vpif_s_dv_preset, 1834 + .vidioc_g_dv_preset = vpif_g_dv_preset, 1835 + .vidioc_query_dv_preset = vpif_query_dv_preset, 1836 + .vidioc_s_dv_timings = vpif_s_dv_timings, 1837 + .vidioc_g_dv_timings = vpif_g_dv_timings, 1838 + .vidioc_g_chip_ident = vpif_g_chip_ident, 1839 + #ifdef CONFIG_VIDEO_ADV_DEBUG 1840 + .vidioc_g_register = vpif_dbg_g_register, 1841 + .vidioc_s_register = vpif_dbg_s_register, 1842 + #endif 1843 + .vidioc_log_status = vpif_log_status, 2066 1844 }; 2067 1845 2068 1846 /* vpif file operations */ ··· 2082 1836 .owner = THIS_MODULE, 2083 1837 .open = vpif_open, 2084 1838 .release = vpif_release, 2085 - .ioctl = video_ioctl2, 1839 + .unlocked_ioctl = video_ioctl2, 2086 1840 .mmap = vpif_mmap, 2087 1841 .poll = vpif_poll 2088 1842 }; ··· 2225 1979 common = &(ch->common[VPIF_VIDEO_INDEX]); 2226 1980 spin_lock_init(&common->irqlock); 2227 1981 mutex_init(&common->lock); 1982 + ch->video_dev->lock = &common->lock; 2228 1983 /* Initialize prio member of channel object */ 2229 1984 v4l2_prio_init(&ch->prio); 2230 1985 err = video_register_device(ch->video_dev, ··· 2273 2026 if (vpif_obj.sd[i]) 2274 2027 vpif_obj.sd[i]->grp_id = 1 << i; 2275 2028 } 2276 - v4l2_info(&vpif_obj.v4l2_dev, "DM646x VPIF Capture driver" 2277 - " initialized\n"); 2278 2029 2030 + v4l2_info(&vpif_obj.v4l2_dev, 2031 + "DM646x VPIF capture driver initialized\n"); 2279 2032 return 0; 2280 2033 2281 2034 probe_subdev_out:
+2
drivers/media/video/davinci/vpif_capture.h
··· 59 59 enum v4l2_field buf_field; 60 60 /* Currently selected or default standard */ 61 61 v4l2_std_id stdid; 62 + u32 dv_preset; 63 + struct v4l2_bt_timings bt_timings; 62 64 /* This is to track the last input that is passed to application */ 63 65 u32 input_idx; 64 66 };
+367 -107
drivers/media/video/davinci/vpif_display.c
··· 38 38 #include <media/adv7343.h> 39 39 #include <media/v4l2-device.h> 40 40 #include <media/v4l2-ioctl.h> 41 + #include <media/v4l2-chip-ident.h> 41 42 42 43 #include <mach/dm646x.h> 43 44 ··· 84 83 85 84 static struct vpif_device vpif_obj = { {NULL} }; 86 85 static struct device *vpif_dev; 87 - 88 - static const struct vpif_channel_config_params ch_params[] = { 89 - { 90 - "NTSC", 720, 480, 30, 0, 1, 268, 1440, 1, 23, 263, 266, 91 - 286, 525, 525, 0, 1, 0, V4L2_STD_525_60, 92 - }, 93 - { 94 - "PAL", 720, 576, 25, 0, 1, 280, 1440, 1, 23, 311, 313, 95 - 336, 624, 625, 0, 1, 0, V4L2_STD_625_50, 96 - }, 97 - }; 98 86 99 87 /* 100 88 * vpif_uservirt_to_phys: This function is used to convert user ··· 363 373 return IRQ_HANDLED; 364 374 } 365 375 366 - static int vpif_get_std_info(struct channel_obj *ch) 376 + static int vpif_update_std_info(struct channel_obj *ch) 367 377 { 368 - struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 369 378 struct video_obj *vid_ch = &ch->video; 370 379 struct vpif_params *vpifparams = &ch->vpifparams; 371 380 struct vpif_channel_config_params *std_info = &vpifparams->std_info; 372 381 const struct vpif_channel_config_params *config; 373 382 374 - int index; 383 + int i; 375 384 376 - std_info->stdid = vid_ch->stdid; 377 - if (!std_info->stdid) 378 - return -1; 379 - 380 - for (index = 0; index < ARRAY_SIZE(ch_params); index++) { 381 - config = &ch_params[index]; 382 - if (config->stdid & std_info->stdid) { 383 - memcpy(std_info, config, sizeof(*config)); 384 - break; 385 + for (i = 0; i < vpif_ch_params_count; i++) { 386 + config = &ch_params[i]; 387 + if (config->hd_sd == 0) { 388 + vpif_dbg(2, debug, "SD format\n"); 389 + if (config->stdid & vid_ch->stdid) { 390 + memcpy(std_info, config, sizeof(*config)); 391 + break; 392 + } 393 + } else { 394 + vpif_dbg(2, debug, "HD format\n"); 395 + if (config->dv_preset == vid_ch->dv_preset) { 396 + memcpy(std_info, config, sizeof(*config)); 397 + break; 398 + } 385 399 } 386 400 } 387 401 388 - if (index == ARRAY_SIZE(ch_params)) 389 - return -1; 402 + if (i == vpif_ch_params_count) { 403 + vpif_dbg(1, debug, "Format not found\n"); 404 + return -EINVAL; 405 + } 406 + 407 + return 0; 408 + } 409 + 410 + static int vpif_update_resolution(struct channel_obj *ch) 411 + { 412 + struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 413 + struct video_obj *vid_ch = &ch->video; 414 + struct vpif_params *vpifparams = &ch->vpifparams; 415 + struct vpif_channel_config_params *std_info = &vpifparams->std_info; 416 + 417 + if (!vid_ch->stdid && !vid_ch->dv_preset && !vid_ch->bt_timings.height) 418 + return -EINVAL; 419 + 420 + if (vid_ch->stdid || vid_ch->dv_preset) { 421 + if (vpif_update_std_info(ch)) 422 + return -EINVAL; 423 + } 390 424 391 425 common->fmt.fmt.pix.width = std_info->width; 392 426 common->fmt.fmt.pix.height = std_info->height; ··· 418 404 common->fmt.fmt.pix.width, common->fmt.fmt.pix.height); 419 405 420 406 /* Set height and width paramateres */ 421 - ch->common[VPIF_VIDEO_INDEX].height = std_info->height; 422 - ch->common[VPIF_VIDEO_INDEX].width = std_info->width; 407 + common->height = std_info->height; 408 + common->width = std_info->width; 423 409 424 410 return 0; 425 411 } ··· 530 516 else 531 517 sizeimage = config_params.channel_bufsize[ch->channel_id]; 532 518 533 - if (vpif_get_std_info(ch)) { 534 - vpif_err("Error getting the standard info\n"); 519 + if (vpif_update_resolution(ch)) 535 520 return -EINVAL; 536 - } 537 521 538 522 hpitch = pixfmt->bytesperline; 539 523 vpitch = sizeimage / (hpitch * 2); ··· 580 568 static int vpif_mmap(struct file *filep, struct vm_area_struct *vma) 581 569 { 582 570 struct vpif_fh *fh = filep->private_data; 583 - struct common_obj *common = &fh->channel->common[VPIF_VIDEO_INDEX]; 571 + struct channel_obj *ch = fh->channel; 572 + struct common_obj *common = &(ch->common[VPIF_VIDEO_INDEX]); 573 + 574 + vpif_dbg(2, debug, "vpif_mmap\n"); 584 575 585 576 return videobuf_mmap_mapper(&common->buffer_queue, vma); 586 577 } ··· 652 637 struct channel_obj *ch = fh->channel; 653 638 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 654 639 655 - if (mutex_lock_interruptible(&common->lock)) 656 - return -ERESTARTSYS; 657 - 658 640 /* if this instance is doing IO */ 659 641 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 660 642 /* Reset io_usrs member of channel object */ ··· 674 662 config_params.numbuffers[ch->channel_id]; 675 663 } 676 664 677 - mutex_unlock(&common->lock); 678 - 679 665 /* Decrement channel usrs counter */ 680 666 atomic_dec(&ch->usrs); 681 667 /* If this file handle has initialize encoder device, reset it */ ··· 690 680 } 691 681 692 682 /* functions implementing ioctls */ 693 - 683 + /** 684 + * vpif_querycap() - QUERYCAP handler 685 + * @file: file ptr 686 + * @priv: file handle 687 + * @cap: ptr to v4l2_capability structure 688 + */ 694 689 static int vpif_querycap(struct file *file, void *priv, 695 690 struct v4l2_capability *cap) 696 691 { ··· 737 722 if (common->fmt.type != fmt->type) 738 723 return -EINVAL; 739 724 740 - /* Fill in the information about format */ 741 - if (mutex_lock_interruptible(&common->lock)) 742 - return -ERESTARTSYS; 743 - 744 - if (vpif_get_std_info(ch)) { 745 - vpif_err("Error getting the standard info\n"); 725 + if (vpif_update_resolution(ch)) 746 726 return -EINVAL; 747 - } 748 - 749 727 *fmt = common->fmt; 750 - mutex_unlock(&common->lock); 751 728 return 0; 752 729 } 753 730 ··· 780 773 /* store the pix format in the channel object */ 781 774 common->fmt.fmt.pix = *pixfmt; 782 775 /* store the format in the channel object */ 783 - if (mutex_lock_interruptible(&common->lock)) 784 - return -ERESTARTSYS; 785 - 786 776 common->fmt = *fmt; 787 - mutex_unlock(&common->lock); 788 - 789 777 return 0; 790 778 } 791 779 ··· 810 808 struct common_obj *common; 811 809 enum v4l2_field field; 812 810 u8 index = 0; 813 - int ret = 0; 814 811 815 812 /* This file handle has not initialized the channel, 816 813 It is not allowed to do settings */ ··· 827 826 index = VPIF_VIDEO_INDEX; 828 827 829 828 common = &ch->common[index]; 830 - if (mutex_lock_interruptible(&common->lock)) 831 - return -ERESTARTSYS; 832 829 833 - if (common->fmt.type != reqbuf->type) { 834 - ret = -EINVAL; 835 - goto reqbuf_exit; 836 - } 830 + if (common->fmt.type != reqbuf->type) 831 + return -EINVAL; 837 832 838 - if (0 != common->io_usrs) { 839 - ret = -EBUSY; 840 - goto reqbuf_exit; 841 - } 833 + if (0 != common->io_usrs) 834 + return -EBUSY; 842 835 843 836 if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 844 837 if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY) ··· 849 854 &common->irqlock, 850 855 reqbuf->type, field, 851 856 sizeof(struct videobuf_buffer), fh, 852 - NULL); 857 + &common->lock); 853 858 854 859 /* Set io allowed member of file handle to TRUE */ 855 860 fh->io_allowed[index] = 1; ··· 860 865 INIT_LIST_HEAD(&common->dma_queue); 861 866 862 867 /* Allocate buffers */ 863 - ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); 864 - 865 - reqbuf_exit: 866 - mutex_unlock(&common->lock); 867 - return ret; 868 + return videobuf_reqbufs(&common->buffer_queue, reqbuf); 868 869 } 869 870 870 871 static int vpif_querybuf(struct file *file, void *priv, ··· 981 990 } 982 991 983 992 /* Call encoder subdevice function to set the standard */ 984 - if (mutex_lock_interruptible(&common->lock)) 985 - return -ERESTARTSYS; 986 - 987 993 ch->video.stdid = *std_id; 994 + ch->video.dv_preset = V4L2_DV_INVALID; 995 + memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); 996 + 988 997 /* Get the information about the standard */ 989 - if (vpif_get_std_info(ch)) { 990 - vpif_err("Error getting the standard info\n"); 998 + if (vpif_update_resolution(ch)) 991 999 return -EINVAL; 992 - } 993 1000 994 1001 if ((ch->vpifparams.std_info.width * 995 1002 ch->vpifparams.std_info.height * 2) > 996 1003 config_params.channel_bufsize[ch->channel_id]) { 997 1004 vpif_err("invalid std for this size\n"); 998 - ret = -EINVAL; 999 - goto s_std_exit; 1005 + return -EINVAL; 1000 1006 } 1001 1007 1002 1008 common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width; ··· 1004 1016 s_std_output, *std_id); 1005 1017 if (ret < 0) { 1006 1018 vpif_err("Failed to set output standard\n"); 1007 - goto s_std_exit; 1019 + return ret; 1008 1020 } 1009 1021 1010 1022 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core, 1011 1023 s_std, *std_id); 1012 1024 if (ret < 0) 1013 1025 vpif_err("Failed to set standard for sub devices\n"); 1014 - 1015 - s_std_exit: 1016 - mutex_unlock(&common->lock); 1017 1026 return ret; 1018 1027 } 1019 1028 ··· 1075 1090 if (ret < 0) 1076 1091 return ret; 1077 1092 1078 - /* Call videobuf_streamon to start streaming in videobuf */ 1093 + /* Call videobuf_streamon to start streaming in videobuf */ 1079 1094 ret = videobuf_streamon(&common->buffer_queue); 1080 1095 if (ret < 0) { 1081 1096 vpif_err("videobuf_streamon\n"); 1082 1097 return ret; 1083 1098 } 1084 1099 1085 - if (mutex_lock_interruptible(&common->lock)) 1086 - return -ERESTARTSYS; 1087 - 1088 1100 /* If buffer queue is empty, return error */ 1089 1101 if (list_empty(&common->dma_queue)) { 1090 1102 vpif_err("buffer queue is empty\n"); 1091 - ret = -EIO; 1092 - goto streamon_exit; 1103 + return -EIO; 1093 1104 } 1094 1105 1095 1106 /* Get the next frame from the buffer queue */ ··· 1111 1130 || (!ch->vpifparams.std_info.frm_fmt 1112 1131 && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) { 1113 1132 vpif_err("conflict in field format and std format\n"); 1114 - ret = -EINVAL; 1115 - goto streamon_exit; 1133 + return -EINVAL; 1116 1134 } 1117 1135 1118 1136 /* clock settings */ ··· 1120 1140 ch->vpifparams.std_info.hd_sd); 1121 1141 if (ret < 0) { 1122 1142 vpif_err("can't set clock\n"); 1123 - goto streamon_exit; 1143 + return ret; 1124 1144 } 1125 1145 1126 1146 /* set the parameters and addresses */ 1127 1147 ret = vpif_set_video_params(vpif, ch->channel_id + 2); 1128 1148 if (ret < 0) 1129 - goto streamon_exit; 1149 + return ret; 1130 1150 1131 1151 common->started = ret; 1132 1152 vpif_config_addr(ch, ret); ··· 1151 1171 } 1152 1172 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; 1153 1173 } 1154 - 1155 - streamon_exit: 1156 - mutex_unlock(&common->lock); 1157 1174 return ret; 1158 1175 } 1159 1176 ··· 1176 1199 return -EINVAL; 1177 1200 } 1178 1201 1179 - if (mutex_lock_interruptible(&common->lock)) 1180 - return -ERESTARTSYS; 1181 - 1182 1202 if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 1183 1203 /* disable channel */ 1184 1204 if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { ··· 1190 1216 } 1191 1217 1192 1218 common->started = 0; 1193 - mutex_unlock(&common->lock); 1194 - 1195 1219 return videobuf_streamoff(&common->buffer_queue); 1196 1220 } 1197 1221 ··· 1236 1264 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 1237 1265 int ret = 0; 1238 1266 1239 - if (mutex_lock_interruptible(&common->lock)) 1240 - return -ERESTARTSYS; 1241 - 1242 1267 if (common->started) { 1243 1268 vpif_err("Streaming in progress\n"); 1244 - ret = -EBUSY; 1245 - goto s_output_exit; 1269 + return -EBUSY; 1246 1270 } 1247 1271 1248 1272 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video, ··· 1248 1280 vpif_err("Failed to set output standard\n"); 1249 1281 1250 1282 vid_ch->output_id = i; 1251 - 1252 - s_output_exit: 1253 - mutex_unlock(&common->lock); 1254 1283 return ret; 1255 1284 } 1256 1285 ··· 1280 1315 return v4l2_prio_change(&ch->prio, &fh->prio, p); 1281 1316 } 1282 1317 1318 + /** 1319 + * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler 1320 + * @file: file ptr 1321 + * @priv: file handle 1322 + * @preset: input preset 1323 + */ 1324 + static int vpif_enum_dv_presets(struct file *file, void *priv, 1325 + struct v4l2_dv_enum_preset *preset) 1326 + { 1327 + struct vpif_fh *fh = priv; 1328 + struct channel_obj *ch = fh->channel; 1329 + struct video_obj *vid_ch = &ch->video; 1330 + 1331 + return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], 1332 + video, enum_dv_presets, preset); 1333 + } 1334 + 1335 + /** 1336 + * vpif_s_dv_presets() - S_DV_PRESETS handler 1337 + * @file: file ptr 1338 + * @priv: file handle 1339 + * @preset: input preset 1340 + */ 1341 + static int vpif_s_dv_preset(struct file *file, void *priv, 1342 + struct v4l2_dv_preset *preset) 1343 + { 1344 + struct vpif_fh *fh = priv; 1345 + struct channel_obj *ch = fh->channel; 1346 + struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 1347 + struct video_obj *vid_ch = &ch->video; 1348 + int ret = 0; 1349 + 1350 + if (common->started) { 1351 + vpif_dbg(1, debug, "streaming in progress\n"); 1352 + return -EBUSY; 1353 + } 1354 + 1355 + ret = v4l2_prio_check(&ch->prio, fh->prio); 1356 + if (ret != 0) 1357 + return ret; 1358 + 1359 + fh->initialized = 1; 1360 + 1361 + /* Call encoder subdevice function to set the standard */ 1362 + if (mutex_lock_interruptible(&common->lock)) 1363 + return -ERESTARTSYS; 1364 + 1365 + ch->video.dv_preset = preset->preset; 1366 + ch->video.stdid = V4L2_STD_UNKNOWN; 1367 + memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); 1368 + 1369 + /* Get the information about the standard */ 1370 + if (vpif_update_resolution(ch)) { 1371 + ret = -EINVAL; 1372 + } else { 1373 + /* Configure the default format information */ 1374 + vpif_config_format(ch); 1375 + 1376 + ret = v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], 1377 + video, s_dv_preset, preset); 1378 + } 1379 + 1380 + mutex_unlock(&common->lock); 1381 + 1382 + return ret; 1383 + } 1384 + /** 1385 + * vpif_g_dv_presets() - G_DV_PRESETS handler 1386 + * @file: file ptr 1387 + * @priv: file handle 1388 + * @preset: input preset 1389 + */ 1390 + static int vpif_g_dv_preset(struct file *file, void *priv, 1391 + struct v4l2_dv_preset *preset) 1392 + { 1393 + struct vpif_fh *fh = priv; 1394 + struct channel_obj *ch = fh->channel; 1395 + 1396 + preset->preset = ch->video.dv_preset; 1397 + 1398 + return 0; 1399 + } 1400 + /** 1401 + * vpif_s_dv_timings() - S_DV_TIMINGS handler 1402 + * @file: file ptr 1403 + * @priv: file handle 1404 + * @timings: digital video timings 1405 + */ 1406 + static int vpif_s_dv_timings(struct file *file, void *priv, 1407 + struct v4l2_dv_timings *timings) 1408 + { 1409 + struct vpif_fh *fh = priv; 1410 + struct channel_obj *ch = fh->channel; 1411 + struct vpif_params *vpifparams = &ch->vpifparams; 1412 + struct vpif_channel_config_params *std_info = &vpifparams->std_info; 1413 + struct video_obj *vid_ch = &ch->video; 1414 + struct v4l2_bt_timings *bt = &vid_ch->bt_timings; 1415 + int ret; 1416 + 1417 + if (timings->type != V4L2_DV_BT_656_1120) { 1418 + vpif_dbg(2, debug, "Timing type not defined\n"); 1419 + return -EINVAL; 1420 + } 1421 + 1422 + /* Configure subdevice timings, if any */ 1423 + ret = v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], 1424 + video, s_dv_timings, timings); 1425 + if (ret == -ENOIOCTLCMD) { 1426 + vpif_dbg(2, debug, "Custom DV timings not supported by " 1427 + "subdevice\n"); 1428 + return -EINVAL; 1429 + } 1430 + if (ret < 0) { 1431 + vpif_dbg(2, debug, "Error setting custom DV timings\n"); 1432 + return ret; 1433 + } 1434 + 1435 + if (!(timings->bt.width && timings->bt.height && 1436 + (timings->bt.hbackporch || 1437 + timings->bt.hfrontporch || 1438 + timings->bt.hsync) && 1439 + timings->bt.vfrontporch && 1440 + (timings->bt.vbackporch || 1441 + timings->bt.vsync))) { 1442 + vpif_dbg(2, debug, "Timings for width, height, " 1443 + "horizontal back porch, horizontal sync, " 1444 + "horizontal front porch, vertical back porch, " 1445 + "vertical sync and vertical back porch " 1446 + "must be defined\n"); 1447 + return -EINVAL; 1448 + } 1449 + 1450 + *bt = timings->bt; 1451 + 1452 + /* Configure video port timings */ 1453 + 1454 + std_info->eav2sav = bt->hbackporch + bt->hfrontporch + 1455 + bt->hsync - 8; 1456 + std_info->sav2eav = bt->width; 1457 + 1458 + std_info->l1 = 1; 1459 + std_info->l3 = bt->vsync + bt->vbackporch + 1; 1460 + 1461 + if (bt->interlaced) { 1462 + if (bt->il_vbackporch || bt->il_vfrontporch || bt->il_vsync) { 1463 + std_info->vsize = bt->height * 2 + 1464 + bt->vfrontporch + bt->vsync + bt->vbackporch + 1465 + bt->il_vfrontporch + bt->il_vsync + 1466 + bt->il_vbackporch; 1467 + std_info->l5 = std_info->vsize/2 - 1468 + (bt->vfrontporch - 1); 1469 + std_info->l7 = std_info->vsize/2 + 1; 1470 + std_info->l9 = std_info->l7 + bt->il_vsync + 1471 + bt->il_vbackporch + 1; 1472 + std_info->l11 = std_info->vsize - 1473 + (bt->il_vfrontporch - 1); 1474 + } else { 1475 + vpif_dbg(2, debug, "Required timing values for " 1476 + "interlaced BT format missing\n"); 1477 + return -EINVAL; 1478 + } 1479 + } else { 1480 + std_info->vsize = bt->height + bt->vfrontporch + 1481 + bt->vsync + bt->vbackporch; 1482 + std_info->l5 = std_info->vsize - (bt->vfrontporch - 1); 1483 + } 1484 + strncpy(std_info->name, "Custom timings BT656/1120", 1485 + VPIF_MAX_NAME); 1486 + std_info->width = bt->width; 1487 + std_info->height = bt->height; 1488 + std_info->frm_fmt = bt->interlaced ? 0 : 1; 1489 + std_info->ycmux_mode = 0; 1490 + std_info->capture_format = 0; 1491 + std_info->vbi_supported = 0; 1492 + std_info->hd_sd = 1; 1493 + std_info->stdid = 0; 1494 + std_info->dv_preset = V4L2_DV_INVALID; 1495 + 1496 + vid_ch->stdid = 0; 1497 + vid_ch->dv_preset = V4L2_DV_INVALID; 1498 + 1499 + return 0; 1500 + } 1501 + 1502 + /** 1503 + * vpif_g_dv_timings() - G_DV_TIMINGS handler 1504 + * @file: file ptr 1505 + * @priv: file handle 1506 + * @timings: digital video timings 1507 + */ 1508 + static int vpif_g_dv_timings(struct file *file, void *priv, 1509 + struct v4l2_dv_timings *timings) 1510 + { 1511 + struct vpif_fh *fh = priv; 1512 + struct channel_obj *ch = fh->channel; 1513 + struct video_obj *vid_ch = &ch->video; 1514 + struct v4l2_bt_timings *bt = &vid_ch->bt_timings; 1515 + 1516 + timings->bt = *bt; 1517 + 1518 + return 0; 1519 + } 1520 + 1521 + /* 1522 + * vpif_g_chip_ident() - Identify the chip 1523 + * @file: file ptr 1524 + * @priv: file handle 1525 + * @chip: chip identity 1526 + * 1527 + * Returns zero or -EINVAL if read operations fails. 1528 + */ 1529 + static int vpif_g_chip_ident(struct file *file, void *priv, 1530 + struct v4l2_dbg_chip_ident *chip) 1531 + { 1532 + chip->ident = V4L2_IDENT_NONE; 1533 + chip->revision = 0; 1534 + if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && 1535 + chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) { 1536 + vpif_dbg(2, debug, "match_type is invalid.\n"); 1537 + return -EINVAL; 1538 + } 1539 + 1540 + return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core, 1541 + g_chip_ident, chip); 1542 + } 1543 + 1544 + #ifdef CONFIG_VIDEO_ADV_DEBUG 1545 + /* 1546 + * vpif_dbg_g_register() - Read register 1547 + * @file: file ptr 1548 + * @priv: file handle 1549 + * @reg: register to be read 1550 + * 1551 + * Debugging only 1552 + * Returns zero or -EINVAL if read operations fails. 1553 + */ 1554 + static int vpif_dbg_g_register(struct file *file, void *priv, 1555 + struct v4l2_dbg_register *reg){ 1556 + struct vpif_fh *fh = priv; 1557 + struct channel_obj *ch = fh->channel; 1558 + struct video_obj *vid_ch = &ch->video; 1559 + 1560 + return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], core, 1561 + g_register, reg); 1562 + } 1563 + 1564 + /* 1565 + * vpif_dbg_s_register() - Write to register 1566 + * @file: file ptr 1567 + * @priv: file handle 1568 + * @reg: register to be modified 1569 + * 1570 + * Debugging only 1571 + * Returns zero or -EINVAL if write operations fails. 1572 + */ 1573 + static int vpif_dbg_s_register(struct file *file, void *priv, 1574 + struct v4l2_dbg_register *reg){ 1575 + struct vpif_fh *fh = priv; 1576 + struct channel_obj *ch = fh->channel; 1577 + struct video_obj *vid_ch = &ch->video; 1578 + 1579 + return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], core, 1580 + s_register, reg); 1581 + } 1582 + #endif 1583 + 1584 + /* 1585 + * vpif_log_status() - Status information 1586 + * @file: file ptr 1587 + * @priv: file handle 1588 + * 1589 + * Returns zero. 1590 + */ 1591 + static int vpif_log_status(struct file *filep, void *priv) 1592 + { 1593 + /* status for sub devices */ 1594 + v4l2_device_call_all(&vpif_obj.v4l2_dev, 0, core, log_status); 1595 + 1596 + return 0; 1597 + } 1598 + 1283 1599 /* vpif display ioctl operations */ 1284 1600 static const struct v4l2_ioctl_ops vpif_ioctl_ops = { 1285 1601 .vidioc_querycap = vpif_querycap, ··· 1582 1336 .vidioc_s_output = vpif_s_output, 1583 1337 .vidioc_g_output = vpif_g_output, 1584 1338 .vidioc_cropcap = vpif_cropcap, 1339 + .vidioc_enum_dv_presets = vpif_enum_dv_presets, 1340 + .vidioc_s_dv_preset = vpif_s_dv_preset, 1341 + .vidioc_g_dv_preset = vpif_g_dv_preset, 1342 + .vidioc_s_dv_timings = vpif_s_dv_timings, 1343 + .vidioc_g_dv_timings = vpif_g_dv_timings, 1344 + .vidioc_g_chip_ident = vpif_g_chip_ident, 1345 + #ifdef CONFIG_VIDEO_ADV_DEBUG 1346 + .vidioc_g_register = vpif_dbg_g_register, 1347 + .vidioc_s_register = vpif_dbg_s_register, 1348 + #endif 1349 + .vidioc_log_status = vpif_log_status, 1585 1350 }; 1586 1351 1587 1352 static const struct v4l2_file_operations vpif_fops = { 1588 1353 .owner = THIS_MODULE, 1589 1354 .open = vpif_open, 1590 1355 .release = vpif_release, 1591 - .ioctl = video_ioctl2, 1356 + .unlocked_ioctl = video_ioctl2, 1592 1357 .mmap = vpif_mmap, 1593 1358 .poll = vpif_poll 1594 1359 }; ··· 1783 1526 v4l2_prio_init(&ch->prio); 1784 1527 ch->common[VPIF_VIDEO_INDEX].fmt.type = 1785 1528 V4L2_BUF_TYPE_VIDEO_OUTPUT; 1529 + ch->video_dev->lock = &common->lock; 1786 1530 1787 1531 /* register video device */ 1788 1532 vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", ··· 1823 1565 vpif_obj.sd[i]->grp_id = 1 << i; 1824 1566 } 1825 1567 1568 + v4l2_info(&vpif_obj.v4l2_dev, 1569 + "DM646x VPIF display driver initialized\n"); 1826 1570 return 0; 1827 1571 1828 1572 probe_subdev_out:
+2
drivers/media/video/davinci/vpif_display.h
··· 67 67 * most recent displayed frame only */ 68 68 v4l2_std_id stdid; /* Currently selected or default 69 69 * standard */ 70 + u32 dv_preset; 71 + struct v4l2_bt_timings bt_timings; 70 72 u32 output_id; /* Current output id */ 71 73 }; 72 74
+11 -8
drivers/media/video/em28xx/em28xx-cards.c
··· 33 33 #include <media/saa7115.h> 34 34 #include <media/tvp5150.h> 35 35 #include <media/tvaudio.h> 36 + #include <media/mt9v011.h> 36 37 #include <media/i2c-addr.h> 37 38 #include <media/tveeprom.h> 38 39 #include <media/v4l2-common.h> ··· 1918 1917 I2C_CLIENT_END 1919 1918 }; 1920 1919 1921 - static unsigned short mt9v011_addrs[] = { 1922 - 0xba >> 1, 1923 - I2C_CLIENT_END 1924 - }; 1925 - 1926 1920 static unsigned short msp3400_addrs[] = { 1927 1921 0x80 >> 1, 1928 1922 0x88 >> 1, ··· 2433 2437 dev->init_data.ir_codes = RC_MAP_RC5_HAUPPAUGE_NEW; 2434 2438 dev->init_data.get_key = em28xx_get_key_em_haup; 2435 2439 dev->init_data.name = "i2c IR (EM2840 Hauppauge)"; 2440 + break; 2436 2441 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: 2437 2442 dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE; 2438 2443 dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe; ··· 2620 2623 "tvp5150", 0, tvp5150_addrs); 2621 2624 2622 2625 if (dev->em28xx_sensor == EM28XX_MT9V011) { 2626 + struct mt9v011_platform_data pdata; 2627 + struct i2c_board_info mt9v011_info = { 2628 + .type = "mt9v011", 2629 + .addr = 0xba >> 1, 2630 + .platform_data = &pdata, 2631 + }; 2623 2632 struct v4l2_subdev *sd; 2624 2633 2625 - sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2626 - &dev->i2c_adap, "mt9v011", 0, mt9v011_addrs); 2627 - v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal); 2634 + pdata.xtal = dev->sensor_xtal; 2635 + sd = v4l2_i2c_new_subdev_board(&dev->v4l2_dev, &dev->i2c_adap, 2636 + &mt9v011_info, NULL); 2628 2637 } 2629 2638 2630 2639
-24
drivers/media/video/et61x251/et61x251.h
··· 59 59 /*****************************************************************************/ 60 60 61 61 static const struct usb_device_id et61x251_id_table[] = { 62 - { USB_DEVICE(0x102c, 0x6151), }, 63 62 { USB_DEVICE(0x102c, 0x6251), }, 64 - { USB_DEVICE(0x102c, 0x6253), }, 65 - { USB_DEVICE(0x102c, 0x6254), }, 66 - { USB_DEVICE(0x102c, 0x6255), }, 67 - { USB_DEVICE(0x102c, 0x6256), }, 68 - { USB_DEVICE(0x102c, 0x6257), }, 69 - { USB_DEVICE(0x102c, 0x6258), }, 70 - { USB_DEVICE(0x102c, 0x6259), }, 71 - { USB_DEVICE(0x102c, 0x625a), }, 72 - { USB_DEVICE(0x102c, 0x625b), }, 73 - { USB_DEVICE(0x102c, 0x625c), }, 74 - { USB_DEVICE(0x102c, 0x625d), }, 75 - { USB_DEVICE(0x102c, 0x625e), }, 76 - { USB_DEVICE(0x102c, 0x625f), }, 77 - { USB_DEVICE(0x102c, 0x6260), }, 78 - { USB_DEVICE(0x102c, 0x6261), }, 79 - { USB_DEVICE(0x102c, 0x6262), }, 80 - { USB_DEVICE(0x102c, 0x6263), }, 81 - { USB_DEVICE(0x102c, 0x6264), }, 82 - { USB_DEVICE(0x102c, 0x6265), }, 83 - { USB_DEVICE(0x102c, 0x6266), }, 84 - { USB_DEVICE(0x102c, 0x6267), }, 85 - { USB_DEVICE(0x102c, 0x6268), }, 86 - { USB_DEVICE(0x102c, 0x6269), }, 87 63 { } 88 64 }; 89 65
+1 -1
drivers/media/video/gspca/benq.c
··· 276 276 }; 277 277 278 278 /* -- module initialisation -- */ 279 - static const __devinitdata struct usb_device_id device_table[] = { 279 + static const struct usb_device_id device_table[] = { 280 280 {USB_DEVICE(0x04a5, 0x3035)}, 281 281 {} 282 282 };
+2 -2
drivers/media/video/gspca/conex.c
··· 1040 1040 }; 1041 1041 1042 1042 /* -- module initialisation -- */ 1043 - static const struct usb_device_id device_table[] __devinitconst = { 1043 + static const struct usb_device_id device_table[] = { 1044 1044 {USB_DEVICE(0x0572, 0x0041)}, 1045 1045 {} 1046 1046 }; 1047 1047 MODULE_DEVICE_TABLE(usb, device_table); 1048 1048 1049 1049 /* -- device connect -- */ 1050 - static int __devinit sd_probe(struct usb_interface *intf, 1050 + static int sd_probe(struct usb_interface *intf, 1051 1051 const struct usb_device_id *id) 1052 1052 { 1053 1053 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
+1 -1
drivers/media/video/gspca/cpia1.c
··· 2088 2088 }; 2089 2089 2090 2090 /* -- module initialisation -- */ 2091 - static const __devinitdata struct usb_device_id device_table[] = { 2091 + static const struct usb_device_id device_table[] = { 2092 2092 {USB_DEVICE(0x0553, 0x0002)}, 2093 2093 {USB_DEVICE(0x0813, 0x0001)}, 2094 2094 {}
+2 -2
drivers/media/video/gspca/etoms.c
··· 864 864 }; 865 865 866 866 /* -- module initialisation -- */ 867 - static const struct usb_device_id device_table[] __devinitconst = { 867 + static const struct usb_device_id device_table[] = { 868 868 {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, 869 869 #if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE 870 870 {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, ··· 875 875 MODULE_DEVICE_TABLE(usb, device_table); 876 876 877 877 /* -- device connect -- */ 878 - static int __devinit sd_probe(struct usb_interface *intf, 878 + static int sd_probe(struct usb_interface *intf, 879 879 const struct usb_device_id *id) 880 880 { 881 881 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
+1 -1
drivers/media/video/gspca/finepix.c
··· 229 229 } 230 230 231 231 /* Table of supported USB devices */ 232 - static const __devinitdata struct usb_device_id device_table[] = { 232 + static const struct usb_device_id device_table[] = { 233 233 {USB_DEVICE(0x04cb, 0x0104)}, 234 234 {USB_DEVICE(0x04cb, 0x0109)}, 235 235 {USB_DEVICE(0x04cb, 0x010b)},
+1 -1
drivers/media/video/gspca/gl860/gl860.c
··· 488 488 489 489 /*=================== USB driver structure initialisation ==================*/ 490 490 491 - static const __devinitdata struct usb_device_id device_table[] = { 491 + static const struct usb_device_id device_table[] = { 492 492 {USB_DEVICE(0x05e3, 0x0503)}, 493 493 {USB_DEVICE(0x05e3, 0xf191)}, 494 494 {}
+100 -120
drivers/media/video/gspca/gspca.c
··· 55 55 MODULE_DESCRIPTION("GSPCA USB Camera Driver"); 56 56 MODULE_LICENSE("GPL"); 57 57 58 - #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 11, 0) 58 + #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 12, 0) 59 59 60 60 #ifdef GSPCA_DEBUG 61 61 int gspca_debug = D_ERR | D_PROBE; ··· 508 508 return 0; 509 509 } 510 510 511 - static int frame_alloc(struct gspca_dev *gspca_dev, 512 - unsigned int count) 511 + static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file, 512 + enum v4l2_memory memory, unsigned int count) 513 513 { 514 514 struct gspca_frame *frame; 515 515 unsigned int frsz; ··· 519 519 frsz = gspca_dev->cam.cam_mode[i].sizeimage; 520 520 PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); 521 521 frsz = PAGE_ALIGN(frsz); 522 - gspca_dev->frsz = frsz; 523 522 if (count >= GSPCA_MAX_FRAMES) 524 523 count = GSPCA_MAX_FRAMES - 1; 525 524 gspca_dev->frbuf = vmalloc_32(frsz * count); ··· 526 527 err("frame alloc failed"); 527 528 return -ENOMEM; 528 529 } 530 + gspca_dev->capt_file = file; 531 + gspca_dev->memory = memory; 532 + gspca_dev->frsz = frsz; 529 533 gspca_dev->nframes = count; 530 534 for (i = 0; i < count; i++) { 531 535 frame = &gspca_dev->frame[i]; ··· 537 535 frame->v4l2_buf.flags = 0; 538 536 frame->v4l2_buf.field = V4L2_FIELD_NONE; 539 537 frame->v4l2_buf.length = frsz; 540 - frame->v4l2_buf.memory = gspca_dev->memory; 538 + frame->v4l2_buf.memory = memory; 541 539 frame->v4l2_buf.sequence = 0; 542 540 frame->data = gspca_dev->frbuf + i * frsz; 543 541 frame->v4l2_buf.m.offset = i * frsz; ··· 560 558 gspca_dev->frame[i].data = NULL; 561 559 } 562 560 gspca_dev->nframes = 0; 561 + gspca_dev->frsz = 0; 562 + gspca_dev->capt_file = NULL; 563 + gspca_dev->memory = GSPCA_MEMORY_NO; 563 564 } 564 565 565 566 static void destroy_urbs(struct gspca_dev *gspca_dev) ··· 1215 1210 static int dev_open(struct file *file) 1216 1211 { 1217 1212 struct gspca_dev *gspca_dev; 1218 - int ret; 1219 1213 1220 1214 PDEBUG(D_STREAM, "[%s] open", current->comm); 1221 1215 gspca_dev = (struct gspca_dev *) video_devdata(file); 1222 - if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1223 - return -ERESTARTSYS; 1224 - if (!gspca_dev->present) { 1225 - ret = -ENODEV; 1226 - goto out; 1227 - } 1228 - 1229 - if (gspca_dev->users > 4) { /* (arbitrary value) */ 1230 - ret = -EBUSY; 1231 - goto out; 1232 - } 1216 + if (!gspca_dev->present) 1217 + return -ENODEV; 1233 1218 1234 1219 /* protect the subdriver against rmmod */ 1235 - if (!try_module_get(gspca_dev->module)) { 1236 - ret = -ENODEV; 1237 - goto out; 1238 - } 1239 - 1240 - gspca_dev->users++; 1220 + if (!try_module_get(gspca_dev->module)) 1221 + return -ENODEV; 1241 1222 1242 1223 file->private_data = gspca_dev; 1243 1224 #ifdef GSPCA_DEBUG ··· 1235 1244 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL 1236 1245 | V4L2_DEBUG_IOCTL_ARG); 1237 1246 #endif 1238 - ret = 0; 1239 - out: 1240 - mutex_unlock(&gspca_dev->queue_lock); 1241 - if (ret != 0) 1242 - PDEBUG(D_ERR|D_STREAM, "open failed err %d", ret); 1243 - else 1244 - PDEBUG(D_STREAM, "open done"); 1245 - return ret; 1247 + return 0; 1246 1248 } 1247 1249 1248 1250 static int dev_close(struct file *file) ··· 1245 1261 PDEBUG(D_STREAM, "[%s] close", current->comm); 1246 1262 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1247 1263 return -ERESTARTSYS; 1248 - gspca_dev->users--; 1249 1264 1250 1265 /* if the file did the capture, free the streaming resources */ 1251 1266 if (gspca_dev->capt_file == file) { ··· 1255 1272 mutex_unlock(&gspca_dev->usb_lock); 1256 1273 } 1257 1274 frame_free(gspca_dev); 1258 - gspca_dev->capt_file = NULL; 1259 - gspca_dev->memory = GSPCA_MEMORY_NO; 1260 1275 } 1261 1276 file->private_data = NULL; 1262 1277 module_put(gspca_dev->module); ··· 1497 1516 return -ERESTARTSYS; 1498 1517 1499 1518 if (gspca_dev->memory != GSPCA_MEMORY_NO 1519 + && gspca_dev->memory != GSPCA_MEMORY_READ 1500 1520 && gspca_dev->memory != rb->memory) { 1501 1521 ret = -EBUSY; 1502 1522 goto out; ··· 1526 1544 gspca_stream_off(gspca_dev); 1527 1545 mutex_unlock(&gspca_dev->usb_lock); 1528 1546 } 1547 + /* Don't restart the stream when switching from read to mmap mode */ 1548 + if (gspca_dev->memory == GSPCA_MEMORY_READ) 1549 + streaming = 0; 1529 1550 1530 1551 /* free the previous allocated buffers, if any */ 1531 - if (gspca_dev->nframes != 0) { 1552 + if (gspca_dev->nframes != 0) 1532 1553 frame_free(gspca_dev); 1533 - gspca_dev->capt_file = NULL; 1534 - } 1535 1554 if (rb->count == 0) /* unrequest */ 1536 1555 goto out; 1537 - gspca_dev->memory = rb->memory; 1538 - ret = frame_alloc(gspca_dev, rb->count); 1556 + ret = frame_alloc(gspca_dev, file, rb->memory, rb->count); 1539 1557 if (ret == 0) { 1540 1558 rb->count = gspca_dev->nframes; 1541 - gspca_dev->capt_file = file; 1542 1559 if (streaming) 1543 1560 ret = gspca_init_transfer(gspca_dev); 1544 1561 } ··· 1611 1630 1612 1631 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1613 1632 return -EINVAL; 1614 - if (!gspca_dev->streaming) 1615 - return 0; 1633 + 1616 1634 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1617 1635 return -ERESTARTSYS; 1636 + 1637 + if (!gspca_dev->streaming) { 1638 + ret = 0; 1639 + goto out; 1640 + } 1618 1641 1619 1642 /* check the capture file */ 1620 1643 if (gspca_dev->capt_file != file) { ··· 1634 1649 gspca_dev->usb_err = 0; 1635 1650 gspca_stream_off(gspca_dev); 1636 1651 mutex_unlock(&gspca_dev->usb_lock); 1652 + /* In case another thread is waiting in dqbuf */ 1653 + wake_up_interruptible(&gspca_dev->wq); 1637 1654 1638 1655 /* empty the transfer queues */ 1639 1656 atomic_set(&gspca_dev->fr_q, 0); ··· 1814 1827 return ret; 1815 1828 } 1816 1829 1817 - /* 1818 - * wait for a video frame 1819 - * 1820 - * If a frame is ready, its index is returned. 1821 - */ 1822 - static int frame_wait(struct gspca_dev *gspca_dev, 1823 - int nonblock_ing) 1830 + static int frame_ready_nolock(struct gspca_dev *gspca_dev, struct file *file, 1831 + enum v4l2_memory memory) 1824 1832 { 1825 - int i, ret; 1833 + if (!gspca_dev->present) 1834 + return -ENODEV; 1835 + if (gspca_dev->capt_file != file || gspca_dev->memory != memory || 1836 + !gspca_dev->streaming) 1837 + return -EINVAL; 1826 1838 1827 1839 /* check if a frame is ready */ 1828 - i = gspca_dev->fr_o; 1829 - if (i == atomic_read(&gspca_dev->fr_i)) { 1830 - if (nonblock_ing) 1831 - return -EAGAIN; 1840 + return gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i); 1841 + } 1832 1842 1833 - /* wait till a frame is ready */ 1834 - ret = wait_event_interruptible_timeout(gspca_dev->wq, 1835 - i != atomic_read(&gspca_dev->fr_i) || 1836 - !gspca_dev->streaming || !gspca_dev->present, 1837 - msecs_to_jiffies(3000)); 1838 - if (ret < 0) 1839 - return ret; 1840 - if (ret == 0 || !gspca_dev->streaming || !gspca_dev->present) 1841 - return -EIO; 1842 - } 1843 + static int frame_ready(struct gspca_dev *gspca_dev, struct file *file, 1844 + enum v4l2_memory memory) 1845 + { 1846 + int ret; 1843 1847 1844 - gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES; 1845 - 1846 - if (gspca_dev->sd_desc->dq_callback) { 1847 - mutex_lock(&gspca_dev->usb_lock); 1848 - gspca_dev->usb_err = 0; 1849 - if (gspca_dev->present) 1850 - gspca_dev->sd_desc->dq_callback(gspca_dev); 1851 - mutex_unlock(&gspca_dev->usb_lock); 1852 - } 1853 - return gspca_dev->fr_queue[i]; 1848 + if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1849 + return -ERESTARTSYS; 1850 + ret = frame_ready_nolock(gspca_dev, file, memory); 1851 + mutex_unlock(&gspca_dev->queue_lock); 1852 + return ret; 1854 1853 } 1855 1854 1856 1855 /* ··· 1849 1876 { 1850 1877 struct gspca_dev *gspca_dev = priv; 1851 1878 struct gspca_frame *frame; 1852 - int i, ret; 1879 + int i, j, ret; 1853 1880 1854 1881 PDEBUG(D_FRAM, "dqbuf"); 1855 - if (v4l2_buf->memory != gspca_dev->memory) 1856 - return -EINVAL; 1857 1882 1858 - if (!gspca_dev->present) 1859 - return -ENODEV; 1860 - 1861 - /* if not streaming, be sure the application will not loop forever */ 1862 - if (!(file->f_flags & O_NONBLOCK) 1863 - && !gspca_dev->streaming && gspca_dev->users == 1) 1864 - return -EINVAL; 1865 - 1866 - /* only the capturing file may dequeue */ 1867 - if (gspca_dev->capt_file != file) 1868 - return -EINVAL; 1869 - 1870 - /* only one dequeue / read at a time */ 1871 - if (mutex_lock_interruptible(&gspca_dev->read_lock)) 1883 + if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1872 1884 return -ERESTARTSYS; 1873 1885 1874 - ret = frame_wait(gspca_dev, file->f_flags & O_NONBLOCK); 1875 - if (ret < 0) 1876 - goto out; 1877 - i = ret; /* frame index */ 1878 - frame = &gspca_dev->frame[i]; 1886 + for (;;) { 1887 + ret = frame_ready_nolock(gspca_dev, file, v4l2_buf->memory); 1888 + if (ret < 0) 1889 + goto out; 1890 + if (ret > 0) 1891 + break; 1892 + 1893 + mutex_unlock(&gspca_dev->queue_lock); 1894 + 1895 + if (file->f_flags & O_NONBLOCK) 1896 + return -EAGAIN; 1897 + 1898 + /* wait till a frame is ready */ 1899 + ret = wait_event_interruptible_timeout(gspca_dev->wq, 1900 + frame_ready(gspca_dev, file, v4l2_buf->memory), 1901 + msecs_to_jiffies(3000)); 1902 + if (ret < 0) 1903 + return ret; 1904 + if (ret == 0) 1905 + return -EIO; 1906 + 1907 + if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1908 + return -ERESTARTSYS; 1909 + } 1910 + 1911 + i = gspca_dev->fr_o; 1912 + j = gspca_dev->fr_queue[i]; 1913 + frame = &gspca_dev->frame[j]; 1914 + 1915 + gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES; 1916 + 1917 + if (gspca_dev->sd_desc->dq_callback) { 1918 + mutex_lock(&gspca_dev->usb_lock); 1919 + gspca_dev->usb_err = 0; 1920 + if (gspca_dev->present) 1921 + gspca_dev->sd_desc->dq_callback(gspca_dev); 1922 + mutex_unlock(&gspca_dev->usb_lock); 1923 + } 1924 + 1925 + frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; 1926 + memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf); 1927 + PDEBUG(D_FRAM, "dqbuf %d", j); 1928 + ret = 0; 1929 + 1879 1930 if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { 1880 1931 if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, 1881 1932 frame->data, ··· 1907 1910 PDEBUG(D_ERR|D_STREAM, 1908 1911 "dqbuf cp to user failed"); 1909 1912 ret = -EFAULT; 1910 - goto out; 1911 1913 } 1912 1914 } 1913 - frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; 1914 - memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf); 1915 - PDEBUG(D_FRAM, "dqbuf %d", i); 1916 - ret = 0; 1917 1915 out: 1918 - mutex_unlock(&gspca_dev->read_lock); 1916 + mutex_unlock(&gspca_dev->queue_lock); 1919 1917 return ret; 1920 1918 } 1921 1919 ··· 2025 2033 poll_wait(file, &gspca_dev->wq, wait); 2026 2034 2027 2035 /* if reqbufs is not done, the user would use read() */ 2028 - if (gspca_dev->nframes == 0) { 2029 - if (gspca_dev->memory != GSPCA_MEMORY_NO) 2030 - return POLLERR; /* not the 1st time */ 2036 + if (gspca_dev->memory == GSPCA_MEMORY_NO) { 2031 2037 ret = read_alloc(gspca_dev, file); 2032 2038 if (ret != 0) 2033 2039 return POLLERR; ··· 2057 2067 PDEBUG(D_FRAM, "read (%zd)", count); 2058 2068 if (!gspca_dev->present) 2059 2069 return -ENODEV; 2060 - switch (gspca_dev->memory) { 2061 - case GSPCA_MEMORY_NO: /* first time */ 2070 + if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* first time ? */ 2062 2071 ret = read_alloc(gspca_dev, file); 2063 2072 if (ret != 0) 2064 2073 return ret; 2065 - break; 2066 - case GSPCA_MEMORY_READ: 2067 - if (gspca_dev->capt_file == file) 2068 - break; 2069 - /* fall thru */ 2070 - default: 2071 - return -EINVAL; 2072 2074 } 2073 2075 2074 2076 /* get a frame */ ··· 2248 2266 goto out; 2249 2267 2250 2268 mutex_init(&gspca_dev->usb_lock); 2251 - mutex_init(&gspca_dev->read_lock); 2252 2269 mutex_init(&gspca_dev->queue_lock); 2253 2270 init_waitqueue_head(&gspca_dev->wq); 2254 2271 ··· 2322 2341 PDEBUG(D_PROBE, "%s disconnect", 2323 2342 video_device_node_name(&gspca_dev->vdev)); 2324 2343 mutex_lock(&gspca_dev->usb_lock); 2325 - gspca_dev->present = 0; 2326 2344 2327 - if (gspca_dev->streaming) { 2328 - destroy_urbs(gspca_dev); 2329 - wake_up_interruptible(&gspca_dev->wq); 2330 - } 2345 + gspca_dev->present = 0; 2346 + wake_up_interruptible(&gspca_dev->wq); 2347 + 2348 + destroy_urbs(gspca_dev); 2331 2349 2332 2350 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) 2333 2351 gspca_input_destroy_urb(gspca_dev);
-2
drivers/media/video/gspca/gspca.h
··· 205 205 206 206 wait_queue_head_t wq; /* wait queue */ 207 207 struct mutex usb_lock; /* usb exchange protection */ 208 - struct mutex read_lock; /* read protection */ 209 208 struct mutex queue_lock; /* ISOC queue protection */ 210 209 int usb_err; /* USB error - protected by usb_lock */ 211 210 u16 pkt_size; /* ISOC packet size */ 212 211 #ifdef CONFIG_PM 213 212 char frozen; /* suspend - resume */ 214 213 #endif 215 - char users; /* number of opens */ 216 214 char present; /* device connected */ 217 215 char nbufread; /* number of buffers for read() */ 218 216 char memory; /* memory type (V4L2_MEMORY_xxx) */
+1 -1
drivers/media/video/gspca/jeilinj.c
··· 314 314 } 315 315 316 316 /* Table of supported USB devices */ 317 - static const __devinitdata struct usb_device_id device_table[] = { 317 + static const struct usb_device_id device_table[] = { 318 318 {USB_DEVICE(0x0979, 0x0280)}, 319 319 {} 320 320 };
+2 -2
drivers/media/video/gspca/jpeg.h
··· 141 141 memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head); 142 142 #ifndef CONEX_CAM 143 143 jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8; 144 - jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height & 0xff; 144 + jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height; 145 145 jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8; 146 - jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width & 0xff; 146 + jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width; 147 147 jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY; 148 148 #endif 149 149 }
+1 -1
drivers/media/video/gspca/konica.c
··· 607 607 }; 608 608 609 609 /* -- module initialisation -- */ 610 - static const __devinitdata struct usb_device_id device_table[] = { 610 + static const struct usb_device_id device_table[] = { 611 611 {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */ 612 612 {} 613 613 };
+1 -1
drivers/media/video/gspca/m5602/m5602_core.c
··· 28 28 static int dump_bridge; 29 29 int dump_sensor; 30 30 31 - static const __devinitdata struct usb_device_id m5602_table[] = { 31 + static const struct usb_device_id m5602_table[] = { 32 32 {USB_DEVICE(0x0402, 0x5602)}, 33 33 {} 34 34 };
+1 -1
drivers/media/video/gspca/mars.c
··· 490 490 }; 491 491 492 492 /* -- module initialisation -- */ 493 - static const __devinitdata struct usb_device_id device_table[] = { 493 + static const struct usb_device_id device_table[] = { 494 494 {USB_DEVICE(0x093a, 0x050f)}, 495 495 {} 496 496 };
+1 -1
drivers/media/video/gspca/mr97310a.c
··· 1229 1229 }; 1230 1230 1231 1231 /* -- module initialisation -- */ 1232 - static const __devinitdata struct usb_device_id device_table[] = { 1232 + static const struct usb_device_id device_table[] = { 1233 1233 {USB_DEVICE(0x08ca, 0x0110)}, /* Trust Spyc@m 100 */ 1234 1234 {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */ 1235 1235 {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */
+3 -5
drivers/media/video/gspca/ov519.c
··· 488 488 #define R511_SNAP_PXDIV 0x1c 489 489 #define R511_SNAP_LNDIV 0x1d 490 490 #define R511_SNAP_UV_EN 0x1e 491 - #define R511_SNAP_UV_EN 0x1e 492 491 #define R511_SNAP_OPTS 0x1f 493 492 494 493 #define R511_DRAM_FLOW_CTL 0x20 ··· 1846 1847 { 0x6c, 0x0a }, 1847 1848 { 0x6d, 0x55 }, 1848 1849 { 0x6e, 0x11 }, 1849 - { 0x6f, 0x9f }, 1850 - /* "9e for advance AWB" */ 1850 + { 0x6f, 0x9f }, /* "9e for advance AWB" */ 1851 1851 { 0x6a, 0x40 }, 1852 1852 { OV7670_R01_BLUE, 0x40 }, 1853 1853 { OV7670_R02_RED, 0x60 }, ··· 3052 3054 { 3053 3055 static const struct ov_regvals init_519[] = { 3054 3056 { 0x5a, 0x6d }, /* EnableSystem */ 3055 - { 0x53, 0x9b }, 3057 + { 0x53, 0x9b }, /* don't enable the microcontroller */ 3056 3058 { OV519_R54_EN_CLK1, 0xff }, /* set bit2 to enable jpeg */ 3057 3059 { 0x5d, 0x03 }, 3058 3060 { 0x49, 0x01 }, ··· 4745 4747 }; 4746 4748 4747 4749 /* -- module initialisation -- */ 4748 - static const __devinitdata struct usb_device_id device_table[] = { 4750 + static const struct usb_device_id device_table[] = { 4749 4751 {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, 4750 4752 {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 }, 4751 4753 {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 },
+20 -9
drivers/media/video/gspca/ov534.c
··· 479 479 struct usb_device *udev = gspca_dev->dev; 480 480 int ret; 481 481 482 - PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val); 482 + if (gspca_dev->usb_err < 0) 483 + return; 484 + 485 + PDEBUG(D_USBO, "SET 01 0000 %04x %02x", reg, val); 483 486 gspca_dev->usb_buf[0] = val; 484 487 ret = usb_control_msg(udev, 485 488 usb_sndctrlpipe(udev, 0), 486 489 0x01, 487 490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 488 491 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 489 - if (ret < 0) 492 + if (ret < 0) { 490 493 err("write failed %d", ret); 494 + gspca_dev->usb_err = ret; 495 + } 491 496 } 492 497 493 498 static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) ··· 500 495 struct usb_device *udev = gspca_dev->dev; 501 496 int ret; 502 497 498 + if (gspca_dev->usb_err < 0) 499 + return 0; 503 500 ret = usb_control_msg(udev, 504 501 usb_rcvctrlpipe(udev, 0), 505 502 0x01, 506 503 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 507 504 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 508 - PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, gspca_dev->usb_buf[0]); 509 - if (ret < 0) 505 + PDEBUG(D_USBI, "GET 01 0000 %04x %02x", reg, gspca_dev->usb_buf[0]); 506 + if (ret < 0) { 510 507 err("read failed %d", ret); 508 + gspca_dev->usb_err = ret; 509 + } 511 510 return gspca_dev->usb_buf[0]; 512 511 } 513 512 ··· 567 558 568 559 static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) 569 560 { 570 - PDEBUG(D_USBO, "reg: 0x%02x, val: 0x%02x", reg, val); 561 + PDEBUG(D_USBO, "sccb write: %02x %02x", reg, val); 571 562 ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); 572 563 ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); 573 564 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); 574 565 575 - if (!sccb_check_status(gspca_dev)) 566 + if (!sccb_check_status(gspca_dev)) { 576 567 err("sccb_reg_write failed"); 568 + gspca_dev->usb_err = -EIO; 569 + } 577 570 } 578 571 579 572 static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) ··· 896 885 ov534_set_led(gspca_dev, 0); 897 886 set_frame_rate(gspca_dev); 898 887 899 - return 0; 888 + return gspca_dev->usb_err; 900 889 } 901 890 902 891 static int sd_start(struct gspca_dev *gspca_dev) ··· 931 920 932 921 ov534_set_led(gspca_dev, 1); 933 922 ov534_reg_write(gspca_dev, 0xe0, 0x00); 934 - return 0; 923 + return gspca_dev->usb_err; 935 924 } 936 925 937 926 static void sd_stopN(struct gspca_dev *gspca_dev) ··· 1300 1289 }; 1301 1290 1302 1291 /* -- module initialisation -- */ 1303 - static const __devinitdata struct usb_device_id device_table[] = { 1292 + static const struct usb_device_id device_table[] = { 1304 1293 {USB_DEVICE(0x1415, 0x2000)}, 1305 1294 {} 1306 1295 };
+1 -1
drivers/media/video/gspca/ov534_9.c
··· 1429 1429 }; 1430 1430 1431 1431 /* -- module initialisation -- */ 1432 - static const __devinitdata struct usb_device_id device_table[] = { 1432 + static const struct usb_device_id device_table[] = { 1433 1433 {USB_DEVICE(0x06f8, 0x3003)}, 1434 1434 {} 1435 1435 };
+1 -1
drivers/media/video/gspca/pac207.c
··· 530 530 }; 531 531 532 532 /* -- module initialisation -- */ 533 - static const __devinitdata struct usb_device_id device_table[] = { 533 + static const struct usb_device_id device_table[] = { 534 534 {USB_DEVICE(0x041e, 0x4028)}, 535 535 {USB_DEVICE(0x093a, 0x2460)}, 536 536 {USB_DEVICE(0x093a, 0x2461)},
+2 -2
drivers/media/video/gspca/pac7302.c
··· 1184 1184 }; 1185 1185 1186 1186 /* -- module initialisation -- */ 1187 - static const struct usb_device_id device_table[] __devinitconst = { 1187 + static const struct usb_device_id device_table[] = { 1188 1188 {USB_DEVICE(0x06f8, 0x3009)}, 1189 1189 {USB_DEVICE(0x093a, 0x2620)}, 1190 1190 {USB_DEVICE(0x093a, 0x2621)}, ··· 1201 1201 MODULE_DEVICE_TABLE(usb, device_table); 1202 1202 1203 1203 /* -- device connect -- */ 1204 - static int __devinit sd_probe(struct usb_interface *intf, 1204 + static int sd_probe(struct usb_interface *intf, 1205 1205 const struct usb_device_id *id) 1206 1206 { 1207 1207 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
+2 -2
drivers/media/video/gspca/pac7311.c
··· 837 837 }; 838 838 839 839 /* -- module initialisation -- */ 840 - static const struct usb_device_id device_table[] __devinitconst = { 840 + static const struct usb_device_id device_table[] = { 841 841 {USB_DEVICE(0x093a, 0x2600)}, 842 842 {USB_DEVICE(0x093a, 0x2601)}, 843 843 {USB_DEVICE(0x093a, 0x2603)}, ··· 849 849 MODULE_DEVICE_TABLE(usb, device_table); 850 850 851 851 /* -- device connect -- */ 852 - static int __devinit sd_probe(struct usb_interface *intf, 852 + static int sd_probe(struct usb_interface *intf, 853 853 const struct usb_device_id *id) 854 854 { 855 855 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
+1 -1
drivers/media/video/gspca/sn9c2028.c
··· 703 703 }; 704 704 705 705 /* -- module initialisation -- */ 706 - static const __devinitdata struct usb_device_id device_table[] = { 706 + static const struct usb_device_id device_table[] = { 707 707 {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */ 708 708 /* The Genius Smart is untested. I can't find an owner ! */ 709 709 /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */
+1 -1
drivers/media/video/gspca/sn9c20x.c
··· 2470 2470 | (SENSOR_ ## sensor << 8) \ 2471 2471 | (i2c_addr) 2472 2472 2473 - static const __devinitdata struct usb_device_id device_table[] = { 2473 + static const struct usb_device_id device_table[] = { 2474 2474 {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)}, 2475 2475 {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)}, 2476 2476 {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)},
+157 -113
drivers/media/video/gspca/sonixb.c
··· 23 23 /* Some documentation on known sonixb registers: 24 24 25 25 Reg Use 26 + sn9c101 / sn9c102: 26 27 0x10 high nibble red gain low nibble blue gain 27 28 0x11 low nibble green gain 29 + sn9c103: 30 + 0x05 red gain 0-127 31 + 0x06 blue gain 0-127 32 + 0x07 green gain 0-127 33 + all: 34 + 0x08-0x0f i2c / 3wire registers 28 35 0x12 hstart 29 36 0x13 vstart 30 37 0x15 hsize (hsize = register-value * 16) ··· 95 88 typedef const __u8 sensor_init_t[8]; 96 89 97 90 struct sensor_data { 98 - const __u8 *bridge_init[2]; 99 - int bridge_init_size[2]; 91 + const __u8 *bridge_init; 100 92 sensor_init_t *sensor_init; 101 93 int sensor_init_size; 102 - sensor_init_t *sensor_bridge_init[2]; 103 - int sensor_bridge_init_size[2]; 104 94 int flags; 105 95 unsigned ctrl_dis; 106 96 __u8 sensor_addr; ··· 118 114 #define NO_FREQ (1 << FREQ_IDX) 119 115 #define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX) 120 116 121 - #define COMP2 0x8f 122 117 #define COMP 0xc7 /* 0x87 //0x07 */ 123 118 #define COMP1 0xc9 /* 0x89 //0x09 */ 124 119 ··· 126 123 127 124 #define SYS_CLK 0x04 128 125 129 - #define SENS(bridge_1, bridge_3, sensor, sensor_1, \ 130 - sensor_3, _flags, _ctrl_dis, _sensor_addr) \ 126 + #define SENS(bridge, sensor, _flags, _ctrl_dis, _sensor_addr) \ 131 127 { \ 132 - .bridge_init = { bridge_1, bridge_3 }, \ 133 - .bridge_init_size = { sizeof(bridge_1), sizeof(bridge_3) }, \ 128 + .bridge_init = bridge, \ 134 129 .sensor_init = sensor, \ 135 130 .sensor_init_size = sizeof(sensor), \ 136 - .sensor_bridge_init = { sensor_1, sensor_3,}, \ 137 - .sensor_bridge_init_size = { sizeof(sensor_1), sizeof(sensor_3)}, \ 138 131 .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \ 139 132 } 140 133 ··· 310 311 0x00, 0x00, 311 312 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 312 313 0x28, 0x1e, 0x60, 0x8e, 0x42, 313 - 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c 314 314 }; 315 315 static const __u8 hv7131d_sensor_init[][8] = { 316 316 {0xa0, 0x11, 0x01, 0x04, 0x00, 0x00, 0x00, 0x17}, ··· 324 326 0x00, 0x00, 325 327 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 326 328 0x28, 0x1e, 0x60, 0x8a, 0x20, 327 - 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c 328 329 }; 329 330 static const __u8 hv7131r_sensor_init[][8] = { 330 331 {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10}, ··· 336 339 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 337 340 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 338 341 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, 339 - 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07 342 + 0x10, 340 343 }; 341 344 static const __u8 ov6650_sensor_init[][8] = { 342 345 /* Bright, contrast, etc are set through SCBB interface. ··· 375 378 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ 376 379 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ 377 380 0x28, 0x1e, /* H & V sizes r15 .. r16 */ 378 - 0x68, COMP2, MCK_INIT1, /* r17 .. r19 */ 379 - 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */ 380 - }; 381 - static const __u8 initOv7630_3[] = { 382 - 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */ 383 - 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ 384 - 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */ 385 - 0x28, 0x1e, /* H & V sizes r15 .. r16 */ 386 381 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ 387 - 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */ 388 - 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */ 389 - 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */ 390 382 }; 391 383 static const __u8 ov7630_sensor_init[][8] = { 392 384 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, 393 385 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10}, 394 386 /* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */ 395 - {0xd0, 0x21, 0x12, 0x1c, 0x00, 0x80, 0x34, 0x10}, /* jfm */ 387 + {0xd0, 0x21, 0x12, 0x5c, 0x00, 0x80, 0x34, 0x10}, /* jfm */ 396 388 {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10}, 397 389 {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10}, 398 390 {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10}, ··· 399 413 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, 400 414 }; 401 415 402 - static const __u8 ov7630_sensor_init_3[][8] = { 403 - {0xa0, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, 404 - }; 405 - 406 416 static const __u8 initPas106[] = { 407 417 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, 408 418 0x00, 0x00, 409 419 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 410 420 0x16, 0x12, 0x24, COMP1, MCK_INIT1, 411 - 0x18, 0x10, 0x02, 0x02, 0x09, 0x07 412 421 }; 413 422 /* compression 0x86 mckinit1 0x2b */ 414 423 ··· 477 496 0x00, 0x00, 478 497 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a, 479 498 0x28, 0x1e, 0x20, 0x89, 0x20, 480 - 0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c 481 499 }; 482 500 483 501 /* "Known" PAS202BCB registers: ··· 517 537 0x00, 0x00, 518 538 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a, 519 539 0x16, 0x12, 0x60, 0x86, 0x2b, 520 - 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 521 540 }; 522 541 /* Same as above, except a different hstart */ 523 542 static const __u8 initTas5110d[] = { ··· 524 545 0x00, 0x00, 525 546 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a, 526 547 0x16, 0x12, 0x60, 0x86, 0x2b, 527 - 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 528 548 }; 529 - static const __u8 tas5110_sensor_init[][8] = { 549 + /* tas5110c is 3 wire, tas5110d is 2 wire (regular i2c) */ 550 + static const __u8 tas5110c_sensor_init[][8] = { 530 551 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10}, 531 552 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10}, 532 - {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, 553 + }; 554 + /* Known TAS5110D registers 555 + * reg02: gain, bit order reversed!! 0 == max gain, 255 == min gain 556 + * reg03: bit3: vflip, bit4: ~hflip, bit7: ~gainboost (~ == inverted) 557 + * Note: writing reg03 seems to only work when written together with 02 558 + */ 559 + static const __u8 tas5110d_sensor_init[][8] = { 560 + {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, /* reset */ 533 561 }; 534 562 535 563 static const __u8 initTas5130[] = { ··· 544 558 0x00, 0x00, 545 559 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a, 546 560 0x28, 0x1e, 0x60, COMP, MCK_INIT, 547 - 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c 548 561 }; 549 562 static const __u8 tas5130_sensor_init[][8] = { 550 563 /* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10}, ··· 554 569 }; 555 570 556 571 static struct sensor_data sensor_data[] = { 557 - SENS(initHv7131d, NULL, hv7131d_sensor_init, NULL, NULL, F_GAIN, NO_BRIGHTNESS|NO_FREQ, 0), 558 - SENS(initHv7131r, NULL, hv7131r_sensor_init, NULL, NULL, 0, NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), 559 - SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF, 0, 0x60), 560 - SENS(initOv7630, initOv7630_3, ov7630_sensor_init, NULL, ov7630_sensor_init_3, 561 - F_GAIN, 0, 0x21), 562 - SENS(initPas106, NULL, pas106_sensor_init, NULL, NULL, F_GAIN|F_SIF, NO_FREQ, 563 - 0), 564 - SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, F_GAIN, 565 - NO_FREQ, 0), 566 - SENS(initTas5110c, NULL, tas5110_sensor_init, NULL, NULL, 567 - F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0), 568 - SENS(initTas5110d, NULL, tas5110_sensor_init, NULL, NULL, 569 - F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0), 570 - SENS(initTas5130, NULL, tas5130_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, 571 - 0), 572 + SENS(initHv7131d, hv7131d_sensor_init, F_GAIN, NO_BRIGHTNESS|NO_FREQ, 0), 573 + SENS(initHv7131r, hv7131r_sensor_init, 0, NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), 574 + SENS(initOv6650, ov6650_sensor_init, F_GAIN|F_SIF, 0, 0x60), 575 + SENS(initOv7630, ov7630_sensor_init, F_GAIN, 0, 0x21), 576 + SENS(initPas106, pas106_sensor_init, F_GAIN|F_SIF, NO_FREQ, 0), 577 + SENS(initPas202, pas202_sensor_init, F_GAIN, NO_FREQ, 0), 578 + SENS(initTas5110c, tas5110c_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, 579 + NO_BRIGHTNESS|NO_FREQ, 0), 580 + SENS(initTas5110d, tas5110d_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, 581 + NO_BRIGHTNESS|NO_FREQ, 0), 582 + SENS(initTas5130, tas5130_sensor_init, F_GAIN, 583 + NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), 572 584 }; 573 585 574 586 /* get one byte in gspca_dev->usb_buf */ ··· 637 655 static void setbrightness(struct gspca_dev *gspca_dev) 638 656 { 639 657 struct sd *sd = (struct sd *) gspca_dev; 640 - __u8 value; 641 658 642 659 switch (sd->sensor) { 643 660 case SENSOR_OV6650: ··· 678 697 goto err; 679 698 break; 680 699 } 681 - case SENSOR_TAS5130CXX: { 682 - __u8 i2c[] = 683 - {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; 684 - 685 - value = 0xff - sd->brightness; 686 - i2c[4] = value; 687 - PDEBUG(D_CONF, "brightness %d : %d", value, i2c[4]); 688 - if (i2c_w(gspca_dev, i2c) < 0) 689 - goto err; 690 - break; 691 - } 692 700 } 693 701 return; 694 702 err: ··· 703 733 break; 704 734 } 705 735 case SENSOR_TAS5110C: 706 - case SENSOR_TAS5110D: { 736 + case SENSOR_TAS5130CXX: { 707 737 __u8 i2c[] = 708 738 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; 709 739 710 740 i2c[4] = 255 - gain; 741 + if (i2c_w(gspca_dev, i2c) < 0) 742 + goto err; 743 + break; 744 + } 745 + case SENSOR_TAS5110D: { 746 + __u8 i2c[] = { 747 + 0xb0, 0x61, 0x02, 0x00, 0x10, 0x00, 0x00, 0x17 }; 748 + gain = 255 - gain; 749 + /* The bits in the register are the wrong way around!! */ 750 + i2c[3] |= (gain & 0x80) >> 7; 751 + i2c[3] |= (gain & 0x40) >> 5; 752 + i2c[3] |= (gain & 0x20) >> 3; 753 + i2c[3] |= (gain & 0x10) >> 1; 754 + i2c[3] |= (gain & 0x08) << 1; 755 + i2c[3] |= (gain & 0x04) << 3; 756 + i2c[3] |= (gain & 0x02) << 5; 757 + i2c[3] |= (gain & 0x01) << 7; 711 758 if (i2c_w(gspca_dev, i2c) < 0) 712 759 goto err; 713 760 break; ··· 783 796 { 784 797 struct sd *sd = (struct sd *) gspca_dev; 785 798 __u8 gain; 786 - __u8 buf[2] = { 0, 0 }; 799 + __u8 buf[3] = { 0, 0, 0 }; 787 800 788 801 if (sensor_data[sd->sensor].flags & F_GAIN) { 789 802 /* Use the sensor gain to do the actual gain */ ··· 791 804 return; 792 805 } 793 806 794 - gain = sd->gain >> 4; 795 - 796 - /* red and blue gain */ 797 - buf[0] = gain << 4 | gain; 798 - /* green gain */ 799 - buf[1] = gain; 800 - reg_w(gspca_dev, 0x10, buf, 2); 807 + if (sd->bridge == BRIDGE_103) { 808 + gain = sd->gain >> 1; 809 + buf[0] = gain; /* Red */ 810 + buf[1] = gain; /* Green */ 811 + buf[2] = gain; /* Blue */ 812 + reg_w(gspca_dev, 0x05, buf, 3); 813 + } else { 814 + gain = sd->gain >> 4; 815 + buf[0] = gain << 4 | gain; /* Red and blue */ 816 + buf[1] = gain; /* Green */ 817 + reg_w(gspca_dev, 0x10, buf, 2); 818 + } 801 819 } 802 820 803 821 static void setexposure(struct gspca_dev *gspca_dev) ··· 1041 1049 desired_avg_lum = 5000; 1042 1050 } else { 1043 1051 deadzone = 1500; 1044 - desired_avg_lum = 18000; 1052 + desired_avg_lum = 13000; 1045 1053 } 1046 1054 1047 1055 if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) ··· 1119 1127 { 1120 1128 struct sd *sd = (struct sd *) gspca_dev; 1121 1129 struct cam *cam = &gspca_dev->cam; 1122 - int mode, l; 1123 - const __u8 *sn9c10x; 1124 - __u8 reg12_19[8]; 1130 + int i, mode; 1131 + __u8 regs[0x31]; 1125 1132 1126 1133 mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; 1127 - sn9c10x = sensor_data[sd->sensor].bridge_init[sd->bridge]; 1128 - l = sensor_data[sd->sensor].bridge_init_size[sd->bridge]; 1129 - memcpy(reg12_19, &sn9c10x[0x12 - 1], 8); 1130 - reg12_19[6] = sn9c10x[0x18 - 1] | (mode << 4); 1131 - /* Special cases where reg 17 and or 19 value depends on mode */ 1134 + /* Copy registers 0x01 - 0x19 from the template */ 1135 + memcpy(&regs[0x01], sensor_data[sd->sensor].bridge_init, 0x19); 1136 + /* Set the mode */ 1137 + regs[0x18] |= mode << 4; 1138 + 1139 + /* Set bridge gain to 1.0 */ 1140 + if (sd->bridge == BRIDGE_103) { 1141 + regs[0x05] = 0x20; /* Red */ 1142 + regs[0x06] = 0x20; /* Green */ 1143 + regs[0x07] = 0x20; /* Blue */ 1144 + } else { 1145 + regs[0x10] = 0x00; /* Red and blue */ 1146 + regs[0x11] = 0x00; /* Green */ 1147 + } 1148 + 1149 + /* Setup pixel numbers and auto exposure window */ 1150 + if (sensor_data[sd->sensor].flags & F_SIF) { 1151 + regs[0x1a] = 0x14; /* HO_SIZE 640, makes no sense */ 1152 + regs[0x1b] = 0x0a; /* VO_SIZE 320, makes no sense */ 1153 + regs[0x1c] = 0x02; /* AE H-start 64 */ 1154 + regs[0x1d] = 0x02; /* AE V-start 64 */ 1155 + regs[0x1e] = 0x09; /* AE H-end 288 */ 1156 + regs[0x1f] = 0x07; /* AE V-end 224 */ 1157 + } else { 1158 + regs[0x1a] = 0x1d; /* HO_SIZE 960, makes no sense */ 1159 + regs[0x1b] = 0x10; /* VO_SIZE 512, makes no sense */ 1160 + regs[0x1c] = 0x05; /* AE H-start 160 */ 1161 + regs[0x1d] = 0x03; /* AE V-start 96 */ 1162 + regs[0x1e] = 0x0f; /* AE H-end 480 */ 1163 + regs[0x1f] = 0x0c; /* AE V-end 384 */ 1164 + } 1165 + 1166 + /* Setup the gamma table (only used with the sn9c103 bridge) */ 1167 + for (i = 0; i < 16; i++) 1168 + regs[0x20 + i] = i * 16; 1169 + regs[0x20 + i] = 255; 1170 + 1171 + /* Special cases where some regs depend on mode or bridge */ 1132 1172 switch (sd->sensor) { 1133 1173 case SENSOR_TAS5130CXX: 1134 - /* probably not mode specific at all most likely the upper 1174 + /* FIXME / TESTME 1175 + probably not mode specific at all most likely the upper 1135 1176 nibble of 0x19 is exposure (clock divider) just as with 1136 1177 the tas5110, we need someone to test this. */ 1137 - reg12_19[7] = mode ? 0x23 : 0x43; 1178 + regs[0x19] = mode ? 0x23 : 0x43; 1138 1179 break; 1180 + case SENSOR_OV7630: 1181 + /* FIXME / TESTME for some reason with the 101/102 bridge the 1182 + clock is set to 12 Mhz (reg1 == 0x04), rather then 24. 1183 + Also the hstart needs to go from 1 to 2 when using a 103, 1184 + which is likely related. This does not seem right. */ 1185 + if (sd->bridge == BRIDGE_103) { 1186 + regs[0x01] = 0x44; /* Select 24 Mhz clock */ 1187 + regs[0x12] = 0x02; /* Set hstart to 2 */ 1188 + } 1139 1189 } 1140 1190 /* Disable compression when the raw bayer format has been selected */ 1141 1191 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) 1142 - reg12_19[6] &= ~0x80; 1192 + regs[0x18] &= ~0x80; 1143 1193 1144 1194 /* Vga mode emulation on SIF sensor? */ 1145 1195 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { 1146 - reg12_19[0] += 16; /* 0x12: hstart adjust */ 1147 - reg12_19[1] += 24; /* 0x13: vstart adjust */ 1148 - reg12_19[3] = 320 / 16; /* 0x15: hsize */ 1149 - reg12_19[4] = 240 / 16; /* 0x16: vsize */ 1196 + regs[0x12] += 16; /* hstart adjust */ 1197 + regs[0x13] += 24; /* vstart adjust */ 1198 + regs[0x15] = 320 / 16; /* hsize */ 1199 + regs[0x16] = 240 / 16; /* vsize */ 1150 1200 } 1151 1201 1152 1202 /* reg 0x01 bit 2 video transfert on */ 1153 - reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1); 1203 + reg_w(gspca_dev, 0x01, &regs[0x01], 1); 1154 1204 /* reg 0x17 SensorClk enable inv Clk 0x60 */ 1155 - reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); 1205 + reg_w(gspca_dev, 0x17, &regs[0x17], 1); 1156 1206 /* Set the registers from the template */ 1157 - reg_w(gspca_dev, 0x01, sn9c10x, l); 1207 + reg_w(gspca_dev, 0x01, &regs[0x01], 1208 + (sd->bridge == BRIDGE_103) ? 0x30 : 0x1f); 1158 1209 1159 1210 /* Init the sensor */ 1160 1211 i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, 1161 1212 sensor_data[sd->sensor].sensor_init_size); 1162 - if (sensor_data[sd->sensor].sensor_bridge_init[sd->bridge]) 1163 - i2c_w_vector(gspca_dev, 1164 - sensor_data[sd->sensor].sensor_bridge_init[sd->bridge], 1165 - sensor_data[sd->sensor].sensor_bridge_init_size[ 1166 - sd->bridge]); 1167 1213 1168 - /* Mode specific sensor setup */ 1214 + /* Mode / bridge specific sensor setup */ 1169 1215 switch (sd->sensor) { 1170 1216 case SENSOR_PAS202: { 1171 1217 const __u8 i2cpclockdiv[] = ··· 1211 1181 /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */ 1212 1182 if (mode) 1213 1183 i2c_w(gspca_dev, i2cpclockdiv); 1184 + break; 1214 1185 } 1186 + case SENSOR_OV7630: 1187 + /* FIXME / TESTME We should be able to handle this identical 1188 + for the 101/102 and the 103 case */ 1189 + if (sd->bridge == BRIDGE_103) { 1190 + const __u8 i2c[] = { 0xa0, 0x21, 0x13, 1191 + 0x80, 0x00, 0x00, 0x00, 0x10 }; 1192 + i2c_w(gspca_dev, i2c); 1193 + } 1194 + break; 1215 1195 } 1216 1196 /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ 1217 - reg_w(gspca_dev, 0x15, &reg12_19[3], 2); 1197 + reg_w(gspca_dev, 0x15, &regs[0x15], 2); 1218 1198 /* compression register */ 1219 - reg_w(gspca_dev, 0x18, &reg12_19[6], 1); 1199 + reg_w(gspca_dev, 0x18, &regs[0x18], 1); 1220 1200 /* H_start */ 1221 - reg_w(gspca_dev, 0x12, &reg12_19[0], 1); 1201 + reg_w(gspca_dev, 0x12, &regs[0x12], 1); 1222 1202 /* V_START */ 1223 - reg_w(gspca_dev, 0x13, &reg12_19[1], 1); 1203 + reg_w(gspca_dev, 0x13, &regs[0x13], 1); 1224 1204 /* reset 0x17 SensorClk enable inv Clk 0x60 */ 1225 1205 /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ 1226 - reg_w(gspca_dev, 0x17, &reg12_19[5], 1); 1206 + reg_w(gspca_dev, 0x17, &regs[0x17], 1); 1227 1207 /*MCKSIZE ->3 */ /*fixme: not ov7630*/ 1228 - reg_w(gspca_dev, 0x19, &reg12_19[7], 1); 1208 + reg_w(gspca_dev, 0x19, &regs[0x19], 1); 1229 1209 /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ 1230 - reg_w(gspca_dev, 0x1c, &sn9c10x[0x1c - 1], 4); 1210 + reg_w(gspca_dev, 0x1c, &regs[0x1c], 4); 1231 1211 /* Enable video transfert */ 1232 - reg_w(gspca_dev, 0x01, &sn9c10x[0], 1); 1212 + reg_w(gspca_dev, 0x01, &regs[0x01], 1); 1233 1213 /* Compression */ 1234 - reg_w(gspca_dev, 0x18, &reg12_19[6], 2); 1214 + reg_w(gspca_dev, 0x18, &regs[0x18], 2); 1235 1215 msleep(20); 1236 1216 1237 1217 sd->reg11 = -1; ··· 1565 1525 .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge 1566 1526 1567 1527 1568 - static const struct usb_device_id device_table[] __devinitconst = { 1528 + static const struct usb_device_id device_table[] = { 1569 1529 {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */ 1570 1530 {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */ 1571 1531 {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */ 1572 1532 {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)}, 1573 1533 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, 1574 1534 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, 1575 - #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 1576 1535 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, 1536 + #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 1577 1537 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, 1578 1538 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, 1579 1539 #endif ··· 1584 1544 {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)}, 1585 1545 {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)}, 1586 1546 {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)}, 1587 - /* {USB_DEVICE(0x0c45, 0x602b), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */ 1547 + /* {USB_DEVICE(0x0c45, 0x6030), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */ 1548 + /* {USB_DEVICE(0x0c45, 0x6082), SB(MI03XX, 103)}, */ /* MI0343 MI0360 */ 1549 + {USB_DEVICE(0x0c45, 0x6083), SB(HV7131D, 103)}, 1550 + {USB_DEVICE(0x0c45, 0x608c), SB(HV7131R, 103)}, 1551 + /* {USB_DEVICE(0x0c45, 0x608e), SB(CISVF10, 103)}, */ 1588 1552 {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)}, 1589 - #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 1553 + {USB_DEVICE(0x0c45, 0x60a8), SB(PAS106, 103)}, 1554 + {USB_DEVICE(0x0c45, 0x60aa), SB(TAS5130CXX, 103)}, 1590 1555 {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)}, 1591 - #endif 1592 1556 {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)}, 1593 1557 {} 1594 1558 }; 1595 1559 MODULE_DEVICE_TABLE(usb, device_table); 1596 1560 1597 1561 /* -- device connect -- */ 1598 - static int __devinit sd_probe(struct usb_interface *intf, 1562 + static int sd_probe(struct usb_interface *intf, 1599 1563 const struct usb_device_id *id) 1600 1564 { 1601 1565 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
+79 -78
drivers/media/video/gspca/sonixj.c
··· 25 25 #include "gspca.h" 26 26 #include "jpeg.h" 27 27 28 - #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) 29 - 30 28 MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); 31 29 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 32 30 MODULE_LICENSE("GPL"); 31 + 32 + static int starcam; 33 33 34 34 /* controls */ 35 35 enum e_ctrl { ··· 43 43 HFLIP, 44 44 VFLIP, 45 45 SHARPNESS, 46 - INFRARED, 46 + ILLUM, 47 47 FREQ, 48 48 NCTRLS /* number of controls */ 49 49 }; ··· 100 100 }; 101 101 102 102 /* device flags */ 103 - #define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */ 103 + #define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */ 104 + #define F_ILLUM 0x02 /* presence of illuminator */ 104 105 105 106 /* sn9c1xx definitions */ 106 107 /* register 0x01 */ ··· 125 124 static void setautogain(struct gspca_dev *gspca_dev); 126 125 static void sethvflip(struct gspca_dev *gspca_dev); 127 126 static void setsharpness(struct gspca_dev *gspca_dev); 128 - static void setinfrared(struct gspca_dev *gspca_dev); 127 + static void setillum(struct gspca_dev *gspca_dev); 129 128 static void setfreq(struct gspca_dev *gspca_dev); 130 129 131 130 static const struct ctrl sd_ctrls[NCTRLS] = { ··· 252 251 }, 253 252 .set_control = setsharpness 254 253 }, 255 - /* mt9v111 only */ 256 - [INFRARED] = { 254 + [ILLUM] = { 257 255 { 258 - .id = V4L2_CID_INFRARED, 256 + .id = V4L2_CID_ILLUMINATORS_1, 259 257 .type = V4L2_CTRL_TYPE_BOOLEAN, 260 - .name = "Infrared", 258 + .name = "Illuminator / infrared", 261 259 .minimum = 0, 262 260 .maximum = 1, 263 261 .step = 1, 264 262 .default_value = 0, 265 263 }, 266 - .set_control = setinfrared 264 + .set_control = setillum 267 265 }, 268 266 /* ov7630/ov7648/ov7660 only */ 269 267 [FREQ] = { ··· 282 282 /* table of the disabled controls */ 283 283 static const __u32 ctrl_dis[] = { 284 284 [SENSOR_ADCM1700] = (1 << AUTOGAIN) | 285 - (1 << INFRARED) | 286 285 (1 << HFLIP) | 287 286 (1 << VFLIP) | 288 287 (1 << FREQ), 289 288 290 - [SENSOR_GC0307] = (1 << INFRARED) | 291 - (1 << HFLIP) | 289 + [SENSOR_GC0307] = (1 << HFLIP) | 292 290 (1 << VFLIP) | 293 291 (1 << FREQ), 294 292 295 - [SENSOR_HV7131R] = (1 << INFRARED) | 296 - (1 << HFLIP) | 293 + [SENSOR_HV7131R] = (1 << HFLIP) | 297 294 (1 << FREQ), 298 295 299 - [SENSOR_MI0360] = (1 << INFRARED) | 300 - (1 << HFLIP) | 296 + [SENSOR_MI0360] = (1 << HFLIP) | 301 297 (1 << VFLIP) | 302 298 (1 << FREQ), 303 299 304 - [SENSOR_MI0360B] = (1 << INFRARED) | 305 - (1 << HFLIP) | 300 + [SENSOR_MI0360B] = (1 << HFLIP) | 306 301 (1 << VFLIP) | 307 302 (1 << FREQ), 308 303 309 - [SENSOR_MO4000] = (1 << INFRARED) | 310 - (1 << HFLIP) | 304 + [SENSOR_MO4000] = (1 << HFLIP) | 311 305 (1 << VFLIP) | 312 306 (1 << FREQ), 313 307 ··· 309 315 (1 << VFLIP) | 310 316 (1 << FREQ), 311 317 312 - [SENSOR_OM6802] = (1 << INFRARED) | 313 - (1 << HFLIP) | 318 + [SENSOR_OM6802] = (1 << HFLIP) | 314 319 (1 << VFLIP) | 315 320 (1 << FREQ), 316 321 317 - [SENSOR_OV7630] = (1 << INFRARED) | 318 - (1 << HFLIP), 322 + [SENSOR_OV7630] = (1 << HFLIP), 319 323 320 - [SENSOR_OV7648] = (1 << INFRARED) | 321 - (1 << HFLIP), 324 + [SENSOR_OV7648] = (1 << HFLIP), 322 325 323 326 [SENSOR_OV7660] = (1 << AUTOGAIN) | 324 - (1 << INFRARED) | 325 327 (1 << HFLIP) | 326 328 (1 << VFLIP), 327 329 328 330 [SENSOR_PO1030] = (1 << AUTOGAIN) | 329 - (1 << INFRARED) | 330 331 (1 << HFLIP) | 331 332 (1 << VFLIP) | 332 333 (1 << FREQ), 333 334 334 335 [SENSOR_PO2030N] = (1 << AUTOGAIN) | 335 - (1 << INFRARED) | 336 336 (1 << FREQ), 337 337 338 338 [SENSOR_SOI768] = (1 << AUTOGAIN) | 339 - (1 << INFRARED) | 340 339 (1 << HFLIP) | 341 340 (1 << VFLIP) | 342 341 (1 << FREQ), 343 342 344 343 [SENSOR_SP80708] = (1 << AUTOGAIN) | 345 - (1 << INFRARED) | 346 344 (1 << HFLIP) | 347 345 (1 << VFLIP) | 348 346 (1 << FREQ), ··· 1808 1822 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); 1809 1823 switch (sd->bridge) { 1810 1824 case BRIDGE_SN9C102P: 1811 - if (regF1 != 0x11) 1812 - return -ENODEV; 1813 - reg_w1(gspca_dev, 0x02, regGpio[1]); 1814 - break; 1815 1825 case BRIDGE_SN9C105: 1816 1826 if (regF1 != 0x11) 1817 1827 return -ENODEV; 1818 - if (sd->sensor == SENSOR_MI0360) 1819 - mi0360_probe(gspca_dev); 1820 - reg_w(gspca_dev, 0x01, regGpio, 2); 1821 - break; 1822 - case BRIDGE_SN9C120: 1823 - if (regF1 != 0x12) 1824 - return -ENODEV; 1825 - switch (sd->sensor) { 1826 - case SENSOR_MI0360: 1827 - mi0360_probe(gspca_dev); 1828 - break; 1829 - case SENSOR_OV7630: 1830 - ov7630_probe(gspca_dev); 1831 - break; 1832 - case SENSOR_OV7648: 1833 - ov7648_probe(gspca_dev); 1834 - break; 1835 - case SENSOR_PO2030N: 1836 - po2030n_probe(gspca_dev); 1837 - break; 1838 - } 1839 - regGpio[1] = 0x70; /* no audio */ 1840 - reg_w(gspca_dev, 0x01, regGpio, 2); 1841 1828 break; 1842 1829 default: 1843 1830 /* case BRIDGE_SN9C110: */ 1844 - /* case BRIDGE_SN9C325: */ 1831 + /* case BRIDGE_SN9C120: */ 1845 1832 if (regF1 != 0x12) 1846 1833 return -ENODEV; 1834 + } 1835 + 1836 + switch (sd->sensor) { 1837 + case SENSOR_MI0360: 1838 + mi0360_probe(gspca_dev); 1839 + break; 1840 + case SENSOR_OV7630: 1841 + ov7630_probe(gspca_dev); 1842 + break; 1843 + case SENSOR_OV7648: 1844 + ov7648_probe(gspca_dev); 1845 + break; 1846 + case SENSOR_PO2030N: 1847 + po2030n_probe(gspca_dev); 1848 + break; 1849 + } 1850 + 1851 + switch (sd->bridge) { 1852 + case BRIDGE_SN9C102P: 1853 + reg_w1(gspca_dev, 0x02, regGpio[1]); 1854 + break; 1855 + case BRIDGE_SN9C105: 1856 + reg_w(gspca_dev, 0x01, regGpio, 2); 1857 + break; 1858 + case BRIDGE_SN9C110: 1847 1859 reg_w1(gspca_dev, 0x02, 0x62); 1860 + break; 1861 + case BRIDGE_SN9C120: 1862 + regGpio[1] = 0x70; /* no audio */ 1863 + reg_w(gspca_dev, 0x01, regGpio, 2); 1848 1864 break; 1849 1865 } 1850 1866 ··· 1862 1874 sd->i2c_addr = sn9c1xx[9]; 1863 1875 1864 1876 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; 1877 + if (!(sd->flags & F_ILLUM)) 1878 + gspca_dev->ctrl_dis |= (1 << ILLUM); 1865 1879 1866 1880 return gspca_dev->usb_err; 1867 1881 } ··· 2187 2197 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val); 2188 2198 } 2189 2199 2190 - static void setinfrared(struct gspca_dev *gspca_dev) 2200 + static void setillum(struct gspca_dev *gspca_dev) 2191 2201 { 2192 2202 struct sd *sd = (struct sd *) gspca_dev; 2193 2203 2194 - if (gspca_dev->ctrl_dis & (1 << INFRARED)) 2204 + if (gspca_dev->ctrl_dis & (1 << ILLUM)) 2195 2205 return; 2196 - /*fixme: different sequence for StarCam Clip and StarCam 370i */ 2197 - /* Clip */ 2198 - i2c_w1(gspca_dev, 0x02, /* gpio */ 2199 - sd->ctrls[INFRARED].val ? 0x66 : 0x64); 2206 + switch (sd->sensor) { 2207 + case SENSOR_ADCM1700: 2208 + reg_w1(gspca_dev, 0x02, /* gpio */ 2209 + sd->ctrls[ILLUM].val ? 0x64 : 0x60); 2210 + break; 2211 + case SENSOR_MT9V111: 2212 + if (starcam) 2213 + reg_w1(gspca_dev, 0x02, 2214 + sd->ctrls[ILLUM].val ? 2215 + 0x55 : 0x54); /* 370i */ 2216 + else 2217 + reg_w1(gspca_dev, 0x02, 2218 + sd->ctrls[ILLUM].val ? 2219 + 0x66 : 0x64); /* Clip */ 2220 + break; 2221 + } 2200 2222 } 2201 2223 2202 2224 static void setfreq(struct gspca_dev *gspca_dev) ··· 2346 2344 /* sensor clock already enabled in sd_init */ 2347 2345 /* reg_w1(gspca_dev, 0xf1, 0x00); */ 2348 2346 reg01 = sn9c1xx[1]; 2349 - if (sd->flags & PDN_INV) 2347 + if (sd->flags & F_PDN_INV) 2350 2348 reg01 ^= S_PDN_INV; /* power down inverted */ 2351 2349 reg_w1(gspca_dev, 0x01, reg01); 2352 2350 ··· 2909 2907 .driver_info = (BRIDGE_ ## bridge << 16) \ 2910 2908 | (SENSOR_ ## sensor << 8) \ 2911 2909 | (flags) 2912 - static const __devinitdata struct usb_device_id device_table[] = { 2913 - #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2910 + static const struct usb_device_id device_table[] = { 2914 2911 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, 2915 2912 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, 2916 - #endif 2917 - {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)}, 2918 - {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)}, 2913 + {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)}, 2914 + {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)}, 2919 2915 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, 2920 2916 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, 2921 2917 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, ··· 2925 2925 /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ 2926 2926 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, 2927 2927 /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ 2928 - {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, 2928 + {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)}, 2929 2929 /* or MT9V111 */ 2930 2930 /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ 2931 2931 /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ ··· 2936 2936 /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ 2937 2937 /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ 2938 2938 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, 2939 - #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2940 2939 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, 2941 2940 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, 2942 - #endif 2943 2941 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ 2944 2942 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/ 2945 2943 /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ ··· 2960 2962 /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ 2961 2963 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, 2962 2964 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, 2963 - #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2964 2965 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, 2965 - #endif 2966 2966 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, 2967 2967 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, 2968 2968 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ 2969 2969 /* or GC0305 / GC0307 */ 2970 2970 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ 2971 2971 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ 2972 - {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/ 2972 + {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)}, 2973 + /* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/ 2973 2974 {} 2974 2975 }; 2975 2976 MODULE_DEVICE_TABLE(usb, device_table); ··· 3004 3007 3005 3008 module_init(sd_mod_init); 3006 3009 module_exit(sd_mod_exit); 3010 + 3011 + module_param(starcam, int, 0644); 3012 + MODULE_PARM_DESC(starcam, 3013 + "StarCam model. 0: Clip, 1: 370i");
+1 -1
drivers/media/video/gspca/spca1528.c
··· 555 555 }; 556 556 557 557 /* -- module initialisation -- */ 558 - static const __devinitdata struct usb_device_id device_table[] = { 558 + static const struct usb_device_id device_table[] = { 559 559 {USB_DEVICE(0x04fc, 0x1528)}, 560 560 {} 561 561 };
+1 -1
drivers/media/video/gspca/spca500.c
··· 1051 1051 }; 1052 1052 1053 1053 /* -- module initialisation -- */ 1054 - static const __devinitdata struct usb_device_id device_table[] = { 1054 + static const struct usb_device_id device_table[] = { 1055 1055 {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200}, 1056 1056 {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300}, 1057 1057 {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler},
+1 -1
drivers/media/video/gspca/spca501.c
··· 2155 2155 }; 2156 2156 2157 2157 /* -- module initialisation -- */ 2158 - static const __devinitdata struct usb_device_id device_table[] = { 2158 + static const struct usb_device_id device_table[] = { 2159 2159 {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325}, 2160 2160 {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera}, 2161 2161 {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite},
+1 -1
drivers/media/video/gspca/spca505.c
··· 786 786 }; 787 787 788 788 /* -- module initialisation -- */ 789 - static const __devinitdata struct usb_device_id device_table[] = { 789 + static const struct usb_device_id device_table[] = { 790 790 {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, 791 791 {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, 792 792 /*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */
+1 -1
drivers/media/video/gspca/spca508.c
··· 1509 1509 }; 1510 1510 1511 1511 /* -- module initialisation -- */ 1512 - static const __devinitdata struct usb_device_id device_table[] = { 1512 + static const struct usb_device_id device_table[] = { 1513 1513 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam}, 1514 1514 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista}, 1515 1515 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
+1 -1
drivers/media/video/gspca/spca561.c
··· 1061 1061 }; 1062 1062 1063 1063 /* -- module initialisation -- */ 1064 - static const __devinitdata struct usb_device_id device_table[] = { 1064 + static const struct usb_device_id device_table[] = { 1065 1065 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, 1066 1066 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, 1067 1067 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A},
+1 -1
drivers/media/video/gspca/sq905.c
··· 396 396 } 397 397 398 398 /* Table of supported USB devices */ 399 - static const __devinitdata struct usb_device_id device_table[] = { 399 + static const struct usb_device_id device_table[] = { 400 400 {USB_DEVICE(0x2770, 0x9120)}, 401 401 {} 402 402 };
+1 -1
drivers/media/video/gspca/sq905c.c
··· 298 298 } 299 299 300 300 /* Table of supported USB devices */ 301 - static const __devinitdata struct usb_device_id device_table[] = { 301 + static const struct usb_device_id device_table[] = { 302 302 {USB_DEVICE(0x2770, 0x905c)}, 303 303 {USB_DEVICE(0x2770, 0x9050)}, 304 304 {USB_DEVICE(0x2770, 0x9051)},
+1 -1
drivers/media/video/gspca/sq930x.c
··· 1163 1163 #define ST(sensor, type) \ 1164 1164 .driver_info = (SENSOR_ ## sensor << 8) \ 1165 1165 | (type) 1166 - static const __devinitdata struct usb_device_id device_table[] = { 1166 + static const struct usb_device_id device_table[] = { 1167 1167 {USB_DEVICE(0x041e, 0x4038), ST(MI0360, 0)}, 1168 1168 {USB_DEVICE(0x041e, 0x403c), ST(LZ24BP, 0)}, 1169 1169 {USB_DEVICE(0x041e, 0x403d), ST(LZ24BP, 0)},
+1 -1
drivers/media/video/gspca/stk014.c
··· 495 495 }; 496 496 497 497 /* -- module initialisation -- */ 498 - static const __devinitdata struct usb_device_id device_table[] = { 498 + static const struct usb_device_id device_table[] = { 499 499 {USB_DEVICE(0x05e1, 0x0893)}, 500 500 {} 501 501 };
+1 -1
drivers/media/video/gspca/stv0680.c
··· 327 327 }; 328 328 329 329 /* -- module initialisation -- */ 330 - static const __devinitdata struct usb_device_id device_table[] = { 330 + static const struct usb_device_id device_table[] = { 331 331 {USB_DEVICE(0x0553, 0x0202)}, 332 332 {USB_DEVICE(0x041e, 0x4007)}, 333 333 {}
+1 -1
drivers/media/video/gspca/stv06xx/stv06xx.c
··· 564 564 565 565 566 566 /* -- module initialisation -- */ 567 - static const __devinitdata struct usb_device_id device_table[] = { 567 + static const struct usb_device_id device_table[] = { 568 568 /* QuickCam Express */ 569 569 {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, 570 570 /* LEGO cam / QuickCam Web */
+1 -1
drivers/media/video/gspca/sunplus.c
··· 1162 1162 #define BS(bridge, subtype) \ 1163 1163 .driver_info = (BRIDGE_ ## bridge << 8) \ 1164 1164 | (subtype) 1165 - static const __devinitdata struct usb_device_id device_table[] = { 1165 + static const struct usb_device_id device_table[] = { 1166 1166 {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)}, 1167 1167 {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)}, 1168 1168 {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
+1 -1
drivers/media/video/gspca/t613.c
··· 1416 1416 }; 1417 1417 1418 1418 /* -- module initialisation -- */ 1419 - static const __devinitdata struct usb_device_id device_table[] = { 1419 + static const struct usb_device_id device_table[] = { 1420 1420 {USB_DEVICE(0x17a1, 0x0128)}, 1421 1421 {} 1422 1422 };
+1 -1
drivers/media/video/gspca/tv8532.c
··· 388 388 }; 389 389 390 390 /* -- module initialisation -- */ 391 - static const __devinitdata struct usb_device_id device_table[] = { 391 + static const struct usb_device_id device_table[] = { 392 392 {USB_DEVICE(0x046d, 0x0920)}, 393 393 {USB_DEVICE(0x046d, 0x0921)}, 394 394 {USB_DEVICE(0x0545, 0x808b)},
+1 -1
drivers/media/video/gspca/vc032x.c
··· 4192 4192 #define BF(bridge, flags) \ 4193 4193 .driver_info = (BRIDGE_ ## bridge << 8) \ 4194 4194 | (flags) 4195 - static const __devinitdata struct usb_device_id device_table[] = { 4195 + static const struct usb_device_id device_table[] = { 4196 4196 {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)}, 4197 4197 {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)}, 4198 4198 {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)},
+1 -1
drivers/media/video/gspca/zc3xx.c
··· 6909 6909 #endif 6910 6910 }; 6911 6911 6912 - static const __devinitdata struct usb_device_id device_table[] = { 6912 + static const struct usb_device_id device_table[] = { 6913 6913 {USB_DEVICE(0x041e, 0x041e)}, 6914 6914 {USB_DEVICE(0x041e, 0x4017)}, 6915 6915 {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106},
+1 -3
drivers/media/video/hdpvr/Makefile
··· 1 - hdpvr-objs := hdpvr-control.o hdpvr-core.o hdpvr-video.o 2 - 3 - hdpvr-$(CONFIG_I2C) += hdpvr-i2c.o 1 + hdpvr-objs := hdpvr-control.o hdpvr-core.o hdpvr-video.o hdpvr-i2c.o 4 2 5 3 obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o 6 4
+4 -6
drivers/media/video/hdpvr/hdpvr-core.c
··· 378 378 goto error; 379 379 } 380 380 381 - #ifdef CONFIG_I2C 382 - /* until i2c is working properly */ 383 - retval = 0; /* hdpvr_register_i2c_adapter(dev); */ 381 + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 382 + retval = hdpvr_register_i2c_adapter(dev); 384 383 if (retval < 0) { 385 384 v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n"); 386 385 goto error; 387 386 } 388 387 389 - /* until i2c is working properly */ 390 - retval = 0; /* hdpvr_register_i2c_ir(dev); */ 388 + retval = hdpvr_register_i2c_ir(dev); 391 389 if (retval < 0) 392 390 v4l2_err(&dev->v4l2_dev, "registering i2c IR devices failed\n"); 393 - #endif /* CONFIG_I2C */ 391 + #endif 394 392 395 393 /* let the user know what node this device is now attached to */ 396 394 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
+70 -79
drivers/media/video/hdpvr/hdpvr-i2c.c
··· 13 13 * 14 14 */ 15 15 16 + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 17 + 16 18 #include <linux/i2c.h> 17 19 #include <linux/slab.h> 18 20 ··· 30 28 #define Z8F0811_IR_TX_I2C_ADDR 0x70 31 29 #define Z8F0811_IR_RX_I2C_ADDR 0x71 32 30 33 - static const u8 ir_i2c_addrs[] = { 34 - Z8F0811_IR_TX_I2C_ADDR, 35 - Z8F0811_IR_RX_I2C_ADDR, 31 + 32 + static struct i2c_board_info hdpvr_i2c_board_info = { 33 + I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR), 34 + I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR), 36 35 }; 37 - 38 - static const char * const ir_devicenames[] = { 39 - "ir_tx_z8f0811_hdpvr", 40 - "ir_rx_z8f0811_hdpvr", 41 - }; 42 - 43 - static int hdpvr_new_i2c_ir(struct hdpvr_device *dev, struct i2c_adapter *adap, 44 - const char *type, u8 addr) 45 - { 46 - struct i2c_board_info info; 47 - struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; 48 - unsigned short addr_list[2] = { addr, I2C_CLIENT_END }; 49 - 50 - memset(&info, 0, sizeof(struct i2c_board_info)); 51 - strlcpy(info.type, type, I2C_NAME_SIZE); 52 - 53 - /* Our default information for ir-kbd-i2c.c to use */ 54 - switch (addr) { 55 - case Z8F0811_IR_RX_I2C_ADDR: 56 - init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 57 - init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 58 - init_data->type = RC_TYPE_RC5; 59 - init_data->name = "HD PVR"; 60 - info.platform_data = init_data; 61 - break; 62 - } 63 - 64 - return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ? 65 - -1 : 0; 66 - } 67 36 68 37 int hdpvr_register_i2c_ir(struct hdpvr_device *dev) 69 38 { 70 - int i; 71 - int ret = 0; 39 + struct i2c_client *c; 40 + struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; 72 41 73 - for (i = 0; i < ARRAY_SIZE(ir_i2c_addrs); i++) 74 - ret += hdpvr_new_i2c_ir(dev, dev->i2c_adapter, 75 - ir_devicenames[i], ir_i2c_addrs[i]); 42 + /* Our default information for ir-kbd-i2c.c to use */ 43 + init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 44 + init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 45 + init_data->type = RC_TYPE_RC5; 46 + init_data->name = "HD PVR"; 47 + hdpvr_i2c_board_info.platform_data = init_data; 76 48 77 - return ret; 49 + c = i2c_new_device(&dev->i2c_adapter, &hdpvr_i2c_board_info); 50 + 51 + return (c == NULL) ? -ENODEV : 0; 78 52 } 79 53 80 - static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr, 81 - char *data, int len) 54 + static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus, 55 + unsigned char addr, char *data, int len) 82 56 { 83 57 int ret; 84 - char *buf = kmalloc(len, GFP_KERNEL); 85 - if (!buf) 86 - return -ENOMEM; 58 + 59 + if (len > sizeof(dev->i2c_buf)) 60 + return -EINVAL; 87 61 88 62 ret = usb_control_msg(dev->udev, 89 63 usb_rcvctrlpipe(dev->udev, 0), 90 64 REQTYPE_I2C_READ, CTRL_READ_REQUEST, 91 - 0x100|addr, 0, buf, len, 1000); 65 + (bus << 8) | addr, 0, &dev->i2c_buf, len, 1000); 92 66 93 67 if (ret == len) { 94 - memcpy(data, buf, len); 68 + memcpy(data, &dev->i2c_buf, len); 95 69 ret = 0; 96 70 } else if (ret >= 0) 97 71 ret = -EIO; 98 72 99 - kfree(buf); 100 - 101 73 return ret; 102 74 } 103 75 104 - static int hdpvr_i2c_write(struct hdpvr_device *dev, unsigned char addr, 105 - char *data, int len) 76 + static int hdpvr_i2c_write(struct hdpvr_device *dev, int bus, 77 + unsigned char addr, char *data, int len) 106 78 { 107 79 int ret; 108 - char *buf = kmalloc(len, GFP_KERNEL); 109 - if (!buf) 110 - return -ENOMEM; 111 80 112 - memcpy(buf, data, len); 81 + if (len > sizeof(dev->i2c_buf)) 82 + return -EINVAL; 83 + 84 + memcpy(&dev->i2c_buf, data, len); 113 85 ret = usb_control_msg(dev->udev, 114 86 usb_sndctrlpipe(dev->udev, 0), 115 87 REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST, 116 - 0x100|addr, 0, buf, len, 1000); 88 + (bus << 8) | addr, 0, &dev->i2c_buf, len, 1000); 117 89 118 90 if (ret < 0) 119 - goto error; 91 + return ret; 120 92 121 93 ret = usb_control_msg(dev->udev, 122 94 usb_rcvctrlpipe(dev->udev, 0), 123 95 REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST, 124 - 0, 0, buf, 2, 1000); 96 + 0, 0, &dev->i2c_buf, 2, 1000); 125 97 126 - if (ret == 2) 98 + if ((ret == 2) && (dev->i2c_buf[1] == (len - 1))) 127 99 ret = 0; 128 100 else if (ret >= 0) 129 101 ret = -EIO; 130 102 131 - error: 132 - kfree(buf); 133 103 return ret; 134 104 } 135 105 ··· 120 146 addr = msgs[i].addr << 1; 121 147 122 148 if (msgs[i].flags & I2C_M_RD) 123 - retval = hdpvr_i2c_read(dev, addr, msgs[i].buf, 149 + retval = hdpvr_i2c_read(dev, 1, addr, msgs[i].buf, 124 150 msgs[i].len); 125 151 else 126 - retval = hdpvr_i2c_write(dev, addr, msgs[i].buf, 152 + retval = hdpvr_i2c_write(dev, 1, addr, msgs[i].buf, 127 153 msgs[i].len); 128 154 } 129 155 ··· 142 168 .functionality = hdpvr_functionality, 143 169 }; 144 170 171 + static struct i2c_adapter hdpvr_i2c_adapter_template = { 172 + .name = "Hauppage HD PVR I2C", 173 + .owner = THIS_MODULE, 174 + .algo = &hdpvr_algo, 175 + }; 176 + 177 + static int hdpvr_activate_ir(struct hdpvr_device *dev) 178 + { 179 + char buffer[8]; 180 + 181 + mutex_lock(&dev->i2c_mutex); 182 + 183 + hdpvr_i2c_read(dev, 0, 0x54, buffer, 1); 184 + 185 + buffer[0] = 0; 186 + buffer[1] = 0x8; 187 + hdpvr_i2c_write(dev, 1, 0x54, buffer, 2); 188 + 189 + buffer[1] = 0x18; 190 + hdpvr_i2c_write(dev, 1, 0x54, buffer, 2); 191 + 192 + mutex_unlock(&dev->i2c_mutex); 193 + 194 + return 0; 195 + } 196 + 145 197 int hdpvr_register_i2c_adapter(struct hdpvr_device *dev) 146 198 { 147 - struct i2c_adapter *i2c_adap; 148 199 int retval = -ENOMEM; 149 200 150 - i2c_adap = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); 151 - if (i2c_adap == NULL) 152 - goto error; 201 + hdpvr_activate_ir(dev); 153 202 154 - strlcpy(i2c_adap->name, "Hauppauge HD PVR I2C", 155 - sizeof(i2c_adap->name)); 156 - i2c_adap->algo = &hdpvr_algo; 157 - i2c_adap->owner = THIS_MODULE; 158 - i2c_adap->dev.parent = &dev->udev->dev; 203 + memcpy(&dev->i2c_adapter, &hdpvr_i2c_adapter_template, 204 + sizeof(struct i2c_adapter)); 205 + dev->i2c_adapter.dev.parent = &dev->udev->dev; 159 206 160 - i2c_set_adapdata(i2c_adap, dev); 207 + i2c_set_adapdata(&dev->i2c_adapter, dev); 161 208 162 - retval = i2c_add_adapter(i2c_adap); 209 + retval = i2c_add_adapter(&dev->i2c_adapter); 163 210 164 - if (!retval) 165 - dev->i2c_adapter = i2c_adap; 166 - else 167 - kfree(i2c_adap); 168 - 169 - error: 170 211 return retval; 171 212 } 213 + 214 + #endif
+2 -5
drivers/media/video/hdpvr/hdpvr-video.c
··· 1220 1220 v4l2_device_unregister(&dev->v4l2_dev); 1221 1221 1222 1222 /* deregister I2C adapter */ 1223 - #ifdef CONFIG_I2C 1223 + #if defined(CONFIG_I2C) || (CONFIG_I2C_MODULE) 1224 1224 mutex_lock(&dev->i2c_mutex); 1225 - if (dev->i2c_adapter) 1226 - i2c_del_adapter(dev->i2c_adapter); 1227 - kfree(dev->i2c_adapter); 1228 - dev->i2c_adapter = NULL; 1225 + i2c_del_adapter(&dev->i2c_adapter); 1229 1226 mutex_unlock(&dev->i2c_mutex); 1230 1227 #endif /* CONFIG_I2C */ 1231 1228
+4 -1
drivers/media/video/hdpvr/hdpvr.h
··· 25 25 KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE) 26 26 27 27 #define HDPVR_MAX 8 28 + #define HDPVR_I2C_MAX_SIZE 128 28 29 29 30 /* Define these values to match your devices */ 30 31 #define HD_PVR_VENDOR_ID 0x2040 ··· 107 106 struct work_struct worker; 108 107 109 108 /* I2C adapter */ 110 - struct i2c_adapter *i2c_adapter; 109 + struct i2c_adapter i2c_adapter; 111 110 /* I2C lock */ 112 111 struct mutex i2c_mutex; 112 + /* I2C message buffer space */ 113 + char i2c_buf[HDPVR_I2C_MAX_SIZE]; 113 114 114 115 /* For passing data to ir-kbd-i2c */ 115 116 struct IR_i2c_init_data ir_i2c_init_data;
+10 -2
drivers/media/video/ir-kbd-i2c.c
··· 244 244 static u32 ir_key, ir_raw; 245 245 int rc; 246 246 247 - dprintk(2,"ir_poll_key\n"); 247 + dprintk(3, "%s\n", __func__); 248 248 rc = ir->get_key(ir, &ir_key, &ir_raw); 249 249 if (rc < 0) { 250 250 dprintk(2,"error\n"); 251 251 return; 252 252 } 253 253 254 - if (rc) 254 + if (rc) { 255 + dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key); 255 256 rc_keydown(ir->rc, ir_key, 0); 257 + } 256 258 } 257 259 258 260 static void ir_work(struct work_struct *work) ··· 322 320 ir->get_key = get_key_avermedia_cardbus; 323 321 rc_type = RC_TYPE_OTHER; 324 322 ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 323 + break; 324 + case 0x71: 325 + name = "Hauppauge/Zilog Z8"; 326 + ir->get_key = get_key_haup_xvr; 327 + rc_type = RC_TYPE_RC5; 328 + ir_codes = hauppauge ? RC_MAP_HAUPPAUGE_NEW : RC_MAP_RC5_TV; 325 329 break; 326 330 } 327 331
+7 -2
drivers/media/video/ivtv/ivtv-i2c.c
··· 300 300 adap, type, 0, I2C_ADDRS(hw_addrs[idx])); 301 301 } else if (hw == IVTV_HW_CX25840) { 302 302 struct cx25840_platform_data pdata; 303 + struct i2c_board_info cx25840_info = { 304 + .type = "cx25840", 305 + .addr = hw_addrs[idx], 306 + .platform_data = &pdata, 307 + }; 303 308 304 309 pdata.pvr150_workaround = itv->pvr150_workaround; 305 - sd = v4l2_i2c_new_subdev_cfg(&itv->v4l2_dev, 306 - adap, type, 0, &pdata, hw_addrs[idx], NULL); 310 + sd = v4l2_i2c_new_subdev_board(&itv->v4l2_dev, adap, 311 + &cx25840_info, NULL); 307 312 } else { 308 313 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 309 314 adap, type, hw_addrs[idx], NULL);
+34 -20
drivers/media/video/mt9v011.c
··· 12 12 #include <asm/div64.h> 13 13 #include <media/v4l2-device.h> 14 14 #include <media/v4l2-chip-ident.h> 15 - #include "mt9v011.h" 15 + #include <media/mt9v011.h> 16 16 17 17 MODULE_DESCRIPTION("Micron mt9v011 sensor driver"); 18 18 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 19 19 MODULE_LICENSE("GPL"); 20 20 21 - 22 21 static int debug; 23 22 module_param(debug, int, 0); 24 23 MODULE_PARM_DESC(debug, "Debug level (0-2)"); 24 + 25 + #define R00_MT9V011_CHIP_VERSION 0x00 26 + #define R01_MT9V011_ROWSTART 0x01 27 + #define R02_MT9V011_COLSTART 0x02 28 + #define R03_MT9V011_HEIGHT 0x03 29 + #define R04_MT9V011_WIDTH 0x04 30 + #define R05_MT9V011_HBLANK 0x05 31 + #define R06_MT9V011_VBLANK 0x06 32 + #define R07_MT9V011_OUT_CTRL 0x07 33 + #define R09_MT9V011_SHUTTER_WIDTH 0x09 34 + #define R0A_MT9V011_CLK_SPEED 0x0a 35 + #define R0B_MT9V011_RESTART 0x0b 36 + #define R0C_MT9V011_SHUTTER_DELAY 0x0c 37 + #define R0D_MT9V011_RESET 0x0d 38 + #define R1E_MT9V011_DIGITAL_ZOOM 0x1e 39 + #define R20_MT9V011_READ_MODE 0x20 40 + #define R2B_MT9V011_GREEN_1_GAIN 0x2b 41 + #define R2C_MT9V011_BLUE_GAIN 0x2c 42 + #define R2D_MT9V011_RED_GAIN 0x2d 43 + #define R2E_MT9V011_GREEN_2_GAIN 0x2e 44 + #define R35_MT9V011_GLOBAL_GAIN 0x35 45 + #define RF1_MT9V011_CHIP_ENABLE 0xf1 46 + 47 + #define MT9V011_VERSION 0x8232 48 + #define MT9V011_REV_B_VERSION 0x8243 25 49 26 50 /* supported controls */ 27 51 static struct v4l2_queryctrl mt9v011_qctrl[] = { ··· 493 469 return 0; 494 470 } 495 471 496 - static int mt9v011_s_config(struct v4l2_subdev *sd, int dumb, void *data) 497 - { 498 - struct mt9v011 *core = to_mt9v011(sd); 499 - unsigned *xtal = data; 500 - 501 - v4l2_dbg(1, debug, sd, "s_config called\n"); 502 - 503 - if (xtal) { 504 - core->xtal = *xtal; 505 - v4l2_dbg(1, debug, sd, "xtal set to %d.%03d MHz\n", 506 - *xtal / 1000000, (*xtal / 1000) % 1000); 507 - } 508 - 509 - return 0; 510 - } 511 - 512 - 513 472 #ifdef CONFIG_VIDEO_ADV_DEBUG 514 473 static int mt9v011_g_register(struct v4l2_subdev *sd, 515 474 struct v4l2_dbg_register *reg) ··· 543 536 .g_ctrl = mt9v011_g_ctrl, 544 537 .s_ctrl = mt9v011_s_ctrl, 545 538 .reset = mt9v011_reset, 546 - .s_config = mt9v011_s_config, 547 539 .g_chip_ident = mt9v011_g_chip_ident, 548 540 #ifdef CONFIG_VIDEO_ADV_DEBUG 549 541 .g_register = mt9v011_g_register, ··· 601 595 core->width = 640; 602 596 core->height = 480; 603 597 core->xtal = 27000000; /* Hz */ 598 + 599 + if (c->dev.platform_data) { 600 + struct mt9v011_platform_data *pdata = c->dev.platform_data; 601 + 602 + core->xtal = pdata->xtal; 603 + v4l2_dbg(1, debug, sd, "xtal set to %d.%03d MHz\n", 604 + core->xtal / 1000000, (core->xtal / 1000) % 1000); 605 + } 604 606 605 607 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", 606 608 c->addr << 1, c->adapter->name, version);
-36
drivers/media/video/mt9v011.h
··· 1 - /* 2 - * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor 3 - * 4 - * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com) 5 - * This code is placed under the terms of the GNU General Public License v2 6 - */ 7 - 8 - #ifndef MT9V011_H_ 9 - #define MT9V011_H_ 10 - 11 - #define R00_MT9V011_CHIP_VERSION 0x00 12 - #define R01_MT9V011_ROWSTART 0x01 13 - #define R02_MT9V011_COLSTART 0x02 14 - #define R03_MT9V011_HEIGHT 0x03 15 - #define R04_MT9V011_WIDTH 0x04 16 - #define R05_MT9V011_HBLANK 0x05 17 - #define R06_MT9V011_VBLANK 0x06 18 - #define R07_MT9V011_OUT_CTRL 0x07 19 - #define R09_MT9V011_SHUTTER_WIDTH 0x09 20 - #define R0A_MT9V011_CLK_SPEED 0x0a 21 - #define R0B_MT9V011_RESTART 0x0b 22 - #define R0C_MT9V011_SHUTTER_DELAY 0x0c 23 - #define R0D_MT9V011_RESET 0x0d 24 - #define R1E_MT9V011_DIGITAL_ZOOM 0x1e 25 - #define R20_MT9V011_READ_MODE 0x20 26 - #define R2B_MT9V011_GREEN_1_GAIN 0x2b 27 - #define R2C_MT9V011_BLUE_GAIN 0x2c 28 - #define R2D_MT9V011_RED_GAIN 0x2d 29 - #define R2E_MT9V011_GREEN_2_GAIN 0x2e 30 - #define R35_MT9V011_GLOBAL_GAIN 0x35 31 - #define RF1_MT9V011_CHIP_ENABLE 0xf1 32 - 33 - #define MT9V011_VERSION 0x8232 34 - #define MT9V011_REV_B_VERSION 0x8243 35 - 36 - #endif
+32 -42
drivers/media/video/ov7670.c
··· 1449 1449 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0); 1450 1450 } 1451 1451 1452 - static int ov7670_s_config(struct v4l2_subdev *sd, int dumb, void *data) 1453 - { 1454 - struct i2c_client *client = v4l2_get_subdevdata(sd); 1455 - struct ov7670_config *config = data; 1456 - struct ov7670_info *info = to_state(sd); 1457 - int ret; 1458 - 1459 - info->clock_speed = 30; /* default: a guess */ 1460 - 1461 - /* 1462 - * Must apply configuration before initializing device, because it 1463 - * selects I/O method. 1464 - */ 1465 - if (config) { 1466 - info->min_width = config->min_width; 1467 - info->min_height = config->min_height; 1468 - info->use_smbus = config->use_smbus; 1469 - 1470 - if (config->clock_speed) 1471 - info->clock_speed = config->clock_speed; 1472 - } 1473 - 1474 - /* Make sure it's an ov7670 */ 1475 - ret = ov7670_detect(sd); 1476 - if (ret) { 1477 - v4l_dbg(1, debug, client, 1478 - "chip found @ 0x%x (%s) is not an ov7670 chip.\n", 1479 - client->addr << 1, client->adapter->name); 1480 - kfree(info); 1481 - return ret; 1482 - } 1483 - v4l_info(client, "chip found @ 0x%02x (%s)\n", 1484 - client->addr << 1, client->adapter->name); 1485 - 1486 - info->fmt = &ov7670_formats[0]; 1487 - info->sat = 128; /* Review this */ 1488 - info->clkrc = info->clock_speed / 30; 1489 - 1490 - return 0; 1491 - } 1492 - 1493 1452 #ifdef CONFIG_VIDEO_ADV_DEBUG 1494 1453 static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) 1495 1454 { ··· 1487 1528 .s_ctrl = ov7670_s_ctrl, 1488 1529 .queryctrl = ov7670_queryctrl, 1489 1530 .reset = ov7670_reset, 1490 - .s_config = ov7670_s_config, 1491 1531 .init = ov7670_init, 1492 1532 #ifdef CONFIG_VIDEO_ADV_DEBUG 1493 1533 .g_register = ov7670_g_register, ··· 1516 1558 { 1517 1559 struct v4l2_subdev *sd; 1518 1560 struct ov7670_info *info; 1561 + int ret; 1519 1562 1520 1563 info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); 1521 1564 if (info == NULL) ··· 1524 1565 sd = &info->sd; 1525 1566 v4l2_i2c_subdev_init(sd, client, &ov7670_ops); 1526 1567 1568 + info->clock_speed = 30; /* default: a guess */ 1569 + if (client->dev.platform_data) { 1570 + struct ov7670_config *config = client->dev.platform_data; 1571 + 1572 + /* 1573 + * Must apply configuration before initializing device, because it 1574 + * selects I/O method. 1575 + */ 1576 + info->min_width = config->min_width; 1577 + info->min_height = config->min_height; 1578 + info->use_smbus = config->use_smbus; 1579 + 1580 + if (config->clock_speed) 1581 + info->clock_speed = config->clock_speed; 1582 + } 1583 + 1584 + /* Make sure it's an ov7670 */ 1585 + ret = ov7670_detect(sd); 1586 + if (ret) { 1587 + v4l_dbg(1, debug, client, 1588 + "chip found @ 0x%x (%s) is not an ov7670 chip.\n", 1589 + client->addr << 1, client->adapter->name); 1590 + kfree(info); 1591 + return ret; 1592 + } 1593 + v4l_info(client, "chip found @ 0x%02x (%s)\n", 1594 + client->addr << 1, client->adapter->name); 1595 + 1596 + info->fmt = &ov7670_formats[0]; 1597 + info->sat = 128; /* Review this */ 1598 + info->clkrc = info->clock_speed / 30; 1527 1599 return 0; 1528 1600 } 1529 1601
+2
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
··· 40 40 #include "pvrusb2-io.h" 41 41 #include <media/v4l2-device.h> 42 42 #include <media/cx2341x.h> 43 + #include <media/ir-kbd-i2c.h> 43 44 #include "pvrusb2-devattr.h" 44 45 45 46 /* Legal values for PVR2_CID_HSM */ ··· 203 202 204 203 /* IR related */ 205 204 unsigned int ir_scheme_active; /* IR scheme as seen from the outside */ 205 + struct IR_i2c_init_data ir_init_data; /* params passed to IR modules */ 206 206 207 207 /* Frequency table */ 208 208 unsigned int freqTable[FREQTABLE_SIZE];
+43 -19
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
··· 19 19 */ 20 20 21 21 #include <linux/i2c.h> 22 + #include <media/ir-kbd-i2c.h> 22 23 #include "pvrusb2-i2c-core.h" 23 24 #include "pvrusb2-hdw-internal.h" 24 25 #include "pvrusb2-debug.h" ··· 48 47 int, S_IRUGO|S_IWUSR); 49 48 MODULE_PARM_DESC(disable_autoload_ir_video, 50 49 "1=do not try to autoload ir_video IR receiver"); 51 - 52 - /* Mapping of IR schemes to known I2C addresses - if any */ 53 - static const unsigned char ir_video_addresses[] = { 54 - [PVR2_IR_SCHEME_ZILOG] = 0x71, 55 - [PVR2_IR_SCHEME_29XXX] = 0x18, 56 - [PVR2_IR_SCHEME_24XXX] = 0x18, 57 - }; 58 50 59 51 static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */ 60 52 u8 i2c_addr, /* I2C address we're talking to */ ··· 568 574 static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) 569 575 { 570 576 struct i2c_board_info info; 571 - unsigned char addr = 0; 577 + struct IR_i2c_init_data *init_data = &hdw->ir_init_data; 572 578 if (pvr2_disable_ir_video) { 573 579 pvr2_trace(PVR2_TRACE_INFO, 574 580 "Automatic binding of ir_video has been disabled."); 575 581 return; 576 582 } 577 - if (hdw->ir_scheme_active < ARRAY_SIZE(ir_video_addresses)) { 578 - addr = ir_video_addresses[hdw->ir_scheme_active]; 579 - } 580 - if (!addr) { 583 + memset(&info, 0, sizeof(struct i2c_board_info)); 584 + switch (hdw->ir_scheme_active) { 585 + case PVR2_IR_SCHEME_24XXX: /* FX2-controlled IR */ 586 + case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */ 587 + init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 588 + init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; 589 + init_data->type = RC_TYPE_RC5; 590 + init_data->name = hdw->hdw_desc->description; 591 + init_data->polling_interval = 100; /* ms From ir-kbd-i2c */ 592 + /* IR Receiver */ 593 + info.addr = 0x18; 594 + info.platform_data = init_data; 595 + strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 596 + pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.", 597 + info.type, info.addr); 598 + i2c_new_device(&hdw->i2c_adap, &info); 599 + break; 600 + case PVR2_IR_SCHEME_ZILOG: /* HVR-1950 style */ 601 + case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */ 602 + init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 603 + init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 604 + init_data->type = RC_TYPE_RC5; 605 + init_data->name = hdw->hdw_desc->description; 606 + init_data->polling_interval = 260; /* ms From lirc_zilog */ 607 + /* IR Receiver */ 608 + info.addr = 0x71; 609 + info.platform_data = init_data; 610 + strlcpy(info.type, "ir_rx_z8f0811_haup", I2C_NAME_SIZE); 611 + pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.", 612 + info.type, info.addr); 613 + i2c_new_device(&hdw->i2c_adap, &info); 614 + /* IR Trasmitter */ 615 + info.addr = 0x70; 616 + info.platform_data = init_data; 617 + strlcpy(info.type, "ir_tx_z8f0811_haup", I2C_NAME_SIZE); 618 + pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.", 619 + info.type, info.addr); 620 + i2c_new_device(&hdw->i2c_adap, &info); 621 + break; 622 + default: 581 623 /* The device either doesn't support I2C-based IR or we 582 624 don't know (yet) how to operate IR on the device. */ 583 - return; 625 + break; 584 626 } 585 - pvr2_trace(PVR2_TRACE_INFO, 586 - "Binding ir_video to i2c address 0x%02x.", addr); 587 - memset(&info, 0, sizeof(struct i2c_board_info)); 588 - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 589 - info.addr = addr; 590 - i2c_new_device(&hdw->i2c_adap, &info); 591 627 } 592 628 593 629 void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
+12 -39
drivers/media/video/saa7134/saa7134-cards.c
··· 5179 5179 [SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG] = { 5180 5180 .name = "Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid", 5181 5181 .audio_clock = 0x00187de7, 5182 - #if 0 5183 - /* 5184 - * FIXME: Analog mode doesn't work, if digital is enabled. The proper 5185 - * fix is to use tda8290 driver, but Kworld seems to use an 5186 - * unsupported version of tda8295. 5187 - */ 5188 - .tuner_type = TUNER_NXP_TDA18271, /* TUNER_PHILIPS_TDA8290 */ 5189 - .tuner_addr = 0x60, 5190 - #else 5191 - .tuner_type = UNSET, 5182 + .tuner_type = TUNER_PHILIPS_TDA8290, 5192 5183 .tuner_addr = ADDR_UNSET, 5193 - #endif 5194 5184 .radio_type = UNSET, 5195 5185 .radio_addr = ADDR_UNSET, 5196 5186 .gpiomask = 0x8e054000, ··· 6922 6932 /* toggle AGC switch through GPIO 27 */ 6923 6933 switch (mode) { 6924 6934 case TDA18271_ANALOG: 6925 - saa7134_set_gpio(dev, 27, 0); 6935 + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); 6936 + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000); 6937 + msleep(20); 6926 6938 break; 6927 6939 case TDA18271_DIGITAL: 6928 - saa7134_set_gpio(dev, 27, 1); 6940 + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000); 6941 + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000); 6942 + msleep(20); 6943 + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000); 6944 + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000); 6945 + msleep(30); 6929 6946 break; 6930 6947 default: 6931 6948 return -EINVAL; ··· 6990 6993 int saa7134_tuner_callback(void *priv, int component, int command, int arg) 6991 6994 { 6992 6995 struct saa7134_dev *dev = priv; 6996 + 6993 6997 if (dev != NULL) { 6994 6998 switch (dev->tuner_type) { 6995 6999 case TUNER_PHILIPS_TDA8290: ··· 7657 7659 break; 7658 7660 } 7659 7661 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: 7660 - { 7661 - struct i2c_msg msg = { .addr = 0x4b, .flags = 0 }; 7662 - int i; 7663 - static u8 buffer[][2] = { 7664 - {0x30, 0x31}, 7665 - {0xff, 0x00}, 7666 - {0x41, 0x03}, 7667 - {0x41, 0x1a}, 7668 - {0xff, 0x02}, 7669 - {0x34, 0x00}, 7670 - {0x45, 0x97}, 7671 - {0x45, 0xc1}, 7672 - }; 7673 7662 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); 7674 7663 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000); 7675 7664 7676 - /* 7677 - * FIXME: identify what device is at addr 0x4b and what means 7678 - * this initialization 7679 - */ 7680 - for (i = 0; i < ARRAY_SIZE(buffer); i++) { 7681 - msg.buf = &buffer[i][0]; 7682 - msg.len = ARRAY_SIZE(buffer[0]); 7683 - if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) 7684 - printk(KERN_WARNING 7685 - "%s: Unable to enable tuner(%i).\n", 7686 - dev->name, i); 7687 - } 7665 + saa7134_set_gpio(dev, 27, 0); 7688 7666 break; 7689 - } 7690 7667 } /* switch() */ 7691 7668 7692 7669 /* initialize tuner */
+36 -44
drivers/media/video/saa7134/saa7134-dvb.c
··· 237 237 static struct tda18271_config kworld_tda18271_config = { 238 238 .std_map = &mb86a20s_tda18271_std_map, 239 239 .gate = TDA18271_GATE_DIGITAL, 240 + .config = 3, /* Use tuner callback for AGC */ 241 + 240 242 }; 241 243 242 244 static const struct mb86a20s_config kworld_mb86a20s_config = { 243 245 .demod_address = 0x10, 244 246 }; 247 + 248 + static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable) 249 + { 250 + struct saa7134_dev *dev = fe->dvb->priv; 251 + 252 + unsigned char initmsg[] = {0x45, 0x97}; 253 + unsigned char msg_enable[] = {0x45, 0xc1}; 254 + unsigned char msg_disable[] = {0x45, 0x81}; 255 + struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2}; 256 + 257 + if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { 258 + wprintk("could not access the I2C gate\n"); 259 + return -EIO; 260 + } 261 + if (enable) 262 + msg.buf = msg_enable; 263 + else 264 + msg.buf = msg_disable; 265 + if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { 266 + wprintk("could not access the I2C gate\n"); 267 + return -EIO; 268 + } 269 + msleep(20); 270 + return 0; 271 + } 245 272 246 273 /* ================================================================== 247 274 * tda1004x based DVB-T cards, helper functions ··· 647 620 .config = 2, 648 621 .switch_addr = 0x42 649 622 }; 650 - 651 - /* ------------------------------------------------------------------ */ 652 - 653 - static int __kworld_sbtvd_i2c_gate_ctrl(struct saa7134_dev *dev, int enable) 654 - { 655 - unsigned char initmsg[] = {0x45, 0x97}; 656 - unsigned char msg_enable[] = {0x45, 0xc1}; 657 - unsigned char msg_disable[] = {0x45, 0x81}; 658 - struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2}; 659 - 660 - if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { 661 - wprintk("could not access the I2C gate\n"); 662 - return -EIO; 663 - } 664 - if (enable) 665 - msg.buf = msg_enable; 666 - else 667 - msg.buf = msg_disable; 668 - if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { 669 - wprintk("could not access the I2C gate\n"); 670 - return -EIO; 671 - } 672 - msleep(20); 673 - return 0; 674 - } 675 - static int kworld_sbtvd_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 676 - { 677 - struct saa7134_dev *dev = fe->dvb->priv; 678 - 679 - return __kworld_sbtvd_i2c_gate_ctrl(dev, enable); 680 - } 681 623 682 624 /* ------------------------------------------------------------------ */ 683 625 ··· 1656 1660 } 1657 1661 break; 1658 1662 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: 1659 - __kworld_sbtvd_i2c_gate_ctrl(dev, 0); 1660 - saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000); 1661 - saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000); 1662 - msleep(20); 1663 - saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000); 1664 - saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000); 1665 - msleep(20); 1663 + /* Switch to digital mode */ 1664 + saa7134_tuner_callback(dev, 0, 1665 + TDA18271_CALLBACK_CMD_AGC_ENABLE, 1); 1666 1666 fe0->dvb.frontend = dvb_attach(mb86a20s_attach, 1667 1667 &kworld_mb86a20s_config, 1668 1668 &dev->i2c_adap); 1669 - __kworld_sbtvd_i2c_gate_ctrl(dev, 1); 1670 1669 if (fe0->dvb.frontend != NULL) { 1670 + dvb_attach(tda829x_attach, fe0->dvb.frontend, 1671 + &dev->i2c_adap, 0x4b, 1672 + &tda829x_no_probe); 1671 1673 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1672 1674 0x60, &dev->i2c_adap, 1673 1675 &kworld_tda18271_config); 1674 - /* 1675 - * Only after success, it can initialize the gate, otherwise 1676 - * an OOPS will hit, due to kfree(fe0->dvb.frontend) 1677 - */ 1678 - fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_i2c_gate_ctrl; 1676 + fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl; 1679 1677 } 1678 + 1679 + /* mb86a20s need to use the I2C gateway */ 1680 1680 break; 1681 1681 default: 1682 1682 wprintk("Huh? unknown DVB card?\n");
+32 -42
drivers/media/video/sn9c102/sn9c102_devtable.h
··· 47 47 { SN9C102_USB_DEVICE(0x0c45, 0x6009, BRIDGE_SN9C102), }, 48 48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, 49 49 /* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */ 50 - #endif 51 50 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, 51 + #endif 52 52 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, 53 53 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, 54 54 #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE ··· 56 56 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), }, 57 57 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), }, 58 58 #endif 59 - { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, 59 + { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, /* not in sonixb */ 60 60 #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 61 61 { SN9C102_USB_DEVICE(0x0c45, 0x602c, BRIDGE_SN9C102), }, 62 62 /* { SN9C102_USB_DEVICE(0x0c45, 0x602d, BRIDGE_SN9C102), }, HV7131R */ 63 63 { SN9C102_USB_DEVICE(0x0c45, 0x602e, BRIDGE_SN9C102), }, 64 64 #endif 65 - { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, 65 + { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, /* not in sonixb */ 66 66 /* SN9C103 */ 67 - { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, 68 - { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, 67 + /* { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, non existent ? */ 68 + { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, /* not in sonixb */ 69 + #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 69 70 /* { SN9C102_USB_DEVICE(0x0c45, 0x6083, BRIDGE_SN9C103), }, HY7131D/E */ 70 - { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, 71 - { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, 72 - { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, 71 + /* { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, non existent ? */ 72 + /* { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, non existent ? */ 73 + /* { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, non existent ? */ 73 74 { SN9C102_USB_DEVICE(0x0c45, 0x608c, BRIDGE_SN9C103), }, 74 75 /* { SN9C102_USB_DEVICE(0x0c45, 0x608e, BRIDGE_SN9C103), }, CISVF10 */ 75 - #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 76 76 { SN9C102_USB_DEVICE(0x0c45, 0x608f, BRIDGE_SN9C103), }, 77 - #endif 78 - { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, 79 - { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, 80 - { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), }, 77 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, non existent ? */ 78 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, non existent ? */ 79 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), }, non existent ? */ 81 80 /* { SN9C102_USB_DEVICE(0x0c45, 0x60a8, BRIDGE_SN9C103), }, PAS106 */ 82 81 /* { SN9C102_USB_DEVICE(0x0c45, 0x60aa, BRIDGE_SN9C103), }, TAS5130 */ 83 - /* { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, TAS5130 */ 84 - { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, 85 - { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, 82 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, TAS5110, non existent */ 83 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, non existent ? */ 84 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, non existent ? */ 86 85 { SN9C102_USB_DEVICE(0x0c45, 0x60af, BRIDGE_SN9C103), }, 87 - #if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 88 86 { SN9C102_USB_DEVICE(0x0c45, 0x60b0, BRIDGE_SN9C103), }, 87 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), }, non existent ? */ 88 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), }, non existent ? */ 89 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), }, non existent ? */ 90 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ba, BRIDGE_SN9C103), }, non existent ? */ 91 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60bb, BRIDGE_SN9C103), }, non existent ? */ 92 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, non existent ? */ 93 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, non existent ? */ 89 94 #endif 90 - { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), }, 91 - { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), }, 92 - { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), }, 93 - { SN9C102_USB_DEVICE(0x0c45, 0x60ba, BRIDGE_SN9C103), }, 94 - { SN9C102_USB_DEVICE(0x0c45, 0x60bb, BRIDGE_SN9C103), }, 95 - { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, 96 - { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, 97 95 /* SN9C105 */ 98 96 #if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 99 97 { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), }, 100 98 { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), }, 101 99 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, 102 100 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, 103 - #endif 104 101 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, 105 - { SN9C102_USB_DEVICE(0x0c45, 0x60c2, BRIDGE_SN9C105), }, 106 - { SN9C102_USB_DEVICE(0x0c45, 0x60c8, BRIDGE_SN9C105), }, 107 - { SN9C102_USB_DEVICE(0x0c45, 0x60cc, BRIDGE_SN9C105), }, 108 - { SN9C102_USB_DEVICE(0x0c45, 0x60ea, BRIDGE_SN9C105), }, 109 - { SN9C102_USB_DEVICE(0x0c45, 0x60ec, BRIDGE_SN9C105), }, 110 - { SN9C102_USB_DEVICE(0x0c45, 0x60ef, BRIDGE_SN9C105), }, 111 - { SN9C102_USB_DEVICE(0x0c45, 0x60fa, BRIDGE_SN9C105), }, 102 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60c2, BRIDGE_SN9C105), }, PO1030 */ 103 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60c8, BRIDGE_SN9C105), }, OM6801 */ 104 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60cc, BRIDGE_SN9C105), }, HV7131GP */ 105 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ea, BRIDGE_SN9C105), }, non existent ? */ 106 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ec, BRIDGE_SN9C105), }, MO4000 */ 107 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60ef, BRIDGE_SN9C105), }, ICM105C */ 108 + /* { SN9C102_USB_DEVICE(0x0c45, 0x60fa, BRIDGE_SN9C105), }, OV7648 */ 112 109 { SN9C102_USB_DEVICE(0x0c45, 0x60fb, BRIDGE_SN9C105), }, 113 110 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, 114 111 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, 115 112 /* SN9C120 */ 116 113 { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), }, 117 - #if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 118 - { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, 119 - #endif 120 - { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, 121 - { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, 122 - #if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 114 + /* { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, po2030 */ 115 + /* { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, om6801 */ 116 + /* { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, S5K53BEB */ 123 117 { SN9C102_USB_DEVICE(0x0c45, 0x6130, BRIDGE_SN9C120), }, 124 - #endif 125 118 /* { SN9C102_USB_DEVICE(0x0c45, 0x6138, BRIDGE_SN9C120), }, MO8000 */ 126 - #if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 127 119 { SN9C102_USB_DEVICE(0x0c45, 0x613a, BRIDGE_SN9C120), }, 128 - #endif 129 120 { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), }, 130 - #if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 131 121 { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), }, 132 122 { SN9C102_USB_DEVICE(0x0c45, 0x613e, BRIDGE_SN9C120), }, 133 123 #endif
-10
drivers/media/video/sr030pc30.c
··· 714 714 return ret; 715 715 } 716 716 717 - static int sr030pc30_s_config(struct v4l2_subdev *sd, 718 - int irq, void *platform_data) 719 - { 720 - struct sr030pc30_info *info = to_sr030pc30(sd); 721 - 722 - info->pdata = platform_data; 723 - return 0; 724 - } 725 - 726 717 static int sr030pc30_s_stream(struct v4l2_subdev *sd, int enable) 727 718 { 728 719 return 0; ··· 754 763 } 755 764 756 765 static const struct v4l2_subdev_core_ops sr030pc30_core_ops = { 757 - .s_config = sr030pc30_s_config, 758 766 .s_power = sr030pc30_s_power, 759 767 .queryctrl = sr030pc30_queryctrl, 760 768 .s_ctrl = sr030pc30_s_ctrl,
-411
drivers/media/video/tda9875.c
··· 1 - /* 2 - * For the TDA9875 chip 3 - * (The TDA9875 is used on the Diamond DTV2000 french version 4 - * Other cards probably use these chips as well.) 5 - * This driver will not complain if used with any 6 - * other i2c device with the same address. 7 - * 8 - * Copyright (c) 2000 Guillaume Delvit based on Gerd Knorr source and 9 - * Eric Sandeen 10 - * Copyright (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org> 11 - * This code is placed under the terms of the GNU General Public License 12 - * Based on tda9855.c by Steve VanDeBogart (vandebo@uclink.berkeley.edu) 13 - * Which was based on tda8425.c by Greg Alexander (c) 1998 14 - * 15 - * OPTIONS: 16 - * debug - set to 1 if you'd like to see debug messages 17 - * 18 - * Revision: 0.1 - original version 19 - */ 20 - 21 - #include <linux/module.h> 22 - #include <linux/kernel.h> 23 - #include <linux/string.h> 24 - #include <linux/timer.h> 25 - #include <linux/delay.h> 26 - #include <linux/errno.h> 27 - #include <linux/slab.h> 28 - #include <linux/i2c.h> 29 - #include <linux/videodev2.h> 30 - #include <media/v4l2-device.h> 31 - #include <media/i2c-addr.h> 32 - 33 - static int debug; /* insmod parameter */ 34 - module_param(debug, int, S_IRUGO | S_IWUSR); 35 - MODULE_LICENSE("GPL"); 36 - 37 - 38 - /* This is a superset of the TDA9875 */ 39 - struct tda9875 { 40 - struct v4l2_subdev sd; 41 - int rvol, lvol; 42 - int bass, treble; 43 - }; 44 - 45 - static inline struct tda9875 *to_state(struct v4l2_subdev *sd) 46 - { 47 - return container_of(sd, struct tda9875, sd); 48 - } 49 - 50 - #define dprintk if (debug) printk 51 - 52 - /* The TDA9875 is made by Philips Semiconductor 53 - * http://www.semiconductors.philips.com 54 - * TDA9875: I2C-bus controlled DSP audio processor, FM demodulator 55 - * 56 - */ 57 - 58 - /* subaddresses for TDA9875 */ 59 - #define TDA9875_MUT 0x12 /*General mute (value --> 0b11001100*/ 60 - #define TDA9875_CFG 0x01 /* Config register (value --> 0b00000000 */ 61 - #define TDA9875_DACOS 0x13 /*DAC i/o select (ADC) 0b0000100*/ 62 - #define TDA9875_LOSR 0x16 /*Line output select regirter 0b0100 0001*/ 63 - 64 - #define TDA9875_CH1V 0x0c /*Channel 1 volume (mute)*/ 65 - #define TDA9875_CH2V 0x0d /*Channel 2 volume (mute)*/ 66 - #define TDA9875_SC1 0x14 /*SCART 1 in (mono)*/ 67 - #define TDA9875_SC2 0x15 /*SCART 2 in (mono)*/ 68 - 69 - #define TDA9875_ADCIS 0x17 /*ADC input select (mono) 0b0110 000*/ 70 - #define TDA9875_AER 0x19 /*Audio effect (AVL+Pseudo) 0b0000 0110*/ 71 - #define TDA9875_MCS 0x18 /*Main channel select (DAC) 0b0000100*/ 72 - #define TDA9875_MVL 0x1a /* Main volume gauche */ 73 - #define TDA9875_MVR 0x1b /* Main volume droite */ 74 - #define TDA9875_MBA 0x1d /* Main Basse */ 75 - #define TDA9875_MTR 0x1e /* Main treble */ 76 - #define TDA9875_ACS 0x1f /* Auxilary channel select (FM) 0b0000000*/ 77 - #define TDA9875_AVL 0x20 /* Auxilary volume gauche */ 78 - #define TDA9875_AVR 0x21 /* Auxilary volume droite */ 79 - #define TDA9875_ABA 0x22 /* Auxilary Basse */ 80 - #define TDA9875_ATR 0x23 /* Auxilary treble */ 81 - 82 - #define TDA9875_MSR 0x02 /* Monitor select register */ 83 - #define TDA9875_C1MSB 0x03 /* Carrier 1 (FM) frequency register MSB */ 84 - #define TDA9875_C1MIB 0x04 /* Carrier 1 (FM) frequency register (16-8]b */ 85 - #define TDA9875_C1LSB 0x05 /* Carrier 1 (FM) frequency register LSB */ 86 - #define TDA9875_C2MSB 0x06 /* Carrier 2 (nicam) frequency register MSB */ 87 - #define TDA9875_C2MIB 0x07 /* Carrier 2 (nicam) frequency register (16-8]b */ 88 - #define TDA9875_C2LSB 0x08 /* Carrier 2 (nicam) frequency register LSB */ 89 - #define TDA9875_DCR 0x09 /* Demodulateur configuration regirter*/ 90 - #define TDA9875_DEEM 0x0a /* FM de-emphasis regirter*/ 91 - #define TDA9875_FMAT 0x0b /* FM Matrix regirter*/ 92 - 93 - /* values */ 94 - #define TDA9875_MUTE_ON 0xff /* general mute */ 95 - #define TDA9875_MUTE_OFF 0xcc /* general no mute */ 96 - 97 - 98 - 99 - /* Begin code */ 100 - 101 - static int tda9875_write(struct v4l2_subdev *sd, int subaddr, unsigned char val) 102 - { 103 - struct i2c_client *client = v4l2_get_subdevdata(sd); 104 - unsigned char buffer[2]; 105 - 106 - v4l2_dbg(1, debug, sd, "Writing %d 0x%x\n", subaddr, val); 107 - buffer[0] = subaddr; 108 - buffer[1] = val; 109 - if (2 != i2c_master_send(client, buffer, 2)) { 110 - v4l2_warn(sd, "I/O error, trying (write %d 0x%x)\n", 111 - subaddr, val); 112 - return -1; 113 - } 114 - return 0; 115 - } 116 - 117 - 118 - static int i2c_read_register(struct i2c_client *client, int addr, int reg) 119 - { 120 - unsigned char write[1]; 121 - unsigned char read[1]; 122 - struct i2c_msg msgs[2] = { 123 - { addr, 0, 1, write }, 124 - { addr, I2C_M_RD, 1, read } 125 - }; 126 - 127 - write[0] = reg; 128 - 129 - if (2 != i2c_transfer(client->adapter, msgs, 2)) { 130 - v4l_warn(client, "I/O error (read2)\n"); 131 - return -1; 132 - } 133 - v4l_dbg(1, debug, client, "chip_read2: reg%d=0x%x\n", reg, read[0]); 134 - return read[0]; 135 - } 136 - 137 - static void tda9875_set(struct v4l2_subdev *sd) 138 - { 139 - struct tda9875 *tda = to_state(sd); 140 - unsigned char a; 141 - 142 - v4l2_dbg(1, debug, sd, "tda9875_set(%04x,%04x,%04x,%04x)\n", 143 - tda->lvol, tda->rvol, tda->bass, tda->treble); 144 - 145 - a = tda->lvol & 0xff; 146 - tda9875_write(sd, TDA9875_MVL, a); 147 - a =tda->rvol & 0xff; 148 - tda9875_write(sd, TDA9875_MVR, a); 149 - a =tda->bass & 0xff; 150 - tda9875_write(sd, TDA9875_MBA, a); 151 - a =tda->treble & 0xff; 152 - tda9875_write(sd, TDA9875_MTR, a); 153 - } 154 - 155 - static void do_tda9875_init(struct v4l2_subdev *sd) 156 - { 157 - struct tda9875 *t = to_state(sd); 158 - 159 - v4l2_dbg(1, debug, sd, "In tda9875_init\n"); 160 - tda9875_write(sd, TDA9875_CFG, 0xd0); /*reg de config 0 (reset)*/ 161 - tda9875_write(sd, TDA9875_MSR, 0x03); /* Monitor 0b00000XXX*/ 162 - tda9875_write(sd, TDA9875_C1MSB, 0x00); /*Car1(FM) MSB XMHz*/ 163 - tda9875_write(sd, TDA9875_C1MIB, 0x00); /*Car1(FM) MIB XMHz*/ 164 - tda9875_write(sd, TDA9875_C1LSB, 0x00); /*Car1(FM) LSB XMHz*/ 165 - tda9875_write(sd, TDA9875_C2MSB, 0x00); /*Car2(NICAM) MSB XMHz*/ 166 - tda9875_write(sd, TDA9875_C2MIB, 0x00); /*Car2(NICAM) MIB XMHz*/ 167 - tda9875_write(sd, TDA9875_C2LSB, 0x00); /*Car2(NICAM) LSB XMHz*/ 168 - tda9875_write(sd, TDA9875_DCR, 0x00); /*Demod config 0x00*/ 169 - tda9875_write(sd, TDA9875_DEEM, 0x44); /*DE-Emph 0b0100 0100*/ 170 - tda9875_write(sd, TDA9875_FMAT, 0x00); /*FM Matrix reg 0x00*/ 171 - tda9875_write(sd, TDA9875_SC1, 0x00); /* SCART 1 (SC1)*/ 172 - tda9875_write(sd, TDA9875_SC2, 0x01); /* SCART 2 (sc2)*/ 173 - 174 - tda9875_write(sd, TDA9875_CH1V, 0x10); /* Channel volume 1 mute*/ 175 - tda9875_write(sd, TDA9875_CH2V, 0x10); /* Channel volume 2 mute */ 176 - tda9875_write(sd, TDA9875_DACOS, 0x02); /* sig DAC i/o(in:nicam)*/ 177 - tda9875_write(sd, TDA9875_ADCIS, 0x6f); /* sig ADC input(in:mono)*/ 178 - tda9875_write(sd, TDA9875_LOSR, 0x00); /* line out (in:mono)*/ 179 - tda9875_write(sd, TDA9875_AER, 0x00); /*06 Effect (AVL+PSEUDO) */ 180 - tda9875_write(sd, TDA9875_MCS, 0x44); /* Main ch select (DAC) */ 181 - tda9875_write(sd, TDA9875_MVL, 0x03); /* Vol Main left 10dB */ 182 - tda9875_write(sd, TDA9875_MVR, 0x03); /* Vol Main right 10dB*/ 183 - tda9875_write(sd, TDA9875_MBA, 0x00); /* Main Bass Main 0dB*/ 184 - tda9875_write(sd, TDA9875_MTR, 0x00); /* Main Treble Main 0dB*/ 185 - tda9875_write(sd, TDA9875_ACS, 0x44); /* Aux chan select (dac)*/ 186 - tda9875_write(sd, TDA9875_AVL, 0x00); /* Vol Aux left 0dB*/ 187 - tda9875_write(sd, TDA9875_AVR, 0x00); /* Vol Aux right 0dB*/ 188 - tda9875_write(sd, TDA9875_ABA, 0x00); /* Aux Bass Main 0dB*/ 189 - tda9875_write(sd, TDA9875_ATR, 0x00); /* Aux Aigus Main 0dB*/ 190 - 191 - tda9875_write(sd, TDA9875_MUT, 0xcc); /* General mute */ 192 - 193 - t->lvol = t->rvol = 0; /* 0dB */ 194 - t->bass = 0; /* 0dB */ 195 - t->treble = 0; /* 0dB */ 196 - tda9875_set(sd); 197 - } 198 - 199 - 200 - static int tda9875_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 201 - { 202 - struct tda9875 *t = to_state(sd); 203 - 204 - switch (ctrl->id) { 205 - case V4L2_CID_AUDIO_VOLUME: 206 - { 207 - int left = (t->lvol+84)*606; 208 - int right = (t->rvol+84)*606; 209 - 210 - ctrl->value=max(left,right); 211 - return 0; 212 - } 213 - case V4L2_CID_AUDIO_BALANCE: 214 - { 215 - int left = (t->lvol+84)*606; 216 - int right = (t->rvol+84)*606; 217 - int volume = max(left,right); 218 - int balance = (32768*min(left,right))/ 219 - (volume ? volume : 1); 220 - ctrl->value=(left<right)? 221 - (65535-balance) : balance; 222 - return 0; 223 - } 224 - case V4L2_CID_AUDIO_BASS: 225 - ctrl->value = (t->bass+12)*2427; /* min -12 max +15 */ 226 - return 0; 227 - case V4L2_CID_AUDIO_TREBLE: 228 - ctrl->value = (t->treble+12)*2730;/* min -12 max +12 */ 229 - return 0; 230 - } 231 - return -EINVAL; 232 - } 233 - 234 - static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 235 - { 236 - struct tda9875 *t = to_state(sd); 237 - int chvol = 0, volume = 0, balance = 0, left, right; 238 - 239 - switch (ctrl->id) { 240 - case V4L2_CID_AUDIO_VOLUME: 241 - left = (t->lvol+84)*606; 242 - right = (t->rvol+84)*606; 243 - 244 - volume = max(left,right); 245 - balance = (32768*min(left,right))/ 246 - (volume ? volume : 1); 247 - balance =(left<right)? 248 - (65535-balance) : balance; 249 - 250 - volume = ctrl->value; 251 - 252 - chvol=1; 253 - break; 254 - case V4L2_CID_AUDIO_BALANCE: 255 - left = (t->lvol+84)*606; 256 - right = (t->rvol+84)*606; 257 - 258 - volume=max(left,right); 259 - 260 - balance = ctrl->value; 261 - 262 - chvol=1; 263 - break; 264 - case V4L2_CID_AUDIO_BASS: 265 - t->bass = ((ctrl->value/2400)-12) & 0xff; 266 - if (t->bass > 15) 267 - t->bass = 15; 268 - if (t->bass < -12) 269 - t->bass = -12 & 0xff; 270 - break; 271 - case V4L2_CID_AUDIO_TREBLE: 272 - t->treble = ((ctrl->value/2700)-12) & 0xff; 273 - if (t->treble > 12) 274 - t->treble = 12; 275 - if (t->treble < -12) 276 - t->treble = -12 & 0xff; 277 - break; 278 - default: 279 - return -EINVAL; 280 - } 281 - 282 - if (chvol) { 283 - left = (min(65536 - balance,32768) * 284 - volume) / 32768; 285 - right = (min(balance,32768) * 286 - volume) / 32768; 287 - t->lvol = ((left/606)-84) & 0xff; 288 - if (t->lvol > 24) 289 - t->lvol = 24; 290 - if (t->lvol < -84) 291 - t->lvol = -84 & 0xff; 292 - 293 - t->rvol = ((right/606)-84) & 0xff; 294 - if (t->rvol > 24) 295 - t->rvol = 24; 296 - if (t->rvol < -84) 297 - t->rvol = -84 & 0xff; 298 - } 299 - 300 - tda9875_set(sd); 301 - return 0; 302 - } 303 - 304 - static int tda9875_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) 305 - { 306 - switch (qc->id) { 307 - case V4L2_CID_AUDIO_VOLUME: 308 - return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 58880); 309 - case V4L2_CID_AUDIO_BASS: 310 - case V4L2_CID_AUDIO_TREBLE: 311 - return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 32768); 312 - } 313 - return -EINVAL; 314 - } 315 - 316 - /* ----------------------------------------------------------------------- */ 317 - 318 - static const struct v4l2_subdev_core_ops tda9875_core_ops = { 319 - .queryctrl = tda9875_queryctrl, 320 - .g_ctrl = tda9875_g_ctrl, 321 - .s_ctrl = tda9875_s_ctrl, 322 - }; 323 - 324 - static const struct v4l2_subdev_ops tda9875_ops = { 325 - .core = &tda9875_core_ops, 326 - }; 327 - 328 - /* ----------------------------------------------------------------------- */ 329 - 330 - 331 - /* *********************** * 332 - * i2c interface functions * 333 - * *********************** */ 334 - 335 - static int tda9875_checkit(struct i2c_client *client, int addr) 336 - { 337 - int dic, rev; 338 - 339 - dic = i2c_read_register(client, addr, 254); 340 - rev = i2c_read_register(client, addr, 255); 341 - 342 - if (dic == 0 || dic == 2) { /* tda9875 and tda9875A */ 343 - v4l_info(client, "tda9875%s rev. %d detected at 0x%02x\n", 344 - dic == 0 ? "" : "A", rev, addr << 1); 345 - return 1; 346 - } 347 - v4l_info(client, "no such chip at 0x%02x (dic=0x%x rev=0x%x)\n", 348 - addr << 1, dic, rev); 349 - return 0; 350 - } 351 - 352 - static int tda9875_probe(struct i2c_client *client, 353 - const struct i2c_device_id *id) 354 - { 355 - struct tda9875 *t; 356 - struct v4l2_subdev *sd; 357 - 358 - v4l_info(client, "chip found @ 0x%02x (%s)\n", 359 - client->addr << 1, client->adapter->name); 360 - 361 - if (!tda9875_checkit(client, client->addr)) 362 - return -ENODEV; 363 - 364 - t = kzalloc(sizeof(*t), GFP_KERNEL); 365 - if (!t) 366 - return -ENOMEM; 367 - sd = &t->sd; 368 - v4l2_i2c_subdev_init(sd, client, &tda9875_ops); 369 - 370 - do_tda9875_init(sd); 371 - return 0; 372 - } 373 - 374 - static int tda9875_remove(struct i2c_client *client) 375 - { 376 - struct v4l2_subdev *sd = i2c_get_clientdata(client); 377 - 378 - do_tda9875_init(sd); 379 - v4l2_device_unregister_subdev(sd); 380 - kfree(to_state(sd)); 381 - return 0; 382 - } 383 - 384 - static const struct i2c_device_id tda9875_id[] = { 385 - { "tda9875", 0 }, 386 - { } 387 - }; 388 - MODULE_DEVICE_TABLE(i2c, tda9875_id); 389 - 390 - static struct i2c_driver tda9875_driver = { 391 - .driver = { 392 - .owner = THIS_MODULE, 393 - .name = "tda9875", 394 - }, 395 - .probe = tda9875_probe, 396 - .remove = tda9875_remove, 397 - .id_table = tda9875_id, 398 - }; 399 - 400 - static __init int init_tda9875(void) 401 - { 402 - return i2c_add_driver(&tda9875_driver); 403 - } 404 - 405 - static __exit void exit_tda9875(void) 406 - { 407 - i2c_del_driver(&tda9875_driver); 408 - } 409 - 410 - module_init(init_tda9875); 411 - module_exit(exit_tda9875);
+7 -6
drivers/media/video/tlg2300/pd-video.c
··· 512 512 int buf_size, gfp_t gfp_flags, 513 513 usb_complete_t complete_fn, void *context) 514 514 { 515 - struct urb *urb; 516 - void *mem; 517 - int i; 515 + int i = 0; 518 516 519 - for (i = 0; i < num; i++) { 520 - urb = usb_alloc_urb(0, gfp_flags); 517 + for (; i < num; i++) { 518 + void *mem; 519 + struct urb *urb = usb_alloc_urb(0, gfp_flags); 521 520 if (urb == NULL) 522 521 return i; 523 522 524 523 mem = usb_alloc_coherent(udev, buf_size, gfp_flags, 525 524 &urb->transfer_dma); 526 - if (mem == NULL) 525 + if (mem == NULL) { 526 + usb_free_urb(urb); 527 527 return i; 528 + } 528 529 529 530 usb_fill_bulk_urb(urb, udev, usb_rcvbulkpipe(udev, ep_addr), 530 531 mem, buf_size, complete_fn, context);
+2 -17
drivers/media/video/v4l2-common.c
··· 407 407 /* Decrease the module use count to match the first try_module_get. */ 408 408 module_put(client->driver->driver.owner); 409 409 410 - if (sd) { 411 - /* We return errors from v4l2_subdev_call only if we have the 412 - callback as the .s_config is not mandatory */ 413 - int err = v4l2_subdev_call(sd, core, s_config, 414 - info->irq, info->platform_data); 415 - 416 - if (err && err != -ENOIOCTLCMD) { 417 - v4l2_device_unregister_subdev(sd); 418 - sd = NULL; 419 - } 420 - } 421 - 422 410 error: 423 411 /* If we have a client but no subdev, then something went wrong and 424 412 we must unregister the client. */ ··· 416 428 } 417 429 EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board); 418 430 419 - struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 431 + struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, 420 432 struct i2c_adapter *adapter, const char *client_type, 421 - int irq, void *platform_data, 422 433 u8 addr, const unsigned short *probe_addrs) 423 434 { 424 435 struct i2c_board_info info; ··· 427 440 memset(&info, 0, sizeof(info)); 428 441 strlcpy(info.type, client_type, sizeof(info.type)); 429 442 info.addr = addr; 430 - info.irq = irq; 431 - info.platform_data = platform_data; 432 443 433 444 return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, probe_addrs); 434 445 } 435 - EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_cfg); 446 + EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); 436 447 437 448 /* Return i2c client address of v4l2_subdev. */ 438 449 unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
+22 -12
drivers/media/video/v4l2-ctrls.c
··· 569 569 int ret; 570 570 u32 size; 571 571 572 - ctrl->has_new = 1; 572 + ctrl->is_new = 1; 573 573 switch (ctrl->type) { 574 574 case V4L2_CTRL_TYPE_INTEGER64: 575 575 ctrl->val64 = c->value64; ··· 1280 1280 if (ctrl->done) 1281 1281 continue; 1282 1282 1283 - for (i = 0; i < master->ncontrols; i++) 1284 - cur_to_new(master->cluster[i]); 1283 + for (i = 0; i < master->ncontrols; i++) { 1284 + if (master->cluster[i]) { 1285 + cur_to_new(master->cluster[i]); 1286 + master->cluster[i]->is_new = 1; 1287 + } 1288 + } 1285 1289 1286 1290 /* Skip button controls and read-only controls. */ 1287 1291 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON || ··· 1344 1340 1345 1341 ctrl = ref->ctrl; 1346 1342 memset(qc, 0, sizeof(*qc)); 1347 - qc->id = ctrl->id; 1343 + if (id >= V4L2_CID_PRIVATE_BASE) 1344 + qc->id = id; 1345 + else 1346 + qc->id = ctrl->id; 1348 1347 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); 1349 1348 qc->minimum = ctrl->minimum; 1350 1349 qc->maximum = ctrl->maximum; 1351 1350 qc->default_value = ctrl->default_value; 1352 - if (qc->type == V4L2_CTRL_TYPE_MENU) 1351 + if (ctrl->type == V4L2_CTRL_TYPE_MENU) 1353 1352 qc->step = 1; 1354 1353 else 1355 1354 qc->step = ctrl->step; ··· 1652 1645 if (ctrl == NULL) 1653 1646 continue; 1654 1647 1655 - if (ctrl->has_new) { 1648 + if (ctrl->is_new) { 1656 1649 /* Double check this: it may have changed since the 1657 1650 last check in try_or_set_ext_ctrls(). */ 1658 1651 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) ··· 1726 1719 1727 1720 v4l2_ctrl_lock(ctrl); 1728 1721 1729 - /* Reset the 'has_new' flags of the cluster */ 1722 + /* Reset the 'is_new' flags of the cluster */ 1730 1723 for (j = 0; j < master->ncontrols; j++) 1731 1724 if (master->cluster[j]) 1732 - master->cluster[j]->has_new = 0; 1725 + master->cluster[j]->is_new = 0; 1733 1726 1734 1727 /* Copy the new caller-supplied control values. 1735 - user_to_new() sets 'has_new' to 1. */ 1728 + user_to_new() sets 'is_new' to 1. */ 1736 1729 ret = cluster_walk(i, cs, helpers, user_to_new); 1737 1730 1738 1731 if (!ret) ··· 1827 1820 int ret; 1828 1821 int i; 1829 1822 1823 + if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) 1824 + return -EACCES; 1825 + 1830 1826 v4l2_ctrl_lock(ctrl); 1831 1827 1832 - /* Reset the 'has_new' flags of the cluster */ 1828 + /* Reset the 'is_new' flags of the cluster */ 1833 1829 for (i = 0; i < master->ncontrols; i++) 1834 1830 if (master->cluster[i]) 1835 - master->cluster[i]->has_new = 0; 1831 + master->cluster[i]->is_new = 0; 1836 1832 1837 1833 ctrl->val = *val; 1838 - ctrl->has_new = 1; 1834 + ctrl->is_new = 1; 1839 1835 ret = try_or_set_control_cluster(master, false); 1840 1836 if (!ret) 1841 1837 ret = try_or_set_control_cluster(master, true);
+4 -5
drivers/media/video/v4l2-dev.c
··· 419 419 * The registration code assigns minor numbers and device node numbers 420 420 * based on the requested type and registers the new device node with 421 421 * the kernel. 422 + * 423 + * This function assumes that struct video_device was zeroed when it 424 + * was allocated and does not contain any stale date. 425 + * 422 426 * An error is returned if no free minor or device node number could be 423 427 * found, or if the registration of the device node failed. 424 428 * ··· 444 440 int minor_offset = 0; 445 441 int minor_cnt = VIDEO_NUM_DEVICES; 446 442 const char *name_base; 447 - void *priv = vdev->dev.p; 448 443 449 444 /* A minor value of -1 marks this video device as never 450 445 having been registered */ ··· 562 559 } 563 560 564 561 /* Part 4: register the device with sysfs */ 565 - memset(&vdev->dev, 0, sizeof(vdev->dev)); 566 - /* The memset above cleared the device's device_private, so 567 - put back the copy we made earlier. */ 568 - vdev->dev.p = priv; 569 562 vdev->dev.class = &video_class; 570 563 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); 571 564 if (vdev->parent)
+14 -2
drivers/media/video/v4l2-device.c
··· 100 100 is a platform bus, then it is never deleted. */ 101 101 if (client) 102 102 i2c_unregister_device(client); 103 + continue; 103 104 } 104 105 #endif 105 106 #if defined(CONFIG_SPI) ··· 109 108 110 109 if (spi) 111 110 spi_unregister_device(spi); 111 + continue; 112 112 } 113 113 #endif 114 114 } ··· 128 126 WARN_ON(sd->v4l2_dev != NULL); 129 127 if (!try_module_get(sd->owner)) 130 128 return -ENODEV; 129 + sd->v4l2_dev = v4l2_dev; 130 + if (sd->internal_ops && sd->internal_ops->registered) { 131 + err = sd->internal_ops->registered(sd); 132 + if (err) 133 + return err; 134 + } 131 135 /* This just returns 0 if either of the two args is NULL */ 132 136 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler); 133 - if (err) 137 + if (err) { 138 + if (sd->internal_ops && sd->internal_ops->unregistered) 139 + sd->internal_ops->unregistered(sd); 134 140 return err; 135 - sd->v4l2_dev = v4l2_dev; 141 + } 136 142 spin_lock(&v4l2_dev->lock); 137 143 list_add_tail(&sd->list, &v4l2_dev->subdevs); 138 144 spin_unlock(&v4l2_dev->lock); ··· 156 146 spin_lock(&sd->v4l2_dev->lock); 157 147 list_del(&sd->list); 158 148 spin_unlock(&sd->v4l2_dev->lock); 149 + if (sd->internal_ops && sd->internal_ops->unregistered) 150 + sd->internal_ops->unregistered(sd); 159 151 sd->v4l2_dev = NULL; 160 152 module_put(sd->owner); 161 153 }
+12 -8
drivers/media/video/v4l2-ioctl.c
··· 1659 1659 { 1660 1660 struct v4l2_dbg_register *p = arg; 1661 1661 1662 - if (!capable(CAP_SYS_ADMIN)) 1663 - ret = -EPERM; 1664 - else if (ops->vidioc_g_register) 1665 - ret = ops->vidioc_g_register(file, fh, p); 1662 + if (ops->vidioc_g_register) { 1663 + if (!capable(CAP_SYS_ADMIN)) 1664 + ret = -EPERM; 1665 + else 1666 + ret = ops->vidioc_g_register(file, fh, p); 1667 + } 1666 1668 break; 1667 1669 } 1668 1670 case VIDIOC_DBG_S_REGISTER: 1669 1671 { 1670 1672 struct v4l2_dbg_register *p = arg; 1671 1673 1672 - if (!capable(CAP_SYS_ADMIN)) 1673 - ret = -EPERM; 1674 - else if (ops->vidioc_s_register) 1675 - ret = ops->vidioc_s_register(file, fh, p); 1674 + if (ops->vidioc_s_register) { 1675 + if (!capable(CAP_SYS_ADMIN)) 1676 + ret = -EPERM; 1677 + else 1678 + ret = ops->vidioc_s_register(file, fh, p); 1679 + } 1676 1680 break; 1677 1681 } 1678 1682 #endif
+1
drivers/media/video/w9966.c
··· 937 937 parport_unregister_device(cam->pdev); 938 938 w9966_set_state(cam, W9966_STATE_PDEV, 0); 939 939 } 940 + memset(cam, 0, sizeof(*cam)); 940 941 } 941 942 942 943
+1 -1
drivers/media/video/zoran/zoran_card.c
··· 1041 1041 /* allocate memory *before* doing anything to the hardware 1042 1042 * in case allocation fails */ 1043 1043 zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); 1044 - zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL); 1044 + zr->video_dev = video_device_alloc(); 1045 1045 if (!zr->stat_com || !zr->video_dev) { 1046 1046 dprintk(1, 1047 1047 KERN_ERR
+30 -6
drivers/staging/lirc/TODO.lirc_zilog
··· 1 - The binding between hdpvr and lirc_zilog is currently disabled, 1 + 1. Both ir-kbd-i2c and lirc_zilog provide support for RX events. 2 + The 'tx_only' lirc_zilog module parameter will allow ir-kbd-i2c 3 + and lirc_zilog to coexist in the kernel, if the user requires such a set-up. 4 + However the IR unit will not work well without coordination between the 5 + two modules. A shared mutex, for transceiver access locking, needs to be 6 + supplied by bridge drivers, in struct IR_i2_init_data, to both ir-kbd-i2c 7 + and lirc_zilog, before they will coexist usefully. This should be fixed 8 + before moving out of staging. 9 + 10 + 2. References and locking need careful examination. For cx18 and ivtv PCI 11 + cards, which are not easily "hot unplugged", the imperfect state of reference 12 + counting and locking is acceptable if not correct. For USB connected units 13 + like HD PVR, PVR USB2, HVR-1900, and HVR1950, the likelyhood of an Ooops on 14 + unplug is probably great. Proper reference counting and locking needs to be 15 + implemented before this module is moved out of staging. 16 + 17 + 3. The binding between hdpvr and lirc_zilog is currently disabled, 2 18 due to an OOPS reported a few years ago when both the hdpvr and cx18 3 19 drivers were loaded in his system. More details can be seen at: 4 20 http://www.mail-archive.com/linux-media@vger.kernel.org/msg09163.html 5 21 More tests need to be done, in order to fix the reported issue. 6 22 7 - There's a conflict between ir-kbd-i2c: Both provide support for RX events. 8 - Such conflict needs to be fixed, before moving it out of staging. 23 + 4. In addition to providing a shared mutex for transceiver access 24 + locking, bridge drivers, if able, should provide a chip reset() callback 25 + to lirc_zilog via struct IR_i2c_init_data. cx18 and ivtv already have routines 26 + to perform Z8 chip resets via GPIO manipulations. This will allow lirc_zilog 27 + to bring the chip back to normal when it hangs, in the same places the 28 + original lirc_pvr150 driver code does. This is not strictly needed, so it 29 + is not required to move lirc_zilog out of staging. 9 30 10 - The way I2C probe works, it will try to register the driver twice, one 11 - for RX and another for TX. The logic needs to be fixed to avoid such 12 - issue. 31 + 5. Both lirc_zilog and ir-kbd-i2c support the Zilog Z8 for IR, as programmed 32 + and installed on Hauppauge products. When working on either module, developers 33 + must consider at least the following bridge drivers which mention an IR Rx unit 34 + at address 0x71 (indicative of a Z8): 35 + 36 + ivtv cx18 hdpvr pvrusb2 bt8xx cx88 saa7134 13 37
+1
drivers/staging/lirc/lirc_imon.c
··· 447 447 448 448 exit: 449 449 mutex_unlock(&context->ctx_lock); 450 + kfree(data_buf); 450 451 451 452 return (!retval) ? n_bytes : retval; 452 453 }
+1
drivers/staging/lirc/lirc_it87.c
··· 232 232 i++; 233 233 } 234 234 terminate_send(tx_buf[i - 1]); 235 + kfree(tx_buf); 235 236 return n; 236 237 } 237 238
+14 -5
drivers/staging/lirc/lirc_parallel.c
··· 376 376 unsigned long flags; 377 377 int counttimer; 378 378 int *wbuf; 379 + ssize_t ret; 379 380 380 381 if (!is_claimed) 381 382 return -EBUSY; ··· 394 393 if (timer == 0) { 395 394 /* try again if device is ready */ 396 395 timer = init_lirc_timer(); 397 - if (timer == 0) 398 - return -EIO; 396 + if (timer == 0) { 397 + ret = -EIO; 398 + goto out; 399 + } 399 400 } 400 401 401 402 /* adjust values from usecs */ ··· 423 420 if (check_pselecd && (in(1) & LP_PSELECD)) { 424 421 lirc_off(); 425 422 local_irq_restore(flags); 426 - return -EIO; 423 + ret = -EIO; 424 + goto out; 427 425 } 428 426 } while (counttimer < wbuf[i]); 429 427 i++; ··· 440 436 level = newlevel; 441 437 if (check_pselecd && (in(1) & LP_PSELECD)) { 442 438 local_irq_restore(flags); 443 - return -EIO; 439 + ret = -EIO; 440 + goto out; 444 441 } 445 442 } while (counttimer < wbuf[i]); 446 443 i++; ··· 450 445 #else 451 446 /* place code that handles write without external timer here */ 452 447 #endif 453 - return n; 448 + ret = n; 449 + out: 450 + kfree(wbuf); 451 + 452 + return ret; 454 453 } 455 454 456 455 static unsigned int lirc_poll(struct file *file, poll_table *wait)
+1
drivers/staging/lirc/lirc_sasem.c
··· 448 448 exit: 449 449 450 450 mutex_unlock(&context->ctx_lock); 451 + kfree(data_buf); 451 452 452 453 return (!retval) ? n_bytes : retval; 453 454 }
+2 -1
drivers/staging/lirc/lirc_serial.c
··· 966 966 if (n % sizeof(int) || count % 2 == 0) 967 967 return -EINVAL; 968 968 wbuf = memdup_user(buf, n); 969 - if (PTR_ERR(wbuf)) 969 + if (IS_ERR(wbuf)) 970 970 return PTR_ERR(wbuf); 971 971 spin_lock_irqsave(&hardware[type].lock, flags); 972 972 if (type == LIRC_IRDEO) { ··· 981 981 } 982 982 off(); 983 983 spin_unlock_irqrestore(&hardware[type].lock, flags); 984 + kfree(wbuf); 984 985 return n; 985 986 } 986 987
+1
drivers/staging/lirc/lirc_sir.c
··· 330 330 /* enable receiver */ 331 331 Ser2UTCR3 = UTCR3_RXE|UTCR3_RIE; 332 332 #endif 333 + kfree(tx_buf); 333 334 return count; 334 335 } 335 336
+360 -304
drivers/staging/lirc/lirc_zilog.c
··· 20 20 * 21 21 * parts are cut&pasted from the lirc_i2c.c driver 22 22 * 23 + * Numerous changes updating lirc_zilog.c in kernel 2.6.38 and later are 24 + * Copyright (C) 2011 Andy Walls <awalls@md.metrocast.net> 25 + * 23 26 * This program is free software; you can redistribute it and/or modify 24 27 * it under the terms of the GNU General Public License as published by 25 28 * the Free Software Foundation; either version 2 of the License, or ··· 63 60 #include <media/lirc_dev.h> 64 61 #include <media/lirc.h> 65 62 66 - struct IR { 67 - struct lirc_driver l; 68 - 69 - /* Device info */ 70 - struct mutex ir_lock; 71 - int open; 72 - bool is_hdpvr; 73 - 63 + struct IR_rx { 74 64 /* RX device */ 75 - struct i2c_client c_rx; 76 - int have_rx; 65 + struct i2c_client *c; 77 66 78 67 /* RX device buffer & lock */ 79 68 struct lirc_buffer buf; 80 69 struct mutex buf_lock; 81 70 82 71 /* RX polling thread data */ 83 - struct completion *t_notify; 84 - struct completion *t_notify2; 85 - int shutdown; 86 72 struct task_struct *task; 87 73 88 74 /* RX read data */ 89 75 unsigned char b[3]; 76 + bool hdpvr_data_fmt; 77 + }; 90 78 79 + struct IR_tx { 91 80 /* TX device */ 92 - struct i2c_client c_tx; 81 + struct i2c_client *c; 82 + 83 + /* TX additional actions needed */ 93 84 int need_boot; 94 - int have_tx; 85 + bool post_tx_ready_poll; 86 + }; 87 + 88 + struct IR { 89 + struct lirc_driver l; 90 + 91 + struct mutex ir_lock; 92 + int open; 93 + 94 + struct i2c_adapter *adapter; 95 + struct IR_rx *rx; 96 + struct IR_tx *tx; 95 97 }; 96 98 97 99 /* Minor -> data mapping */ 100 + static struct mutex ir_devices_lock; 98 101 static struct IR *ir_devices[MAX_IRCTL_DEVICES]; 99 102 100 103 /* Block size for IR transmitter */ ··· 133 124 #define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \ 134 125 ## args) 135 126 #define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) 136 - 137 - #define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX" 138 - #define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX" 127 + #define zilog_info(s, args...) printk(KERN_INFO KBUILD_MODNAME ": " s, ## args) 139 128 140 129 /* module parameters */ 141 130 static int debug; /* debug output */ 142 - static int disable_rx; /* disable RX device */ 143 - static int disable_tx; /* disable TX device */ 131 + static int tx_only; /* only handle the IR Tx function */ 144 132 static int minor = -1; /* minor number */ 145 133 146 134 #define dprintk(fmt, args...) \ ··· 156 150 int ret; 157 151 int failures = 0; 158 152 unsigned char sendbuf[1] = { 0 }; 153 + struct IR_rx *rx = ir->rx; 159 154 160 - if (lirc_buffer_full(&ir->buf)) { 155 + if (rx == NULL) 156 + return -ENXIO; 157 + 158 + if (lirc_buffer_full(&rx->buf)) { 161 159 dprintk("buffer overflow\n"); 162 160 return -EOVERFLOW; 163 161 } ··· 171 161 * data and we have space 172 162 */ 173 163 do { 164 + if (kthread_should_stop()) 165 + return -ENODATA; 166 + 174 167 /* 175 168 * Lock i2c bus for the duration. RX/TX chips interfere so 176 169 * this is worth it 177 170 */ 178 171 mutex_lock(&ir->ir_lock); 179 172 173 + if (kthread_should_stop()) { 174 + mutex_unlock(&ir->ir_lock); 175 + return -ENODATA; 176 + } 177 + 180 178 /* 181 179 * Send random "poll command" (?) Windows driver does this 182 180 * and it is a good point to detect chip failure. 183 181 */ 184 - ret = i2c_master_send(&ir->c_rx, sendbuf, 1); 182 + ret = i2c_master_send(rx->c, sendbuf, 1); 185 183 if (ret != 1) { 186 184 zilog_error("i2c_master_send failed with %d\n", ret); 187 185 if (failures >= 3) { ··· 204 186 "trying reset\n"); 205 187 206 188 set_current_state(TASK_UNINTERRUPTIBLE); 189 + if (kthread_should_stop()) { 190 + mutex_unlock(&ir->ir_lock); 191 + return -ENODATA; 192 + } 207 193 schedule_timeout((100 * HZ + 999) / 1000); 208 - ir->need_boot = 1; 194 + ir->tx->need_boot = 1; 209 195 210 196 ++failures; 211 197 mutex_unlock(&ir->ir_lock); 212 198 continue; 213 199 } 214 200 215 - ret = i2c_master_recv(&ir->c_rx, keybuf, sizeof(keybuf)); 201 + if (kthread_should_stop()) { 202 + mutex_unlock(&ir->ir_lock); 203 + return -ENODATA; 204 + } 205 + ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf)); 216 206 mutex_unlock(&ir->ir_lock); 217 207 if (ret != sizeof(keybuf)) { 218 208 zilog_error("i2c_master_recv failed with %d -- " 219 209 "keeping last read buffer\n", ret); 220 210 } else { 221 - ir->b[0] = keybuf[3]; 222 - ir->b[1] = keybuf[4]; 223 - ir->b[2] = keybuf[5]; 224 - dprintk("key (0x%02x/0x%02x)\n", ir->b[0], ir->b[1]); 211 + rx->b[0] = keybuf[3]; 212 + rx->b[1] = keybuf[4]; 213 + rx->b[2] = keybuf[5]; 214 + dprintk("key (0x%02x/0x%02x)\n", rx->b[0], rx->b[1]); 225 215 } 226 216 227 217 /* key pressed ? */ 228 - if (ir->is_hdpvr) { 218 + if (rx->hdpvr_data_fmt) { 229 219 if (got_data && (keybuf[0] == 0x80)) 230 220 return 0; 231 221 else if (got_data && (keybuf[0] == 0x00)) 232 222 return -ENODATA; 233 - } else if ((ir->b[0] & 0x80) == 0) 223 + } else if ((rx->b[0] & 0x80) == 0) 234 224 return got_data ? 0 : -ENODATA; 235 225 236 226 /* look what we have */ 237 - code = (((__u16)ir->b[0] & 0x7f) << 6) | (ir->b[1] >> 2); 227 + code = (((__u16)rx->b[0] & 0x7f) << 6) | (rx->b[1] >> 2); 238 228 239 229 codes[0] = (code >> 8) & 0xff; 240 230 codes[1] = code & 0xff; 241 231 242 232 /* return it */ 243 - lirc_buffer_write(&ir->buf, codes); 233 + lirc_buffer_write(&rx->buf, codes); 244 234 ++got_data; 245 - } while (!lirc_buffer_full(&ir->buf)); 235 + } while (!lirc_buffer_full(&rx->buf)); 246 236 247 237 return 0; 248 238 } ··· 268 242 static int lirc_thread(void *arg) 269 243 { 270 244 struct IR *ir = arg; 271 - 272 - if (ir->t_notify != NULL) 273 - complete(ir->t_notify); 245 + struct IR_rx *rx = ir->rx; 274 246 275 247 dprintk("poll thread started\n"); 276 248 277 - do { 278 - if (ir->open) { 279 - set_current_state(TASK_INTERRUPTIBLE); 249 + while (!kthread_should_stop()) { 250 + set_current_state(TASK_INTERRUPTIBLE); 280 251 281 - /* 282 - * This is ~113*2 + 24 + jitter (2*repeat gap + 283 - * code length). We use this interval as the chip 284 - * resets every time you poll it (bad!). This is 285 - * therefore just sufficient to catch all of the 286 - * button presses. It makes the remote much more 287 - * responsive. You can see the difference by 288 - * running irw and holding down a button. With 289 - * 100ms, the old polling interval, you'll notice 290 - * breaks in the repeat sequence corresponding to 291 - * lost keypresses. 292 - */ 293 - schedule_timeout((260 * HZ) / 1000); 294 - if (ir->shutdown) 295 - break; 296 - if (!add_to_buf(ir)) 297 - wake_up_interruptible(&ir->buf.wait_poll); 298 - } else { 299 - /* if device not opened so we can sleep half a second */ 300 - set_current_state(TASK_INTERRUPTIBLE); 252 + /* if device not opened, we can sleep half a second */ 253 + if (!ir->open) { 301 254 schedule_timeout(HZ/2); 255 + continue; 302 256 } 303 - } while (!ir->shutdown); 304 257 305 - if (ir->t_notify2 != NULL) 306 - wait_for_completion(ir->t_notify2); 307 - 308 - ir->task = NULL; 309 - if (ir->t_notify != NULL) 310 - complete(ir->t_notify); 258 + /* 259 + * This is ~113*2 + 24 + jitter (2*repeat gap + code length). 260 + * We use this interval as the chip resets every time you poll 261 + * it (bad!). This is therefore just sufficient to catch all 262 + * of the button presses. It makes the remote much more 263 + * responsive. You can see the difference by running irw and 264 + * holding down a button. With 100ms, the old polling 265 + * interval, you'll notice breaks in the repeat sequence 266 + * corresponding to lost keypresses. 267 + */ 268 + schedule_timeout((260 * HZ) / 1000); 269 + if (kthread_should_stop()) 270 + break; 271 + if (!add_to_buf(ir)) 272 + wake_up_interruptible(&rx->buf.wait_poll); 273 + } 311 274 312 275 dprintk("poll thread ended\n"); 313 276 return 0; ··· 314 299 * this is completely broken code. lirc_unregister_driver() 315 300 * must be possible even when the device is open 316 301 */ 317 - if (ir->c_rx.addr) 318 - i2c_use_client(&ir->c_rx); 319 - if (ir->c_tx.addr) 320 - i2c_use_client(&ir->c_tx); 302 + if (ir->rx != NULL) 303 + i2c_use_client(ir->rx->c); 304 + if (ir->tx != NULL) 305 + i2c_use_client(ir->tx->c); 321 306 322 307 return 0; 323 308 } ··· 326 311 { 327 312 struct IR *ir = data; 328 313 329 - if (ir->c_rx.addr) 330 - i2c_release_client(&ir->c_rx); 331 - if (ir->c_tx.addr) 332 - i2c_release_client(&ir->c_tx); 314 + if (ir->rx) 315 + i2c_release_client(ir->rx->c); 316 + if (ir->tx) 317 + i2c_release_client(ir->tx->c); 333 318 if (ir->l.owner != NULL) 334 319 module_put(ir->l.owner); 335 320 } ··· 468 453 } 469 454 470 455 /* send a block of data to the IR TX device */ 471 - static int send_data_block(struct IR *ir, unsigned char *data_block) 456 + static int send_data_block(struct IR_tx *tx, unsigned char *data_block) 472 457 { 473 458 int i, j, ret; 474 459 unsigned char buf[5]; ··· 482 467 buf[1 + j] = data_block[i + j]; 483 468 dprintk("%02x %02x %02x %02x %02x", 484 469 buf[0], buf[1], buf[2], buf[3], buf[4]); 485 - ret = i2c_master_send(&ir->c_tx, buf, tosend + 1); 470 + ret = i2c_master_send(tx->c, buf, tosend + 1); 486 471 if (ret != tosend + 1) { 487 472 zilog_error("i2c_master_send failed with %d\n", ret); 488 473 return ret < 0 ? ret : -EFAULT; ··· 493 478 } 494 479 495 480 /* send boot data to the IR TX device */ 496 - static int send_boot_data(struct IR *ir) 481 + static int send_boot_data(struct IR_tx *tx) 497 482 { 498 483 int ret; 499 484 unsigned char buf[4]; 500 485 501 486 /* send the boot block */ 502 - ret = send_data_block(ir, tx_data->boot_data); 487 + ret = send_data_block(tx, tx_data->boot_data); 503 488 if (ret != 0) 504 489 return ret; 505 490 506 491 /* kick it off? */ 507 492 buf[0] = 0x00; 508 493 buf[1] = 0x20; 509 - ret = i2c_master_send(&ir->c_tx, buf, 2); 494 + ret = i2c_master_send(tx->c, buf, 2); 510 495 if (ret != 2) { 511 496 zilog_error("i2c_master_send failed with %d\n", ret); 512 497 return ret < 0 ? ret : -EFAULT; 513 498 } 514 - ret = i2c_master_send(&ir->c_tx, buf, 1); 499 + ret = i2c_master_send(tx->c, buf, 1); 515 500 if (ret != 1) { 516 501 zilog_error("i2c_master_send failed with %d\n", ret); 517 502 return ret < 0 ? ret : -EFAULT; 518 503 } 519 504 520 505 /* Here comes the firmware version... (hopefully) */ 521 - ret = i2c_master_recv(&ir->c_tx, buf, 4); 506 + ret = i2c_master_recv(tx->c, buf, 4); 522 507 if (ret != 4) { 523 508 zilog_error("i2c_master_recv failed with %d\n", ret); 524 509 return 0; ··· 558 543 } 559 544 560 545 /* load "firmware" for the IR TX device */ 561 - static int fw_load(struct IR *ir) 546 + static int fw_load(struct IR_tx *tx) 562 547 { 563 548 int ret; 564 549 unsigned int i; ··· 573 558 } 574 559 575 560 /* Request codeset data file */ 576 - ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &ir->c_tx.dev); 561 + ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c->dev); 577 562 if (ret != 0) { 578 563 zilog_error("firmware haup-ir-blaster.bin not available " 579 564 "(%d)\n", ret); ··· 700 685 } 701 686 702 687 /* initialise the IR TX device */ 703 - static int tx_init(struct IR *ir) 688 + static int tx_init(struct IR_tx *tx) 704 689 { 705 690 int ret; 706 691 707 692 /* Load 'firmware' */ 708 - ret = fw_load(ir); 693 + ret = fw_load(tx); 709 694 if (ret != 0) 710 695 return ret; 711 696 712 697 /* Send boot block */ 713 - ret = send_boot_data(ir); 698 + ret = send_boot_data(tx); 714 699 if (ret != 0) 715 700 return ret; 716 - ir->need_boot = 0; 701 + tx->need_boot = 0; 717 702 718 703 /* Looks good */ 719 704 return 0; ··· 729 714 static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) 730 715 { 731 716 struct IR *ir = filep->private_data; 732 - unsigned char buf[ir->buf.chunk_size]; 717 + struct IR_rx *rx = ir->rx; 733 718 int ret = 0, written = 0; 734 719 DECLARE_WAITQUEUE(wait, current); 735 720 736 721 dprintk("read called\n"); 737 - if (ir->c_rx.addr == 0) 722 + if (rx == NULL) 738 723 return -ENODEV; 739 724 740 - if (mutex_lock_interruptible(&ir->buf_lock)) 725 + if (mutex_lock_interruptible(&rx->buf_lock)) 741 726 return -ERESTARTSYS; 742 727 743 - if (n % ir->buf.chunk_size) { 728 + if (n % rx->buf.chunk_size) { 744 729 dprintk("read result = -EINVAL\n"); 745 - mutex_unlock(&ir->buf_lock); 730 + mutex_unlock(&rx->buf_lock); 746 731 return -EINVAL; 747 732 } 748 733 ··· 751 736 * to avoid losing scan code (in case when queue is awaken somewhere 752 737 * between while condition checking and scheduling) 753 738 */ 754 - add_wait_queue(&ir->buf.wait_poll, &wait); 739 + add_wait_queue(&rx->buf.wait_poll, &wait); 755 740 set_current_state(TASK_INTERRUPTIBLE); 756 741 757 742 /* ··· 759 744 * mode and 'copy_to_user' is happy, wait for data. 760 745 */ 761 746 while (written < n && ret == 0) { 762 - if (lirc_buffer_empty(&ir->buf)) { 747 + if (lirc_buffer_empty(&rx->buf)) { 763 748 /* 764 749 * According to the read(2) man page, 'written' can be 765 750 * returned as less than 'n', instead of blocking ··· 779 764 schedule(); 780 765 set_current_state(TASK_INTERRUPTIBLE); 781 766 } else { 782 - lirc_buffer_read(&ir->buf, buf); 767 + unsigned char buf[rx->buf.chunk_size]; 768 + lirc_buffer_read(&rx->buf, buf); 783 769 ret = copy_to_user((void *)outbuf+written, buf, 784 - ir->buf.chunk_size); 785 - written += ir->buf.chunk_size; 770 + rx->buf.chunk_size); 771 + written += rx->buf.chunk_size; 786 772 } 787 773 } 788 774 789 - remove_wait_queue(&ir->buf.wait_poll, &wait); 775 + remove_wait_queue(&rx->buf.wait_poll, &wait); 790 776 set_current_state(TASK_RUNNING); 791 - mutex_unlock(&ir->buf_lock); 777 + mutex_unlock(&rx->buf_lock); 792 778 793 779 dprintk("read result = %s (%d)\n", 794 780 ret ? "-EFAULT" : "OK", ret); ··· 798 782 } 799 783 800 784 /* send a keypress to the IR TX device */ 801 - static int send_code(struct IR *ir, unsigned int code, unsigned int key) 785 + static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) 802 786 { 803 787 unsigned char data_block[TX_BLOCK_SIZE]; 804 788 unsigned char buf[2]; ··· 815 799 return ret; 816 800 817 801 /* Send the data block */ 818 - ret = send_data_block(ir, data_block); 802 + ret = send_data_block(tx, data_block); 819 803 if (ret != 0) 820 804 return ret; 821 805 822 806 /* Send data block length? */ 823 807 buf[0] = 0x00; 824 808 buf[1] = 0x40; 825 - ret = i2c_master_send(&ir->c_tx, buf, 2); 809 + ret = i2c_master_send(tx->c, buf, 2); 826 810 if (ret != 2) { 827 811 zilog_error("i2c_master_send failed with %d\n", ret); 828 812 return ret < 0 ? ret : -EFAULT; 829 813 } 830 - ret = i2c_master_send(&ir->c_tx, buf, 1); 814 + ret = i2c_master_send(tx->c, buf, 1); 831 815 if (ret != 1) { 832 816 zilog_error("i2c_master_send failed with %d\n", ret); 833 817 return ret < 0 ? ret : -EFAULT; 834 818 } 835 819 836 820 /* Send finished download? */ 837 - ret = i2c_master_recv(&ir->c_tx, buf, 1); 821 + ret = i2c_master_recv(tx->c, buf, 1); 838 822 if (ret != 1) { 839 823 zilog_error("i2c_master_recv failed with %d\n", ret); 840 824 return ret < 0 ? ret : -EFAULT; ··· 848 832 /* Send prepare command? */ 849 833 buf[0] = 0x00; 850 834 buf[1] = 0x80; 851 - ret = i2c_master_send(&ir->c_tx, buf, 2); 835 + ret = i2c_master_send(tx->c, buf, 2); 852 836 if (ret != 2) { 853 837 zilog_error("i2c_master_send failed with %d\n", ret); 854 838 return ret < 0 ? ret : -EFAULT; ··· 859 843 * last i2c_master_recv always fails with a -5, so for now, we're 860 844 * going to skip this whole mess and say we're done on the HD PVR 861 845 */ 862 - if (ir->is_hdpvr) { 846 + if (!tx->post_tx_ready_poll) { 863 847 dprintk("sent code %u, key %u\n", code, key); 864 848 return 0; 865 849 } ··· 873 857 for (i = 0; i < 20; ++i) { 874 858 set_current_state(TASK_UNINTERRUPTIBLE); 875 859 schedule_timeout((50 * HZ + 999) / 1000); 876 - ret = i2c_master_send(&ir->c_tx, buf, 1); 860 + ret = i2c_master_send(tx->c, buf, 1); 877 861 if (ret == 1) 878 862 break; 879 863 dprintk("NAK expected: i2c_master_send " ··· 886 870 } 887 871 888 872 /* Seems to be an 'ok' response */ 889 - i = i2c_master_recv(&ir->c_tx, buf, 1); 873 + i = i2c_master_recv(tx->c, buf, 1); 890 874 if (i != 1) { 891 875 zilog_error("i2c_master_recv failed with %d\n", ret); 892 876 return -EFAULT; ··· 911 895 loff_t *ppos) 912 896 { 913 897 struct IR *ir = filep->private_data; 898 + struct IR_tx *tx = ir->tx; 914 899 size_t i; 915 900 int failures = 0; 916 901 917 - if (ir->c_tx.addr == 0) 902 + if (tx == NULL) 918 903 return -ENODEV; 919 904 920 905 /* Validate user parameters */ ··· 936 919 } 937 920 938 921 /* Send boot data first if required */ 939 - if (ir->need_boot == 1) { 940 - ret = send_boot_data(ir); 922 + if (tx->need_boot == 1) { 923 + ret = send_boot_data(tx); 941 924 if (ret == 0) 942 - ir->need_boot = 0; 925 + tx->need_boot = 0; 943 926 } 944 927 945 928 /* Send the code */ 946 929 if (ret == 0) { 947 - ret = send_code(ir, (unsigned)command >> 16, 930 + ret = send_code(tx, (unsigned)command >> 16, 948 931 (unsigned)command & 0xFFFF); 949 932 if (ret == -EPROTO) { 950 933 mutex_unlock(&ir->ir_lock); ··· 969 952 } 970 953 set_current_state(TASK_UNINTERRUPTIBLE); 971 954 schedule_timeout((100 * HZ + 999) / 1000); 972 - ir->need_boot = 1; 955 + tx->need_boot = 1; 973 956 ++failures; 974 957 } else 975 958 i += sizeof(int); ··· 986 969 static unsigned int poll(struct file *filep, poll_table *wait) 987 970 { 988 971 struct IR *ir = filep->private_data; 972 + struct IR_rx *rx = ir->rx; 989 973 unsigned int ret; 990 974 991 975 dprintk("poll called\n"); 992 - if (ir->c_rx.addr == 0) 976 + if (rx == NULL) 993 977 return -ENODEV; 994 978 995 - mutex_lock(&ir->buf_lock); 979 + mutex_lock(&rx->buf_lock); 996 980 997 - poll_wait(filep, &ir->buf.wait_poll, wait); 981 + poll_wait(filep, &rx->buf.wait_poll, wait); 998 982 999 983 dprintk("poll result = %s\n", 1000 - lirc_buffer_empty(&ir->buf) ? "0" : "POLLIN|POLLRDNORM"); 984 + lirc_buffer_empty(&rx->buf) ? "0" : "POLLIN|POLLRDNORM"); 1001 985 1002 - ret = lirc_buffer_empty(&ir->buf) ? 0 : (POLLIN|POLLRDNORM); 986 + ret = lirc_buffer_empty(&rx->buf) ? 0 : (POLLIN|POLLRDNORM); 1003 987 1004 - mutex_unlock(&ir->buf_lock); 988 + mutex_unlock(&rx->buf_lock); 1005 989 return ret; 1006 990 } 1007 991 ··· 1012 994 int result; 1013 995 unsigned long mode, features = 0; 1014 996 1015 - if (ir->c_rx.addr != 0) 997 + features |= LIRC_CAN_SEND_PULSE; 998 + if (ir->rx != NULL) 1016 999 features |= LIRC_CAN_REC_LIRCCODE; 1017 - if (ir->c_tx.addr != 0) 1018 - features |= LIRC_CAN_SEND_PULSE; 1019 1000 1020 1001 switch (cmd) { 1021 1002 case LIRC_GET_LENGTH: ··· 1041 1024 result = -EINVAL; 1042 1025 break; 1043 1026 case LIRC_GET_SEND_MODE: 1044 - if (!(features&LIRC_CAN_SEND_MASK)) 1045 - return -ENOSYS; 1046 - 1047 1027 result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); 1048 1028 break; 1049 1029 case LIRC_SET_SEND_MODE: 1050 - if (!(features&LIRC_CAN_SEND_MASK)) 1051 - return -ENOSYS; 1052 - 1053 1030 result = get_user(mode, (unsigned long *) arg); 1054 1031 if (!result && mode != LIRC_MODE_PULSE) 1055 1032 return -EINVAL; ··· 1054 1043 return result; 1055 1044 } 1056 1045 1046 + /* ir_devices_lock must be held */ 1047 + static struct IR *find_ir_device_by_minor(unsigned int minor) 1048 + { 1049 + if (minor >= MAX_IRCTL_DEVICES) 1050 + return NULL; 1051 + 1052 + return ir_devices[minor]; 1053 + } 1054 + 1057 1055 /* 1058 1056 * Open the IR device. Get hold of our IR structure and 1059 1057 * stash it in private_data for the file ··· 1071 1051 { 1072 1052 struct IR *ir; 1073 1053 int ret; 1054 + unsigned int minor = MINOR(node->i_rdev); 1074 1055 1075 1056 /* find our IR struct */ 1076 - unsigned minor = MINOR(node->i_rdev); 1077 - if (minor >= MAX_IRCTL_DEVICES) { 1078 - dprintk("minor %d: open result = -ENODEV\n", 1079 - minor); 1057 + mutex_lock(&ir_devices_lock); 1058 + ir = find_ir_device_by_minor(minor); 1059 + mutex_unlock(&ir_devices_lock); 1060 + 1061 + if (ir == NULL) 1080 1062 return -ENODEV; 1081 - } 1082 - ir = ir_devices[minor]; 1083 1063 1084 1064 /* increment in use count */ 1085 1065 mutex_lock(&ir->ir_lock); ··· 1126 1106 1127 1107 static int ir_remove(struct i2c_client *client); 1128 1108 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id); 1129 - static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg); 1130 1109 1131 1110 #define ID_FLAG_TX 0x01 1132 1111 #define ID_FLAG_HDPVR 0x02 ··· 1145 1126 }, 1146 1127 .probe = ir_probe, 1147 1128 .remove = ir_remove, 1148 - .command = ir_command, 1149 1129 .id_table = ir_transceiver_id, 1150 1130 }; 1151 1131 ··· 1162 1144 .release = close 1163 1145 }; 1164 1146 1147 + static void destroy_rx_kthread(struct IR_rx *rx) 1148 + { 1149 + /* end up polling thread */ 1150 + if (rx != NULL && !IS_ERR_OR_NULL(rx->task)) { 1151 + kthread_stop(rx->task); 1152 + rx->task = NULL; 1153 + } 1154 + } 1155 + 1156 + /* ir_devices_lock must be held */ 1157 + static int add_ir_device(struct IR *ir) 1158 + { 1159 + int i; 1160 + 1161 + for (i = 0; i < MAX_IRCTL_DEVICES; i++) 1162 + if (ir_devices[i] == NULL) { 1163 + ir_devices[i] = ir; 1164 + break; 1165 + } 1166 + 1167 + return i == MAX_IRCTL_DEVICES ? -ENOMEM : i; 1168 + } 1169 + 1170 + /* ir_devices_lock must be held */ 1171 + static void del_ir_device(struct IR *ir) 1172 + { 1173 + int i; 1174 + 1175 + for (i = 0; i < MAX_IRCTL_DEVICES; i++) 1176 + if (ir_devices[i] == ir) { 1177 + ir_devices[i] = NULL; 1178 + break; 1179 + } 1180 + } 1181 + 1165 1182 static int ir_remove(struct i2c_client *client) 1166 1183 { 1167 1184 struct IR *ir = i2c_get_clientdata(client); 1168 1185 1169 - mutex_lock(&ir->ir_lock); 1186 + mutex_lock(&ir_devices_lock); 1170 1187 1171 - if (ir->have_rx || ir->have_tx) { 1172 - DECLARE_COMPLETION(tn); 1173 - DECLARE_COMPLETION(tn2); 1174 - 1175 - /* end up polling thread */ 1176 - if (ir->task && !IS_ERR(ir->task)) { 1177 - ir->t_notify = &tn; 1178 - ir->t_notify2 = &tn2; 1179 - ir->shutdown = 1; 1180 - wake_up_process(ir->task); 1181 - complete(&tn2); 1182 - wait_for_completion(&tn); 1183 - ir->t_notify = NULL; 1184 - ir->t_notify2 = NULL; 1185 - } 1186 - 1187 - } else { 1188 - mutex_unlock(&ir->ir_lock); 1189 - zilog_error("%s: detached from something we didn't " 1190 - "attach to\n", __func__); 1191 - return -ENODEV; 1188 + if (ir == NULL) { 1189 + /* We destroyed everything when the first client came through */ 1190 + mutex_unlock(&ir_devices_lock); 1191 + return 0; 1192 1192 } 1193 1193 1194 - /* unregister lirc driver */ 1195 - if (ir->l.minor >= 0 && ir->l.minor < MAX_IRCTL_DEVICES) { 1196 - lirc_unregister_driver(ir->l.minor); 1197 - ir_devices[ir->l.minor] = NULL; 1194 + /* Good-bye LIRC */ 1195 + lirc_unregister_driver(ir->l.minor); 1196 + 1197 + /* Good-bye Rx */ 1198 + destroy_rx_kthread(ir->rx); 1199 + if (ir->rx != NULL) { 1200 + if (ir->rx->buf.fifo_initialized) 1201 + lirc_buffer_free(&ir->rx->buf); 1202 + i2c_set_clientdata(ir->rx->c, NULL); 1203 + kfree(ir->rx); 1198 1204 } 1199 1205 1200 - /* free memory */ 1201 - lirc_buffer_free(&ir->buf); 1202 - mutex_unlock(&ir->ir_lock); 1206 + /* Good-bye Tx */ 1207 + i2c_set_clientdata(ir->tx->c, NULL); 1208 + kfree(ir->tx); 1209 + 1210 + /* Good-bye IR */ 1211 + del_ir_device(ir); 1203 1212 kfree(ir); 1204 1213 1214 + mutex_unlock(&ir_devices_lock); 1205 1215 return 0; 1216 + } 1217 + 1218 + 1219 + /* ir_devices_lock must be held */ 1220 + static struct IR *find_ir_device_by_adapter(struct i2c_adapter *adapter) 1221 + { 1222 + int i; 1223 + struct IR *ir = NULL; 1224 + 1225 + for (i = 0; i < MAX_IRCTL_DEVICES; i++) 1226 + if (ir_devices[i] != NULL && 1227 + ir_devices[i]->adapter == adapter) { 1228 + ir = ir_devices[i]; 1229 + break; 1230 + } 1231 + 1232 + return ir; 1206 1233 } 1207 1234 1208 1235 static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) 1209 1236 { 1210 - struct IR *ir = NULL; 1237 + struct IR *ir; 1211 1238 struct i2c_adapter *adap = client->adapter; 1212 - char buf; 1213 1239 int ret; 1214 - int have_rx = 0, have_tx = 0; 1240 + bool tx_probe = false; 1215 1241 1216 - dprintk("%s: adapter name (%s) nr %d, i2c_device_id name (%s), " 1217 - "client addr=0x%02x\n", 1218 - __func__, adap->name, adap->nr, id->name, client->addr); 1242 + dprintk("%s: %s on i2c-%d (%s), client addr=0x%02x\n", 1243 + __func__, id->name, adap->nr, adap->name, client->addr); 1219 1244 1220 1245 /* 1221 - * FIXME - This probe function probes both the Tx and Rx 1222 - * addresses of the IR microcontroller. 1223 - * 1224 - * However, the I2C subsystem is passing along one I2C client at a 1225 - * time, based on matches to the ir_transceiver_id[] table above. 1226 - * The expectation is that each i2c_client address will be probed 1227 - * individually by drivers so the I2C subsystem can mark all client 1228 - * addresses as claimed or not. 1229 - * 1230 - * This probe routine causes only one of the client addresses, TX or RX, 1231 - * to be claimed. This will cause a problem if the I2C subsystem is 1232 - * subsequently triggered to probe unclaimed clients again. 1246 + * The IR receiver is at i2c address 0x71. 1247 + * The IR transmitter is at i2c address 0x70. 1233 1248 */ 1234 - /* 1235 - * The external IR receiver is at i2c address 0x71. 1236 - * The IR transmitter is at 0x70. 1237 - */ 1238 - client->addr = 0x70; 1239 1249 1240 - if (!disable_tx) { 1241 - if (i2c_master_recv(client, &buf, 1) == 1) 1242 - have_tx = 1; 1243 - dprintk("probe 0x70 @ %s: %s\n", 1244 - adap->name, have_tx ? "success" : "failed"); 1250 + if (id->driver_data & ID_FLAG_TX) 1251 + tx_probe = true; 1252 + else if (tx_only) /* module option */ 1253 + return -ENXIO; 1254 + 1255 + zilog_info("probing IR %s on %s (i2c-%d)\n", 1256 + tx_probe ? "Tx" : "Rx", adap->name, adap->nr); 1257 + 1258 + mutex_lock(&ir_devices_lock); 1259 + 1260 + /* Use a single struct IR instance for both the Rx and Tx functions */ 1261 + ir = find_ir_device_by_adapter(adap); 1262 + if (ir == NULL) { 1263 + ir = kzalloc(sizeof(struct IR), GFP_KERNEL); 1264 + if (ir == NULL) { 1265 + ret = -ENOMEM; 1266 + goto out_no_ir; 1267 + } 1268 + /* store for use in ir_probe() again, and open() later on */ 1269 + ret = add_ir_device(ir); 1270 + if (ret) 1271 + goto out_free_ir; 1272 + 1273 + ir->adapter = adap; 1274 + mutex_init(&ir->ir_lock); 1275 + 1276 + /* set lirc_dev stuff */ 1277 + memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver)); 1278 + ir->l.minor = minor; /* module option */ 1279 + ir->l.code_length = 13; 1280 + ir->l.rbuf = NULL; 1281 + ir->l.fops = &lirc_fops; 1282 + ir->l.data = ir; 1283 + ir->l.dev = &adap->dev; 1284 + ir->l.sample_rate = 0; 1245 1285 } 1246 1286 1247 - if (!disable_rx) { 1248 - client->addr = 0x71; 1249 - if (i2c_master_recv(client, &buf, 1) == 1) 1250 - have_rx = 1; 1251 - dprintk("probe 0x71 @ %s: %s\n", 1252 - adap->name, have_rx ? "success" : "failed"); 1287 + if (tx_probe) { 1288 + /* Set up a struct IR_tx instance */ 1289 + ir->tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL); 1290 + if (ir->tx == NULL) { 1291 + ret = -ENOMEM; 1292 + goto out_free_xx; 1293 + } 1294 + 1295 + ir->tx->c = client; 1296 + ir->tx->need_boot = 1; 1297 + ir->tx->post_tx_ready_poll = 1298 + (id->driver_data & ID_FLAG_HDPVR) ? false : true; 1299 + } else { 1300 + /* Set up a struct IR_rx instance */ 1301 + ir->rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL); 1302 + if (ir->rx == NULL) { 1303 + ret = -ENOMEM; 1304 + goto out_free_xx; 1305 + } 1306 + 1307 + ret = lirc_buffer_init(&ir->rx->buf, 2, BUFLEN / 2); 1308 + if (ret) 1309 + goto out_free_xx; 1310 + 1311 + mutex_init(&ir->rx->buf_lock); 1312 + ir->rx->c = client; 1313 + ir->rx->hdpvr_data_fmt = 1314 + (id->driver_data & ID_FLAG_HDPVR) ? true : false; 1315 + 1316 + /* set lirc_dev stuff */ 1317 + ir->l.rbuf = &ir->rx->buf; 1253 1318 } 1254 1319 1255 - if (!(have_rx || have_tx)) { 1256 - zilog_error("%s: no devices found\n", adap->name); 1257 - goto out_nodev; 1258 - } 1259 - 1260 - printk(KERN_INFO "lirc_zilog: chip found with %s\n", 1261 - have_rx && have_tx ? "RX and TX" : 1262 - have_rx ? "RX only" : "TX only"); 1263 - 1264 - ir = kzalloc(sizeof(struct IR), GFP_KERNEL); 1265 - 1266 - if (!ir) 1267 - goto out_nomem; 1268 - 1269 - ret = lirc_buffer_init(&ir->buf, 2, BUFLEN / 2); 1270 - if (ret) 1271 - goto out_nomem; 1272 - 1273 - mutex_init(&ir->ir_lock); 1274 - mutex_init(&ir->buf_lock); 1275 - ir->need_boot = 1; 1276 - ir->is_hdpvr = (id->driver_data & ID_FLAG_HDPVR) ? true : false; 1277 - 1278 - memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver)); 1279 - ir->l.minor = -1; 1280 - 1281 - /* I2C attach to device */ 1282 1320 i2c_set_clientdata(client, ir); 1283 1321 1322 + /* Proceed only if we have the required Tx and Rx clients ready to go */ 1323 + if (ir->tx == NULL || 1324 + (ir->rx == NULL && !tx_only)) { 1325 + zilog_info("probe of IR %s on %s (i2c-%d) done. Waiting on " 1326 + "IR %s.\n", tx_probe ? "Tx" : "Rx", adap->name, 1327 + adap->nr, tx_probe ? "Rx" : "Tx"); 1328 + goto out_ok; 1329 + } 1330 + 1284 1331 /* initialise RX device */ 1285 - if (have_rx) { 1286 - DECLARE_COMPLETION(tn); 1287 - memcpy(&ir->c_rx, client, sizeof(struct i2c_client)); 1288 - 1289 - ir->c_rx.addr = 0x71; 1290 - strlcpy(ir->c_rx.name, ZILOG_HAUPPAUGE_IR_RX_NAME, 1291 - I2C_NAME_SIZE); 1292 - 1332 + if (ir->rx != NULL) { 1293 1333 /* try to fire up polling thread */ 1294 - ir->t_notify = &tn; 1295 - ir->task = kthread_run(lirc_thread, ir, "lirc_zilog"); 1296 - if (IS_ERR(ir->task)) { 1297 - ret = PTR_ERR(ir->task); 1298 - zilog_error("lirc_register_driver: cannot run " 1299 - "poll thread %d\n", ret); 1300 - goto err; 1334 + ir->rx->task = kthread_run(lirc_thread, ir, 1335 + "zilog-rx-i2c-%d", adap->nr); 1336 + if (IS_ERR(ir->rx->task)) { 1337 + ret = PTR_ERR(ir->rx->task); 1338 + zilog_error("%s: could not start IR Rx polling thread" 1339 + "\n", __func__); 1340 + goto out_free_xx; 1301 1341 } 1302 - wait_for_completion(&tn); 1303 - ir->t_notify = NULL; 1304 - ir->have_rx = 1; 1305 1342 } 1306 - 1307 - /* initialise TX device */ 1308 - if (have_tx) { 1309 - memcpy(&ir->c_tx, client, sizeof(struct i2c_client)); 1310 - ir->c_tx.addr = 0x70; 1311 - strlcpy(ir->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME, 1312 - I2C_NAME_SIZE); 1313 - ir->have_tx = 1; 1314 - } 1315 - 1316 - /* set lirc_dev stuff */ 1317 - ir->l.code_length = 13; 1318 - ir->l.rbuf = &ir->buf; 1319 - ir->l.fops = &lirc_fops; 1320 - ir->l.data = ir; 1321 - ir->l.minor = minor; 1322 - ir->l.dev = &adap->dev; 1323 - ir->l.sample_rate = 0; 1324 1343 1325 1344 /* register with lirc */ 1326 1345 ir->l.minor = lirc_register_driver(&ir->l); 1327 1346 if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) { 1328 - zilog_error("ir_attach: \"minor\" must be between 0 and %d " 1329 - "(%d)!\n", MAX_IRCTL_DEVICES-1, ir->l.minor); 1347 + zilog_error("%s: \"minor\" must be between 0 and %d (%d)!\n", 1348 + __func__, MAX_IRCTL_DEVICES-1, ir->l.minor); 1330 1349 ret = -EBADRQC; 1331 - goto err; 1350 + goto out_free_thread; 1332 1351 } 1333 - 1334 - /* store this for getting back in open() later on */ 1335 - ir_devices[ir->l.minor] = ir; 1336 1352 1337 1353 /* 1338 1354 * if we have the tx device, load the 'firmware'. We do this 1339 1355 * after registering with lirc as otherwise hotplug seems to take 1340 1356 * 10s to create the lirc device. 1341 1357 */ 1342 - if (have_tx) { 1343 - /* Special TX init */ 1344 - ret = tx_init(ir); 1345 - if (ret != 0) 1346 - goto err; 1358 + ret = tx_init(ir->tx); 1359 + if (ret != 0) 1360 + goto out_unregister; 1361 + 1362 + zilog_info("probe of IR %s on %s (i2c-%d) done. IR unit ready.\n", 1363 + tx_probe ? "Tx" : "Rx", adap->name, adap->nr); 1364 + out_ok: 1365 + mutex_unlock(&ir_devices_lock); 1366 + return 0; 1367 + 1368 + out_unregister: 1369 + lirc_unregister_driver(ir->l.minor); 1370 + out_free_thread: 1371 + destroy_rx_kthread(ir->rx); 1372 + out_free_xx: 1373 + if (ir->rx != NULL) { 1374 + if (ir->rx->buf.fifo_initialized) 1375 + lirc_buffer_free(&ir->rx->buf); 1376 + if (ir->rx->c != NULL) 1377 + i2c_set_clientdata(ir->rx->c, NULL); 1378 + kfree(ir->rx); 1347 1379 } 1348 - 1349 - return 0; 1350 - 1351 - err: 1352 - /* undo everything, hopefully... */ 1353 - if (ir->c_rx.addr) 1354 - ir_remove(&ir->c_rx); 1355 - if (ir->c_tx.addr) 1356 - ir_remove(&ir->c_tx); 1357 - return ret; 1358 - 1359 - out_nodev: 1360 - zilog_error("no device found\n"); 1361 - return -ENODEV; 1362 - 1363 - out_nomem: 1364 - zilog_error("memory allocation failure\n"); 1380 + if (ir->tx != NULL) { 1381 + if (ir->tx->c != NULL) 1382 + i2c_set_clientdata(ir->tx->c, NULL); 1383 + kfree(ir->tx); 1384 + } 1385 + out_free_ir: 1386 + del_ir_device(ir); 1365 1387 kfree(ir); 1366 - return -ENOMEM; 1367 - } 1368 - 1369 - static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg) 1370 - { 1371 - /* nothing */ 1372 - return 0; 1388 + out_no_ir: 1389 + zilog_error("%s: probing IR %s on %s (i2c-%d) failed with %d\n", 1390 + __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr, 1391 + ret); 1392 + mutex_unlock(&ir_devices_lock); 1393 + return ret; 1373 1394 } 1374 1395 1375 1396 static int __init zilog_init(void) ··· 1418 1361 zilog_notify("Zilog/Hauppauge IR driver initializing\n"); 1419 1362 1420 1363 mutex_init(&tx_data_lock); 1364 + mutex_init(&ir_devices_lock); 1421 1365 1422 1366 request_module("firmware_class"); 1423 1367 ··· 1444 1386 1445 1387 MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)"); 1446 1388 MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, " 1447 - "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver"); 1389 + "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver, " 1390 + "Andy Walls"); 1448 1391 MODULE_LICENSE("GPL"); 1449 1392 /* for compat with old name, which isn't all that accurate anymore */ 1450 1393 MODULE_ALIAS("lirc_pvr150"); ··· 1456 1397 module_param(debug, bool, 0644); 1457 1398 MODULE_PARM_DESC(debug, "Enable debugging messages"); 1458 1399 1459 - module_param(disable_rx, bool, 0644); 1460 - MODULE_PARM_DESC(disable_rx, "Disable the IR receiver device"); 1461 - 1462 - module_param(disable_tx, bool, 0644); 1463 - MODULE_PARM_DESC(disable_tx, "Disable the IR transmitter device"); 1400 + module_param(tx_only, bool, 0644); 1401 + MODULE_PARM_DESC(tx_only, "Only handle the IR transmit function");
+37 -11
drivers/staging/tm6000/tm6000-video.c
··· 1450 1450 * ------------------------------------------------------------------ 1451 1451 */ 1452 1452 1453 - int tm6000_v4l2_register(struct tm6000_core *dev) 1453 + static struct video_device *vdev_init(struct tm6000_core *dev, 1454 + const struct video_device 1455 + *template, const char *type_name) 1454 1456 { 1455 - int ret = -1; 1456 1457 struct video_device *vfd; 1457 1458 1458 1459 vfd = video_device_alloc(); 1459 - if(!vfd) { 1460 + if (NULL == vfd) 1461 + return NULL; 1462 + 1463 + *vfd = *template; 1464 + vfd->v4l2_dev = &dev->v4l2_dev; 1465 + vfd->release = video_device_release; 1466 + vfd->debug = tm6000_debug; 1467 + vfd->lock = &dev->lock; 1468 + 1469 + snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); 1470 + 1471 + video_set_drvdata(vfd, dev); 1472 + return vfd; 1473 + } 1474 + 1475 + int tm6000_v4l2_register(struct tm6000_core *dev) 1476 + { 1477 + int ret = -1; 1478 + 1479 + dev->vfd = vdev_init(dev, &tm6000_template, "video"); 1480 + 1481 + if (!dev->vfd) { 1482 + printk(KERN_INFO "%s: can't register video device\n", 1483 + dev->name); 1460 1484 return -ENOMEM; 1461 1485 } 1462 - dev->vfd = vfd; 1463 1486 1464 1487 /* init video dma queues */ 1465 1488 INIT_LIST_HEAD(&dev->vidq.active); 1466 1489 INIT_LIST_HEAD(&dev->vidq.queued); 1467 1490 1468 - memcpy(dev->vfd, &tm6000_template, sizeof(*(dev->vfd))); 1469 - dev->vfd->debug = tm6000_debug; 1470 - dev->vfd->lock = &dev->lock; 1471 - 1472 - vfd->v4l2_dev = &dev->v4l2_dev; 1473 - video_set_drvdata(vfd, dev); 1474 - 1475 1491 ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr); 1492 + 1493 + if (ret < 0) { 1494 + printk(KERN_INFO "%s: can't register video device\n", 1495 + dev->name); 1496 + return ret; 1497 + } 1498 + 1499 + printk(KERN_INFO "%s: registered device %s\n", 1500 + dev->name, video_device_node_name(dev->vfd)); 1501 + 1476 1502 printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); 1477 1503 return ret; 1478 1504 }
+17
include/media/mt9v011.h
··· 1 + /* mt9v011 sensor 2 + * 3 + * Copyright (C) 2011 Hans Verkuil <hverkuil@xs4all.nl> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #ifndef __MT9V011_H__ 11 + #define __MT9V011_H__ 12 + 13 + struct mt9v011_platform_data { 14 + unsigned xtal; /* Hz */ 15 + }; 16 + 17 + #endif
+3
include/media/rc-core.h
··· 183 183 } 184 184 185 185 #define IR_MAX_DURATION 0xFFFFFFFF /* a bit more than 4 seconds */ 186 + #define US_TO_NS(usec) ((usec) * 1000) 187 + #define MS_TO_US(msec) ((msec) * 1000) 188 + #define MS_TO_NS(msec) ((msec) * 1000 * 1000) 186 189 187 190 void ir_raw_event_handle(struct rc_dev *dev); 188 191 int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
+1 -1
include/media/saa7146.h
··· 115 115 116 116 /* different device locks */ 117 117 spinlock_t slock; 118 - struct mutex lock; 118 + struct mutex v4l2_lock; 119 119 120 120 unsigned char __iomem *mem; /* pointer to mapped IO memory */ 121 121 u32 revision; /* chip revision; needed for bug-workarounds*/
+1 -12
include/media/v4l2-common.h
··· 138 138 139 139 /* Load an i2c module and return an initialized v4l2_subdev struct. 140 140 The client_type argument is the name of the chip that's on the adapter. */ 141 - struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 141 + struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, 142 142 struct i2c_adapter *adapter, const char *client_type, 143 - int irq, void *platform_data, 144 143 u8 addr, const unsigned short *probe_addrs); 145 - 146 - /* Load an i2c module and return an initialized v4l2_subdev struct. 147 - The client_type argument is the name of the chip that's on the adapter. */ 148 - static inline struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, 149 - struct i2c_adapter *adapter, const char *client_type, 150 - u8 addr, const unsigned short *probe_addrs) 151 - { 152 - return v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, client_type, 0, NULL, 153 - addr, probe_addrs); 154 - } 155 144 156 145 struct i2c_board_info; 157 146
+5 -2
include/media/v4l2-ctrls.h
··· 23 23 24 24 #include <linux/list.h> 25 25 #include <linux/device.h> 26 + #include <linux/videodev2.h> 26 27 27 28 /* forward references */ 28 29 struct v4l2_ctrl_handler; ··· 54 53 * @handler: The handler that owns the control. 55 54 * @cluster: Point to start of cluster array. 56 55 * @ncontrols: Number of controls in cluster array. 57 - * @has_new: Internal flag: set when there is a valid new value. 58 56 * @done: Internal flag: set for each processed control. 57 + * @is_new: Set when the user specified a new value for this control. It 58 + * is also set when called from v4l2_ctrl_handler_setup. Drivers 59 + * should never set this flag. 59 60 * @is_private: If set, then this control is private to its handler and it 60 61 * will not be added to any other handlers. Drivers can set 61 62 * this flag. ··· 100 97 struct v4l2_ctrl_handler *handler; 101 98 struct v4l2_ctrl **cluster; 102 99 unsigned ncontrols; 103 - unsigned int has_new:1; 104 100 unsigned int done:1; 105 101 102 + unsigned int is_new:1; 106 103 unsigned int is_private:1; 107 104 unsigned int is_volatile:1; 108 105
+18 -5
include/media/v4l2-subdev.h
··· 106 106 u8 strength; /* Pin drive strength */ 107 107 }; 108 108 109 - /* s_config: if set, then it is always called by the v4l2_i2c_new_subdev* 110 - functions after the v4l2_subdev was registered. It is used to pass 111 - platform data to the subdev which can be used during initialization. 112 - 109 + /* 113 110 s_io_pin_config: configure one or more chip I/O pins for chips that 114 111 multiplex different internal signal pads out to IO pins. This function 115 112 takes a pointer to an array of 'n' pin configuration entries, one for ··· 138 141 struct v4l2_subdev_core_ops { 139 142 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 140 143 int (*log_status)(struct v4l2_subdev *sd); 141 - int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data); 142 144 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n, 143 145 struct v4l2_subdev_io_pin_config *pincfg); 144 146 int (*init)(struct v4l2_subdev *sd, u32 val); ··· 411 415 const struct v4l2_subdev_sensor_ops *sensor; 412 416 }; 413 417 418 + /* 419 + * Internal ops. Never call this from drivers, only the v4l2 framework can call 420 + * these ops. 421 + * 422 + * registered: called when this subdev is registered. When called the v4l2_dev 423 + * field is set to the correct v4l2_device. 424 + * 425 + * unregistered: called when this subdev is unregistered. When called the 426 + * v4l2_dev field is still set to the correct v4l2_device. 427 + */ 428 + struct v4l2_subdev_internal_ops { 429 + int (*registered)(struct v4l2_subdev *sd); 430 + void (*unregistered)(struct v4l2_subdev *sd); 431 + }; 432 + 414 433 #define V4L2_SUBDEV_NAME_SIZE 32 415 434 416 435 /* Set this flag if this subdev is a i2c device. */ ··· 442 431 u32 flags; 443 432 struct v4l2_device *v4l2_dev; 444 433 const struct v4l2_subdev_ops *ops; 434 + /* Never call these internal ops from within a driver! */ 435 + const struct v4l2_subdev_internal_ops *internal_ops; 445 436 /* The control handler of this subdev. May be NULL. */ 446 437 struct v4l2_ctrl_handler *ctrl_handler; 447 438 /* name must be unique */