aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-dvb.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c1027
1 files changed, 379 insertions, 648 deletions
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index e3059fd33951..65aec881bbde 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -41,7 +41,9 @@
41 41
42#include "tda10086.h" 42#include "tda10086.h"
43#include "tda826x.h" 43#include "tda826x.h"
44#include "tda827x.h"
44#include "isl6421.h" 45#include "isl6421.h"
46
45MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 47MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
46MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
47 49
@@ -54,7 +56,21 @@ static int use_frontend = 0;
54module_param(use_frontend, int, 0644); 56module_param(use_frontend, int, 0644);
55MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); 57MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
56 58
57/* ------------------------------------------------------------------ */ 59static int debug = 0;
60module_param(debug, int, 0644);
61MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
62
63#define dprintk(fmt, arg...) do { if (debug) \
64 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
65
66/* Print a warning */
67#define wprintk(fmt, arg...) \
68 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
69
70/* ------------------------------------------------------------------
71 * mt352 based DVB-T cards
72 */
73
58static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) 74static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
59{ 75{
60 u32 ok; 76 u32 ok;
@@ -75,8 +91,7 @@ static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
75 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); 91 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
76 udelay(10); 92 udelay(10);
77 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); 93 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
78 printk("%s: %s %s\n", dev->name, __FUNCTION__, 94 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
79 ok ? "on" : "off");
80 95
81 if (!ok) 96 if (!ok)
82 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); 97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
@@ -96,7 +111,7 @@ static int mt352_pinnacle_init(struct dvb_frontend* fe)
96 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; 111 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
97 struct saa7134_dev *dev= fe->dvb->priv; 112 struct saa7134_dev *dev= fe->dvb->priv;
98 113
99 printk("%s: %s called\n",dev->name,__FUNCTION__); 114 dprintk("%s called\n", __FUNCTION__);
100 115
101 mt352_write(fe, clock_config, sizeof(clock_config)); 116 mt352_write(fe, clock_config, sizeof(clock_config));
102 udelay(200); 117 udelay(200);
@@ -185,10 +200,26 @@ static struct mt352_config avermedia_777 = {
185 .demod_init = mt352_aver777_init, 200 .demod_init = mt352_aver777_init,
186}; 201};
187 202
188/* ------------------------------------------------------------------ */ 203/* ==================================================================
189static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 204 * tda1004x based DVB-T cards, helper functions
205 */
206
207static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
208 const struct firmware **fw, char *name)
209{
210 struct saa7134_dev *dev = fe->dvb->priv;
211 return request_firmware(fw, name, &dev->pci->dev);
212}
213
214/* ------------------------------------------------------------------
215 * these tuners are tu1216, td1316(a)
216 */
217
218static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
190{ 219{
191 struct saa7134_dev *dev = fe->dvb->priv; 220 struct saa7134_dev *dev = fe->dvb->priv;
221 struct tda1004x_state *state = fe->demodulator_priv;
222 u8 addr = state->config->tuner_address;
192 u8 tuner_buf[4]; 223 u8 tuner_buf[4];
193 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len = 224 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
194 sizeof(tuner_buf) }; 225 sizeof(tuner_buf) };
@@ -263,15 +294,20 @@ static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_
263 294
264 if (fe->ops.i2c_gate_ctrl) 295 if (fe->ops.i2c_gate_ctrl)
265 fe->ops.i2c_gate_ctrl(fe, 1); 296 fe->ops.i2c_gate_ctrl(fe, 1);
266 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) 297 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
298 wprintk("could not write to tuner at addr: 0x%02x\n",
299 addr << 1);
267 return -EIO; 300 return -EIO;
301 }
268 msleep(1); 302 msleep(1);
269 return 0; 303 return 0;
270} 304}
271 305
272static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe) 306static int philips_tu1216_init(struct dvb_frontend *fe)
273{ 307{
274 struct saa7134_dev *dev = fe->dvb->priv; 308 struct saa7134_dev *dev = fe->dvb->priv;
309 struct tda1004x_state *state = fe->demodulator_priv;
310 u8 addr = state->config->tuner_address;
275 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab }; 311 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
276 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) }; 312 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
277 313
@@ -287,46 +323,17 @@ static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
287 323
288/* ------------------------------------------------------------------ */ 324/* ------------------------------------------------------------------ */
289 325
290static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
291{
292 return philips_tda6651_pll_init(0x60, fe);
293}
294
295static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
296{
297 return philips_tda6651_pll_set(0x60, fe, params);
298}
299
300static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
301 const struct firmware **fw, char *name)
302{
303 struct saa7134_dev *dev = fe->dvb->priv;
304 return request_firmware(fw, name, &dev->pci->dev);
305}
306
307static struct tda1004x_config philips_tu1216_60_config = { 326static struct tda1004x_config philips_tu1216_60_config = {
308
309 .demod_address = 0x8, 327 .demod_address = 0x8,
310 .invert = 1, 328 .invert = 1,
311 .invert_oclk = 0, 329 .invert_oclk = 0,
312 .xtal_freq = TDA10046_XTAL_4M, 330 .xtal_freq = TDA10046_XTAL_4M,
313 .agc_config = TDA10046_AGC_DEFAULT, 331 .agc_config = TDA10046_AGC_DEFAULT,
314 .if_freq = TDA10046_FREQ_3617, 332 .if_freq = TDA10046_FREQ_3617,
315 .request_firmware = philips_tda1004x_request_firmware, 333 .tuner_address = 0x60,
334 .request_firmware = philips_tda1004x_request_firmware
316}; 335};
317 336
318/* ------------------------------------------------------------------ */
319
320static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
321{
322 return philips_tda6651_pll_init(0x61, fe);
323}
324
325static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
326{
327 return philips_tda6651_pll_set(0x61, fe, params);
328}
329
330static struct tda1004x_config philips_tu1216_61_config = { 337static struct tda1004x_config philips_tu1216_61_config = {
331 338
332 .demod_address = 0x8, 339 .demod_address = 0x8,
@@ -335,7 +342,8 @@ static struct tda1004x_config philips_tu1216_61_config = {
335 .xtal_freq = TDA10046_XTAL_4M, 342 .xtal_freq = TDA10046_XTAL_4M,
336 .agc_config = TDA10046_AGC_DEFAULT, 343 .agc_config = TDA10046_AGC_DEFAULT,
337 .if_freq = TDA10046_FREQ_3617, 344 .if_freq = TDA10046_FREQ_3617,
338 .request_firmware = philips_tda1004x_request_firmware, 345 .tuner_address = 0x61,
346 .request_firmware = philips_tda1004x_request_firmware
339}; 347};
340 348
341/* ------------------------------------------------------------------ */ 349/* ------------------------------------------------------------------ */
@@ -343,24 +351,42 @@ static struct tda1004x_config philips_tu1216_61_config = {
343static int philips_td1316_tuner_init(struct dvb_frontend *fe) 351static int philips_td1316_tuner_init(struct dvb_frontend *fe)
344{ 352{
345 struct saa7134_dev *dev = fe->dvb->priv; 353 struct saa7134_dev *dev = fe->dvb->priv;
354 struct tda1004x_state *state = fe->demodulator_priv;
355 u8 addr = state->config->tuner_address;
346 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab }; 356 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
347 struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) }; 357 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
348 358
349 /* setup PLL configuration */ 359 /* setup PLL configuration */
350 if (fe->ops.i2c_gate_ctrl) 360 if (fe->ops.i2c_gate_ctrl)
351 fe->ops.i2c_gate_ctrl(fe, 1); 361 fe->ops.i2c_gate_ctrl(fe, 1);
352 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1) 362 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
353 return -EIO; 363 return -EIO;
354 if (fe->ops.i2c_gate_ctrl)
355 fe->ops.i2c_gate_ctrl(fe, 0);
356 return 0; 364 return 0;
357} 365}
358 366
359static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 367static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
360{ 368{
361 return philips_tda6651_pll_set(0x61, fe, params); 369 return philips_tda6651_pll_set(fe, params);
362} 370}
363 371
372static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
373{
374 struct saa7134_dev *dev = fe->dvb->priv;
375 struct tda1004x_state *state = fe->demodulator_priv;
376 u8 addr = state->config->tuner_address;
377 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
378 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
379
380 /* switch the tuner to analog mode */
381 if (fe->ops.i2c_gate_ctrl)
382 fe->ops.i2c_gate_ctrl(fe, 1);
383 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
384 return -EIO;
385 return 0;
386}
387
388/* ------------------------------------------------------------------ */
389
364static int philips_europa_tuner_init(struct dvb_frontend *fe) 390static int philips_europa_tuner_init(struct dvb_frontend *fe)
365{ 391{
366 struct saa7134_dev *dev = fe->dvb->priv; 392 struct saa7134_dev *dev = fe->dvb->priv;
@@ -380,18 +406,14 @@ static int philips_europa_tuner_init(struct dvb_frontend *fe)
380static int philips_europa_tuner_sleep(struct dvb_frontend *fe) 406static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
381{ 407{
382 struct saa7134_dev *dev = fe->dvb->priv; 408 struct saa7134_dev *dev = fe->dvb->priv;
383 /* this message actually turns the tuner back to analog mode */
384 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
385 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
386 409
387 i2c_transfer(&dev->i2c_adap, &analog_msg, 1); 410 static u8 msg[] = { 0x00, 0x14 };
388 msleep(1); 411 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
412
413 if (philips_td1316_tuner_sleep(fe))
414 return -EIO;
389 415
390 /* switch the board to analog mode */ 416 /* switch the board to analog mode */
391 analog_msg.addr = 0x43;
392 analog_msg.len = 0x02;
393 msg[0] = 0x00;
394 msg[1] = 0x14;
395 if (fe->ops.i2c_gate_ctrl) 417 if (fe->ops.i2c_gate_ctrl)
396 fe->ops.i2c_gate_ctrl(fe, 1); 418 fe->ops.i2c_gate_ctrl(fe, 1);
397 i2c_transfer(&dev->i2c_adap, &analog_msg, 1); 419 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
@@ -416,7 +438,8 @@ static struct tda1004x_config philips_europa_config = {
416 .xtal_freq = TDA10046_XTAL_4M, 438 .xtal_freq = TDA10046_XTAL_4M,
417 .agc_config = TDA10046_AGC_IFO_AUTO_POS, 439 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
418 .if_freq = TDA10046_FREQ_052, 440 .if_freq = TDA10046_FREQ_052,
419 .request_firmware = NULL, 441 .tuner_address = 0x61,
442 .request_firmware = philips_tda1004x_request_firmware
420}; 443};
421 444
422/* ------------------------------------------------------------------ */ 445/* ------------------------------------------------------------------ */
@@ -424,9 +447,11 @@ static struct tda1004x_config philips_europa_config = {
424static int philips_fmd1216_tuner_init(struct dvb_frontend *fe) 447static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
425{ 448{
426 struct saa7134_dev *dev = fe->dvb->priv; 449 struct saa7134_dev *dev = fe->dvb->priv;
450 struct tda1004x_state *state = fe->demodulator_priv;
451 u8 addr = state->config->tuner_address;
427 /* this message is to set up ATC and ALC */ 452 /* this message is to set up ATC and ALC */
428 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 453 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
429 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; 454 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
430 455
431 if (fe->ops.i2c_gate_ctrl) 456 if (fe->ops.i2c_gate_ctrl)
432 fe->ops.i2c_gate_ctrl(fe, 1); 457 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -440,9 +465,11 @@ static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
440static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe) 465static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
441{ 466{
442 struct saa7134_dev *dev = fe->dvb->priv; 467 struct saa7134_dev *dev = fe->dvb->priv;
468 struct tda1004x_state *state = fe->demodulator_priv;
469 u8 addr = state->config->tuner_address;
443 /* this message actually turns the tuner back to analog mode */ 470 /* this message actually turns the tuner back to analog mode */
444 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 }; 471 u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
445 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) }; 472 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
446 473
447 if (fe->ops.i2c_gate_ctrl) 474 if (fe->ops.i2c_gate_ctrl)
448 fe->ops.i2c_gate_ctrl(fe, 1); 475 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -460,8 +487,10 @@ static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
460static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 487static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
461{ 488{
462 struct saa7134_dev *dev = fe->dvb->priv; 489 struct saa7134_dev *dev = fe->dvb->priv;
490 struct tda1004x_state *state = fe->demodulator_priv;
491 u8 addr = state->config->tuner_address;
463 u8 tuner_buf[4]; 492 u8 tuner_buf[4];
464 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len = 493 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
465 sizeof(tuner_buf) }; 494 sizeof(tuner_buf) };
466 int tuner_frequency = 0; 495 int tuner_frequency = 0;
467 int divider = 0; 496 int divider = 0;
@@ -536,8 +565,11 @@ static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_
536 565
537 if (fe->ops.i2c_gate_ctrl) 566 if (fe->ops.i2c_gate_ctrl)
538 fe->ops.i2c_gate_ctrl(fe, 1); 567 fe->ops.i2c_gate_ctrl(fe, 1);
539 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) 568 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
569 wprintk("could not write to tuner at addr: 0x%02x\n",
570 addr << 1);
540 return -EIO; 571 return -EIO;
572 }
541 return 0; 573 return 0;
542} 574}
543 575
@@ -548,582 +580,365 @@ static struct tda1004x_config medion_cardbus = {
548 .xtal_freq = TDA10046_XTAL_16M, 580 .xtal_freq = TDA10046_XTAL_16M,
549 .agc_config = TDA10046_AGC_IFO_AUTO_NEG, 581 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
550 .if_freq = TDA10046_FREQ_3613, 582 .if_freq = TDA10046_FREQ_3613,
551 .request_firmware = NULL, 583 .tuner_address = 0x61,
584 .request_firmware = philips_tda1004x_request_firmware
552}; 585};
553 586
554/* ------------------------------------------------------------------ */ 587/* ------------------------------------------------------------------
555 588 * tda 1004x based cards with philips silicon tuner
556struct tda827x_data { 589 */
557 u32 lomax;
558 u8 spd;
559 u8 bs;
560 u8 bp;
561 u8 cp;
562 u8 gc3;
563 u8 div1p5;
564};
565
566static struct tda827x_data tda827x_dvbt[] = {
567 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
568 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
569 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
570 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
571 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
572 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
573 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
574 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
575 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
576 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
577 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
578 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
579 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
580 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
581 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
582 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
583 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
584 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
585 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
586 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
587 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
588 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
589 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
590 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
591 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
592 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
593 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
594 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
595 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
596};
597
598static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
599{
600 return 0;
601}
602 590
603static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 591static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
604{ 592{
605 struct saa7134_dev *dev = fe->dvb->priv; 593 struct saa7134_dev *dev = fe->dvb->priv;
606 u8 tuner_buf[14]; 594 struct tda1004x_state *state = fe->demodulator_priv;
607 595 u8 addr = state->config->i2c_gate;
608 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf, 596 u8 config = state->config->tuner_config;
609 .len = sizeof(tuner_buf) }; 597 u8 GP00_CF[] = {0x20, 0x01};
610 int i, tuner_freq, if_freq; 598 u8 GP00_LEV[] = {0x22, 0x00};
611 u32 N; 599
612 switch (params->u.ofdm.bandwidth) { 600 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
613 case BANDWIDTH_6_MHZ: 601 if (config) {
614 if_freq = 4000000; 602 if (high) {
615 break; 603 dprintk("setting LNA to high gain\n");
616 case BANDWIDTH_7_MHZ: 604 } else {
617 if_freq = 4500000; 605 dprintk("setting LNA to low gain\n");
618 break; 606 }
619 default: /* 8 MHz or Auto */
620 if_freq = 5000000;
621 break;
622 }
623 tuner_freq = params->frequency + if_freq;
624
625 i = 0;
626 while (tda827x_dvbt[i].lomax < tuner_freq) {
627 if(tda827x_dvbt[i + 1].lomax == 0)
628 break;
629 i++;
630 } 607 }
631 608 switch (config) {
632 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2); 609 case 0: /* no LNA */
633 tuner_buf[0] = 0;
634 tuner_buf[1] = (N>>8) | 0x40;
635 tuner_buf[2] = N & 0xff;
636 tuner_buf[3] = 0;
637 tuner_buf[4] = 0x52;
638 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
639 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
640 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
641 tuner_buf[7] = 0xbf;
642 tuner_buf[8] = 0x2a;
643 tuner_buf[9] = 0x05;
644 tuner_buf[10] = 0xff;
645 tuner_buf[11] = 0x00;
646 tuner_buf[12] = 0x00;
647 tuner_buf[13] = 0x40;
648
649 tuner_msg.len = 14;
650 if (fe->ops.i2c_gate_ctrl)
651 fe->ops.i2c_gate_ctrl(fe, 1);
652 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
653 return -EIO;
654
655 msleep(500);
656 /* correct CP value */
657 tuner_buf[0] = 0x30;
658 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
659 tuner_msg.len = 2;
660 if (fe->ops.i2c_gate_ctrl)
661 fe->ops.i2c_gate_ctrl(fe, 1);
662 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
663
664 return 0;
665}
666
667static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
668{
669 struct saa7134_dev *dev = fe->dvb->priv;
670 static u8 tda827x_sleep[] = { 0x30, 0xd0};
671 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
672 .len = sizeof(tda827x_sleep) };
673 if (fe->ops.i2c_gate_ctrl)
674 fe->ops.i2c_gate_ctrl(fe, 1);
675 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
676 return 0;
677}
678
679static struct tda1004x_config tda827x_lifeview_config = {
680 .demod_address = 0x08,
681 .invert = 1,
682 .invert_oclk = 0,
683 .xtal_freq = TDA10046_XTAL_16M,
684 .agc_config = TDA10046_AGC_TDA827X_GP11,
685 .if_freq = TDA10046_FREQ_045,
686 .request_firmware = NULL,
687};
688
689/* ------------------------------------------------------------------ */
690
691struct tda827xa_data {
692 u32 lomax;
693 u8 svco;
694 u8 spd;
695 u8 scr;
696 u8 sbs;
697 u8 gc3;
698};
699
700static struct tda827xa_data tda827xa_dvbt[] = {
701 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
702 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
703 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
704 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
705 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
706 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
707 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
708 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
709 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
710 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
711 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
712 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
713 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
714 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
715 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
716 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
717 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
718 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
719 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
720 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
721 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
722 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
723 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
724 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
725 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
726 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
727 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
728
729
730static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
731{
732 struct saa7134_dev *dev = fe->dvb->priv;
733 u8 tuner_buf[14];
734 unsigned char reg2[2];
735
736 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
737 int i, tuner_freq, if_freq;
738 u32 N;
739
740 switch (params->u.ofdm.bandwidth) {
741 case BANDWIDTH_6_MHZ:
742 if_freq = 4000000;
743 break; 610 break;
744 case BANDWIDTH_7_MHZ: 611 case 1: /* switch is GPIO 0 of tda8290 */
745 if_freq = 4500000; 612 case 2:
613 /* turn Vsync off */
614 saa7134_set_gpio(dev, 22, 0);
615 GP00_LEV[1] = high ? 0 : 1;
616 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
617 wprintk("could not access tda8290 at addr: 0x%02x\n",
618 addr << 1);
619 return;
620 }
621 msg.buf = GP00_LEV;
622 if (config == 2)
623 GP00_LEV[1] = high ? 1 : 0;
624 i2c_transfer(&dev->i2c_adap, &msg, 1);
746 break; 625 break;
747 default: /* 8 MHz or Auto */ 626 case 3: /* switch with GPIO of saa713x */
748 if_freq = 5000000; 627 saa7134_set_gpio(dev, 22, high);
749 break; 628 break;
750 } 629 }
751 tuner_freq = params->frequency + if_freq;
752
753 i = 0;
754 while (tda827xa_dvbt[i].lomax < tuner_freq) {
755 if(tda827xa_dvbt[i + 1].lomax == 0)
756 break;
757 i++;
758 }
759
760 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
761 tuner_buf[0] = 0; // subaddress
762 tuner_buf[1] = N >> 8;
763 tuner_buf[2] = N & 0xff;
764 tuner_buf[3] = 0;
765 tuner_buf[4] = 0x16;
766 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
767 tda827xa_dvbt[i].sbs;
768 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
769 tuner_buf[7] = 0x0c;
770 tuner_buf[8] = 0x06;
771 tuner_buf[9] = 0x24;
772 tuner_buf[10] = 0xff;
773 tuner_buf[11] = 0x60;
774 tuner_buf[12] = 0x00;
775 tuner_buf[13] = 0x39; // lpsel
776 msg.len = 14;
777 if (fe->ops.i2c_gate_ctrl)
778 fe->ops.i2c_gate_ctrl(fe, 1);
779 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
780 return -EIO;
781
782 msg.buf= reg2;
783 msg.len = 2;
784 reg2[0] = 0x60;
785 reg2[1] = 0x3c;
786 if (fe->ops.i2c_gate_ctrl)
787 fe->ops.i2c_gate_ctrl(fe, 1);
788 i2c_transfer(&dev->i2c_adap, &msg, 1);
789
790 reg2[0] = 0xa0;
791 reg2[1] = 0x40;
792 if (fe->ops.i2c_gate_ctrl)
793 fe->ops.i2c_gate_ctrl(fe, 1);
794 i2c_transfer(&dev->i2c_adap, &msg, 1);
795
796 msleep(2);
797 /* correct CP value */
798 reg2[0] = 0x30;
799 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
800 msg.len = 2;
801 if (fe->ops.i2c_gate_ctrl)
802 fe->ops.i2c_gate_ctrl(fe, 1);
803 i2c_transfer(&dev->i2c_adap, &msg, 1);
804
805 msleep(550);
806 reg2[0] = 0x50;
807 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
808 if (fe->ops.i2c_gate_ctrl)
809 fe->ops.i2c_gate_ctrl(fe, 1);
810 i2c_transfer(&dev->i2c_adap, &msg, 1);
811
812 return 0;
813
814} 630}
815 631
816static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe) 632static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
817{ 633{
818 struct saa7134_dev *dev = fe->dvb->priv; 634 struct tda1004x_state *state = fe->demodulator_priv;
819 static u8 tda827xa_sleep[] = { 0x30, 0x90};
820 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
821 .len = sizeof(tda827xa_sleep) };
822 if (fe->ops.i2c_gate_ctrl)
823 fe->ops.i2c_gate_ctrl(fe, 1);
824 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
825 if (fe->ops.i2c_gate_ctrl)
826 fe->ops.i2c_gate_ctrl(fe, 0);
827 return 0;
828}
829 635
830/* ------------------------------------------------------------------ */ 636 u8 addr = state->config->i2c_gate;
831
832static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
833{
834 struct saa7134_dev *dev = fe->dvb->priv;
835 static u8 tda8290_close[] = { 0x21, 0xc0}; 637 static u8 tda8290_close[] = { 0x21, 0xc0};
836 static u8 tda8290_open[] = { 0x21, 0x80}; 638 static u8 tda8290_open[] = { 0x21, 0x80};
837 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; 639 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
838 if (enable) { 640 if (enable) {
839 tda8290_msg.buf = tda8290_close; 641 tda8290_msg.buf = tda8290_close;
840 } else { 642 } else {
841 tda8290_msg.buf = tda8290_open; 643 tda8290_msg.buf = tda8290_open;
842 } 644 }
843 if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1) 645 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
646 struct saa7134_dev *dev = fe->dvb->priv;
647 wprintk("could not access tda8290 I2C gate\n");
844 return -EIO; 648 return -EIO;
649 }
845 msleep(20); 650 msleep(20);
846 return 0; 651 return 0;
847} 652}
848 653
849/* ------------------------------------------------------------------ */ 654/* ------------------------------------------------------------------ */
850 655
851static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 656static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
852{ 657{
853 int ret; 658 struct saa7134_dev *dev = fe->dvb->priv;
659 struct tda1004x_state *state = fe->demodulator_priv;
854 660
855 ret = philips_tda827xa_pll_set(0x61, fe, params); 661 switch (state->config->antenna_switch) {
856 if (ret != 0) 662 case 0: break;
857 return ret; 663 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
664 saa7134_set_gpio(dev, 21, 0);
665 break;
666 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
667 saa7134_set_gpio(dev, 21, 1);
668 break;
669 }
858 return 0; 670 return 0;
859} 671}
860 672
861static int philips_tiger_tuner_init(struct dvb_frontend *fe) 673static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
862{ 674{
863 struct saa7134_dev *dev = fe->dvb->priv; 675 struct saa7134_dev *dev = fe->dvb->priv;
864 static u8 data[] = { 0x3c, 0x33, 0x6a}; 676 struct tda1004x_state *state = fe->demodulator_priv;
865 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
866 677
867 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) 678 switch (state->config->antenna_switch) {
868 return -EIO; 679 case 0: break;
680 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
681 saa7134_set_gpio(dev, 21, 1);
682 break;
683 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
684 saa7134_set_gpio(dev, 21, 0);
685 break;
686 }
869 return 0; 687 return 0;
870} 688}
871 689
872static int philips_tiger_tuner_sleep(struct dvb_frontend *fe) 690static struct tda827x_config tda827x_cfg = {
873{ 691 .lna_gain = philips_tda827x_lna_gain,
874 struct saa7134_dev *dev = fe->dvb->priv; 692 .init = philips_tda827x_tuner_init,
875 static u8 data[] = { 0x3c, 0x33, 0x68}; 693 .sleep = philips_tda827x_tuner_sleep
876 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 694};
877 695
878 i2c_transfer(&dev->i2c_adap, &msg, 1); 696static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
879 philips_tda827xa_tuner_sleep( 0x61, fe); 697{
880 return 0; 698 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
699 if (dev->dvb.frontend) {
700 if (tda_conf->i2c_gate)
701 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
702 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
703 &dev->i2c_adap,&tda827x_cfg) == NULL) {
704 wprintk("no tda827x tuner found at addr: %02x\n",
705 tda_conf->tuner_address);
706 }
707 }
881} 708}
882 709
883static struct tda1004x_config philips_tiger_config = { 710/* ------------------------------------------------------------------ */
711static struct tda1004x_config tda827x_lifeview_config = {
884 .demod_address = 0x08, 712 .demod_address = 0x08,
885 .invert = 1, 713 .invert = 1,
886 .invert_oclk = 0, 714 .invert_oclk = 0,
887 .xtal_freq = TDA10046_XTAL_16M, 715 .xtal_freq = TDA10046_XTAL_16M,
888 .agc_config = TDA10046_AGC_TDA827X_GP11, 716 .agc_config = TDA10046_AGC_TDA827X,
717 .gpio_config = TDA10046_GP11_I,
889 .if_freq = TDA10046_FREQ_045, 718 .if_freq = TDA10046_FREQ_045,
890 .request_firmware = NULL, 719 .tuner_address = 0x60,
720 .request_firmware = philips_tda1004x_request_firmware
891}; 721};
892/* ------------------------------------------------------------------ */
893
894static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
895{
896 struct saa7134_dev *dev = fe->dvb->priv;
897 static u8 data[] = { 0x3c, 0x33, 0x62};
898 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
899 722
900 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) 723static struct tda1004x_config philips_tiger_config = {
901 return -EIO; 724 .demod_address = 0x08,
902 return 0; 725 .invert = 1,
903} 726 .invert_oclk = 0,
904 727 .xtal_freq = TDA10046_XTAL_16M,
905static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe) 728 .agc_config = TDA10046_AGC_TDA827X,
906{ 729 .gpio_config = TDA10046_GP11_I,
907 struct saa7134_dev *dev = fe->dvb->priv; 730 .if_freq = TDA10046_FREQ_045,
908 static u8 data[] = { 0x3c, 0x33, 0x60}; 731 .i2c_gate = 0x4b,
909 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 732 .tuner_address = 0x61,
910 733 .tuner_config = 0,
911 i2c_transfer(&dev->i2c_adap, &msg, 1); 734 .antenna_switch= 1,
912 philips_tda827xa_tuner_sleep( 0x61, fe); 735 .request_firmware = philips_tda1004x_request_firmware
913 return 0; 736};
914}
915 737
916static struct tda1004x_config cinergy_ht_config = { 738static struct tda1004x_config cinergy_ht_config = {
917 .demod_address = 0x08, 739 .demod_address = 0x08,
918 .invert = 1, 740 .invert = 1,
919 .invert_oclk = 0, 741 .invert_oclk = 0,
920 .xtal_freq = TDA10046_XTAL_16M, 742 .xtal_freq = TDA10046_XTAL_16M,
921 .agc_config = TDA10046_AGC_TDA827X_GP01, 743 .agc_config = TDA10046_AGC_TDA827X,
744 .gpio_config = TDA10046_GP01_I,
922 .if_freq = TDA10046_FREQ_045, 745 .if_freq = TDA10046_FREQ_045,
923 .request_firmware = NULL, 746 .i2c_gate = 0x4b,
747 .tuner_address = 0x61,
748 .tuner_config = 0,
749 .request_firmware = philips_tda1004x_request_firmware
924}; 750};
925 751
926/* ------------------------------------------------------------------ */ 752static struct tda1004x_config cinergy_ht_pci_config = {
753 .demod_address = 0x08,
754 .invert = 1,
755 .invert_oclk = 0,
756 .xtal_freq = TDA10046_XTAL_16M,
757 .agc_config = TDA10046_AGC_TDA827X,
758 .gpio_config = TDA10046_GP01_I,
759 .if_freq = TDA10046_FREQ_045,
760 .i2c_gate = 0x4b,
761 .tuner_address = 0x60,
762 .tuner_config = 0,
763 .request_firmware = philips_tda1004x_request_firmware
764};
927 765
928static struct tda1004x_config pinnacle_pctv_310i_config = { 766static struct tda1004x_config philips_tiger_s_config = {
929 .demod_address = 0x08, 767 .demod_address = 0x08,
930 .invert = 1, 768 .invert = 1,
931 .invert_oclk = 0, 769 .invert_oclk = 0,
932 .xtal_freq = TDA10046_XTAL_16M, 770 .xtal_freq = TDA10046_XTAL_16M,
933 .agc_config = TDA10046_AGC_TDA827X_GP11, 771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP01_I,
934 .if_freq = TDA10046_FREQ_045, 773 .if_freq = TDA10046_FREQ_045,
935 .request_firmware = philips_tda1004x_request_firmware, 774 .i2c_gate = 0x4b,
775 .tuner_address = 0x61,
776 .tuner_config = 2,
777 .antenna_switch= 1,
778 .request_firmware = philips_tda1004x_request_firmware
936}; 779};
937 780
938/* ------------------------------------------------------------------ */ 781static struct tda1004x_config pinnacle_pctv_310i_config = {
782 .demod_address = 0x08,
783 .invert = 1,
784 .invert_oclk = 0,
785 .xtal_freq = TDA10046_XTAL_16M,
786 .agc_config = TDA10046_AGC_TDA827X,
787 .gpio_config = TDA10046_GP11_I,
788 .if_freq = TDA10046_FREQ_045,
789 .i2c_gate = 0x4b,
790 .tuner_address = 0x61,
791 .tuner_config = 1,
792 .request_firmware = philips_tda1004x_request_firmware
793};
939 794
940static struct tda1004x_config hauppauge_hvr_1110_config = { 795static struct tda1004x_config hauppauge_hvr_1110_config = {
941 .demod_address = 0x08, 796 .demod_address = 0x08,
942 .invert = 1, 797 .invert = 1,
943 .invert_oclk = 0, 798 .invert_oclk = 0,
944 .xtal_freq = TDA10046_XTAL_16M, 799 .xtal_freq = TDA10046_XTAL_16M,
945 .agc_config = TDA10046_AGC_TDA827X_GP11, 800 .agc_config = TDA10046_AGC_TDA827X,
801 .gpio_config = TDA10046_GP11_I,
946 .if_freq = TDA10046_FREQ_045, 802 .if_freq = TDA10046_FREQ_045,
947 .request_firmware = philips_tda1004x_request_firmware, 803 .i2c_gate = 0x4b,
804 .tuner_address = 0x61,
805 .request_firmware = philips_tda1004x_request_firmware
948}; 806};
949 807
950/* ------------------------------------------------------------------ */
951
952static struct tda1004x_config asus_p7131_dual_config = { 808static struct tda1004x_config asus_p7131_dual_config = {
953 .demod_address = 0x08, 809 .demod_address = 0x08,
954 .invert = 1, 810 .invert = 1,
955 .invert_oclk = 0, 811 .invert_oclk = 0,
956 .xtal_freq = TDA10046_XTAL_16M, 812 .xtal_freq = TDA10046_XTAL_16M,
957 .agc_config = TDA10046_AGC_TDA827X_GP11, 813 .agc_config = TDA10046_AGC_TDA827X,
814 .gpio_config = TDA10046_GP11_I,
958 .if_freq = TDA10046_FREQ_045, 815 .if_freq = TDA10046_FREQ_045,
959 .request_firmware = philips_tda1004x_request_firmware, 816 .i2c_gate = 0x4b,
817 .tuner_address = 0x61,
818 .tuner_config = 0,
819 .antenna_switch= 2,
820 .request_firmware = philips_tda1004x_request_firmware
960}; 821};
961 822
962static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
963{
964 struct saa7134_dev *dev = fe->dvb->priv;
965 static u8 data[] = { 0x3c, 0x33, 0x6a};
966 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
967
968 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
969 return -EIO;
970 /* make sure the DVB-T antenna input is set */
971 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
972 return 0;
973}
974
975static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
976{
977 struct saa7134_dev *dev = fe->dvb->priv;
978 static u8 data[] = { 0x3c, 0x33, 0x68};
979 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
980
981 i2c_transfer(&dev->i2c_adap, &msg, 1);
982 philips_tda827xa_tuner_sleep( 0x61, fe);
983 /* reset antenna inputs for analog usage */
984 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
985 return 0;
986}
987
988/* ------------------------------------------------------------------ */
989
990static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
991{
992 int ret;
993
994 ret = philips_tda827xa_pll_set(0x60, fe, params);
995 return ret;
996}
997
998static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
999{
1000 philips_tda827xa_tuner_sleep(0x60, fe);
1001 return 0;
1002}
1003
1004static struct tda1004x_config lifeview_trio_config = { 823static struct tda1004x_config lifeview_trio_config = {
1005 .demod_address = 0x09, 824 .demod_address = 0x09,
1006 .invert = 1, 825 .invert = 1,
1007 .invert_oclk = 0, 826 .invert_oclk = 0,
1008 .xtal_freq = TDA10046_XTAL_16M, 827 .xtal_freq = TDA10046_XTAL_16M,
1009 .agc_config = TDA10046_AGC_TDA827X_GP00, 828 .agc_config = TDA10046_AGC_TDA827X,
829 .gpio_config = TDA10046_GP00_I,
1010 .if_freq = TDA10046_FREQ_045, 830 .if_freq = TDA10046_FREQ_045,
1011 .request_firmware = NULL, 831 .tuner_address = 0x60,
832 .request_firmware = philips_tda1004x_request_firmware
1012}; 833};
1013 834
1014/* ------------------------------------------------------------------ */ 835static struct tda1004x_config tevion_dvbt220rf_config = {
1015
1016static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
1017{
1018 int ret;
1019
1020 ret = philips_tda827xa_pll_set(0x61, fe, params);
1021 return ret;
1022}
1023
1024static int ads_duo_tuner_init(struct dvb_frontend *fe)
1025{
1026 struct saa7134_dev *dev = fe->dvb->priv;
1027 /* route TDA8275a AGC input to the channel decoder */
1028 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
1029 return 0;
1030}
1031
1032static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1033{
1034 struct saa7134_dev *dev = fe->dvb->priv;
1035 /* route TDA8275a AGC input to the analog IF chip*/
1036 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
1037 philips_tda827xa_tuner_sleep( 0x61, fe);
1038 return 0;
1039}
1040
1041static struct tda1004x_config ads_tech_duo_config = {
1042 .demod_address = 0x08, 836 .demod_address = 0x08,
1043 .invert = 1, 837 .invert = 1,
1044 .invert_oclk = 0, 838 .invert_oclk = 0,
1045 .xtal_freq = TDA10046_XTAL_16M, 839 .xtal_freq = TDA10046_XTAL_16M,
1046 .agc_config = TDA10046_AGC_TDA827X_GP00, 840 .agc_config = TDA10046_AGC_TDA827X,
841 .gpio_config = TDA10046_GP11_I,
1047 .if_freq = TDA10046_FREQ_045, 842 .if_freq = TDA10046_FREQ_045,
1048 .request_firmware = NULL, 843 .tuner_address = 0x60,
844 .request_firmware = philips_tda1004x_request_firmware
1049}; 845};
1050 846
1051/* ------------------------------------------------------------------ */ 847static struct tda1004x_config md8800_dvbt_config = {
1052 848 .demod_address = 0x08,
1053static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 849 .invert = 1,
1054{ 850 .invert_oclk = 0,
1055 int ret; 851 .xtal_freq = TDA10046_XTAL_16M,
1056 ret = philips_tda827xa_pll_set(0x60, fe, params); 852 .agc_config = TDA10046_AGC_TDA827X,
1057 return ret; 853 .gpio_config = TDA10046_GP01_I,
1058} 854 .if_freq = TDA10046_FREQ_045,
1059 855 .i2c_gate = 0x4b,
1060static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe) 856 .tuner_address = 0x60,
1061{ 857 .tuner_config = 0,
1062 philips_tda827xa_tuner_sleep( 0x61, fe); 858 .request_firmware = philips_tda1004x_request_firmware
1063 return 0; 859};
1064}
1065 860
1066static struct tda1004x_config tevion_dvbt220rf_config = { 861static struct tda1004x_config asus_p7131_4871_config = {
1067 .demod_address = 0x08, 862 .demod_address = 0x08,
1068 .invert = 1, 863 .invert = 1,
1069 .invert_oclk = 0, 864 .invert_oclk = 0,
1070 .xtal_freq = TDA10046_XTAL_16M, 865 .xtal_freq = TDA10046_XTAL_16M,
1071 .agc_config = TDA10046_AGC_TDA827X_GP11, 866 .agc_config = TDA10046_AGC_TDA827X,
867 .gpio_config = TDA10046_GP01_I,
1072 .if_freq = TDA10046_FREQ_045, 868 .if_freq = TDA10046_FREQ_045,
1073 .request_firmware = NULL, 869 .i2c_gate = 0x4b,
870 .tuner_address = 0x61,
871 .tuner_config = 2,
872 .antenna_switch= 2,
873 .request_firmware = philips_tda1004x_request_firmware
1074}; 874};
1075 875
1076/* ------------------------------------------------------------------ */ 876static struct tda1004x_config asus_p7131_hybrid_lna_config = {
877 .demod_address = 0x08,
878 .invert = 1,
879 .invert_oclk = 0,
880 .xtal_freq = TDA10046_XTAL_16M,
881 .agc_config = TDA10046_AGC_TDA827X,
882 .gpio_config = TDA10046_GP11_I,
883 .if_freq = TDA10046_FREQ_045,
884 .i2c_gate = 0x4b,
885 .tuner_address = 0x61,
886 .tuner_config = 2,
887 .antenna_switch= 2,
888 .request_firmware = philips_tda1004x_request_firmware
889};
890/* ------------------------------------------------------------------
891 * special case: this card uses saa713x GPIO22 for the mode switch
892 */
1077 893
1078static int md8800_dvbt_analog_mode(struct dvb_frontend *fe) 894static int ads_duo_tuner_init(struct dvb_frontend *fe)
1079{ 895{
1080 struct saa7134_dev *dev = fe->dvb->priv; 896 struct saa7134_dev *dev = fe->dvb->priv;
1081 static u8 data[] = { 0x3c, 0x33, 0x68}; 897 philips_tda827x_tuner_init(fe);
1082 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 898 /* route TDA8275a AGC input to the channel decoder */
1083 899 saa7134_set_gpio(dev, 22, 1);
1084 i2c_transfer(&dev->i2c_adap, &msg, 1);
1085 philips_tda827xa_tuner_sleep( 0x61, fe);
1086 return 0; 900 return 0;
1087} 901}
1088 902
1089static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 903static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
1090{ 904{
1091 int ret;
1092 struct saa7134_dev *dev = fe->dvb->priv; 905 struct saa7134_dev *dev = fe->dvb->priv;
1093 static u8 tda8290_close[] = { 0x21, 0xc0}; 906 /* route TDA8275a AGC input to the analog IF chip*/
1094 static u8 tda8290_open[] = { 0x21, 0x80}; 907 saa7134_set_gpio(dev, 22, 0);
1095 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2}; 908 philips_tda827x_tuner_sleep(fe);
1096 /* close tda8290 i2c bridge */ 909 return 0;
1097 tda8290_msg.buf = tda8290_close;
1098 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1099 if (ret != 1)
1100 return -EIO;
1101 msleep(20);
1102 ret = philips_tda827xa_pll_set(0x60, fe, params);
1103 if (ret != 0)
1104 return ret;
1105 /* open tda8290 i2c bridge */
1106 tda8290_msg.buf = tda8290_open;
1107 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
1108 return ret;
1109} 910}
1110 911
1111static struct tda1004x_config md8800_dvbt_config = { 912static struct tda827x_config ads_duo_cfg = {
913 .lna_gain = philips_tda827x_lna_gain,
914 .init = ads_duo_tuner_init,
915 .sleep = ads_duo_tuner_sleep
916};
917
918static struct tda1004x_config ads_tech_duo_config = {
1112 .demod_address = 0x08, 919 .demod_address = 0x08,
1113 .invert = 1, 920 .invert = 1,
1114 .invert_oclk = 0, 921 .invert_oclk = 0,
1115 .xtal_freq = TDA10046_XTAL_16M, 922 .xtal_freq = TDA10046_XTAL_16M,
1116 .agc_config = TDA10046_AGC_TDA827X_GP11, 923 .agc_config = TDA10046_AGC_TDA827X,
924 .gpio_config = TDA10046_GP00_I,
1117 .if_freq = TDA10046_FREQ_045, 925 .if_freq = TDA10046_FREQ_045,
1118 .request_firmware = NULL, 926 .tuner_address = 0x61,
927 .request_firmware = philips_tda1004x_request_firmware
1119}; 928};
1120 929
930/* ==================================================================
931 * tda10086 based DVB-S cards, helper functions
932 */
933
1121static struct tda10086_config flydvbs = { 934static struct tda10086_config flydvbs = {
1122 .demod_address = 0x0e, 935 .demod_address = 0x0e,
1123 .invert = 0, 936 .invert = 0,
1124}; 937};
1125 938
1126/* ------------------------------------------------------------------ */ 939/* ==================================================================
940 * nxt200x based ATSC cards, helper functions
941 */
1127 942
1128static struct nxt200x_config avertvhda180 = { 943static struct nxt200x_config avertvhda180 = {
1129 .demod_address = 0x0a, 944 .demod_address = 0x0a,
@@ -1143,10 +958,13 @@ static struct nxt200x_config kworldatsc110 = {
1143 .set_pll_input = nxt200x_set_pll_input, 958 .set_pll_input = nxt200x_set_pll_input,
1144}; 959};
1145 960
1146/* ------------------------------------------------------------------ */ 961/* ==================================================================
962 * Core code
963 */
1147 964
1148static int dvb_init(struct saa7134_dev *dev) 965static int dvb_init(struct saa7134_dev *dev)
1149{ 966{
967 int ret;
1150 /* init struct videobuf_dvb */ 968 /* init struct videobuf_dvb */
1151 dev->ts.nr_bufs = 32; 969 dev->ts.nr_bufs = 32;
1152 dev->ts.nr_packets = 32*4; 970 dev->ts.nr_packets = 32*4;
@@ -1160,7 +978,7 @@ static int dvb_init(struct saa7134_dev *dev)
1160 978
1161 switch (dev->board) { 979 switch (dev->board) {
1162 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 980 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1163 printk("%s: pinnacle 300i dvb setup\n",dev->name); 981 dprintk("pinnacle 300i dvb setup\n");
1164 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, 982 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1165 &dev->i2c_adap); 983 &dev->i2c_adap);
1166 if (dev->dvb.frontend) { 984 if (dev->dvb.frontend) {
@@ -1169,7 +987,7 @@ static int dvb_init(struct saa7134_dev *dev)
1169 break; 987 break;
1170 case SAA7134_BOARD_AVERMEDIA_777: 988 case SAA7134_BOARD_AVERMEDIA_777:
1171 case SAA7134_BOARD_AVERMEDIA_A16AR: 989 case SAA7134_BOARD_AVERMEDIA_A16AR:
1172 printk("%s: avertv 777 dvb setup\n",dev->name); 990 dprintk("avertv 777 dvb setup\n");
1173 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 991 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1174 &dev->i2c_adap); 992 &dev->i2c_adap);
1175 if (dev->dvb.frontend) { 993 if (dev->dvb.frontend) {
@@ -1191,42 +1009,15 @@ static int dvb_init(struct saa7134_dev *dev)
1191 &philips_tu1216_60_config, 1009 &philips_tu1216_60_config,
1192 &dev->i2c_adap); 1010 &dev->i2c_adap);
1193 if (dev->dvb.frontend) { 1011 if (dev->dvb.frontend) {
1194 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init; 1012 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1195 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params; 1013 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1196 } 1014 }
1197 break; 1015 break;
1198 case SAA7134_BOARD_FLYDVBTDUO: 1016 case SAA7134_BOARD_FLYDVBTDUO:
1199 dev->dvb.frontend = dvb_attach(tda10046_attach,
1200 &tda827x_lifeview_config,
1201 &dev->i2c_adap);
1202 if (dev->dvb.frontend) {
1203 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1204 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1205 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1206 }
1207 break;
1208 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1017 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1209 dev->dvb.frontend = dvb_attach(tda10046_attach, 1018 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1210 &tda827x_lifeview_config,
1211 &dev->i2c_adap);
1212 if (dev->dvb.frontend) {
1213 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1214 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1215 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1216 }
1217 break; 1019 break;
1218 case SAA7134_BOARD_PHILIPS_EUROPA: 1020 case SAA7134_BOARD_PHILIPS_EUROPA:
1219 dev->dvb.frontend = dvb_attach(tda10046_attach,
1220 &philips_europa_config,
1221 &dev->i2c_adap);
1222 if (dev->dvb.frontend) {
1223 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1224 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1225 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1226 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1227 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1228 }
1229 break;
1230 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1021 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1231 dev->dvb.frontend = dvb_attach(tda10046_attach, 1022 dev->dvb.frontend = dvb_attach(tda10046_attach,
1232 &philips_europa_config, 1023 &philips_europa_config,
@@ -1244,125 +1035,61 @@ static int dvb_init(struct saa7134_dev *dev)
1244 &philips_tu1216_61_config, 1035 &philips_tu1216_61_config,
1245 &dev->i2c_adap); 1036 &dev->i2c_adap);
1246 if (dev->dvb.frontend) { 1037 if (dev->dvb.frontend) {
1247 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init; 1038 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1248 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params; 1039 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1249 } 1040 }
1250 break; 1041 break;
1251 case SAA7134_BOARD_PHILIPS_TIGER: 1042 case SAA7134_BOARD_PHILIPS_TIGER:
1252 dev->dvb.frontend = dvb_attach(tda10046_attach, 1043 configure_tda827x_fe(dev, &philips_tiger_config);
1253 &philips_tiger_config,
1254 &dev->i2c_adap);
1255 if (dev->dvb.frontend) {
1256 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1257 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1258 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1259 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1260 }
1261 break; 1044 break;
1262 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1045 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1263 dev->dvb.frontend = dvb_attach(tda10046_attach, 1046 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
1264 &pinnacle_pctv_310i_config,
1265 &dev->i2c_adap);
1266 if (dev->dvb.frontend) {
1267 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1268 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1269 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1270 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1271 }
1272 break; 1047 break;
1273 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1048 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1274 dev->dvb.frontend = dvb_attach(tda10046_attach, 1049 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
1275 &hauppauge_hvr_1110_config,
1276 &dev->i2c_adap);
1277 if (dev->dvb.frontend) {
1278 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1279 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1280 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1281 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1282 }
1283 break; 1050 break;
1284 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1051 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1285 dev->dvb.frontend = dvb_attach(tda10046_attach, 1052 configure_tda827x_fe(dev, &asus_p7131_dual_config);
1286 &asus_p7131_dual_config,
1287 &dev->i2c_adap);
1288 if (dev->dvb.frontend) {
1289 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1290 dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
1291 dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
1292 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1293 }
1294 break; 1053 break;
1295 case SAA7134_BOARD_FLYDVBT_LR301: 1054 case SAA7134_BOARD_FLYDVBT_LR301:
1296 dev->dvb.frontend = dvb_attach(tda10046_attach, 1055 configure_tda827x_fe(dev, &tda827x_lifeview_config);
1297 &tda827x_lifeview_config,
1298 &dev->i2c_adap);
1299 if (dev->dvb.frontend) {
1300 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1301 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1302 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
1303 }
1304 break; 1056 break;
1305 case SAA7134_BOARD_FLYDVB_TRIO: 1057 case SAA7134_BOARD_FLYDVB_TRIO:
1306 if(! use_frontend) { //terrestrial 1058 if(! use_frontend) { //terrestrial
1307 dev->dvb.frontend = dvb_attach(tda10046_attach, 1059 configure_tda827x_fe(dev, &lifeview_trio_config);
1308 &lifeview_trio_config,
1309 &dev->i2c_adap);
1310 if (dev->dvb.frontend) {
1311 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1312 dev->dvb.frontend->ops.tuner_ops.set_params =
1313 lifeview_trio_tuner_set_params;
1314 }
1315 } else { //satellite 1060 } else { //satellite
1316 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1061 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1317 if (dev->dvb.frontend) { 1062 if (dev->dvb.frontend) {
1318 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1063 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1319 &dev->i2c_adap, 0) == NULL) { 1064 &dev->i2c_adap, 0) == NULL) {
1320 printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__); 1065 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1321 } 1066 }
1322 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1067 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1323 0x08, 0, 0) == NULL) { 1068 0x08, 0, 0) == NULL) {
1324 printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__); 1069 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1325 } 1070 }
1326 } 1071 }
1327 } 1072 }
1328 break; 1073 break;
1329 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1074 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1075 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1330 dev->dvb.frontend = dvb_attach(tda10046_attach, 1076 dev->dvb.frontend = dvb_attach(tda10046_attach,
1331 &ads_tech_duo_config, 1077 &ads_tech_duo_config,
1332 &dev->i2c_adap); 1078 &dev->i2c_adap);
1333 if (dev->dvb.frontend) { 1079 if (dev->dvb.frontend) {
1334 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1080 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
1335 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; 1081 ads_tech_duo_config.tuner_address,
1336 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params; 1082 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
1083 wprintk("no tda827x tuner found at addr: %02x\n",
1084 ads_tech_duo_config.tuner_address);
1085 }
1337 } 1086 }
1338 break; 1087 break;
1339 case SAA7134_BOARD_TEVION_DVBT_220RF: 1088 case SAA7134_BOARD_TEVION_DVBT_220RF:
1340 dev->dvb.frontend = dvb_attach(tda10046_attach, 1089 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
1341 &tevion_dvbt220rf_config,
1342 &dev->i2c_adap);
1343 if (dev->dvb.frontend) {
1344 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1345 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1346 }
1347 break;
1348 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1349 dev->dvb.frontend = dvb_attach(tda10046_attach,
1350 &ads_tech_duo_config,
1351 &dev->i2c_adap);
1352 if (dev->dvb.frontend) {
1353 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1354 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1355 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1356 }
1357 break; 1090 break;
1358 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1091 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1359 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config, 1092 configure_tda827x_fe(dev, &md8800_dvbt_config);
1360 &dev->i2c_adap);
1361 if (dev->dvb.frontend) {
1362 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1363 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1364 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1365 }
1366 break; 1093 break;
1367 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1094 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1368 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1095 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
@@ -1386,11 +1113,11 @@ static int dvb_init(struct saa7134_dev *dev)
1386 if (dev->dvb.frontend) { 1113 if (dev->dvb.frontend) {
1387 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1114 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1388 &dev->i2c_adap, 0) == NULL) { 1115 &dev->i2c_adap, 0) == NULL) {
1389 printk("%s: No tda826x found!\n", __FUNCTION__); 1116 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1390 } 1117 }
1391 if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1118 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1392 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1119 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1393 printk("%s: No ISL6421 found!\n", __FUNCTION__); 1120 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
1394 } 1121 }
1395 } 1122 }
1396 break; 1123 break;
@@ -1415,41 +1142,45 @@ static int dvb_init(struct saa7134_dev *dev)
1415 } 1142 }
1416 break; 1143 break;
1417 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1144 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1418 dev->dvb.frontend = dvb_attach(tda10046_attach, 1145 configure_tda827x_fe(dev, &cinergy_ht_config);
1419 &cinergy_ht_config,
1420 &dev->i2c_adap);
1421 if (dev->dvb.frontend) {
1422 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
1423 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
1424 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
1425 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
1426
1427 }
1428 break; 1146 break;
1429 case SAA7134_BOARD_CINERGY_HT_PCI: 1147 case SAA7134_BOARD_CINERGY_HT_PCI:
1430 dev->dvb.frontend = dvb_attach(tda10046_attach, 1148 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
1431 &cinergy_ht_config, 1149 break;
1432 &dev->i2c_adap); 1150 case SAA7134_BOARD_PHILIPS_TIGER_S:
1433 if (dev->dvb.frontend) { 1151 configure_tda827x_fe(dev, &philips_tiger_s_config);
1434 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 1152 break;
1435 dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init; 1153 case SAA7134_BOARD_ASUS_P7131_4871:
1436 dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep; 1154 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1437 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set; 1155 break;
1438 1156 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1439 } 1157 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
1440 break; 1158 break;
1441 default: 1159 default:
1442 printk("%s: Huh? unknown DVB card?\n",dev->name); 1160 wprintk("Huh? unknown DVB card?\n");
1443 break; 1161 break;
1444 } 1162 }
1445 1163
1446 if (NULL == dev->dvb.frontend) { 1164 if (NULL == dev->dvb.frontend) {
1447 printk("%s: frontend initialization failed\n",dev->name); 1165 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
1448 return -1; 1166 return -1;
1449 } 1167 }
1450 1168
1451 /* register everything else */ 1169 /* register everything else */
1452 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); 1170 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1171
1172 /* this sequence is necessary to make the tda1004x load its firmware
1173 * and to enter analog mode of hybrid boards
1174 */
1175 if (!ret) {
1176 if (dev->dvb.frontend->ops.init)
1177 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1178 if (dev->dvb.frontend->ops.sleep)
1179 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1180 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1181 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1182 }
1183 return ret;
1453} 1184}
1454 1185
1455static int dvb_fini(struct saa7134_dev *dev) 1186static int dvb_fini(struct saa7134_dev *dev)