aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/dvb-pll.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/dvb-pll.c')
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 78114fc2672..b0785d542f0 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -488,7 +488,8 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
488 struct dvb_pll_priv *priv = fe->tuner_priv; 488 struct dvb_pll_priv *priv = fe->tuner_priv;
489 u8 buf[4]; 489 u8 buf[4];
490 struct i2c_msg msg = 490 struct i2c_msg msg =
491 { .addr = priv->pll_i2c_address, .flags = 0, .buf = buf, .len = sizeof(buf) }; 491 { .addr = priv->pll_i2c_address, .flags = 0,
492 .buf = buf, .len = sizeof(buf) };
492 int i; 493 int i;
493 int result; 494 int result;
494 495
@@ -516,12 +517,14 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
516 return 0; 517 return 0;
517} 518}
518 519
519static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 520static int dvb_pll_set_params(struct dvb_frontend *fe,
521 struct dvb_frontend_parameters *params)
520{ 522{
521 struct dvb_pll_priv *priv = fe->tuner_priv; 523 struct dvb_pll_priv *priv = fe->tuner_priv;
522 u8 buf[4]; 524 u8 buf[4];
523 struct i2c_msg msg = 525 struct i2c_msg msg =
524 { .addr = priv->pll_i2c_address, .flags = 0, .buf = buf, .len = sizeof(buf) }; 526 { .addr = priv->pll_i2c_address, .flags = 0,
527 .buf = buf, .len = sizeof(buf) };
525 int result; 528 int result;
526 u32 div; 529 u32 div;
527 int i; 530 int i;
@@ -535,7 +538,8 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
535 bandwidth = params->u.ofdm.bandwidth; 538 bandwidth = params->u.ofdm.bandwidth;
536 } 539 }
537 540
538 if ((result = dvb_pll_configure(priv->pll_desc, buf, params->frequency, bandwidth)) != 0) 541 if ((result = dvb_pll_configure(priv->pll_desc, buf, params->frequency,
542 bandwidth)) != 0)
539 return result; 543 return result;
540 544
541 if (fe->ops.i2c_gate_ctrl) 545 if (fe->ops.i2c_gate_ctrl)
@@ -550,14 +554,18 @@ static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
550 continue; 554 continue;
551 break; 555 break;
552 } 556 }
553 div = (params->frequency + priv->pll_desc->entries[i].offset) / priv->pll_desc->entries[i].stepsize; 557 div = (params->frequency + priv->pll_desc->entries[i].offset) /
554 priv->frequency = (div * priv->pll_desc->entries[i].stepsize) - priv->pll_desc->entries[i].offset; 558 priv->pll_desc->entries[i].stepsize;
559 priv->frequency = (div * priv->pll_desc->entries[i].stepsize) -
560 priv->pll_desc->entries[i].offset;
555 priv->bandwidth = bandwidth; 561 priv->bandwidth = bandwidth;
556 562
557 return 0; 563 return 0;
558} 564}
559 565
560static int dvb_pll_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8 *buf, int buf_len) 566static int dvb_pll_calc_regs(struct dvb_frontend *fe,
567 struct dvb_frontend_parameters *params,
568 u8 *buf, int buf_len)
561{ 569{
562 struct dvb_pll_priv *priv = fe->tuner_priv; 570 struct dvb_pll_priv *priv = fe->tuner_priv;
563 int result; 571 int result;
@@ -573,7 +581,8 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parame
573 bandwidth = params->u.ofdm.bandwidth; 581 bandwidth = params->u.ofdm.bandwidth;
574 } 582 }
575 583
576 if ((result = dvb_pll_configure(priv->pll_desc, buf+1, params->frequency, bandwidth)) != 0) 584 if ((result = dvb_pll_configure(priv->pll_desc, buf+1,
585 params->frequency, bandwidth)) != 0)
577 return result; 586 return result;
578 buf[0] = priv->pll_i2c_address; 587 buf[0] = priv->pll_i2c_address;
579 588
@@ -583,8 +592,10 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parame
583 continue; 592 continue;
584 break; 593 break;
585 } 594 }
586 div = (params->frequency + priv->pll_desc->entries[i].offset) / priv->pll_desc->entries[i].stepsize; 595 div = (params->frequency + priv->pll_desc->entries[i].offset) /
587 priv->frequency = (div * priv->pll_desc->entries[i].stepsize) - priv->pll_desc->entries[i].offset; 596 priv->pll_desc->entries[i].stepsize;
597 priv->frequency = (div * priv->pll_desc->entries[i].stepsize) -
598 priv->pll_desc->entries[i].offset;
588 priv->bandwidth = bandwidth; 599 priv->bandwidth = bandwidth;
589 600
590 return 5; 601 return 5;
@@ -613,10 +624,13 @@ static struct dvb_tuner_ops dvb_pll_tuner_ops = {
613 .get_bandwidth = dvb_pll_get_bandwidth, 624 .get_bandwidth = dvb_pll_get_bandwidth,
614}; 625};
615 626
616struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc) 627struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
628 struct i2c_adapter *i2c,
629 struct dvb_pll_desc *desc)
617{ 630{
618 u8 b1 [] = { 0 }; 631 u8 b1 [] = { 0 };
619 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 }; 632 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD,
633 .buf = b1, .len = 1 };
620 struct dvb_pll_priv *priv = NULL; 634 struct dvb_pll_priv *priv = NULL;
621 int ret; 635 int ret;
622 636
@@ -639,7 +653,9 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struc
639 priv->i2c = i2c; 653 priv->i2c = i2c;
640 priv->pll_desc = desc; 654 priv->pll_desc = desc;
641 655
642 memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, sizeof(struct dvb_tuner_ops)); 656 memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops,
657 sizeof(struct dvb_tuner_ops));
658
643 strncpy(fe->ops.tuner_ops.info.name, desc->name, 128); 659 strncpy(fe->ops.tuner_ops.info.name, desc->name, 128);
644 fe->ops.tuner_ops.info.frequency_min = desc->min; 660 fe->ops.tuner_ops.info.frequency_min = desc->min;
645 fe->ops.tuner_ops.info.frequency_min = desc->max; 661 fe->ops.tuner_ops.info.frequency_min = desc->max;