diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-10-21 18:39:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:09 -0500 |
commit | 4e9154b8a77d0f0f8f06857162823905612a50d7 (patch) | |
tree | b4aaf7945fe52833168eabc8b581bedc2a774035 /drivers/media/video/tda9887.c | |
parent | 482b498d7a1eb0e445657fb55d2bc6d4871c0ef5 (diff) |
V4L/DVB (6440): tuner: convert analog tuner demod sub-modules to dvb_frontend interface
Convert tda9887 and tda8290/5 to dvb_frontend interface
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tda9887.c')
-rw-r--r-- | drivers/media/video/tda9887.c | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 68b22da7e25b..7663a5579757 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -21,17 +21,19 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #define tda9887_info(fmt, arg...) do {\ | 23 | #define tda9887_info(fmt, arg...) do {\ |
24 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ | 24 | printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ |
25 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) | 25 | i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) |
26 | #define tda9887_dbg(fmt, arg...) do {\ | 26 | #define tda9887_dbg(fmt, arg...) do {\ |
27 | if (tuner_debug) \ | 27 | if (tuner_debug) \ |
28 | printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ | 28 | printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ |
29 | i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) | 29 | i2c_adapter_id(priv->t->i2c.adapter), priv->t->i2c.addr , ##arg); } while (0) |
30 | 30 | ||
31 | struct tda9887_priv { | 31 | struct tda9887_priv { |
32 | struct tuner_i2c_props i2c_props; | 32 | struct tuner_i2c_props i2c_props; |
33 | 33 | ||
34 | unsigned char data[4]; | 34 | unsigned char data[4]; |
35 | |||
36 | struct tuner *t; | ||
35 | }; | 37 | }; |
36 | 38 | ||
37 | /* ---------------------------------------------------------------------- */ | 39 | /* ---------------------------------------------------------------------- */ |
@@ -262,8 +264,10 @@ static struct tvnorm radio_mono = { | |||
262 | 264 | ||
263 | /* ---------------------------------------------------------------------- */ | 265 | /* ---------------------------------------------------------------------- */ |
264 | 266 | ||
265 | static void dump_read_message(struct tuner *t, unsigned char *buf) | 267 | static void dump_read_message(struct dvb_frontend *fe, unsigned char *buf) |
266 | { | 268 | { |
269 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
270 | |||
267 | static char *afc[16] = { | 271 | static char *afc[16] = { |
268 | "- 12.5 kHz", | 272 | "- 12.5 kHz", |
269 | "- 37.5 kHz", | 273 | "- 37.5 kHz", |
@@ -290,8 +294,10 @@ static void dump_read_message(struct tuner *t, unsigned char *buf) | |||
290 | tda9887_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low"); | 294 | tda9887_info(" vfi level : %s\n", (buf[0] & 0x80) ? "high" : "low"); |
291 | } | 295 | } |
292 | 296 | ||
293 | static void dump_write_message(struct tuner *t, unsigned char *buf) | 297 | static void dump_write_message(struct dvb_frontend *fe, unsigned char *buf) |
294 | { | 298 | { |
299 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
300 | |||
295 | static char *sound[4] = { | 301 | static char *sound[4] = { |
296 | "AM/TV", | 302 | "AM/TV", |
297 | "FM/radio", | 303 | "FM/radio", |
@@ -386,9 +392,12 @@ static void dump_write_message(struct tuner *t, unsigned char *buf) | |||
386 | 392 | ||
387 | /* ---------------------------------------------------------------------- */ | 393 | /* ---------------------------------------------------------------------- */ |
388 | 394 | ||
389 | static int tda9887_set_tvnorm(struct tuner *t, char *buf) | 395 | static int tda9887_set_tvnorm(struct dvb_frontend *fe) |
390 | { | 396 | { |
397 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
398 | struct tuner *t = priv->t; | ||
391 | struct tvnorm *norm = NULL; | 399 | struct tvnorm *norm = NULL; |
400 | char *buf = priv->data; | ||
392 | int i; | 401 | int i; |
393 | 402 | ||
394 | if (t->mode == V4L2_TUNER_RADIO) { | 403 | if (t->mode == V4L2_TUNER_RADIO) { |
@@ -426,8 +435,11 @@ module_param(port2, int, 0644); | |||
426 | module_param(qss, int, 0644); | 435 | module_param(qss, int, 0644); |
427 | module_param(adjust, int, 0644); | 436 | module_param(adjust, int, 0644); |
428 | 437 | ||
429 | static int tda9887_set_insmod(struct tuner *t, char *buf) | 438 | static int tda9887_set_insmod(struct dvb_frontend *fe) |
430 | { | 439 | { |
440 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
441 | char *buf = priv->data; | ||
442 | |||
431 | if (UNSET != port1) { | 443 | if (UNSET != port1) { |
432 | if (port1) | 444 | if (port1) |
433 | buf[1] |= cOutputPort1Inactive; | 445 | buf[1] |= cOutputPort1Inactive; |
@@ -455,8 +467,12 @@ static int tda9887_set_insmod(struct tuner *t, char *buf) | |||
455 | return 0; | 467 | return 0; |
456 | } | 468 | } |
457 | 469 | ||
458 | static int tda9887_set_config(struct tuner *t, char *buf) | 470 | static int tda9887_set_config(struct dvb_frontend *fe) |
459 | { | 471 | { |
472 | struct tda9887_priv *priv = fe->analog_demod_priv; | ||
473 | struct tuner *t = priv->t; | ||
474 | char *buf = priv->data; | ||
475 | |||
460 | if (t->tda9887_config & TDA9887_PORT1_ACTIVE) | 476 | if (t->tda9887_config & TDA9887_PORT1_ACTIVE) |
461 | buf[1] &= ~cOutputPort1Inactive; | 477 | buf[1] &= ~cOutputPort1Inactive; |
462 | if (t->tda9887_config & TDA9887_PORT1_INACTIVE) | 478 | if (t->tda9887_config & TDA9887_PORT1_INACTIVE) |
@@ -510,26 +526,27 @@ static int tda9887_set_config(struct tuner *t, char *buf) | |||
510 | 526 | ||
511 | /* ---------------------------------------------------------------------- */ | 527 | /* ---------------------------------------------------------------------- */ |
512 | 528 | ||
513 | static int tda9887_status(struct tuner *t) | 529 | static int tda9887_status(struct dvb_frontend *fe) |
514 | { | 530 | { |
515 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 531 | struct tda9887_priv *priv = fe->analog_demod_priv; |
516 | unsigned char buf[1]; | 532 | unsigned char buf[1]; |
517 | int rc; | 533 | int rc; |
518 | 534 | ||
519 | memset(buf,0,sizeof(buf)); | 535 | memset(buf,0,sizeof(buf)); |
520 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) | 536 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,buf,1))) |
521 | tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); | 537 | tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc); |
522 | dump_read_message(t, buf); | 538 | dump_read_message(fe, buf); |
523 | return 0; | 539 | return 0; |
524 | } | 540 | } |
525 | 541 | ||
526 | static void tda9887_configure(struct tuner *t) | 542 | static void tda9887_configure(struct dvb_frontend *fe) |
527 | { | 543 | { |
528 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 544 | struct tda9887_priv *priv = fe->analog_demod_priv; |
545 | struct tuner *t = priv->t; | ||
529 | int rc; | 546 | int rc; |
530 | 547 | ||
531 | memset(priv->data,0,sizeof(priv->data)); | 548 | memset(priv->data,0,sizeof(priv->data)); |
532 | tda9887_set_tvnorm(t,priv->data); | 549 | tda9887_set_tvnorm(fe); |
533 | 550 | ||
534 | /* A note on the port settings: | 551 | /* A note on the port settings: |
535 | These settings tend to depend on the specifics of the board. | 552 | These settings tend to depend on the specifics of the board. |
@@ -547,8 +564,8 @@ static void tda9887_configure(struct tuner *t) | |||
547 | priv->data[1] |= cOutputPort1Inactive; | 564 | priv->data[1] |= cOutputPort1Inactive; |
548 | priv->data[1] |= cOutputPort2Inactive; | 565 | priv->data[1] |= cOutputPort2Inactive; |
549 | 566 | ||
550 | tda9887_set_config(t,priv->data); | 567 | tda9887_set_config(fe); |
551 | tda9887_set_insmod(t,priv->data); | 568 | tda9887_set_insmod(fe); |
552 | 569 | ||
553 | if (t->mode == T_STANDBY) { | 570 | if (t->mode == T_STANDBY) { |
554 | priv->data[1] |= cForcedMuteAudioON; | 571 | priv->data[1] |= cForcedMuteAudioON; |
@@ -557,28 +574,28 @@ static void tda9887_configure(struct tuner *t) | |||
557 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", | 574 | tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", |
558 | priv->data[1],priv->data[2],priv->data[3]); | 575 | priv->data[1],priv->data[2],priv->data[3]); |
559 | if (tuner_debug > 1) | 576 | if (tuner_debug > 1) |
560 | dump_write_message(t, priv->data); | 577 | dump_write_message(fe, priv->data); |
561 | 578 | ||
562 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4))) | 579 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,priv->data,4))) |
563 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); | 580 | tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); |
564 | 581 | ||
565 | if (tuner_debug > 2) { | 582 | if (tuner_debug > 2) { |
566 | msleep_interruptible(1000); | 583 | msleep_interruptible(1000); |
567 | tda9887_status(t); | 584 | tda9887_status(fe); |
568 | } | 585 | } |
569 | } | 586 | } |
570 | 587 | ||
571 | /* ---------------------------------------------------------------------- */ | 588 | /* ---------------------------------------------------------------------- */ |
572 | 589 | ||
573 | static void tda9887_tuner_status(struct tuner *t) | 590 | static void tda9887_tuner_status(struct dvb_frontend *fe) |
574 | { | 591 | { |
575 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 592 | struct tda9887_priv *priv = fe->analog_demod_priv; |
576 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); | 593 | tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]); |
577 | } | 594 | } |
578 | 595 | ||
579 | static int tda9887_get_afc(struct tuner *t) | 596 | static int tda9887_get_afc(struct dvb_frontend *fe) |
580 | { | 597 | { |
581 | struct tda9887_priv *priv = t->fe.analog_demod_priv; | 598 | struct tda9887_priv *priv = fe->analog_demod_priv; |
582 | static int AFC_BITS_2_kHz[] = { | 599 | static int AFC_BITS_2_kHz[] = { |
583 | -12500, -37500, -62500, -97500, | 600 | -12500, -37500, -62500, -97500, |
584 | -112500, -137500, -162500, -187500, | 601 | -112500, -137500, -162500, -187500, |
@@ -594,20 +611,20 @@ static int tda9887_get_afc(struct tuner *t) | |||
594 | return afc; | 611 | return afc; |
595 | } | 612 | } |
596 | 613 | ||
597 | static void tda9887_standby(struct tuner *t) | 614 | static void tda9887_standby(struct dvb_frontend *fe) |
598 | { | 615 | { |
599 | tda9887_configure(t); | 616 | tda9887_configure(fe); |
600 | } | 617 | } |
601 | 618 | ||
602 | static void tda9887_set_freq(struct tuner *t, unsigned int freq) | 619 | static void tda9887_set_freq(struct dvb_frontend *fe, unsigned int freq) |
603 | { | 620 | { |
604 | tda9887_configure(t); | 621 | tda9887_configure(fe); |
605 | } | 622 | } |
606 | 623 | ||
607 | static void tda9887_release(struct tuner *t) | 624 | static void tda9887_release(struct dvb_frontend *fe) |
608 | { | 625 | { |
609 | kfree(t->fe.analog_demod_priv); | 626 | kfree(fe->analog_demod_priv); |
610 | t->fe.analog_demod_priv = NULL; | 627 | fe->analog_demod_priv = NULL; |
611 | } | 628 | } |
612 | 629 | ||
613 | static struct analog_tuner_ops tda9887_tuner_ops = { | 630 | static struct analog_tuner_ops tda9887_tuner_ops = { |
@@ -630,6 +647,7 @@ int tda9887_tuner_init(struct tuner *t) | |||
630 | 647 | ||
631 | priv->i2c_props.addr = t->i2c.addr; | 648 | priv->i2c_props.addr = t->i2c.addr; |
632 | priv->i2c_props.adap = t->i2c.adapter; | 649 | priv->i2c_props.adap = t->i2c.adapter; |
650 | priv->t = t; | ||
633 | 651 | ||
634 | strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); | 652 | strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); |
635 | 653 | ||