Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck...
[linux-drm-fsl-dcu.git] / drivers / media / tuners / r820t.c
index 1c23666468cf69223542b5f89f024a1201c4733d..d9ee43fae62dee4f7f5cf474d4f74ed21e4c5a01 100644 (file)
@@ -612,10 +612,19 @@ static int r820t_set_pll(struct r820t_priv *priv, enum v4l2_tuner_type type,
 
        vco_fine_tune = (data[4] & 0x30) >> 4;
 
-       if (vco_fine_tune > VCO_POWER_REF)
-               div_num = div_num - 1;
-       else if (vco_fine_tune < VCO_POWER_REF)
-               div_num = div_num + 1;
+       tuner_dbg("mix_div=%d div_num=%d vco_fine_tune=%d\n",
+                       mix_div, div_num, vco_fine_tune);
+
+       /*
+        * XXX: R828D/16MHz seems to have always vco_fine_tune=1.
+        * Due to that, this calculation goes wrong.
+        */
+       if (priv->cfg->rafael_chip != CHIP_R828D) {
+               if (vco_fine_tune > VCO_POWER_REF)
+                       div_num = div_num - 1;
+               else if (vco_fine_tune < VCO_POWER_REF)
+                       div_num = div_num + 1;
+       }
 
        rc = r820t_write_reg_mask(priv, 0x10, div_num << 5, 0xe0);
        if (rc < 0)
@@ -637,11 +646,6 @@ static int r820t_set_pll(struct r820t_priv *priv, enum v4l2_tuner_type type,
                vco_fra = pll_ref * 129 / 128;
        }
 
-       if (nint > 63) {
-               tuner_info("No valid PLL values for %u kHz!\n", freq);
-               return -EINVAL;
-       }
-
        ni = (nint - 13) / 4;
        si = nint - 4 * ni - 13;