diff options
Diffstat (limited to 'drivers/media/dvb/frontends/mt312.c')
-rw-r--r-- | drivers/media/dvb/frontends/mt312.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c index d3aea83cf218..1ef821825641 100644 --- a/drivers/media/dvb/frontends/mt312.c +++ b/drivers/media/dvb/frontends/mt312.c | |||
@@ -39,7 +39,6 @@ | |||
39 | 39 | ||
40 | struct mt312_state { | 40 | struct mt312_state { |
41 | struct i2c_adapter* i2c; | 41 | struct i2c_adapter* i2c; |
42 | struct dvb_frontend_ops ops; | ||
43 | /* configuration settings */ | 42 | /* configuration settings */ |
44 | const struct mt312_config* config; | 43 | const struct mt312_config* config; |
45 | struct dvb_frontend frontend; | 44 | struct dvb_frontend frontend; |
@@ -277,12 +276,6 @@ static int mt312_initfe(struct dvb_frontend* fe) | |||
277 | if ((ret = mt312_writereg(state, CS_SW_LIM, 0x69)) < 0) | 276 | if ((ret = mt312_writereg(state, CS_SW_LIM, 0x69)) < 0) |
278 | return ret; | 277 | return ret; |
279 | 278 | ||
280 | if (state->config->pll_init) { | ||
281 | mt312_writereg(state, GPP_CTRL, 0x40); | ||
282 | state->config->pll_init(fe); | ||
283 | mt312_writereg(state, GPP_CTRL, 0x00); | ||
284 | } | ||
285 | |||
286 | return 0; | 279 | return 0; |
287 | } | 280 | } |
288 | 281 | ||
@@ -477,16 +470,16 @@ static int mt312_set_frontend(struct dvb_frontend* fe, | |||
477 | 470 | ||
478 | dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency); | 471 | dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency); |
479 | 472 | ||
480 | if ((p->frequency < fe->ops->info.frequency_min) | 473 | if ((p->frequency < fe->ops.info.frequency_min) |
481 | || (p->frequency > fe->ops->info.frequency_max)) | 474 | || (p->frequency > fe->ops.info.frequency_max)) |
482 | return -EINVAL; | 475 | return -EINVAL; |
483 | 476 | ||
484 | if ((p->inversion < INVERSION_OFF) | 477 | if ((p->inversion < INVERSION_OFF) |
485 | || (p->inversion > INVERSION_ON)) | 478 | || (p->inversion > INVERSION_ON)) |
486 | return -EINVAL; | 479 | return -EINVAL; |
487 | 480 | ||
488 | if ((p->u.qpsk.symbol_rate < fe->ops->info.symbol_rate_min) | 481 | if ((p->u.qpsk.symbol_rate < fe->ops.info.symbol_rate_min) |
489 | || (p->u.qpsk.symbol_rate > fe->ops->info.symbol_rate_max)) | 482 | || (p->u.qpsk.symbol_rate > fe->ops.info.symbol_rate_max)) |
490 | return -EINVAL; | 483 | return -EINVAL; |
491 | 484 | ||
492 | if ((p->u.qpsk.fec_inner < FEC_NONE) | 485 | if ((p->u.qpsk.fec_inner < FEC_NONE) |
@@ -529,9 +522,10 @@ static int mt312_set_frontend(struct dvb_frontend* fe, | |||
529 | return -EINVAL; | 522 | return -EINVAL; |
530 | } | 523 | } |
531 | 524 | ||
532 | mt312_writereg(state, GPP_CTRL, 0x40); | 525 | if (fe->ops.tuner_ops.set_params) { |
533 | state->config->pll_set(fe, p); | 526 | fe->ops.tuner_ops.set_params(fe, p); |
534 | mt312_writereg(state, GPP_CTRL, 0x00); | 527 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); |
528 | } | ||
535 | 529 | ||
536 | /* sr = (u16)(sr * 256.0 / 1000000.0) */ | 530 | /* sr = (u16)(sr * 256.0 / 1000000.0) */ |
537 | sr = mt312_div(p->u.qpsk.symbol_rate * 4, 15625); | 531 | sr = mt312_div(p->u.qpsk.symbol_rate * 4, 15625); |
@@ -578,6 +572,17 @@ static int mt312_get_frontend(struct dvb_frontend* fe, | |||
578 | return 0; | 572 | return 0; |
579 | } | 573 | } |
580 | 574 | ||
575 | static int mt312_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | ||
576 | { | ||
577 | struct mt312_state* state = fe->demodulator_priv; | ||
578 | |||
579 | if (enable) { | ||
580 | return mt312_writereg(state, GPP_CTRL, 0x40); | ||
581 | } else { | ||
582 | return mt312_writereg(state, GPP_CTRL, 0x00); | ||
583 | } | ||
584 | } | ||
585 | |||
581 | static int mt312_sleep(struct dvb_frontend* fe) | 586 | static int mt312_sleep(struct dvb_frontend* fe) |
582 | { | 587 | { |
583 | struct mt312_state *state = fe->demodulator_priv; | 588 | struct mt312_state *state = fe->demodulator_priv; |
@@ -633,6 +638,7 @@ static struct dvb_frontend_ops vp310_mt312_ops = { | |||
633 | 638 | ||
634 | .init = mt312_initfe, | 639 | .init = mt312_initfe, |
635 | .sleep = mt312_sleep, | 640 | .sleep = mt312_sleep, |
641 | .i2c_gate_ctrl = mt312_i2c_gate_ctrl, | ||
636 | 642 | ||
637 | .set_frontend = mt312_set_frontend, | 643 | .set_frontend = mt312_set_frontend, |
638 | .get_frontend = mt312_get_frontend, | 644 | .get_frontend = mt312_get_frontend, |
@@ -663,19 +669,22 @@ struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, | |||
663 | /* setup the state */ | 669 | /* setup the state */ |
664 | state->config = config; | 670 | state->config = config; |
665 | state->i2c = i2c; | 671 | state->i2c = i2c; |
666 | memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); | ||
667 | 672 | ||
668 | /* check if the demod is there */ | 673 | /* check if the demod is there */ |
669 | if (mt312_readreg(state, ID, &state->id) < 0) | 674 | if (mt312_readreg(state, ID, &state->id) < 0) |
670 | goto error; | 675 | goto error; |
671 | 676 | ||
677 | /* create dvb_frontend */ | ||
678 | memcpy(&state->frontend.ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); | ||
679 | state->frontend.demodulator_priv = state; | ||
680 | |||
672 | switch (state->id) { | 681 | switch (state->id) { |
673 | case ID_VP310: | 682 | case ID_VP310: |
674 | strcpy(state->ops.info.name, "Zarlink VP310 DVB-S"); | 683 | strcpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S"); |
675 | state->frequency = 90; | 684 | state->frequency = 90; |
676 | break; | 685 | break; |
677 | case ID_MT312: | 686 | case ID_MT312: |
678 | strcpy(state->ops.info.name, "Zarlink MT312 DVB-S"); | 687 | strcpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S"); |
679 | state->frequency = 60; | 688 | state->frequency = 60; |
680 | break; | 689 | break; |
681 | default: | 690 | default: |
@@ -683,9 +692,6 @@ struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, | |||
683 | goto error; | 692 | goto error; |
684 | } | 693 | } |
685 | 694 | ||
686 | /* create dvb_frontend */ | ||
687 | state->frontend.ops = &state->ops; | ||
688 | state->frontend.demodulator_priv = state; | ||
689 | return &state->frontend; | 695 | return &state->frontend; |
690 | 696 | ||
691 | error: | 697 | error: |