diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-09 00:26:48 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:03:28 -0500 |
commit | ab1660503ac3af7febfcf987648509b484d4feda (patch) | |
tree | 9ca5fbfadf1c4c7a6c227b5deb549d198217720a /drivers/media/video/tda8290.c | |
parent | fa746aee336fedfe25e6945e5967399966948420 (diff) |
V4L/DVB (6785): tda8290: remove dependency on struct tuner
- remove dependency of tda8290 module on struct tuner
- move tuner_foo printk macros from tuner-driver.h into tuner-core.c
- clean up #includes of tuner-i2c.h / tuner-driver.h
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tda8290.c')
-rw-r--r-- | drivers/media/video/tda8290.c | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index a39cb1f9e875..d0d13bc61250 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
@@ -23,12 +23,14 @@ | |||
23 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/videodev.h> | 25 | #include <linux/videodev.h> |
26 | #include "tuner-driver.h" | ||
27 | #include "tuner-i2c.h" | ||
26 | #include "tda8290.h" | 28 | #include "tda8290.h" |
27 | #include "tda827x.h" | 29 | #include "tda827x.h" |
28 | #include "tda18271.h" | 30 | #include "tda18271.h" |
29 | 31 | ||
30 | static int tuner_debug; | 32 | static int debug; |
31 | module_param_named(debug, tuner_debug, int, 0644); | 33 | module_param(debug, int, 0644); |
32 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 34 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
33 | 35 | ||
34 | #define PREFIX "tda8290" | 36 | #define PREFIX "tda8290" |
@@ -50,8 +52,6 @@ struct tda8290_priv { | |||
50 | #define TDA18271 16 | 52 | #define TDA18271 16 |
51 | 53 | ||
52 | struct tda827x_config cfg; | 54 | struct tda827x_config cfg; |
53 | |||
54 | struct tuner *t; | ||
55 | }; | 55 | }; |
56 | 56 | ||
57 | /*---------------------------------------------------------------------*/ | 57 | /*---------------------------------------------------------------------*/ |
@@ -114,7 +114,6 @@ static void set_audio(struct dvb_frontend *fe, | |||
114 | struct analog_parameters *params) | 114 | struct analog_parameters *params) |
115 | { | 115 | { |
116 | struct tda8290_priv *priv = fe->analog_demod_priv; | 116 | struct tda8290_priv *priv = fe->analog_demod_priv; |
117 | struct tuner *t = priv->t; | ||
118 | char* mode; | 117 | char* mode; |
119 | 118 | ||
120 | if (params->std & V4L2_STD_MN) { | 119 | if (params->std & V4L2_STD_MN) { |
@@ -150,7 +149,6 @@ static void tda8290_set_params(struct dvb_frontend *fe, | |||
150 | struct analog_parameters *params) | 149 | struct analog_parameters *params) |
151 | { | 150 | { |
152 | struct tda8290_priv *priv = fe->analog_demod_priv; | 151 | struct tda8290_priv *priv = fe->analog_demod_priv; |
153 | struct tuner *t = priv->t; | ||
154 | 152 | ||
155 | unsigned char soft_reset[] = { 0x00, 0x00 }; | 153 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
156 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; | 154 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; |
@@ -176,7 +174,8 @@ static void tda8290_set_params(struct dvb_frontend *fe, | |||
176 | 174 | ||
177 | set_audio(fe, params); | 175 | set_audio(fe, params); |
178 | 176 | ||
179 | tuner_dbg("tda827xa config is 0x%02x\n", t->config); | 177 | if (priv->cfg.config) |
178 | tuner_dbg("tda827xa config is 0x%02x\n", *priv->cfg.config); | ||
180 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); | 179 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); |
181 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); | 180 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); |
182 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); | 181 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); |
@@ -362,7 +361,6 @@ static void tda8295_set_params(struct dvb_frontend *fe, | |||
362 | struct analog_parameters *params) | 361 | struct analog_parameters *params) |
363 | { | 362 | { |
364 | struct tda8290_priv *priv = fe->analog_demod_priv; | 363 | struct tda8290_priv *priv = fe->analog_demod_priv; |
365 | struct tuner *t = priv->t; | ||
366 | 364 | ||
367 | unsigned char blanking_mode[] = { 0x1d, 0x00 }; | 365 | unsigned char blanking_mode[] = { 0x1d, 0x00 }; |
368 | 366 | ||
@@ -442,13 +440,13 @@ static void tda8295_standby(struct dvb_frontend *fe) | |||
442 | static void tda8290_init_if(struct dvb_frontend *fe) | 440 | static void tda8290_init_if(struct dvb_frontend *fe) |
443 | { | 441 | { |
444 | struct tda8290_priv *priv = fe->analog_demod_priv; | 442 | struct tda8290_priv *priv = fe->analog_demod_priv; |
445 | struct tuner *t = priv->t; | ||
446 | 443 | ||
447 | unsigned char set_VS[] = { 0x30, 0x6F }; | 444 | unsigned char set_VS[] = { 0x30, 0x6F }; |
448 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; | 445 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; |
449 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; | 446 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; |
450 | 447 | ||
451 | if ((t->config == 1) || (t->config == 2)) | 448 | if ((priv->cfg.config) && |
449 | ((*priv->cfg.config == 1) || (*priv->cfg.config == 2))) | ||
452 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); | 450 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); |
453 | else | 451 | else |
454 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); | 452 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); |
@@ -516,7 +514,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) | |||
516 | { | 514 | { |
517 | struct tda8290_priv *priv = fe->analog_demod_priv; | 515 | struct tda8290_priv *priv = fe->analog_demod_priv; |
518 | struct analog_tuner_ops *ops = fe->ops.analog_demod_ops; | 516 | struct analog_tuner_ops *ops = fe->ops.analog_demod_ops; |
519 | struct tuner *t = priv->t; | ||
520 | int i, ret, tuners_found; | 517 | int i, ret, tuners_found; |
521 | u32 tuner_addrs; | 518 | u32 tuner_addrs; |
522 | u8 data; | 519 | u8 data; |
@@ -595,29 +592,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) | |||
595 | 592 | ||
596 | ops->i2c_gate_ctrl(fe, 0); | 593 | ops->i2c_gate_ctrl(fe, 0); |
597 | 594 | ||
598 | switch (priv->ver) { | ||
599 | case TDA8290 | TDA8275: | ||
600 | strlcpy(t->i2c->name, "tda8290+75", sizeof(t->i2c->name)); | ||
601 | break; | ||
602 | case TDA8295 | TDA8275: | ||
603 | strlcpy(t->i2c->name, "tda8295+75", sizeof(t->i2c->name)); | ||
604 | break; | ||
605 | case TDA8290 | TDA8275A: | ||
606 | strlcpy(t->i2c->name, "tda8290+75a", sizeof(t->i2c->name)); | ||
607 | break; | ||
608 | case TDA8295 | TDA8275A: | ||
609 | strlcpy(t->i2c->name, "tda8295+75a", sizeof(t->i2c->name)); | ||
610 | break; | ||
611 | case TDA8290 | TDA18271: | ||
612 | strlcpy(t->i2c->name, "tda8290+18271", sizeof(t->i2c->name)); | ||
613 | break; | ||
614 | case TDA8295 | TDA18271: | ||
615 | strlcpy(t->i2c->name, "tda8295+18271", sizeof(t->i2c->name)); | ||
616 | break; | ||
617 | default: | ||
618 | return -EINVAL; | ||
619 | } | ||
620 | |||
621 | return 0; | 595 | return 0; |
622 | } | 596 | } |
623 | 597 | ||
@@ -631,7 +605,7 @@ static int tda8290_probe(struct tuner_i2c_props *i2c_props) | |||
631 | tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); | 605 | tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); |
632 | 606 | ||
633 | if (tda8290_id[1] == TDA8290_ID) { | 607 | if (tda8290_id[1] == TDA8290_ID) { |
634 | if (tuner_debug) | 608 | if (debug) |
635 | printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", | 609 | printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", |
636 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), | 610 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), |
637 | i2c_props->addr); | 611 | i2c_props->addr); |
@@ -651,7 +625,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props) | |||
651 | tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); | 625 | tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); |
652 | 626 | ||
653 | if (tda8295_id[1] == TDA8295_ID) { | 627 | if (tda8295_id[1] == TDA8295_ID) { |
654 | if (tuner_debug) | 628 | if (debug) |
655 | printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", | 629 | printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", |
656 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), | 630 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), |
657 | i2c_props->addr); | 631 | i2c_props->addr); |
@@ -677,21 +651,24 @@ static struct analog_tuner_ops tda8295_tuner_ops = { | |||
677 | .i2c_gate_ctrl = tda8295_i2c_bridge, | 651 | .i2c_gate_ctrl = tda8295_i2c_bridge, |
678 | }; | 652 | }; |
679 | 653 | ||
680 | int tda829x_attach(struct tuner *t) | 654 | struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, |
655 | struct i2c_adapter *i2c_adap, u8 i2c_addr, | ||
656 | struct tda829x_config *cfg) | ||
681 | { | 657 | { |
682 | struct dvb_frontend *fe = &t->fe; | ||
683 | struct tda8290_priv *priv = NULL; | 658 | struct tda8290_priv *priv = NULL; |
659 | char *name; | ||
684 | 660 | ||
685 | priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); | 661 | priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); |
686 | if (priv == NULL) | 662 | if (priv == NULL) |
687 | return -ENOMEM; | 663 | return NULL; |
688 | fe->analog_demod_priv = priv; | 664 | fe->analog_demod_priv = priv; |
689 | 665 | ||
690 | priv->i2c_props.addr = t->i2c->addr; | 666 | priv->i2c_props.addr = i2c_addr; |
691 | priv->i2c_props.adap = t->i2c->adapter; | 667 | priv->i2c_props.adap = i2c_adap; |
692 | priv->cfg.config = &t->config; | 668 | if (cfg) { |
693 | priv->cfg.tuner_callback = t->tuner_callback; | 669 | priv->cfg.config = cfg->lna_cfg; |
694 | priv->t = t; | 670 | priv->cfg.tuner_callback = cfg->tuner_callback; |
671 | } | ||
695 | 672 | ||
696 | if (tda8290_probe(&priv->i2c_props) == 0) { | 673 | if (tda8290_probe(&priv->i2c_props) == 0) { |
697 | priv->ver = TDA8290; | 674 | priv->ver = TDA8290; |
@@ -706,30 +683,50 @@ int tda829x_attach(struct tuner *t) | |||
706 | if (tda829x_find_tuner(fe) < 0) | 683 | if (tda829x_find_tuner(fe) < 0) |
707 | goto fail; | 684 | goto fail; |
708 | 685 | ||
686 | switch (priv->ver) { | ||
687 | case TDA8290 | TDA8275: | ||
688 | name = "tda8290+75"; | ||
689 | break; | ||
690 | case TDA8295 | TDA8275: | ||
691 | name = "tda8295+75"; | ||
692 | break; | ||
693 | case TDA8290 | TDA8275A: | ||
694 | name = "tda8290+75a"; | ||
695 | break; | ||
696 | case TDA8295 | TDA8275A: | ||
697 | name = "tda8295+75a"; | ||
698 | break; | ||
699 | case TDA8290 | TDA18271: | ||
700 | name = "tda8290+18271"; | ||
701 | break; | ||
702 | case TDA8295 | TDA18271: | ||
703 | name = "tda8295+18271"; | ||
704 | break; | ||
705 | default: | ||
706 | goto fail; | ||
707 | } | ||
708 | tuner_info("type set to %s\n", name); | ||
709 | |||
709 | if (priv->ver & TDA8290) { | 710 | if (priv->ver & TDA8290) { |
710 | tda8290_init_tuner(fe); | 711 | tda8290_init_tuner(fe); |
711 | tda8290_init_if(fe); | 712 | tda8290_init_if(fe); |
712 | } else if (priv->ver & TDA8295) | 713 | } else if (priv->ver & TDA8295) |
713 | tda8295_init_if(fe); | 714 | tda8295_init_if(fe); |
714 | 715 | ||
715 | tuner_info("type set to %s\n", t->i2c->name); | 716 | return fe; |
716 | |||
717 | t->mode = V4L2_TUNER_ANALOG_TV; | ||
718 | |||
719 | return 0; | ||
720 | 717 | ||
721 | fail: | 718 | fail: |
722 | tda829x_release(fe); | 719 | tda829x_release(fe); |
723 | fe->ops.analog_demod_ops = NULL; | 720 | fe->ops.analog_demod_ops = NULL; |
724 | return -EINVAL; | 721 | return NULL; |
725 | } | 722 | } |
726 | EXPORT_SYMBOL_GPL(tda829x_attach); | 723 | EXPORT_SYMBOL_GPL(tda829x_attach); |
727 | 724 | ||
728 | int tda829x_probe(struct tuner *t) | 725 | int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) |
729 | { | 726 | { |
730 | struct tuner_i2c_props i2c_props = { | 727 | struct tuner_i2c_props i2c_props = { |
731 | .adap = t->i2c->adapter, | 728 | .adap = i2c_adap, |
732 | .addr = t->i2c->addr | 729 | .addr = i2c_addr, |
733 | }; | 730 | }; |
734 | 731 | ||
735 | unsigned char soft_reset[] = { 0x00, 0x00 }; | 732 | unsigned char soft_reset[] = { 0x00, 0x00 }; |