提交 c293d0a7 编写于 作者: M Michael Krufky 提交者: Mauro Carvalho Chehab

V4L/DVB (7384): tda18271: store FM_RFn setting in struct tda18271_std_map_item

All standard related configuration is stored within
struct tda18271_std_map_item.  Pass a pointer to this
structure rather than its individual members.
Signed-off-by: NMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 5555309c
...@@ -37,8 +37,8 @@ static LIST_HEAD(hybrid_tuner_instance_list); ...@@ -37,8 +37,8 @@ static LIST_HEAD(hybrid_tuner_instance_list);
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static int tda18271_channel_configuration(struct dvb_frontend *fe, static int tda18271_channel_configuration(struct dvb_frontend *fe,
u32 ifc, u32 freq, u32 bw, u8 std, struct tda18271_std_map_item *map,
int radio) u32 freq, u32 bw)
{ {
struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_priv *priv = fe->tuner_priv;
unsigned char *regs = priv->tda18271_regs; unsigned char *regs = priv->tda18271_regs;
...@@ -48,7 +48,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, ...@@ -48,7 +48,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
/* set standard */ /* set standard */
regs[R_EP3] &= ~0x1f; /* clear std bits */ regs[R_EP3] &= ~0x1f; /* clear std bits */
regs[R_EP3] |= std; regs[R_EP3] |= map->std_bits;
/* set cal mode to normal */ /* set cal mode to normal */
regs[R_EP4] &= ~0x03; regs[R_EP4] &= ~0x03;
...@@ -66,10 +66,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, ...@@ -66,10 +66,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
break; break;
} }
if (radio) /* update FM_RFn */
regs[R_EP4] |= 0x80;
else
regs[R_EP4] &= ~0x80; regs[R_EP4] &= ~0x80;
regs[R_EP4] |= map->fm_rfn << 7;
/* update RF_TOP / IF_TOP */ /* update RF_TOP / IF_TOP */
switch (priv->mode) { switch (priv->mode) {
...@@ -114,7 +113,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, ...@@ -114,7 +113,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
N = freq + ifc; N = map->if_freq * 1000 + freq;
/* FIXME: assumes master */ /* FIXME: assumes master */
tda18271_calc_main_pll(fe, N); tda18271_calc_main_pll(fe, N);
...@@ -728,12 +727,12 @@ static int tda18271_init(struct dvb_frontend *fe) ...@@ -728,12 +727,12 @@ static int tda18271_init(struct dvb_frontend *fe)
} }
static int tda18271_tune(struct dvb_frontend *fe, static int tda18271_tune(struct dvb_frontend *fe,
u32 ifc, u32 freq, u32 bw, u8 std, int radio) struct tda18271_std_map_item *map, u32 freq, u32 bw)
{ {
struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_priv *priv = fe->tuner_priv;
tda_dbg("freq = %d, ifc = %d, bw = %d, std = 0x%02x\n", tda_dbg("freq = %d, ifc = %d, bw = %d, std = 0x%02x\n",
freq, ifc, bw, std); freq, map->if_freq, bw, map->std_bits);
tda18271_init(fe); tda18271_init(fe);
...@@ -747,7 +746,7 @@ static int tda18271_tune(struct dvb_frontend *fe, ...@@ -747,7 +746,7 @@ static int tda18271_tune(struct dvb_frontend *fe,
tda18271c2_rf_tracking_filters_correction(fe, freq); tda18271c2_rf_tracking_filters_correction(fe, freq);
break; break;
} }
tda18271_channel_configuration(fe, ifc, freq, bw, std, radio); tda18271_channel_configuration(fe, map, freq, bw);
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
...@@ -761,9 +760,8 @@ static int tda18271_set_params(struct dvb_frontend *fe, ...@@ -761,9 +760,8 @@ static int tda18271_set_params(struct dvb_frontend *fe,
{ {
struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_priv *priv = fe->tuner_priv;
struct tda18271_std_map *std_map = &priv->std; struct tda18271_std_map *std_map = &priv->std;
struct tda18271_std_map_item *map;
int ret; int ret;
u8 std;
u16 sgIF;
u32 bw, freq = params->frequency; u32 bw, freq = params->frequency;
priv->mode = TDA18271_DIGITAL; priv->mode = TDA18271_DIGITAL;
...@@ -772,13 +770,11 @@ static int tda18271_set_params(struct dvb_frontend *fe, ...@@ -772,13 +770,11 @@ static int tda18271_set_params(struct dvb_frontend *fe,
switch (params->u.vsb.modulation) { switch (params->u.vsb.modulation) {
case VSB_8: case VSB_8:
case VSB_16: case VSB_16:
std = std_map->atsc_6.std_bits; map = &std_map->atsc_6;
sgIF = std_map->atsc_6.if_freq;
break; break;
case QAM_64: case QAM_64:
case QAM_256: case QAM_256:
std = std_map->qam_6.std_bits; map = &std_map->qam_6;
sgIF = std_map->qam_6.if_freq;
break; break;
default: default:
tda_warn("modulation not set!\n"); tda_warn("modulation not set!\n");
...@@ -793,18 +789,15 @@ static int tda18271_set_params(struct dvb_frontend *fe, ...@@ -793,18 +789,15 @@ static int tda18271_set_params(struct dvb_frontend *fe,
switch (params->u.ofdm.bandwidth) { switch (params->u.ofdm.bandwidth) {
case BANDWIDTH_6_MHZ: case BANDWIDTH_6_MHZ:
bw = 6000000; bw = 6000000;
std = std_map->dvbt_6.std_bits; map = &std_map->dvbt_6;
sgIF = std_map->dvbt_6.if_freq;
break; break;
case BANDWIDTH_7_MHZ: case BANDWIDTH_7_MHZ:
bw = 7000000; bw = 7000000;
std = std_map->dvbt_7.std_bits; map = &std_map->dvbt_7;
sgIF = std_map->dvbt_7.if_freq;
break; break;
case BANDWIDTH_8_MHZ: case BANDWIDTH_8_MHZ:
bw = 8000000; bw = 8000000;
std = std_map->dvbt_8.std_bits; map = &std_map->dvbt_8;
sgIF = std_map->dvbt_8.if_freq;
break; break;
default: default:
tda_warn("bandwidth not set!\n"); tda_warn("bandwidth not set!\n");
...@@ -819,7 +812,7 @@ static int tda18271_set_params(struct dvb_frontend *fe, ...@@ -819,7 +812,7 @@ static int tda18271_set_params(struct dvb_frontend *fe,
if (fe->ops.analog_ops.standby) if (fe->ops.analog_ops.standby)
fe->ops.analog_ops.standby(fe); fe->ops.analog_ops.standby(fe);
ret = tda18271_tune(fe, sgIF * 1000, freq, bw, std, 0); ret = tda18271_tune(fe, map, freq, bw);
if (ret < 0) if (ret < 0)
goto fail; goto fail;
...@@ -836,57 +829,46 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, ...@@ -836,57 +829,46 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
{ {
struct tda18271_priv *priv = fe->tuner_priv; struct tda18271_priv *priv = fe->tuner_priv;
struct tda18271_std_map *std_map = &priv->std; struct tda18271_std_map *std_map = &priv->std;
struct tda18271_std_map_item *map;
char *mode; char *mode;
int ret, radio = 0; int ret;
u8 std;
u16 sgIF;
u32 freq = params->frequency * 62500; u32 freq = params->frequency * 62500;
priv->mode = TDA18271_ANALOG; priv->mode = TDA18271_ANALOG;
if (params->mode == V4L2_TUNER_RADIO) { if (params->mode == V4L2_TUNER_RADIO) {
radio = 1;
freq = freq / 1000; freq = freq / 1000;
std = std_map->fm_radio.std_bits; map = &std_map->fm_radio;
sgIF = std_map->fm_radio.if_freq;
mode = "fm"; mode = "fm";
} else if (params->std & V4L2_STD_MN) { } else if (params->std & V4L2_STD_MN) {
std = std_map->atv_mn.std_bits; map = &std_map->atv_mn;
sgIF = std_map->atv_mn.if_freq;
mode = "MN"; mode = "MN";
} else if (params->std & V4L2_STD_B) { } else if (params->std & V4L2_STD_B) {
std = std_map->atv_b.std_bits; map = &std_map->atv_b;
sgIF = std_map->atv_b.if_freq;
mode = "B"; mode = "B";
} else if (params->std & V4L2_STD_GH) { } else if (params->std & V4L2_STD_GH) {
std = std_map->atv_gh.std_bits; map = &std_map->atv_gh;
sgIF = std_map->atv_gh.if_freq;
mode = "GH"; mode = "GH";
} else if (params->std & V4L2_STD_PAL_I) { } else if (params->std & V4L2_STD_PAL_I) {
std = std_map->atv_i.std_bits; map = &std_map->atv_i;
sgIF = std_map->atv_i.if_freq;
mode = "I"; mode = "I";
} else if (params->std & V4L2_STD_DK) { } else if (params->std & V4L2_STD_DK) {
std = std_map->atv_dk.std_bits; map = &std_map->atv_dk;
sgIF = std_map->atv_dk.if_freq;
mode = "DK"; mode = "DK";
} else if (params->std & V4L2_STD_SECAM_L) { } else if (params->std & V4L2_STD_SECAM_L) {
std = std_map->atv_l.std_bits; map = &std_map->atv_l;
sgIF = std_map->atv_l.if_freq;
mode = "L"; mode = "L";
} else if (params->std & V4L2_STD_SECAM_LC) { } else if (params->std & V4L2_STD_SECAM_LC) {
std = std_map->atv_lc.std_bits; map = &std_map->atv_lc;
sgIF = std_map->atv_lc.if_freq;
mode = "L'"; mode = "L'";
} else { } else {
std = std_map->atv_i.std_bits; map = &std_map->atv_i;
sgIF = std_map->atv_i.if_freq;
mode = "xx"; mode = "xx";
} }
tda_dbg("setting tda18271 to system %s\n", mode); tda_dbg("setting tda18271 to system %s\n", mode);
ret = tda18271_tune(fe, sgIF * 1000, freq, 0, std, radio); ret = tda18271_tune(fe, map, freq, 0);
if (ret < 0) if (ret < 0)
goto fail; goto fail;
......
...@@ -1187,37 +1187,37 @@ int tda18271_lookup_map(struct dvb_frontend *fe, ...@@ -1187,37 +1187,37 @@ int tda18271_lookup_map(struct dvb_frontend *fe,
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static struct tda18271_std_map tda18271c1_std_map = { static struct tda18271_std_map tda18271c1_std_map = {
.fm_radio = { .if_freq = 1250, .std_bits = 0x18 }, .fm_radio = { .if_freq = 1250, .std_bits = 0x18, .fm_rfn = 1 },
.atv_b = { .if_freq = 6750, .std_bits = 0x0e }, .atv_b = { .if_freq = 6750, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_dk = { .if_freq = 7750, .std_bits = 0x0f }, .atv_dk = { .if_freq = 7750, .std_bits = 0x0f, .fm_rfn = 0 },
.atv_gh = { .if_freq = 7750, .std_bits = 0x0f }, .atv_gh = { .if_freq = 7750, .std_bits = 0x0f, .fm_rfn = 0 },
.atv_i = { .if_freq = 7750, .std_bits = 0x0f }, .atv_i = { .if_freq = 7750, .std_bits = 0x0f, .fm_rfn = 0 },
.atv_l = { .if_freq = 7750, .std_bits = 0x0f }, .atv_l = { .if_freq = 7750, .std_bits = 0x0f, .fm_rfn = 0 },
.atv_lc = { .if_freq = 1250, .std_bits = 0x0f }, .atv_lc = { .if_freq = 1250, .std_bits = 0x0f, .fm_rfn = 0 },
.atv_mn = { .if_freq = 5750, .std_bits = 0x0d }, .atv_mn = { .if_freq = 5750, .std_bits = 0x0d, .fm_rfn = 0 },
.atsc_6 = { .if_freq = 3250, .std_bits = 0x1c }, .atsc_6 = { .if_freq = 3250, .std_bits = 0x1c, .fm_rfn = 0 },
.dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c }, .dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c, .fm_rfn = 0 },
.dvbt_7 = { .if_freq = 3800, .std_bits = 0x1d }, .dvbt_7 = { .if_freq = 3800, .std_bits = 0x1d, .fm_rfn = 0 },
.dvbt_8 = { .if_freq = 4300, .std_bits = 0x1e }, .dvbt_8 = { .if_freq = 4300, .std_bits = 0x1e, .fm_rfn = 0 },
.qam_6 = { .if_freq = 4000, .std_bits = 0x1d }, .qam_6 = { .if_freq = 4000, .std_bits = 0x1d, .fm_rfn = 0 },
.qam_8 = { .if_freq = 5000, .std_bits = 0x1f }, .qam_8 = { .if_freq = 5000, .std_bits = 0x1f, .fm_rfn = 0 },
}; };
static struct tda18271_std_map tda18271c2_std_map = { static struct tda18271_std_map tda18271c2_std_map = {
.fm_radio = { .if_freq = 1250, .std_bits = 0x18 }, .fm_radio = { .if_freq = 1250, .std_bits = 0x18, .fm_rfn = 1 },
.atv_b = { .if_freq = 6000, .std_bits = 0x0d }, .atv_b = { .if_freq = 6000, .std_bits = 0x0d, .fm_rfn = 0 },
.atv_dk = { .if_freq = 6900, .std_bits = 0x0e }, .atv_dk = { .if_freq = 6900, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_gh = { .if_freq = 7100, .std_bits = 0x0e }, .atv_gh = { .if_freq = 7100, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_i = { .if_freq = 7250, .std_bits = 0x0e }, .atv_i = { .if_freq = 7250, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_l = { .if_freq = 6900, .std_bits = 0x0e }, .atv_l = { .if_freq = 6900, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_lc = { .if_freq = 1250, .std_bits = 0x0e }, .atv_lc = { .if_freq = 1250, .std_bits = 0x0e, .fm_rfn = 0 },
.atv_mn = { .if_freq = 5400, .std_bits = 0x0c }, .atv_mn = { .if_freq = 5400, .std_bits = 0x0c, .fm_rfn = 0 },
.atsc_6 = { .if_freq = 3250, .std_bits = 0x1c }, .atsc_6 = { .if_freq = 3250, .std_bits = 0x1c, .fm_rfn = 0 },
.dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c }, .dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c, .fm_rfn = 0 },
.dvbt_7 = { .if_freq = 3500, .std_bits = 0x1c }, .dvbt_7 = { .if_freq = 3500, .std_bits = 0x1c, .fm_rfn = 0 },
.dvbt_8 = { .if_freq = 4000, .std_bits = 0x1d }, .dvbt_8 = { .if_freq = 4000, .std_bits = 0x1d, .fm_rfn = 0 },
.qam_6 = { .if_freq = 4000, .std_bits = 0x1d }, .qam_6 = { .if_freq = 4000, .std_bits = 0x1d, .fm_rfn = 0 },
.qam_8 = { .if_freq = 5000, .std_bits = 0x1f }, .qam_8 = { .if_freq = 5000, .std_bits = 0x1f, .fm_rfn = 0 },
}; };
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
struct tda18271_std_map_item { struct tda18271_std_map_item {
u16 if_freq; u16 if_freq;
u8 std_bits; u8 std_bits;
unsigned int fm_rfn:1;
}; };
struct tda18271_std_map { struct tda18271_std_map {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册