V4L/DVB (11992): Add missing __devexit_p()
[linux-2.6.git] / drivers / media / dvb / bt8xx / bt878.c
index 3c5a8e2..a24c125 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card
  *
- * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de>
+ * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
  *
  * large parts based on the bttv driver
  * Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@metzlerbros.de)
@@ -28,7 +28,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <asm/io.h>
@@ -63,8 +62,6 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging, default is 0 (off).");
 int bt878_num;
 struct bt878 bt878[BT878_MAX];
 
-EXPORT_SYMBOL(bt878_debug);
-EXPORT_SYMBOL(bt878_verbose);
 EXPORT_SYMBOL(bt878_num);
 EXPORT_SYMBOL(bt878);
 
@@ -78,7 +75,11 @@ EXPORT_SYMBOL(bt878);
 #if defined(dprintk)
 #undef dprintk
 #endif
-#define dprintk if(bt878_debug) printk
+#define dprintk(fmt, arg...) \
+       do { \
+               if (bt878_debug) \
+                       printk(KERN_DEBUG fmt, ##arg); \
+       } while (0)
 
 static void bt878_mem_free(struct bt878 *bt)
 {
@@ -157,7 +158,7 @@ static int bt878_make_risc(struct bt878 *bt)
        }
 
        if (bt->line_count > 255) {
-               printk("bt878: buffer size error!\n");
+               printk(KERN_ERR "bt878: buffer size error!\n");
                return -EINVAL;
        }
        return 0;
@@ -219,7 +220,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
        controlreg &= ~0x1f;
        controlreg |= 0x1b;
 
-       btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START);
+       btwrite(bt->risc_dma, BT878_ARISC_START);
 
        /* original int mask had :
         *    6    2    8    4    0
@@ -268,7 +269,7 @@ EXPORT_SYMBOL(bt878_stop);
 /* Interrupt service routine */
 /*****************************/
 
-static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t bt878_irq(int irq, void *dev_id)
 {
        u32 stat, astat, mask;
        int count;
@@ -283,12 +284,13 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                if (!(astat = (stat & mask)))
                        return IRQ_NONE;        /* this interrupt is not for me */
 /*             dprintk("bt878(%d) debug: irq count %d, stat 0x%8.8x, mask 0x%8.8x\n",bt->nr,count,stat,mask); */
-               btwrite(astat, BT878_AINT_STAT);        /* try to clear interupt condition */
+               btwrite(astat, BT878_AINT_STAT);        /* try to clear interrupt condition */
 
 
                if (astat & (BT878_ASCERR | BT878_AOCERR)) {
                        if (bt878_verbose) {
-                               printk("bt878(%d): irq%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                      "bt878(%d): irq%s%s risc_pc=%08x\n",
                                       bt->nr,
                                       (astat & BT878_ASCERR) ? " SCERR" :
                                       "",
@@ -298,8 +300,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                }
                if (astat & (BT878_APABORT | BT878_ARIPERR | BT878_APPERR)) {
                        if (bt878_verbose) {
-                               printk
-                                   ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                    "bt878(%d): irq%s%s%s risc_pc=%08x\n",
                                     bt->nr,
                                     (astat & BT878_APABORT) ? " PABORT" :
                                     "",
@@ -311,8 +313,8 @@ static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
                }
                if (astat & (BT878_AFDSR | BT878_AFTRGT | BT878_AFBUS)) {
                        if (bt878_verbose) {
-                               printk
-                                   ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
+                               printk(KERN_INFO
+                                    "bt878(%d): irq%s%s%s risc_pc=%08x\n",
                                     bt->nr,
                                     (astat & BT878_AFDSR) ? " FDSR" : "",
                                     (astat & BT878_AFTRGT) ? " FTRGT" :
@@ -344,7 +346,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
        int retval;
 
        retval = 0;
-       if (down_interruptible (&bt->gpio_lock))
+       if (mutex_lock_interruptible(&bt->gpio_lock))
                return -ERESTARTSYS;
        /* special gpio signal */
        switch (cmd) {
@@ -375,12 +377,44 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
                retval = -EINVAL;
                break;
        }
-       up(&bt->gpio_lock);
+       mutex_unlock(&bt->gpio_lock);
        return retval;
 }
 
 EXPORT_SYMBOL(bt878_device_control);
 
+#define BROOKTREE_878_DEVICE(vend, dev, name) \
+       { \
+               .vendor = PCI_VENDOR_ID_BROOKTREE, \
+               .device = PCI_DEVICE_ID_BROOKTREE_878, \
+               .subvendor = (vend), .subdevice = (dev), \
+               .driver_data = (unsigned long) name \
+       }
+
+static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
+       BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"),
+       BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"),
+       BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"),
+       BROOKTREE_878_DEVICE(0x11bd, 0x0026, "Pinnacle PCTV SAT CI"),
+       BROOKTREE_878_DEVICE(0x1822, 0x0001, "Twinhan VisionPlus DVB"),
+       BROOKTREE_878_DEVICE(0x270f, 0xfc00,
+                               "ChainTech digitop DST-1000 DVB-S"),
+       BROOKTREE_878_DEVICE(0x1461, 0x0771, "AVermedia AverTV DVB-T 771"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xdb10, "DViCO FusionHDTV DVB-T Lite"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xdb11, "Ultraview DVB-T Lite"),
+       BROOKTREE_878_DEVICE(0x18ac, 0xd500, "DViCO FusionHDTV 5 Lite"),
+       BROOKTREE_878_DEVICE(0x7063, 0x2000, "pcHDTV HD-2000 TV"),
+       BROOKTREE_878_DEVICE(0x1822, 0x0026, "DNTV Live! Mini"),
+       { }
+};
+
+MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
+
+static const char * __devinit card_name(const struct pci_device_id *id)
+{
+       return id->driver_data ? (const char *)id->driver_data : "Unknown";
+}
+
 /***********************/
 /* PCI device handling */
 /***********************/
@@ -388,18 +422,30 @@ EXPORT_SYMBOL(bt878_device_control);
 static int __devinit bt878_probe(struct pci_dev *dev,
                                 const struct pci_device_id *pci_id)
 {
-       int result;
+       int result = 0;
        unsigned char lat;
        struct bt878 *bt;
 #if defined(__powerpc__)
        unsigned int cmd;
 #endif
+       unsigned int cardid;
 
        printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n",
               bt878_num);
+       if (bt878_num >= BT878_MAX) {
+               printk(KERN_ERR "bt878: Too many devices inserted\n");
+               result = -ENOMEM;
+               goto fail0;
+       }
        if (pci_enable_device(dev))
                return -EIO;
 
+       cardid = dev->subsystem_device << 16;
+       cardid |= dev->subsystem_vendor;
+
+       printk(KERN_INFO "%s: card id=[0x%x],[ %s ] has DVB functions.\n",
+                               __func__, cardid, card_name(pci_id));
+
        bt = &bt878[bt878_num];
        bt->dev = dev;
        bt->nr = bt878_num;
@@ -416,6 +462,8 @@ static int __devinit bt878_probe(struct pci_dev *dev,
 
        pci_read_config_byte(dev, PCI_CLASS_REVISION, &bt->revision);
        pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+
+
        printk(KERN_INFO "bt878(%d): Bt%x (rev %d) at %02x:%02x.%x, ",
               bt878_num, bt->id, bt->revision, dev->bus->number,
               PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
@@ -441,7 +489,7 @@ static int __devinit bt878_probe(struct pci_dev *dev,
        btwrite(0, BT848_INT_MASK);
 
        result = request_irq(bt->irq, bt878_irq,
-                            SA_SHIRQ | SA_INTERRUPT, "bt878",
+                            IRQF_SHARED | IRQF_DISABLED, "bt878",
                             (void *) bt);
        if (result == -EINVAL) {
                printk(KERN_ERR "bt878(%d): Bad irq number or handler\n",
@@ -460,14 +508,8 @@ static int __devinit bt878_probe(struct pci_dev *dev,
        pci_set_master(dev);
        pci_set_drvdata(dev, bt);
 
-/*        if(init_bt878(btv) < 0) {
-               bt878_remove(dev);
-               return -EIO;
-       }
-*/
-
        if ((result = bt878_mem_alloc(bt))) {
-               printk("bt878: failed to allocate memory!\n");
+               printk(KERN_ERR "bt878: failed to allocate memory!\n");
                goto fail2;
        }
 
@@ -493,7 +535,7 @@ static void __devexit bt878_remove(struct pci_dev *pci_dev)
        struct bt878 *bt = pci_get_drvdata(pci_dev);
 
        if (bt878_verbose)
-               printk("bt878(%d): unloading\n", bt->nr);
+               printk(KERN_INFO "bt878(%d): unloading\n", bt->nr);
 
        /* turn off all capturing, DMA and IRQs */
        btand(~0x13, BT878_AGPIO_DMA_CTL);
@@ -527,22 +569,14 @@ static void __devexit bt878_remove(struct pci_dev *pci_dev)
        return;
 }
 
-static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
-       {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BROOKTREE_878,
-        PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       {0,}
-};
-
-MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
-
 static struct pci_driver bt878_pci_driver = {
       .name    = "bt878",
       .id_table = bt878_pci_tbl,
       .probe   = bt878_probe,
-      .remove  = bt878_remove,
+      .remove  = __devexit_p(bt878_remove),
 };
 
-static int bt878_pci_driver_registered = 0;
+static int bt878_pci_driver_registered;
 
 /*******************************/
 /* Module management functions */