#include <linux/module.h>
#include <linux/delay.h>
#include <linux/dvb/frontend.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <media/dvb_frontend.h>
#include "mt2060.h"
#include "mt2060_priv.h"
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
#define dprintk(args...) …
static int mt2060_readreg(struct mt2060_priv *priv, u8 reg, u8 *val)
{ … }
static int mt2060_writereg(struct mt2060_priv *priv, u8 reg, u8 val)
{ … }
static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len)
{ … }
static u8 mt2060_config1[] = …;
static u8 mt2060_config2[] = …;
#ifdef MT2060_SPURCHECK
static int mt2060_spurcalc(u32 lo1,u32 lo2,u32 if2)
{
int I,J;
int dia,diamin,diff;
diamin=1000000;
for (I = 1; I < 10; I++) {
J = ((2*I*lo1)/lo2+1)/2;
diff = I*(int)lo1-J*(int)lo2;
if (diff < 0) diff=-diff;
dia = (diff-(int)if2);
if (dia < 0) dia=-dia;
if (diamin > dia) diamin=dia;
}
return diamin;
}
#define BANDWIDTH …
static int mt2060_spurcheck(u32 lo1,u32 lo2,u32 if2)
{
u32 Spur,Sp1,Sp2;
int I,J;
I=0;
J=1000;
Spur=mt2060_spurcalc(lo1,lo2,if2);
if (Spur < BANDWIDTH) {
dprintk("Spurs before : f_lo1: %d f_lo2: %d (kHz)",
(int)lo1,(int)lo2);
I=1000;
Sp1 = mt2060_spurcalc(lo1+I,lo2+I,if2);
Sp2 = mt2060_spurcalc(lo1-I,lo2-I,if2);
if (Sp1 < Sp2) {
J=-J; I=-I; Spur=Sp2;
} else
Spur=Sp1;
while (Spur < BANDWIDTH) {
I += J;
Spur = mt2060_spurcalc(lo1+I,lo2+I,if2);
}
dprintk("Spurs after : f_lo1: %d f_lo2: %d (kHz)",
(int)(lo1+I),(int)(lo2+I));
}
return I;
}
#endif
#define IF2 …
#define FREF …
static int mt2060_set_params(struct dvb_frontend *fe)
{ … }
static void mt2060_calibrate(struct mt2060_priv *priv)
{ … }
static int mt2060_get_frequency(struct dvb_frontend *fe, u32 *frequency)
{ … }
static int mt2060_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
{ … }
static int mt2060_init(struct dvb_frontend *fe)
{ … }
static int mt2060_sleep(struct dvb_frontend *fe)
{ … }
static void mt2060_release(struct dvb_frontend *fe)
{ … }
static const struct dvb_tuner_ops mt2060_tuner_ops = …;
struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
{ … }
EXPORT_SYMBOL_GPL(…);
static int mt2060_probe(struct i2c_client *client)
{ … }
static void mt2060_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id mt2060_id_table[] = …;
MODULE_DEVICE_TABLE(i2c, mt2060_id_table);
static struct i2c_driver mt2060_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;