summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-12-25 16:54:22 -0500
committerMichael Krufky <mkrufky@linuxtv.org>2007-12-25 16:54:22 -0500
commitdab2345f72cba8d4e8db808997bf823d1f838805 (patch)
tree3715c18a332dd806ecc4e2b0d68486619aaae158 /linux/drivers/media/dvb/frontends
parentc0f219350f794bb2f178b966429696c2ffd46508 (diff)
downloadmediapointer-dvb-s2-dab2345f72cba8d4e8db808997bf823d1f838805.tar.gz
mediapointer-dvb-s2-dab2345f72cba8d4e8db808997bf823d1f838805.tar.bz2
tda18271: break calculation functions out of tda18271_tune
From: Michael Krufky <mkrufky@linuxtv.org> Break out the following new functions from tda18271_tune: tda18271_calc_bp_filter tda18271_calc_km tda18271_calc_rf_band tda18271_calc_gain_taper tda18271_calc_ir_measure tda18271_calc_rf_cal Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/dvb/frontends')
-rw-r--r--linux/drivers/media/dvb/frontends/tda18271-fe.c143
1 files changed, 114 insertions, 29 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda18271-fe.c b/linux/drivers/media/dvb/frontends/tda18271-fe.c
index a13b2ecec..2541b215d 100644
--- a/linux/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/linux/drivers/media/dvb/frontends/tda18271-fe.c
@@ -407,13 +407,118 @@ fail:
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);
#if 0
@@ -427,10 +532,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;
@@ -479,23 +581,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);
@@ -519,14 +612,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 */
@@ -563,11 +651,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;