Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] r820t: add support for R828D

Small changes in order to support tuner version R828D @ 16 MHz clock.
There was 'vco_fine_tune' check, which seems to adjust synthesizer
output divider (mixer dix / LO div / Rout) by one. R828D seems to
return vco_fine_tune=1 every time and that condition causes tuning
fail as output divider was increased by one.
Resolve problem by skipping whole condition in case of R828D tuner.
Just to mention, other tuner, R820T, seems to return 2 here.
Synthesizer maximum frequency check was hard coded to check synthesizer N
and thus worked correctly only for clock frequencies around 30 MHz.
As whole test is quite useless in any case, I removed it totally.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Antti Palosaari and committed by
Mauro Carvalho Chehab
7315b933 4f7c09b9

+13 -9
+13 -9
drivers/media/tuners/r820t.c
··· 612 612 613 613 vco_fine_tune = (data[4] & 0x30) >> 4; 614 614 615 - if (vco_fine_tune > VCO_POWER_REF) 616 - div_num = div_num - 1; 617 - else if (vco_fine_tune < VCO_POWER_REF) 618 - div_num = div_num + 1; 615 + tuner_dbg("mix_div=%d div_num=%d vco_fine_tune=%d\n", 616 + mix_div, div_num, vco_fine_tune); 617 + 618 + /* 619 + * XXX: R828D/16MHz seems to have always vco_fine_tune=1. 620 + * Due to that, this calculation goes wrong. 621 + */ 622 + if (priv->cfg->rafael_chip != CHIP_R828D) { 623 + if (vco_fine_tune > VCO_POWER_REF) 624 + div_num = div_num - 1; 625 + else if (vco_fine_tune < VCO_POWER_REF) 626 + div_num = div_num + 1; 627 + } 619 628 620 629 rc = r820t_write_reg_mask(priv, 0x10, div_num << 5, 0xe0); 621 630 if (rc < 0) ··· 644 635 vco_fra = pll_ref * 127 / 128; 645 636 } else if ((vco_fra > pll_ref) && (vco_fra < pll_ref * 129 / 128)) { 646 637 vco_fra = pll_ref * 129 / 128; 647 - } 648 - 649 - if (nint > 63) { 650 - tuner_info("No valid PLL values for %u kHz!\n", freq); 651 - return -EINVAL; 652 638 } 653 639 654 640 ni = (nint - 13) / 4;