[media] fc2580: calculate filter control word dynamically
authorAntti Palosaari <crope@iki.fi>
Sun, 3 May 2015 18:16:52 +0000 (15:16 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 18 May 2015 18:56:46 +0000 (15:56 -0300)
Calculate low-pass filter control word dynamically from given radio
channel bandwidth.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/tuners/fc2580.c
drivers/media/tuners/fc2580_priv.h

index 08838b4b48214ea464eb8ad2038853a0d028e658..30cee76b5f370237f0619c38f3ce9b969a892569 100644 (file)
@@ -46,7 +46,7 @@ static int fc2580_set_params(struct dvb_frontend *fe)
        int ret, i;
        unsigned int uitmp, div_ref, div_ref_val, div_n, k, k_cw, div_out;
        u64 f_vco;
-       u8 u8tmp, synth_config;
+       u8 synth_config;
        unsigned long timeout;
 
        dev_dbg(&client->dev,
@@ -249,9 +249,9 @@ static int fc2580_set_params(struct dvb_frontend *fe)
        if (ret)
                goto err;
 
-       u8tmp = div_u64((u64) dev->clk * fc2580_if_filter_lut[i].mul,
-                       1000000000);
-       ret = regmap_write(dev->regmap, 0x37, u8tmp);
+       uitmp = (unsigned int) 8058000 - (c->bandwidth_hz * 122 / 100 / 2);
+       uitmp = div64_u64((u64) dev->clk * uitmp, 1000000000000ULL);
+       ret = regmap_write(dev->regmap, 0x37, uitmp);
        if (ret)
                goto err;
 
index 60f8f6caca11b44f2879903816a22fcecdbf5c6b..bd88b0141141a23b206522e99d440fc14ec7c383 100644 (file)
@@ -64,16 +64,15 @@ static const struct fc2580_pll fc2580_pll_lut[] = {
 
 struct fc2580_if_filter {
        u32 freq;
-       u16 mul;
        u8 r36_val;
        u8 r39_val;
 };
 
 static const struct fc2580_if_filter fc2580_if_filter_lut[] = {
-       {   6000000, 4400, 0x18, 0x00},
-       {   7000000, 3910, 0x18, 0x80},
-       {   8000000, 3300, 0x18, 0x80},
-       {0xffffffff, 3300, 0x18, 0x80},
+       {   6000000, 0x18, 0x00},
+       {   7000000, 0x18, 0x80},
+       {   8000000, 0x18, 0x80},
+       {0xffffffff, 0x18, 0x80},
 };
 
 struct fc2580_freq_regs {