]> err.no Git - linux-2.6/blobdiff - drivers/media/dvb/frontends/mt352.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[linux-2.6] / drivers / media / dvb / frontends / mt352.c
index 5de7376c94ce13e9501b1cda912c17a09be738e6..7cd190b6f01573919e7939948b8f922e8f5622b2 100644 (file)
@@ -32,7 +32,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/string.h>
@@ -70,7 +69,7 @@ static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
        return 0;
 }
 
-int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
+static int _mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
 {
        int err,i;
        for (i=0; i < ilen-1; i++)
@@ -107,7 +106,7 @@ static int mt352_sleep(struct dvb_frontend* fe)
 {
        static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
 
-       mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
+       _mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
        return 0;
 }
 
@@ -153,7 +152,13 @@ static void mt352_calc_input_freq(struct mt352_state* state,
        if (state->config.if2)
                if2 = state->config.if2;
 
-       ife = (2*adc_clock - if2);
+       if (adc_clock >= if2 * 2)
+               ife = if2;
+       else {
+               ife = adc_clock - (if2 % adc_clock);
+               if (ife > adc_clock / 2)
+                       ife = adc_clock - ife;
+       }
        value = -16374 * ife / adc_clock;
        dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n",
                __FUNCTION__, if2, ife, adc_clock, value, value & 0x3fff);
@@ -293,14 +298,14 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
                                fe->ops.i2c_gate_ctrl(fe, 0);
                }
 
-               mt352_write(fe, buf, 8);
-               mt352_write(fe, fsm_go, 2);
+               _mt352_write(fe, buf, 8);
+               _mt352_write(fe, fsm_go, 2);
        } else {
                if (fe->ops.tuner_ops.calc_regs) {
                        fe->ops.tuner_ops.calc_regs(fe, param, buf+8, 5);
                        buf[8] <<= 1;
-                       mt352_write(fe, buf, sizeof(buf));
-                       mt352_write(fe, tuner_go, 2);
+                       _mt352_write(fe, buf, sizeof(buf));
+                       _mt352_write(fe, tuner_go, 2);
                }
        }
 
@@ -522,7 +527,7 @@ static int mt352_init(struct dvb_frontend* fe)
            (mt352_read_register(state, CONFIG) & 0x20) == 0) {
 
                /* Do a "hard" reset */
-               mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
+               _mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
                return state->config.demod_init(fe);
        }
 
@@ -585,6 +590,7 @@ static struct dvb_frontend_ops mt352_ops = {
 
        .init = mt352_init,
        .sleep = mt352_sleep,
+       .write = _mt352_write,
 
        .set_frontend = mt352_set_parameters,
        .get_frontend = mt352_get_parameters,
@@ -605,4 +611,3 @@ MODULE_AUTHOR("Holger Waechtler, Daniel Mack, Antonio Mancuso");
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(mt352_attach);
-EXPORT_SYMBOL(mt352_write);