aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-05-08 17:05:16 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-07-18 13:23:29 -0400
commitb7754d74d20b701603eacf587a92ec6f71a302e1 (patch)
tree90c410f5c935196feabc087b5872894ac0db1aac
parent4919c49278b3299c1373912dec9c3d9cf27ec56d (diff)
V4L/DVB (5636): Integrate all users of the fmd1216 tuner with dvb-pll
Enhance the dvb-pll definition of the fmd1216 tuner by adding an init sequence and a sleep sequence. The init sequence sets the AGC control register to 0xa0, selecting the fast time constant and 112 dBuV take-over point. This the recommended value for DVB-T operation. The sleep sequence sets bit P4 (which is believed to turn the analog demodulator on), turns off the tuning voltage, and sets the AGC control register to 0x60 (external AGC voltage, the recommended value for analog operation). The existing dvb-pll users in the cx88 driver, listed below, will gain these init and sleep sequences. CX88_BOARD_HAUPPAUGE_HVR1100 Hauppauge WinTV-HVR1100 DVB-T/Hybrid CX88_BOARD_HAUPPAUGE_HVR1100LP Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profi CX88_BOARD_WINFAST_DTV2000H WinFast DTV2000 H CX88_BOARD_HAUPPAUGE_HVR3000 Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DV CX88_BOARD_HAUPPAUGE_HVR1300 Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encod This non-dvb-pll user in the cx88 driver should only gain the sleep sequence, as it already had an equivalent init sequence. The non-dvb-pll code for this user is removed. X88_BOARD_DNTV_LIVE_DVB_T_PRO digitalnow DNTV Live! DVB-T Pro In these saa7134 driver, these non-dvb-pll users are converted to use dvb-pll: SAA7134_BOARD_MD7134 Medion 7134 SAA7134_BOARD_ASUS_EUROPA2_HYBRID Asus Europa2 OEM The saa7134 functions philips_fmd1216_tuner_init(), philips_fmd1216_tuner_sleep(), and philips_fmd1216_tuner_set_params() are deleted and the dvb-pll versions are used. This should result in equivalent sleep, init, and tuning sequences being sent to the tuner. For the cxusb driver, only one board is effected: USB_PID_MEDION_MD95700 Medion MD95700 This board used dvb_usb_tuner_init_i2c() and dvb_usb_tuner_set_params_i2c() for init and tuning, respectively. These functions are effectively the same as the dvb-pll versions. They call a tuner pass control function defined at the dvb-usb level, but this does not matter, as this card does not have a tuner pass control function (only the dib3000mb does). This board will gain the sleep sequence, while init and tuning should be unchanged. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c10
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c61
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c140
4 files changed, 17 insertions, 202 deletions
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index bac2ae3b4a1f..88aeb2512212 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -354,14 +354,8 @@ static struct mt352_config cxusb_mt352_config = {
354/* Callbacks for DVB USB */ 354/* Callbacks for DVB USB */
355static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) 355static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
356{ 356{
357 u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 357 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
358 adap->pll_addr = 0x61; 358 &dvb_pll_fmd1216me);
359 memcpy(adap->pll_init, bpll, 4);
360 adap->pll_desc = &dvb_pll_fmd1216me;
361
362 adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
363 adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
364
365 return 0; 359 return 0;
366} 360}
367 361
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index fc440b1e2449..9fb4decebd95 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -38,6 +38,12 @@
38 0x50 = AGC Take over point = 103 dBuV */ 38 0x50 = AGC Take over point = 103 dBuV */
39static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 }; 39static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 };
40 40
41/* 0x04 = 166.67 kHz divider
42
43 0x80 = AGC Time constant 50ms Iagc = 9 uA
44 0x20 = AGC Take over point = 112 dBuV */
45static u8 tua603x_agc112[] = { 2, 0x80|0x40|0x18|0x04|0x01, 0x80|0x20 };
46
41struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { 47struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
42 .name = "Thomson dtt7579", 48 .name = "Thomson dtt7579",
43 .min = 177000000, 49 .min = 177000000,
@@ -285,6 +291,8 @@ struct dvb_pll_desc dvb_pll_fmd1216me = {
285 .max = 858000000, 291 .max = 858000000,
286 .iffreq= 36125000, 292 .iffreq= 36125000,
287 .set = fmd1216me_bw, 293 .set = fmd1216me_bw,
294 .initdata = tua603x_agc112,
295 .sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 },
288 .count = 7, 296 .count = 7,
289 .entries = { 297 .entries = {
290 { 143870000, 166667, 0xbc, 0x41 }, 298 { 143870000, 166667, 0xbc, 0x41 },
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 420c25f53bca..affec4674adb 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -221,62 +221,6 @@ static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
221 return 0; 221 return 0;
222} 222}
223 223
224static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
225{
226 struct cx8802_dev *dev= fe->dvb->priv;
227
228 /* this message is to set up ATC and ALC */
229 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
230 struct i2c_msg msg =
231 { .addr = dev->core->pll_addr, .flags = 0,
232 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
233 int err;
234
235 if (fe->ops.i2c_gate_ctrl)
236 fe->ops.i2c_gate_ctrl(fe, 1);
237 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
238 if (err < 0)
239 return err;
240 else
241 return -EREMOTEIO;
242 }
243
244 return 0;
245}
246
247static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
248 struct dvb_frontend_parameters* params)
249{
250 struct cx8802_dev *dev= fe->dvb->priv;
251 u8 buf[4];
252 struct i2c_msg msg =
253 { .addr = dev->core->pll_addr, .flags = 0,
254 .buf = buf, .len = 4 };
255 int err;
256
257 /* Switch PLL to DVB mode */
258 err = philips_fmd1216_pll_init(fe);
259 if (err)
260 return err;
261
262 /* Tune PLL */
263 dvb_pll_configure(dev->core->pll_desc, buf, params);
264 if (fe->ops.i2c_gate_ctrl)
265 fe->ops.i2c_gate_ctrl(fe, 1);
266 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
267
268 printk(KERN_WARNING "cx88-dvb: %s error "
269 "(addr %02x <- %02x, err = %i)\n",
270 __FUNCTION__, dev->core->pll_addr, buf[0], err);
271 if (err < 0)
272 return err;
273 else
274 return -EREMOTEIO;
275 }
276
277 return 0;
278}
279
280static struct mt352_config dntv_live_dvbt_pro_config = { 224static struct mt352_config dntv_live_dvbt_pro_config = {
281 .demod_address = 0x0f, 225 .demod_address = 0x0f,
282 .no_tuner = 1, 226 .no_tuner = 1,
@@ -531,12 +475,11 @@ static int dvb_register(struct cx8802_dev *dev)
531 break; 475 break;
532 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 476 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
533#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) 477#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
534 dev->core->pll_addr = 0x61;
535 dev->core->pll_desc = &dvb_pll_fmd1216me;
536 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 478 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
537 &((struct vp3054_i2c_state *)dev->card_priv)->adap); 479 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
538 if (dev->dvb.frontend != NULL) { 480 if (dev->dvb.frontend != NULL) {
539 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params; 481 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
482 &dev->core->i2c_adap, &dvb_pll_fmd1216me);
540 } 483 }
541#else 484#else
542 printk("%s: built without vp3054 support\n", dev->core->name); 485 printk("%s: built without vp3054 support\n", dev->core->name);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 0d66addde423..3a28b4ca42eb 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -432,135 +432,6 @@ static struct tda1004x_config philips_europa_config = {
432 432
433/* ------------------------------------------------------------------ */ 433/* ------------------------------------------------------------------ */
434 434
435static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
436{
437 struct saa7134_dev *dev = fe->dvb->priv;
438 struct tda1004x_state *state = fe->demodulator_priv;
439 u8 addr = state->config->tuner_address;
440 /* this message is to set up ATC and ALC */
441 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
442 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
443
444 if (fe->ops.i2c_gate_ctrl)
445 fe->ops.i2c_gate_ctrl(fe, 1);
446 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
447 return -EIO;
448 msleep(1);
449
450 return 0;
451}
452
453static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
454{
455 struct saa7134_dev *dev = fe->dvb->priv;
456 struct tda1004x_state *state = fe->demodulator_priv;
457 u8 addr = state->config->tuner_address;
458 /* this message actually turns the tuner back to analog mode */
459 u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
460 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
461
462 if (fe->ops.i2c_gate_ctrl)
463 fe->ops.i2c_gate_ctrl(fe, 1);
464 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
465 msleep(1);
466 fmd1216_init[2] = 0x86;
467 fmd1216_init[3] = 0x54;
468 if (fe->ops.i2c_gate_ctrl)
469 fe->ops.i2c_gate_ctrl(fe, 1);
470 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
471 msleep(1);
472 return 0;
473}
474
475static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
476{
477 struct saa7134_dev *dev = fe->dvb->priv;
478 struct tda1004x_state *state = fe->demodulator_priv;
479 u8 addr = state->config->tuner_address;
480 u8 tuner_buf[4];
481 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
482 sizeof(tuner_buf) };
483 int tuner_frequency = 0;
484 int divider = 0;
485 u8 band, mode, cp;
486
487 /* determine charge pump */
488 tuner_frequency = params->frequency + 36130000;
489 if (tuner_frequency < 87000000)
490 return -EINVAL;
491 /* low band */
492 else if (tuner_frequency < 180000000) {
493 band = 1;
494 mode = 7;
495 cp = 0;
496 } else if (tuner_frequency < 195000000) {
497 band = 1;
498 mode = 6;
499 cp = 1;
500 /* mid band */
501 } else if (tuner_frequency < 366000000) {
502 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
503 band = 10;
504 } else {
505 band = 2;
506 }
507 mode = 7;
508 cp = 0;
509 } else if (tuner_frequency < 478000000) {
510 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
511 band = 10;
512 } else {
513 band = 2;
514 }
515 mode = 6;
516 cp = 1;
517 /* high band */
518 } else if (tuner_frequency < 662000000) {
519 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
520 band = 12;
521 } else {
522 band = 4;
523 }
524 mode = 7;
525 cp = 0;
526 } else if (tuner_frequency < 840000000) {
527 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
528 band = 12;
529 } else {
530 band = 4;
531 }
532 mode = 6;
533 cp = 1;
534 } else {
535 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
536 band = 12;
537 } else {
538 band = 4;
539 }
540 mode = 7;
541 cp = 1;
542
543 }
544 /* calculate divisor */
545 /* ((36166000 + Finput) / 166666) rounded! */
546 divider = (tuner_frequency + 83333) / 166667;
547
548 /* setup tuner buffer */
549 tuner_buf[0] = (divider >> 8) & 0x7f;
550 tuner_buf[1] = divider & 0xff;
551 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
552 tuner_buf[3] = 0x40 | band;
553
554 if (fe->ops.i2c_gate_ctrl)
555 fe->ops.i2c_gate_ctrl(fe, 1);
556 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
557 wprintk("could not write to tuner at addr: 0x%02x\n",
558 addr << 1);
559 return -EIO;
560 }
561 return 0;
562}
563
564static struct tda1004x_config medion_cardbus = { 435static struct tda1004x_config medion_cardbus = {
565 .demod_address = 0x08, 436 .demod_address = 0x08,
566 .invert = 1, 437 .invert = 1,
@@ -992,9 +863,8 @@ static int dvb_init(struct saa7134_dev *dev)
992 &medion_cardbus, 863 &medion_cardbus,
993 &dev->i2c_adap); 864 &dev->i2c_adap);
994 if (dev->dvb.frontend) { 865 if (dev->dvb.frontend) {
995 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 866 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
996 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; 867 &dev->i2c_adap, &dvb_pll_fmd1216me);
997 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
998 } 868 }
999 break; 869 break;
1000 case SAA7134_BOARD_PHILIPS_TOUGH: 870 case SAA7134_BOARD_PHILIPS_TOUGH:
@@ -1123,9 +993,9 @@ static int dvb_init(struct saa7134_dev *dev)
1123 if (dev->dvb.frontend) { 993 if (dev->dvb.frontend) {
1124 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 994 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1125 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 995 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1126 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 996
1127 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; 997 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
1128 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params; 998 &dev->i2c_adap, &dvb_pll_fmd1216me);
1129 } 999 }
1130 break; 1000 break;
1131 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 1001 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: