comparison driver/pt1_pci.c @ 64:98a92ce5382e

added fake support code for PT2. the PT2 part is not expected to work. be careful!
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 22 Oct 2009 02:18:12 +0900
parents c915076353ae
children 272a8fba970b
comparison
equal deleted inserted replaced
63:ca419e61f7f2 64:98a92ce5382e
57 module_param(debug, int, 0); 57 module_param(debug, int, 0);
58 module_param(lnb, int, 0); 58 module_param(lnb, int, 0);
59 MODULE_PARM_DESC(debug, "debug level (1-2)"); 59 MODULE_PARM_DESC(debug, "debug level (1-2)");
60 MODULE_PARM_DESC(debug, "LNB level (0:OFF 1:+11V 2:+15V)"); 60 MODULE_PARM_DESC(debug, "LNB level (0:OFF 1:+11V 2:+15V)");
61 61
62 #define VENDOR_EARTHSOFT 0x10ee
63 #define PCI_PT1_ID 0x211a
64 #define PCI_PT2_ID 0x222a
65
62 static struct pci_device_id pt1_pci_tbl[] = { 66 static struct pci_device_id pt1_pci_tbl[] = {
63 { 0x10ee, 0x211a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 67 { VENDOR_EARTHSOFT, PCI_PT1_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
68 { VENDOR_EARTHSOFT, PCI_PT2_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
64 { 0, } 69 { 0, }
65 }; 70 };
66 MODULE_DEVICE_TABLE(pci, pt1_pci_tbl); 71 MODULE_DEVICE_TABLE(pci, pt1_pci_tbl);
67 #define DEV_NAME "pt1video" 72 #define DEV_NAME "pt1video"
68 73
95 __u32 base_minor ; 100 __u32 base_minor ;
96 struct cdev cdev[MAX_CHANNEL]; 101 struct cdev cdev[MAX_CHANNEL];
97 wait_queue_head_t dma_wait_q ;// for poll on reading 102 wait_queue_head_t dma_wait_q ;// for poll on reading
98 DMA_CONTROL *dmactl[DMA_RING_SIZE]; 103 DMA_CONTROL *dmactl[DMA_RING_SIZE];
99 PT1_CHANNEL *channel[MAX_CHANNEL]; 104 PT1_CHANNEL *channel[MAX_CHANNEL];
100 }PT1_DEVICE; 105 int cardtype;
106 } PT1_DEVICE;
101 107
102 typedef struct _MICRO_PACKET{ 108 typedef struct _MICRO_PACKET{
103 char data[3]; 109 char data[3];
104 char head ; 110 char head ;
105 }MICRO_PACKET; 111 }MICRO_PACKET;
512 } 518 }
513 dummy = copy_to_user(arg, &signal, sizeof(int)); 519 dummy = copy_to_user(arg, &signal, sizeof(int));
514 return 0 ; 520 return 0 ;
515 case LNB_ENABLE: 521 case LNB_ENABLE:
516 if(lnb){ 522 if(lnb){
517 settuner_reset(channel->ptr->regs, lnb, TUNER_POWER_ON_RESET_DISABLE); 523 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, lnb, TUNER_POWER_ON_RESET_DISABLE);
518 } 524 }
519 return 0 ; 525 return 0 ;
520 case LNB_DISABLE: 526 case LNB_DISABLE:
521 if(lnb){ 527 if(lnb){
522 settuner_reset(channel->ptr->regs, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); 528 settuner_reset(channel->ptr->regs, channel->ptr->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
523 } 529 }
524 return 0 ; 530 return 0 ;
525 } 531 }
526 return -EINVAL; 532 return -EINVAL;
527 } 533 }
626 struct resource *dummy; 632 struct resource *dummy;
627 633
628 rc = pci_enable_device(pdev); 634 rc = pci_enable_device(pdev);
629 if (rc) 635 if (rc)
630 return rc; 636 return rc;
631 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 637 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
632 if (rc) { 638 if (rc) {
633 printk(KERN_ERR "PT1:DMA MASK ERROR"); 639 printk(KERN_ERR "PT1:DMA MASK ERROR");
634 return rc; 640 return rc;
635 } 641 }
636 642
661 kfree(dev_conf); 667 kfree(dev_conf);
662 printk(KERN_ERR "PT1:out of memory !"); 668 printk(KERN_ERR "PT1:out of memory !");
663 return -ENOMEM ; 669 return -ENOMEM ;
664 } 670 }
665 } 671 }
672
673 switch(ent->device) {
674 case PCI_PT1_ID:
675 dev_conf->cardtype = PT1;
676 break;
677 case PCI_PT2_ID:
678 dev_conf->cardtype = PT2;
679 break;
680 default:
681 break;
682 }
683
666 // PCIアドレスをマップする 684 // PCIアドレスをマップする
667 dev_conf->mmio_start = pci_resource_start(pdev, 0); 685 dev_conf->mmio_start = pci_resource_start(pdev, 0);
668 dev_conf->mmio_len = pci_resource_len(pdev, 0); 686 dev_conf->mmio_len = pci_resource_len(pdev, 0);
669 dummy = request_mem_region(dev_conf->mmio_start, dev_conf->mmio_len, DEV_NAME); 687 dummy = request_mem_region(dev_conf->mmio_start, dev_conf->mmio_len, DEV_NAME);
670 if (!dummy) { 688 if (!dummy) {
681 if(xc3s_init(dev_conf->regs)){ 699 if(xc3s_init(dev_conf->regs)){
682 printk(KERN_ERR "Error xc3s_init\n"); 700 printk(KERN_ERR "Error xc3s_init\n");
683 goto out_err_fpga; 701 goto out_err_fpga;
684 } 702 }
685 // チューナリセット 703 // チューナリセット
686 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_ON_RESET_ENABLE); 704 settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_ENABLE);
687 schedule_timeout_interruptible(msecs_to_jiffies(50)); 705 schedule_timeout_interruptible(msecs_to_jiffies(50));
688 706
689 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); 707 settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE);
690 schedule_timeout_interruptible(msecs_to_jiffies(10)); 708 schedule_timeout_interruptible(msecs_to_jiffies(10));
691 mutex_init(&dev_conf->lock); 709 mutex_init(&dev_conf->lock);
692 710
693 // Tuner 初期化処理 711 // Tuner 初期化処理
694 for(lp = 0 ; lp < MAX_TUNER ; lp++){ 712 for(lp = 0 ; lp < MAX_TUNER ; lp++){
813 kfree(dev_conf->channel[lp]); 831 kfree(dev_conf->channel[lp]);
814 } 832 }
815 } 833 }
816 out_err_fpga: 834 out_err_fpga:
817 writel(0xb0b0000, dev_conf->regs); 835 writel(0xb0b0000, dev_conf->regs);
818 writel(0, dev_conf->regs + 4); 836 writel(0, dev_conf->regs + CFG_REGS_ADDR);
819 iounmap(dev_conf->regs); 837 iounmap(dev_conf->regs);
820 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len); 838 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len);
821 for (i = 0; i < DMA_RING_SIZE; i++) { 839 for (i = 0; i < DMA_RING_SIZE; i++) {
822 kfree(dev_conf->dmactl[i]); 840 kfree(dev_conf->dmactl[i]);
823 } 841 }
862 (MINOR(dev_conf->dev) + lp))); 880 (MINOR(dev_conf->dev) + lp)));
863 } 881 }
864 882
865 unregister_chrdev_region(dev_conf->dev, MAX_CHANNEL); 883 unregister_chrdev_region(dev_conf->dev, MAX_CHANNEL);
866 writel(0xb0b0000, dev_conf->regs); 884 writel(0xb0b0000, dev_conf->regs);
867 writel(0, dev_conf->regs + 4); 885 writel(0, dev_conf->regs + CFG_REGS_ADDR);
868 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_OFF); 886 settuner_reset(dev_conf->regs, dev_conf->cardtype, LNB_OFF, TUNER_POWER_OFF);
869 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len); 887 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len);
870 iounmap(dev_conf->regs); 888 iounmap(dev_conf->regs);
871 for (i = 0; i < DMA_RING_SIZE; i++) { 889 for (i = 0; i < DMA_RING_SIZE; i++) {
872 kfree(dev_conf->dmactl[i]); 890 kfree(dev_conf->dmactl[i]);
873 } 891 }