diff options
author | Michael Krufky <mkrufky@kernellabs.com> | 2009-10-24 17:37:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:40:57 -0500 |
commit | 5881ecfca058d731758c76018205b5b3dff9291f (patch) | |
tree | 6962f9676a5917596c19d09268b3d74f035ad44f /drivers/media | |
parent | 188ea058ff2e671270273a1f5d13f46ca75b8a35 (diff) |
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>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/common/tuners/tda18271-fe.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index 8b934f48b6f3..cae0df1748f1 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -1205,23 +1205,23 @@ static int tda18271_setup_configuration(struct dvb_frontend *fe, | |||
1205 | return 0; | 1205 | return 0; |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | static inline int tda18271_need_cal_on_startup(struct tda18271_config *cfg) | ||
1209 | { | ||
1210 | /* tda18271_cal_on_startup == -1 when cal module option is unset */ | ||
1211 | return ((tda18271_cal_on_startup == -1) ? | ||
1212 | /* honor configuration setting */ | ||
1213 | ((cfg) && (cfg->rf_cal_on_startup)) : | ||
1214 | /* module option overrides configuration setting */ | ||
1215 | (tda18271_cal_on_startup)) ? 1 : 0; | ||
1216 | } | ||
1217 | |||
1208 | static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg) | 1218 | static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg) |
1209 | { | 1219 | { |
1210 | struct tda18271_config *cfg = (struct tda18271_config *) priv_cfg; | 1220 | struct tda18271_config *cfg = (struct tda18271_config *) priv_cfg; |
1211 | int rf_cal_on_startup; | ||
1212 | 1221 | ||
1213 | tda18271_setup_configuration(fe, cfg); | 1222 | tda18271_setup_configuration(fe, cfg); |
1214 | 1223 | ||
1215 | /* tda18271_cal_on_startup == -1 when cal module option is unset */ | 1224 | if (tda18271_need_cal_on_startup(cfg)) |
1216 | if (tda18271_cal_on_startup == -1) { | ||
1217 | /* honor configuration setting */ | ||
1218 | rf_cal_on_startup = | ||
1219 | ((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0; | ||
1220 | } else { | ||
1221 | /* module option overrides configuration setting */ | ||
1222 | rf_cal_on_startup = tda18271_cal_on_startup; | ||
1223 | } | ||
1224 | if (rf_cal_on_startup) | ||
1225 | tda18271_init(fe); | 1225 | tda18271_init(fe); |
1226 | 1226 | ||
1227 | return 0; | 1227 | return 0; |
@@ -1249,7 +1249,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1249 | struct tda18271_config *cfg) | 1249 | struct tda18271_config *cfg) |
1250 | { | 1250 | { |
1251 | struct tda18271_priv *priv = NULL; | 1251 | struct tda18271_priv *priv = NULL; |
1252 | int instance, rf_cal_on_startup = 0; | 1252 | int instance; |
1253 | 1253 | ||
1254 | mutex_lock(&tda18271_list_mutex); | 1254 | mutex_lock(&tda18271_list_mutex); |
1255 | 1255 | ||
@@ -1266,17 +1266,6 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1266 | 1266 | ||
1267 | tda18271_setup_configuration(fe, cfg); | 1267 | tda18271_setup_configuration(fe, cfg); |
1268 | 1268 | ||
1269 | /* tda18271_cal_on_startup == -1 when cal | ||
1270 | * module option is unset */ | ||
1271 | if (tda18271_cal_on_startup == -1) { | ||
1272 | /* honor attach-time configuration */ | ||
1273 | rf_cal_on_startup = | ||
1274 | ((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0; | ||
1275 | } else { | ||
1276 | /* module option overrides attach configuration */ | ||
1277 | rf_cal_on_startup = tda18271_cal_on_startup; | ||
1278 | } | ||
1279 | |||
1280 | priv->cal_initialized = false; | 1269 | priv->cal_initialized = false; |
1281 | mutex_init(&priv->lock); | 1270 | mutex_init(&priv->lock); |
1282 | 1271 | ||
@@ -1289,7 +1278,8 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1289 | mutex_lock(&priv->lock); | 1278 | mutex_lock(&priv->lock); |
1290 | tda18271_init_regs(fe); | 1279 | tda18271_init_regs(fe); |
1291 | 1280 | ||
1292 | if ((rf_cal_on_startup) && (priv->id == TDA18271HDC2)) | 1281 | if ((tda18271_need_cal_on_startup(cfg)) && |
1282 | (priv->id == TDA18271HDC2)) | ||
1293 | tda18271c2_rf_cal_init(fe); | 1283 | tda18271c2_rf_cal_init(fe); |
1294 | 1284 | ||
1295 | mutex_unlock(&priv->lock); | 1285 | mutex_unlock(&priv->lock); |
@@ -1313,19 +1303,8 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1313 | priv->output_opt = cfg->output_opt; | 1303 | priv->output_opt = cfg->output_opt; |
1314 | if (cfg->std_map) | 1304 | if (cfg->std_map) |
1315 | tda18271_update_std_map(fe, cfg->std_map); | 1305 | tda18271_update_std_map(fe, cfg->std_map); |
1316 | |||
1317 | /* tda18271_cal_on_startup == -1 when cal | ||
1318 | * module option is unset */ | ||
1319 | if (tda18271_cal_on_startup == -1) { | ||
1320 | /* honor attach-time configuration */ | ||
1321 | rf_cal_on_startup = | ||
1322 | (cfg->rf_cal_on_startup) ? 1 : 0; | ||
1323 | } else { | ||
1324 | /* module option overrides attach config */ | ||
1325 | rf_cal_on_startup = tda18271_cal_on_startup; | ||
1326 | } | ||
1327 | } | 1306 | } |
1328 | if (rf_cal_on_startup) | 1307 | if (tda18271_need_cal_on_startup(cfg)) |
1329 | tda18271_init(fe); | 1308 | tda18271_init(fe); |
1330 | break; | 1309 | break; |
1331 | } | 1310 | } |