aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/sp887x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/sp887x.c')
-rw-r--r--drivers/media/dvb/frontends/sp887x.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
index eb8a602198ca..b0a2b02f6608 100644
--- a/drivers/media/dvb/frontends/sp887x.c
+++ b/drivers/media/dvb/frontends/sp887x.c
@@ -24,7 +24,6 @@
24 24
25struct sp887x_state { 25struct sp887x_state {
26 struct i2c_adapter* i2c; 26 struct i2c_adapter* i2c;
27 struct dvb_frontend_ops ops;
28 const struct sp887x_config* config; 27 const struct sp887x_config* config;
29 struct dvb_frontend frontend; 28 struct dvb_frontend frontend;
30 29
@@ -208,15 +207,6 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware
208 /* bit 0x010: enable data valid signal */ 207 /* bit 0x010: enable data valid signal */
209 sp887x_writereg(state, 0xd00, 0x010); 208 sp887x_writereg(state, 0xd00, 0x010);
210 sp887x_writereg(state, 0x0d1, 0x000); 209 sp887x_writereg(state, 0x0d1, 0x000);
211
212 /* setup the PLL */
213 if (state->config->pll_init) {
214 sp887x_writereg(state, 0x206, 0x001);
215 state->config->pll_init(fe);
216 sp887x_writereg(state, 0x206, 0x000);
217 }
218
219 printk ("done.\n");
220 return 0; 210 return 0;
221}; 211};
222 212
@@ -362,9 +352,16 @@ static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
362 sp887x_microcontroller_stop(state); 352 sp887x_microcontroller_stop(state);
363 353
364 /* setup the PLL */ 354 /* setup the PLL */
365 sp887x_writereg(state, 0x206, 0x001); 355 if (fe->ops.tuner_ops.set_params) {
366 actual_freq = state->config->pll_set(fe, p); 356 fe->ops.tuner_ops.set_params(fe, p);
367 sp887x_writereg(state, 0x206, 0x000); 357 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
358 }
359 if (fe->ops.tuner_ops.get_frequency) {
360 fe->ops.tuner_ops.get_frequency(fe, &actual_freq);
361 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
362 } else {
363 actual_freq = p->frequency;
364 }
368 365
369 /* read status reg in order to clear <pending irqs */ 366 /* read status reg in order to clear <pending irqs */
370 sp887x_readreg(state, 0x200); 367 sp887x_readreg(state, 0x200);
@@ -486,6 +483,17 @@ static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
486 return 0; 483 return 0;
487} 484}
488 485
486static int sp887x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
487{
488 struct sp887x_state* state = fe->demodulator_priv;
489
490 if (enable) {
491 return sp887x_writereg(state, 0x206, 0x001);
492 } else {
493 return sp887x_writereg(state, 0x206, 0x000);
494 }
495}
496
489static int sp887x_sleep(struct dvb_frontend* fe) 497static int sp887x_sleep(struct dvb_frontend* fe)
490{ 498{
491 struct sp887x_state* state = fe->demodulator_priv; 499 struct sp887x_state* state = fe->demodulator_priv;
@@ -555,14 +563,13 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
555 /* setup the state */ 563 /* setup the state */
556 state->config = config; 564 state->config = config;
557 state->i2c = i2c; 565 state->i2c = i2c;
558 memcpy(&state->ops, &sp887x_ops, sizeof(struct dvb_frontend_ops));
559 state->initialised = 0; 566 state->initialised = 0;
560 567
561 /* check if the demod is there */ 568 /* check if the demod is there */
562 if (sp887x_readreg(state, 0x0200) < 0) goto error; 569 if (sp887x_readreg(state, 0x0200) < 0) goto error;
563 570
564 /* create dvb_frontend */ 571 /* create dvb_frontend */
565 state->frontend.ops = &state->ops; 572 memcpy(&state->frontend.ops, &sp887x_ops, sizeof(struct dvb_frontend_ops));
566 state->frontend.demodulator_priv = state; 573 state->frontend.demodulator_priv = state;
567 return &state->frontend; 574 return &state->frontend;
568 575
@@ -589,6 +596,7 @@ static struct dvb_frontend_ops sp887x_ops = {
589 596
590 .init = sp887x_init, 597 .init = sp887x_init,
591 .sleep = sp887x_sleep, 598 .sleep = sp887x_sleep,
599 .i2c_gate_ctrl = sp887x_i2c_gate_ctrl,
592 600
593 .set_frontend = sp887x_setup_frontend_parameters, 601 .set_frontend = sp887x_setup_frontend_parameters,
594 .get_tune_settings = sp887x_get_tune_settings, 602 .get_tune_settings = sp887x_get_tune_settings,