aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/dvb/frontends/tda18271-tables.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-12-25 00:39:37 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 19:04:25 -0200
commit2f27dfc98cc0a183be9e3c2fc0da0450b85e5fde (patch)
treee47034d3d6b0c09c34de248e18a01a880d485abc /drivers/media/dvb/frontends/tda18271-tables.c
parentd37142102a2adaa3391a384ea6a780afb5804789 (diff)
V4L/DVB (6926): tda18271: consolidate table lookup functions
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-tables.c')
-rw-r--r--drivers/media/dvb/frontends/tda18271-tables.c126
1 files changed, 73 insertions, 53 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-tables.c b/drivers/media/dvb/frontends/tda18271-tables.c
index 02b6d2cb957..8990bef0cf7 100644
--- a/drivers/media/dvb/frontends/tda18271-tables.c
+++ b/drivers/media/dvb/frontends/tda18271-tables.c
@@ -267,22 +267,33 @@ static struct tda18271_map tda18271_ir_measure[] = {
/*---------------------------------------------------------------------*/
-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) {
+ dbg_info("%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);
-}
+ dbg_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) {
+ dbg_info("%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);
-}
+ dbg_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;
}
/*