diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-24 22:39:37 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:04:25 -0500 |
commit | 2f27dfc98cc0a183be9e3c2fc0da0450b85e5fde (patch) | |
tree | e47034d3d6b0c09c34de248e18a01a880d485abc /drivers/media/dvb/frontends/tda18271-tables.c | |
parent | d37142102a2adaa3391a384ea6a780afb5804789 (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.c | 126 |
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 02b6d2cb9570..8990bef0cf7e 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[] = { | |||
267 | 267 | ||
268 | /*---------------------------------------------------------------------*/ | 268 | /*---------------------------------------------------------------------*/ |
269 | 269 | ||
270 | static void tda18271_lookup_map(struct tda18271_map *map, | 270 | int tda18271_lookup_pll_map(enum tda18271_map_type map_type, |
271 | u32 *freq, u8 *val) | 271 | u32 *freq, u8 *post_div, u8 *div) |
272 | { | 272 | { |
273 | int i = 0; | 273 | struct tda18271_pll_map *map = NULL; |
274 | while ((map[i].rfmax * 1000) < *freq) { | 274 | unsigned int i = 0; |
275 | if (map[i + 1].rfmax == 0) | 275 | char *map_name; |
276 | break; | 276 | |
277 | i++; | 277 | switch (map_type) { |
278 | case MAIN_PLL: | ||
279 | map = tda18271_main_pll; | ||
280 | map_name = "main_pll"; | ||
281 | break; | ||
282 | case CAL_PLL: | ||
283 | map = tda18271_cal_pll; | ||
284 | map_name = "cal_pll"; | ||
285 | break; | ||
286 | default: | ||
287 | /* we should never get here */ | ||
288 | map_name = "undefined"; | ||
289 | break; | ||
290 | } | ||
291 | |||
292 | if (!map) { | ||
293 | dbg_info("%s map is not set!\n", map_name); | ||
294 | return -EINVAL; | ||
278 | } | 295 | } |
279 | *val = map[i].val; | ||
280 | } | ||
281 | 296 | ||
282 | static void tda18271_lookup_pll_map(struct tda18271_pll_map *map, | ||
283 | u32 *freq, u8 *post_div, u8 *div) | ||
284 | { | ||
285 | int i = 0; | ||
286 | while ((map[i].lomax * 1000) < *freq) { | 297 | while ((map[i].lomax * 1000) < *freq) { |
287 | if (map[i + 1].lomax == 0) | 298 | if (map[i + 1].lomax == 0) |
288 | break; | 299 | break; |
@@ -290,56 +301,65 @@ static void tda18271_lookup_pll_map(struct tda18271_pll_map *map, | |||
290 | } | 301 | } |
291 | *post_div = map[i].pd; | 302 | *post_div = map[i].pd; |
292 | *div = map[i].d; | 303 | *div = map[i].d; |
293 | } | ||
294 | |||
295 | /*---------------------------------------------------------------------*/ | ||
296 | 304 | ||
297 | void tda18271_lookup_cal_pll(u32 *freq, u8 *post_div, u8 *div) | 305 | dbg_map("%s: post div = 0x%02x, div = 0x%02x\n", |
298 | { | 306 | map_name, *post_div, *div); |
299 | tda18271_lookup_pll_map(tda18271_cal_pll, freq, post_div, div); | ||
300 | dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div); | ||
301 | } | ||
302 | 307 | ||
303 | void tda18271_lookup_main_pll(u32 *freq, u8 *post_div, u8 *div) | 308 | return 0; |
304 | { | ||
305 | tda18271_lookup_pll_map(tda18271_main_pll, freq, post_div, div); | ||
306 | dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div); | ||
307 | } | 309 | } |
308 | 310 | ||
309 | void tda18271_lookup_bp_filter(u32 *freq, u8 *val) | 311 | int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) |
310 | { | 312 | { |
311 | tda18271_lookup_map(tda18271_bp_filter, freq, val); | 313 | struct tda18271_map *map = NULL; |
312 | dbg_map("0x%02x\n", *val); | 314 | unsigned int i = 0; |
313 | } | 315 | char *map_name; |
314 | 316 | ||
315 | void tda18271_lookup_km(u32 *freq, u8 *val) | 317 | switch (map_type) { |
316 | { | 318 | case BP_FILTER: |
317 | tda18271_lookup_map(tda18271_km, freq, val); | 319 | map = tda18271_bp_filter; |
318 | dbg_map("0x%02x\n", *val); | 320 | map_name = "bp_filter"; |
319 | } | 321 | break; |
322 | case RF_CAL_KMCO: | ||
323 | map = tda18271_km; | ||
324 | map_name = "km"; | ||
325 | break; | ||
326 | case RF_BAND: | ||
327 | map = tda18271_rf_band; | ||
328 | map_name = "rf_band"; | ||
329 | break; | ||
330 | case GAIN_TAPER: | ||
331 | map = tda18271_gain_taper; | ||
332 | map_name = "gain_taper"; | ||
333 | break; | ||
334 | case RF_CAL: | ||
335 | map = tda18271_rf_cal; | ||
336 | map_name = "rf_cal"; | ||
337 | break; | ||
338 | case IR_MEASURE: | ||
339 | map = tda18271_ir_measure; | ||
340 | map_name = "ir_measure"; | ||
341 | break; | ||
342 | default: | ||
343 | /* we should never get here */ | ||
344 | map_name = "undefined"; | ||
345 | break; | ||
346 | } | ||
320 | 347 | ||
321 | void tda18271_lookup_rf_band(u32 *freq, u8 *val) | 348 | if (!map) { |
322 | { | 349 | dbg_info("%s map is not set!\n", map_name); |
323 | tda18271_lookup_map(tda18271_rf_band, freq, val); | 350 | return -EINVAL; |
324 | dbg_map("0x%02x\n", *val); | 351 | } |
325 | } | ||
326 | 352 | ||
327 | void tda18271_lookup_gain_taper(u32 *freq, u8 *val) | 353 | while ((map[i].rfmax * 1000) < *freq) { |
328 | { | 354 | if (map[i + 1].rfmax == 0) |
329 | tda18271_lookup_map(tda18271_gain_taper, freq, val); | 355 | break; |
330 | dbg_map("0x%02x\n", *val); | 356 | i++; |
331 | } | 357 | } |
358 | *val = map[i].val; | ||
332 | 359 | ||
333 | void tda18271_lookup_rf_cal(u32 *freq, u8 *val) | 360 | dbg_map("%s: 0x%02x\n", map_name, *val); |
334 | { | ||
335 | tda18271_lookup_map(tda18271_rf_cal, freq, val); | ||
336 | dbg_map("0x%02x\n", *val); | ||
337 | } | ||
338 | 361 | ||
339 | void tda18271_lookup_ir_measure(u32 *freq, u8 *val) | 362 | return 0; |
340 | { | ||
341 | tda18271_lookup_map(tda18271_ir_measure, freq, val); | ||
342 | dbg_map("0x%02x\n", *val); | ||
343 | } | 363 | } |
344 | 364 | ||
345 | /* | 365 | /* |