[PATCH] bttv driver II

From: Rui Sousa (rsousa@grad.physics.sunysb.edu)
Date: Mon May 22 2000 - 03:21:19 EST


And now... the patch. (sigh)

I will also post it at:

http://grad.physics.sunysb.edu/~rsousa/code/bttv

Rui Sousa

diff -ur linux-2.3/drivers/char/Config.in linux-2.3.new/drivers/char/Config.in
--- linux-2.3/drivers/char/Config.in Sun May 21 15:28:37 2000
+++ linux-2.3.new/drivers/char/Config.in Mon May 22 02:54:25 2000
@@ -205,7 +205,7 @@
    fi
    comment 'Video Adapters'
    if [ "$CONFIG_I2C_ALGOBIT" = "y" -o "$CONFIG_I2C_ALGOBIT" = "m" ]; then
- dep_tristate ' BT848 Video For Linux' CONFIG_VIDEO_BT848 $CONFIG_VIDEO_DEV $CONFIG_PCI $CONFIG_I2C_ALGOBIT
+ dep_tristate ' BT848 Video For Linux' CONFIG_VIDEO_BT848 $CONFIG_VIDEO_DEV $CONFIG_PCI $CONFIG_I2C_ALGOBIT $CONFIG_SOUND
    fi
    dep_tristate ' Mediavision Pro Movie Studio Video For Linux' CONFIG_VIDEO_PMS $CONFIG_VIDEO_DEV
    if [ "$CONFIG_ALL_PPC" = "y" ]; then
diff -ur linux-2.3/drivers/char/bttv.c linux-2.3.new/drivers/char/bttv.c
--- linux-2.3/drivers/char/bttv.c Sun May 21 16:18:52 2000
+++ linux-2.3.new/drivers/char/bttv.c Mon May 22 02:38:45 2000
@@ -43,12 +43,13 @@
 #include <linux/interrupt.h>
 #include <linux/kmod.h>
 #include <linux/vmalloc.h>
+#include <linux/init.h>
 
 #include "bttv.h"
 #include "tuner.h"
 
-#define DEBUG(x) /* Debug driver */
-#define IDEBUG(x) /* Debug interrupt handler */
+#define DEBUG(x) /* Debug driver */
+#define IDEBUG(x) /* Debug interrupt handler */
 #define MIN(a,b) (((a)>(b))?(b):(a))
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
@@ -466,7 +467,7 @@
         NULL
 };
 
-static int init_bttv_i2c(struct bttv *btv)
+static int __init init_bttv_i2c(struct bttv *btv)
 {
         /* i2c bit_adapter */
         memcpy(&btv->i2c_adap, &i2c_adap_template, sizeof(struct i2c_adapter));
@@ -488,7 +489,7 @@
 }
 
 /* read I2C */
-static int I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
+static int __init I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
 {
         unsigned char buffer = 0;
 
@@ -513,7 +514,7 @@
 }
 
 /* write I2C */
-static int I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
+static int __init I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
                     unsigned char b2, int both)
 {
         unsigned char buffer[2];
@@ -530,7 +531,7 @@
 }
 
 /* read EEPROM */
-static void readee(struct bttv *btv, unsigned char *eedata, int addr)
+static void __init readee(struct bttv *btv, unsigned char *eedata, int addr)
 {
         int i;
         
@@ -557,7 +558,7 @@
         int id;
         char *name;
 }
-hauppauge_tuner[] =
+hauppauge_tuner[] __initdata =
 {
         { TUNER_ABSENT, "" },
         { TUNER_ABSENT, "External" },
@@ -605,8 +606,7 @@
         { TUNER_ABSENT, "Temic 4046FM5" },
 };
 
-static void
-hauppauge_eeprom(struct bttv *btv)
+static void __init hauppauge_eeprom(struct bttv *btv)
 {
         if (eeprom_data[9] < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER))
         {
@@ -615,10 +615,11 @@
                         printk("bttv%d: Hauppauge eeprom: tuner=%s (%d)\n",btv->nr,
                                hauppauge_tuner[eeprom_data[9]].name,btv->tuner_type);
         }
+
+ return;
 }
 
-static void
-hauppauge_boot_msp34xx(struct bttv *btv)
+static void __init hauppauge_boot_msp34xx(struct bttv *btv)
 {
         int i;
 
@@ -654,7 +655,7 @@
 /* This is basically the same procedure as
  * used by Alessandro Rubini in his pxc200
  * driver, but using BTTV functions */
-static void init_PXC200(struct bttv *btv)
+static void __init init_PXC200(struct bttv *btv)
 {
         static const int vals[] = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,
                                     0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
@@ -704,7 +705,7 @@
         unsigned id;
         int cardnr;
         char *name;
-} cards[] = {
+} cards[] __initdata = {
         { 0x00011002, BTTV_HAUPPAUGE878, "ATI TV Wonder" },
         { 0x00011461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
         { 0x00031461, BTTV_AVPHONE98, "AVerMedia TVPhone98" },
@@ -912,8 +913,7 @@
 };
 #define TVCARDS (sizeof(tvcards)/sizeof(struct tvcard))
 
-static void
-dump_eeprom(struct bttv *btv,int addr)
+static void __init dump_eeprom(struct bttv *btv,int addr)
 {
         int i;
 
@@ -930,8 +930,7 @@
         }
 }
 
-static int
-idcard_eeprom(struct bttv *btv)
+static int __init idcard_eeprom(struct bttv *btv)
 {
         unsigned id;
         int i,n;
@@ -1737,8 +1736,7 @@
         struct tvnorm *tvn;
         unsigned long flags;
          
- save_flags(flags);
- cli();
+ spin_lock_irqsave(&btv->s_lock, flags);
 
         tvn=&tvnorms[btv->win.norm];
         
@@ -1792,7 +1790,7 @@
         btwrite(format, BT848_COLOR_FMT);
         btwrite(bswap | BT848_COLOR_CTL_GAMMA, BT848_COLOR_CTL);
 
- restore_flags(flags);
+ spin_unlock_irqrestore(&btv->s_lock, flags);
 }
 
 
@@ -1856,6 +1854,7 @@
 {
         unsigned int *ro, *re;
         unsigned int *vbuf;
+ unsigned long flags;
         
         if(btv->fbuffer==NULL)
         {
@@ -1891,7 +1890,7 @@
         if (debug)
                 printk("bttv%d: cap vgrab: queue %d (%d:%dx%d)\n",
                        btv->nr,mp->frame,mp->format,mp->width,mp->height);
- cli();
+ spin_lock_irqsave(&btv->s_lock, flags);
         btv->gbuf[mp->frame].stat = GBUFFER_GRABBING;
         btv->gbuf[mp->frame].fmt = palette2fmt[mp->format];
         btv->gbuf[mp->frame].width = mp->width;
@@ -1912,7 +1911,7 @@
         btv->gqueue[btv->gq_in++] = mp->frame;
         btv->gq_in = btv->gq_in % MAX_GBUFFERS;
 
- sti();
+ spin_unlock_irqrestore(&btv->s_lock, flags);
         btor(3, BT848_CAP_CTL);
         btor(3, BT848_GPIO_DMA_CTL);
         return 0;
@@ -1933,23 +1932,25 @@
         todo=count;
         while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
         {
+ unsigned long flags;
+
                 if(copy_to_user((void *) buf, (void *) btv->vbibuf+btv->vbip, q))
                         return -EFAULT;
                 todo-=q;
                 buf+=q;
 
- cli();
+ spin_lock_irqsave(&btv->s_lock, flags);
                 if (todo && q==VBIBUF_SIZE-btv->vbip)
                 {
                         if(nonblock)
                         {
- sti();
+ spin_unlock_irqrestore(&btv->s_lock, flags);
                                 if(count==todo)
                                         return -EWOULDBLOCK;
                                 return count-todo;
                         }
+ spin_unlock_irqrestore(&btv->s_lock, flags);
                         interruptible_sleep_on(&btv->vbiq);
- sti();
                         if(signal_pending(current))
                         {
                                 if(todo==count)
@@ -1957,7 +1958,8 @@
                                 else
                                         return count-todo;
                         }
- }
+ } else
+ spin_unlock_irqrestore(&btv->s_lock, flags);
         }
         if (todo)
         {
@@ -1980,7 +1982,7 @@
 {
         if (verbose)
                 printk("bttv%d: resetting chip\n",btv->nr);
- btwrite(0xfffffUL, BT848_INT_STAT);
+ btwrite(~0x0UL, BT848_INT_STAT);
         btand(~15, BT848_GPIO_DMA_CTL);
         btwrite(0, BT848_SRESET);
         btwrite(virt_to_bus(btv->risc_jmp+2),
@@ -2006,6 +2008,8 @@
         int i,ret;
 
         ret = -EBUSY;
+
+ MOD_INC_USE_COUNT;
         down(&btv->lock);
         if (btv->user)
                 goto out_unlock;
@@ -2027,11 +2031,11 @@
         set_pll(btv);
         btv->user++;
         up(&btv->lock);
- MOD_INC_USE_COUNT;
         return 0;
 
  out_unlock:
         up(&btv->lock);
+ MOD_DEC_USE_COUNT;
         return ret;
 }
 
@@ -2749,6 +2753,8 @@
         todo=count;
         while (todo && todo>(q=VBIBUF_SIZE-btv->vbip))
         {
+ unsigned long flags;
+
                 if (btv->needs_restart) {
                         down(&btv->lock);
                         bt848_restart(btv);
@@ -2759,18 +2765,18 @@
                 todo-=q;
                 buf+=q;
 
- cli();
+ spin_lock_irqsave(&btv->s_lock, flags);
                 if (todo && q==VBIBUF_SIZE-btv->vbip)
                 {
                         if(nonblock)
                         {
- sti();
+ spin_unlock_irqrestore(&btv->s_lock, flags);
                                 if(count==todo)
                                         return -EWOULDBLOCK;
                                 return count-todo;
                         }
+ spin_unlock_irqrestore(&btv->s_lock, flags);
                         interruptible_sleep_on(&btv->vbiq);
- sti();
                         if(signal_pending(current))
                         {
                                 if(todo==count)
@@ -2778,7 +2784,8 @@
                                 else
                                         return count-todo;
                         }
- }
+ } else
+ spin_unlock_irqrestore(&btv->s_lock, flags);
         }
         if (todo)
         {
@@ -2807,6 +2814,8 @@
 {
         struct bttv *btv=(struct bttv *)(dev-2);
 
+ MOD_INC_USE_COUNT;
+
         down(&btv->lock);
         if (btv->needs_restart)
                 bt848_restart(btv);
@@ -2815,7 +2824,6 @@
         bt848_set_risc_jmps(btv,-1);
         up(&btv->lock);
 
- MOD_INC_USE_COUNT;
         return 0;
 }
 
@@ -2887,6 +2895,7 @@
         struct bttv *btv = (struct bttv *)(dev-1);
         unsigned long v;
 
+ MOD_INC_USE_COUNT;
         down(&btv->lock);
         if (btv->user)
                 goto busy_unlock;
@@ -2899,11 +2908,11 @@
         bt848_muxsel(btv,0);
         up(&btv->lock);
 
- MOD_INC_USE_COUNT;
         return 0;
 
  busy_unlock:
         up(&btv->lock);
+ MOD_DEC_USE_COUNT;
         return -EBUSY;
 }
 
@@ -3009,7 +3018,7 @@
 #define TRITON_PEER_CONCURRENCY (1<<3)
   
 
-static void handle_chipset(void)
+static void __init handle_chipset(void)
 {
         struct pci_dev *dev = NULL;
   
@@ -3041,7 +3050,7 @@
 
 
 /* can tda9855.c handle this too maybe? */
-static void init_tda9840(struct bttv *btv)
+static void __init init_tda9840(struct bttv *btv)
 {
         /* Horrible Hack */
         I2CWrite(btv, I2C_TDA9840, TDA9840_SW, 0x2a, 1); /* sound mode switching */
@@ -3057,17 +3066,16 @@
 
 /* Figure out card and tuner type */
 
-static void idcard(int i)
+static void __init idcard(struct bttv *btv)
 {
- struct bttv *btv = &bttvs[i];
         int type,eeprom = 0;
 
         btwrite(0, BT848_GPIO_OUT_EN);
- DEBUG(printk(KERN_DEBUG "bttv%d: GPIO: 0x%08x\n", i, btread(BT848_GPIO_DATA)));
+ DEBUG(printk(KERN_DEBUG "bttv%d: GPIO: 0x%08x\n", btv->nr, btread(BT848_GPIO_DATA)));
 
         /* Default the card to the user-selected one. */
- if (card[i] >= 0 && card[i] < TVCARDS)
- btv->type=card[i];
+ if (card[btv->nr] >= 0 && card[btv->nr] < TVCARDS)
+ btv->type=card[btv->nr];
 
         /* If we were asked to auto-detect, then do so! */
         if (btv->type == BTTV_UNKNOWN) {
@@ -3220,6 +3228,10 @@
 
 static void bt848_set_risc_jmps(struct bttv *btv, int flags)
 {
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&btv->s_lock, irq_flags);
+
         if (-1 == flags) {
                 /* defaults */
                 flags = 0;
@@ -3306,18 +3318,17 @@
                 bt848_dma(btv, 3);
         else
                 bt848_dma(btv, 0);
+
+ spin_unlock_irqrestore(&btv->s_lock, irq_flags);
 }
 
-static int
-init_video_dev(struct bttv *btv)
+static int __init init_video_dev(struct bttv *btv)
 {
- int num = btv - bttvs;
-
         memcpy(&btv->video_dev,&bttv_template, sizeof(bttv_template));
         memcpy(&btv->vbi_dev,&vbi_template, sizeof(vbi_template));
         memcpy(&btv->radio_dev,&radio_template,sizeof(radio_template));
         
- idcard(num);
+ idcard(btv);
         
         if(video_register_device(&btv->video_dev,VFL_TYPE_GRABBER)<0)
                 return -1;
@@ -3326,7 +3337,7 @@
                 video_unregister_device(&btv->video_dev);
                 return -1;
         }
- if (radio[num])
+ if (radio[btv->nr])
         {
                 if(video_register_device(&btv->radio_dev, VFL_TYPE_RADIO)<0)
                 {
@@ -3338,9 +3349,8 @@
         return 1;
 }
 
-static int init_bt848(int i)
+static int __init init_bt848(struct bttv *btv)
 {
- struct bttv *btv = &bttvs[i];
         int j;
 
         btv->user=0;
@@ -3350,14 +3360,14 @@
          * might help to make a new card work */
         if (verbose >= 2)
                 printk("bttv%d: gpio: out_enable=0x%x, data=0x%x, in=0x%x\n",
- i,
+ btv->nr,
                        btread(BT848_GPIO_OUT_EN),
                        btread(BT848_GPIO_DATA),
                        btread(BT848_GPIO_REG_INP));
 
         /* reset the bt848 */
         btwrite(0, BT848_SRESET);
- DEBUG(printk(KERN_DEBUG "bttv%d: bt848_mem: 0x%lx\n",i,(unsigned long) btv->bt848_mem));
+ DEBUG(printk(KERN_DEBUG "bttv%d: bt848_mem: 0x%lx\n", btv->nr, (unsigned long) btv->bt848_mem));
 
         /* not registered yet */
         btv->video_dev.minor = -1;
@@ -3465,7 +3475,7 @@
         btwrite(0x00, BT848_O_SCLOOP);
 
         /* clear interrupt status */
- btwrite(0xfffffUL, BT848_INT_STAT);
+ btwrite(~0x0UL, BT848_INT_STAT);
         
         /* set interrupt mask */
         btwrite(btv->triton1|
@@ -3505,7 +3515,6 @@
                 astat=stat&btread(BT848_INT_MASK);
                 if (!astat)
                         return;
- btwrite(astat,BT848_INT_STAT);
                 IDEBUG(printk ("bttv%d: astat=%08x\n", btv->nr, astat));
                 IDEBUG(printk ("bttv%d: stat=%08x\n", btv->nr, stat));
 
@@ -3667,7 +3676,9 @@
                 {
                         IDEBUG(printk ("bttv%d: IRQ_I2CDONE\n", btv->nr));
                 }
-
+
+ btwrite(astat,BT848_INT_STAT);
+
                 count++;
                 if (count > 10)
                         printk (KERN_WARNING "bttv%d: irq loop %d\n",
@@ -3687,7 +3698,76 @@
  * Scan for a Bt848 card, request the irq and map the io memory
  */
 
-int configure_bt848(struct pci_dev *dev, int bttv_num)
+static void __init bttv_remove(struct pci_dev *pci_dev)
+{
+ u8 command;
+ int j;
+ struct bttv *btv = pci_dev->driver_data;
+
+ /* unregister i2c_bus */
+ i2c_bit_del_bus(&btv->i2c_adap);
+
+ /* turn off all capturing, DMA and IRQs */
+ btand(~15, BT848_GPIO_DMA_CTL);
+
+ /* first disable interrupts before unmapping the memory! */
+ btwrite(0, BT848_INT_MASK);
+ btwrite(~0x0UL,BT848_INT_STAT);
+ btwrite(0x0, BT848_GPIO_OUT_EN);
+
+ /* disable PCI bus-mastering */
+ pci_read_config_byte(btv->dev, PCI_COMMAND, &command);
+ /* Should this be &=~ ?? */
+ command&=~PCI_COMMAND_MASTER;
+ pci_write_config_byte(btv->dev, PCI_COMMAND, command);
+
+ /* unmap and free memory */
+ for (j = 0; j < gbuffers; j++)
+ if (btv->gbuf[j].risc)
+ kfree(btv->gbuf[j].risc);
+ if (btv->gbuf)
+ kfree((void *) btv->gbuf);
+
+ if (btv->risc_scr_odd)
+ kfree((void *) btv->risc_scr_odd);
+
+ if (btv->risc_scr_even)
+ kfree((void *) btv->risc_scr_even);
+
+ DEBUG(printk(KERN_DEBUG "free: risc_jmp: 0x%p.\n", btv->risc_jmp));
+ if (btv->risc_jmp)
+ kfree((void *) btv->risc_jmp);
+
+ DEBUG(printk(KERN_DEBUG "bt848_vbibuf: 0x%p.\n", btv->vbibuf));
+ if (btv->vbibuf)
+ vfree((void *) btv->vbibuf);
+
+ free_irq(btv->irq,btv);
+ DEBUG(printk(KERN_DEBUG "bt848_mem: 0x%p.\n", btv->bt848_mem));
+ if (btv->bt848_mem)
+ iounmap(btv->bt848_mem);
+
+ if(btv->video_dev.minor!=-1)
+ video_unregister_device(&btv->video_dev);
+ if(btv->vbi_dev.minor!=-1)
+ video_unregister_device(&btv->vbi_dev);
+ if (radio[btv->nr] && btv->radio_dev.minor != -1)
+ video_unregister_device(&btv->radio_dev);
+
+ release_mem_region(btv->bt848_adr,
+ pci_resource_len(btv->dev,0));
+ /* wake up any waiting processes
+ because shutdown flag is set, no new processes (in this queue)
+ are expected
+ */
+ btv->shutdown=1;
+ wake_up(&btv->gpioq);
+
+ return;
+}
+
+
+static int __init bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
 {
         int result;
         unsigned char command;
@@ -3696,6 +3776,8 @@
         unsigned int cmd;
 #endif
 
+ printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
+
         btv=&bttvs[bttv_num];
         btv->dev=dev;
         btv->nr = bttv_num;
@@ -3711,6 +3793,7 @@
         btv->vbip=VBIBUF_SIZE;
 
         init_waitqueue_head(&btv->gpioq);
+ btv->s_lock = SPIN_LOCK_UNLOCKED;
         btv->shutdown=0;
 
         btv->id=dev->device;
@@ -3718,7 +3801,7 @@
         btv->bt848_adr=pci_resource_start(dev, 0);
         if (pci_enable_device(dev))
                 return -EIO;
- if (!request_mem_region(pci_resource_start(dev,0),
+ if (!request_mem_region(btv->bt848_adr,
                                 pci_resource_len(dev,0),
                                 "bttv")) {
                 return -EBUSY;
@@ -3782,119 +3865,53 @@
                 if (!(command&BT878_EN_TBFX))
                 {
                         printk("bttv: 430FX compatibility could not be enabled\n");
+ free_irq(btv->irq,btv);
                         result = -1;
                         goto fail;
                 }
         }
+
+ dev->driver_data = btv;
+
+ if(init_bt848(btv) < 0) {
+ bttv_remove(dev);
+ return -EIO;
+ }
+
+ bttv_num++;
+
         return 0;
         
  fail:
- release_mem_region(pci_resource_start(btv->dev,0),
+ release_mem_region(btv->bt848_adr,
                            pci_resource_len(btv->dev,0));
         return result;
 }
 
-static int find_bt848(void)
-{
- struct pci_dev *dev;
- int result=0;
-
- bttv_num=0;
-
- pci_for_each_dev(dev) {
- if (dev->vendor == PCI_VENDOR_ID_BROOKTREE)
- if ((dev->device == PCI_DEVICE_ID_BT848)||
- (dev->device == PCI_DEVICE_ID_BT849)||
- (dev->device == PCI_DEVICE_ID_BT878)||
- (dev->device == PCI_DEVICE_ID_BT879))
- result=configure_bt848(dev,bttv_num++);
- if (result)
- return result;
- }
- if(bttv_num)
- printk(KERN_INFO "bttv: %d Bt8xx card(s) found.\n", bttv_num);
- return bttv_num;
-}
-
-static void release_bttv(void)
-{
- u8 command;
- int i,j;
- struct bttv *btv;
-
- for (i=0;i<bttv_num; i++)
- {
- btv=&bttvs[i];
-
- /* unregister i2c_bus */
- i2c_bit_del_bus(&btv->i2c_adap);
-
- /* turn off all capturing, DMA and IRQs */
- btand(~15, BT848_GPIO_DMA_CTL);
-
- /* first disable interrupts before unmapping the memory! */
- btwrite(0, BT848_INT_MASK);
- btwrite(0xffffffffUL,BT848_INT_STAT);
- btwrite(0x0, BT848_GPIO_OUT_EN);
-
- /* disable PCI bus-mastering */
- pci_read_config_byte(btv->dev, PCI_COMMAND, &command);
- /* Should this be &=~ ?? */
- command&=~PCI_COMMAND_MASTER;
- pci_write_config_byte(btv->dev, PCI_COMMAND, command);
-
- /* unmap and free memory */
- for (j = 0; j < gbuffers; j++)
- if (btv->gbuf[j].risc)
- kfree(btv->gbuf[j].risc);
- if (btv->gbuf)
- kfree((void *) btv->gbuf);
+static struct pci_device_id bttv_pci_tbl[] __initdata = {
+ {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+ {0,}
+};
 
- if (btv->risc_scr_odd)
- kfree((void *) btv->risc_scr_odd);
-
- if (btv->risc_scr_even)
- kfree((void *) btv->risc_scr_even);
+MODULE_DEVICE_TABLE(pci, bttv_pci_tbl);
 
- DEBUG(printk(KERN_DEBUG "free: risc_jmp: 0x%p.\n", btv->risc_jmp));
- if (btv->risc_jmp)
- kfree((void *) btv->risc_jmp);
-
- DEBUG(printk(KERN_DEBUG "bt848_vbibuf: 0x%p.\n", btv->vbibuf));
- if (btv->vbibuf)
- vfree((void *) btv->vbibuf);
-
-
- free_irq(btv->irq,btv);
- DEBUG(printk(KERN_DEBUG "bt848_mem: 0x%p.\n", btv->bt848_mem));
- if (btv->bt848_mem)
- iounmap(btv->bt848_mem);
-
- if(btv->video_dev.minor!=-1)
- video_unregister_device(&btv->video_dev);
- if(btv->vbi_dev.minor!=-1)
- video_unregister_device(&btv->vbi_dev);
- if (radio[btv->nr] && btv->radio_dev.minor != -1)
- video_unregister_device(&btv->radio_dev);
-
- release_mem_region(pci_resource_start(btv->dev,0),
- pci_resource_len(btv->dev,0));
- /* wake up any waiting processes
- because shutdown flag is set, no new processes (in this queue)
- are expected
- */
- btv->shutdown=1;
- wake_up(&btv->gpioq);
- }
-}
+static struct pci_driver bttv_pci_driver = {
+ name:"bttv",
+ id_table:bttv_pci_tbl,
+ probe:bttv_probe,
+ remove:bttv_remove,
+};
 
-#ifdef MODULE
-int init_module(void)
-#else
-int init_bttv_cards(struct video_init *unused)
-#endif
+static int __init bttv_init_module(void)
 {
- int i;
+ bttv_num = 0;
 
         printk(KERN_INFO "bttv: driver version %d.%d.%d loaded\n",
                (BTTV_VERSION_CODE >> 16) & 0xff,
@@ -3909,31 +3926,18 @@
                        gbuffers,gbufsize/1024,gbuffers*gbufsize/1024);
 
         handle_chipset();
- if (find_bt848()<=0)
- return -EIO;
 
- /* initialize Bt848s */
- for (i=0; i<bttv_num; i++)
- {
- if (init_bt848(i)<0)
- {
- release_bttv();
- return -EIO;
- }
- }
-
- return 0;
+ return pci_module_init(&bttv_pci_driver);
 }
 
-
-#ifdef MODULE
-
-void cleanup_module(void)
+static void __exit bttv_cleanup_module(void)
 {
- release_bttv();
+ pci_unregister_driver(&bttv_pci_driver);
+ return;
 }
 
-#endif
+module_init(bttv_init_module);
+module_exit(bttv_cleanup_module);
 
 /*
  * Local variables:
diff -ur linux-2.3/drivers/char/bttv.h linux-2.3.new/drivers/char/bttv.h
--- linux-2.3/drivers/char/bttv.h Sun May 21 15:38:29 2000
+++ linux-2.3.new/drivers/char/bttv.h Mon May 22 02:32:17 2000
@@ -143,6 +143,8 @@
 
         int tuner_type;
         int channel;
+
+ spinlock_t s_lock;
         
         unsigned int nr;
         unsigned short id;
diff -ur linux-2.3/drivers/char/videodev.c linux-2.3.new/drivers/char/videodev.c
--- linux-2.3/drivers/char/videodev.c Thu May 4 22:13:29 2000
+++ linux-2.3.new/drivers/char/videodev.c Mon May 22 03:11:51 2000
@@ -41,7 +41,6 @@
 static struct video_device *video_device[VIDEO_NUM_DEVICES];
 
 #ifdef CONFIG_VIDEO_BT848
-extern int init_bttv_cards(struct video_init *);
 extern int i2c_tuner_init(struct video_init *);
 #endif
 #ifdef CONFIG_VIDEO_BWQCAM
@@ -59,9 +58,8 @@
 
 static struct video_init video_init_list[]={
 #ifdef CONFIG_VIDEO_BT848
- {"i2c-tuner", i2c_tuner_init},
- {"bttv", init_bttv_cards},
-#endif
+ {"i2c-tuner", i2c_tuner_init},
+#endif
 #ifdef CONFIG_VIDEO_BWQCAM
         {"bw-qcam", init_bw_qcams},
 #endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:21 EST