aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/s5h1420.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/s5h1420.c')
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
index d69477596921..2c2c344c4c64 100644
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -38,7 +38,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
38 38
39struct s5h1420_state { 39struct s5h1420_state {
40 struct i2c_adapter* i2c; 40 struct i2c_adapter* i2c;
41 struct dvb_frontend_ops ops;
42 const struct s5h1420_config* config; 41 const struct s5h1420_config* config;
43 struct dvb_frontend frontend; 42 struct dvb_frontend frontend;
44 43
@@ -584,7 +583,6 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe,
584 struct s5h1420_state* state = fe->demodulator_priv; 583 struct s5h1420_state* state = fe->demodulator_priv;
585 int frequency_delta; 584 int frequency_delta;
586 struct dvb_frontend_tune_settings fesettings; 585 struct dvb_frontend_tune_settings fesettings;
587 u32 tmp;
588 586
589 /* check if we should do a fast-tune */ 587 /* check if we should do a fast-tune */
590 memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); 588 memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters));
@@ -596,10 +594,17 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe,
596 (state->fec_inner == p->u.qpsk.fec_inner) && 594 (state->fec_inner == p->u.qpsk.fec_inner) &&
597 (state->symbol_rate == p->u.qpsk.symbol_rate)) { 595 (state->symbol_rate == p->u.qpsk.symbol_rate)) {
598 596
599 if (state->config->pll_set) { 597 if (fe->ops.tuner_ops.set_params) {
600 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); 598 fe->ops.tuner_ops.set_params(fe, p);
601 state->config->pll_set(fe, p, &tmp); 599 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
600 }
601 if (fe->ops.tuner_ops.get_frequency) {
602 u32 tmp;
603 fe->ops.tuner_ops.get_frequency(fe, &tmp);
604 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
602 s5h1420_setfreqoffset(state, p->frequency - tmp); 605 s5h1420_setfreqoffset(state, p->frequency - tmp);
606 } else {
607 s5h1420_setfreqoffset(state, 0);
603 } 608 }
604 return 0; 609 return 0;
605 } 610 }
@@ -646,9 +651,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe,
646 s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); 651 s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1);
647 652
648 /* set tuner PLL */ 653 /* set tuner PLL */
649 if (state->config->pll_set) { 654 if (fe->ops.tuner_ops.set_params) {
650 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); 655 fe->ops.tuner_ops.set_params(fe, p);
651 state->config->pll_set(fe, p, &tmp); 656 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
652 s5h1420_setfreqoffset(state, 0); 657 s5h1420_setfreqoffset(state, 0);
653 } 658 }
654 659
@@ -708,6 +713,17 @@ static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
708 return 0; 713 return 0;
709} 714}
710 715
716static int s5h1420_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
717{
718 struct s5h1420_state* state = fe->demodulator_priv;
719
720 if (enable) {
721 return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
722 } else {
723 return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
724 }
725}
726
711static int s5h1420_init (struct dvb_frontend* fe) 727static int s5h1420_init (struct dvb_frontend* fe)
712{ 728{
713 struct s5h1420_state* state = fe->demodulator_priv; 729 struct s5h1420_state* state = fe->demodulator_priv;
@@ -717,13 +733,6 @@ static int s5h1420_init (struct dvb_frontend* fe)
717 msleep(10); 733 msleep(10);
718 s5h1420_reset(state); 734 s5h1420_reset(state);
719 735
720 /* init PLL */
721 if (state->config->pll_init) {
722 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
723 state->config->pll_init(fe);
724 s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
725 }
726
727 return 0; 736 return 0;
728} 737}
729 738
@@ -756,7 +765,6 @@ struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
756 /* setup the state */ 765 /* setup the state */
757 state->config = config; 766 state->config = config;
758 state->i2c = i2c; 767 state->i2c = i2c;
759 memcpy(&state->ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops));
760 state->postlocked = 0; 768 state->postlocked = 0;
761 state->fclk = 88000000; 769 state->fclk = 88000000;
762 state->tunedfreq = 0; 770 state->tunedfreq = 0;
@@ -769,7 +777,7 @@ struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
769 goto error; 777 goto error;
770 778
771 /* create dvb_frontend */ 779 /* create dvb_frontend */
772 state->frontend.ops = &state->ops; 780 memcpy(&state->frontend.ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops));
773 state->frontend.demodulator_priv = state; 781 state->frontend.demodulator_priv = state;
774 return &state->frontend; 782 return &state->frontend;
775 783
@@ -800,6 +808,7 @@ static struct dvb_frontend_ops s5h1420_ops = {
800 808
801 .init = s5h1420_init, 809 .init = s5h1420_init,
802 .sleep = s5h1420_sleep, 810 .sleep = s5h1420_sleep,
811 .i2c_gate_ctrl = s5h1420_i2c_gate_ctrl,
803 812
804 .set_frontend = s5h1420_set_frontend, 813 .set_frontend = s5h1420_set_frontend,
805 .get_frontend = s5h1420_get_frontend, 814 .get_frontend = s5h1420_get_frontend,