aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
diff options
context:
space:
mode:
authorPatrick Boettcher <pb@linuxtv.org>2008-03-29 19:49:57 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:56 -0400
commit6394cf53abc0b3a2db9e8b947ef5c77b16861ec8 (patch)
tree6d442ab2e89d17ef963ee840ba50440e225f30cb /drivers/media/dvb/b2c2/flexcop-fe-tuner.c
parent0b5afdd2ea5f52d260d1e42d43fb0fa09ec0da2f (diff)
V4L/DVB (7469): Preparation for supporting new devices, cleanup and saneness
To prepare the support for new device to the flexcop-family some preparation and cleanups was done + some saneness: - created an i2c-adapter for each i2c-port available. Easier usage for devices with several device on different i2c-busses - initialize i2c before doing the eeprom read - changed the way to attach the different frontends, easier to read now - enabled support for i2c-devices having no register address (1-byte access) Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/b2c2/flexcop-fe-tuner.c')
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c111
1 files changed, 64 insertions, 47 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 441ffdf0d9c9..46d6f5d8cd1c 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -183,13 +183,13 @@ static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dv
183 buf[2] = 0x84; /* 0xC4 */ 183 buf[2] = 0x84; /* 0xC4 */
184 buf[3] = 0x08; 184 buf[3] = 0x08;
185 185
186 if (params->frequency < 1500000) buf[3] |= 0x10; 186 if (params->frequency < 1500000)
187 buf[3] |= 0x10;
187 188
188 if (fe->ops.i2c_gate_ctrl) 189 if (fe->ops.i2c_gate_ctrl)
189 fe->ops.i2c_gate_ctrl(fe, 1); 190 fe->ops.i2c_gate_ctrl(fe, 1);
190 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) { 191 if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
191 return -EIO; 192 return -EIO;
192 }
193 return 0; 193 return 0;
194} 194}
195 195
@@ -340,7 +340,7 @@ static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe,
340 340
341 if (fe->ops.i2c_gate_ctrl) 341 if (fe->ops.i2c_gate_ctrl)
342 fe->ops.i2c_gate_ctrl(fe, 1); 342 fe->ops.i2c_gate_ctrl(fe, 1);
343 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) 343 if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
344 return -EIO; 344 return -EIO;
345 return 0; 345 return 0;
346} 346}
@@ -389,10 +389,11 @@ static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe,
389 if (fe->ops.i2c_gate_ctrl) 389 if (fe->ops.i2c_gate_ctrl)
390 fe->ops.i2c_gate_ctrl(fe, 0); 390 fe->ops.i2c_gate_ctrl(fe, 0);
391 deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); 391 deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]);
392 ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_TUNER, 0x61, buf[0], &buf[1], 3); 392 ret = fc->i2c_request(&fc->fc_i2c_adap[2],
393 FC_WRITE, 0x61, buf[0], &buf[1], 3);
393 deb_tuner("tuner write returned: %d\n",ret); 394 deb_tuner("tuner write returned: %d\n",ret);
394 395
395 return 0; 396 return ret;
396} 397}
397 398
398static u8 alps_tdee4_stv0297_inittab[] = { 399static u8 alps_tdee4_stv0297_inittab[] = {
@@ -479,53 +480,67 @@ static struct stv0297_config alps_tdee4_stv0297_config = {
479int flexcop_frontend_init(struct flexcop_device *fc) 480int flexcop_frontend_init(struct flexcop_device *fc)
480{ 481{
481 struct dvb_frontend_ops *ops; 482 struct dvb_frontend_ops *ops;
483 struct i2c_adapter *i2c = &fc->fc_i2c_adap[0].i2c_adap;
482 484
483 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ 485 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
484 if ((fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { 486 fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c);
487 if (fc->fe != NULL) {
485 ops = &fc->fe->ops; 488 ops = &fc->fe->ops;
486 489
487 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; 490 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
488 491
489 ops->set_voltage = flexcop_set_voltage; 492 ops->set_voltage = flexcop_set_voltage;
490 493
491 fc->fe_sleep = ops->sleep; 494 fc->fe_sleep = ops->sleep;
492 ops->sleep = flexcop_sleep; 495 ops->sleep = flexcop_sleep;
496
497 fc->dev_type = FC_SKY;
498 goto fe_found;
499 }
493 500
494 fc->dev_type = FC_SKY;
495 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address);
496 } else
497 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ 501 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
498 if ((fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { 502 fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c);
499 fc->dev_type = FC_AIR_DVB; 503 if (fc->fe != NULL) {
504 fc->dev_type = FC_AIR_DVB;
500 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; 505 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
501 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); 506 goto fe_found;
502 } else 507 }
508
503 /* try the air atsc 2nd generation (nxt2002) */ 509 /* try the air atsc 2nd generation (nxt2002) */
504 if ((fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, &fc->i2c_adap)) != NULL) { 510 fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, i2c);
505 fc->dev_type = FC_AIR_ATSC2; 511 if (fc->fe != NULL) {
512 fc->dev_type = FC_AIR_ATSC2;
506 dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); 513 dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV);
507 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); 514 goto fe_found;
508 } else 515 }
509 /* try the air atsc 3nd generation (lgdt3303) */ 516
510 if ((fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { 517 fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, i2c);
511 fc->dev_type = FC_AIR_ATSC3; 518 if (fc->fe != NULL) {
512 dvb_attach(simple_tuner_attach, fc->fe, 519 fc->dev_type = FC_AIR_ATSC3;
513 &fc->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF); 520 dvb_attach(simple_tuner_attach, fc->fe, i2c, 0x61,
514 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); 521 TUNER_LG_TDVS_H06XF);
515 } else 522 goto fe_found;
523 }
524
516 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ 525 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
517 if ((fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) { 526 fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, i2c);
518 fc->dev_type = FC_AIR_ATSC1; 527 if (fc->fe != NULL) {
519 info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); 528 fc->dev_type = FC_AIR_ATSC1;
520 } else 529 goto fe_found;
530 }
531
521 /* try the cable dvb (stv0297) */ 532 /* try the cable dvb (stv0297) */
522 if ((fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { 533 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c);
523 fc->dev_type = FC_CABLE; 534 if (fc->fe != NULL) {
535 fc->dev_type = FC_CABLE;
524 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 536 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
525 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 537 goto fe_found;
526 } else 538 }
539
527 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 540 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
528 if ((fc->fe = dvb_attach(vp310_mt312_attach, &skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 541 fc->fe = dvb_attach(vp310_mt312_attach,
542 &skystar23_samsung_tbdu18132_config, i2c);
543 if (fc->fe != NULL) {
529 ops = &fc->fe->ops; 544 ops = &fc->fe->ops;
530 545
531 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; 546 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
@@ -539,19 +554,21 @@ int flexcop_frontend_init(struct flexcop_device *fc)
539 ops->sleep = flexcop_sleep; 554 ops->sleep = flexcop_sleep;
540 555
541 fc->dev_type = FC_SKY_OLD; 556 fc->dev_type = FC_SKY_OLD;
542 info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address); 557 goto fe_found;
543 } 558 }
544 559
545 if (fc->fe == NULL) { 560 err("no frontend driver found for this B2C2/FlexCop adapter");
546 err("no frontend driver found for this B2C2/FlexCop adapter"); 561 return -ENODEV;
547 return -ENODEV; 562
548 } else { 563fe_found:
549 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { 564 info("found '%s' .", fc->fe->ops.info.name);
550 err("frontend registration failed!"); 565 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
551 dvb_frontend_detach(fc->fe); 566 err("frontend registration failed!");
552 fc->fe = NULL; 567 ops = &fc->fe->ops;
553 return -EINVAL; 568 if (ops->release != NULL)
554 } 569 ops->release(fc->fe);
570 fc->fe = NULL;
571 return -EINVAL;
555 } 572 }
556 fc->init_state |= FC_STATE_FE_INIT; 573 fc->init_state |= FC_STATE_FE_INIT;
557 return 0; 574 return 0;