aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSri Deevi <Srinivasa.Deevi@conexant.com>2009-03-20 22:33:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:06 -0400
commitb1196126b016d0f28a99c16b27c403d0ecac501a (patch)
tree771b637e63514e40a051613e296ed6b2838f7e07
parented559edf35bdefb91c7eba5ea3dfd1e939aaa782 (diff)
V4L/DVB (11128): cx231xx: convert the calls to subdev format
This patch converts cx231xx to the new v4l2 dev/subdev, doing: - Conversion of i2c calls to subdev calls; - all subdev calls to call_all(); - Corrected the header file order in cx231xx.h; - Added tuner frequency setting. Signed-off-by: Srinivasa Deevi <srinivasa.deevi@conexant.com> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/cx231xx/cx231xx-cards.c61
-rw-r--r--drivers/media/video/cx231xx/cx231xx-i2c.c44
-rw-r--r--drivers/media/video/cx231xx/cx231xx-vbi.c4
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c64
-rw-r--r--drivers/media/video/cx231xx/cx231xx.h21
5 files changed, 91 insertions, 103 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
248static void cx231xx_config_tuner(struct cx231xx *dev) 246static 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/* ----------------------------------------------------------------------- */
290void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) 285void 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
309void cx231xx_card_setup(struct cx231xx *dev) 304void 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);
diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c
index 4489126c48c1..f95114aa23a1 100644
--- a/drivers/media/video/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/video/cx231xx/cx231xx-i2c.c
@@ -435,18 +435,6 @@ static int attach_inform(struct i2c_client *client)
435 struct cx231xx *dev = bus->dev; 435 struct cx231xx *dev = bus->dev;
436 436
437 switch (client->addr << 1) { 437 switch (client->addr << 1) {
438 case 0x32:
439 dprintk1(1, "attach_inform: Geminit III detected.\n");
440 break;
441 case 0x02:
442 dprintk1(1, "attach_inform: Acquarius detected.\n");
443 break;
444 case 0xa0:
445 dprintk1(1, "attach_inform: eeprom detected.\n");
446 break;
447 case 0x60:
448 dprintk1(1, "attach_inform: Colibri detected.\n");
449 break;
450 case 0x8e: 438 case 0x8e:
451 { 439 {
452 struct IR_i2c *ir = i2c_get_clientdata(client); 440 struct IR_i2c *ir = i2c_get_clientdata(client);
@@ -455,28 +443,15 @@ static int attach_inform(struct i2c_client *client)
455 cx231xx_set_ir(dev, ir); 443 cx231xx_set_ir(dev, ir);
456 break; 444 break;
457 } 445 }
458 case 0x80:
459 case 0x88:
460 dprintk1(1, "attach_inform: Hammerhead detected.\n");
461 break; 446 break;
462 447
463 default: 448 default:
464 if (!dev->tuner_addr) 449 break;
465 dev->tuner_addr = client->addr;
466
467 dprintk1(1, "attach inform: detected I2C address %x\n",
468 client->addr << 1);
469 } 450 }
470 451
471 return 0; 452 return 0;
472} 453}
473 454
474static int detach_inform(struct i2c_client *client)
475{
476 dprintk1(1, "i2c detach [client=%s]\n", client->name);
477 return 0;
478}
479
480static struct i2c_algorithm cx231xx_algo = { 455static struct i2c_algorithm cx231xx_algo = {
481 .master_xfer = cx231xx_i2c_xfer, 456 .master_xfer = cx231xx_i2c_xfer,
482 .functionality = functionality, 457 .functionality = functionality,
@@ -484,12 +459,10 @@ static struct i2c_algorithm cx231xx_algo = {
484 459
485static struct i2c_adapter cx231xx_adap_template = { 460static struct i2c_adapter cx231xx_adap_template = {
486 .owner = THIS_MODULE, 461 .owner = THIS_MODULE,
487 .class = I2C_CLASS_TV_ANALOG,
488 .name = "cx231xx", 462 .name = "cx231xx",
489 .id = I2C_HW_B_CX231XX, 463 .id = I2C_HW_B_CX231XX,
490 .algo = &cx231xx_algo, 464 .algo = &cx231xx_algo,
491 .client_register = attach_inform, 465 .client_register = attach_inform,
492 .client_unregister = detach_inform,
493}; 466};
494 467
495static struct i2c_client cx231xx_client_template = { 468static struct i2c_client cx231xx_client_template = {
@@ -536,19 +509,6 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
536} 509}
537 510
538/* 511/*
539 * cx231xx_i2c_call_clients()
540 * send commands to all attached i2c devices
541 */
542void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
543 void *arg)
544{
545 /* struct cx231xx *dev = bus->dev; */
546
547 BUG_ON(NULL == bus->i2c_adap.algo_data);
548 i2c_clients_command(&bus->i2c_adap, cmd, arg);
549}
550
551/*
552 * cx231xx_i2c_register() 512 * cx231xx_i2c_register()
553 * register i2c bus 513 * register i2c bus
554 */ 514 */
@@ -571,7 +531,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
571 531
572 bus->i2c_algo.data = bus; 532 bus->i2c_algo.data = bus;
573 bus->i2c_adap.algo_data = bus; 533 bus->i2c_adap.algo_data = bus;
574 i2c_set_adapdata(&bus->i2c_adap, bus); 534 i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
575 i2c_add_adapter(&bus->i2c_adap); 535 i2c_add_adapter(&bus->i2c_adap);
576 536
577 bus->i2c_client.adapter = &bus->i2c_adap; 537 bus->i2c_client.adapter = &bus->i2c_adap;
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c
index 82db39d339e1..94180526909c 100644
--- a/drivers/media/video/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/video/cx231xx/cx231xx-vbi.c
@@ -187,10 +187,6 @@ vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count,
187 if (*count < CX231XX_MIN_BUF) 187 if (*count < CX231XX_MIN_BUF)
188 *count = CX231XX_MIN_BUF; 188 *count = CX231XX_MIN_BUF;
189 189
190 /* call VBI setup if required */
191 /* cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f);
192 */
193
194 return 0; 190 return 0;
195} 191}
196 192
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 606f80129ffb..65430ecc180c 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -704,7 +704,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
704 f.frequency = dev->ctl_freq; 704 f.frequency = dev->ctl_freq;
705 f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 705 f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
706 706
707 cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f); 707 call_all(dev, tuner, s_frequency, &f);
708 708
709 return 0; 709 return 0;
710} 710}
@@ -830,8 +830,7 @@ void video_mux(struct cx231xx *dev, int index)
830 830
831 cx231xx_set_video_input_mux(dev, index); 831 cx231xx_set_video_input_mux(dev, index);
832 832
833 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_INT_S_VIDEO_ROUTING, 833 cx25840_call(dev, video, s_routing, &route);
834 &route);
835 834
836 cx231xx_set_audio_input(dev, dev->ctl_ainput); 835 cx231xx_set_audio_input(dev, dev->ctl_ainput);
837 836
@@ -1045,7 +1044,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1045 dev->format = fmt; 1044 dev->format = fmt;
1046 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1045 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
1047 1046
1048 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_FMT, f); 1047 call_all(dev, video, s_fmt, f);
1049 1048
1050 /* Set the correct alternate setting for this resolution */ 1049 /* Set the correct alternate setting for this resolution */
1051 cx231xx_resolution_set(dev); 1050 cx231xx_resolution_set(dev);
@@ -1064,7 +1063,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id * id)
1064 return 0; 1063 return 0;
1065} 1064}
1066 1065
1067static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm) 1066static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
1068{ 1067{
1069 struct cx231xx_fh *fh = priv; 1068 struct cx231xx_fh *fh = priv;
1070 struct cx231xx *dev = fh->dev; 1069 struct cx231xx *dev = fh->dev;
@@ -1090,7 +1089,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
1090 dev->height = f.fmt.pix.height; 1089 dev->height = f.fmt.pix.height;
1091 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1090 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
1092 1091
1093 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_STD, &dev->norm); 1092 call_all(dev, tuner, s_std, dev->norm);
1094 1093
1095 mutex_unlock(&dev->lock); 1094 mutex_unlock(&dev->lock);
1096 1095
@@ -1244,7 +1243,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1244 *qc = cx231xx_ctls[i].v; 1243 *qc = cx231xx_ctls[i].v;
1245 1244
1246 mutex_lock(&dev->lock); 1245 mutex_lock(&dev->lock);
1247 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_QUERYCTRL, qc); 1246 call_all(dev, core, queryctrl, qc);
1248 mutex_unlock(&dev->lock); 1247 mutex_unlock(&dev->lock);
1249 1248
1250 if (qc->type) 1249 if (qc->type)
@@ -1265,9 +1264,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1265 return rc; 1264 return rc;
1266 1265
1267 mutex_lock(&dev->lock); 1266 mutex_lock(&dev->lock);
1268 1267 call_all(dev, core, g_ctrl, ctrl);
1269 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_CTRL, ctrl);
1270
1271 mutex_unlock(&dev->lock); 1268 mutex_unlock(&dev->lock);
1272 return rc; 1269 return rc;
1273} 1270}
@@ -1284,9 +1281,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1284 return rc; 1281 return rc;
1285 1282
1286 mutex_lock(&dev->lock); 1283 mutex_lock(&dev->lock);
1287 1284 call_all(dev, core, s_ctrl, ctrl);
1288 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_S_CTRL, ctrl);
1289
1290 mutex_unlock(&dev->lock); 1285 mutex_unlock(&dev->lock);
1291 return rc; 1286 return rc;
1292} 1287}
@@ -1328,9 +1323,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
1328 return -EINVAL; 1323 return -EINVAL;
1329#if 0 1324#if 0
1330 mutex_lock(&dev->lock); 1325 mutex_lock(&dev->lock);
1331 1326 call_all(dev, tuner, s_tuner, t);
1332 cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_TUNER, t);
1333
1334 mutex_unlock(&dev->lock); 1327 mutex_unlock(&dev->lock);
1335#endif 1328#endif
1336 return 0; 1329 return 0;
@@ -1346,7 +1339,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
1346 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1339 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1347 f->frequency = dev->ctl_freq; 1340 f->frequency = dev->ctl_freq;
1348 1341
1349 cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f); 1342 call_all(dev, tuner, g_frequency, f);
1350 1343
1351 mutex_unlock(&dev->lock); 1344 mutex_unlock(&dev->lock);
1352 1345
@@ -1382,10 +1375,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1382 if (dev->tuner_type == TUNER_XC5000) { 1375 if (dev->tuner_type == TUNER_XC5000) {
1383 if (dev->cx231xx_set_analog_freq != NULL) 1376 if (dev->cx231xx_set_analog_freq != NULL)
1384 dev->cx231xx_set_analog_freq(dev, f->frequency); 1377 dev->cx231xx_set_analog_freq(dev, f->frequency);
1385 } else { 1378 } else
1386 cx231xx_i2c_call_clients(&dev->i2c_bus[1], 1379 call_all(dev, tuner, s_frequency, f);
1387 VIDIOC_S_FREQUENCY, f);
1388 }
1389 1380
1390 mutex_unlock(&dev->lock); 1381 mutex_unlock(&dev->lock);
1391 1382
@@ -1467,8 +1458,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1467 return ret < 0 ? ret : 0; 1458 return ret < 0 ? ret : 0;
1468 1459
1469 case V4L2_CHIP_MATCH_I2C_DRIVER: 1460 case V4L2_CHIP_MATCH_I2C_DRIVER:
1470 cx231xx_i2c_call_clients(&dev->i2c_bus[0], 1461 call_all(dev, core, g_register, reg);
1471 VIDIOC_DBG_G_REGISTER, reg);
1472 return 0; 1462 return 0;
1473 case V4L2_CHIP_MATCH_I2C_ADDR: 1463 case V4L2_CHIP_MATCH_I2C_ADDR:
1474 /* Not supported yet */ 1464 /* Not supported yet */
@@ -1479,7 +1469,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1479 } 1469 }
1480 1470
1481 mutex_lock(&dev->lock); 1471 mutex_lock(&dev->lock);
1482 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_G_REGISTER, reg); 1472 call_all(dev, core, g_register, reg);
1483 mutex_unlock(&dev->lock); 1473 mutex_unlock(&dev->lock);
1484 1474
1485 return ret; 1475 return ret;
@@ -1562,9 +1552,7 @@ static int vidioc_s_register(struct file *file, void *priv,
1562 } 1552 }
1563 1553
1564 mutex_lock(&dev->lock); 1554 mutex_lock(&dev->lock);
1565 1555 call_all(dev, core, s_register, reg);
1566 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_DBG_S_REGISTER, reg);
1567
1568 mutex_unlock(&dev->lock); 1556 mutex_unlock(&dev->lock);
1569 1557
1570 return ret; 1558 return ret;
@@ -1608,6 +1596,8 @@ static int vidioc_streamon(struct file *file, void *priv,
1608 if (likely(rc >= 0)) 1596 if (likely(rc >= 0))
1609 rc = videobuf_streamon(&fh->vb_vidq); 1597 rc = videobuf_streamon(&fh->vb_vidq);
1610 1598
1599 call_all(dev, video, s_stream, 1);
1600
1611 mutex_unlock(&dev->lock); 1601 mutex_unlock(&dev->lock);
1612 1602
1613 return rc; 1603 return rc;
@@ -1632,6 +1622,8 @@ static int vidioc_streamoff(struct file *file, void *priv,
1632 1622
1633 mutex_lock(&dev->lock); 1623 mutex_lock(&dev->lock);
1634 1624
1625 cx25840_call(dev, video, s_stream, 0);
1626
1635 videobuf_streamoff(&fh->vb_vidq); 1627 videobuf_streamoff(&fh->vb_vidq);
1636 res_free(fh); 1628 res_free(fh);
1637 1629
@@ -1648,7 +1640,7 @@ static int vidioc_querycap(struct file *file, void *priv,
1648 1640
1649 strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); 1641 strlcpy(cap->driver, "cx231xx", sizeof(cap->driver));
1650 strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); 1642 strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card));
1651 strlcpy(cap->bus_info, dev_name(&dev->udev->dev), 1643 strlcpy(cap->bus_info, dev->v4l2_dev.name,
1652 sizeof(cap->bus_info)); 1644 sizeof(cap->bus_info));
1653 1645
1654 cap->version = CX231XX_VERSION_CODE; 1646 cap->version = CX231XX_VERSION_CODE;
@@ -1696,7 +1688,7 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
1696 1688
1697 f->fmt.sliced.service_set = 0; 1689 f->fmt.sliced.service_set = 0;
1698 1690
1699 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_FMT, f); 1691 call_all(dev, video, g_fmt, f);
1700 1692
1701 if (f->fmt.sliced.service_set == 0) 1693 if (f->fmt.sliced.service_set == 0)
1702 rc = -EINVAL; 1694 rc = -EINVAL;
@@ -1717,7 +1709,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
1717 return rc; 1709 return rc;
1718 1710
1719 mutex_lock(&dev->lock); 1711 mutex_lock(&dev->lock);
1720 cx231xx_i2c_call_clients(&dev->i2c_bus[0], VIDIOC_G_FMT, f); 1712 call_all(dev, video, g_fmt, f);
1721 mutex_unlock(&dev->lock); 1713 mutex_unlock(&dev->lock);
1722 1714
1723 if (f->fmt.sliced.service_set == 0) 1715 if (f->fmt.sliced.service_set == 0)
@@ -1872,7 +1864,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
1872 t->type = V4L2_TUNER_RADIO; 1864 t->type = V4L2_TUNER_RADIO;
1873 1865
1874 mutex_lock(&dev->lock); 1866 mutex_lock(&dev->lock);
1875 cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t); 1867 call_all(dev, tuner, s_tuner, t);
1876 mutex_unlock(&dev->lock); 1868 mutex_unlock(&dev->lock);
1877 1869
1878 return 0; 1870 return 0;
@@ -1905,7 +1897,7 @@ static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
1905 return -EINVAL; 1897 return -EINVAL;
1906 1898
1907 mutex_lock(&dev->lock); 1899 mutex_lock(&dev->lock);
1908 cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_TUNER, t); 1900 call_all(dev, tuner, s_tuner, t);
1909 mutex_unlock(&dev->lock); 1901 mutex_unlock(&dev->lock);
1910 1902
1911 return 0; 1903 return 0;
@@ -2011,8 +2003,7 @@ static int cx231xx_v4l2_open(struct file *filp)
2011 2003
2012 /* cx231xx_start_radio(dev); */ 2004 /* cx231xx_start_radio(dev); */
2013 2005
2014 cx231xx_i2c_call_clients(&dev->i2c_bus[1], AUDC_SET_RADIO, 2006 call_all(dev, tuner, s_radio);
2015 NULL);
2016 } 2007 }
2017 2008
2018 dev->users++; 2009 dev->users++;
@@ -2135,8 +2126,7 @@ static int cx231xx_v4l2_close(struct file *filp)
2135 } 2126 }
2136 2127
2137 /* Save some power by putting tuner to sleep */ 2128 /* Save some power by putting tuner to sleep */
2138 cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_STANDBY, 2129 call_all(dev, core, s_standby, 0);
2139 NULL);
2140 2130
2141 /* do this before setting alternate! */ 2131 /* do this before setting alternate! */
2142 cx231xx_uninit_isoc(dev); 2132 cx231xx_uninit_isoc(dev);
@@ -2350,7 +2340,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
2350 2340
2351 *vfd = *template; 2341 *vfd = *template;
2352 vfd->minor = -1; 2342 vfd->minor = -1;
2353 vfd->parent = &dev->udev->dev; 2343 vfd->v4l2_dev = &dev->v4l2_dev;
2354 vfd->release = video_device_release; 2344 vfd->release = video_device_release;
2355 vfd->debug = video_debug; 2345 vfd->debug = video_debug;
2356 2346
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h
index 7c2a162f5c41..d658e3599d86 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -23,11 +23,15 @@
23#define _CX231XX_H 23#define _CX231XX_H
24 24
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26#include <media/videobuf-vmalloc.h> 26#include <linux/types.h>
27 27#include <linux/ioctl.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-algo-bit.h> 29#include <linux/i2c-algo-bit.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31
32
33#include <media/videobuf-vmalloc.h>
34#include <media/v4l2-device.h>
31#include <media/ir-kbd-i2c.h> 35#include <media/ir-kbd-i2c.h>
32#if defined(CONFIG_VIDEO_CX231XX_DVB) || \ 36#if defined(CONFIG_VIDEO_CX231XX_DVB) || \
33 defined(CONFIG_VIDEO_CX231XX_DVB_MODULE) 37 defined(CONFIG_VIDEO_CX231XX_DVB_MODULE)
@@ -447,6 +451,10 @@ struct cx231xx {
447 451
448 struct cx231xx_fmt *format; 452 struct cx231xx_fmt *format;
449 453
454 struct v4l2_device v4l2_dev;
455 struct v4l2_subdev *sd_cx25840;
456 struct v4l2_subdev *sd_tuner;
457
450 struct cx231xx_IR *ir; 458 struct cx231xx_IR *ir;
451 459
452 struct list_head devlist; 460 struct list_head devlist;
@@ -544,6 +552,13 @@ struct cx231xx {
544 552
545}; 553};
546 554
555#define cx25840_call(cx231xx, o, f, args...) \
556 v4l2_subdev_call(cx231xx->sd_cx25840, o, f, ##args)
557#define tuner_call(cx231xx, o, f, args...) \
558 v4l2_subdev_call(cx231xx->sd_tuner, o, f, ##args)
559#define call_all(dev, o, f, args...) \
560 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args)
561
547struct cx231xx_ops { 562struct cx231xx_ops {
548 struct list_head next; 563 struct list_head next;
549 char *name; 564 char *name;
@@ -557,8 +572,6 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
557int cx231xx_reset_analog_tuner(struct cx231xx *dev); 572int cx231xx_reset_analog_tuner(struct cx231xx *dev);
558 573
559/* Provided by cx231xx-i2c.c */ 574/* Provided by cx231xx-i2c.c */
560void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
561 void *arg);
562void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); 575void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
563int cx231xx_i2c_register(struct cx231xx_i2c *bus); 576int cx231xx_i2c_register(struct cx231xx_i2c *bus);
564int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); 577int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);