diff options
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/Kconfig | 10 | ||||
-rw-r--r-- | drivers/media/dvb/b2c2/Kconfig | 6 | ||||
-rw-r--r-- | drivers/media/dvb/bt8xx/Kconfig | 3 | ||||
-rw-r--r-- | drivers/media/dvb/bt8xx/dvb-bt8xx.c | 6 | ||||
-rw-r--r-- | drivers/media/dvb/cinergyT2/cinergyT2.c | 5 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.c | 12 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvbdev.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/cxusb.c | 17 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/cx24123.c | 565 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dvb-pll.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/pluto2/Kconfig | 3 | ||||
-rw-r--r-- | drivers/media/dvb/pluto2/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/Kconfig | 12 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget-av.c | 6 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget-ci.c | 105 | ||||
-rw-r--r-- | drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 6 |
17 files changed, 544 insertions, 224 deletions
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig index 3f0ec6be03ae..a97c8f5e9a5d 100644 --- a/drivers/media/dvb/Kconfig +++ b/drivers/media/dvb/Kconfig | |||
@@ -22,26 +22,26 @@ config DVB | |||
22 | source "drivers/media/dvb/dvb-core/Kconfig" | 22 | source "drivers/media/dvb/dvb-core/Kconfig" |
23 | 23 | ||
24 | comment "Supported SAA7146 based PCI Adapters" | 24 | comment "Supported SAA7146 based PCI Adapters" |
25 | depends on DVB_CORE && PCI | 25 | depends on DVB_CORE && PCI && I2C |
26 | source "drivers/media/dvb/ttpci/Kconfig" | 26 | source "drivers/media/dvb/ttpci/Kconfig" |
27 | 27 | ||
28 | comment "Supported USB Adapters" | 28 | comment "Supported USB Adapters" |
29 | depends on DVB_CORE && USB | 29 | depends on DVB_CORE && USB && I2C |
30 | source "drivers/media/dvb/dvb-usb/Kconfig" | 30 | source "drivers/media/dvb/dvb-usb/Kconfig" |
31 | source "drivers/media/dvb/ttusb-budget/Kconfig" | 31 | source "drivers/media/dvb/ttusb-budget/Kconfig" |
32 | source "drivers/media/dvb/ttusb-dec/Kconfig" | 32 | source "drivers/media/dvb/ttusb-dec/Kconfig" |
33 | source "drivers/media/dvb/cinergyT2/Kconfig" | 33 | source "drivers/media/dvb/cinergyT2/Kconfig" |
34 | 34 | ||
35 | comment "Supported FlexCopII (B2C2) Adapters" | 35 | comment "Supported FlexCopII (B2C2) Adapters" |
36 | depends on DVB_CORE && (PCI || USB) | 36 | depends on DVB_CORE && (PCI || USB) && I2C |
37 | source "drivers/media/dvb/b2c2/Kconfig" | 37 | source "drivers/media/dvb/b2c2/Kconfig" |
38 | 38 | ||
39 | comment "Supported BT878 Adapters" | 39 | comment "Supported BT878 Adapters" |
40 | depends on DVB_CORE && PCI | 40 | depends on DVB_CORE && PCI && I2C |
41 | source "drivers/media/dvb/bt8xx/Kconfig" | 41 | source "drivers/media/dvb/bt8xx/Kconfig" |
42 | 42 | ||
43 | comment "Supported Pluto2 Adapters" | 43 | comment "Supported Pluto2 Adapters" |
44 | depends on DVB_CORE && PCI | 44 | depends on DVB_CORE && PCI && I2C |
45 | source "drivers/media/dvb/pluto2/Kconfig" | 45 | source "drivers/media/dvb/pluto2/Kconfig" |
46 | 46 | ||
47 | comment "Supported DVB Frontends" | 47 | comment "Supported DVB Frontends" |
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig index 2963605c0ecc..d7f1fd5b7b02 100644 --- a/drivers/media/dvb/b2c2/Kconfig +++ b/drivers/media/dvb/b2c2/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_B2C2_FLEXCOP | 1 | config DVB_B2C2_FLEXCOP |
2 | tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters" | 2 | tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters" |
3 | depends on DVB_CORE | 3 | depends on DVB_CORE && I2C |
4 | select DVB_STV0299 | 4 | select DVB_STV0299 |
5 | select DVB_MT352 | 5 | select DVB_MT352 |
6 | select DVB_MT312 | 6 | select DVB_MT312 |
@@ -16,7 +16,7 @@ config DVB_B2C2_FLEXCOP | |||
16 | 16 | ||
17 | config DVB_B2C2_FLEXCOP_PCI | 17 | config DVB_B2C2_FLEXCOP_PCI |
18 | tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI" | 18 | tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI" |
19 | depends on DVB_B2C2_FLEXCOP && PCI | 19 | depends on DVB_B2C2_FLEXCOP && PCI && I2C |
20 | help | 20 | help |
21 | Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2. | 21 | Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2. |
22 | 22 | ||
@@ -24,7 +24,7 @@ config DVB_B2C2_FLEXCOP_PCI | |||
24 | 24 | ||
25 | config DVB_B2C2_FLEXCOP_USB | 25 | config DVB_B2C2_FLEXCOP_USB |
26 | tristate "Technisat/B2C2 Air/Sky/Cable2PC USB" | 26 | tristate "Technisat/B2C2 Air/Sky/Cable2PC USB" |
27 | depends on DVB_B2C2_FLEXCOP && USB | 27 | depends on DVB_B2C2_FLEXCOP && USB && I2C |
28 | help | 28 | help |
29 | Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2, | 29 | Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2, |
30 | 30 | ||
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig index 376ca48f1d1d..f394002118f8 100644 --- a/drivers/media/dvb/bt8xx/Kconfig +++ b/drivers/media/dvb/bt8xx/Kconfig | |||
@@ -1,12 +1,13 @@ | |||
1 | config DVB_BT8XX | 1 | config DVB_BT8XX |
2 | tristate "BT8xx based PCI cards" | 2 | tristate "BT8xx based PCI cards" |
3 | depends on DVB_CORE && PCI && VIDEO_BT848 | 3 | depends on DVB_CORE && PCI && I2C && VIDEO_BT848 |
4 | select DVB_MT352 | 4 | select DVB_MT352 |
5 | select DVB_SP887X | 5 | select DVB_SP887X |
6 | select DVB_NXT6000 | 6 | select DVB_NXT6000 |
7 | select DVB_CX24110 | 7 | select DVB_CX24110 |
8 | select DVB_OR51211 | 8 | select DVB_OR51211 |
9 | select DVB_LGDT330X | 9 | select DVB_LGDT330X |
10 | select DVB_ZL10353 | ||
10 | select FW_LOADER | 11 | select FW_LOADER |
11 | help | 12 | help |
12 | Support for PCI cards based on the Bt8xx PCI bridge. Examples are | 13 | Support for PCI cards based on the Bt8xx PCI bridge. Examples are |
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index baa8227ef87c..ccc7b2eb4a2d 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c | |||
@@ -115,7 +115,7 @@ static int is_pci_slot_eq(struct pci_dev* adev, struct pci_dev* bdev) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev) | 118 | static struct bt878 __devinit *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev) |
119 | { | 119 | { |
120 | unsigned int card_nr; | 120 | unsigned int card_nr; |
121 | 121 | ||
@@ -709,7 +709,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | 712 | static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) |
713 | { | 713 | { |
714 | int result; | 714 | int result; |
715 | 715 | ||
@@ -794,7 +794,7 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | |||
794 | return 0; | 794 | return 0; |
795 | } | 795 | } |
796 | 796 | ||
797 | static int dvb_bt8xx_probe(struct bttv_sub_device *sub) | 797 | static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub) |
798 | { | 798 | { |
799 | struct dvb_bt8xx_card *card; | 799 | struct dvb_bt8xx_card *card; |
800 | struct pci_dev* bttv_pci_dev; | 800 | struct pci_dev* bttv_pci_dev; |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 71b575dc22bd..9325d039ea65 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
@@ -902,7 +902,10 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
902 | return -ENOMEM; | 902 | return -ENOMEM; |
903 | } | 903 | } |
904 | 904 | ||
905 | dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE); | 905 | if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE)) < 0) { |
906 | kfree(cinergyt2); | ||
907 | return err; | ||
908 | } | ||
906 | 909 | ||
907 | cinergyt2->demux.priv = cinergyt2; | 910 | cinergyt2->demux.priv = cinergyt2; |
908 | cinergyt2->demux.filternum = 256; | 911 | cinergyt2->demux.filternum = 256; |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 4f8f257e6795..a051790161b0 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -106,6 +106,8 @@ struct dvb_frontend_private { | |||
106 | unsigned long tune_mode_flags; | 106 | unsigned long tune_mode_flags; |
107 | unsigned int delay; | 107 | unsigned int delay; |
108 | unsigned int reinitialise; | 108 | unsigned int reinitialise; |
109 | int tone; | ||
110 | int voltage; | ||
109 | 111 | ||
110 | /* swzigzag values */ | 112 | /* swzigzag values */ |
111 | unsigned int state; | 113 | unsigned int state; |
@@ -537,6 +539,12 @@ static int dvb_frontend_thread(void *data) | |||
537 | 539 | ||
538 | if (fepriv->reinitialise) { | 540 | if (fepriv->reinitialise) { |
539 | dvb_frontend_init(fe); | 541 | dvb_frontend_init(fe); |
542 | if (fepriv->tone != -1) { | ||
543 | fe->ops->set_tone(fe, fepriv->tone); | ||
544 | } | ||
545 | if (fepriv->voltage != -1) { | ||
546 | fe->ops->set_voltage(fe, fepriv->voltage); | ||
547 | } | ||
540 | fepriv->reinitialise = 0; | 548 | fepriv->reinitialise = 0; |
541 | } | 549 | } |
542 | 550 | ||
@@ -788,6 +796,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
788 | case FE_SET_TONE: | 796 | case FE_SET_TONE: |
789 | if (fe->ops->set_tone) { | 797 | if (fe->ops->set_tone) { |
790 | err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); | 798 | err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); |
799 | fepriv->tone = (fe_sec_tone_mode_t) parg; | ||
791 | fepriv->state = FESTATE_DISEQC; | 800 | fepriv->state = FESTATE_DISEQC; |
792 | fepriv->status = 0; | 801 | fepriv->status = 0; |
793 | } | 802 | } |
@@ -796,6 +805,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
796 | case FE_SET_VOLTAGE: | 805 | case FE_SET_VOLTAGE: |
797 | if (fe->ops->set_voltage) { | 806 | if (fe->ops->set_voltage) { |
798 | err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg); | 807 | err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg); |
808 | fepriv->voltage = (fe_sec_voltage_t) parg; | ||
799 | fepriv->state = FESTATE_DISEQC; | 809 | fepriv->state = FESTATE_DISEQC; |
800 | fepriv->status = 0; | 810 | fepriv->status = 0; |
801 | } | 811 | } |
@@ -995,6 +1005,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) | |||
995 | 1005 | ||
996 | /* normal tune mode when opened R/W */ | 1006 | /* normal tune mode when opened R/W */ |
997 | fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; | 1007 | fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; |
1008 | fepriv->tone = -1; | ||
1009 | fepriv->voltage = -1; | ||
998 | } | 1010 | } |
999 | 1011 | ||
1000 | return ret; | 1012 | return ret; |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 96fe0ecae250..3852430d0260 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
@@ -219,8 +219,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, | |||
219 | return -ENOMEM; | 219 | return -ENOMEM; |
220 | } | 220 | } |
221 | 221 | ||
222 | mutex_unlock(&dvbdev_register_lock); | ||
223 | |||
224 | memcpy(dvbdev, template, sizeof(struct dvb_device)); | 222 | memcpy(dvbdev, template, sizeof(struct dvb_device)); |
225 | dvbdev->type = type; | 223 | dvbdev->type = type; |
226 | dvbdev->id = id; | 224 | dvbdev->id = id; |
@@ -231,6 +229,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, | |||
231 | 229 | ||
232 | list_add_tail (&dvbdev->list_head, &adap->device_list); | 230 | list_add_tail (&dvbdev->list_head, &adap->device_list); |
233 | 231 | ||
232 | mutex_unlock(&dvbdev_register_lock); | ||
233 | |||
234 | devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), | 234 | devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), |
235 | S_IFCHR | S_IRUSR | S_IWUSR, | 235 | S_IFCHR | S_IRUSR | S_IWUSR, |
236 | "dvb/adapter%d/%s%d", adap->num, dnames[type], id); | 236 | "dvb/adapter%d/%s%d", adap->num, dnames[type], id); |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index d3df12039b06..e388fb1567d6 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_USB | 1 | config DVB_USB |
2 | tristate "Support for various USB DVB devices" | 2 | tristate "Support for various USB DVB devices" |
3 | depends on DVB_CORE && USB | 3 | depends on DVB_CORE && USB && I2C |
4 | select FW_LOADER | 4 | select FW_LOADER |
5 | help | 5 | help |
6 | By enabling this you will be able to choose the various supported | 6 | By enabling this you will be able to choose the various supported |
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 7edd6362b9cc..1f0d3e995c8d 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
@@ -150,6 +150,15 @@ static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
150 | return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); | 150 | return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
154 | { | ||
155 | u8 b = 0; | ||
156 | if (onoff) | ||
157 | return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); | ||
158 | else | ||
159 | return 0; | ||
160 | } | ||
161 | |||
153 | static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) | 162 | static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) |
154 | { | 163 | { |
155 | u8 buf[2] = { 0x03, 0x00 }; | 164 | u8 buf[2] = { 0x03, 0x00 }; |
@@ -544,7 +553,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { | |||
544 | .size_of_priv = sizeof(struct cxusb_state), | 553 | .size_of_priv = sizeof(struct cxusb_state), |
545 | 554 | ||
546 | .streaming_ctrl = cxusb_streaming_ctrl, | 555 | .streaming_ctrl = cxusb_streaming_ctrl, |
547 | .power_ctrl = cxusb_power_ctrl, | 556 | .power_ctrl = cxusb_bluebird_power_ctrl, |
548 | .frontend_attach = cxusb_lgdt3303_frontend_attach, | 557 | .frontend_attach = cxusb_lgdt3303_frontend_attach, |
549 | .tuner_attach = cxusb_lgh064f_tuner_attach, | 558 | .tuner_attach = cxusb_lgh064f_tuner_attach, |
550 | 559 | ||
@@ -589,7 +598,7 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { | |||
589 | .size_of_priv = sizeof(struct cxusb_state), | 598 | .size_of_priv = sizeof(struct cxusb_state), |
590 | 599 | ||
591 | .streaming_ctrl = cxusb_streaming_ctrl, | 600 | .streaming_ctrl = cxusb_streaming_ctrl, |
592 | .power_ctrl = cxusb_power_ctrl, | 601 | .power_ctrl = cxusb_bluebird_power_ctrl, |
593 | .frontend_attach = cxusb_dee1601_frontend_attach, | 602 | .frontend_attach = cxusb_dee1601_frontend_attach, |
594 | .tuner_attach = cxusb_dee1601_tuner_attach, | 603 | .tuner_attach = cxusb_dee1601_tuner_attach, |
595 | 604 | ||
@@ -638,7 +647,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { | |||
638 | .size_of_priv = sizeof(struct cxusb_state), | 647 | .size_of_priv = sizeof(struct cxusb_state), |
639 | 648 | ||
640 | .streaming_ctrl = cxusb_streaming_ctrl, | 649 | .streaming_ctrl = cxusb_streaming_ctrl, |
641 | .power_ctrl = cxusb_power_ctrl, | 650 | .power_ctrl = cxusb_bluebird_power_ctrl, |
642 | .frontend_attach = cxusb_mt352_frontend_attach, | 651 | .frontend_attach = cxusb_mt352_frontend_attach, |
643 | .tuner_attach = cxusb_lgz201_tuner_attach, | 652 | .tuner_attach = cxusb_lgz201_tuner_attach, |
644 | 653 | ||
@@ -683,7 +692,7 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { | |||
683 | .size_of_priv = sizeof(struct cxusb_state), | 692 | .size_of_priv = sizeof(struct cxusb_state), |
684 | 693 | ||
685 | .streaming_ctrl = cxusb_streaming_ctrl, | 694 | .streaming_ctrl = cxusb_streaming_ctrl, |
686 | .power_ctrl = cxusb_power_ctrl, | 695 | .power_ctrl = cxusb_bluebird_power_ctrl, |
687 | .frontend_attach = cxusb_mt352_frontend_attach, | 696 | .frontend_attach = cxusb_mt352_frontend_attach, |
688 | .tuner_attach = cxusb_dtt7579_tuner_attach, | 697 | .tuner_attach = cxusb_dtt7579_tuner_attach, |
689 | 698 | ||
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c index d661c6f9cbe5..691dc840dcc0 100644 --- a/drivers/media/dvb/frontends/cx24123.c +++ b/drivers/media/dvb/frontends/cx24123.c | |||
@@ -29,6 +29,9 @@ | |||
29 | #include "dvb_frontend.h" | 29 | #include "dvb_frontend.h" |
30 | #include "cx24123.h" | 30 | #include "cx24123.h" |
31 | 31 | ||
32 | #define XTAL 10111000 | ||
33 | |||
34 | static int force_band; | ||
32 | static int debug; | 35 | static int debug; |
33 | #define dprintk(args...) \ | 36 | #define dprintk(args...) \ |
34 | do { \ | 37 | do { \ |
@@ -52,6 +55,7 @@ struct cx24123_state | |||
52 | u32 VGAarg; | 55 | u32 VGAarg; |
53 | u32 bandselectarg; | 56 | u32 bandselectarg; |
54 | u32 pllarg; | 57 | u32 pllarg; |
58 | u32 FILTune; | ||
55 | 59 | ||
56 | /* The Demod/Tuner can't easily provide these, we cache them */ | 60 | /* The Demod/Tuner can't easily provide these, we cache them */ |
57 | u32 currentfreq; | 61 | u32 currentfreq; |
@@ -63,43 +67,33 @@ static struct | |||
63 | { | 67 | { |
64 | u32 symbolrate_low; | 68 | u32 symbolrate_low; |
65 | u32 symbolrate_high; | 69 | u32 symbolrate_high; |
66 | u32 VCAslope; | ||
67 | u32 VCAoffset; | ||
68 | u32 VGA1offset; | ||
69 | u32 VGA2offset; | ||
70 | u32 VCAprogdata; | 70 | u32 VCAprogdata; |
71 | u32 VGAprogdata; | 71 | u32 VGAprogdata; |
72 | u32 FILTune; | ||
72 | } cx24123_AGC_vals[] = | 73 | } cx24123_AGC_vals[] = |
73 | { | 74 | { |
74 | { | 75 | { |
75 | .symbolrate_low = 1000000, | 76 | .symbolrate_low = 1000000, |
76 | .symbolrate_high = 4999999, | 77 | .symbolrate_high = 4999999, |
77 | .VCAslope = 0x07, | 78 | /* the specs recommend other values for VGA offsets, |
78 | .VCAoffset = 0x0f, | 79 | but tests show they are wrong */ |
79 | .VGA1offset = 0x1f8, | 80 | .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0, |
80 | .VGA2offset = 0x1f8, | 81 | .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x07, |
81 | .VGAprogdata = (2 << 18) | (0x1f8 << 9) | 0x1f8, | 82 | .FILTune = 0x27f /* 0.41 V */ |
82 | .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x07, | ||
83 | }, | 83 | }, |
84 | { | 84 | { |
85 | .symbolrate_low = 5000000, | 85 | .symbolrate_low = 5000000, |
86 | .symbolrate_high = 14999999, | 86 | .symbolrate_high = 14999999, |
87 | .VCAslope = 0x1f, | 87 | .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0, |
88 | .VCAoffset = 0x1f, | 88 | .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x1f, |
89 | .VGA1offset = 0x1e0, | 89 | .FILTune = 0x317 /* 0.90 V */ |
90 | .VGA2offset = 0x180, | ||
91 | .VGAprogdata = (2 << 18) | (0x180 << 9) | 0x1e0, | ||
92 | .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x1f, | ||
93 | }, | 90 | }, |
94 | { | 91 | { |
95 | .symbolrate_low = 15000000, | 92 | .symbolrate_low = 15000000, |
96 | .symbolrate_high = 45000000, | 93 | .symbolrate_high = 45000000, |
97 | .VCAslope = 0x3f, | 94 | .VGAprogdata = (1 << 19) | (0x100 << 9) | 0x180, |
98 | .VCAoffset = 0x3f, | 95 | .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x3f, |
99 | .VGA1offset = 0x180, | 96 | .FILTune = 0x145 /* 2.70 V */ |
100 | .VGA2offset = 0x100, | ||
101 | .VGAprogdata = (2 << 18) | (0x100 << 9) | 0x180, | ||
102 | .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x3f, | ||
103 | }, | 97 | }, |
104 | }; | 98 | }; |
105 | 99 | ||
@@ -112,91 +106,80 @@ static struct | |||
112 | { | 106 | { |
113 | u32 freq_low; | 107 | u32 freq_low; |
114 | u32 freq_high; | 108 | u32 freq_high; |
115 | u32 bandselect; | ||
116 | u32 VCOdivider; | 109 | u32 VCOdivider; |
117 | u32 VCOnumber; | ||
118 | u32 progdata; | 110 | u32 progdata; |
119 | } cx24123_bandselect_vals[] = | 111 | } cx24123_bandselect_vals[] = |
120 | { | 112 | { |
113 | /* band 1 */ | ||
121 | { | 114 | { |
122 | .freq_low = 950000, | 115 | .freq_low = 950000, |
123 | .freq_high = 1018999, | ||
124 | .bandselect = 0x40, | ||
125 | .VCOdivider = 4, | ||
126 | .VCOnumber = 7, | ||
127 | .progdata = (0 << 18) | (0 << 9) | 0x40, | ||
128 | }, | ||
129 | { | ||
130 | .freq_low = 1019000, | ||
131 | .freq_high = 1074999, | 116 | .freq_high = 1074999, |
132 | .bandselect = 0x80, | ||
133 | .VCOdivider = 4, | 117 | .VCOdivider = 4, |
134 | .VCOnumber = 8, | 118 | .progdata = (0 << 19) | (0 << 9) | 0x40, |
135 | .progdata = (0 << 18) | (0 << 9) | 0x80, | ||
136 | }, | 119 | }, |
120 | |||
121 | /* band 2 */ | ||
137 | { | 122 | { |
138 | .freq_low = 1075000, | 123 | .freq_low = 1075000, |
139 | .freq_high = 1227999, | 124 | .freq_high = 1177999, |
140 | .bandselect = 0x01, | 125 | .VCOdivider = 4, |
141 | .VCOdivider = 2, | 126 | .progdata = (0 << 19) | (0 << 9) | 0x80, |
142 | .VCOnumber = 1, | ||
143 | .progdata = (0 << 18) | (1 << 9) | 0x01, | ||
144 | }, | 127 | }, |
128 | |||
129 | /* band 3 */ | ||
145 | { | 130 | { |
146 | .freq_low = 1228000, | 131 | .freq_low = 1178000, |
147 | .freq_high = 1349999, | 132 | .freq_high = 1295999, |
148 | .bandselect = 0x02, | ||
149 | .VCOdivider = 2, | 133 | .VCOdivider = 2, |
150 | .VCOnumber = 2, | 134 | .progdata = (0 << 19) | (1 << 9) | 0x01, |
151 | .progdata = (0 << 18) | (1 << 9) | 0x02, | ||
152 | }, | 135 | }, |
136 | |||
137 | /* band 4 */ | ||
153 | { | 138 | { |
154 | .freq_low = 1350000, | 139 | .freq_low = 1296000, |
155 | .freq_high = 1481999, | 140 | .freq_high = 1431999, |
156 | .bandselect = 0x04, | ||
157 | .VCOdivider = 2, | 141 | .VCOdivider = 2, |
158 | .VCOnumber = 3, | 142 | .progdata = (0 << 19) | (1 << 9) | 0x02, |
159 | .progdata = (0 << 18) | (1 << 9) | 0x04, | ||
160 | }, | 143 | }, |
144 | |||
145 | /* band 5 */ | ||
161 | { | 146 | { |
162 | .freq_low = 1482000, | 147 | .freq_low = 1432000, |
163 | .freq_high = 1595999, | 148 | .freq_high = 1575999, |
164 | .bandselect = 0x08, | ||
165 | .VCOdivider = 2, | 149 | .VCOdivider = 2, |
166 | .VCOnumber = 4, | 150 | .progdata = (0 << 19) | (1 << 9) | 0x04, |
167 | .progdata = (0 << 18) | (1 << 9) | 0x08, | ||
168 | }, | 151 | }, |
152 | |||
153 | /* band 6 */ | ||
169 | { | 154 | { |
170 | .freq_low = 1596000, | 155 | .freq_low = 1576000, |
171 | .freq_high = 1717999, | 156 | .freq_high = 1717999, |
172 | .bandselect = 0x10, | ||
173 | .VCOdivider = 2, | 157 | .VCOdivider = 2, |
174 | .VCOnumber = 5, | 158 | .progdata = (0 << 19) | (1 << 9) | 0x08, |
175 | .progdata = (0 << 18) | (1 << 9) | 0x10, | ||
176 | }, | 159 | }, |
160 | |||
161 | /* band 7 */ | ||
177 | { | 162 | { |
178 | .freq_low = 1718000, | 163 | .freq_low = 1718000, |
179 | .freq_high = 1855999, | 164 | .freq_high = 1855999, |
180 | .bandselect = 0x20, | ||
181 | .VCOdivider = 2, | 165 | .VCOdivider = 2, |
182 | .VCOnumber = 6, | 166 | .progdata = (0 << 19) | (1 << 9) | 0x10, |
183 | .progdata = (0 << 18) | (1 << 9) | 0x20, | ||
184 | }, | 167 | }, |
168 | |||
169 | /* band 8 */ | ||
185 | { | 170 | { |
186 | .freq_low = 1856000, | 171 | .freq_low = 1856000, |
187 | .freq_high = 2035999, | 172 | .freq_high = 2035999, |
188 | .bandselect = 0x40, | ||
189 | .VCOdivider = 2, | 173 | .VCOdivider = 2, |
190 | .VCOnumber = 7, | 174 | .progdata = (0 << 19) | (1 << 9) | 0x20, |
191 | .progdata = (0 << 18) | (1 << 9) | 0x40, | ||
192 | }, | 175 | }, |
176 | |||
177 | /* band 9 */ | ||
193 | { | 178 | { |
194 | .freq_low = 2036000, | 179 | .freq_low = 2036000, |
195 | .freq_high = 2149999, | 180 | .freq_high = 2150000, |
196 | .bandselect = 0x80, | ||
197 | .VCOdivider = 2, | 181 | .VCOdivider = 2, |
198 | .VCOnumber = 8, | 182 | .progdata = (0 << 19) | (1 << 9) | 0x40, |
199 | .progdata = (0 << 18) | (1 << 9) | 0x80, | ||
200 | }, | 183 | }, |
201 | }; | 184 | }; |
202 | 185 | ||
@@ -207,49 +190,44 @@ static struct { | |||
207 | { | 190 | { |
208 | {0x00, 0x03}, /* Reset system */ | 191 | {0x00, 0x03}, /* Reset system */ |
209 | {0x00, 0x00}, /* Clear reset */ | 192 | {0x00, 0x00}, /* Clear reset */ |
210 | {0x01, 0x3b}, /* Apply sensible defaults, from an i2c sniffer */ | 193 | {0x03, 0x07}, /* QPSK, DVB, Auto Acquisition (default) */ |
211 | {0x03, 0x07}, | 194 | {0x04, 0x10}, /* MPEG */ |
212 | {0x04, 0x10}, | 195 | {0x05, 0x04}, /* MPEG */ |
213 | {0x05, 0x04}, | 196 | {0x06, 0x31}, /* MPEG (default) */ |
214 | {0x06, 0x31}, | 197 | {0x0b, 0x00}, /* Freq search start point (default) */ |
215 | {0x0d, 0x02}, | 198 | {0x0c, 0x00}, /* Demodulator sample gain (default) */ |
216 | {0x0e, 0x03}, | 199 | {0x0d, 0x02}, /* Frequency search range = Fsymbol / 4 (default) */ |
217 | {0x0f, 0xfe}, | 200 | {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */ |
218 | {0x10, 0x01}, | 201 | {0x0f, 0xfe}, /* FEC search mask (all supported codes) */ |
219 | {0x14, 0x01}, | 202 | {0x10, 0x01}, /* Default search inversion, no repeat (default) */ |
220 | {0x15, 0x98}, | 203 | {0x16, 0x00}, /* Enable reading of frequency */ |
221 | {0x16, 0x00}, | 204 | {0x17, 0x01}, /* Enable EsNO Ready Counter */ |
222 | {0x17, 0x01}, | 205 | {0x1c, 0x80}, /* Enable error counter */ |
223 | {0x1b, 0x05}, | 206 | {0x20, 0x00}, /* Tuner burst clock rate = 500KHz */ |
224 | {0x1c, 0x80}, | 207 | {0x21, 0x15}, /* Tuner burst mode, word length = 0x15 */ |
225 | {0x1d, 0x00}, | 208 | {0x28, 0x00}, /* Enable FILTERV with positive pol., DiSEqC 2.x off */ |
226 | {0x1e, 0x00}, | 209 | {0x29, 0x00}, /* DiSEqC LNB_DC off */ |
227 | {0x20, 0x41}, | 210 | {0x2a, 0xb0}, /* DiSEqC Parameters (default) */ |
228 | {0x21, 0x15}, | 211 | {0x2b, 0x73}, /* DiSEqC Tone Frequency (default) */ |
229 | {0x27, 0x14}, | 212 | {0x2c, 0x00}, /* DiSEqC Message (0x2c - 0x31) */ |
230 | {0x28, 0x46}, | ||
231 | {0x29, 0x00}, | ||
232 | {0x2a, 0xb0}, | ||
233 | {0x2b, 0x73}, | ||
234 | {0x2c, 0x00}, | ||
235 | {0x2d, 0x00}, | 213 | {0x2d, 0x00}, |
236 | {0x2e, 0x00}, | 214 | {0x2e, 0x00}, |
237 | {0x2f, 0x00}, | 215 | {0x2f, 0x00}, |
238 | {0x30, 0x00}, | 216 | {0x30, 0x00}, |
239 | {0x31, 0x00}, | 217 | {0x31, 0x00}, |
240 | {0x32, 0x8c}, | 218 | {0x32, 0x8c}, /* DiSEqC Parameters (default) */ |
241 | {0x33, 0x00}, | 219 | {0x33, 0x00}, /* Interrupts off (0x33 - 0x34) */ |
242 | {0x34, 0x00}, | 220 | {0x34, 0x00}, |
243 | {0x35, 0x03}, | 221 | {0x35, 0x03}, /* DiSEqC Tone Amplitude (default) */ |
244 | {0x36, 0x02}, | 222 | {0x36, 0x02}, /* DiSEqC Parameters (default) */ |
245 | {0x37, 0x3a}, | 223 | {0x37, 0x3a}, /* DiSEqC Parameters (default) */ |
246 | {0x3a, 0x00}, /* Enable AGC accumulator */ | 224 | {0x3a, 0x00}, /* Enable AGC accumulator (for signal strength) */ |
247 | {0x44, 0x00}, | 225 | {0x44, 0x00}, /* Constellation (default) */ |
248 | {0x45, 0x00}, | 226 | {0x45, 0x00}, /* Symbol count (default) */ |
249 | {0x46, 0x05}, | 227 | {0x46, 0x0d}, /* Symbol rate estimator on (default) */ |
250 | {0x56, 0x41}, | 228 | {0x56, 0x41}, /* Various (default) */ |
251 | {0x57, 0xff}, | 229 | {0x57, 0xff}, /* Error Counter Window (default) */ |
252 | {0x67, 0x83}, | 230 | {0x67, 0x83}, /* Non-DCII symbol clock */ |
253 | }; | 231 | }; |
254 | 232 | ||
255 | static int cx24123_writereg(struct cx24123_state* state, int reg, int data) | 233 | static int cx24123_writereg(struct cx24123_state* state, int reg, int data) |
@@ -258,6 +236,10 @@ static int cx24123_writereg(struct cx24123_state* state, int reg, int data) | |||
258 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; | 236 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; |
259 | int err; | 237 | int err; |
260 | 238 | ||
239 | if (debug>1) | ||
240 | printk("cx24123: %s: write reg 0x%02x, value 0x%02x\n", | ||
241 | __FUNCTION__,reg, data); | ||
242 | |||
261 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 243 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { |
262 | printk("%s: writereg error(err == %i, reg == 0x%02x," | 244 | printk("%s: writereg error(err == %i, reg == 0x%02x," |
263 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 245 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); |
@@ -274,6 +256,10 @@ static int cx24123_writelnbreg(struct cx24123_state* state, int reg, int data) | |||
274 | struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 }; | 256 | struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 }; |
275 | int err; | 257 | int err; |
276 | 258 | ||
259 | if (debug>1) | ||
260 | printk("cx24123: %s: writeln addr=0x08, reg 0x%02x, value 0x%02x\n", | ||
261 | __FUNCTION__,reg, data); | ||
262 | |||
277 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 263 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { |
278 | printk("%s: writelnbreg error (err == %i, reg == 0x%02x," | 264 | printk("%s: writelnbreg error (err == %i, reg == 0x%02x," |
279 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 265 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); |
@@ -303,6 +289,9 @@ static int cx24123_readreg(struct cx24123_state* state, u8 reg) | |||
303 | return ret; | 289 | return ret; |
304 | } | 290 | } |
305 | 291 | ||
292 | if (debug>1) | ||
293 | printk("cx24123: read reg 0x%02x, value 0x%02x\n",reg, ret); | ||
294 | |||
306 | return b1[0]; | 295 | return b1[0]; |
307 | } | 296 | } |
308 | 297 | ||
@@ -313,17 +302,23 @@ static int cx24123_readlnbreg(struct cx24123_state* state, u8 reg) | |||
313 | 302 | ||
314 | static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) | 303 | static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) |
315 | { | 304 | { |
305 | u8 nom_reg = cx24123_readreg(state, 0x0e); | ||
306 | u8 auto_reg = cx24123_readreg(state, 0x10); | ||
307 | |||
316 | switch (inversion) { | 308 | switch (inversion) { |
317 | case INVERSION_OFF: | 309 | case INVERSION_OFF: |
318 | cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) & 0x7f); | 310 | dprintk("%s: inversion off\n",__FUNCTION__); |
319 | cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); | 311 | cx24123_writereg(state, 0x0e, nom_reg & ~0x80); |
312 | cx24123_writereg(state, 0x10, auto_reg | 0x80); | ||
320 | break; | 313 | break; |
321 | case INVERSION_ON: | 314 | case INVERSION_ON: |
322 | cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) | 0x80); | 315 | dprintk("%s: inversion on\n",__FUNCTION__); |
323 | cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80); | 316 | cx24123_writereg(state, 0x0e, nom_reg | 0x80); |
317 | cx24123_writereg(state, 0x10, auto_reg | 0x80); | ||
324 | break; | 318 | break; |
325 | case INVERSION_AUTO: | 319 | case INVERSION_AUTO: |
326 | cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) & 0x7f); | 320 | dprintk("%s: inversion auto\n",__FUNCTION__); |
321 | cx24123_writereg(state, 0x10, auto_reg & ~0x80); | ||
327 | break; | 322 | break; |
328 | default: | 323 | default: |
329 | return -EINVAL; | 324 | return -EINVAL; |
@@ -338,92 +333,191 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers | |||
338 | 333 | ||
339 | val = cx24123_readreg(state, 0x1b) >> 7; | 334 | val = cx24123_readreg(state, 0x1b) >> 7; |
340 | 335 | ||
341 | if (val == 0) | 336 | if (val == 0) { |
337 | dprintk("%s: read inversion off\n",__FUNCTION__); | ||
342 | *inversion = INVERSION_OFF; | 338 | *inversion = INVERSION_OFF; |
343 | else | 339 | } else { |
340 | dprintk("%s: read inversion on\n",__FUNCTION__); | ||
344 | *inversion = INVERSION_ON; | 341 | *inversion = INVERSION_ON; |
342 | } | ||
345 | 343 | ||
346 | return 0; | 344 | return 0; |
347 | } | 345 | } |
348 | 346 | ||
349 | static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) | 347 | static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) |
350 | { | 348 | { |
349 | u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; | ||
350 | |||
351 | if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) | 351 | if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) |
352 | fec = FEC_AUTO; | 352 | fec = FEC_AUTO; |
353 | 353 | ||
354 | /* Hardware has 5/11 and 3/5 but are never unused */ | ||
355 | switch (fec) { | 354 | switch (fec) { |
356 | case FEC_NONE: | ||
357 | return cx24123_writereg(state, 0x0f, 0x01); | ||
358 | case FEC_1_2: | 355 | case FEC_1_2: |
359 | return cx24123_writereg(state, 0x0f, 0x02); | 356 | dprintk("%s: set FEC to 1/2\n",__FUNCTION__); |
357 | cx24123_writereg(state, 0x0e, nom_reg | 0x01); | ||
358 | cx24123_writereg(state, 0x0f, 0x02); | ||
359 | break; | ||
360 | case FEC_2_3: | 360 | case FEC_2_3: |
361 | return cx24123_writereg(state, 0x0f, 0x04); | 361 | dprintk("%s: set FEC to 2/3\n",__FUNCTION__); |
362 | cx24123_writereg(state, 0x0e, nom_reg | 0x02); | ||
363 | cx24123_writereg(state, 0x0f, 0x04); | ||
364 | break; | ||
362 | case FEC_3_4: | 365 | case FEC_3_4: |
363 | return cx24123_writereg(state, 0x0f, 0x08); | 366 | dprintk("%s: set FEC to 3/4\n",__FUNCTION__); |
367 | cx24123_writereg(state, 0x0e, nom_reg | 0x03); | ||
368 | cx24123_writereg(state, 0x0f, 0x08); | ||
369 | break; | ||
370 | case FEC_4_5: | ||
371 | dprintk("%s: set FEC to 4/5\n",__FUNCTION__); | ||
372 | cx24123_writereg(state, 0x0e, nom_reg | 0x04); | ||
373 | cx24123_writereg(state, 0x0f, 0x10); | ||
374 | break; | ||
364 | case FEC_5_6: | 375 | case FEC_5_6: |
365 | return cx24123_writereg(state, 0x0f, 0x20); | 376 | dprintk("%s: set FEC to 5/6\n",__FUNCTION__); |
377 | cx24123_writereg(state, 0x0e, nom_reg | 0x05); | ||
378 | cx24123_writereg(state, 0x0f, 0x20); | ||
379 | break; | ||
380 | case FEC_6_7: | ||
381 | dprintk("%s: set FEC to 6/7\n",__FUNCTION__); | ||
382 | cx24123_writereg(state, 0x0e, nom_reg | 0x06); | ||
383 | cx24123_writereg(state, 0x0f, 0x40); | ||
384 | break; | ||
366 | case FEC_7_8: | 385 | case FEC_7_8: |
367 | return cx24123_writereg(state, 0x0f, 0x80); | 386 | dprintk("%s: set FEC to 7/8\n",__FUNCTION__); |
387 | cx24123_writereg(state, 0x0e, nom_reg | 0x07); | ||
388 | cx24123_writereg(state, 0x0f, 0x80); | ||
389 | break; | ||
368 | case FEC_AUTO: | 390 | case FEC_AUTO: |
369 | return cx24123_writereg(state, 0x0f, 0xae); | 391 | dprintk("%s: set FEC to auto\n",__FUNCTION__); |
392 | cx24123_writereg(state, 0x0f, 0xfe); | ||
393 | break; | ||
370 | default: | 394 | default: |
371 | return -EOPNOTSUPP; | 395 | return -EOPNOTSUPP; |
372 | } | 396 | } |
397 | |||
398 | return 0; | ||
373 | } | 399 | } |
374 | 400 | ||
375 | static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) | 401 | static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) |
376 | { | 402 | { |
377 | int ret; | 403 | int ret; |
378 | u8 val; | ||
379 | 404 | ||
380 | ret = cx24123_readreg (state, 0x1b); | 405 | ret = cx24123_readreg (state, 0x1b); |
381 | if (ret < 0) | 406 | if (ret < 0) |
382 | return ret; | 407 | return ret; |
383 | val = ret & 0x07; | 408 | ret = ret & 0x07; |
384 | switch (val) { | 409 | |
410 | switch (ret) { | ||
385 | case 1: | 411 | case 1: |
386 | *fec = FEC_1_2; | 412 | *fec = FEC_1_2; |
387 | break; | 413 | break; |
388 | case 3: | 414 | case 2: |
389 | *fec = FEC_2_3; | 415 | *fec = FEC_2_3; |
390 | break; | 416 | break; |
391 | case 4: | 417 | case 3: |
392 | *fec = FEC_3_4; | 418 | *fec = FEC_3_4; |
393 | break; | 419 | break; |
394 | case 5: | 420 | case 4: |
395 | *fec = FEC_4_5; | 421 | *fec = FEC_4_5; |
396 | break; | 422 | break; |
397 | case 6: | 423 | case 5: |
398 | *fec = FEC_5_6; | 424 | *fec = FEC_5_6; |
399 | break; | 425 | break; |
426 | case 6: | ||
427 | *fec = FEC_6_7; | ||
428 | break; | ||
400 | case 7: | 429 | case 7: |
401 | *fec = FEC_7_8; | 430 | *fec = FEC_7_8; |
402 | break; | 431 | break; |
403 | case 2: /* *fec = FEC_3_5; break; */ | ||
404 | case 0: /* *fec = FEC_5_11; break; */ | ||
405 | *fec = FEC_AUTO; | ||
406 | break; | ||
407 | default: | 432 | default: |
408 | *fec = FEC_NONE; // can't happen | 433 | /* this can happen when there's no lock */ |
434 | *fec = FEC_NONE; | ||
409 | } | 435 | } |
410 | 436 | ||
411 | return 0; | 437 | return 0; |
412 | } | 438 | } |
413 | 439 | ||
414 | /* fixme: Symbol rates < 3MSps may not work because of precision loss */ | 440 | /* Approximation of closest integer of log2(a/b). It actually gives the |
441 | lowest integer i such that 2^i >= round(a/b) */ | ||
442 | static u32 cx24123_int_log2(u32 a, u32 b) | ||
443 | { | ||
444 | u32 exp, nearest = 0; | ||
445 | u32 div = a / b; | ||
446 | if(a % b >= b / 2) ++div; | ||
447 | if(div < (1 << 31)) | ||
448 | { | ||
449 | for(exp = 1; div > exp; nearest++) | ||
450 | exp += exp; | ||
451 | } | ||
452 | return nearest; | ||
453 | } | ||
454 | |||
415 | static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) | 455 | static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) |
416 | { | 456 | { |
417 | u32 val; | 457 | u32 tmp, sample_rate, ratio, sample_gain; |
458 | u8 pll_mult; | ||
459 | |||
460 | /* check if symbol rate is within limits */ | ||
461 | if ((srate > state->ops.info.symbol_rate_max) || | ||
462 | (srate < state->ops.info.symbol_rate_min)) | ||
463 | return -EOPNOTSUPP;; | ||
464 | |||
465 | /* choose the sampling rate high enough for the required operation, | ||
466 | while optimizing the power consumed by the demodulator */ | ||
467 | if (srate < (XTAL*2)/2) | ||
468 | pll_mult = 2; | ||
469 | else if (srate < (XTAL*3)/2) | ||
470 | pll_mult = 3; | ||
471 | else if (srate < (XTAL*4)/2) | ||
472 | pll_mult = 4; | ||
473 | else if (srate < (XTAL*5)/2) | ||
474 | pll_mult = 5; | ||
475 | else if (srate < (XTAL*6)/2) | ||
476 | pll_mult = 6; | ||
477 | else if (srate < (XTAL*7)/2) | ||
478 | pll_mult = 7; | ||
479 | else if (srate < (XTAL*8)/2) | ||
480 | pll_mult = 8; | ||
481 | else | ||
482 | pll_mult = 9; | ||
483 | |||
484 | |||
485 | sample_rate = pll_mult * XTAL; | ||
486 | |||
487 | /* | ||
488 | SYSSymbolRate[21:0] = (srate << 23) / sample_rate | ||
489 | |||
490 | We have to use 32 bit unsigned arithmetic without precision loss. | ||
491 | The maximum srate is 45000000 or 0x02AEA540. This number has | ||
492 | only 6 clear bits on top, hence we can shift it left only 6 bits | ||
493 | at a time. Borrowed from cx24110.c | ||
494 | */ | ||
495 | |||
496 | tmp = srate << 6; | ||
497 | ratio = tmp / sample_rate; | ||
498 | |||
499 | tmp = (tmp % sample_rate) << 6; | ||
500 | ratio = (ratio << 6) + (tmp / sample_rate); | ||
501 | |||
502 | tmp = (tmp % sample_rate) << 6; | ||
503 | ratio = (ratio << 6) + (tmp / sample_rate); | ||
504 | |||
505 | tmp = (tmp % sample_rate) << 5; | ||
506 | ratio = (ratio << 5) + (tmp / sample_rate); | ||
507 | |||
508 | |||
509 | cx24123_writereg(state, 0x01, pll_mult * 6); | ||
418 | 510 | ||
419 | val = (srate / 1185) * 100; | 511 | cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f ); |
512 | cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff ); | ||
513 | cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); | ||
420 | 514 | ||
421 | /* Compensate for scaling up, by removing 17 symbols per 1Msps */ | 515 | /* also set the demodulator sample gain */ |
422 | val = val - (17 * (srate / 1000000)); | 516 | sample_gain = cx24123_int_log2(sample_rate, srate); |
517 | tmp = cx24123_readreg(state, 0x0c) & ~0xe0; | ||
518 | cx24123_writereg(state, 0x0c, tmp | sample_gain << 5); | ||
423 | 519 | ||
424 | cx24123_writereg(state, 0x08, (val >> 16) & 0xff ); | 520 | dprintk("%s: srate=%d, ratio=0x%08x, sample_rate=%i sample_gain=%d\n", __FUNCTION__, srate, ratio, sample_rate, sample_gain); |
425 | cx24123_writereg(state, 0x09, (val >> 8) & 0xff ); | ||
426 | cx24123_writereg(state, 0x0a, (val ) & 0xff ); | ||
427 | 521 | ||
428 | return 0; | 522 | return 0; |
429 | } | 523 | } |
@@ -437,6 +531,9 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
437 | struct cx24123_state *state = fe->demodulator_priv; | 531 | struct cx24123_state *state = fe->demodulator_priv; |
438 | u32 ndiv = 0, adiv = 0, vco_div = 0; | 532 | u32 ndiv = 0, adiv = 0, vco_div = 0; |
439 | int i = 0; | 533 | int i = 0; |
534 | int pump = 2; | ||
535 | int band = 0; | ||
536 | int num_bands = sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]); | ||
440 | 537 | ||
441 | /* Defaults for low freq, low rate */ | 538 | /* Defaults for low freq, low rate */ |
442 | state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; | 539 | state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; |
@@ -444,38 +541,49 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
444 | state->bandselectarg = cx24123_bandselect_vals[0].progdata; | 541 | state->bandselectarg = cx24123_bandselect_vals[0].progdata; |
445 | vco_div = cx24123_bandselect_vals[0].VCOdivider; | 542 | vco_div = cx24123_bandselect_vals[0].VCOdivider; |
446 | 543 | ||
447 | /* For the given symbolerate, determine the VCA and VGA programming bits */ | 544 | /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ |
448 | for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++) | 545 | for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++) |
449 | { | 546 | { |
450 | if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && | 547 | if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && |
451 | (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { | 548 | (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { |
452 | state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; | 549 | state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; |
453 | state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; | 550 | state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; |
551 | state->FILTune = cx24123_AGC_vals[i].FILTune; | ||
454 | } | 552 | } |
455 | } | 553 | } |
456 | 554 | ||
457 | /* For the given frequency, determine the bandselect programming bits */ | 555 | /* determine the band to use */ |
458 | for (i = 0; i < sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]); i++) | 556 | if(force_band < 1 || force_band > num_bands) |
459 | { | 557 | { |
460 | if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && | 558 | for (i = 0; i < num_bands; i++) |
461 | (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) { | 559 | { |
462 | state->bandselectarg = cx24123_bandselect_vals[i].progdata; | 560 | if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && |
463 | vco_div = cx24123_bandselect_vals[i].VCOdivider; | 561 | (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) |
562 | band = i; | ||
464 | } | 563 | } |
465 | } | 564 | } |
565 | else | ||
566 | band = force_band - 1; | ||
567 | |||
568 | state->bandselectarg = cx24123_bandselect_vals[band].progdata; | ||
569 | vco_div = cx24123_bandselect_vals[band].VCOdivider; | ||
570 | |||
571 | /* determine the charge pump current */ | ||
572 | if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) | ||
573 | pump = 0x01; | ||
574 | else | ||
575 | pump = 0x02; | ||
466 | 576 | ||
467 | /* Determine the N/A dividers for the requested lband freq (in kHz). */ | 577 | /* Determine the N/A dividers for the requested lband freq (in kHz). */ |
468 | /* Note: 10111 (kHz) is the Crystal Freq and divider of 10. */ | 578 | /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ |
469 | ndiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) / 32) & 0x1ff; | 579 | ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; |
470 | adiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) % 32) & 0x1f; | 580 | adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; |
471 | 581 | ||
472 | if (adiv == 0) | 582 | if (adiv == 0) |
473 | adiv++; | 583 | ndiv++; |
474 | 584 | ||
475 | /* determine the correct pll frequency values. */ | 585 | /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ |
476 | /* Command 11, refdiv 11, cpump polarity 1, cpump current 3mA 10. */ | 586 | state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; |
477 | state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (2 << 14); | ||
478 | state->pllarg |= (ndiv << 5) | adiv; | ||
479 | 587 | ||
480 | return 0; | 588 | return 0; |
481 | } | 589 | } |
@@ -489,6 +597,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
489 | struct cx24123_state *state = fe->demodulator_priv; | 597 | struct cx24123_state *state = fe->demodulator_priv; |
490 | unsigned long timeout; | 598 | unsigned long timeout; |
491 | 599 | ||
600 | dprintk("%s: pll writereg called, data=0x%08x\n",__FUNCTION__,data); | ||
601 | |||
492 | /* align the 21 bytes into to bit23 boundary */ | 602 | /* align the 21 bytes into to bit23 boundary */ |
493 | data = data << 3; | 603 | data = data << 3; |
494 | 604 | ||
@@ -538,6 +648,9 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
538 | static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 648 | static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) |
539 | { | 649 | { |
540 | struct cx24123_state *state = fe->demodulator_priv; | 650 | struct cx24123_state *state = fe->demodulator_priv; |
651 | u8 val; | ||
652 | |||
653 | dprintk("frequency=%i\n", p->frequency); | ||
541 | 654 | ||
542 | if (cx24123_pll_calculate(fe, p) != 0) { | 655 | if (cx24123_pll_calculate(fe, p) != 0) { |
543 | printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__); | 656 | printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__); |
@@ -552,6 +665,14 @@ static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
552 | cx24123_pll_writereg(fe, p, state->bandselectarg); | 665 | cx24123_pll_writereg(fe, p, state->bandselectarg); |
553 | cx24123_pll_writereg(fe, p, state->pllarg); | 666 | cx24123_pll_writereg(fe, p, state->pllarg); |
554 | 667 | ||
668 | /* set the FILTUNE voltage */ | ||
669 | val = cx24123_readreg(state, 0x28) & ~0x3; | ||
670 | cx24123_writereg(state, 0x27, state->FILTune >> 2); | ||
671 | cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3)); | ||
672 | |||
673 | dprintk("%s: pll tune VCA=%d, band=%d, pll=%d\n",__FUNCTION__,state->VCAarg, | ||
674 | state->bandselectarg,state->pllarg); | ||
675 | |||
555 | return 0; | 676 | return 0; |
556 | } | 677 | } |
557 | 678 | ||
@@ -560,6 +681,8 @@ static int cx24123_initfe(struct dvb_frontend* fe) | |||
560 | struct cx24123_state *state = fe->demodulator_priv; | 681 | struct cx24123_state *state = fe->demodulator_priv; |
561 | int i; | 682 | int i; |
562 | 683 | ||
684 | dprintk("%s: init frontend\n",__FUNCTION__); | ||
685 | |||
563 | /* Configure the demod to a good set of defaults */ | 686 | /* Configure the demod to a good set of defaults */ |
564 | for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) | 687 | for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) |
565 | cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); | 688 | cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); |
@@ -587,10 +710,13 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage | |||
587 | 710 | ||
588 | switch (voltage) { | 711 | switch (voltage) { |
589 | case SEC_VOLTAGE_13: | 712 | case SEC_VOLTAGE_13: |
713 | dprintk("%s: isl6421 voltage = 13V\n",__FUNCTION__); | ||
590 | return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */ | 714 | return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */ |
591 | case SEC_VOLTAGE_18: | 715 | case SEC_VOLTAGE_18: |
716 | dprintk("%s: isl6421 voltage = 18V\n",__FUNCTION__); | ||
592 | return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */ | 717 | return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */ |
593 | case SEC_VOLTAGE_OFF: | 718 | case SEC_VOLTAGE_OFF: |
719 | dprintk("%s: isl5421 voltage off\n",__FUNCTION__); | ||
594 | return cx24123_writelnbreg(state, 0x0, val & 0x30); | 720 | return cx24123_writelnbreg(state, 0x0, val & 0x30); |
595 | default: | 721 | default: |
596 | return -EINVAL; | 722 | return -EINVAL; |
@@ -624,13 +750,93 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage | |||
624 | return 0; | 750 | return 0; |
625 | } | 751 | } |
626 | 752 | ||
627 | static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, | 753 | /* wait for diseqc queue to become ready (or timeout) */ |
628 | struct dvb_diseqc_master_cmd *cmd) | 754 | static void cx24123_wait_for_diseqc(struct cx24123_state *state) |
755 | { | ||
756 | unsigned long timeout = jiffies + msecs_to_jiffies(200); | ||
757 | while (!(cx24123_readreg(state, 0x29) & 0x40)) { | ||
758 | if(time_after(jiffies, timeout)) { | ||
759 | printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__); | ||
760 | break; | ||
761 | } | ||
762 | msleep(10); | ||
763 | } | ||
764 | } | ||
765 | |||
766 | static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) | ||
629 | { | 767 | { |
630 | /* fixme: Implement diseqc */ | 768 | struct cx24123_state *state = fe->demodulator_priv; |
631 | printk("%s: No support yet\n",__FUNCTION__); | 769 | int i, val; |
770 | |||
771 | dprintk("%s:\n",__FUNCTION__); | ||
772 | |||
773 | /* check if continuous tone has been stopped */ | ||
774 | if (state->config->use_isl6421) | ||
775 | val = cx24123_readlnbreg(state, 0x00) & 0x10; | ||
776 | else | ||
777 | val = cx24123_readreg(state, 0x29) & 0x10; | ||
632 | 778 | ||
633 | return -ENOTSUPP; | 779 | |
780 | if (val) { | ||
781 | printk("%s: ERROR: attempt to send diseqc command before tone is off\n", __FUNCTION__); | ||
782 | return -ENOTSUPP; | ||
783 | } | ||
784 | |||
785 | /* wait for diseqc queue ready */ | ||
786 | cx24123_wait_for_diseqc(state); | ||
787 | |||
788 | /* select tone mode */ | ||
789 | cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xf8); | ||
790 | |||
791 | for (i = 0; i < cmd->msg_len; i++) | ||
792 | cx24123_writereg(state, 0x2C + i, cmd->msg[i]); | ||
793 | |||
794 | val = cx24123_readreg(state, 0x29); | ||
795 | cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); | ||
796 | |||
797 | /* wait for diseqc message to finish sending */ | ||
798 | cx24123_wait_for_diseqc(state); | ||
799 | |||
800 | return 0; | ||
801 | } | ||
802 | |||
803 | static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | ||
804 | { | ||
805 | struct cx24123_state *state = fe->demodulator_priv; | ||
806 | int val; | ||
807 | |||
808 | dprintk("%s:\n", __FUNCTION__); | ||
809 | |||
810 | /* check if continuous tone has been stoped */ | ||
811 | if (state->config->use_isl6421) | ||
812 | val = cx24123_readlnbreg(state, 0x00) & 0x10; | ||
813 | else | ||
814 | val = cx24123_readreg(state, 0x29) & 0x10; | ||
815 | |||
816 | |||
817 | if (val) { | ||
818 | printk("%s: ERROR: attempt to send diseqc command before tone is off\n", __FUNCTION__); | ||
819 | return -ENOTSUPP; | ||
820 | } | ||
821 | |||
822 | cx24123_wait_for_diseqc(state); | ||
823 | |||
824 | /* select tone mode */ | ||
825 | val = cx24123_readreg(state, 0x2a) & 0xf8; | ||
826 | cx24123_writereg(state, 0x2a, val | 0x04); | ||
827 | |||
828 | val = cx24123_readreg(state, 0x29); | ||
829 | |||
830 | if (burst == SEC_MINI_A) | ||
831 | cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x00)); | ||
832 | else if (burst == SEC_MINI_B) | ||
833 | cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x08)); | ||
834 | else | ||
835 | return -EINVAL; | ||
836 | |||
837 | cx24123_wait_for_diseqc(state); | ||
838 | |||
839 | return 0; | ||
634 | } | 840 | } |
635 | 841 | ||
636 | static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | 842 | static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) |
@@ -642,13 +848,15 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
642 | 848 | ||
643 | *status = 0; | 849 | *status = 0; |
644 | if (lock & 0x01) | 850 | if (lock & 0x01) |
645 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; | 851 | *status |= FE_HAS_SIGNAL; |
852 | if (sync & 0x02) | ||
853 | *status |= FE_HAS_CARRIER; | ||
646 | if (sync & 0x04) | 854 | if (sync & 0x04) |
647 | *status |= FE_HAS_VITERBI; | 855 | *status |= FE_HAS_VITERBI; |
648 | if (sync & 0x08) | 856 | if (sync & 0x08) |
649 | *status |= FE_HAS_CARRIER; | 857 | *status |= FE_HAS_SYNC; |
650 | if (sync & 0x80) | 858 | if (sync & 0x80) |
651 | *status |= FE_HAS_SYNC | FE_HAS_LOCK; | 859 | *status |= FE_HAS_LOCK; |
652 | 860 | ||
653 | return 0; | 861 | return 0; |
654 | } | 862 | } |
@@ -681,6 +889,8 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber) | |||
681 | else | 889 | else |
682 | state->snr = 0; | 890 | state->snr = 0; |
683 | 891 | ||
892 | dprintk("%s: BER = %d, S/N index = %d\n",__FUNCTION__,state->lastber, state->snr); | ||
893 | |||
684 | *ber = state->lastber; | 894 | *ber = state->lastber; |
685 | 895 | ||
686 | return 0; | 896 | return 0; |
@@ -691,6 +901,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_str | |||
691 | struct cx24123_state *state = fe->demodulator_priv; | 901 | struct cx24123_state *state = fe->demodulator_priv; |
692 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ | 902 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ |
693 | 903 | ||
904 | dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength); | ||
905 | |||
694 | return 0; | 906 | return 0; |
695 | } | 907 | } |
696 | 908 | ||
@@ -699,6 +911,8 @@ static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) | |||
699 | struct cx24123_state *state = fe->demodulator_priv; | 911 | struct cx24123_state *state = fe->demodulator_priv; |
700 | *snr = state->snr; | 912 | *snr = state->snr; |
701 | 913 | ||
914 | dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr); | ||
915 | |||
702 | return 0; | 916 | return 0; |
703 | } | 917 | } |
704 | 918 | ||
@@ -707,6 +921,8 @@ static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
707 | struct cx24123_state *state = fe->demodulator_priv; | 921 | struct cx24123_state *state = fe->demodulator_priv; |
708 | *ucblocks = state->lastber; | 922 | *ucblocks = state->lastber; |
709 | 923 | ||
924 | dprintk("%s: ucblocks (ber) = %d\n",__FUNCTION__,*ucblocks); | ||
925 | |||
710 | return 0; | 926 | return 0; |
711 | } | 927 | } |
712 | 928 | ||
@@ -714,6 +930,8 @@ static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
714 | { | 930 | { |
715 | struct cx24123_state *state = fe->demodulator_priv; | 931 | struct cx24123_state *state = fe->demodulator_priv; |
716 | 932 | ||
933 | dprintk("%s: set_frontend\n",__FUNCTION__); | ||
934 | |||
717 | if (state->config->set_ts_params) | 935 | if (state->config->set_ts_params) |
718 | state->config->set_ts_params(fe, 0); | 936 | state->config->set_ts_params(fe, 0); |
719 | 937 | ||
@@ -737,6 +955,8 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
737 | { | 955 | { |
738 | struct cx24123_state *state = fe->demodulator_priv; | 956 | struct cx24123_state *state = fe->demodulator_priv; |
739 | 957 | ||
958 | dprintk("%s: get_frontend\n",__FUNCTION__); | ||
959 | |||
740 | if (cx24123_get_inversion(state, &p->inversion) != 0) { | 960 | if (cx24123_get_inversion(state, &p->inversion) != 0) { |
741 | printk("%s: Failed to get inversion status\n",__FUNCTION__); | 961 | printk("%s: Failed to get inversion status\n",__FUNCTION__); |
742 | return -EREMOTEIO; | 962 | return -EREMOTEIO; |
@@ -763,8 +983,10 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
763 | 983 | ||
764 | switch (tone) { | 984 | switch (tone) { |
765 | case SEC_TONE_ON: | 985 | case SEC_TONE_ON: |
986 | dprintk("%s: isl6421 sec tone on\n",__FUNCTION__); | ||
766 | return cx24123_writelnbreg(state, 0x0, val | 0x10); | 987 | return cx24123_writelnbreg(state, 0x0, val | 0x10); |
767 | case SEC_TONE_OFF: | 988 | case SEC_TONE_OFF: |
989 | dprintk("%s: isl6421 sec tone off\n",__FUNCTION__); | ||
768 | return cx24123_writelnbreg(state, 0x0, val & 0x2f); | 990 | return cx24123_writelnbreg(state, 0x0, val & 0x2f); |
769 | default: | 991 | default: |
770 | printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); | 992 | printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); |
@@ -855,12 +1077,13 @@ static struct dvb_frontend_ops cx24123_ops = { | |||
855 | .frequency_min = 950000, | 1077 | .frequency_min = 950000, |
856 | .frequency_max = 2150000, | 1078 | .frequency_max = 2150000, |
857 | .frequency_stepsize = 1011, /* kHz for QPSK frontends */ | 1079 | .frequency_stepsize = 1011, /* kHz for QPSK frontends */ |
858 | .frequency_tolerance = 29500, | 1080 | .frequency_tolerance = 5000, |
859 | .symbol_rate_min = 1000000, | 1081 | .symbol_rate_min = 1000000, |
860 | .symbol_rate_max = 45000000, | 1082 | .symbol_rate_max = 45000000, |
861 | .caps = FE_CAN_INVERSION_AUTO | | 1083 | .caps = FE_CAN_INVERSION_AUTO | |
862 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | 1084 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
863 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | 1085 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | |
1086 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | ||
864 | FE_CAN_QPSK | FE_CAN_RECOVER | 1087 | FE_CAN_QPSK | FE_CAN_RECOVER |
865 | }, | 1088 | }, |
866 | 1089 | ||
@@ -875,12 +1098,16 @@ static struct dvb_frontend_ops cx24123_ops = { | |||
875 | .read_snr = cx24123_read_snr, | 1098 | .read_snr = cx24123_read_snr, |
876 | .read_ucblocks = cx24123_read_ucblocks, | 1099 | .read_ucblocks = cx24123_read_ucblocks, |
877 | .diseqc_send_master_cmd = cx24123_send_diseqc_msg, | 1100 | .diseqc_send_master_cmd = cx24123_send_diseqc_msg, |
1101 | .diseqc_send_burst = cx24123_diseqc_send_burst, | ||
878 | .set_tone = cx24123_set_tone, | 1102 | .set_tone = cx24123_set_tone, |
879 | .set_voltage = cx24123_set_voltage, | 1103 | .set_voltage = cx24123_set_voltage, |
880 | }; | 1104 | }; |
881 | 1105 | ||
882 | module_param(debug, int, 0644); | 1106 | module_param(debug, int, 0644); |
883 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | 1107 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); |
1108 | |||
1109 | module_param(force_band, int, 0644); | ||
1110 | MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); | ||
884 | 1111 | ||
885 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware"); | 1112 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware"); |
886 | MODULE_AUTHOR("Steven Toth"); | 1113 | MODULE_AUTHOR("Steven Toth"); |
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index b6e2c387a04c..791706ec1da3 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c | |||
@@ -235,8 +235,8 @@ struct dvb_pll_desc dvb_pll_tdvs_tua6034 = { | |||
235 | .max = 863000000, | 235 | .max = 863000000, |
236 | .count = 3, | 236 | .count = 3, |
237 | .entries = { | 237 | .entries = { |
238 | { 160000000, 44000000, 62500, 0xce, 0x01 }, | 238 | { 165000000, 44000000, 62500, 0xce, 0x01 }, |
239 | { 455000000, 44000000, 62500, 0xce, 0x02 }, | 239 | { 450000000, 44000000, 62500, 0xce, 0x02 }, |
240 | { 999999999, 44000000, 62500, 0xce, 0x04 }, | 240 | { 999999999, 44000000, 62500, 0xce, 0x04 }, |
241 | }, | 241 | }, |
242 | }; | 242 | }; |
diff --git a/drivers/media/dvb/pluto2/Kconfig b/drivers/media/dvb/pluto2/Kconfig index 84f8f9f52869..7d8e6e87bdbb 100644 --- a/drivers/media/dvb/pluto2/Kconfig +++ b/drivers/media/dvb/pluto2/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config DVB_PLUTO2 | 1 | config DVB_PLUTO2 |
2 | tristate "Pluto2 cards" | 2 | tristate "Pluto2 cards" |
3 | depends on DVB_CORE && PCI | 3 | depends on DVB_CORE && PCI && I2C |
4 | select I2C | ||
5 | select I2C_ALGOBIT | 4 | select I2C_ALGOBIT |
6 | select DVB_TDA1004X | 5 | select DVB_TDA1004X |
7 | help | 6 | help |
diff --git a/drivers/media/dvb/pluto2/Makefile b/drivers/media/dvb/pluto2/Makefile index 86ca84b2be6e..ce6a9aaf937e 100644 --- a/drivers/media/dvb/pluto2/Makefile +++ b/drivers/media/dvb/pluto2/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | obj-$(CONFIG_DVB_PLUTO2) = pluto2.o | 1 | obj-$(CONFIG_DVB_PLUTO2) += pluto2.o |
2 | 2 | ||
3 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 3 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig index 5b2aadb8385c..b5ac7dfde52f 100644 --- a/drivers/media/dvb/ttpci/Kconfig +++ b/drivers/media/dvb/ttpci/Kconfig | |||
@@ -1,8 +1,7 @@ | |||
1 | config DVB_AV7110 | 1 | config DVB_AV7110 |
2 | tristate "AV7110 cards" | 2 | tristate "AV7110 cards" |
3 | depends on DVB_CORE && PCI | 3 | depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 |
4 | select FW_LOADER | 4 | select FW_LOADER |
5 | select VIDEO_DEV | ||
6 | select VIDEO_SAA7146_VV | 5 | select VIDEO_SAA7146_VV |
7 | select DVB_VES1820 | 6 | select DVB_VES1820 |
8 | select DVB_VES1X93 | 7 | select DVB_VES1X93 |
@@ -59,7 +58,7 @@ config DVB_AV7110_OSD | |||
59 | 58 | ||
60 | config DVB_BUDGET | 59 | config DVB_BUDGET |
61 | tristate "Budget cards" | 60 | tristate "Budget cards" |
62 | depends on DVB_CORE && PCI | 61 | depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 |
63 | select VIDEO_SAA7146 | 62 | select VIDEO_SAA7146 |
64 | select DVB_STV0299 | 63 | select DVB_STV0299 |
65 | select DVB_VES1X93 | 64 | select DVB_VES1X93 |
@@ -80,7 +79,7 @@ config DVB_BUDGET | |||
80 | 79 | ||
81 | config DVB_BUDGET_CI | 80 | config DVB_BUDGET_CI |
82 | tristate "Budget cards with onboard CI connector" | 81 | tristate "Budget cards with onboard CI connector" |
83 | depends on DVB_CORE && PCI | 82 | depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 |
84 | select VIDEO_SAA7146 | 83 | select VIDEO_SAA7146 |
85 | select DVB_STV0297 | 84 | select DVB_STV0297 |
86 | select DVB_STV0299 | 85 | select DVB_STV0299 |
@@ -100,8 +99,7 @@ config DVB_BUDGET_CI | |||
100 | 99 | ||
101 | config DVB_BUDGET_AV | 100 | config DVB_BUDGET_AV |
102 | tristate "Budget cards with analog video inputs" | 101 | tristate "Budget cards with analog video inputs" |
103 | depends on DVB_CORE && PCI | 102 | depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 |
104 | select VIDEO_DEV | ||
105 | select VIDEO_SAA7146_VV | 103 | select VIDEO_SAA7146_VV |
106 | select DVB_STV0299 | 104 | select DVB_STV0299 |
107 | select DVB_TDA1004X | 105 | select DVB_TDA1004X |
@@ -119,7 +117,7 @@ config DVB_BUDGET_AV | |||
119 | 117 | ||
120 | config DVB_BUDGET_PATCH | 118 | config DVB_BUDGET_PATCH |
121 | tristate "AV7110 cards with Budget Patch" | 119 | tristate "AV7110 cards with Budget Patch" |
122 | depends on DVB_CORE && DVB_BUDGET | 120 | depends on DVB_CORE && DVB_BUDGET && VIDEO_V4L1 |
123 | select DVB_AV7110 | 121 | select DVB_AV7110 |
124 | select DVB_STV0299 | 122 | select DVB_STV0299 |
125 | select DVB_VES1X93 | 123 | select DVB_VES1X93 |
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 8efe3ce5f66c..8a7cd7d505cf 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -1190,8 +1190,6 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1190 | SAA7146_HPS_SYNC_PORT_A); | 1190 | SAA7146_HPS_SYNC_PORT_A); |
1191 | 1191 | ||
1192 | saa7113_setinput(budget_av, 0); | 1192 | saa7113_setinput(budget_av, 0); |
1193 | } else { | ||
1194 | ciintf_init(budget_av); | ||
1195 | } | 1193 | } |
1196 | 1194 | ||
1197 | /* fixme: find some sane values here... */ | 1195 | /* fixme: find some sane values here... */ |
@@ -1211,6 +1209,10 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1211 | budget_av->budget.dvb_adapter.priv = budget_av; | 1209 | budget_av->budget.dvb_adapter.priv = budget_av; |
1212 | frontend_init(budget_av); | 1210 | frontend_init(budget_av); |
1213 | 1211 | ||
1212 | if (!budget_av->has_saa7113) { | ||
1213 | ciintf_init(budget_av); | ||
1214 | } | ||
1215 | |||
1214 | return 0; | 1216 | return 0; |
1215 | } | 1217 | } |
1216 | 1218 | ||
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 5f91036f5b87..e64a609cf4ff 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -71,6 +71,7 @@ struct budget_ci { | |||
71 | struct tasklet_struct msp430_irq_tasklet; | 71 | struct tasklet_struct msp430_irq_tasklet; |
72 | struct tasklet_struct ciintf_irq_tasklet; | 72 | struct tasklet_struct ciintf_irq_tasklet; |
73 | int slot_status; | 73 | int slot_status; |
74 | int ci_irq; | ||
74 | struct dvb_ca_en50221 ca; | 75 | struct dvb_ca_en50221 ca; |
75 | char ir_dev_name[50]; | 76 | char ir_dev_name[50]; |
76 | u8 tuner_pll_address; /* used for philips_tdm1316l configs */ | 77 | u8 tuner_pll_address; /* used for philips_tdm1316l configs */ |
@@ -276,8 +277,10 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) | |||
276 | if (slot != 0) | 277 | if (slot != 0) |
277 | return -EINVAL; | 278 | return -EINVAL; |
278 | 279 | ||
279 | // trigger on RISING edge during reset so we know when READY is re-asserted | 280 | if (budget_ci->ci_irq) { |
280 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); | 281 | // trigger on RISING edge during reset so we know when READY is re-asserted |
282 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); | ||
283 | } | ||
281 | budget_ci->slot_status = SLOTSTATUS_RESET; | 284 | budget_ci->slot_status = SLOTSTATUS_RESET; |
282 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); | 285 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); |
283 | msleep(1); | 286 | msleep(1); |
@@ -370,11 +373,50 @@ static void ciintf_interrupt(unsigned long data) | |||
370 | } | 373 | } |
371 | } | 374 | } |
372 | 375 | ||
376 | static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) | ||
377 | { | ||
378 | struct budget_ci *budget_ci = (struct budget_ci *) ca->data; | ||
379 | unsigned int flags; | ||
380 | |||
381 | // ensure we don't get spurious IRQs during initialisation | ||
382 | if (!budget_ci->budget.ci_present) | ||
383 | return -EINVAL; | ||
384 | |||
385 | // read the CAM status | ||
386 | flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); | ||
387 | if (flags & CICONTROL_CAMDETECT) { | ||
388 | // mark it as present if it wasn't before | ||
389 | if (budget_ci->slot_status & SLOTSTATUS_NONE) { | ||
390 | budget_ci->slot_status = SLOTSTATUS_PRESENT; | ||
391 | } | ||
392 | |||
393 | // during a RESET, we check if we can read from IO memory to see when CAM is ready | ||
394 | if (budget_ci->slot_status & SLOTSTATUS_RESET) { | ||
395 | if (ciintf_read_attribute_mem(ca, slot, 0) == 0x1d) { | ||
396 | budget_ci->slot_status = SLOTSTATUS_READY; | ||
397 | } | ||
398 | } | ||
399 | } else { | ||
400 | budget_ci->slot_status = SLOTSTATUS_NONE; | ||
401 | } | ||
402 | |||
403 | if (budget_ci->slot_status != SLOTSTATUS_NONE) { | ||
404 | if (budget_ci->slot_status & SLOTSTATUS_READY) { | ||
405 | return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; | ||
406 | } | ||
407 | return DVB_CA_EN50221_POLL_CAM_PRESENT; | ||
408 | } | ||
409 | |||
410 | return 0; | ||
411 | } | ||
412 | |||
373 | static int ciintf_init(struct budget_ci *budget_ci) | 413 | static int ciintf_init(struct budget_ci *budget_ci) |
374 | { | 414 | { |
375 | struct saa7146_dev *saa = budget_ci->budget.dev; | 415 | struct saa7146_dev *saa = budget_ci->budget.dev; |
376 | int flags; | 416 | int flags; |
377 | int result; | 417 | int result; |
418 | int ci_version; | ||
419 | int ca_flags; | ||
378 | 420 | ||
379 | memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221)); | 421 | memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221)); |
380 | 422 | ||
@@ -382,16 +424,29 @@ static int ciintf_init(struct budget_ci *budget_ci) | |||
382 | saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800); | 424 | saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800); |
383 | 425 | ||
384 | // test if it is there | 426 | // test if it is there |
385 | if ((ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0) & 0xa0) != 0xa0) { | 427 | ci_version = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0); |
428 | if ((ci_version & 0xa0) != 0xa0) { | ||
386 | result = -ENODEV; | 429 | result = -ENODEV; |
387 | goto error; | 430 | goto error; |
388 | } | 431 | } |
432 | |||
389 | // determine whether a CAM is present or not | 433 | // determine whether a CAM is present or not |
390 | flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); | 434 | flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0); |
391 | budget_ci->slot_status = SLOTSTATUS_NONE; | 435 | budget_ci->slot_status = SLOTSTATUS_NONE; |
392 | if (flags & CICONTROL_CAMDETECT) | 436 | if (flags & CICONTROL_CAMDETECT) |
393 | budget_ci->slot_status = SLOTSTATUS_PRESENT; | 437 | budget_ci->slot_status = SLOTSTATUS_PRESENT; |
394 | 438 | ||
439 | // version 0xa2 of the CI firmware doesn't generate interrupts | ||
440 | if (ci_version == 0xa2) { | ||
441 | ca_flags = 0; | ||
442 | budget_ci->ci_irq = 0; | ||
443 | } else { | ||
444 | ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | | ||
445 | DVB_CA_EN50221_FLAG_IRQ_FR | | ||
446 | DVB_CA_EN50221_FLAG_IRQ_DA; | ||
447 | budget_ci->ci_irq = 1; | ||
448 | } | ||
449 | |||
395 | // register CI interface | 450 | // register CI interface |
396 | budget_ci->ca.owner = THIS_MODULE; | 451 | budget_ci->ca.owner = THIS_MODULE; |
397 | budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem; | 452 | budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem; |
@@ -401,23 +456,27 @@ static int ciintf_init(struct budget_ci *budget_ci) | |||
401 | budget_ci->ca.slot_reset = ciintf_slot_reset; | 456 | budget_ci->ca.slot_reset = ciintf_slot_reset; |
402 | budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; | 457 | budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; |
403 | budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; | 458 | budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; |
459 | budget_ci->ca.poll_slot_status = ciintf_poll_slot_status; | ||
404 | budget_ci->ca.data = budget_ci; | 460 | budget_ci->ca.data = budget_ci; |
405 | if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter, | 461 | if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter, |
406 | &budget_ci->ca, | 462 | &budget_ci->ca, |
407 | DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | | 463 | ca_flags, 1)) != 0) { |
408 | DVB_CA_EN50221_FLAG_IRQ_FR | | ||
409 | DVB_CA_EN50221_FLAG_IRQ_DA, 1)) != 0) { | ||
410 | printk("budget_ci: CI interface detected, but initialisation failed.\n"); | 464 | printk("budget_ci: CI interface detected, but initialisation failed.\n"); |
411 | goto error; | 465 | goto error; |
412 | } | 466 | } |
467 | |||
413 | // Setup CI slot IRQ | 468 | // Setup CI slot IRQ |
414 | tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci); | 469 | if (budget_ci->ci_irq) { |
415 | if (budget_ci->slot_status != SLOTSTATUS_NONE) { | 470 | tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci); |
416 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); | 471 | if (budget_ci->slot_status != SLOTSTATUS_NONE) { |
417 | } else { | 472 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); |
418 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); | 473 | } else { |
474 | saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI); | ||
475 | } | ||
476 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03); | ||
419 | } | 477 | } |
420 | saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03); | 478 | |
479 | // enable interface | ||
421 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, | 480 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, |
422 | CICONTROL_RESET, 1, 0); | 481 | CICONTROL_RESET, 1, 0); |
423 | 482 | ||
@@ -426,10 +485,12 @@ static int ciintf_init(struct budget_ci *budget_ci) | |||
426 | budget_ci->budget.ci_present = 1; | 485 | budget_ci->budget.ci_present = 1; |
427 | 486 | ||
428 | // forge a fake CI IRQ so the CAM state is setup correctly | 487 | // forge a fake CI IRQ so the CAM state is setup correctly |
429 | flags = DVB_CA_EN50221_CAMCHANGE_REMOVED; | 488 | if (budget_ci->ci_irq) { |
430 | if (budget_ci->slot_status != SLOTSTATUS_NONE) | 489 | flags = DVB_CA_EN50221_CAMCHANGE_REMOVED; |
431 | flags = DVB_CA_EN50221_CAMCHANGE_INSERTED; | 490 | if (budget_ci->slot_status != SLOTSTATUS_NONE) |
432 | dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags); | 491 | flags = DVB_CA_EN50221_CAMCHANGE_INSERTED; |
492 | dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags); | ||
493 | } | ||
433 | 494 | ||
434 | return 0; | 495 | return 0; |
435 | 496 | ||
@@ -443,9 +504,13 @@ static void ciintf_deinit(struct budget_ci *budget_ci) | |||
443 | struct saa7146_dev *saa = budget_ci->budget.dev; | 504 | struct saa7146_dev *saa = budget_ci->budget.dev; |
444 | 505 | ||
445 | // disable CI interrupts | 506 | // disable CI interrupts |
446 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03); | 507 | if (budget_ci->ci_irq) { |
447 | saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT); | 508 | saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03); |
448 | tasklet_kill(&budget_ci->ciintf_irq_tasklet); | 509 | saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT); |
510 | tasklet_kill(&budget_ci->ciintf_irq_tasklet); | ||
511 | } | ||
512 | |||
513 | // reset interface | ||
449 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); | 514 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0); |
450 | msleep(1); | 515 | msleep(1); |
451 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, | 516 | ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, |
@@ -473,7 +538,7 @@ static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr) | |||
473 | if (*isr & MASK_10) | 538 | if (*isr & MASK_10) |
474 | ttpci_budget_irq10_handler(dev, isr); | 539 | ttpci_budget_irq10_handler(dev, isr); |
475 | 540 | ||
476 | if ((*isr & MASK_03) && (budget_ci->budget.ci_present)) | 541 | if ((*isr & MASK_03) && (budget_ci->budget.ci_present) && (budget_ci->ci_irq)) |
477 | tasklet_schedule(&budget_ci->ciintf_irq_tasklet); | 542 | tasklet_schedule(&budget_ci->ciintf_irq_tasklet); |
478 | } | 543 | } |
479 | 544 | ||
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 248fdc7accfb..6ceae38125c7 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | |||
@@ -1507,7 +1507,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1507 | 1507 | ||
1508 | mutex_unlock(&ttusb->semi2c); | 1508 | mutex_unlock(&ttusb->semi2c); |
1509 | 1509 | ||
1510 | dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); | 1510 | if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE)) < 0) { |
1511 | ttusb_free_iso_urbs(ttusb); | ||
1512 | kfree(ttusb); | ||
1513 | return result; | ||
1514 | } | ||
1511 | ttusb->adapter.priv = ttusb; | 1515 | ttusb->adapter.priv = ttusb; |
1512 | 1516 | ||
1513 | /* i2c */ | 1517 | /* i2c */ |