aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda1004x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda1004x.c')
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c55
1 files changed, 18 insertions, 37 deletions
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index b83dafa4e12c..59a2ed614fca 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -47,7 +47,6 @@ enum tda1004x_demod {
47 47
48struct tda1004x_state { 48struct tda1004x_state {
49 struct i2c_adapter* i2c; 49 struct i2c_adapter* i2c;
50 struct dvb_frontend_ops ops;
51 const struct tda1004x_config* config; 50 const struct tda1004x_config* config;
52 struct dvb_frontend frontend; 51 struct dvb_frontend frontend;
53 52
@@ -600,13 +599,6 @@ static int tda10045_init(struct dvb_frontend* fe)
600 599
601 tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC 600 tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
602 601
603 // Init the PLL
604 if (state->config->pll_init) {
605 tda1004x_enable_tuner_i2c(state);
606 state->config->pll_init(fe);
607 tda1004x_disable_tuner_i2c(state);
608 }
609
610 // tda setup 602 // tda setup
611 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer 603 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
612 tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream 604 tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
@@ -635,16 +627,6 @@ static int tda10046_init(struct dvb_frontend* fe)
635 return -EIO; 627 return -EIO;
636 } 628 }
637 629
638 // Init the tuner PLL
639 if (state->config->pll_init) {
640 tda1004x_enable_tuner_i2c(state);
641 if (state->config->pll_init(fe)) {
642 printk(KERN_ERR "tda1004x: pll init failed\n");
643 return -EIO;
644 }
645 tda1004x_disable_tuner_i2c(state);
646 }
647
648 // tda setup 630 // tda setup
649 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer 631 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
650 tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream 632 tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream
@@ -712,12 +694,10 @@ static int tda1004x_set_fe(struct dvb_frontend* fe,
712 } 694 }
713 695
714 // set frequency 696 // set frequency
715 tda1004x_enable_tuner_i2c(state); 697 if (fe->ops.tuner_ops.set_params) {
716 if (state->config->pll_set(fe, fe_params)) { 698 fe->ops.tuner_ops.set_params(fe, fe_params);
717 printk(KERN_ERR "tda1004x: pll set failed\n"); 699 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
718 return -EIO;
719 } 700 }
720 tda1004x_disable_tuner_i2c(state);
721 701
722 // Hardcoded to use auto as much as possible on the TDA10045 as it 702 // Hardcoded to use auto as much as possible on the TDA10045 as it
723 // is very unreliable if AUTO mode is _not_ used. 703 // is very unreliable if AUTO mode is _not_ used.
@@ -1183,16 +1163,6 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1183 break; 1163 break;
1184 1164
1185 case TDA1004X_DEMOD_TDA10046: 1165 case TDA1004X_DEMOD_TDA10046:
1186 if (state->config->pll_sleep != NULL) {
1187 tda1004x_enable_tuner_i2c(state);
1188 state->config->pll_sleep(fe);
1189 if (state->config->if_freq != TDA10046_FREQ_052) {
1190 /* special hack for Philips EUROPA Based boards:
1191 * keep the I2c bridge open for tuner access in analog mode
1192 */
1193 tda1004x_disable_tuner_i2c(state);
1194 }
1195 }
1196 /* set outputs to tristate */ 1166 /* set outputs to tristate */
1197 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff); 1167 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff);
1198 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1); 1168 tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
@@ -1202,6 +1172,17 @@ static int tda1004x_sleep(struct dvb_frontend* fe)
1202 return 0; 1172 return 0;
1203} 1173}
1204 1174
1175static int tda1004x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
1176{
1177 struct tda1004x_state* state = fe->demodulator_priv;
1178
1179 if (enable) {
1180 return tda1004x_enable_tuner_i2c(state);
1181 } else {
1182 return tda1004x_disable_tuner_i2c(state);
1183 }
1184}
1185
1205static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 1186static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
1206{ 1187{
1207 fesettings->min_delay_ms = 800; 1188 fesettings->min_delay_ms = 800;
@@ -1235,6 +1216,7 @@ static struct dvb_frontend_ops tda10045_ops = {
1235 1216
1236 .init = tda10045_init, 1217 .init = tda10045_init,
1237 .sleep = tda1004x_sleep, 1218 .sleep = tda1004x_sleep,
1219 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
1238 1220
1239 .set_frontend = tda1004x_set_fe, 1221 .set_frontend = tda1004x_set_fe,
1240 .get_frontend = tda1004x_get_fe, 1222 .get_frontend = tda1004x_get_fe,
@@ -1260,7 +1242,6 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1260 /* setup the state */ 1242 /* setup the state */
1261 state->config = config; 1243 state->config = config;
1262 state->i2c = i2c; 1244 state->i2c = i2c;
1263 memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
1264 state->demod_type = TDA1004X_DEMOD_TDA10045; 1245 state->demod_type = TDA1004X_DEMOD_TDA10045;
1265 1246
1266 /* check if the demod is there */ 1247 /* check if the demod is there */
@@ -1270,7 +1251,7 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1270 } 1251 }
1271 1252
1272 /* create dvb_frontend */ 1253 /* create dvb_frontend */
1273 state->frontend.ops = &state->ops; 1254 memcpy(&state->frontend.ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
1274 state->frontend.demodulator_priv = state; 1255 state->frontend.demodulator_priv = state;
1275 return &state->frontend; 1256 return &state->frontend;
1276} 1257}
@@ -1293,6 +1274,7 @@ static struct dvb_frontend_ops tda10046_ops = {
1293 1274
1294 .init = tda10046_init, 1275 .init = tda10046_init,
1295 .sleep = tda1004x_sleep, 1276 .sleep = tda1004x_sleep,
1277 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
1296 1278
1297 .set_frontend = tda1004x_set_fe, 1279 .set_frontend = tda1004x_set_fe,
1298 .get_frontend = tda1004x_get_fe, 1280 .get_frontend = tda1004x_get_fe,
@@ -1318,7 +1300,6 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1318 /* setup the state */ 1300 /* setup the state */
1319 state->config = config; 1301 state->config = config;
1320 state->i2c = i2c; 1302 state->i2c = i2c;
1321 memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1322 state->demod_type = TDA1004X_DEMOD_TDA10046; 1303 state->demod_type = TDA1004X_DEMOD_TDA10046;
1323 1304
1324 /* check if the demod is there */ 1305 /* check if the demod is there */
@@ -1328,7 +1309,7 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1328 } 1309 }
1329 1310
1330 /* create dvb_frontend */ 1311 /* create dvb_frontend */
1331 state->frontend.ops = &state->ops; 1312 memcpy(&state->frontend.ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
1332 state->frontend.demodulator_priv = state; 1313 state->frontend.demodulator_priv = state;
1333 return &state->frontend; 1314 return &state->frontend;
1334} 1315}