aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c73
1 files changed, 19 insertions, 54 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 5bf9049c6c00..850a6c606750 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -511,54 +511,7 @@ static int airstar_atsc3_attach(struct flexcop_device *fc,
511#endif 511#endif
512 512
513/* CableStar2 DVB-C */ 513/* CableStar2 DVB-C */
514#if FE_SUPPORTED(STV0297) 514#if FE_SUPPORTED(STV0297) && FE_SUPPORTED(PLL)
515static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe,
516 struct dvb_frontend_parameters *fep)
517{
518 struct flexcop_device *fc = fe->dvb->priv;
519 u8 buf[4];
520 u16 div;
521 int ret;
522
523/* 62.5 kHz * 10 */
524#define REF_FREQ 625
525#define FREQ_OFFSET 36125
526
527 div = ((fep->frequency/1000 + FREQ_OFFSET) * 10) / REF_FREQ;
528/* 4 MHz = 4000 KHz */
529
530 buf[0] = (u8)( div >> 8) & 0x7f;
531 buf[1] = (u8) div & 0xff;
532
533/* F(osc) = N * Reference Freq. (62.5 kHz)
534 * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8
535 * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0
536 * byte 4 : 1 * * AGD R3 R2 R1 R0
537 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
538 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */
539 buf[2] = 0x95;
540
541/* Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
542 * 47 - 153 0 * 0 0 0 0 0 1 0x01
543 * 153 - 430 0 * 0 0 0 0 1 0 0x02
544 * 430 - 822 0 * 0 0 1 0 0 0 0x08
545 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
546
547 if (fep->frequency <= 153000000) buf[3] = 0x01;
548 else if (fep->frequency <= 430000000) buf[3] = 0x02;
549 else if (fep->frequency <= 822000000) buf[3] = 0x08;
550 else buf[3] = 0x88;
551
552 if (fe->ops.i2c_gate_ctrl)
553 fe->ops.i2c_gate_ctrl(fe, 0);
554 deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n", fep->frequency,
555 buf[0], buf[1], buf[2], buf[3]);
556 ret = fc->i2c_request(&fc->fc_i2c_adap[2],
557 FC_WRITE, 0x61, buf[0], &buf[1], 3);
558 deb_tuner("tuner write returned: %d\n",ret);
559 return ret;
560}
561
562static u8 alps_tdee4_stv0297_inittab[] = { 515static u8 alps_tdee4_stv0297_inittab[] = {
563 0x80, 0x01, 516 0x80, 0x01,
564 0x80, 0x00, 517 0x80, 0x00,
@@ -642,13 +595,25 @@ static int cablestar2_attach(struct flexcop_device *fc,
642{ 595{
643 fc->fc_i2c_adap[0].no_base_addr = 1; 596 fc->fc_i2c_adap[0].no_base_addr = 1;
644 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); 597 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c);
645 if (!fc->fe) { 598 if (!fc->fe)
646 /* Reset for next frontend to try */ 599 goto fail;
647 fc->fc_i2c_adap[0].no_base_addr = 0; 600
648 return 0; 601 /* This tuner doesn't use the stv0297's I2C gate, but instead the
649 } 602 * tuner is connected to a different flexcop I2C adapter. */
650 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 603 if (fc->fe->ops.i2c_gate_ctrl)
604 fc->fe->ops.i2c_gate_ctrl(fc->fe, 0);
605 fc->fe->ops.i2c_gate_ctrl = NULL;
606
607 if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61,
608 &fc->fc_i2c_adap[2].i2c_adap, DVB_PLL_TDEE4))
609 goto fail;
610
651 return 1; 611 return 1;
612
613fail:
614 /* Reset for next frontend to try */
615 fc->fc_i2c_adap[0].no_base_addr = 0;
616 return 0;
652} 617}
653#else 618#else
654#define cablestar2_attach NULL 619#define cablestar2_attach NULL