aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/sp8870.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/sp8870.c')
-rw-r--r--drivers/media/dvb/frontends/sp8870.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
index 73829e647e50..44ec5b9a4695 100644
--- a/drivers/media/dvb/frontends/sp8870.c
+++ b/drivers/media/dvb/frontends/sp8870.c
@@ -44,8 +44,6 @@ struct sp8870_state {
44 44
45 struct i2c_adapter* i2c; 45 struct i2c_adapter* i2c;
46 46
47 struct dvb_frontend_ops ops;
48
49 const struct sp8870_config* config; 47 const struct sp8870_config* config;
50 48
51 struct dvb_frontend frontend; 49 struct dvb_frontend frontend;
@@ -262,9 +260,10 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
262 sp8870_microcontroller_stop(state); 260 sp8870_microcontroller_stop(state);
263 261
264 // set tuner parameters 262 // set tuner parameters
265 sp8870_writereg(state, 0x206, 0x001); 263 if (fe->ops.tuner_ops.set_params) {
266 state->config->pll_set(fe, p); 264 fe->ops.tuner_ops.set_params(fe, p);
267 sp8870_writereg(state, 0x206, 0x000); 265 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
266 }
268 267
269 // sample rate correction bit [23..17] 268 // sample rate correction bit [23..17]
270 sp8870_writereg(state, 0x0319, 0x000A); 269 sp8870_writereg(state, 0x0319, 0x000A);
@@ -349,13 +348,6 @@ static int sp8870_init (struct dvb_frontend* fe)
349 sp8870_writereg(state, 0x0D00, 0x010); 348 sp8870_writereg(state, 0x0D00, 0x010);
350 sp8870_writereg(state, 0x0D01, 0x000); 349 sp8870_writereg(state, 0x0D01, 0x000);
351 350
352 /* setup PLL */
353 if (state->config->pll_init) {
354 sp8870_writereg(state, 0x206, 0x001);
355 state->config->pll_init(fe);
356 sp8870_writereg(state, 0x206, 0x000);
357 }
358
359 return 0; 351 return 0;
360} 352}
361 353
@@ -541,6 +533,17 @@ static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend
541 return 0; 533 return 0;
542} 534}
543 535
536static int sp8870_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
537{
538 struct sp8870_state* state = fe->demodulator_priv;
539
540 if (enable) {
541 return sp8870_writereg(state, 0x206, 0x001);
542 } else {
543 return sp8870_writereg(state, 0x206, 0x000);
544 }
545}
546
544static void sp8870_release(struct dvb_frontend* fe) 547static void sp8870_release(struct dvb_frontend* fe)
545{ 548{
546 struct sp8870_state* state = fe->demodulator_priv; 549 struct sp8870_state* state = fe->demodulator_priv;
@@ -561,14 +564,13 @@ struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
561 /* setup the state */ 564 /* setup the state */
562 state->config = config; 565 state->config = config;
563 state->i2c = i2c; 566 state->i2c = i2c;
564 memcpy(&state->ops, &sp8870_ops, sizeof(struct dvb_frontend_ops));
565 state->initialised = 0; 567 state->initialised = 0;
566 568
567 /* check if the demod is there */ 569 /* check if the demod is there */
568 if (sp8870_readreg(state, 0x0200) < 0) goto error; 570 if (sp8870_readreg(state, 0x0200) < 0) goto error;
569 571
570 /* create dvb_frontend */ 572 /* create dvb_frontend */
571 state->frontend.ops = &state->ops; 573 memcpy(&state->frontend.ops, &sp8870_ops, sizeof(struct dvb_frontend_ops));
572 state->frontend.demodulator_priv = state; 574 state->frontend.demodulator_priv = state;
573 return &state->frontend; 575 return &state->frontend;
574 576
@@ -597,6 +599,7 @@ static struct dvb_frontend_ops sp8870_ops = {
597 599
598 .init = sp8870_init, 600 .init = sp8870_init,
599 .sleep = sp8870_sleep, 601 .sleep = sp8870_sleep,
602 .i2c_gate_ctrl = sp8870_i2c_gate_ctrl,
600 603
601 .set_frontend = sp8870_set_frontend, 604 .set_frontend = sp8870_set_frontend,
602 .get_tune_settings = sp8870_get_tune_settings, 605 .get_tune_settings = sp8870_get_tune_settings,