diff options
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-cards.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 6a67c2dca9a0..096d007efd4a 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -243,8 +243,6 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) | |||
243 | 243 | ||
244 | } | 244 | } |
245 | 245 | ||
246 | #if 0 | ||
247 | |||
248 | static void cx231xx_config_tuner(struct cx231xx *dev) | 246 | static void cx231xx_config_tuner(struct cx231xx *dev) |
249 | { | 247 | { |
250 | struct tuner_setup tun_setup; | 248 | struct tuner_setup tun_setup; |
@@ -258,8 +256,8 @@ static void cx231xx_config_tuner(struct cx231xx *dev) | |||
258 | tun_setup.addr = dev->tuner_addr; | 256 | tun_setup.addr = dev->tuner_addr; |
259 | tun_setup.tuner_callback = cx231xx_tuner_callback; | 257 | tun_setup.tuner_callback = cx231xx_tuner_callback; |
260 | 258 | ||
261 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR, | 259 | tuner_call(dev, tuner, s_type_addr, &tun_setup); |
262 | &tun_setup); | 260 | |
263 | #if 0 | 261 | #if 0 |
264 | if (tun_setup.type == TUNER_XC5000) { | 262 | if (tun_setup.type == TUNER_XC5000) { |
265 | static struct xc2028_ctrl ctrl = { | 263 | static struct xc2028_ctrl ctrl = { |
@@ -271,20 +269,17 @@ static void cx231xx_config_tuner(struct cx231xx *dev) | |||
271 | .tuner = dev->tuner_type, | 269 | .tuner = dev->tuner_type, |
272 | .priv = &ctrl, | 270 | .priv = &ctrl, |
273 | }; | 271 | }; |
274 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG, | 272 | tuner_call(dev, tuner, s_config, &cfg); |
275 | &cfg); | ||
276 | } | 273 | } |
277 | #endif | 274 | #endif |
278 | |||
279 | /* configure tuner */ | 275 | /* configure tuner */ |
280 | f.tuner = 0; | 276 | f.tuner = 0; |
281 | f.type = V4L2_TUNER_ANALOG_TV; | 277 | f.type = V4L2_TUNER_ANALOG_TV; |
282 | f.frequency = 9076; /* just a magic number */ | 278 | f.frequency = 9076; /* just a magic number */ |
283 | dev->ctl_freq = f.frequency; | 279 | dev->ctl_freq = f.frequency; |
284 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f); | 280 | call_all(dev, tuner, s_frequency, &f); |
285 | } | ||
286 | 281 | ||
287 | #endif | 282 | } |
288 | 283 | ||
289 | /* ----------------------------------------------------------------------- */ | 284 | /* ----------------------------------------------------------------------- */ |
290 | void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) | 285 | void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) |
@@ -308,6 +303,7 @@ void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) | |||
308 | 303 | ||
309 | void cx231xx_card_setup(struct cx231xx *dev) | 304 | void cx231xx_card_setup(struct cx231xx *dev) |
310 | { | 305 | { |
306 | |||
311 | cx231xx_set_model(dev); | 307 | cx231xx_set_model(dev); |
312 | 308 | ||
313 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; | 309 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; |
@@ -332,16 +328,29 @@ void cx231xx_card_setup(struct cx231xx *dev) | |||
332 | /* request some modules */ | 328 | /* request some modules */ |
333 | if (dev->board.decoder == CX231XX_AVDECODER) { | 329 | if (dev->board.decoder == CX231XX_AVDECODER) { |
334 | cx231xx_info(": Requesting cx25840 module\n"); | 330 | cx231xx_info(": Requesting cx25840 module\n"); |
335 | request_module("cx25840"); | 331 | dev->sd_cx25840 = |
332 | v4l2_i2c_new_subdev(&dev->i2c_bus[0].i2c_adap, | ||
333 | "cx25840", "cx25840", 0x88 >> 1); | ||
334 | if (dev->sd_cx25840 == NULL) | ||
335 | cx231xx_info("cx25840 subdev registration failure\n"); | ||
336 | cx25840_call(dev, core, init, 0); | ||
337 | |||
336 | } | 338 | } |
337 | #if 0 | 339 | |
338 | if (dev->board.tuner_type != TUNER_ABSENT) { | 340 | if (dev->board.tuner_type != TUNER_ABSENT) { |
339 | cx231xx_info(": Requesting Tuner module\n"); | 341 | cx231xx_info(": Requesting Tuner module\n"); |
340 | request_module("tuner"); | 342 | dev->sd_tuner = |
343 | v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap, | ||
344 | "tuner", "tuner", 0xc2 >> 1); | ||
345 | if (dev->sd_tuner == NULL) | ||
346 | cx231xx_info("tuner subdev registration failure\n"); | ||
347 | |||
348 | cx231xx_config_tuner(dev); | ||
341 | } | 349 | } |
342 | 350 | ||
343 | cx231xx_config_tuner(dev); | 351 | cx231xx_config_tuner(dev); |
344 | 352 | ||
353 | #if 0 | ||
345 | /* TBD IR will be added later */ | 354 | /* TBD IR will be added later */ |
346 | cx231xx_ir_init(dev); | 355 | cx231xx_ir_init(dev); |
347 | #endif | 356 | #endif |
@@ -371,7 +380,7 @@ void cx231xx_config_i2c(struct cx231xx *dev) | |||
371 | route.input = INPUT(dev->video_input)->vmux; | 380 | route.input = INPUT(dev->video_input)->vmux; |
372 | route.output = 0; | 381 | route.output = 0; |
373 | 382 | ||
374 | cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_STREAMON, NULL); | 383 | call_all(dev, video, s_stream, 1); |
375 | } | 384 | } |
376 | 385 | ||
377 | /* | 386 | /* |
@@ -549,7 +558,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
549 | udev = usb_get_dev(interface_to_usbdev(interface)); | 558 | udev = usb_get_dev(interface_to_usbdev(interface)); |
550 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 559 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
551 | 560 | ||
552 | cx231xx_info(": Interface Number %d\n", ifnum); | 561 | printk(DRIVER_NAME ": Interface Number %d\n", ifnum); |
553 | 562 | ||
554 | /* Interface number 0 - IR interface */ | 563 | /* Interface number 0 - IR interface */ |
555 | if (ifnum == 0) { | 564 | if (ifnum == 0) { |
@@ -689,12 +698,25 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
689 | /* AV device initialization */ | 698 | /* AV device initialization */ |
690 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { | 699 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { |
691 | cx231xx_info(" Calling init_dev\n"); | 700 | cx231xx_info(" Calling init_dev\n"); |
701 | |||
702 | /* Create v4l2 device */ | ||
703 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), | ||
704 | "%s-%03d", "cx231xx", nr); | ||
705 | retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev); | ||
706 | if (retval) { | ||
707 | printk(KERN_ERR "%s() v4l2_device_register failed\n", | ||
708 | __func__); | ||
709 | cx231xx_devused &= ~(1 << nr); | ||
710 | kfree(dev); | ||
711 | return -EIO; | ||
712 | } | ||
713 | |||
692 | /* allocate device struct */ | 714 | /* allocate device struct */ |
693 | retval = cx231xx_init_dev(&dev, udev, nr); | 715 | retval = cx231xx_init_dev(&dev, udev, nr); |
694 | if (retval) { | 716 | if (retval) { |
695 | cx231xx_devused &= ~(1 << dev->devno); | 717 | cx231xx_devused &= ~(1 << dev->devno); |
718 | v4l2_device_unregister(&dev->v4l2_dev); | ||
696 | kfree(dev); | 719 | kfree(dev); |
697 | |||
698 | return retval; | 720 | return retval; |
699 | } | 721 | } |
700 | 722 | ||
@@ -718,6 +740,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
718 | if (dev->video_mode.alt_max_pkt_size == NULL) { | 740 | if (dev->video_mode.alt_max_pkt_size == NULL) { |
719 | cx231xx_errdev("out of memory!\n"); | 741 | cx231xx_errdev("out of memory!\n"); |
720 | cx231xx_devused &= ~(1 << nr); | 742 | cx231xx_devused &= ~(1 << nr); |
743 | v4l2_device_unregister(&dev->v4l2_dev); | ||
721 | kfree(dev); | 744 | kfree(dev); |
722 | return -ENOMEM; | 745 | return -ENOMEM; |
723 | } | 746 | } |
@@ -752,6 +775,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
752 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | 775 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { |
753 | cx231xx_errdev("out of memory!\n"); | 776 | cx231xx_errdev("out of memory!\n"); |
754 | cx231xx_devused &= ~(1 << nr); | 777 | cx231xx_devused &= ~(1 << nr); |
778 | v4l2_device_unregister(&dev->v4l2_dev); | ||
755 | kfree(dev); | 779 | kfree(dev); |
756 | return -ENOMEM; | 780 | return -ENOMEM; |
757 | } | 781 | } |
@@ -786,6 +810,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
786 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | 810 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { |
787 | cx231xx_errdev("out of memory!\n"); | 811 | cx231xx_errdev("out of memory!\n"); |
788 | cx231xx_devused &= ~(1 << nr); | 812 | cx231xx_devused &= ~(1 << nr); |
813 | v4l2_device_unregister(&dev->v4l2_dev); | ||
789 | kfree(dev); | 814 | kfree(dev); |
790 | return -ENOMEM; | 815 | return -ENOMEM; |
791 | } | 816 | } |
@@ -824,6 +849,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
824 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | 849 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
825 | cx231xx_errdev("out of memory!\n"); | 850 | cx231xx_errdev("out of memory!\n"); |
826 | cx231xx_devused &= ~(1 << nr); | 851 | cx231xx_devused &= ~(1 << nr); |
852 | v4l2_device_unregister(&dev->v4l2_dev); | ||
827 | kfree(dev); | 853 | kfree(dev); |
828 | return -ENOMEM; | 854 | return -ENOMEM; |
829 | } | 855 | } |
@@ -876,6 +902,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
876 | if (!dev) | 902 | if (!dev) |
877 | return; | 903 | return; |
878 | 904 | ||
905 | /* delete v4l2 device */ | ||
906 | v4l2_device_unregister(&dev->v4l2_dev); | ||
907 | |||
879 | /* wait until all current v4l2 io is finished then deallocate | 908 | /* wait until all current v4l2 io is finished then deallocate |
880 | resources */ | 909 | resources */ |
881 | mutex_lock(&dev->lock); | 910 | mutex_lock(&dev->lock); |