aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/budget-av.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci/budget-av.c')
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c283
1 files changed, 185 insertions, 98 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 8a7cd7d505cf..6163cb03b8f4 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -50,6 +50,12 @@
50 50
51#define DEBICICAM 0x02420000 51#define DEBICICAM 0x02420000
52 52
53#define SLOTSTATUS_NONE 1
54#define SLOTSTATUS_PRESENT 2
55#define SLOTSTATUS_RESET 4
56#define SLOTSTATUS_READY 8
57#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
58
53struct budget_av { 59struct budget_av {
54 struct budget budget; 60 struct budget budget;
55 struct video_device *vd; 61 struct video_device *vd;
@@ -58,8 +64,15 @@ struct budget_av {
58 struct tasklet_struct ciintf_irq_tasklet; 64 struct tasklet_struct ciintf_irq_tasklet;
59 int slot_status; 65 int slot_status;
60 struct dvb_ca_en50221 ca; 66 struct dvb_ca_en50221 ca;
67 u8 reinitialise_demod:1;
68 u8 tda10021_poclkp:1;
69 u8 tda10021_ts_enabled;
70 int (*tda10021_set_frontend)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
61}; 71};
62 72
73static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
74
75
63/* GPIO Connections: 76/* GPIO Connections:
64 * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*! 77 * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
65 * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory 78 * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
@@ -129,9 +142,10 @@ static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int ad
129 udelay(1); 142 udelay(1);
130 143
131 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1); 144 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
132 145 if (result == -ETIMEDOUT) {
133 if (result == -ETIMEDOUT) 146 ciintf_slot_shutdown(ca, slot);
134 budget_av->slot_status = 0; 147 printk(KERN_INFO "budget-av: cam ejected 1\n");
148 }
135 return result; 149 return result;
136} 150}
137 151
@@ -147,9 +161,10 @@ static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int a
147 udelay(1); 161 udelay(1);
148 162
149 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1); 163 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
150 164 if (result == -ETIMEDOUT) {
151 if (result == -ETIMEDOUT) 165 ciintf_slot_shutdown(ca, slot);
152 budget_av->slot_status = 0; 166 printk(KERN_INFO "budget-av: cam ejected 2\n");
167 }
153 return result; 168 return result;
154} 169}
155 170
@@ -165,9 +180,11 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre
165 udelay(1); 180 udelay(1);
166 181
167 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0); 182 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
168 183 if ((result == -ETIMEDOUT) || ((result == 0xff) && ((address & 3) < 2))) {
169 if (result == -ETIMEDOUT) 184 ciintf_slot_shutdown(ca, slot);
170 budget_av->slot_status = 0; 185 printk(KERN_INFO "budget-av: cam ejected 3\n");
186 return -ETIMEDOUT;
187 }
171 return result; 188 return result;
172} 189}
173 190
@@ -183,9 +200,10 @@ static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addr
183 udelay(1); 200 udelay(1);
184 201
185 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0); 202 result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
186 203 if (result == -ETIMEDOUT) {
187 if (result == -ETIMEDOUT) 204 ciintf_slot_shutdown(ca, slot);
188 budget_av->slot_status = 0; 205 printk(KERN_INFO "budget-av: cam ejected 5\n");
206 }
189 return result; 207 return result;
190} 208}
191 209
@@ -193,12 +211,12 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
193{ 211{
194 struct budget_av *budget_av = (struct budget_av *) ca->data; 212 struct budget_av *budget_av = (struct budget_av *) ca->data;
195 struct saa7146_dev *saa = budget_av->budget.dev; 213 struct saa7146_dev *saa = budget_av->budget.dev;
196 int timeout = 50; // 5 seconds (4.4.6 Ready)
197 214
198 if (slot != 0) 215 if (slot != 0)
199 return -EINVAL; 216 return -EINVAL;
200 217
201 dprintk(1, "ciintf_slot_reset\n"); 218 dprintk(1, "ciintf_slot_reset\n");
219 budget_av->slot_status = SLOTSTATUS_RESET;
202 220
203 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ 221 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
204 222
@@ -208,20 +226,17 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
208 msleep(20); /* 20 ms Vcc settling time */ 226 msleep(20); /* 20 ms Vcc settling time */
209 227
210 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */ 228 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
229 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
230 msleep(20);
211 231
212 /* This should have been based on pin 16 READY of the pcmcia port, 232 /* reinitialise the frontend if necessary */
213 * but AFAICS it is not routed to the saa7146 */ 233 if (budget_av->reinitialise_demod)
214 while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) 234 dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
215 msleep(100);
216
217 /* reinitialise the frontend */
218 dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
219 235
220 if (timeout <= 0) 236 /* set tda10021 back to original clock configuration on reset */
221 { 237 if (budget_av->tda10021_poclkp) {
222 printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); 238 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
223 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ 239 budget_av->tda10021_ts_enabled = 0;
224 return -ETIMEDOUT;
225 } 240 }
226 241
227 return 0; 242 return 0;
@@ -238,7 +253,13 @@ static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
238 dprintk(1, "ciintf_slot_shutdown\n"); 253 dprintk(1, "ciintf_slot_shutdown\n");
239 254
240 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB); 255 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
241 budget_av->slot_status = 0; 256 budget_av->slot_status = SLOTSTATUS_NONE;
257
258 /* set tda10021 back to original clock configuration when cam removed */
259 if (budget_av->tda10021_poclkp) {
260 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
261 budget_av->tda10021_ts_enabled = 0;
262 }
242 return 0; 263 return 0;
243} 264}
244 265
@@ -253,6 +274,13 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
253 dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status); 274 dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
254 275
255 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA); 276 ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
277
278 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */
279 if (budget_av->tda10021_poclkp) {
280 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1);
281 budget_av->tda10021_ts_enabled = 1;
282 }
283
256 return 0; 284 return 0;
257} 285}
258 286
@@ -260,50 +288,61 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
260{ 288{
261 struct budget_av *budget_av = (struct budget_av *) ca->data; 289 struct budget_av *budget_av = (struct budget_av *) ca->data;
262 struct saa7146_dev *saa = budget_av->budget.dev; 290 struct saa7146_dev *saa = budget_av->budget.dev;
263 int cam_present = 0; 291 int result;
264 292
265 if (slot != 0) 293 if (slot != 0)
266 return -EINVAL; 294 return -EINVAL;
267 295
268 if (!budget_av->slot_status) 296 /* test the card detect line - needs to be done carefully
269 { 297 * since it never goes high for some CAMs on this interface (e.g. topuptv) */
270 // first of all test the card detect line 298 if (budget_av->slot_status == SLOTSTATUS_NONE) {
271 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 299 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
272 udelay(1); 300 udelay(1);
273 if (saa7146_read(saa, PSR) & MASK_06) 301 if (saa7146_read(saa, PSR) & MASK_06) {
274 { 302 if (budget_av->slot_status == SLOTSTATUS_NONE) {
275 cam_present = 1; 303 budget_av->slot_status = SLOTSTATUS_PRESENT;
304 printk(KERN_INFO "budget-av: cam inserted A\n");
305 }
276 } 306 }
277 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); 307 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
308 }
278 309
279 // that is unreliable however, so try and read from IO memory 310 /* We also try and read from IO memory to work round the above detection bug. If
280 if (!cam_present) 311 * there is no CAM, we will get a timeout. Only done if there is no cam
281 { 312 * present, since this test actually breaks some cams :(
282 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO); 313 *
283 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) != -ETIMEDOUT) 314 * if the CI interface is not open, we also do the above test since we
284 { 315 * don't care if the cam has problems - we'll be resetting it on open() anyway */
285 cam_present = 1; 316 if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
317 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
318 result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
319 if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
320 budget_av->slot_status = SLOTSTATUS_PRESENT;
321 printk(KERN_INFO "budget-av: cam inserted B\n");
322 } else if (result < 0) {
323 if (budget_av->slot_status != SLOTSTATUS_NONE) {
324 ciintf_slot_shutdown(ca, slot);
325 printk(KERN_INFO "budget-av: cam ejected 5\n");
326 return 0;
286 } 327 }
287 } 328 }
329 }
288 330
289 // did we find something? 331 /* read from attribute memory in reset/ready state to know when the CAM is ready */
290 if (cam_present) { 332 if (budget_av->slot_status == SLOTSTATUS_RESET) {
291 printk(KERN_INFO "budget-av: cam inserted\n"); 333 result = ciintf_read_attribute_mem(ca, slot, 0);
292 budget_av->slot_status = 1; 334 if (result == 0x1d) {
293 } 335 budget_av->slot_status = SLOTSTATUS_READY;
294 } else if (!open) {
295 saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
296 if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT)
297 {
298 printk(KERN_INFO "budget-av: cam ejected\n");
299 saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
300 budget_av->slot_status = 0;
301 } 336 }
302 } 337 }
303 338
304 if (budget_av->slot_status == 1) 339 /* work out correct return code */
305 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; 340 if (budget_av->slot_status != SLOTSTATUS_NONE) {
306 341 if (budget_av->slot_status & SLOTSTATUS_READY) {
342 return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
343 }
344 return DVB_CA_EN50221_POLL_CAM_PRESENT;
345 }
307 return 0; 346 return 0;
308} 347}
309 348
@@ -333,6 +372,8 @@ static int ciintf_init(struct budget_av *budget_av)
333 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable; 372 budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
334 budget_av->ca.poll_slot_status = ciintf_poll_slot_status; 373 budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
335 budget_av->ca.data = budget_av; 374 budget_av->ca.data = budget_av;
375 budget_av->budget.ci_present = 1;
376 budget_av->slot_status = SLOTSTATUS_NONE;
336 377
337 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter, 378 if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
338 &budget_av->ca, 0, 1)) != 0) { 379 &budget_av->ca, 0, 1)) != 0) {
@@ -341,7 +382,6 @@ static int ciintf_init(struct budget_av *budget_av)
341 } 382 }
342 383
343 printk(KERN_INFO "budget-av: ci interface initialised.\n"); 384 printk(KERN_INFO "budget-av: ci interface initialised.\n");
344 budget_av->budget.ci_present = 1;
345 return 0; 385 return 0;
346 386
347error: 387error:
@@ -472,12 +512,12 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra
472 return 0; 512 return 0;
473} 513}
474 514
475static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, 515static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
476 struct i2c_adapter *i2c, 516 struct dvb_frontend_parameters *params)
477 struct dvb_frontend_parameters *params)
478{ 517{
479 u32 div; 518 u32 div;
480 u8 buf[4]; 519 u8 buf[4];
520 struct budget *budget = (struct budget *) fe->dvb->priv;
481 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 521 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
482 522
483 if ((params->frequency < 950000) || (params->frequency > 2150000)) 523 if ((params->frequency < 950000) || (params->frequency > 2150000))
@@ -501,7 +541,9 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
501 else if (params->frequency < 2150000) 541 else if (params->frequency < 2150000)
502 buf[3] |= 0xC0; 542 buf[3] |= 0xC0;
503 543
504 if (i2c_transfer(i2c, &msg, 1) != 1) 544 if (fe->ops.i2c_gate_ctrl)
545 fe->ops.i2c_gate_ctrl(fe, 1);
546 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
505 return -EIO; 547 return -EIO;
506 return 0; 548 return 0;
507} 549}
@@ -509,9 +551,8 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe,
509#define MIN2(a,b) ((a) < (b) ? (a) : (b)) 551#define MIN2(a,b) ((a) < (b) ? (a) : (b))
510#define MIN3(a,b,c) MIN2(MIN2(a,b),c) 552#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
511 553
512static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe, 554static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe,
513 struct i2c_adapter *i2c, 555 struct dvb_frontend_parameters *params)
514 struct dvb_frontend_parameters *params)
515{ 556{
516 u8 reg0 [2] = { 0x00, 0x00 }; 557 u8 reg0 [2] = { 0x00, 0x00 };
517 u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 }; 558 u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
@@ -521,6 +562,7 @@ static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe,
521 int R, A, N, P, M; 562 int R, A, N, P, M;
522 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 }; 563 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
523 int freq = params->frequency; 564 int freq = params->frequency;
565 struct budget *budget = (struct budget *) fe->dvb->priv;
524 566
525 first_ZF = (freq) / 1000; 567 first_ZF = (freq) / 1000;
526 568
@@ -620,21 +662,25 @@ static int philips_su1278sh2_tua6100_pll_set(struct dvb_frontend *fe,
620 reg0[1] |= 0x03; 662 reg0[1] |= 0x03;
621 663
622 /* already enabled - do not reenable i2c repeater or TX fails */ 664 /* already enabled - do not reenable i2c repeater or TX fails */
665 if (fe->ops.i2c_gate_ctrl)
666 fe->ops.i2c_gate_ctrl(fe, 1);
623 msg.buf = reg0; 667 msg.buf = reg0;
624 msg.len = sizeof(reg0); 668 msg.len = sizeof(reg0);
625 if (i2c_transfer(i2c, &msg, 1) != 1) 669 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
626 return -EIO; 670 return -EIO;
627 671
628 stv0299_enable_plli2c(fe); 672 if (fe->ops.i2c_gate_ctrl)
673 fe->ops.i2c_gate_ctrl(fe, 1);
629 msg.buf = reg1; 674 msg.buf = reg1;
630 msg.len = sizeof(reg1); 675 msg.len = sizeof(reg1);
631 if (i2c_transfer(i2c, &msg, 1) != 1) 676 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
632 return -EIO; 677 return -EIO;
633 678
634 stv0299_enable_plli2c(fe); 679 if (fe->ops.i2c_gate_ctrl)
680 fe->ops.i2c_gate_ctrl(fe, 1);
635 msg.buf = reg2; 681 msg.buf = reg2;
636 msg.len = sizeof(reg2); 682 msg.len = sizeof(reg2);
637 if (i2c_transfer(i2c, &msg, 1) != 1) 683 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
638 return -EIO; 684 return -EIO;
639 685
640 return 0; 686 return 0;
@@ -692,7 +738,6 @@ static struct stv0299_config typhoon_config = {
692 .volt13_op0_op1 = STV0299_VOLT13_OP0, 738 .volt13_op0_op1 = STV0299_VOLT13_OP0,
693 .min_delay_ms = 100, 739 .min_delay_ms = 100,
694 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, 740 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
695 .pll_set = philips_su1278_ty_ci_pll_set,
696}; 741};
697 742
698 743
@@ -706,7 +751,6 @@ static struct stv0299_config cinergy_1200s_config = {
706 .volt13_op0_op1 = STV0299_VOLT13_OP0, 751 .volt13_op0_op1 = STV0299_VOLT13_OP0,
707 .min_delay_ms = 100, 752 .min_delay_ms = 100,
708 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, 753 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
709 .pll_set = philips_su1278_ty_ci_pll_set,
710}; 754};
711 755
712static struct stv0299_config cinergy_1200s_1894_0010_config = { 756static struct stv0299_config cinergy_1200s_1894_0010_config = {
@@ -719,10 +763,9 @@ static struct stv0299_config cinergy_1200s_1894_0010_config = {
719 .volt13_op0_op1 = STV0299_VOLT13_OP0, 763 .volt13_op0_op1 = STV0299_VOLT13_OP0,
720 .min_delay_ms = 100, 764 .min_delay_ms = 100,
721 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, 765 .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
722 .pll_set = philips_su1278sh2_tua6100_pll_set,
723}; 766};
724 767
725static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 768static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
726{ 769{
727 struct budget *budget = (struct budget *) fe->dvb->priv; 770 struct budget *budget = (struct budget *) fe->dvb->priv;
728 u8 buf[4]; 771 u8 buf[4];
@@ -738,6 +781,8 @@ static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p
738 buf[3] = (params->frequency < 150000000 ? 0x01 : 781 buf[3] = (params->frequency < 150000000 ? 0x01 :
739 params->frequency < 445000000 ? 0x02 : 0x04); 782 params->frequency < 445000000 ? 0x02 : 0x04);
740 783
784 if (fe->ops.i2c_gate_ctrl)
785 fe->ops.i2c_gate_ctrl(fe, 1);
741 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1) 786 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
742 return -EIO; 787 return -EIO;
743 return 0; 788 return 0;
@@ -745,19 +790,20 @@ static int philips_cu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p
745 790
746static struct tda10021_config philips_cu1216_config = { 791static struct tda10021_config philips_cu1216_config = {
747 .demod_address = 0x0c, 792 .demod_address = 0x0c,
748 .pll_set = philips_cu1216_pll_set,
749}; 793};
750 794
751 795
752 796
753 797
754static int philips_tu1216_pll_init(struct dvb_frontend *fe) 798static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
755{ 799{
756 struct budget *budget = (struct budget *) fe->dvb->priv; 800 struct budget *budget = (struct budget *) fe->dvb->priv;
757 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; 801 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
758 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; 802 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
759 803
760 // setup PLL configuration 804 // setup PLL configuration
805 if (fe->ops.i2c_gate_ctrl)
806 fe->ops.i2c_gate_ctrl(fe, 1);
761 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) 807 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
762 return -EIO; 808 return -EIO;
763 msleep(1); 809 msleep(1);
@@ -765,7 +811,7 @@ static int philips_tu1216_pll_init(struct dvb_frontend *fe)
765 return 0; 811 return 0;
766} 812}
767 813
768static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 814static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
769{ 815{
770 struct budget *budget = (struct budget *) fe->dvb->priv; 816 struct budget *budget = (struct budget *) fe->dvb->priv;
771 u8 tuner_buf[4]; 817 u8 tuner_buf[4];
@@ -839,6 +885,8 @@ static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_p
839 tuner_buf[2] = 0xca; 885 tuner_buf[2] = 0xca;
840 tuner_buf[3] = (cp << 5) | (filter << 3) | band; 886 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
841 887
888 if (fe->ops.i2c_gate_ctrl)
889 fe->ops.i2c_gate_ctrl(fe, 1);
842 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1) 890 if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
843 return -EIO; 891 return -EIO;
844 892
@@ -862,9 +910,6 @@ static struct tda1004x_config philips_tu1216_config = {
862 .xtal_freq = TDA10046_XTAL_4M, 910 .xtal_freq = TDA10046_XTAL_4M,
863 .agc_config = TDA10046_AGC_DEFAULT, 911 .agc_config = TDA10046_AGC_DEFAULT,
864 .if_freq = TDA10046_FREQ_3617, 912 .if_freq = TDA10046_FREQ_3617,
865 .pll_init = philips_tu1216_pll_init,
866 .pll_set = philips_tu1216_pll_set,
867 .pll_sleep = NULL,
868 .request_firmware = philips_tu1216_request_firmware, 913 .request_firmware = philips_tu1216_request_firmware,
869}; 914};
870 915
@@ -911,13 +956,13 @@ static u8 philips_sd1878_inittab[] = {
911 0xff, 0xff 956 0xff, 0xff
912}; 957};
913 958
914static int philips_sd1878_tda8261_pll_set(struct dvb_frontend *fe, 959static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe,
915 struct i2c_adapter *i2c, 960 struct dvb_frontend_parameters *params)
916 struct dvb_frontend_parameters *params)
917{ 961{
918 u8 buf[4]; 962 u8 buf[4];
919 int rc; 963 int rc;
920 struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)}; 964 struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)};
965 struct budget *budget = (struct budget *) fe->dvb->priv;
921 966
922 if((params->frequency < 950000) || (params->frequency > 2150000)) 967 if((params->frequency < 950000) || (params->frequency > 2150000))
923 return -EINVAL; 968 return -EINVAL;
@@ -926,7 +971,9 @@ static int philips_sd1878_tda8261_pll_set(struct dvb_frontend *fe,
926 params->frequency, 0); 971 params->frequency, 0);
927 if(rc < 0) return rc; 972 if(rc < 0) return rc;
928 973
929 if(i2c_transfer(i2c, &tuner_msg, 1) != 1) 974 if (fe->ops.i2c_gate_ctrl)
975 fe->ops.i2c_gate_ctrl(fe, 1);
976 if(i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
930 return -EIO; 977 return -EIO;
931 978
932 return 0; 979 return 0;
@@ -969,7 +1016,7 @@ static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
969 1016
970static struct stv0299_config philips_sd1878_config = { 1017static struct stv0299_config philips_sd1878_config = {
971 .demod_address = 0x68, 1018 .demod_address = 0x68,
972 .inittab = philips_sd1878_inittab, 1019 .inittab = philips_sd1878_inittab,
973 .mclk = 88000000UL, 1020 .mclk = 88000000UL,
974 .invert = 0, 1021 .invert = 0,
975 .skip_reinit = 0, 1022 .skip_reinit = 0,
@@ -977,7 +1024,6 @@ static struct stv0299_config philips_sd1878_config = {
977 .volt13_op0_op1 = STV0299_VOLT13_OP0, 1024 .volt13_op0_op1 = STV0299_VOLT13_OP0,
978 .min_delay_ms = 100, 1025 .min_delay_ms = 100,
979 .set_symbol_rate = philips_sd1878_ci_set_symbol_rate, 1026 .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
980 .pll_set = philips_sd1878_tda8261_pll_set,
981}; 1027};
982 1028
983static u8 read_pwm(struct budget_av *budget_av) 1029static u8 read_pwm(struct budget_av *budget_av)
@@ -1003,6 +1049,7 @@ static u8 read_pwm(struct budget_av *budget_av)
1003 1049
1004#define SUBID_DVBS_TV_STAR 0x0014 1050#define SUBID_DVBS_TV_STAR 0x0014
1005#define SUBID_DVBS_TV_STAR_CI 0x0016 1051#define SUBID_DVBS_TV_STAR_CI 0x0016
1052#define SUBID_DVBS_EASYWATCH_1 0x001a
1006#define SUBID_DVBS_EASYWATCH 0x001e 1053#define SUBID_DVBS_EASYWATCH 0x001e
1007#define SUBID_DVBC_KNC1 0x0020 1054#define SUBID_DVBC_KNC1 0x0020
1008#define SUBID_DVBC_KNC1_PLUS 0x0021 1055#define SUBID_DVBC_KNC1_PLUS 0x0021
@@ -1012,17 +1059,36 @@ static u8 read_pwm(struct budget_av *budget_av)
1012#define SUBID_DVBT_KNC1 0x0030 1059#define SUBID_DVBT_KNC1 0x0030
1013#define SUBID_DVBT_CINERGY1200 0x1157 1060#define SUBID_DVBT_CINERGY1200 0x1157
1014 1061
1062
1063static int tda10021_set_frontend(struct dvb_frontend *fe,
1064 struct dvb_frontend_parameters *p)
1065{
1066 struct budget_av* budget_av = fe->dvb->priv;
1067 int result;
1068
1069 result = budget_av->tda10021_set_frontend(fe, p);
1070 if (budget_av->tda10021_ts_enabled) {
1071 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1);
1072 } else {
1073 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
1074 }
1075
1076 return result;
1077}
1078
1015static void frontend_init(struct budget_av *budget_av) 1079static void frontend_init(struct budget_av *budget_av)
1016{ 1080{
1017 struct saa7146_dev * saa = budget_av->budget.dev; 1081 struct saa7146_dev * saa = budget_av->budget.dev;
1018 struct dvb_frontend * fe = NULL; 1082 struct dvb_frontend * fe = NULL;
1019 1083
1084 /* Enable / PowerON Frontend */
1085 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
1086
1087 /* additional setup necessary for the PLUS cards */
1020 switch (saa->pci->subsystem_device) { 1088 switch (saa->pci->subsystem_device) {
1021 case SUBID_DVBS_KNC1_PLUS: 1089 case SUBID_DVBS_KNC1_PLUS:
1022 case SUBID_DVBC_KNC1_PLUS: 1090 case SUBID_DVBC_KNC1_PLUS:
1023 case SUBID_DVBT_KNC1_PLUS: 1091 case SUBID_DVBT_KNC1_PLUS:
1024 // Enable / PowerON Frontend
1025 saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
1026 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); 1092 saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
1027 break; 1093 break;
1028 } 1094 }
@@ -1030,12 +1096,19 @@ static void frontend_init(struct budget_av *budget_av)
1030 switch (saa->pci->subsystem_device) { 1096 switch (saa->pci->subsystem_device) {
1031 1097
1032 case SUBID_DVBS_KNC1: 1098 case SUBID_DVBS_KNC1:
1099 case SUBID_DVBS_EASYWATCH_1:
1033 if (saa->pci->subsystem_vendor == 0x1894) { 1100 if (saa->pci->subsystem_vendor == 0x1894) {
1034 fe = stv0299_attach(&cinergy_1200s_1894_0010_config, 1101 fe = stv0299_attach(&cinergy_1200s_1894_0010_config,
1035 &budget_av->budget.i2c_adap); 1102 &budget_av->budget.i2c_adap);
1103 if (fe) {
1104 fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params;
1105 }
1036 } else { 1106 } else {
1037 fe = stv0299_attach(&typhoon_config, 1107 fe = stv0299_attach(&typhoon_config,
1038 &budget_av->budget.i2c_adap); 1108 &budget_av->budget.i2c_adap);
1109 if (fe) {
1110 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
1111 }
1039 } 1112 }
1040 break; 1113 break;
1041 1114
@@ -1045,41 +1118,53 @@ static void frontend_init(struct budget_av *budget_av)
1045 case SUBID_DVBS_EASYWATCH: 1118 case SUBID_DVBS_EASYWATCH:
1046 fe = stv0299_attach(&philips_sd1878_config, 1119 fe = stv0299_attach(&philips_sd1878_config,
1047 &budget_av->budget.i2c_adap); 1120 &budget_av->budget.i2c_adap);
1121 if (fe) {
1122 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params;
1123 }
1048 break; 1124 break;
1049 1125
1050 case SUBID_DVBS_KNC1_PLUS: 1126 case SUBID_DVBS_KNC1_PLUS:
1051 case SUBID_DVBS_TYPHOON: 1127 case SUBID_DVBS_TYPHOON:
1052 fe = stv0299_attach(&typhoon_config, 1128 fe = stv0299_attach(&typhoon_config,
1053 &budget_av->budget.i2c_adap); 1129 &budget_av->budget.i2c_adap);
1130 if (fe) {
1131 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
1132 }
1054 break; 1133 break;
1055 1134
1056 case SUBID_DVBS_CINERGY1200: 1135 case SUBID_DVBS_CINERGY1200:
1057 fe = stv0299_attach(&cinergy_1200s_config, 1136 fe = stv0299_attach(&cinergy_1200s_config,
1058 &budget_av->budget.i2c_adap); 1137 &budget_av->budget.i2c_adap);
1138 if (fe) {
1139 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
1140 }
1059 break; 1141 break;
1060 1142
1061 case SUBID_DVBC_KNC1: 1143 case SUBID_DVBC_KNC1:
1062 case SUBID_DVBC_KNC1_PLUS: 1144 case SUBID_DVBC_KNC1_PLUS:
1145 case SUBID_DVBC_CINERGY1200:
1146 budget_av->reinitialise_demod = 1;
1063 fe = tda10021_attach(&philips_cu1216_config, 1147 fe = tda10021_attach(&philips_cu1216_config,
1064 &budget_av->budget.i2c_adap, 1148 &budget_av->budget.i2c_adap,
1065 read_pwm(budget_av)); 1149 read_pwm(budget_av));
1150 if (fe) {
1151 budget_av->tda10021_poclkp = 1;
1152 budget_av->tda10021_set_frontend = fe->ops.set_frontend;
1153 fe->ops.set_frontend = tda10021_set_frontend;
1154 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1155 }
1066 break; 1156 break;
1067 1157
1068 case SUBID_DVBT_KNC1: 1158 case SUBID_DVBT_KNC1:
1069 case SUBID_DVBT_KNC1_PLUS: 1159 case SUBID_DVBT_KNC1_PLUS:
1070 fe = tda10046_attach(&philips_tu1216_config,
1071 &budget_av->budget.i2c_adap);
1072 break;
1073
1074 case SUBID_DVBC_CINERGY1200:
1075 fe = tda10021_attach(&philips_cu1216_config,
1076 &budget_av->budget.i2c_adap,
1077 read_pwm(budget_av));
1078 break;
1079
1080 case SUBID_DVBT_CINERGY1200: 1160 case SUBID_DVBT_CINERGY1200:
1161 budget_av->reinitialise_demod = 1;
1081 fe = tda10046_attach(&philips_tu1216_config, 1162 fe = tda10046_attach(&philips_tu1216_config,
1082 &budget_av->budget.i2c_adap); 1163 &budget_av->budget.i2c_adap);
1164 if (fe) {
1165 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
1166 fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
1167 }
1083 break; 1168 break;
1084 } 1169 }
1085 1170
@@ -1098,8 +1183,8 @@ static void frontend_init(struct budget_av *budget_av)
1098 if (dvb_register_frontend(&budget_av->budget.dvb_adapter, 1183 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1099 budget_av->budget.dvb_frontend)) { 1184 budget_av->budget.dvb_frontend)) {
1100 printk(KERN_ERR "budget-av: Frontend registration failed!\n"); 1185 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
1101 if (budget_av->budget.dvb_frontend->ops->release) 1186 if (budget_av->budget.dvb_frontend->ops.release)
1102 budget_av->budget.dvb_frontend->ops->release(budget_av->budget.dvb_frontend); 1187 budget_av->budget.dvb_frontend->ops.release(budget_av->budget.dvb_frontend);
1103 budget_av->budget.dvb_frontend = NULL; 1188 budget_av->budget.dvb_frontend = NULL;
1104 } 1189 }
1105} 1190}
@@ -1293,6 +1378,7 @@ MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
1293MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T); 1378MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
1294MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR); 1379MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
1295MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR); 1380MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
1381MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S);
1296MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP); 1382MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
1297MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP); 1383MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
1298MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP); 1384MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
@@ -1309,6 +1395,7 @@ static struct pci_device_id pci_tbl[] = {
1309 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014), 1395 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
1310 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016), 1396 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
1311 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e), 1397 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
1398 MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
1312 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020), 1399 MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
1313 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021), 1400 MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
1314 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030), 1401 MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),