diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-12-28 00:00:48 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-12-28 00:00:48 -0200 |
commit | 7b521bbdf47733d7fdb67604a036eb9d968169ae (patch) | |
tree | d84f3604a8b9a27e42311c68976e061e532ecd44 /linux/drivers/media/dvb | |
parent | 7b270ae611f8cbe3f4eb2f3987860ed1df23dd77 (diff) | |
parent | dab2345f72cba8d4e8db808997bf823d1f838805 (diff) | |
download | mediapointer-dvb-s2-7b521bbdf47733d7fdb67604a036eb9d968169ae.tar.gz mediapointer-dvb-s2-7b521bbdf47733d7fdb67604a036eb9d968169ae.tar.bz2 |
merge: http://linuxtv.org/hg/~mkrufky/tda18271
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-fe.c | 235 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-priv.h | 68 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/tda18271-tables.c | 136 |
3 files changed, 280 insertions, 159 deletions
diff --git a/linux/drivers/media/dvb/frontends/tda18271-fe.c b/linux/drivers/media/dvb/frontends/tda18271-fe.c index e1a187e14..2541b215d 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-fe.c +++ b/linux/drivers/media/dvb/frontends/tda18271-fe.c @@ -21,8 +21,6 @@ #include <linux/delay.h> #include "compat.h" #include <linux/videodev2.h> - -#include "tda18271.h" #include "tda18271-priv.h" int tda18271_debug; @@ -31,23 +29,6 @@ MODULE_PARM_DESC(debug, "set debug level (info=1, map=2, reg=4 (or-able))"); /*---------------------------------------------------------------------*/ -enum tda18271_mode { - TDA18271_ANALOG, - TDA18271_DIGITAL, -}; - -struct tda18271_priv { - u8 i2c_addr; - struct i2c_adapter *i2c_adap; - unsigned char tda18271_regs[TDA18271_NUM_REGS]; - - enum tda18271_mode mode; - enum tda18271_i2c_gate gate; - - u32 frequency; - u32 bandwidth; -}; - static int tda18271_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) { struct tda18271_priv *priv = fe->tuner_priv; @@ -96,23 +77,23 @@ static void tda18271_dump_regs(struct dvb_frontend *fe) struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; - dbg_reg("=== TDA18271 REG DUMP ===\n"); - dbg_reg("ID_BYTE = 0x%02x\n", 0xff & regs[R_ID]); - dbg_reg("THERMO_BYTE = 0x%02x\n", 0xff & regs[R_TM]); - dbg_reg("POWER_LEVEL_BYTE = 0x%02x\n", 0xff & regs[R_PL]); - dbg_reg("EASY_PROG_BYTE_1 = 0x%02x\n", 0xff & regs[R_EP1]); - dbg_reg("EASY_PROG_BYTE_2 = 0x%02x\n", 0xff & regs[R_EP2]); - dbg_reg("EASY_PROG_BYTE_3 = 0x%02x\n", 0xff & regs[R_EP3]); - dbg_reg("EASY_PROG_BYTE_4 = 0x%02x\n", 0xff & regs[R_EP4]); - dbg_reg("EASY_PROG_BYTE_5 = 0x%02x\n", 0xff & regs[R_EP5]); - dbg_reg("CAL_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[R_CPD]); - dbg_reg("CAL_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[R_CD1]); - dbg_reg("CAL_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[R_CD2]); - dbg_reg("CAL_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[R_CD3]); - dbg_reg("MAIN_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[R_MPD]); - dbg_reg("MAIN_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[R_MD1]); - dbg_reg("MAIN_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[R_MD2]); - dbg_reg("MAIN_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[R_MD3]); + tda_reg("=== TDA18271 REG DUMP ===\n"); + tda_reg("ID_BYTE = 0x%02x\n", 0xff & regs[R_ID]); + tda_reg("THERMO_BYTE = 0x%02x\n", 0xff & regs[R_TM]); + tda_reg("POWER_LEVEL_BYTE = 0x%02x\n", 0xff & regs[R_PL]); + tda_reg("EASY_PROG_BYTE_1 = 0x%02x\n", 0xff & regs[R_EP1]); + tda_reg("EASY_PROG_BYTE_2 = 0x%02x\n", 0xff & regs[R_EP2]); + tda_reg("EASY_PROG_BYTE_3 = 0x%02x\n", 0xff & regs[R_EP3]); + tda_reg("EASY_PROG_BYTE_4 = 0x%02x\n", 0xff & regs[R_EP4]); + tda_reg("EASY_PROG_BYTE_5 = 0x%02x\n", 0xff & regs[R_EP5]); + tda_reg("CAL_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[R_CPD]); + tda_reg("CAL_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[R_CD1]); + tda_reg("CAL_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[R_CD2]); + tda_reg("CAL_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[R_CD3]); + tda_reg("MAIN_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[R_MPD]); + tda_reg("MAIN_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[R_MD1]); + tda_reg("MAIN_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[R_MD2]); + tda_reg("MAIN_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[R_MD3]); } static void tda18271_read_regs(struct dvb_frontend *fe) @@ -136,8 +117,7 @@ static void tda18271_read_regs(struct dvb_frontend *fe) tda18271_i2c_gate_ctrl(fe, 0); if (ret != 2) - printk("ERROR: %s: i2c_transfer returned: %d\n", - __FUNCTION__, ret); + tda_err("ERROR: i2c_transfer returned: %d\n", ret); if (tda18271_debug & DBG_REG) tda18271_dump_regs(fe); @@ -167,8 +147,7 @@ static void tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) tda18271_i2c_gate_ctrl(fe, 0); if (ret != 1) - printk(KERN_WARNING "ERROR: %s: i2c_transfer returned: %d\n", - __FUNCTION__, ret); + tda_err("ERROR: i2c_transfer returned: %d\n", ret); } /*---------------------------------------------------------------------*/ @@ -178,7 +157,8 @@ static int tda18271_init_regs(struct dvb_frontend *fe) struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; - printk(KERN_INFO "tda18271: initializing registers\n"); + tda_dbg("initializing registers for device @ %d-%04x\n", + i2c_adapter_id(priv->i2c_adap), priv->i2c_addr); /* initialize registers */ regs[R_ID] = 0x83; @@ -380,7 +360,9 @@ static int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq) u8 d, pd; u32 div; - tda18271_lookup_main_pll(&freq, &pd, &d); + int ret = tda18271_lookup_pll_map(MAIN_PLL, &freq, &pd, &d); + if (ret < 0) + goto fail; regs[R_MPD] = (0x77 & pd); @@ -398,8 +380,8 @@ static int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq) regs[R_MD1] = 0x7f & (div >> 16); regs[R_MD2] = 0xff & (div >> 8); regs[R_MD3] = 0xff & div; - - return 0; +fail: + return ret; } static int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq) @@ -410,7 +392,9 @@ static int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq) u8 d, pd; u32 div; - tda18271_lookup_cal_pll(&freq, &pd, &d); + int ret = tda18271_lookup_pll_map(CAL_PLL, &freq, &pd, &d); + if (ret < 0) + goto fail; regs[R_CPD] = pd; @@ -419,8 +403,114 @@ static int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq) regs[R_CD1] = 0x7f & (div >> 16); regs[R_CD2] = 0xff & (div >> 8); regs[R_CD3] = 0xff & div; +fail: + return ret; +} - return 0; +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, @@ -429,7 +519,6 @@ static int tda18271_tune(struct dvb_frontend *fe, struct tda18271_priv *priv = fe->tuner_priv; unsigned char *regs = priv->tda18271_regs; u32 N = 0; - u8 val; tda18271_init(fe); #if 0 @@ -438,15 +527,12 @@ static int tda18271_tune(struct dvb_frontend *fe, freq = freq / 1000; #endif - dbg_info("freq = %d, ifc = %d\n", freq, ifc); + tda_dbg("freq = %d, ifc = %d\n", freq, ifc); /* RF tracking filter calibration */ /* calculate BP_Filter */ - tda18271_lookup_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; @@ -495,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_km(&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_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_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); @@ -535,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_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 */ @@ -579,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_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; @@ -623,8 +692,7 @@ static int tda18271_set_params(struct dvb_frontend *fe, sgIF = 4000000; break; default: - printk(KERN_WARNING "%s: modulation not set!\n", - __FUNCTION__); + tda_warn("modulation not set!\n"); return -EINVAL; } #if 0 /* keep */ @@ -650,13 +718,11 @@ static int tda18271_set_params(struct dvb_frontend *fe, sgIF = 4300000; break; default: - printk(KERN_WARNING "%s: bandwidth not set!\n", - __FUNCTION__); + tda_warn("bandwidth not set!\n"); return -EINVAL; } } else { - printk(KERN_WARNING "%s: modulation type not supported!\n", - __FUNCTION__); + tda_warn("modulation type not supported!\n"); return -EINVAL; } @@ -711,7 +777,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, if (params->mode == V4L2_TUNER_RADIO) sgIF = 88; /* if frequency is 5.5 MHz */ - dbg_info("setting tda18271 to system %s\n", mode); + tda_dbg("setting tda18271 to system %s\n", mode); return tda18271_tune(fe, sgIF * 62500, params->frequency * 62500, 0, std); @@ -761,7 +827,7 @@ static int tda18271_get_id(struct dvb_frontend *fe) break; } - dbg_info("%s detected @ %d-%04x%s\n", name, + tda_info("%s detected @ %d-%04x%s\n", name, i2c_adapter_id(priv->i2c_adap), priv->i2c_addr, (0 == ret) ? "" : ", device not supported."); @@ -789,7 +855,6 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, { struct tda18271_priv *priv = NULL; - dbg_info("@ %d-%04x\n", i2c_adapter_id(i2c), addr); priv = kzalloc(sizeof(struct tda18271_priv), GFP_KERNEL); if (priv == NULL) return NULL; diff --git a/linux/drivers/media/dvb/frontends/tda18271-priv.h b/linux/drivers/media/dvb/frontends/tda18271-priv.h index e1fa9a467..912b81e0c 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-priv.h +++ b/linux/drivers/media/dvb/frontends/tda18271-priv.h @@ -23,6 +23,7 @@ #include <linux/kernel.h> #include <linux/types.h> +#include "tda18271.h" #define R_ID 0x00 /* ID byte */ #define R_TM 0x01 /* Thermo byte */ @@ -66,31 +67,66 @@ #define TDA18271_NUM_REGS 39 -extern int tda18271_debug; +/*---------------------------------------------------------------------*/ + +enum tda18271_mode { + TDA18271_ANALOG, + TDA18271_DIGITAL, +}; + +struct tda18271_priv { + u8 i2c_addr; + struct i2c_adapter *i2c_adap; + unsigned char tda18271_regs[TDA18271_NUM_REGS]; + + enum tda18271_mode mode; + enum tda18271_i2c_gate gate; + + u32 frequency; + u32 bandwidth; +}; -#define dprintk(level, fmt, arg...) do {\ - if (tda18271_debug & level) \ - printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ##arg); } while (0) +/*---------------------------------------------------------------------*/ + +extern int tda18271_debug; #define DBG_INFO 1 #define DBG_MAP 2 #define DBG_REG 4 -#define dbg_info(fmt, arg...) dprintk(DBG_INFO, fmt, ##arg) -#define dbg_map(fmt, arg...) dprintk(DBG_MAP, fmt, ##arg) -#define dbg_reg(fmt, arg...) dprintk(DBG_REG, fmt, ##arg) +#define tda_printk(kern, fmt, arg...) \ + printk(kern "%s: " fmt, __FUNCTION__, ##arg) -/*---------------------------------------------------------------------*/ +#define dprintk(kern, lvl, fmt, arg...) do {\ + if (tda18271_debug & lvl) \ + tda_printk(kern, fmt, ##arg); } while (0) + +#define tda_info(fmt, arg...) printk(KERN_INFO fmt, ##arg) +#define tda_warn(fmt, arg...) tda_printk(KERN_WARNING, fmt, ##arg) +#define tda_err(fmt, arg...) tda_printk(KERN_ERR, fmt, ##arg) +#define tda_dbg(fmt, arg...) dprintk(KERN_DEBUG, DBG_INFO, fmt, ##arg) +#define tda_map(fmt, arg...) dprintk(KERN_DEBUG, DBG_MAP, fmt, ##arg) +#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) -extern void tda18271_lookup_cal_pll(u32 *freq, u8 *post_div, u8 *div); -extern void tda18271_lookup_main_pll(u32 *freq, u8 *post_div, u8 *div); +/*---------------------------------------------------------------------*/ -extern void tda18271_lookup_bp_filter(u32 *freq, u8 *val); -extern void tda18271_lookup_km(u32 *freq, u8 *val); -extern void tda18271_lookup_rf_band(u32 *freq, u8 *val); -extern void tda18271_lookup_gain_taper(u32 *freq, u8 *val); -extern void tda18271_lookup_rf_cal(u32 *freq, u8 *val); -extern void tda18271_lookup_ir_measure(u32 *freq, u8 *val); +enum tda18271_map_type { + /* tda18271_pll_map */ + MAIN_PLL, + CAL_PLL, + /* tda18271_map */ + RF_CAL, + RF_CAL_KMCO, + BP_FILTER, + RF_BAND, + GAIN_TAPER, + IR_MEASURE, +}; + +extern int tda18271_lookup_pll_map(enum tda18271_map_type map_type, + u32 *freq, u8 *post_div, u8 *div); +extern int tda18271_lookup_map(enum tda18271_map_type map_type, + u32 *freq, u8 *val); #endif /* __TDA18271_PRIV_H__ */ diff --git a/linux/drivers/media/dvb/frontends/tda18271-tables.c b/linux/drivers/media/dvb/frontends/tda18271-tables.c index cce0e0d82..e10a93bf1 100644 --- a/linux/drivers/media/dvb/frontends/tda18271-tables.c +++ b/linux/drivers/media/dvb/frontends/tda18271-tables.c @@ -258,31 +258,42 @@ static struct tda18271_map tda18271_rf_cal[] = { }; static struct tda18271_map tda18271_ir_measure[] = { - { .rfmax = 30000, .val = 4}, - { .rfmax = 200000, .val = 5}, - { .rfmax = 600000, .val = 6}, - { .rfmax = 865000, .val = 7}, - { .rfmax = 0, .val = 0}, /* end */ + { .rfmax = 30000, .val = 4 }, + { .rfmax = 200000, .val = 5 }, + { .rfmax = 600000, .val = 6 }, + { .rfmax = 865000, .val = 7 }, + { .rfmax = 0, .val = 0 }, /* end */ }; /*---------------------------------------------------------------------*/ -static void tda18271_lookup_map(struct tda18271_map *map, - u32 *freq, u8 *val) +int tda18271_lookup_pll_map(enum tda18271_map_type map_type, + u32 *freq, u8 *post_div, u8 *div) { - int i = 0; - while ((map[i].rfmax * 1000) < *freq) { - if (map[i + 1].rfmax == 0) - break; - i++; + struct tda18271_pll_map *map = NULL; + unsigned int i = 0; + char *map_name; + + switch (map_type) { + case MAIN_PLL: + map = tda18271_main_pll; + map_name = "main_pll"; + break; + case CAL_PLL: + map = tda18271_cal_pll; + map_name = "cal_pll"; + break; + default: + /* we should never get here */ + map_name = "undefined"; + break; + } + + if (!map) { + tda_warn("%s map is not set!\n", map_name); + return -EINVAL; } - *val = map[i].val; -} -static void tda18271_lookup_pll_map(struct tda18271_pll_map *map, - u32 *freq, u8 *post_div, u8 *div) -{ - int i = 0; while ((map[i].lomax * 1000) < *freq) { if (map[i + 1].lomax == 0) break; @@ -290,56 +301,65 @@ static void tda18271_lookup_pll_map(struct tda18271_pll_map *map, } *post_div = map[i].pd; *div = map[i].d; -} - -/*---------------------------------------------------------------------*/ -void tda18271_lookup_cal_pll(u32 *freq, u8 *post_div, u8 *div) -{ - tda18271_lookup_pll_map(tda18271_cal_pll, freq, post_div, div); - dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div); -} + tda_map("%s: post div = 0x%02x, div = 0x%02x\n", + map_name, *post_div, *div); -void tda18271_lookup_main_pll(u32 *freq, u8 *post_div, u8 *div) -{ - tda18271_lookup_pll_map(tda18271_main_pll, freq, post_div, div); - dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div); + return 0; } -void tda18271_lookup_bp_filter(u32 *freq, u8 *val) +int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) { - tda18271_lookup_map(tda18271_bp_filter, freq, val); - dbg_map("0x%02x\n", *val); -} + struct tda18271_map *map = NULL; + unsigned int i = 0; + char *map_name; -void tda18271_lookup_km(u32 *freq, u8 *val) -{ - tda18271_lookup_map(tda18271_km, freq, val); - dbg_map("0x%02x\n", *val); -} + switch (map_type) { + case BP_FILTER: + map = tda18271_bp_filter; + map_name = "bp_filter"; + break; + case RF_CAL_KMCO: + map = tda18271_km; + map_name = "km"; + break; + case RF_BAND: + map = tda18271_rf_band; + map_name = "rf_band"; + break; + case GAIN_TAPER: + map = tda18271_gain_taper; + map_name = "gain_taper"; + break; + case RF_CAL: + map = tda18271_rf_cal; + map_name = "rf_cal"; + break; + case IR_MEASURE: + map = tda18271_ir_measure; + map_name = "ir_measure"; + break; + default: + /* we should never get here */ + map_name = "undefined"; + break; + } -void tda18271_lookup_rf_band(u32 *freq, u8 *val) -{ - tda18271_lookup_map(tda18271_rf_band, freq, val); - dbg_map("0x%02x\n", *val); -} + if (!map) { + tda_warn("%s map is not set!\n", map_name); + return -EINVAL; + } -void tda18271_lookup_gain_taper(u32 *freq, u8 *val) -{ - tda18271_lookup_map(tda18271_gain_taper, freq, val); - dbg_map("0x%02x\n", *val); -} + while ((map[i].rfmax * 1000) < *freq) { + if (map[i + 1].rfmax == 0) + break; + i++; + } + *val = map[i].val; -void tda18271_lookup_rf_cal(u32 *freq, u8 *val) -{ - tda18271_lookup_map(tda18271_rf_cal, freq, val); - dbg_map("0x%02x\n", *val); -} + tda_map("%s: 0x%02x\n", map_name, *val); -void tda18271_lookup_ir_measure(u32 *freq, u8 *val) -{ - tda18271_lookup_map(tda18271_ir_measure, freq, val); - dbg_map("0x%02x\n", *val); + return 0; } /* |