comparison driver/pt1_pci.c @ 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 f336fd2dcf28
children 015481a6a900
comparison
equal deleted inserted replaced
81:6e3bb2c0c5b6 82:cfb2da5ee428
51 MODULE_DESCRIPTION(DRIVER_DESC); 51 MODULE_DESCRIPTION(DRIVER_DESC);
52 MODULE_LICENSE("GPL"); 52 MODULE_LICENSE("GPL");
53 53
54 static int debug = 7; /* 1 normal messages, 0 quiet .. 7 verbose. */ 54 static int debug = 7; /* 1 normal messages, 0 quiet .. 7 verbose. */
55 static int lnb = 0; /* LNB OFF:0 +11V:1 +15V:2 */ 55 static int lnb = 0; /* LNB OFF:0 +11V:1 +15V:2 */
56 static int lnb_ref_count = 0;
57 struct mutex lnb_mutex;
56 58
57 module_param(debug, int, 0); 59 module_param(debug, int, 0);
58 module_param(lnb, int, 0); 60 module_param(lnb, int, 0);
59 MODULE_PARM_DESC(debug, "debug level (1-2)"); 61 MODULE_PARM_DESC(debug, "debug level (1-2)");
60 MODULE_PARM_DESC(debug, "LNB level (0:OFF 1:+11V 2:+15V)"); 62 MODULE_PARM_DESC(debug, "LNB level (0:OFF 1:+11V 2:+15V)");
319 } 321 }
320 return 0 ; 322 return 0 ;
321 } 323 }
322 static int pt1_open(struct inode *inode, struct file *file) 324 static int pt1_open(struct inode *inode, struct file *file)
323 { 325 {
324
325 int major = imajor(inode); 326 int major = imajor(inode);
326 int minor = iminor(inode); 327 int minor = iminor(inode);
327 int lp ; 328 int lp ;
328 int lp2 ; 329 int lp2 ;
329 PT1_CHANNEL *channel ; 330 PT1_CHANNEL *channel ;
521 dummy = copy_to_user(arg, &signal, sizeof(int)); 522 dummy = copy_to_user(arg, &signal, sizeof(int));
522 return 0 ; 523 return 0 ;
523 case LNB_ENABLE: 524 case LNB_ENABLE:
524 lnb_usr = (int)arg0; 525 lnb_usr = (int)arg0;
525 lnb_eff = lnb_usr ? lnb_usr : lnb; 526 lnb_eff = lnb_usr ? lnb_usr : lnb;
527 mutex_lock(&lnb_mutex);
528 lnb_ref_count += 1;
526 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, lnb_eff, TUNER_POWER_ON_RESET_DISABLE); 529 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, lnb_eff, TUNER_POWER_ON_RESET_DISABLE);
530 mutex_unlock(&lnb_mutex);
527 printk(KERN_INFO "PT1:LNB = %s\n", voltage[lnb_eff]); 531 printk(KERN_INFO "PT1:LNB = %s\n", voltage[lnb_eff]);
532 printk(KERN_INFO "PT1:LNB ref_count = %d\n", lnb_ref_count);
528 return 0 ; 533 return 0 ;
529 case LNB_DISABLE: 534 case LNB_DISABLE:
530 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); 535 mutex_lock(&lnb_mutex);
536 lnb_ref_count -= 1;
537 if(!lnb_ref_count)
538 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
539 mutex_unlock(&lnb_mutex);
540 printk(KERN_INFO "PT1:LNB ref_count = %d\n", lnb_ref_count);
531 return 0 ; 541 return 0 ;
532 } 542 }
533 return -EINVAL; 543 return -EINVAL;
534 } 544 }
535 545
706 schedule_timeout_interruptible(msecs_to_jiffies(50)); 716 schedule_timeout_interruptible(msecs_to_jiffies(50));
707 717
708 settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); 718 settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
709 schedule_timeout_interruptible(msecs_to_jiffies(10)); 719 schedule_timeout_interruptible(msecs_to_jiffies(10));
710 mutex_init(&dev_conf->lock); 720 mutex_init(&dev_conf->lock);
721 mutex_init(&lnb_mutex);
711 722
712 // Tuner 初期化処理 723 // Tuner 初期化処理
713 for(lp = 0 ; lp < MAX_TUNER ; lp++){ 724 for(lp = 0 ; lp < MAX_TUNER ; lp++){
714 rc = tuner_init(dev_conf->regs, dev_conf->cardtype, &dev_conf->lock, lp); 725 rc = tuner_init(dev_conf->regs, dev_conf->cardtype, &dev_conf->lock, lp);
715 if(rc < 0){ 726 if(rc < 0){