diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/common/tuners/tda18271-fe.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index 46c080089eb0..d4fdcd4a0e06 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -259,26 +259,33 @@ static int tda18271_por(struct dvb_frontend *fe) | |||
259 | { | 259 | { |
260 | struct tda18271_priv *priv = fe->tuner_priv; | 260 | struct tda18271_priv *priv = fe->tuner_priv; |
261 | unsigned char *regs = priv->tda18271_regs; | 261 | unsigned char *regs = priv->tda18271_regs; |
262 | int ret; | ||
262 | 263 | ||
263 | /* power up detector 1 */ | 264 | /* power up detector 1 */ |
264 | regs[R_EB12] &= ~0x20; | 265 | regs[R_EB12] &= ~0x20; |
265 | tda18271_write_regs(fe, R_EB12, 1); | 266 | ret = tda18271_write_regs(fe, R_EB12, 1); |
267 | if (ret < 0) | ||
268 | goto fail; | ||
266 | 269 | ||
267 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ | 270 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ |
268 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 271 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
269 | tda18271_write_regs(fe, R_EB18, 1); | 272 | ret = tda18271_write_regs(fe, R_EB18, 1); |
273 | if (ret < 0) | ||
274 | goto fail; | ||
270 | 275 | ||
271 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ | 276 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ |
272 | 277 | ||
273 | /* POR mode */ | 278 | /* POR mode */ |
274 | tda18271_set_standby_mode(fe, 1, 0, 0); | 279 | ret = tda18271_set_standby_mode(fe, 1, 0, 0); |
280 | if (ret < 0) | ||
281 | goto fail; | ||
275 | 282 | ||
276 | /* disable 1.5 MHz low pass filter */ | 283 | /* disable 1.5 MHz low pass filter */ |
277 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ | 284 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ |
278 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ | 285 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ |
279 | tda18271_write_regs(fe, R_EB21, 3); | 286 | ret = tda18271_write_regs(fe, R_EB21, 3); |
280 | 287 | fail: | |
281 | return 0; | 288 | return ret; |
282 | } | 289 | } |
283 | 290 | ||
284 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | 291 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) |
@@ -389,7 +396,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
389 | { | 396 | { |
390 | struct tda18271_priv *priv = fe->tuner_priv; | 397 | struct tda18271_priv *priv = fe->tuner_priv; |
391 | unsigned char *regs = priv->tda18271_regs; | 398 | unsigned char *regs = priv->tda18271_regs; |
392 | int sgn, bcal, count, wait; | 399 | int sgn, bcal, count, wait, ret; |
393 | u8 cid_target; | 400 | u8 cid_target; |
394 | u16 count_limit; | 401 | u16 count_limit; |
395 | u32 freq; | 402 | u32 freq; |
@@ -421,7 +428,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
421 | tda18271_write_regs(fe, R_EP2, 1); | 428 | tda18271_write_regs(fe, R_EP2, 1); |
422 | 429 | ||
423 | /* read power detection info, stored in EB10 */ | 430 | /* read power detection info, stored in EB10 */ |
424 | tda18271_read_extended(fe); | 431 | ret = tda18271_read_extended(fe); |
432 | if (ret < 0) | ||
433 | return ret; | ||
425 | 434 | ||
426 | /* algorithm initialization */ | 435 | /* algorithm initialization */ |
427 | sgn = 1; | 436 | sgn = 1; |
@@ -447,7 +456,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
447 | tda18271_write_regs(fe, R_EP2, 1); | 456 | tda18271_write_regs(fe, R_EP2, 1); |
448 | 457 | ||
449 | /* read power detection info, stored in EB10 */ | 458 | /* read power detection info, stored in EB10 */ |
450 | tda18271_read_extended(fe); | 459 | ret = tda18271_read_extended(fe); |
460 | if (ret < 0) | ||
461 | return ret; | ||
451 | 462 | ||
452 | count += 200; | 463 | count += 200; |
453 | 464 | ||
@@ -478,6 +489,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
478 | { | 489 | { |
479 | struct tda18271_priv *priv = fe->tuner_priv; | 490 | struct tda18271_priv *priv = fe->tuner_priv; |
480 | unsigned char *regs = priv->tda18271_regs; | 491 | unsigned char *regs = priv->tda18271_regs; |
492 | int ret; | ||
481 | 493 | ||
482 | /* set standard to digital */ | 494 | /* set standard to digital */ |
483 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | 495 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
@@ -489,10 +501,14 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
489 | /* update IF output level & IF notch frequency */ | 501 | /* update IF output level & IF notch frequency */ |
490 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 502 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
491 | 503 | ||
492 | tda18271_write_regs(fe, R_EP3, 2); | 504 | ret = tda18271_write_regs(fe, R_EP3, 2); |
505 | if (ret < 0) | ||
506 | goto fail; | ||
493 | 507 | ||
494 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 508 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
495 | tda18271_write_regs(fe, R_EB18, 1); | 509 | ret = tda18271_write_regs(fe, R_EB18, 1); |
510 | if (ret < 0) | ||
511 | goto fail; | ||
496 | 512 | ||
497 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ | 513 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ |
498 | 514 | ||
@@ -500,9 +516,9 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
500 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ | 516 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ |
501 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ | 517 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ |
502 | 518 | ||
503 | tda18271_write_regs(fe, R_EB21, 3); | 519 | ret = tda18271_write_regs(fe, R_EB21, 3); |
504 | 520 | fail: | |
505 | return 0; | 521 | return ret; |
506 | } | 522 | } |
507 | 523 | ||
508 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | 524 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) |
@@ -535,6 +551,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
535 | 551 | ||
536 | /* look for optimized calibration frequency */ | 552 | /* look for optimized calibration frequency */ |
537 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); | 553 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); |
554 | if (bcal < 0) | ||
555 | return bcal; | ||
538 | 556 | ||
539 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); | 557 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); |
540 | prog_tab[rf] = regs[R_EB14]; | 558 | prog_tab[rf] = regs[R_EB14]; |
@@ -575,13 +593,16 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) | |||
575 | { | 593 | { |
576 | struct tda18271_priv *priv = fe->tuner_priv; | 594 | struct tda18271_priv *priv = fe->tuner_priv; |
577 | unsigned int i; | 595 | unsigned int i; |
596 | int ret; | ||
578 | 597 | ||
579 | tda_info("tda18271: performing RF tracking filter calibration\n"); | 598 | tda_info("tda18271: performing RF tracking filter calibration\n"); |
580 | 599 | ||
581 | /* wait for die temperature stabilization */ | 600 | /* wait for die temperature stabilization */ |
582 | msleep(200); | 601 | msleep(200); |
583 | 602 | ||
584 | tda18271_powerscan_init(fe); | 603 | ret = tda18271_powerscan_init(fe); |
604 | if (ret < 0) | ||
605 | goto fail; | ||
585 | 606 | ||
586 | /* rf band calibration */ | 607 | /* rf band calibration */ |
587 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) | 608 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) |
@@ -589,8 +610,8 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) | |||
589 | priv->rf_cal_state[i].rfmax); | 610 | priv->rf_cal_state[i].rfmax); |
590 | 611 | ||
591 | priv->tm_rfcal = tda18271_read_thermometer(fe); | 612 | priv->tm_rfcal = tda18271_read_thermometer(fe); |
592 | 613 | fail: | |
593 | return 0; | 614 | return ret; |
594 | } | 615 | } |
595 | 616 | ||
596 | /* ------------------------------------------------------------------ */ | 617 | /* ------------------------------------------------------------------ */ |
@@ -599,6 +620,7 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
599 | { | 620 | { |
600 | struct tda18271_priv *priv = fe->tuner_priv; | 621 | struct tda18271_priv *priv = fe->tuner_priv; |
601 | unsigned char *regs = priv->tda18271_regs; | 622 | unsigned char *regs = priv->tda18271_regs; |
623 | int ret; | ||
602 | 624 | ||
603 | /* test RF_CAL_OK to see if we need init */ | 625 | /* test RF_CAL_OK to see if we need init */ |
604 | if ((regs[R_EP1] & 0x10) == 0) | 626 | if ((regs[R_EP1] & 0x10) == 0) |
@@ -607,15 +629,19 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
607 | if (priv->cal_initialized) | 629 | if (priv->cal_initialized) |
608 | return 0; | 630 | return 0; |
609 | 631 | ||
610 | tda18271_calc_rf_filter_curve(fe); | 632 | ret = tda18271_calc_rf_filter_curve(fe); |
633 | if (ret < 0) | ||
634 | goto fail; | ||
611 | 635 | ||
612 | tda18271_por(fe); | 636 | ret = tda18271_por(fe); |
637 | if (ret < 0) | ||
638 | goto fail; | ||
613 | 639 | ||
614 | tda_info("tda18271: RF tracking filter calibration complete\n"); | 640 | tda_info("tda18271: RF tracking filter calibration complete\n"); |
615 | 641 | ||
616 | priv->cal_initialized = true; | 642 | priv->cal_initialized = true; |
617 | 643 | fail: | |
618 | return 0; | 644 | return ret; |
619 | } | 645 | } |
620 | 646 | ||
621 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | 647 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, |