tda8290.c (cf9ce948f47640797bd19980e1d99c6d17d0bdc3) tda8290.c (2f719f7a9aa599bc9e1516190336a4ac5c59b18a)
1/*
2
3 i2c tv tuner chip device driver
4 controls the philips tda8290+75 tuner chip combo.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or

--- 219 unchanged lines hidden (view full) ---

228 if (priv->tda8290_easy_mode & 0x60)
229 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_9, 2);
230 else
231 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2);
232 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2);
233 }
234
235
1/*
2
3 i2c tv tuner chip device driver
4 controls the philips tda8290+75 tuner chip combo.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or

--- 219 unchanged lines hidden (view full) ---

228 if (priv->tda8290_easy_mode & 0x60)
229 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_9, 2);
230 else
231 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2);
232 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2);
233 }
234
235
236 tda8290_i2c_bridge(fe, 1);
236 if (fe->ops.analog_ops.i2c_gate_ctrl)
237 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
237
238 if (fe->ops.tuner_ops.set_analog_params)
239 fe->ops.tuner_ops.set_analog_params(fe, params);
240
241 for (i = 0; i < 3; i++) {
242 tuner_i2c_xfer_send_recv(&priv->i2c_props,
243 &addr_pll_stat, 1, &pll_stat, 1);
244 if (pll_stat & 0x80) {

--- 52 unchanged lines hidden (view full) ---

297 if ((adc_sat > 20) || !(pll_stat & 0x80)) {
298 tuner_dbg("trying to resolve SECAM L deadlock\n");
299 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2);
300 msleep(40);
301 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_off, 2);
302 }
303 }
304
238
239 if (fe->ops.tuner_ops.set_analog_params)
240 fe->ops.tuner_ops.set_analog_params(fe, params);
241
242 for (i = 0; i < 3; i++) {
243 tuner_i2c_xfer_send_recv(&priv->i2c_props,
244 &addr_pll_stat, 1, &pll_stat, 1);
245 if (pll_stat & 0x80) {

--- 52 unchanged lines hidden (view full) ---

298 if ((adc_sat > 20) || !(pll_stat & 0x80)) {
299 tuner_dbg("trying to resolve SECAM L deadlock\n");
300 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2);
301 msleep(40);
302 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_off, 2);
303 }
304 }
305
305 tda8290_i2c_bridge(fe, 0);
306 if (fe->ops.analog_ops.i2c_gate_ctrl)
307 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
306 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2);
307}
308
309/*---------------------------------------------------------------------*/
310
311static void tda8295_power(struct dvb_frontend *fe, int enable)
312{
313 struct tda8290_priv *priv = fe->analog_demod_priv;

--- 105 unchanged lines hidden (view full) ---

419 &blanking_mode[0], 1, &blanking_mode[1], 1);
420
421 tda8295_set_video_std(fe);
422
423 blanking_mode[1] = 0x03;
424 tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2);
425 msleep(20);
426
308 tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2);
309}
310
311/*---------------------------------------------------------------------*/
312
313static void tda8295_power(struct dvb_frontend *fe, int enable)
314{
315 struct tda8290_priv *priv = fe->analog_demod_priv;

--- 105 unchanged lines hidden (view full) ---

421 &blanking_mode[0], 1, &blanking_mode[1], 1);
422
423 tda8295_set_video_std(fe);
424
425 blanking_mode[1] = 0x03;
426 tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2);
427 msleep(20);
428
427 tda8295_i2c_bridge(fe, 1);
429 if (fe->ops.analog_ops.i2c_gate_ctrl)
430 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
428
429 if (fe->ops.tuner_ops.set_analog_params)
430 fe->ops.tuner_ops.set_analog_params(fe, params);
431
432 if (priv->cfg.agcf)
433 priv->cfg.agcf(fe);
434
435 if (tda8295_has_signal(fe))
436 tuner_dbg("tda8295 is locked\n");
437 else
438 tuner_dbg("tda8295 not locked, no signal?\n");
439
431
432 if (fe->ops.tuner_ops.set_analog_params)
433 fe->ops.tuner_ops.set_analog_params(fe, params);
434
435 if (priv->cfg.agcf)
436 priv->cfg.agcf(fe);
437
438 if (tda8295_has_signal(fe))
439 tuner_dbg("tda8295 is locked\n");
440 else
441 tuner_dbg("tda8295 not locked, no signal?\n");
442
440 tda8295_i2c_bridge(fe, 0);
443 if (fe->ops.analog_ops.i2c_gate_ctrl)
444 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
441}
442
443/*---------------------------------------------------------------------*/
444
445static int tda8290_has_signal(struct dvb_frontend *fe)
446{
447 struct tda8290_priv *priv = fe->analog_demod_priv;
448

--- 11 unchanged lines hidden (view full) ---

460{
461 struct tda8290_priv *priv = fe->analog_demod_priv;
462
463 unsigned char cb1[] = { 0x30, 0xD0 };
464 unsigned char tda8290_standby[] = { 0x00, 0x02 };
465 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
466 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
467
445}
446
447/*---------------------------------------------------------------------*/
448
449static int tda8290_has_signal(struct dvb_frontend *fe)
450{
451 struct tda8290_priv *priv = fe->analog_demod_priv;
452

--- 11 unchanged lines hidden (view full) ---

464{
465 struct tda8290_priv *priv = fe->analog_demod_priv;
466
467 unsigned char cb1[] = { 0x30, 0xD0 };
468 unsigned char tda8290_standby[] = { 0x00, 0x02 };
469 unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
470 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
471
468 tda8290_i2c_bridge(fe, 1);
472 if (fe->ops.analog_ops.i2c_gate_ctrl)
473 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
469 if (priv->ver & TDA8275A)
470 cb1[1] = 0x90;
471 i2c_transfer(priv->i2c_props.adap, &msg, 1);
474 if (priv->ver & TDA8275A)
475 cb1[1] = 0x90;
476 i2c_transfer(priv->i2c_props.adap, &msg, 1);
472 tda8290_i2c_bridge(fe, 0);
477 if (fe->ops.analog_ops.i2c_gate_ctrl)
478 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
473 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2);
474 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2);
475}
476
477static void tda8295_standby(struct dvb_frontend *fe)
478{
479 tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */
480

--- 51 unchanged lines hidden (view full) ---

532 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
533 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
534 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
535 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
536 .buf=tda8275_init, .len = 14};
537 if (priv->ver & TDA8275A)
538 msg.buf = tda8275a_init;
539
479 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2);
480 tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2);
481}
482
483static void tda8295_standby(struct dvb_frontend *fe)
484{
485 tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */
486

--- 51 unchanged lines hidden (view full) ---

538 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
539 unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
540 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
541 struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
542 .buf=tda8275_init, .len = 14};
543 if (priv->ver & TDA8275A)
544 msg.buf = tda8275a_init;
545
540 tda8290_i2c_bridge(fe, 1);
546 if (fe->ops.analog_ops.i2c_gate_ctrl)
547 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
541 i2c_transfer(priv->i2c_props.adap, &msg, 1);
548 i2c_transfer(priv->i2c_props.adap, &msg, 1);
542 tda8290_i2c_bridge(fe, 0);
549 if (fe->ops.analog_ops.i2c_gate_ctrl)
550 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
543}
544
545/*---------------------------------------------------------------------*/
546
547static void tda829x_release(struct dvb_frontend *fe)
548{
549 struct tda8290_priv *priv = fe->analog_demod_priv;
550

--- 9 unchanged lines hidden (view full) ---

560
561static struct tda18271_config tda829x_tda18271_config = {
562 .gate = TDA18271_GATE_ANALOG,
563};
564
565static int tda829x_find_tuner(struct dvb_frontend *fe)
566{
567 struct tda8290_priv *priv = fe->analog_demod_priv;
551}
552
553/*---------------------------------------------------------------------*/
554
555static void tda829x_release(struct dvb_frontend *fe)
556{
557 struct tda8290_priv *priv = fe->analog_demod_priv;
558

--- 9 unchanged lines hidden (view full) ---

568
569static struct tda18271_config tda829x_tda18271_config = {
570 .gate = TDA18271_GATE_ANALOG,
571};
572
573static int tda829x_find_tuner(struct dvb_frontend *fe)
574{
575 struct tda8290_priv *priv = fe->analog_demod_priv;
568 struct analog_demod_ops *analog_ops = &fe->ops.analog_ops;
569 int i, ret, tuners_found;
570 u32 tuner_addrs;
571 u8 data;
572 struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 };
573
576 int i, ret, tuners_found;
577 u32 tuner_addrs;
578 u8 data;
579 struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 };
580
574 if (!analog_ops->i2c_gate_ctrl) {
575 printk(KERN_ERR "tda8290: no gate control were provided!\n");
581 if (fe->ops.analog_ops.i2c_gate_ctrl)
582 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
576
583
577 return -EINVAL;
578 }
579
580 analog_ops->i2c_gate_ctrl(fe, 1);
581
582 /* probe for tuner chip */
583 tuners_found = 0;
584 tuner_addrs = 0;
585 for (i = 0x60; i <= 0x63; i++) {
586 msg.addr = i;
587 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
588 if (ret == 1) {
589 tuners_found++;
590 tuner_addrs = (tuner_addrs << 8) + i;
591 }
592 }
593 /* if there is more than one tuner, we expect the right one is
594 behind the bridge and we choose the highest address that doesn't
595 give a response now
596 */
597
584 /* probe for tuner chip */
585 tuners_found = 0;
586 tuner_addrs = 0;
587 for (i = 0x60; i <= 0x63; i++) {
588 msg.addr = i;
589 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
590 if (ret == 1) {
591 tuners_found++;
592 tuner_addrs = (tuner_addrs << 8) + i;
593 }
594 }
595 /* if there is more than one tuner, we expect the right one is
596 behind the bridge and we choose the highest address that doesn't
597 give a response now
598 */
599
598 analog_ops->i2c_gate_ctrl(fe, 0);
600 if (fe->ops.analog_ops.i2c_gate_ctrl)
601 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
599
600 if (tuners_found > 1)
601 for (i = 0; i < tuners_found; i++) {
602 msg.addr = tuner_addrs & 0xff;
603 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
604 if (ret == 1)
605 tuner_addrs = tuner_addrs >> 8;
606 else

--- 6 unchanged lines hidden (view full) ---

613 "defaulting to %x\n", tuner_addrs);
614 } else {
615 tuner_addrs = tuner_addrs & 0xff;
616 tuner_info("setting tuner address to %x\n", tuner_addrs);
617 }
618 priv->tda827x_addr = tuner_addrs;
619 msg.addr = tuner_addrs;
620
602
603 if (tuners_found > 1)
604 for (i = 0; i < tuners_found; i++) {
605 msg.addr = tuner_addrs & 0xff;
606 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
607 if (ret == 1)
608 tuner_addrs = tuner_addrs >> 8;
609 else

--- 6 unchanged lines hidden (view full) ---

616 "defaulting to %x\n", tuner_addrs);
617 } else {
618 tuner_addrs = tuner_addrs & 0xff;
619 tuner_info("setting tuner address to %x\n", tuner_addrs);
620 }
621 priv->tda827x_addr = tuner_addrs;
622 msg.addr = tuner_addrs;
623
621 analog_ops->i2c_gate_ctrl(fe, 1);
624 if (fe->ops.analog_ops.i2c_gate_ctrl)
625 fe->ops.analog_ops.i2c_gate_ctrl(fe, 1);
622 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
623
624 if (ret != 1) {
625 tuner_warn("tuner access failed!\n");
626 ret = i2c_transfer(priv->i2c_props.adap, &msg, 1);
627
628 if (ret != 1) {
629 tuner_warn("tuner access failed!\n");
626 analog_ops->i2c_gate_ctrl(fe, 0);
630 if (fe->ops.analog_ops.i2c_gate_ctrl)
631 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
627 return -EREMOTEIO;
628 }
629
630 if ((data == 0x83) || (data == 0x84)) {
631 priv->ver |= TDA18271;
632 tda829x_tda18271_config.config = priv->cfg.config;
633 dvb_attach(tda18271_attach, fe, priv->tda827x_addr,
634 priv->i2c_props.adap, &tda829x_tda18271_config);

--- 8 unchanged lines hidden (view full) ---

643 priv->cfg.switch_addr = priv->i2c_props.addr;
644 }
645 if (fe->ops.tuner_ops.init)
646 fe->ops.tuner_ops.init(fe);
647
648 if (fe->ops.tuner_ops.sleep)
649 fe->ops.tuner_ops.sleep(fe);
650
632 return -EREMOTEIO;
633 }
634
635 if ((data == 0x83) || (data == 0x84)) {
636 priv->ver |= TDA18271;
637 tda829x_tda18271_config.config = priv->cfg.config;
638 dvb_attach(tda18271_attach, fe, priv->tda827x_addr,
639 priv->i2c_props.adap, &tda829x_tda18271_config);

--- 8 unchanged lines hidden (view full) ---

648 priv->cfg.switch_addr = priv->i2c_props.addr;
649 }
650 if (fe->ops.tuner_ops.init)
651 fe->ops.tuner_ops.init(fe);
652
653 if (fe->ops.tuner_ops.sleep)
654 fe->ops.tuner_ops.sleep(fe);
655
651 analog_ops->i2c_gate_ctrl(fe, 0);
656 if (fe->ops.analog_ops.i2c_gate_ctrl)
657 fe->ops.analog_ops.i2c_gate_ctrl(fe, 0);
652
653 return 0;
654}
655
656static int tda8290_probe(struct tuner_i2c_props *i2c_props)
657{
658#define TDA8290_ID 0x89
659 u8 reg = 0x1f, id;

--- 90 unchanged lines hidden (view full) ---

750 }
751
752 if (tda8295_probe(&priv->i2c_props) == 0) {
753 priv->ver = TDA8295;
754 memcpy(&fe->ops.analog_ops, &tda8295_ops,
755 sizeof(struct analog_demod_ops));
756 }
757
658
659 return 0;
660}
661
662static int tda8290_probe(struct tuner_i2c_props *i2c_props)
663{
664#define TDA8290_ID 0x89
665 u8 reg = 0x1f, id;

--- 90 unchanged lines hidden (view full) ---

756 }
757
758 if (tda8295_probe(&priv->i2c_props) == 0) {
759 priv->ver = TDA8295;
760 memcpy(&fe->ops.analog_ops, &tda8295_ops,
761 sizeof(struct analog_demod_ops));
762 }
763
764 if (cfg && cfg->no_i2c_gate)
765 fe->ops.analog_ops.i2c_gate_ctrl = NULL;
766
758 if (!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) {
759 tda8295_power(fe, 1);
760 if (tda829x_find_tuner(fe) < 0)
761 goto fail;
762 }
763
764 switch (priv->ver) {
765 case TDA8290:

--- 109 unchanged lines hidden ---
767 if (!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) {
768 tda8295_power(fe, 1);
769 if (tda829x_find_tuner(fe) < 0)
770 goto fail;
771 }
772
773 switch (priv->ver) {
774 case TDA8290:

--- 109 unchanged lines hidden ---