mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
V4L/DVB (13218): tda18271: consolidate common code for calibration on startup determination
consolidate common code used to determine if calibration on startup is needed Signed-off-by: Michael Krufky <mkrufky@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
188ea058ff
commit
5881ecfca0
1 changed files with 15 additions and 36 deletions
|
@ -1205,23 +1205,23 @@ static int tda18271_setup_configuration(struct dvb_frontend *fe,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int tda18271_need_cal_on_startup(struct tda18271_config *cfg)
|
||||
{
|
||||
/* tda18271_cal_on_startup == -1 when cal module option is unset */
|
||||
return ((tda18271_cal_on_startup == -1) ?
|
||||
/* honor configuration setting */
|
||||
((cfg) && (cfg->rf_cal_on_startup)) :
|
||||
/* module option overrides configuration setting */
|
||||
(tda18271_cal_on_startup)) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg)
|
||||
{
|
||||
struct tda18271_config *cfg = (struct tda18271_config *) priv_cfg;
|
||||
int rf_cal_on_startup;
|
||||
|
||||
tda18271_setup_configuration(fe, cfg);
|
||||
|
||||
/* tda18271_cal_on_startup == -1 when cal module option is unset */
|
||||
if (tda18271_cal_on_startup == -1) {
|
||||
/* honor configuration setting */
|
||||
rf_cal_on_startup =
|
||||
((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0;
|
||||
} else {
|
||||
/* module option overrides configuration setting */
|
||||
rf_cal_on_startup = tda18271_cal_on_startup;
|
||||
}
|
||||
if (rf_cal_on_startup)
|
||||
if (tda18271_need_cal_on_startup(cfg))
|
||||
tda18271_init(fe);
|
||||
|
||||
return 0;
|
||||
|
@ -1249,7 +1249,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
|
|||
struct tda18271_config *cfg)
|
||||
{
|
||||
struct tda18271_priv *priv = NULL;
|
||||
int instance, rf_cal_on_startup = 0;
|
||||
int instance;
|
||||
|
||||
mutex_lock(&tda18271_list_mutex);
|
||||
|
||||
|
@ -1266,17 +1266,6 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
|
|||
|
||||
tda18271_setup_configuration(fe, cfg);
|
||||
|
||||
/* tda18271_cal_on_startup == -1 when cal
|
||||
* module option is unset */
|
||||
if (tda18271_cal_on_startup == -1) {
|
||||
/* honor attach-time configuration */
|
||||
rf_cal_on_startup =
|
||||
((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0;
|
||||
} else {
|
||||
/* module option overrides attach configuration */
|
||||
rf_cal_on_startup = tda18271_cal_on_startup;
|
||||
}
|
||||
|
||||
priv->cal_initialized = false;
|
||||
mutex_init(&priv->lock);
|
||||
|
||||
|
@ -1289,7 +1278,8 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
|
|||
mutex_lock(&priv->lock);
|
||||
tda18271_init_regs(fe);
|
||||
|
||||
if ((rf_cal_on_startup) && (priv->id == TDA18271HDC2))
|
||||
if ((tda18271_need_cal_on_startup(cfg)) &&
|
||||
(priv->id == TDA18271HDC2))
|
||||
tda18271c2_rf_cal_init(fe);
|
||||
|
||||
mutex_unlock(&priv->lock);
|
||||
|
@ -1313,19 +1303,8 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
|
|||
priv->output_opt = cfg->output_opt;
|
||||
if (cfg->std_map)
|
||||
tda18271_update_std_map(fe, cfg->std_map);
|
||||
|
||||
/* tda18271_cal_on_startup == -1 when cal
|
||||
* module option is unset */
|
||||
if (tda18271_cal_on_startup == -1) {
|
||||
/* honor attach-time configuration */
|
||||
rf_cal_on_startup =
|
||||
(cfg->rf_cal_on_startup) ? 1 : 0;
|
||||
} else {
|
||||
/* module option overrides attach config */
|
||||
rf_cal_on_startup = tda18271_cal_on_startup;
|
||||
}
|
||||
}
|
||||
if (rf_cal_on_startup)
|
||||
if (tda18271_need_cal_on_startup(cfg))
|
||||
tda18271_init(fe);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue