diff options
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-fe.c | 119 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-priv.h | 46 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-tables.c | 106 |
3 files changed, 149 insertions, 122 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c index fee38c1657e1..5d3c4b0975f6 100644 --- a/drivers/media/dvb/frontends/tda18271-fe.c +++ b/drivers/media/dvb/frontends/tda18271-fe.c | |||
@@ -25,22 +25,10 @@ | |||
25 | #include "tda18271.h" | 25 | #include "tda18271.h" |
26 | #include "tda18271-priv.h" | 26 | #include "tda18271-priv.h" |
27 | 27 | ||
28 | static int tda18271_debug; | 28 | int tda18271_debug; |
29 | module_param_named(debug, tda18271_debug, int, 0644); | 29 | module_param_named(debug, tda18271_debug, int, 0644); |
30 | MODULE_PARM_DESC(debug, "set debug level (info=1, map=2, reg=4 (or-able))"); | 30 | MODULE_PARM_DESC(debug, "set debug level (info=1, map=2, reg=4 (or-able))"); |
31 | 31 | ||
32 | #define dprintk(level, fmt, arg...) do {\ | ||
33 | if (tda18271_debug & level) \ | ||
34 | printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ##arg); } while (0) | ||
35 | |||
36 | #define DBG_INFO 1 | ||
37 | #define DBG_MAP 2 | ||
38 | #define DBG_REG 4 | ||
39 | |||
40 | #define dbg_info(fmt, arg...) dprintk(DBG_INFO, fmt, ##arg) | ||
41 | #define dbg_map(fmt, arg...) dprintk(DBG_MAP, fmt, ##arg) | ||
42 | #define dbg_reg(fmt, arg...) dprintk(DBG_REG, fmt, ##arg) | ||
43 | |||
44 | /*---------------------------------------------------------------------*/ | 32 | /*---------------------------------------------------------------------*/ |
45 | 33 | ||
46 | #define TDA18271_ANALOG 0 | 34 | #define TDA18271_ANALOG 0 |
@@ -365,7 +353,7 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
365 | struct tda18271_priv *priv = fe->tuner_priv; | 353 | struct tda18271_priv *priv = fe->tuner_priv; |
366 | unsigned char *regs = priv->tda18271_regs; | 354 | unsigned char *regs = priv->tda18271_regs; |
367 | u32 div, N = 0; | 355 | u32 div, N = 0; |
368 | int i; | 356 | u8 d, pd, val; |
369 | 357 | ||
370 | tda18271_init(fe); | 358 | tda18271_init(fe); |
371 | 359 | ||
@@ -374,16 +362,10 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
374 | /* RF tracking filter calibration */ | 362 | /* RF tracking filter calibration */ |
375 | 363 | ||
376 | /* calculate BP_Filter */ | 364 | /* calculate BP_Filter */ |
377 | i = 0; | 365 | tda18271_calc_bp_filter(&freq, &val); |
378 | while ((tda18271_bp_filter[i].rfmax * 1000) < freq) { | ||
379 | if (tda18271_bp_filter[i + 1].rfmax == 0) | ||
380 | break; | ||
381 | i++; | ||
382 | } | ||
383 | dbg_map("bp filter = 0x%x, i = %d\n", tda18271_bp_filter[i].val, i); | ||
384 | 366 | ||
385 | regs[R_EP1] &= ~0x07; /* clear bp filter bits */ | 367 | regs[R_EP1] &= ~0x07; /* clear bp filter bits */ |
386 | regs[R_EP1] |= tda18271_bp_filter[i].val; | 368 | regs[R_EP1] |= val; |
387 | tda18271_write_regs(fe, R_EP1, 1); | 369 | tda18271_write_regs(fe, R_EP1, 1); |
388 | 370 | ||
389 | regs[R_EB4] &= 0x07; | 371 | regs[R_EB4] &= 0x07; |
@@ -413,18 +395,11 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
413 | break; | 395 | break; |
414 | } | 396 | } |
415 | 397 | ||
416 | i = 0; | 398 | tda18271_calc_cal_pll(&N, &pd, &d); |
417 | while ((tda18271_cal_pll[i].lomax * 1000) < N) { | ||
418 | if (tda18271_cal_pll[i + 1].lomax == 0) | ||
419 | break; | ||
420 | i++; | ||
421 | } | ||
422 | dbg_map("cal pll, pd = 0x%x, d = 0x%x, i = %d\n", | ||
423 | tda18271_cal_pll[i].pd, tda18271_cal_pll[i].d, i); | ||
424 | 399 | ||
425 | regs[R_CPD] = tda18271_cal_pll[i].pd; | 400 | regs[R_CPD] = pd; |
426 | 401 | ||
427 | div = ((tda18271_cal_pll[i].d * (N / 1000)) << 7) / 125; | 402 | div = ((d * (N / 1000)) << 7) / 125; |
428 | regs[R_CD1] = 0xff & (div >> 16); | 403 | regs[R_CD1] = 0xff & (div >> 16); |
429 | regs[R_CD2] = 0xff & (div >> 8); | 404 | regs[R_CD2] = 0xff & (div >> 8); |
430 | regs[R_CD3] = 0xff & div; | 405 | regs[R_CD3] = 0xff & div; |
@@ -440,16 +415,9 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
440 | break; | 415 | break; |
441 | } | 416 | } |
442 | 417 | ||
443 | i = 0; | 418 | tda18271_calc_main_pll(&N, &pd, &d); |
444 | while ((tda18271_main_pll[i].lomax * 1000) < N) { | ||
445 | if (tda18271_main_pll[i + 1].lomax == 0) | ||
446 | break; | ||
447 | i++; | ||
448 | } | ||
449 | dbg_map("main pll, pd = 0x%x, d = 0x%x, i = %d\n", | ||
450 | tda18271_main_pll[i].pd, tda18271_main_pll[i].d, i); | ||
451 | 419 | ||
452 | regs[R_MPD] = (0x7f & tda18271_main_pll[i].pd); | 420 | regs[R_MPD] = (0x7f & pd); |
453 | 421 | ||
454 | switch (priv->mode) { | 422 | switch (priv->mode) { |
455 | case TDA18271_ANALOG: | 423 | case TDA18271_ANALOG: |
@@ -460,7 +428,7 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
460 | break; | 428 | break; |
461 | } | 429 | } |
462 | 430 | ||
463 | div = ((tda18271_main_pll[i].d * (N / 1000)) << 7) / 125; | 431 | div = ((d * (N / 1000)) << 7) / 125; |
464 | regs[R_MD1] = 0xff & (div >> 16); | 432 | regs[R_MD1] = 0xff & (div >> 16); |
465 | regs[R_MD2] = 0xff & (div >> 8); | 433 | regs[R_MD2] = 0xff & (div >> 8); |
466 | regs[R_MD3] = 0xff & div; | 434 | regs[R_MD3] = 0xff & div; |
@@ -469,42 +437,23 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
469 | msleep(5); /* RF tracking filter calibration initialization */ | 437 | msleep(5); /* RF tracking filter calibration initialization */ |
470 | 438 | ||
471 | /* search for K,M,CO for RF Calibration */ | 439 | /* search for K,M,CO for RF Calibration */ |
472 | i = 0; | 440 | tda18271_calc_km(&freq, &val); |
473 | while ((tda18271_km[i].rfmax * 1000) < freq) { | ||
474 | if (tda18271_km[i + 1].rfmax == 0) | ||
475 | break; | ||
476 | i++; | ||
477 | } | ||
478 | dbg_map("km = 0x%x, i = %d\n", tda18271_km[i].val, i); | ||
479 | 441 | ||
480 | regs[R_EB13] &= 0x83; | 442 | regs[R_EB13] &= 0x83; |
481 | regs[R_EB13] |= tda18271_km[i].val; | 443 | regs[R_EB13] |= val; |
482 | tda18271_write_regs(fe, R_EB13, 1); | 444 | tda18271_write_regs(fe, R_EB13, 1); |
483 | 445 | ||
484 | /* search for RF_BAND */ | 446 | /* search for RF_BAND */ |
485 | i = 0; | 447 | tda18271_calc_rf_band(&freq, &val); |
486 | while ((tda18271_rf_band[i].rfmax * 1000) < freq) { | ||
487 | if (tda18271_rf_band[i + 1].rfmax == 0) | ||
488 | break; | ||
489 | i++; | ||
490 | } | ||
491 | dbg_map("rf band = 0x%x, i = %d\n", tda18271_rf_band[i].val, i); | ||
492 | 448 | ||
493 | regs[R_EP2] &= ~0xe0; /* clear rf band bits */ | 449 | regs[R_EP2] &= ~0xe0; /* clear rf band bits */ |
494 | regs[R_EP2] |= (tda18271_rf_band[i].val << 5); | 450 | regs[R_EP2] |= (val << 5); |
495 | 451 | ||
496 | /* search for Gain_Taper */ | 452 | /* search for Gain_Taper */ |
497 | i = 0; | 453 | tda18271_calc_gain_taper(&freq, &val); |
498 | while ((tda18271_gain_taper[i].rfmax * 1000) < freq) { | ||
499 | if (tda18271_gain_taper[i + 1].rfmax == 0) | ||
500 | break; | ||
501 | i++; | ||
502 | } | ||
503 | dbg_map("gain taper = 0x%x, i = %d\n", | ||
504 | tda18271_gain_taper[i].val, i); | ||
505 | 454 | ||
506 | regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ | 455 | regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ |
507 | regs[R_EP2] |= tda18271_gain_taper[i].val; | 456 | regs[R_EP2] |= val; |
508 | 457 | ||
509 | tda18271_write_regs(fe, R_EP2, 1); | 458 | tda18271_write_regs(fe, R_EP2, 1); |
510 | tda18271_write_regs(fe, R_EP1, 1); | 459 | tda18271_write_regs(fe, R_EP1, 1); |
@@ -529,17 +478,11 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
529 | tda18271_write_regs(fe, R_EP1, 1); | 478 | tda18271_write_regs(fe, R_EP1, 1); |
530 | 479 | ||
531 | /* RF tracking filer correction for VHF_Low band */ | 480 | /* RF tracking filer correction for VHF_Low band */ |
532 | i = 0; | 481 | tda18271_calc_rf_cal(&freq, &val); |
533 | while ((tda18271_rf_cal[i].rfmax * 1000) < freq) { | ||
534 | if (tda18271_rf_cal[i].rfmax == 0) | ||
535 | break; | ||
536 | i++; | ||
537 | } | ||
538 | dbg_map("rf cal = 0x%x, i = %d\n", tda18271_rf_cal[i].val, i); | ||
539 | 482 | ||
540 | /* VHF_Low band only */ | 483 | /* VHF_Low band only */ |
541 | if (tda18271_rf_cal[i].rfmax != 0) { | 484 | if (val != 0) { |
542 | regs[R_EB14] = tda18271_rf_cal[i].val; | 485 | regs[R_EB14] = val; |
543 | tda18271_write_regs(fe, R_EB14, 1); | 486 | tda18271_write_regs(fe, R_EB14, 1); |
544 | } | 487 | } |
545 | 488 | ||
@@ -579,29 +522,17 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
579 | regs[R_EP4] &= ~0x80; /* turn this bit on only for fm */ | 522 | regs[R_EP4] &= ~0x80; /* turn this bit on only for fm */ |
580 | 523 | ||
581 | /* image rejection validity EP5[2:0] */ | 524 | /* image rejection validity EP5[2:0] */ |
582 | i = 0; | 525 | tda18271_calc_ir_measure(&freq, &val); |
583 | while ((tda18271_ir_measure[i].rfmax * 1000) < freq) { | 526 | |
584 | if (tda18271_ir_measure[i].rfmax == 0) | ||
585 | break; | ||
586 | i++; | ||
587 | } | ||
588 | dbg_map("ir measure, i = %d\n", i); | ||
589 | regs[R_EP5] &= ~0x07; | 527 | regs[R_EP5] &= ~0x07; |
590 | regs[R_EP5] |= tda18271_ir_measure[i].val; | 528 | regs[R_EP5] |= val; |
591 | 529 | ||
592 | /* calculate MAIN PLL */ | 530 | /* calculate MAIN PLL */ |
593 | N = freq + ifc; | 531 | N = freq + ifc; |
594 | 532 | ||
595 | i = 0; | 533 | tda18271_calc_main_pll(&N, &pd, &d); |
596 | while ((tda18271_main_pll[i].lomax * 1000) < N) { | ||
597 | if (tda18271_main_pll[i + 1].lomax == 0) | ||
598 | break; | ||
599 | i++; | ||
600 | } | ||
601 | dbg_map("main pll, pd = 0x%x, d = 0x%x, i = %d\n", | ||
602 | tda18271_main_pll[i].pd, tda18271_main_pll[i].d, i); | ||
603 | 534 | ||
604 | regs[R_MPD] = (0x7f & tda18271_main_pll[i].pd); | 535 | regs[R_MPD] = (0x7f & pd); |
605 | switch (priv->mode) { | 536 | switch (priv->mode) { |
606 | case TDA18271_ANALOG: | 537 | case TDA18271_ANALOG: |
607 | regs[R_MPD] &= ~0x08; | 538 | regs[R_MPD] &= ~0x08; |
@@ -611,7 +542,7 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
611 | break; | 542 | break; |
612 | } | 543 | } |
613 | 544 | ||
614 | div = ((tda18271_main_pll[i].d * (N / 1000)) << 7) / 125; | 545 | div = ((d * (N / 1000)) << 7) / 125; |
615 | regs[R_MD1] = 0xff & (div >> 16); | 546 | regs[R_MD1] = 0xff & (div >> 16); |
616 | regs[R_MD2] = 0xff & (div >> 8); | 547 | regs[R_MD2] = 0xff & (div >> 8); |
617 | regs[R_MD3] = 0xff & div; | 548 | regs[R_MD3] = 0xff & div; |
diff --git a/drivers/media/dvb/frontends/tda18271-priv.h b/drivers/media/dvb/frontends/tda18271-priv.h index a3158eb25594..d56c2fe3efa2 100644 --- a/drivers/media/dvb/frontends/tda18271-priv.h +++ b/drivers/media/dvb/frontends/tda18271-priv.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifndef __TDA18271_PRIV_H__ | 21 | #ifndef __TDA18271_PRIV_H__ |
22 | #define __TDA18271_PRIV_H__ | 22 | #define __TDA18271_PRIV_H__ |
23 | 23 | ||
24 | #include <linux/kernel.h> | ||
24 | #include <linux/types.h> | 25 | #include <linux/types.h> |
25 | 26 | ||
26 | #define R_ID 0x00 /* ID byte */ | 27 | #define R_ID 0x00 /* ID byte */ |
@@ -65,26 +66,31 @@ | |||
65 | 66 | ||
66 | #define TDA18271_NUM_REGS 39 | 67 | #define TDA18271_NUM_REGS 39 |
67 | 68 | ||
68 | struct tda18271_pll_map { | 69 | extern int tda18271_debug; |
69 | u32 lomax; | 70 | |
70 | u8 pd; /* post div */ | 71 | #define dprintk(level, fmt, arg...) do {\ |
71 | u8 d; /* div */ | 72 | if (tda18271_debug & level) \ |
72 | }; | 73 | printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ##arg); } while (0) |
73 | 74 | ||
74 | extern struct tda18271_pll_map tda18271_main_pll[]; | 75 | #define DBG_INFO 1 |
75 | extern struct tda18271_pll_map tda18271_cal_pll[]; | 76 | #define DBG_MAP 2 |
76 | 77 | #define DBG_REG 4 | |
77 | struct tda18271_map { | 78 | |
78 | u32 rfmax; | 79 | #define dbg_info(fmt, arg...) dprintk(DBG_INFO, fmt, ##arg) |
79 | u8 val; | 80 | #define dbg_map(fmt, arg...) dprintk(DBG_MAP, fmt, ##arg) |
80 | }; | 81 | #define dbg_reg(fmt, arg...) dprintk(DBG_REG, fmt, ##arg) |
81 | 82 | ||
82 | extern struct tda18271_map tda18271_bp_filter[]; | 83 | /*---------------------------------------------------------------------*/ |
83 | extern struct tda18271_map tda18271_km[]; | 84 | |
84 | extern struct tda18271_map tda18271_rf_band[]; | 85 | extern void tda18271_calc_cal_pll(u32 *freq, u8 *post_div, u8 *div); |
85 | extern struct tda18271_map tda18271_gain_taper[]; | 86 | extern void tda18271_calc_main_pll(u32 *freq, u8 *post_div, u8 *div); |
86 | extern struct tda18271_map tda18271_rf_cal[]; | 87 | |
87 | extern struct tda18271_map tda18271_ir_measure[]; | 88 | extern void tda18271_calc_bp_filter(u32 *freq, u8 *val); |
89 | extern void tda18271_calc_km(u32 *freq, u8 *val); | ||
90 | extern void tda18271_calc_rf_band(u32 *freq, u8 *val); | ||
91 | extern void tda18271_calc_gain_taper(u32 *freq, u8 *val); | ||
92 | extern void tda18271_calc_rf_cal(u32 *freq, u8 *val); | ||
93 | extern void tda18271_calc_ir_measure(u32 *freq, u8 *val); | ||
88 | 94 | ||
89 | #endif /* __TDA18271_PRIV_H__ */ | 95 | #endif /* __TDA18271_PRIV_H__ */ |
90 | 96 | ||
diff --git a/drivers/media/dvb/frontends/tda18271-tables.c b/drivers/media/dvb/frontends/tda18271-tables.c index d65d3411e362..65387bb059eb 100644 --- a/drivers/media/dvb/frontends/tda18271-tables.c +++ b/drivers/media/dvb/frontends/tda18271-tables.c | |||
@@ -20,7 +20,20 @@ | |||
20 | 20 | ||
21 | #include "tda18271-priv.h" | 21 | #include "tda18271-priv.h" |
22 | 22 | ||
23 | struct tda18271_pll_map tda18271_main_pll[] = { | 23 | struct tda18271_pll_map { |
24 | u32 lomax; | ||
25 | u8 pd; /* post div */ | ||
26 | u8 d; /* div */ | ||
27 | }; | ||
28 | |||
29 | struct tda18271_map { | ||
30 | u32 rfmax; | ||
31 | u8 val; | ||
32 | }; | ||
33 | |||
34 | /*---------------------------------------------------------------------*/ | ||
35 | |||
36 | static struct tda18271_pll_map tda18271_main_pll[] = { | ||
24 | { .lomax = 32000, .pd = 0x5f, .d = 0xf0 }, | 37 | { .lomax = 32000, .pd = 0x5f, .d = 0xf0 }, |
25 | { .lomax = 35000, .pd = 0x5e, .d = 0xe0 }, | 38 | { .lomax = 35000, .pd = 0x5e, .d = 0xe0 }, |
26 | { .lomax = 37000, .pd = 0x5d, .d = 0xd0 }, | 39 | { .lomax = 37000, .pd = 0x5d, .d = 0xd0 }, |
@@ -64,7 +77,7 @@ struct tda18271_pll_map tda18271_main_pll[] = { | |||
64 | { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ | 77 | { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ |
65 | }; | 78 | }; |
66 | 79 | ||
67 | struct tda18271_pll_map tda18271_cal_pll[] = { | 80 | static struct tda18271_pll_map tda18271_cal_pll[] = { |
68 | { .lomax = 33000, .pd = 0xdd, .d = 0xd0 }, | 81 | { .lomax = 33000, .pd = 0xdd, .d = 0xd0 }, |
69 | { .lomax = 36000, .pd = 0xdc, .d = 0xc0 }, | 82 | { .lomax = 36000, .pd = 0xdc, .d = 0xc0 }, |
70 | { .lomax = 40000, .pd = 0xdb, .d = 0xb0 }, | 83 | { .lomax = 40000, .pd = 0xdb, .d = 0xb0 }, |
@@ -103,7 +116,7 @@ struct tda18271_pll_map tda18271_cal_pll[] = { | |||
103 | { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ | 116 | { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ |
104 | }; | 117 | }; |
105 | 118 | ||
106 | struct tda18271_map tda18271_bp_filter[] = { | 119 | static struct tda18271_map tda18271_bp_filter[] = { |
107 | { .rfmax = 62000, .val = 0x00 }, | 120 | { .rfmax = 62000, .val = 0x00 }, |
108 | { .rfmax = 84000, .val = 0x01 }, | 121 | { .rfmax = 84000, .val = 0x01 }, |
109 | { .rfmax = 100000, .val = 0x02 }, | 122 | { .rfmax = 100000, .val = 0x02 }, |
@@ -114,7 +127,7 @@ struct tda18271_map tda18271_bp_filter[] = { | |||
114 | { .rfmax = 0, .val = 0x00 }, /* end */ | 127 | { .rfmax = 0, .val = 0x00 }, /* end */ |
115 | }; | 128 | }; |
116 | 129 | ||
117 | struct tda18271_map tda18271_km[] = { | 130 | static struct tda18271_map tda18271_km[] = { |
118 | { .rfmax = 61100, .val = 0x74 }, | 131 | { .rfmax = 61100, .val = 0x74 }, |
119 | { .rfmax = 350000, .val = 0x40 }, | 132 | { .rfmax = 350000, .val = 0x40 }, |
120 | { .rfmax = 720000, .val = 0x30 }, | 133 | { .rfmax = 720000, .val = 0x30 }, |
@@ -122,7 +135,7 @@ struct tda18271_map tda18271_km[] = { | |||
122 | { .rfmax = 0, .val = 0x00 }, /* end */ | 135 | { .rfmax = 0, .val = 0x00 }, /* end */ |
123 | }; | 136 | }; |
124 | 137 | ||
125 | struct tda18271_map tda18271_rf_band[] = { | 138 | static struct tda18271_map tda18271_rf_band[] = { |
126 | { .rfmax = 47900, .val = 0x00 }, | 139 | { .rfmax = 47900, .val = 0x00 }, |
127 | { .rfmax = 61100, .val = 0x01 }, | 140 | { .rfmax = 61100, .val = 0x01 }, |
128 | /* { .rfmax = 152600, .val = 0x02 }, */ | 141 | /* { .rfmax = 152600, .val = 0x02 }, */ |
@@ -134,7 +147,7 @@ struct tda18271_map tda18271_rf_band[] = { | |||
134 | { .rfmax = 0, .val = 0x00 }, /* end */ | 147 | { .rfmax = 0, .val = 0x00 }, /* end */ |
135 | }; | 148 | }; |
136 | 149 | ||
137 | struct tda18271_map tda18271_gain_taper[] = { | 150 | static struct tda18271_map tda18271_gain_taper[] = { |
138 | { .rfmax = 45400, .val = 0x1f }, | 151 | { .rfmax = 45400, .val = 0x1f }, |
139 | { .rfmax = 45800, .val = 0x1e }, | 152 | { .rfmax = 45800, .val = 0x1e }, |
140 | { .rfmax = 46200, .val = 0x1d }, | 153 | { .rfmax = 46200, .val = 0x1d }, |
@@ -223,7 +236,7 @@ struct tda18271_map tda18271_gain_taper[] = { | |||
223 | { .rfmax = 0, .val = 0x00 }, /* end */ | 236 | { .rfmax = 0, .val = 0x00 }, /* end */ |
224 | }; | 237 | }; |
225 | 238 | ||
226 | struct tda18271_map tda18271_rf_cal[] = { | 239 | static struct tda18271_map tda18271_rf_cal[] = { |
227 | { .rfmax = 41000, .val = 0x1e }, | 240 | { .rfmax = 41000, .val = 0x1e }, |
228 | { .rfmax = 43000, .val = 0x30 }, | 241 | { .rfmax = 43000, .val = 0x30 }, |
229 | { .rfmax = 45000, .val = 0x43 }, | 242 | { .rfmax = 45000, .val = 0x43 }, |
@@ -244,7 +257,7 @@ struct tda18271_map tda18271_rf_cal[] = { | |||
244 | { .rfmax = 0, .val = 0x00 }, /* end */ | 257 | { .rfmax = 0, .val = 0x00 }, /* end */ |
245 | }; | 258 | }; |
246 | 259 | ||
247 | struct tda18271_map tda18271_ir_measure[] = { | 260 | static struct tda18271_map tda18271_ir_measure[] = { |
248 | { .rfmax = 30000, .val = 4}, | 261 | { .rfmax = 30000, .val = 4}, |
249 | { .rfmax = 200000, .val = 5}, | 262 | { .rfmax = 200000, .val = 5}, |
250 | { .rfmax = 600000, .val = 6}, | 263 | { .rfmax = 600000, .val = 6}, |
@@ -252,6 +265,83 @@ struct tda18271_map tda18271_ir_measure[] = { | |||
252 | { .rfmax = 0, .val = 0}, /* end */ | 265 | { .rfmax = 0, .val = 0}, /* end */ |
253 | }; | 266 | }; |
254 | 267 | ||
268 | /*---------------------------------------------------------------------*/ | ||
269 | |||
270 | static void tda18271_lookup_map(struct tda18271_map *map, | ||
271 | u32 *freq, u8 *val) | ||
272 | { | ||
273 | int i = 0; | ||
274 | while ((map[i].rfmax * 1000) < *freq) { | ||
275 | if (map[i + 1].rfmax == 0) | ||
276 | break; | ||
277 | i++; | ||
278 | } | ||
279 | *val = map[i].val; | ||
280 | } | ||
281 | |||
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) { | ||
287 | if (map[i + 1].lomax == 0) | ||
288 | break; | ||
289 | i++; | ||
290 | } | ||
291 | *post_div = map[i].pd; | ||
292 | *div = map[i].d; | ||
293 | } | ||
294 | |||
295 | /*---------------------------------------------------------------------*/ | ||
296 | |||
297 | void tda18271_calc_cal_pll(u32 *freq, u8 *post_div, u8 *div) | ||
298 | { | ||
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 | |||
303 | void tda18271_calc_main_pll(u32 *freq, u8 *post_div, u8 *div) | ||
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 | } | ||
308 | |||
309 | void tda18271_calc_bp_filter(u32 *freq, u8 *val) | ||
310 | { | ||
311 | tda18271_lookup_map(tda18271_bp_filter, freq, val); | ||
312 | dbg_map("0x%02x\n", *val); | ||
313 | } | ||
314 | |||
315 | void tda18271_calc_km(u32 *freq, u8 *val) | ||
316 | { | ||
317 | tda18271_lookup_map(tda18271_km, freq, val); | ||
318 | dbg_map("0x%02x\n", *val); | ||
319 | } | ||
320 | |||
321 | void tda18271_calc_rf_band(u32 *freq, u8 *val) | ||
322 | { | ||
323 | tda18271_lookup_map(tda18271_rf_band, freq, val); | ||
324 | dbg_map("0x%02x\n", *val); | ||
325 | } | ||
326 | |||
327 | void tda18271_calc_gain_taper(u32 *freq, u8 *val) | ||
328 | { | ||
329 | tda18271_lookup_map(tda18271_gain_taper, freq, val); | ||
330 | dbg_map("0x%02x\n", *val); | ||
331 | } | ||
332 | |||
333 | void tda18271_calc_rf_cal(u32 *freq, u8 *val) | ||
334 | { | ||
335 | tda18271_lookup_map(tda18271_rf_cal, freq, val); | ||
336 | dbg_map("0x%02x\n", *val); | ||
337 | } | ||
338 | |||
339 | void tda18271_calc_ir_measure(u32 *freq, u8 *val) | ||
340 | { | ||
341 | tda18271_lookup_map(tda18271_ir_measure, freq, val); | ||
342 | dbg_map("0x%02x\n", *val); | ||
343 | } | ||
344 | |||
255 | /* | 345 | /* |
256 | * Overrides for Emacs so that we follow Linus's tabbing style. | 346 | * Overrides for Emacs so that we follow Linus's tabbing style. |
257 | * --------------------------------------------------------------------------- | 347 | * --------------------------------------------------------------------------- |