aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda10021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda10021.c')
-rw-r--r--drivers/media/dvb/frontends/tda10021.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 21255cac9793..e83ff2104c9b 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -36,7 +36,6 @@
36 36
37struct tda10021_state { 37struct tda10021_state {
38 struct i2c_adapter* i2c; 38 struct i2c_adapter* i2c;
39 struct dvb_frontend_ops ops;
40 /* configuration settings */ 39 /* configuration settings */
41 const struct tda10021_config* config; 40 const struct tda10021_config* config;
42 struct dvb_frontend frontend; 41 struct dvb_frontend frontend;
@@ -90,6 +89,14 @@ static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
90 return (ret != 1) ? -EREMOTEIO : 0; 89 return (ret != 1) ? -EREMOTEIO : 0;
91} 90}
92 91
92int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data)
93{
94 struct tda10021_state* state = fe->demodulator_priv;
95
96 return tda10021_writereg(state, reg, data);
97}
98EXPORT_SYMBOL(tda10021_write_byte);
99
93static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) 100static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
94{ 101{
95 u8 b0 [] = { reg }; 102 u8 b0 [] = { reg };
@@ -225,13 +232,6 @@ static int tda10021_init (struct dvb_frontend *fe)
225 232
226 //Activate PLL 233 //Activate PLL
227 tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef); 234 tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef);
228
229 if (state->config->pll_init) {
230 lock_tuner(state);
231 state->config->pll_init(fe);
232 unlock_tuner(state);
233 }
234
235 return 0; 235 return 0;
236} 236}
237 237
@@ -259,9 +259,10 @@ static int tda10021_set_parameters (struct dvb_frontend *fe,
259 259
260 //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate); 260 //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
261 261
262 lock_tuner(state); 262 if (fe->ops.tuner_ops.set_params) {
263 state->config->pll_set(fe, p); 263 fe->ops.tuner_ops.set_params(fe, p);
264 unlock_tuner(state); 264 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
265 }
265 266
266 tda10021_set_symbolrate (state, p->u.qam.symbol_rate); 267 tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
267 tda10021_writereg (state, 0x34, state->pwm); 268 tda10021_writereg (state, 0x34, state->pwm);
@@ -376,6 +377,18 @@ static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
376 return 0; 377 return 0;
377} 378}
378 379
380static int tda10021_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
381{
382 struct tda10021_state* state = fe->demodulator_priv;
383
384 if (enable) {
385 lock_tuner(state);
386 } else {
387 unlock_tuner(state);
388 }
389 return 0;
390}
391
379static int tda10021_sleep(struct dvb_frontend* fe) 392static int tda10021_sleep(struct dvb_frontend* fe)
380{ 393{
381 struct tda10021_state* state = fe->demodulator_priv; 394 struct tda10021_state* state = fe->demodulator_priv;
@@ -407,7 +420,6 @@ struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
407 /* setup the state */ 420 /* setup the state */
408 state->config = config; 421 state->config = config;
409 state->i2c = i2c; 422 state->i2c = i2c;
410 memcpy(&state->ops, &tda10021_ops, sizeof(struct dvb_frontend_ops));
411 state->pwm = pwm; 423 state->pwm = pwm;
412 state->reg0 = tda10021_inittab[0]; 424 state->reg0 = tda10021_inittab[0];
413 425
@@ -415,7 +427,7 @@ struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
415 if ((tda10021_readreg(state, 0x1a) & 0xf0) != 0x70) goto error; 427 if ((tda10021_readreg(state, 0x1a) & 0xf0) != 0x70) goto error;
416 428
417 /* create dvb_frontend */ 429 /* create dvb_frontend */
418 state->frontend.ops = &state->ops; 430 memcpy(&state->frontend.ops, &tda10021_ops, sizeof(struct dvb_frontend_ops));
419 state->frontend.demodulator_priv = state; 431 state->frontend.demodulator_priv = state;
420 return &state->frontend; 432 return &state->frontend;
421 433
@@ -448,6 +460,7 @@ static struct dvb_frontend_ops tda10021_ops = {
448 460
449 .init = tda10021_init, 461 .init = tda10021_init,
450 .sleep = tda10021_sleep, 462 .sleep = tda10021_sleep,
463 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl,
451 464
452 .set_frontend = tda10021_set_parameters, 465 .set_frontend = tda10021_set_parameters,
453 .get_frontend = tda10021_get_frontend, 466 .get_frontend = tda10021_get_frontend,