Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76671
b: refs/heads/master
c: 2f27dfc
h: refs/heads/master
i:
  76669: 5cc220b
  76667: 73c814d
  76663: ba6b214
  76655: ef4eebf
  76639: 01d6b18
  76607: 8566f34
  76543: b89e3e9
v: v3
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Jan 25, 2008
1 parent 84354bf commit fa98c8f
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 75 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d37142102a2adaa3391a384ea6a780afb5804789
refs/heads/master: 2f27dfc98cc0a183be9e3c2fc0da0450b85e5fde
28 changes: 16 additions & 12 deletions trunk/drivers/media/dvb/frontends/tda18271-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,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);

Expand All @@ -378,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)
Expand All @@ -390,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;

Expand All @@ -399,8 +403,8 @@ 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;

return 0;
fail:
return ret;
}

static int tda18271_tune(struct dvb_frontend *fe,
Expand All @@ -418,7 +422,7 @@ static int tda18271_tune(struct dvb_frontend *fe,
/* RF tracking filter calibration */

/* calculate BP_Filter */
tda18271_lookup_bp_filter(&freq, &val);
tda18271_lookup_map(BP_FILTER, &freq, &val);

regs[R_EP1] &= ~0x07; /* clear bp filter bits */
regs[R_EP1] |= val;
Expand Down Expand Up @@ -470,20 +474,20 @@ 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);
tda18271_lookup_map(RF_CAL_KMCO, &freq, &val);

regs[R_EB13] &= 0x83;
regs[R_EB13] |= val;
tda18271_write_regs(fe, R_EB13, 1);

/* search for RF_BAND */
tda18271_lookup_rf_band(&freq, &val);
tda18271_lookup_map(RF_BAND, &freq, &val);

regs[R_EP2] &= ~0xe0; /* clear rf band bits */
regs[R_EP2] |= (val << 5);

/* search for Gain_Taper */
tda18271_lookup_gain_taper(&freq, &val);
tda18271_lookup_map(GAIN_TAPER, &freq, &val);

regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
regs[R_EP2] |= val;
Expand Down Expand Up @@ -511,7 +515,7 @@ 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);
tda18271_lookup_map(RF_CAL, &freq, &val);

/* VHF_Low band only */
if (val != 0) {
Expand Down Expand Up @@ -555,7 +559,7 @@ 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);
tda18271_lookup_map(IR_MEASURE, &freq, &val);

regs[R_EP5] &= ~0x07;
regs[R_EP5] |= val;
Expand Down
26 changes: 17 additions & 9 deletions trunk/drivers/media/dvb/frontends/tda18271-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,23 @@ extern int tda18271_debug;

/*---------------------------------------------------------------------*/

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__ */

Expand Down
126 changes: 73 additions & 53 deletions trunk/drivers/media/dvb/frontends/tda18271-tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,79 +267,99 @@ 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;
i++;
}
*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;
}

/*
Expand Down

0 comments on commit fa98c8f

Please sign in to comment.