Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76673
b: refs/heads/master
c: b92bf0f
h: refs/heads/master
i:
  76671: fa98c8f
v: v3
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Jan 25, 2008
1 parent bab51b1 commit 9734846
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 182519f4c99f73f376323580dda494d986b4760b
refs/heads/master: b92bf0f6a94b73a1b8bd0023b1fa642d13b01a76
143 changes: 114 additions & 29 deletions trunk/drivers/media/dvb/frontends/tda18271-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,118 @@ static int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq)
return ret;
}

static int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq)
{
/* Sets BP filter bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(BP_FILTER, freq, &val);
if (ret < 0)
goto fail;

regs[R_EP1] &= ~0x07; /* clear bp filter bits */
regs[R_EP1] |= (0x07 & val);
fail:
return ret;
}

static int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq)
{
/* Sets K & M bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(RF_CAL_KMCO, freq, &val);
if (ret < 0)
goto fail;

regs[R_EB13] &= ~0x7c; /* clear k & m bits */
regs[R_EB13] |= (0x7c & val);
fail:
return ret;
}

static int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq)
{
/* Sets RF Band bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(RF_BAND, freq, &val);
if (ret < 0)
goto fail;

regs[R_EP2] &= ~0xe0; /* clear rf band bits */
regs[R_EP2] |= (0xe0 & (val << 5));
fail:
return ret;
}

static int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq)
{
/* Sets Gain Taper bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(GAIN_TAPER, freq, &val);
if (ret < 0)
goto fail;

regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
regs[R_EP2] |= (0x1f & val);
fail:
return ret;
}

static int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq)
{
/* Sets IR Meas bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(IR_MEASURE, freq, &val);
if (ret < 0)
goto fail;

regs[R_EP5] &= ~0x07;
regs[R_EP5] |= (0x07 & val);
fail:
return ret;
}

static int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq)
{
/* Sets RF Cal bits, but does not write them */
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u8 val;

int ret = tda18271_lookup_map(RF_CAL, freq, &val);
if (ret < 0)
goto fail;

/* VHF_Low band only */
if (0 == val) {
ret = -ERANGE;
goto fail;
}
regs[R_EB14] = val;
fail:
return ret;
}

static int tda18271_tune(struct dvb_frontend *fe,
u32 ifc, u32 freq, u32 bw, u8 std)
{
struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs;
u32 N = 0;
u8 val;

tda18271_init(fe);

Expand All @@ -421,10 +526,7 @@ static int tda18271_tune(struct dvb_frontend *fe,
/* RF tracking filter calibration */

/* calculate BP_Filter */
tda18271_lookup_map(BP_FILTER, &freq, &val);

regs[R_EP1] &= ~0x07; /* clear bp filter bits */
regs[R_EP1] |= val;
tda18271_calc_bp_filter(fe, &freq);
tda18271_write_regs(fe, R_EP1, 1);

regs[R_EB4] &= 0x07;
Expand Down Expand Up @@ -473,23 +575,14 @@ static int tda18271_tune(struct dvb_frontend *fe,
msleep(5); /* RF tracking filter calibration initialization */

/* search for K,M,CO for RF Calibration */
tda18271_lookup_map(RF_CAL_KMCO, &freq, &val);

regs[R_EB13] &= 0x83;
regs[R_EB13] |= val;
tda18271_calc_km(fe, &freq);
tda18271_write_regs(fe, R_EB13, 1);

/* search for RF_BAND */
tda18271_lookup_map(RF_BAND, &freq, &val);

regs[R_EP2] &= ~0xe0; /* clear rf band bits */
regs[R_EP2] |= (val << 5);
tda18271_calc_rf_band(fe, &freq);

/* search for Gain_Taper */
tda18271_lookup_map(GAIN_TAPER, &freq, &val);

regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
regs[R_EP2] |= val;
tda18271_calc_gain_taper(fe, &freq);

tda18271_write_regs(fe, R_EP2, 1);
tda18271_write_regs(fe, R_EP1, 1);
Expand All @@ -513,14 +606,9 @@ static int tda18271_tune(struct dvb_frontend *fe,

tda18271_write_regs(fe, R_EP1, 1);

/* RF tracking filer correction for VHF_Low band */
tda18271_lookup_map(RF_CAL, &freq, &val);

/* VHF_Low band only */
if (val != 0) {
regs[R_EB14] = val;
/* RF tracking filter correction for VHF_Low band */
if (0 == tda18271_calc_rf_cal(fe, &freq))
tda18271_write_regs(fe, R_EB14, 1);
}

/* Channel Configuration */

Expand Down Expand Up @@ -557,11 +645,8 @@ static int tda18271_tune(struct dvb_frontend *fe,

regs[R_EP4] &= ~0x80; /* turn this bit on only for fm */

/* image rejection validity EP5[2:0] */
tda18271_lookup_map(IR_MEASURE, &freq, &val);

regs[R_EP5] &= ~0x07;
regs[R_EP5] |= val;
/* image rejection validity */
tda18271_calc_ir_measure(fe, &freq);

/* calculate MAIN PLL */
N = freq + ifc;
Expand Down

0 comments on commit 9734846

Please sign in to comment.