aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-04-22 13:45:30 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:45 -0400
commit23fb348d00da9c1558b4a9b234b9ac941091b0f1 (patch)
treebd124c4c968a75cca36d28ad48e54f6c0522f7ef /drivers
parent64016330b60e44db1383122a11611073fe98f261 (diff)
V4L/DVB (7266): cx88-dvb: convert attach_xc3028 into a function
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index ef83dab72410..59180cab0a85 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -452,11 +452,33 @@ static struct zl10353_config cx88_geniatech_x8000_mt = {
452 .no_tuner = 1, 452 .no_tuner = 1,
453}; 453};
454 454
455static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
456{
457 struct dvb_frontend *fe;
458 struct xc2028_config cfg = {
459 .i2c_adap = &dev->core->i2c_adap,
460 .i2c_addr = addr,
461 .video_dev = dev->core,
462 };
463
464 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
465 if (!fe) {
466 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
467 dev->core->name);
468 dvb_frontend_detach(dev->dvb.frontend);
469 dvb_unregister_frontend(dev->dvb.frontend);
470 dev->dvb.frontend = NULL;
471 return -EINVAL;
472 }
473
474 printk(KERN_INFO "%s/2: xc3028 attached\n",
475 dev->core->name);
476
477 return 0;
478}
455 479
456static int dvb_register(struct cx8802_dev *dev) 480static int dvb_register(struct cx8802_dev *dev)
457{ 481{
458 int attach_xc3028 = 0;
459
460 /* init struct videobuf_dvb */ 482 /* init struct videobuf_dvb */
461 dev->dvb.name = dev->core->name; 483 dev->dvb.name = dev->core->name;
462 dev->ts_gen_cntrl = 0x0c; 484 dev->ts_gen_cntrl = 0x0c;
@@ -595,8 +617,8 @@ static int dvb_register(struct cx8802_dev *dev)
595 */ 617 */
596 if (dev->dvb.frontend) 618 if (dev->dvb.frontend)
597 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; 619 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
598 620 if (attach_xc3028(0x61, dev) < 0)
599 attach_xc3028 = 1; 621 return -EINVAL;
600 break; 622 break;
601 case CX88_BOARD_PCHDTV_HD3000: 623 case CX88_BOARD_PCHDTV_HD3000:
602 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 624 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
@@ -770,7 +792,8 @@ static int dvb_register(struct cx8802_dev *dev)
770 dev->dvb.frontend = dvb_attach(zl10353_attach, 792 dev->dvb.frontend = dvb_attach(zl10353_attach,
771 &cx88_geniatech_x8000_mt, 793 &cx88_geniatech_x8000_mt,
772 &dev->core->i2c_adap); 794 &dev->core->i2c_adap);
773 attach_xc3028 = 1; 795 if (attach_xc3028(0x61, dev) < 0)
796 return -EINVAL;
774 break; 797 break;
775 case CX88_BOARD_GENIATECH_X8000_MT: 798 case CX88_BOARD_GENIATECH_X8000_MT:
776 dev->ts_gen_cntrl = 0x00; 799 dev->ts_gen_cntrl = 0x00;
@@ -778,7 +801,8 @@ static int dvb_register(struct cx8802_dev *dev)
778 dev->dvb.frontend = dvb_attach(zl10353_attach, 801 dev->dvb.frontend = dvb_attach(zl10353_attach,
779 &cx88_geniatech_x8000_mt, 802 &cx88_geniatech_x8000_mt,
780 &dev->core->i2c_adap); 803 &dev->core->i2c_adap);
781 attach_xc3028 = 1; 804 if (attach_xc3028(0x61, dev) < 0)
805 return -EINVAL;
782 break; 806 break;
783 default: 807 default:
784 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 808 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
@@ -789,27 +813,7 @@ static int dvb_register(struct cx8802_dev *dev)
789 printk(KERN_ERR 813 printk(KERN_ERR
790 "%s/2: frontend initialization failed\n", 814 "%s/2: frontend initialization failed\n",
791 dev->core->name); 815 dev->core->name);
792 return -1; 816 return -EINVAL;
793 }
794
795 if (attach_xc3028) {
796 struct dvb_frontend *fe;
797 struct xc2028_config cfg = {
798 .i2c_adap = &dev->core->i2c_adap,
799 .i2c_addr = 0x61,
800 .video_dev = dev->core,
801 };
802 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
803 if (!fe) {
804 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
805 dev->core->name);
806 dvb_frontend_detach(dev->dvb.frontend);
807 dvb_unregister_frontend(dev->dvb.frontend);
808 dev->dvb.frontend = NULL;
809 return -1;
810 }
811 printk(KERN_INFO "%s/2: xc3028 attached\n",
812 dev->core->name);
813 } 817 }
814 818
815 /* Ensure all frontends negotiate bus access */ 819 /* Ensure all frontends negotiate bus access */