changeset 82:cfb2da5ee428

added LNB reference count to maintain power state during recording.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 04 Jan 2010 22:49:18 +0900
parents 6e3bb2c0c5b6
children b8032e8099de
files driver/pt1_pci.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/driver/pt1_pci.c	Sat Dec 12 22:30:43 2009 +0900
+++ b/driver/pt1_pci.c	Mon Jan 04 22:49:18 2010 +0900
@@ -53,6 +53,8 @@
 
 static int debug = 7;			/* 1 normal messages, 0 quiet .. 7 verbose. */
 static int lnb = 0;			/* LNB OFF:0 +11V:1 +15V:2 */
+static int lnb_ref_count = 0;
+struct mutex lnb_mutex;
 
 module_param(debug, int, 0);
 module_param(lnb, int, 0);
@@ -321,7 +323,6 @@
 }
 static int pt1_open(struct inode *inode, struct file *file)
 {
-
 	int		major = imajor(inode);
 	int		minor = iminor(inode);
 	int		lp ;
@@ -523,11 +524,20 @@
 		case LNB_ENABLE:
 			lnb_usr = (int)arg0;
 			lnb_eff = lnb_usr ? lnb_usr : lnb;
+			mutex_lock(&lnb_mutex);
+			lnb_ref_count += 1;
 			settuner_reset(channel->ptr->regs, channel->ptr->cardtype, lnb_eff, TUNER_POWER_ON_RESET_DISABLE);
+			mutex_unlock(&lnb_mutex);
 			printk(KERN_INFO "PT1:LNB = %s\n", voltage[lnb_eff]);
+			printk(KERN_INFO "PT1:LNB ref_count = %d\n", lnb_ref_count);
 			return 0 ;
 		case LNB_DISABLE:
-			settuner_reset(channel->ptr->regs, channel->ptr->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
+			mutex_lock(&lnb_mutex);
+			lnb_ref_count -= 1;
+			if(!lnb_ref_count)
+				settuner_reset(channel->ptr->regs, channel->ptr->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
+			mutex_unlock(&lnb_mutex);
+			printk(KERN_INFO "PT1:LNB ref_count = %d\n", lnb_ref_count);
 			return 0 ;
 	}
 	return -EINVAL;
@@ -708,6 +718,7 @@
 	settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
 	schedule_timeout_interruptible(msecs_to_jiffies(10));
 	mutex_init(&dev_conf->lock);
+	mutex_init(&lnb_mutex);
 
 	// Tuner 初期化処理
 	for(lp = 0 ; lp < MAX_TUNER ; lp++){