aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tda9887.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tda9887.c')
-rw-r--r--drivers/media/video/tda9887.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 106c93b8203f..a0545ba957b0 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -25,10 +25,12 @@ static int debug;
25module_param(debug, int, 0644); 25module_param(debug, int, 0644);
26MODULE_PARM_DESC(debug, "enable verbose debug messages"); 26MODULE_PARM_DESC(debug, "enable verbose debug messages");
27 27
28#define PREFIX "tda9887" 28static DEFINE_MUTEX(tda9887_list_mutex);
29static LIST_HEAD(hybrid_tuner_instance_list);
29 30
30struct tda9887_priv { 31struct tda9887_priv {
31 struct tuner_i2c_props i2c_props; 32 struct tuner_i2c_props i2c_props;
33 struct list_head hybrid_tuner_instance_list;
32 34
33 unsigned char data[4]; 35 unsigned char data[4];
34 unsigned int config; 36 unsigned int config;
@@ -644,7 +646,15 @@ static int tda9887_set_config(struct dvb_frontend *fe, void *priv_cfg)
644 646
645static void tda9887_release(struct dvb_frontend *fe) 647static void tda9887_release(struct dvb_frontend *fe)
646{ 648{
647 kfree(fe->analog_demod_priv); 649 struct tda9887_priv *priv = fe->analog_demod_priv;
650
651 mutex_lock(&tda9887_list_mutex);
652
653 if (priv)
654 hybrid_tuner_release_state(priv);
655
656 mutex_unlock(&tda9887_list_mutex);
657
648 fe->analog_demod_priv = NULL; 658 fe->analog_demod_priv = NULL;
649} 659}
650 660
@@ -665,17 +675,29 @@ struct dvb_frontend *tda9887_attach(struct dvb_frontend *fe,
665 u8 i2c_addr) 675 u8 i2c_addr)
666{ 676{
667 struct tda9887_priv *priv = NULL; 677 struct tda9887_priv *priv = NULL;
678 int instance;
668 679
669 priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); 680 mutex_lock(&tda9887_list_mutex);
670 if (priv == NULL)
671 return NULL;
672 fe->analog_demod_priv = priv;
673 681
674 priv->i2c_props.addr = i2c_addr; 682 instance = hybrid_tuner_request_state(struct tda9887_priv, priv,
675 priv->i2c_props.adap = i2c_adap; 683 hybrid_tuner_instance_list,
676 priv->mode = T_STANDBY; 684 i2c_adap, i2c_addr, "tda9887");
685 switch (instance) {
686 case 0:
687 mutex_unlock(&tda9887_list_mutex);
688 return NULL;
689 break;
690 case 1:
691 fe->analog_demod_priv = priv;
692 priv->mode = T_STANDBY;
693 tuner_info("tda988[5/6/7] found\n");
694 break;
695 default:
696 fe->analog_demod_priv = priv;
697 break;
698 }
677 699
678 tuner_info("tda988[5/6/7] found\n"); 700 mutex_unlock(&tda9887_list_mutex);
679 701
680 memcpy(&fe->ops.analog_ops, &tda9887_ops, 702 memcpy(&fe->ops.analog_ops, &tda9887_ops,
681 sizeof(struct analog_demod_ops)); 703 sizeof(struct analog_demod_ops));