aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci')
-rw-r--r--drivers/media/dvb/ttpci/av7110.c144
-rw-r--r--drivers/media/dvb/ttpci/av7110.h3
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c12
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c4
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c20
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h5
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c16
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c226
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c6
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c12
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c4
-rw-r--r--drivers/media/dvb/ttpci/budget.c4
-rw-r--r--drivers/media/dvb/ttpci/budget.h5
14 files changed, 306 insertions, 157 deletions
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 922c205a2652..8e33a850e13e 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -130,7 +130,7 @@ static void init_av7110_av(struct av7110 *av7110)
130 av7110->current_input = 0; 130 av7110->current_input = 0;
131 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) { 131 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
132 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n", 132 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
133 av7110->dvb_adapter->num); 133 av7110->dvb_adapter.num);
134 av7110->adac_type = DVB_ADAC_CRYSTAL; 134 av7110->adac_type = DVB_ADAC_CRYSTAL;
135 i2c_writereg(av7110, 0x20, 0x01, 0xd2); 135 i2c_writereg(av7110, 0x20, 0x01, 0xd2);
136 i2c_writereg(av7110, 0x20, 0x02, 0x49); 136 i2c_writereg(av7110, 0x20, 0x02, 0x49);
@@ -145,13 +145,13 @@ static void init_av7110_av(struct av7110 *av7110)
145 } 145 }
146 else if (dev->pci->subsystem_vendor == 0x110a) { 146 else if (dev->pci->subsystem_vendor == 0x110a) {
147 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n", 147 printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
148 av7110->dvb_adapter->num); 148 av7110->dvb_adapter.num);
149 av7110->adac_type = DVB_ADAC_NONE; 149 av7110->adac_type = DVB_ADAC_NONE;
150 } 150 }
151 else { 151 else {
152 av7110->adac_type = adac; 152 av7110->adac_type = adac;
153 printk("dvb-ttpci: adac type set to %d @ card %d\n", 153 printk("dvb-ttpci: adac type set to %d @ card %d\n",
154 av7110->dvb_adapter->num, av7110->adac_type); 154 av7110->dvb_adapter.num, av7110->adac_type);
155 } 155 }
156 156
157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
@@ -231,7 +231,7 @@ static int arm_thread(void *data)
231 231
232 if (newloops == av7110->arm_loops) { 232 if (newloops == av7110->arm_loops) {
233 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 233 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
234 av7110->dvb_adapter->num); 234 av7110->dvb_adapter.num);
235 235
236 arm_error(av7110); 236 arm_error(av7110);
237 av7710_set_video_mode(av7110, vidmode); 237 av7710_set_video_mode(av7110, vidmode);
@@ -1282,7 +1282,7 @@ static int av7110_register(struct av7110 *av7110)
1282 av7110->dmxdev.demux = &dvbdemux->dmx; 1282 av7110->dmxdev.demux = &dvbdemux->dmx;
1283 av7110->dmxdev.capabilities = 0; 1283 av7110->dmxdev.capabilities = 0;
1284 1284
1285 dvb_dmxdev_init(&av7110->dmxdev, av7110->dvb_adapter); 1285 dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
1286 1286
1287 av7110->hw_frontend.source = DMX_FRONTEND_0; 1287 av7110->hw_frontend.source = DMX_FRONTEND_0;
1288 1288
@@ -1307,11 +1307,11 @@ static int av7110_register(struct av7110 *av7110)
1307 av7110_ca_register(av7110); 1307 av7110_ca_register(av7110);
1308 1308
1309#ifdef CONFIG_DVB_AV7110_OSD 1309#ifdef CONFIG_DVB_AV7110_OSD
1310 dvb_register_device(av7110->dvb_adapter, &av7110->osd_dev, 1310 dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
1311 &dvbdev_osd, av7110, DVB_DEVICE_OSD); 1311 &dvbdev_osd, av7110, DVB_DEVICE_OSD);
1312#endif 1312#endif
1313 1313
1314 dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx); 1314 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
1315 1315
1316 if (budgetpatch) { 1316 if (budgetpatch) {
1317 /* initialize software demux1 without its own frontend 1317 /* initialize software demux1 without its own frontend
@@ -1334,9 +1334,9 @@ static int av7110_register(struct av7110 *av7110)
1334 av7110->dmxdev1.demux = &dvbdemux1->dmx; 1334 av7110->dmxdev1.demux = &dvbdemux1->dmx;
1335 av7110->dmxdev1.capabilities = 0; 1335 av7110->dmxdev1.capabilities = 0;
1336 1336
1337 dvb_dmxdev_init(&av7110->dmxdev1, av7110->dvb_adapter); 1337 dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
1338 1338
1339 dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx); 1339 dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
1340 printk("dvb-ttpci: additional demux1 for budget-patch registered\n"); 1340 printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
1341 } 1341 }
1342 return 0; 1342 return 0;
@@ -1673,6 +1673,106 @@ static struct stv0299_config alps_bsru6_config = {
1673}; 1673};
1674 1674
1675 1675
1676static u8 alps_bsbe1_inittab[] = {
1677 0x01, 0x15,
1678 0x02, 0x30,
1679 0x03, 0x00,
1680 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1681 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1682 0x06, 0x40, /* DAC not used, set to high impendance mode */
1683 0x07, 0x00, /* DAC LSB */
1684 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1685 0x09, 0x00, /* FIFO */
1686 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1687 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1688 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1689 0x10, 0x3f, // AGC2 0x3d
1690 0x11, 0x84,
1691 0x12, 0xb5, // Lock detect: -64 Carrier freq detect:on
1692 0x15, 0xc9, // lock detector threshold
1693 0x16, 0x00,
1694 0x17, 0x00,
1695 0x18, 0x00,
1696 0x19, 0x00,
1697 0x1a, 0x00,
1698 0x1f, 0x50,
1699 0x20, 0x00,
1700 0x21, 0x00,
1701 0x22, 0x00,
1702 0x23, 0x00,
1703 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1704 0x29, 0x1e, // 1/2 threshold
1705 0x2a, 0x14, // 2/3 threshold
1706 0x2b, 0x0f, // 3/4 threshold
1707 0x2c, 0x09, // 5/6 threshold
1708 0x2d, 0x05, // 7/8 threshold
1709 0x2e, 0x01,
1710 0x31, 0x1f, // test all FECs
1711 0x32, 0x19, // viterbi and synchro search
1712 0x33, 0xfc, // rs control
1713 0x34, 0x93, // error control
1714 0x0f, 0x92,
1715 0xff, 0xff
1716};
1717
1718static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1719{
1720 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1721 int ret;
1722 u8 data[4];
1723 u32 div;
1724 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1725
1726 if ((params->frequency < 950000) || (params->frequency > 2150000))
1727 return -EINVAL;
1728
1729 div = (params->frequency + (125 - 1)) / 125; // round correctly
1730 data[0] = (div >> 8) & 0x7f;
1731 data[1] = div & 0xff;
1732 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1733 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
1734
1735 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1736 return (ret != 1) ? -EIO : 0;
1737}
1738
1739static struct stv0299_config alps_bsbe1_config = {
1740 .demod_address = 0x68,
1741 .inittab = alps_bsbe1_inittab,
1742 .mclk = 88000000UL,
1743 .invert = 1,
1744 .enhanced_tuning = 0,
1745 .skip_reinit = 0,
1746 .min_delay_ms = 100,
1747 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1748 .pll_set = alps_bsbe1_pll_set,
1749};
1750
1751static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
1752{
1753 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1754 int ret;
1755 u8 data[1];
1756 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
1757
1758 switch(voltage) {
1759 case SEC_VOLTAGE_OFF:
1760 data[0] = 0x00;
1761 break;
1762 case SEC_VOLTAGE_13:
1763 data[0] = 0x44;
1764 break;
1765 case SEC_VOLTAGE_18:
1766 data[0] = 0x4c;
1767 break;
1768 default:
1769 return -EINVAL;
1770 };
1771
1772 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1773 return (ret != 1) ? -EIO : 0;
1774}
1775
1676 1776
1677static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1777static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1678{ 1778{
@@ -2116,6 +2216,14 @@ static int frontend_init(struct av7110 *av7110)
2116 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240; 2216 av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
2117 break; 2217 break;
2118 } 2218 }
2219 break;
2220
2221 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2222 /* ALPS BSBE1 */
2223 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
2224 if (av7110->fe)
2225 av7110->fe->ops->set_voltage = lnbp21_set_voltage;
2226 break;
2119 } 2227 }
2120 } 2228 }
2121 2229
@@ -2138,7 +2246,7 @@ static int frontend_init(struct av7110 *av7110)
2138 FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command); 2246 FE_FUNC_OVERRIDE(av7110->fe->ops->dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
2139 FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend); 2247 FE_FUNC_OVERRIDE(av7110->fe->ops->set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
2140 2248
2141 ret = dvb_register_frontend(av7110->dvb_adapter, av7110->fe); 2249 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2142 if (ret < 0) { 2250 if (ret < 0) {
2143 printk("av7110: Frontend registration failed!\n"); 2251 printk("av7110: Frontend registration failed!\n");
2144 if (av7110->fe->ops->release) 2252 if (av7110->fe->ops->release)
@@ -2352,7 +2460,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2352 goto err_dvb_unregister_adapter_2; 2460 goto err_dvb_unregister_adapter_2;
2353 2461
2354 ttpci_eeprom_parse_mac(&av7110->i2c_adap, 2462 ttpci_eeprom_parse_mac(&av7110->i2c_adap,
2355 av7110->dvb_adapter->proposed_mac); 2463 av7110->dvb_adapter.proposed_mac);
2356 ret = -ENOMEM; 2464 ret = -ENOMEM;
2357 2465
2358 if (budgetpatch) { 2466 if (budgetpatch) {
@@ -2523,7 +2631,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2523 if (ret < 0) 2631 if (ret < 0)
2524 goto err_av7110_unregister_11; 2632 goto err_av7110_unregister_11;
2525 2633
2526 av7110->dvb_adapter->priv = av7110; 2634 av7110->dvb_adapter.priv = av7110;
2527 ret = frontend_init(av7110); 2635 ret = frontend_init(av7110);
2528 if (ret < 0) 2636 if (ret < 0)
2529 goto err_av7110_exit_v4l_12; 2637 goto err_av7110_exit_v4l_12;
@@ -2558,7 +2666,7 @@ err_saa71466_vfree_4:
2558err_i2c_del_3: 2666err_i2c_del_3:
2559 i2c_del_adapter(&av7110->i2c_adap); 2667 i2c_del_adapter(&av7110->i2c_adap);
2560err_dvb_unregister_adapter_2: 2668err_dvb_unregister_adapter_2:
2561 dvb_unregister_adapter(av7110->dvb_adapter); 2669 dvb_unregister_adapter(&av7110->dvb_adapter);
2562err_put_firmware_1: 2670err_put_firmware_1:
2563 put_firmware(av7110); 2671 put_firmware(av7110);
2564err_kfree_0: 2672err_kfree_0:
@@ -2604,7 +2712,7 @@ static int av7110_detach(struct saa7146_dev* saa)
2604 2712
2605 i2c_del_adapter(&av7110->i2c_adap); 2713 i2c_del_adapter(&av7110->i2c_adap);
2606 2714
2607 dvb_unregister_adapter (av7110->dvb_adapter); 2715 dvb_unregister_adapter (&av7110->dvb_adapter);
2608 2716
2609 av7110_num--; 2717 av7110_num--;
2610 2718
@@ -2672,21 +2780,23 @@ MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
2672MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); 2780MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
2673MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); 2781MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
2674MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X"); 2782MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
2783MAKE_AV7110_INFO(tts_2_3, "Technotrend/Hauppauge WinTV Nexus-S rev2.3");
2675MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE"); 2784MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
2676MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T"); 2785MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
2677MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); 2786MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2678MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); 2787MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2679 2788
2680static struct pci_device_id pci_tbl[] = { 2789static struct pci_device_id pci_tbl[] = {
2790 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2681 MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), 2791 MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000),
2682 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), 2792 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2683 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), 2793 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2684 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), 2794 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2685 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2686 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2687 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2688 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), 2795 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2689 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), 2796 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2797 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2798 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2799 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2690 2800
2691/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte 2801/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
2692/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 2802/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 5070e0523da7..4f69b4d01479 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -220,7 +220,7 @@ struct av7110 {
220 220
221 struct audio_mixer mixer; 221 struct audio_mixer mixer;
222 222
223 struct dvb_adapter *dvb_adapter; 223 struct dvb_adapter dvb_adapter;
224 struct dvb_device *video_dev; 224 struct dvb_device *video_dev;
225 struct dvb_device *audio_dev; 225 struct dvb_device *audio_dev;
226 struct dvb_device *ca_dev; 226 struct dvb_device *ca_dev;
@@ -274,7 +274,6 @@ extern void av7110_ir_exit (void);
274extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val); 274extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
275extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg); 275extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
276extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val); 276extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
277extern int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val);
278 277
279 278
280extern int av7110_init_analog_module(struct av7110 *av7110); 279extern int av7110_init_analog_module(struct av7110 *av7110);
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index d77e8a00688f..ccf946125d02 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1075,7 +1075,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1075 } 1075 }
1076 if (ret < 0) 1076 if (ret < 0)
1077 break; 1077 break;
1078 av7110->videostate.video_format = format; 1078 av7110->videostate.display_format = format;
1079 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType, 1079 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
1080 1, (u16) val); 1080 1, (u16) val);
1081 break; 1081 break;
@@ -1230,14 +1230,20 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1230 switch(av7110->audiostate.channel_select) { 1230 switch(av7110->audiostate.channel_select) {
1231 case AUDIO_STEREO: 1231 case AUDIO_STEREO:
1232 audcom(av7110, AUDIO_CMD_STEREO); 1232 audcom(av7110, AUDIO_CMD_STEREO);
1233 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1234 i2c_writereg(av7110, 0x20, 0x02, 0x49);
1233 break; 1235 break;
1234 1236
1235 case AUDIO_MONO_LEFT: 1237 case AUDIO_MONO_LEFT:
1236 audcom(av7110, AUDIO_CMD_MONO_L); 1238 audcom(av7110, AUDIO_CMD_MONO_L);
1239 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1240 i2c_writereg(av7110, 0x20, 0x02, 0x4a);
1237 break; 1241 break;
1238 1242
1239 case AUDIO_MONO_RIGHT: 1243 case AUDIO_MONO_RIGHT:
1240 audcom(av7110, AUDIO_CMD_MONO_R); 1244 audcom(av7110, AUDIO_CMD_MONO_R);
1245 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1246 i2c_writereg(av7110, 0x20, 0x02, 0x45);
1241 break; 1247 break;
1242 1248
1243 default: 1249 default:
@@ -1409,10 +1415,10 @@ int av7110_av_register(struct av7110 *av7110)
1409 av7110->video_events.overflow = 0; 1415 av7110->video_events.overflow = 0;
1410 memset(&av7110->video_size, 0, sizeof (video_size_t)); 1416 memset(&av7110->video_size, 0, sizeof (video_size_t));
1411 1417
1412 dvb_register_device(av7110->dvb_adapter, &av7110->video_dev, 1418 dvb_register_device(&av7110->dvb_adapter, &av7110->video_dev,
1413 &dvbdev_video, av7110, DVB_DEVICE_VIDEO); 1419 &dvbdev_video, av7110, DVB_DEVICE_VIDEO);
1414 1420
1415 dvb_register_device(av7110->dvb_adapter, &av7110->audio_dev, 1421 dvb_register_device(&av7110->dvb_adapter, &av7110->audio_dev,
1416 &dvbdev_audio, av7110, DVB_DEVICE_AUDIO); 1422 &dvbdev_audio, av7110, DVB_DEVICE_AUDIO);
1417 1423
1418 return 0; 1424 return 0;
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 21f7aacf7726..c3801e328fe9 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -123,7 +123,7 @@ static void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *
123} 123}
124 124
125static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file, 125static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
126 int slots, ca_slot_info_t *slot) 126 int slots, ca_slot_info_t *slot)
127{ 127{
128 int i; 128 int i;
129 int len = 0; 129 int len = 0;
@@ -370,7 +370,7 @@ static struct dvb_device dvbdev_ca = {
370 370
371int av7110_ca_register(struct av7110 *av7110) 371int av7110_ca_register(struct av7110 *av7110)
372{ 372{
373 return dvb_register_device(av7110->dvb_adapter, &av7110->ca_dev, 373 return dvb_register_device(&av7110->dvb_adapter, &av7110->ca_dev,
374 &dvbdev_ca, av7110, DVB_DEVICE_CA); 374 &dvbdev_ca, av7110, DVB_DEVICE_CA);
375} 375}
376 376
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index bd6e5ea4aefe..7fa4a0ebe133 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -104,7 +104,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count)
104 104
105 105
106/* av7110 ARM core boot stuff */ 106/* av7110 ARM core boot stuff */
107 107#if 0
108void av7110_reset_arm(struct av7110 *av7110) 108void av7110_reset_arm(struct av7110 *av7110)
109{ 109{
110 saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO); 110 saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO);
@@ -124,7 +124,7 @@ void av7110_reset_arm(struct av7110 *av7110)
124 av7110->arm_ready = 1; 124 av7110->arm_ready = 1;
125 dprintk(1, "reset ARM\n"); 125 dprintk(1, "reset ARM\n");
126} 126}
127 127#endif /* 0 */
128 128
129static int waitdebi(struct av7110 *av7110, int adr, int state) 129static int waitdebi(struct av7110 *av7110, int adr, int state)
130{ 130{
@@ -335,7 +335,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
335 return 0; 335 return 0;
336} 336}
337 337
338int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) 338static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
339{ 339{
340 int i; 340 int i;
341 unsigned long start; 341 unsigned long start;
@@ -455,7 +455,7 @@ int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
455 return 0; 455 return 0;
456} 456}
457 457
458int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) 458static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
459{ 459{
460 int ret; 460 int ret;
461 461
@@ -500,6 +500,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
500 return ret; 500 return ret;
501} 501}
502 502
503#if 0
503int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len) 504int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
504{ 505{
505 int i, ret; 506 int i, ret;
@@ -521,6 +522,7 @@ int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
521 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret); 522 printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret);
522 return ret; 523 return ret;
523} 524}
525#endif /* 0 */
524 526
525int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, 527int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
526 int request_buf_len, u16 *reply_buf, int reply_buf_len) 528 int request_buf_len, u16 *reply_buf, int reply_buf_len)
@@ -593,7 +595,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
593 return 0; 595 return 0;
594} 596}
595 597
596int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length) 598static int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length)
597{ 599{
598 int ret; 600 int ret;
599 ret = av7110_fw_request(av7110, &tag, 0, buf, length); 601 ret = av7110_fw_request(av7110, &tag, 0, buf, length);
@@ -617,7 +619,7 @@ int av7110_firmversion(struct av7110 *av7110)
617 619
618 if (av7110_fw_query(av7110, tag, buf, 16)) { 620 if (av7110_fw_query(av7110, tag, buf, 16)) {
619 printk("dvb-ttpci: failed to boot firmware @ card %d\n", 621 printk("dvb-ttpci: failed to boot firmware @ card %d\n",
620 av7110->dvb_adapter->num); 622 av7110->dvb_adapter.num);
621 return -EIO; 623 return -EIO;
622 } 624 }
623 625
@@ -628,16 +630,16 @@ int av7110_firmversion(struct av7110 *av7110)
628 av7110->avtype = (buf[8] << 16) + buf[9]; 630 av7110->avtype = (buf[8] << 16) + buf[9];
629 631
630 printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n", 632 printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n",
631 av7110->dvb_adapter->num, av7110->arm_fw, 633 av7110->dvb_adapter.num, av7110->arm_fw,
632 av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app); 634 av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app);
633 635
634 /* print firmware capabilities */ 636 /* print firmware capabilities */
635 if (FW_CI_LL_SUPPORT(av7110->arm_app)) 637 if (FW_CI_LL_SUPPORT(av7110->arm_app))
636 printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n", 638 printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n",
637 av7110->dvb_adapter->num); 639 av7110->dvb_adapter.num);
638 else 640 else
639 printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n", 641 printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n",
640 av7110->dvb_adapter->num); 642 av7110->dvb_adapter.num);
641 643
642 return 0; 644 return 0;
643} 645}
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
index bf901c624682..52061e17c6dd 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ b/drivers/media/dvb/ttpci/av7110_hw.h
@@ -364,7 +364,6 @@ enum av7110_command_type {
364 364
365 365
366 366
367extern void av7110_reset_arm(struct av7110 *av7110);
368extern int av7110_bootarm(struct av7110 *av7110); 367extern int av7110_bootarm(struct av7110 *av7110);
369extern int av7110_firmversion(struct av7110 *av7110); 368extern int av7110_firmversion(struct av7110 *av7110);
370#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000) 369#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000)
@@ -373,12 +372,8 @@ extern int av7110_firmversion(struct av7110 *av7110);
373 372
374extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags); 373extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags);
375extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...); 374extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...);
376extern int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
377extern int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length);
378extern int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len);
379extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, 375extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
380 int request_buf_len, u16 *reply_buf, int reply_buf_len); 376 int request_buf_len, u16 *reply_buf, int reply_buf_len);
381extern int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* Buff, s16 length);
382 377
383 378
384/* DEBI (saa7146 data extension bus interface) access */ 379/* DEBI (saa7146 data extension bus interface) access */
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 6d2256f1e354..665cdb8a3f71 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -10,7 +10,7 @@
10 10
11#define UP_TIMEOUT (HZ/4) 11#define UP_TIMEOUT (HZ/4)
12 12
13/* enable ir debugging by or'ing av7110_debug with 16 */ 13/* enable ir debugging by or'ing debug with 16 */
14 14
15static int ir_initialized; 15static int ir_initialized;
16static struct input_dev input_dev; 16static struct input_dev input_dev;
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index eb84fb08d95c..e65fc36e2ce8 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -46,13 +46,13 @@ int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val)
46 46
47 if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) { 47 if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) {
48 dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n", 48 dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n",
49 av7110->dvb_adapter->num, reg, val); 49 av7110->dvb_adapter.num, reg, val);
50 return -EIO; 50 return -EIO;
51 } 51 }
52 return 0; 52 return 0;
53} 53}
54 54
55int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) 55static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
56{ 56{
57 u8 msg1[3] = { dev, reg >> 8, reg & 0xff }; 57 u8 msg1[3] = { dev, reg >> 8, reg & 0xff };
58 u8 msg2[2]; 58 u8 msg2[2];
@@ -63,7 +63,7 @@ int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
63 63
64 if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) { 64 if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) {
65 dprintk(1, "dvb-ttpci: failed @ card %d, %u\n", 65 dprintk(1, "dvb-ttpci: failed @ card %d, %u\n",
66 av7110->dvb_adapter->num, reg); 66 av7110->dvb_adapter.num, reg);
67 return -EIO; 67 return -EIO;
68 } 68 }
69 *val = (msg2[0] << 8) | msg2[1]; 69 *val = (msg2[0] << 8) | msg2[1];
@@ -552,13 +552,13 @@ int av7110_init_analog_module(struct av7110 *av7110)
552 return -ENODEV; 552 return -ENODEV;
553 553
554 printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n", 554 printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n",
555 av7110->dvb_adapter->num); 555 av7110->dvb_adapter.num);
556 av7110->adac_type = DVB_ADAC_MSP; 556 av7110->adac_type = DVB_ADAC_MSP;
557 msleep(100); // the probing above resets the msp... 557 msleep(100); // the probing above resets the msp...
558 msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1); 558 msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1);
559 msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2); 559 msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2);
560 dprintk(1, "dvb-ttpci: @ card %d MSP3400 version 0x%04x 0x%04x\n", 560 dprintk(1, "dvb-ttpci: @ card %d MSP3400 version 0x%04x 0x%04x\n",
561 av7110->dvb_adapter->num, version1, version2); 561 av7110->dvb_adapter.num, version1, version2);
562 msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00); 562 msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00);
563 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone 563 msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
564 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source 564 msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
@@ -596,7 +596,7 @@ int av7110_init_analog_module(struct av7110 *av7110)
596 /* init the saa7113 */ 596 /* init the saa7113 */
597 while (*i != 0xff) { 597 while (*i != 0xff) {
598 if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) { 598 if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) {
599 dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter->num); 599 dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter.num);
600 break; 600 break;
601 } 601 }
602 i += 2; 602 i += 2;
@@ -726,11 +726,11 @@ static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std)
726{ 726{
727 struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 727 struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
728 728
729 if (std->id == V4L2_STD_PAL) { 729 if (std->id & V4L2_STD_PAL) {
730 av7110->vidmode = VIDEO_MODE_PAL; 730 av7110->vidmode = VIDEO_MODE_PAL;
731 av7110_set_vidmode(av7110, av7110->vidmode); 731 av7110_set_vidmode(av7110, av7110->vidmode);
732 } 732 }
733 else if (std->id == V4L2_STD_NTSC) { 733 else if (std->id & V4L2_STD_NTSC) {
734 av7110->vidmode = VIDEO_MODE_NTSC; 734 av7110->vidmode = VIDEO_MODE_NTSC;
735 av7110_set_vidmode(av7110, av7110->vidmode); 735 av7110_set_vidmode(av7110, av7110->vidmode);
736 } 736 }
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 14e963206b89..6e0f5d307c52 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -59,8 +59,12 @@ struct budget_av {
59 struct dvb_ca_en50221 ca; 59 struct dvb_ca_en50221 ca;
60}; 60};
61 61
62static int enable_ci = 0; 62/* GPIO CI Connections:
63 63 * 0 - Vcc/Reset (Reset is controlled by capacitor)
64 * 1 - Attribute Memory
65 * 2 - Card Enable (Active Low)
66 * 3 - Card Detect
67 */
64 68
65/**************************************************************************** 69/****************************************************************************
66 * INITIALIZATION 70 * INITIALIZATION
@@ -188,22 +192,35 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
188{ 192{
189 struct budget_av *budget_av = (struct budget_av *) ca->data; 193 struct budget_av *budget_av = (struct budget_av *) ca->data;
190 struct saa7146_dev *saa = budget_av->budget.dev; 194 struct saa7146_dev *saa = budget_av->budget.dev;
191 int max = 20; 195 int timeout = 50; // 5 seconds (4.4.6 Ready)
192 196
193 if (slot != 0) 197 if (slot != 0)
194 return -EINVAL; 198 return -EINVAL;
195 199
196 dprintk(1, "ciintf_slot_reset\n"); 200 dprintk(1, "ciintf_slot_reset\n");
197 201
198 /* reset the card */ 202 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
199 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
200 msleep(100);
201 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
202 203
203 while (--max > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) 204 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
205 msleep(2);
206 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
207 msleep(20); /* 20 ms Vcc settling time */
208
209 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
210
211 /* This should have been based on pin 16 READY of the pcmcia port,
212 * but AFAICS it is not routed to the saa7146 */
213 while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d)
204 msleep(100); 214 msleep(100);
205 215
206 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB); 216 if (timeout <= 0)
217 {
218 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n");
219 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
220 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
221 return -ETIMEDOUT;
222 }
223
207 return 0; 224 return 0;
208} 225}
209 226
@@ -240,7 +257,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
240{ 257{
241 struct budget_av *budget_av = (struct budget_av *) ca->data; 258 struct budget_av *budget_av = (struct budget_av *) ca->data;
242 struct saa7146_dev *saa = budget_av->budget.dev; 259 struct saa7146_dev *saa = budget_av->budget.dev;
243 int cam = 0;
244 260
245 if (slot != 0) 261 if (slot != 0)
246 return -EINVAL; 262 return -EINVAL;
@@ -248,15 +264,21 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
248 if (!budget_av->slot_status) { 264 if (!budget_av->slot_status) {
249 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 265 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
250 udelay(1); 266 udelay(1);
251 cam = saa7146_read(saa, PSR) & MASK_06; 267 if (saa7146_read(saa, PSR) & MASK_06)
252 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 268 {
253 269 printk(KERN_INFO "budget-av: cam inserted\n");
254 if (cam)
255 budget_av->slot_status = 1; 270 budget_av->slot_status = 1;
271 }
272 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
256 } else if (!open) { 273 } else if (!open) {
257 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); 274 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
258 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT) 275 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT)
276 {
277 printk(KERN_INFO "budget-av: cam ejected\n");
278 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
279 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
259 budget_av->slot_status = 0; 280 budget_av->slot_status = 0;
281 }
260 } 282 }
261 283
262 if (budget_av->slot_status == 1) 284 if (budget_av->slot_status == 1)
@@ -272,17 +294,11 @@ static int ciintf_init(struct budget_av *budget_av)
272 294
273 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221)); 295 memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
274 296
275 /* setup GPIOs */ 297 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
276 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI); 298 saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
277 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); 299 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
278 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 300 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
279 301
280 /* Reset the card */
281 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
282 msleep(50);
283 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
284 msleep(100);
285
286 /* Enable DEBI pins */ 302 /* Enable DEBI pins */
287 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800); 303 saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
288 304
@@ -297,13 +313,14 @@ static int ciintf_init(struct budget_av *budget_av)
297 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable; 313 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
298 budget_av->ca.poll_slot_status = ciintf_poll_slot_status; 314 budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
299 budget_av->ca.data = budget_av; 315 budget_av->ca.data = budget_av;
300 if ((result = dvb_ca_en50221_init(budget_av->budget.dvb_adapter, 316
317 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
301 &budget_av->ca, 0, 1)) != 0) { 318 &budget_av->ca, 0, 1)) != 0) {
302 printk("budget_av: CI interface detected, but initialisation failed.\n"); 319 printk(KERN_ERR "budget-av: ci initialisation failed.\n");
303 goto error; 320 goto error;
304 } 321 }
305 // success! 322
306 printk("ciintf_init: CI interface initialised\n"); 323 printk(KERN_INFO "budget-av: ci interface initialised.\n");
307 budget_av->budget.ci_present = 1; 324 budget_av->budget.ci_present = 1;
308 return 0; 325 return 0;
309 326
@@ -361,8 +378,12 @@ static const u8 saa7113_tab[] = {
361static int saa7113_init(struct budget_av *budget_av) 378static int saa7113_init(struct budget_av *budget_av)
362{ 379{
363 struct budget *budget = &budget_av->budget; 380 struct budget *budget = &budget_av->budget;
381 struct saa7146_dev *saa = budget->dev;
364 const u8 *data = saa7113_tab; 382 const u8 *data = saa7113_tab;
365 383
384 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
385 msleep(200);
386
366 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) { 387 if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
367 dprintk(1, "saa7113 not found on KNC card\n"); 388 dprintk(1, "saa7113 not found on KNC card\n");
368 return -ENODEV; 389 return -ENODEV;
@@ -697,75 +718,90 @@ static u8 read_pwm(struct budget_av *budget_av)
697 return pwm; 718 return pwm;
698} 719}
699 720
721#define SUBID_DVBS_KNC1 0x0010
722#define SUBID_DVBS_KNC1_PLUS 0x0011
723#define SUBID_DVBS_TYPHOON 0x4f56
724#define SUBID_DVBS_CINERGY1200 0x1154
725
726#define SUBID_DVBC_KNC1 0x0020
727#define SUBID_DVBC_KNC1_PLUS 0x0021
728#define SUBID_DVBC_CINERGY1200 0x1156
729
730#define SUBID_DVBT_KNC1_PLUS 0x0031
731#define SUBID_DVBT_KNC1 0x0030
732#define SUBID_DVBT_CINERGY1200 0x1157
700 733
701static void frontend_init(struct budget_av *budget_av) 734static void frontend_init(struct budget_av *budget_av)
702{ 735{
703 switch (budget_av->budget.dev->pci->subsystem_device) { 736 struct saa7146_dev * saa = budget_av->budget.dev;
704 case 0x4f56: // Typhoon/KNC1 DVB-S budget (stv0299/Philips SU1278(tsa5059)) 737 struct dvb_frontend * fe = NULL;
705 budget_av->budget.dvb_frontend = 738
706 stv0299_attach(&typhoon_config, &budget_av->budget.i2c_adap); 739 switch (saa->pci->subsystem_device) {
707 if (budget_av->budget.dvb_frontend != NULL) { 740 case SUBID_DVBS_KNC1_PLUS:
741 case SUBID_DVBC_KNC1_PLUS:
742 case SUBID_DVBT_KNC1_PLUS:
743 // Enable / PowerON Frontend
744 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
708 break; 745 break;
709 } 746 }
747
748 switch (saa->pci->subsystem_device) {
749
750 case SUBID_DVBS_KNC1:
751 case SUBID_DVBS_KNC1_PLUS:
752 case SUBID_DVBS_TYPHOON:
753 fe = stv0299_attach(&typhoon_config,
754 &budget_av->budget.i2c_adap);
710 break; 755 break;
711 756
712 case 0x0020: // KNC1 DVB-C budget (tda10021/Philips CU1216(tua6034)) 757 case SUBID_DVBS_CINERGY1200:
713 budget_av->budget.dvb_frontend = 758 fe = stv0299_attach(&cinergy_1200s_config,
714 tda10021_attach(&philips_cu1216_config, 759 &budget_av->budget.i2c_adap);
715 &budget_av->budget.i2c_adap, read_pwm(budget_av));
716 if (budget_av->budget.dvb_frontend != NULL) {
717 break;
718 }
719 break; 760 break;
720 761
721 case 0x0030: // KNC1 DVB-T budget (tda10046/Philips TU1216(tda6651tt)) 762 case SUBID_DVBC_KNC1:
722 budget_av->budget.dvb_frontend = 763 case SUBID_DVBC_KNC1_PLUS:
723 tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap); 764 fe = tda10021_attach(&philips_cu1216_config,
724 if (budget_av->budget.dvb_frontend != NULL) { 765 &budget_av->budget.i2c_adap,
725 break; 766 read_pwm(budget_av));
726 }
727 break; 767 break;
728 768
729 case 0x1154: // TerraTec Cinergy 1200 DVB-S (stv0299/Philips SU1278(tsa5059)) 769 case SUBID_DVBT_KNC1:
730 budget_av->budget.dvb_frontend = 770 case SUBID_DVBT_KNC1_PLUS:
731 stv0299_attach(&cinergy_1200s_config, &budget_av->budget.i2c_adap); 771 fe = tda10046_attach(&philips_tu1216_config,
732 if (budget_av->budget.dvb_frontend != NULL) { 772 &budget_av->budget.i2c_adap);
733 break;
734 }
735 break; 773 break;
736 774
737 case 0x1156: // Terratec Cinergy 1200 DVB-C (tda10021/Philips CU1216(tua6034)) 775 case SUBID_DVBC_CINERGY1200:
738 budget_av->budget.dvb_frontend = 776 fe = tda10021_attach(&philips_cu1216_config,
739 tda10021_attach(&philips_cu1216_config, 777 &budget_av->budget.i2c_adap,
740 &budget_av->budget.i2c_adap, read_pwm(budget_av)); 778 read_pwm(budget_av));
741 if (budget_av->budget.dvb_frontend) {
742 break;
743 }
744 break; 779 break;
745 780
746 case 0x1157: // Terratec Cinergy 1200 DVB-T (tda10046/Philips TU1216(tda6651tt)) 781 case SUBID_DVBT_CINERGY1200:
747 budget_av->budget.dvb_frontend = 782 fe = tda10046_attach(&philips_tu1216_config,
748 tda10046_attach(&philips_tu1216_config, &budget_av->budget.i2c_adap); 783 &budget_av->budget.i2c_adap);
749 if (budget_av->budget.dvb_frontend) {
750 break;
751 }
752 break; 784 break;
753 } 785 }
754 786
755 if (budget_av->budget.dvb_frontend == NULL) { 787 if (fe == NULL) {
756 printk("budget_av: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", 788 printk(KERN_ERR "budget-av: A frontend driver was not found "
757 budget_av->budget.dev->pci->vendor, 789 "for device %04x/%04x subsystem %04x/%04x\n",
758 budget_av->budget.dev->pci->device, 790 saa->pci->vendor,
759 budget_av->budget.dev->pci->subsystem_vendor, 791 saa->pci->device,
760 budget_av->budget.dev->pci->subsystem_device); 792 saa->pci->subsystem_vendor,
761 } else { 793 saa->pci->subsystem_device);
762 if (dvb_register_frontend 794 return;
763 (budget_av->budget.dvb_adapter, budget_av->budget.dvb_frontend)) { 795 }
764 printk("budget-av: Frontend registration failed!\n"); 796
765 if (budget_av->budget.dvb_frontend->ops->release) 797 budget_av->budget.dvb_frontend = fe;
766 budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend); 798
767 budget_av->budget.dvb_frontend = NULL; 799 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
768 } 800 budget_av->budget.dvb_frontend)) {
801 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
802 if (budget_av->budget.dvb_frontend->ops->release)
803 budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend);
804 budget_av->budget.dvb_frontend = NULL;
769 } 805 }
770} 806}
771 807
@@ -822,6 +858,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
822 858
823 memset(budget_av, 0, sizeof(struct budget_av)); 859 memset(budget_av, 0, sizeof(struct budget_av));
824 860
861 budget_av->has_saa7113 = 0;
825 budget_av->budget.ci_present = 0; 862 budget_av->budget.ci_present = 0;
826 863
827 dev->ext_priv = budget_av; 864 dev->ext_priv = budget_av;
@@ -836,10 +873,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
836 saa7146_write(dev, DD1_INIT, 0x07000600); 873 saa7146_write(dev, DD1_INIT, 0x07000600);
837 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26); 874 saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
838 875
839 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI); 876 if (saa7113_init(budget_av) == 0) {
840 msleep(500);
841
842 if (0 == saa7113_init(budget_av)) {
843 budget_av->has_saa7113 = 1; 877 budget_av->has_saa7113 = 1;
844 878
845 if (0 != saa7146_vv_init(dev, &vv_data)) { 879 if (0 != saa7146_vv_init(dev, &vv_data)) {
@@ -860,31 +894,26 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
860 894
861 saa7113_setinput(budget_av, 0); 895 saa7113_setinput(budget_av, 0);
862 } else { 896 } else {
863 budget_av->has_saa7113 = 0; 897 ciintf_init(budget_av);
864
865 saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
866 } 898 }
867 899
868 /* fixme: find some sane values here... */ 900 /* fixme: find some sane values here... */
869 saa7146_write(dev, PCI_BT_V1, 0x1c00101f); 901 saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
870 902
871 mac = budget_av->budget.dvb_adapter->proposed_mac; 903 mac = budget_av->budget.dvb_adapter.proposed_mac;
872 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) { 904 if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
873 printk("KNC1-%d: Could not read MAC from KNC1 card\n", 905 printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
874 budget_av->budget.dvb_adapter->num); 906 budget_av->budget.dvb_adapter.num);
875 memset(mac, 0, 6); 907 memset(mac, 0, 6);
876 } else { 908 } else {
877 printk("KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", 909 printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
878 budget_av->budget.dvb_adapter->num, 910 budget_av->budget.dvb_adapter.num,
879 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 911 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
880 } 912 }
881 913
882 budget_av->budget.dvb_adapter->priv = budget_av; 914 budget_av->budget.dvb_adapter.priv = budget_av;
883 frontend_init(budget_av); 915 frontend_init(budget_av);
884 916
885 if (enable_ci)
886 ciintf_init(budget_av);
887
888 return 0; 917 return 0;
889} 918}
890 919
@@ -963,14 +992,21 @@ static struct saa7146_extension budget_extension;
963MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S); 992MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
964MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C); 993MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
965MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T); 994MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
995MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
996MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
997MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
966MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S); 998MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
967MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C); 999MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
968MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T); 1000MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
969 1001
970static struct pci_device_id pci_tbl[] = { 1002static struct pci_device_id pci_tbl[] = {
971 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56), 1003 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
1004 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1005 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
972 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1006 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
1007 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
973 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030), 1008 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
1009 MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
974 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154), 1010 MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
975 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156), 1011 MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
976 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157), 1012 MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
@@ -1010,5 +1046,3 @@ MODULE_LICENSE("GPL");
1010MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); 1046MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
1011MODULE_DESCRIPTION("driver for the SAA7146 based so-called " 1047MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
1012 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)"); 1048 "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
1013module_param_named(enable_ci, enable_ci, int, 0644);
1014MODULE_PARM_DESC(enable_ci, "Turn on/off CI module (default:off).");
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 521111be3558..dce116111376 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -395,7 +395,7 @@ static int ciintf_init(struct budget_ci *budget_ci)
395 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown; 395 budget_ci->ca.slot_shutdown = ciintf_slot_shutdown;
396 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable; 396 budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable;
397 budget_ci->ca.data = budget_ci; 397 budget_ci->ca.data = budget_ci;
398 if ((result = dvb_ca_en50221_init(budget_ci->budget.dvb_adapter, 398 if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter,
399 &budget_ci->ca, 399 &budget_ci->ca,
400 DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE | 400 DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
401 DVB_CA_EN50221_FLAG_IRQ_FR | 401 DVB_CA_EN50221_FLAG_IRQ_FR |
@@ -881,7 +881,7 @@ static void frontend_init(struct budget_ci *budget_ci)
881 budget_ci->budget.dev->pci->subsystem_device); 881 budget_ci->budget.dev->pci->subsystem_device);
882 } else { 882 } else {
883 if (dvb_register_frontend 883 if (dvb_register_frontend
884 (budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) { 884 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
885 printk("budget-ci: Frontend registration failed!\n"); 885 printk("budget-ci: Frontend registration failed!\n");
886 if (budget_ci->budget.dvb_frontend->ops->release) 886 if (budget_ci->budget.dvb_frontend->ops->release)
887 budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend); 887 budget_ci->budget.dvb_frontend->ops->release(budget_ci->budget.dvb_frontend);
@@ -916,7 +916,7 @@ static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
916 916
917 ciintf_init(budget_ci); 917 ciintf_init(budget_ci);
918 918
919 budget_ci->budget.dvb_adapter->priv = budget_ci; 919 budget_ci->budget.dvb_adapter.priv = budget_ci;
920 frontend_init(budget_ci); 920 frontend_init(budget_ci);
921 921
922 return 0; 922 return 0;
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 93a9b40917e4..0498a055a4cd 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -298,7 +298,7 @@ static int budget_register(struct budget *budget)
298 budget->dmxdev.demux = &dvbdemux->dmx; 298 budget->dmxdev.demux = &dvbdemux->dmx;
299 budget->dmxdev.capabilities = 0; 299 budget->dmxdev.capabilities = 0;
300 300
301 dvb_dmxdev_init(&budget->dmxdev, budget->dvb_adapter); 301 dvb_dmxdev_init(&budget->dmxdev, &budget->dvb_adapter);
302 302
303 budget->hw_frontend.source = DMX_FRONTEND_0; 303 budget->hw_frontend.source = DMX_FRONTEND_0;
304 304
@@ -316,7 +316,7 @@ static int budget_register(struct budget *budget)
316 if (ret < 0) 316 if (ret < 0)
317 return ret; 317 return ret;
318 318
319 dvb_net_init(budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx); 319 dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
320 320
321 return 0; 321 return 0;
322} 322}
@@ -385,11 +385,11 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
385 strcpy(budget->i2c_adap.name, budget->card->name); 385 strcpy(budget->i2c_adap.name, budget->card->name);
386 386
387 if (i2c_add_adapter(&budget->i2c_adap) < 0) { 387 if (i2c_add_adapter(&budget->i2c_adap) < 0) {
388 dvb_unregister_adapter(budget->dvb_adapter); 388 dvb_unregister_adapter(&budget->dvb_adapter);
389 return -ENOMEM; 389 return -ENOMEM;
390 } 390 }
391 391
392 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter->proposed_mac); 392 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
393 393
394 if (NULL == 394 if (NULL ==
395 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) { 395 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, length, &budget->pt))) {
@@ -417,7 +417,7 @@ err:
417 417
418 vfree(budget->grabbing); 418 vfree(budget->grabbing);
419 419
420 dvb_unregister_adapter(budget->dvb_adapter); 420 dvb_unregister_adapter(&budget->dvb_adapter);
421 421
422 return ret; 422 return ret;
423} 423}
@@ -432,7 +432,7 @@ int ttpci_budget_deinit(struct budget *budget)
432 432
433 i2c_del_adapter(&budget->i2c_adap); 433 i2c_del_adapter(&budget->i2c_adap);
434 434
435 dvb_unregister_adapter(budget->dvb_adapter); 435 dvb_unregister_adapter(&budget->dvb_adapter);
436 436
437 tasklet_kill(&budget->vpe_tasklet); 437 tasklet_kill(&budget->vpe_tasklet);
438 438
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 5d524a4f213f..8142e26b47f5 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -453,7 +453,7 @@ static void frontend_init(struct budget_patch* budget)
453 budget->dev->pci->subsystem_vendor, 453 budget->dev->pci->subsystem_vendor,
454 budget->dev->pci->subsystem_device); 454 budget->dev->pci->subsystem_device);
455 } else { 455 } else {
456 if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) { 456 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
457 printk("budget-av: Frontend registration failed!\n"); 457 printk("budget-av: Frontend registration failed!\n");
458 if (budget->dvb_frontend->ops->release) 458 if (budget->dvb_frontend->ops->release)
459 budget->dvb_frontend->ops->release(budget->dvb_frontend); 459 budget->dvb_frontend->ops->release(budget->dvb_frontend);
@@ -702,7 +702,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
702 702
703 dev->ext_priv = budget; 703 dev->ext_priv = budget;
704 704
705 budget->dvb_adapter->priv = budget; 705 budget->dvb_adapter.priv = budget;
706 frontend_init(budget); 706 frontend_init(budget);
707 707
708 return 0; 708 return 0;
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 5e6a10f4ad95..083fd44e5f90 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -468,7 +468,7 @@ static void frontend_init(struct budget *budget)
468 budget->dev->pci->subsystem_vendor, 468 budget->dev->pci->subsystem_vendor,
469 budget->dev->pci->subsystem_device); 469 budget->dev->pci->subsystem_device);
470 } else { 470 } else {
471 if (dvb_register_frontend(budget->dvb_adapter, budget->dvb_frontend)) { 471 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
472 printk("budget: Frontend registration failed!\n"); 472 printk("budget: Frontend registration failed!\n");
473 if (budget->dvb_frontend->ops->release) 473 if (budget->dvb_frontend->ops->release)
474 budget->dvb_frontend->ops->release(budget->dvb_frontend); 474 budget->dvb_frontend->ops->release(budget->dvb_frontend);
@@ -497,7 +497,7 @@ static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
497 return err; 497 return err;
498 } 498 }
499 499
500 budget->dvb_adapter->priv = budget; 500 budget->dvb_adapter.priv = budget;
501 frontend_init(budget); 501 frontend_init(budget);
502 502
503 return 0; 503 return 0;
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index 10bd41f0363b..c6ef496ba70a 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -64,7 +64,7 @@ struct budget {
64 64
65 spinlock_t debilock; 65 spinlock_t debilock;
66 66
67 struct dvb_adapter *dvb_adapter; 67 struct dvb_adapter dvb_adapter;
68 struct dvb_frontend *dvb_frontend; 68 struct dvb_frontend *dvb_frontend;
69 void *priv; 69 void *priv;
70}; 70};
@@ -92,6 +92,9 @@ static struct saa7146_pci_extension_data x_var = { \
92#define BUDGET_KNC1S 8 92#define BUDGET_KNC1S 8
93#define BUDGET_KNC1C 9 93#define BUDGET_KNC1C 9
94#define BUDGET_KNC1T 10 94#define BUDGET_KNC1T 10
95#define BUDGET_KNC1SP 11
96#define BUDGET_KNC1CP 12
97#define BUDGET_KNC1TP 13
95 98
96#define BUDGET_VIDEO_PORTA 0 99#define BUDGET_VIDEO_PORTA 0
97#define BUDGET_VIDEO_PORTB 1 100#define BUDGET_VIDEO_PORTB 1