fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / sound / oss / nm256_audio.c
index 777492c..44cd155 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/pm.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include "sound_config.h"
-#include "nm256.h"
-#include "nm256_coeff.h"
 
-int nm256_debug;
+static int nm256_debug;
 static int force_load;
 
+#include "nm256.h"
+#include "nm256_coeff.h"
+
 /* 
  * The size of the playback reserve.  When the playback buffer has less
  * than NM256_PLAY_WMARK_SIZE bytes to output, we request a new
@@ -45,13 +45,13 @@ static struct audio_driver nm256_audio_driver;
 
 static int nm256_grabInterrupt (struct nm256_info *card);
 static int nm256_releaseInterrupt (struct nm256_info *card);
-static irqreturn_t nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy);
-static irqreturn_t nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy);
-static int handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data);
+static irqreturn_t nm256_interrupt (int irq, void *dev_id);
+static irqreturn_t nm256_interrupt_zx (int irq, void *dev_id);
 
 /* These belong in linux/pci.h. */
 #define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
 #define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006
+#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016
 
 /* List of cards.  */
 static struct nm256_info *nmcard_list;
@@ -137,7 +137,7 @@ static int usecache;
 static int buffertop;
 
 /* Check to see if we're using the bank of cached coefficients. */
-int
+static int
 nm256_cachedCoefficients (struct nm256_info *card)
 {
     return usecache;
@@ -156,7 +156,7 @@ static int samplerates[9] = {
  * attempted.
  */
 
-int
+static int
 nm256_setInfo (int dev, struct nm256_info *card)
 {
     int x;
@@ -526,7 +526,7 @@ nm256_initHw (struct nm256_info *card)
  */
 
 static irqreturn_t
-nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy)
+nm256_interrupt (int irq, void *dev_id)
 {
     struct nm256_info *card = (struct nm256_info *)dev_id;
     u16 status;
@@ -629,7 +629,7 @@ nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy)
  */
 
 static irqreturn_t
-nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy)
+nm256_interrupt_zx (int irq, void *dev_id)
 {
     struct nm256_info *card = (struct nm256_info *)dev_id;
     u32 status;
@@ -733,7 +733,7 @@ static int
 nm256_grabInterrupt (struct nm256_info *card)
 {
     if (card->has_irq++ == 0) {
-       if (request_irq (card->irq, card->introutine, SA_SHIRQ,
+       if (request_irq (card->irq, card->introutine, IRQF_SHARED,
                         "NM256_audio", card) < 0) {
            printk (KERN_ERR "NM256: can't obtain IRQ %d\n", card->irq);
            return -1;
@@ -928,7 +928,7 @@ nm256_resetAC97 (struct ac97_hwint *dev)
  * mixer ioctl to the AC97 driver.
  */
 static int
-nm256_default_mixer_ioctl (int dev, unsigned int cmd, caddr_t arg)
+nm256_default_mixer_ioctl (int dev, unsigned int cmd, void __user *arg)
 {
     struct nm256_info *card = nm256_find_card_for_mixer (dev);
     if (card != NULL)
@@ -960,7 +960,7 @@ static struct ac97_mixer_value_list mixer_defaults[] = {
 
 
 /* Installs the AC97 mixer into CARD.  */
-static int __init
+static int __devinit
 nm256_install_mixer (struct nm256_info *card)
 {
     int mixer;
@@ -989,28 +989,19 @@ nm256_install_mixer (struct nm256_info *card)
     return 0;
 }
 
-/* Perform a full reset on the hardware; this is invoked when an APM
-   resume event occurs.  */
-static void
-nm256_full_reset (struct nm256_info *card)
-{
-    nm256_initHw (card);
-    ac97_reset (&(card->mdev));
-}
-
 /* 
  * See if the signature left by the NM256 BIOS is intact; if so, we use
  * the associated address as the end of our audio buffer in the video
  * RAM.
  */
 
-static void __init
+static void __devinit
 nm256_peek_for_sig (struct nm256_info *card)
 {
     u32 port1offset 
        = card->port[0].physaddr + card->port[0].end_offset - 0x0400;
     /* The signature is located 1K below the end of video RAM.  */
-    char *temp = ioremap_nocache (port1offset, 16);
+    char __iomem *temp = ioremap_nocache (port1offset, 16);
     /* Default buffer end is 5120 bytes below the top of RAM.  */
     u32 default_value = card->port[0].end_offset - 0x1400;
     u32 sig;
@@ -1046,11 +1037,10 @@ nm256_peek_for_sig (struct nm256_info *card)
  * VERSTR is a human-readable version string.
  */
 
-static int __init
+static int __devinit
 nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
 {
     struct nm256_info *card;
-    struct pm_dev *pmdev;
     int x;
 
     if (pci_enable_device(pcidev))
@@ -1066,7 +1056,7 @@ nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
     card->playing  = 0;
     card->recording = 0;
     card->rev = rev;
-       spin_lock_init(&card->lock);
+    spin_lock_init(&card->lock);
 
     /* Init the memory port info.  */
     for (x = 0; x < 2; x++) {
@@ -1231,43 +1221,10 @@ nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
 
     nm256_install_mixer (card);
 
-    pmdev = pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), handle_pm_event);
-    if (pmdev)
-        pmdev->data = card;
-
     return 1;
 }
 
 
-/*
- * PM event handler, so the card is properly reinitialized after a power
- * event.
- */
-static int
-handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data)
-{
-    struct nm256_info *crd = (struct nm256_info*) dev->data;
-    if (crd) {
-        switch (rqst) {
-       case PM_SUSPEND:
-           break;
-       case PM_RESUME:
-            {
-                int playing = crd->playing;
-                nm256_full_reset (crd);
-                /*
-                 * A little ugly, but that's ok; pretend the
-                 * block we were playing is done. 
-                 */
-                if (playing)
-                    DMAbuf_outputintr (crd->dev_for_play, 1);
-            }
-           break;
-       }
-    }
-    return 0;
-}
-
 static int __devinit
 nm256_probe(struct pci_dev *pcidev,const struct pci_device_id *pciid)
 {
@@ -1275,6 +1232,8 @@ nm256_probe(struct pci_dev *pcidev,const struct pci_device_id *pciid)
        return nm256_install(pcidev, REV_NM256AV, "256AV");
     if (pcidev->device == PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO)
        return nm256_install(pcidev, REV_NM256ZX, "256ZX");
+    if (pcidev->device == PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO)
+       return nm256_install(pcidev, REV_NM256ZX, "256XL+");
     return -1; /* should not come here ... */
 }
 
@@ -1415,7 +1374,7 @@ nm256_audio_close(int dev)
 
 /* Standard ioctl handler. */
 static int
-nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
+nm256_audio_ioctl(int dev, unsigned int cmd, void __user *arg)
 {
     int ret;
     u32 oldinfo;
@@ -1439,7 +1398,7 @@ nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
     switch (cmd)
        {
        case SOUND_PCM_WRITE_RATE:
-           if (get_user(ret, (int *) arg))
+           if (get_user(ret, (int __user *) arg))
                return -EFAULT;
 
            if (ret != 0) {
@@ -1458,7 +1417,7 @@ nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
            break;
 
        case SNDCTL_DSP_STEREO:
-           if (get_user(ret, (int *) arg))
+           if (get_user(ret, (int __user *) arg))
                return -EFAULT;
 
            card->sinfo[w].stereo = ret ? 1 : 0;
@@ -1469,7 +1428,7 @@ nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
            break;
 
        case SOUND_PCM_WRITE_CHANNELS:
-           if (get_user(ret, (int *) arg))
+           if (get_user(ret, (int __user *) arg))
                return -EFAULT;
 
            if (ret < 1 || ret > 3)
@@ -1487,7 +1446,7 @@ nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
            break;
 
        case SNDCTL_DSP_SETFMT:
-           if (get_user(ret, (int *) arg))
+           if (get_user(ret, (int __user *) arg))
                return -EFAULT;
 
            if (ret != 0) {
@@ -1508,7 +1467,7 @@ nm256_audio_ioctl(int dev, unsigned int cmd, caddr_t arg)
        default:
            return -EINVAL;
        }
-    return put_user(ret, (int *) arg);
+    return put_user(ret, (int __user *) arg);
 }
 
 /*
@@ -1662,34 +1621,35 @@ static struct pci_device_id nm256_pci_tbl[] = {
        PCI_ANY_ID, PCI_ANY_ID, 0, 0},
        {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO,
        PCI_ANY_ID, PCI_ANY_ID, 0, 0},
+       {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO,
+       PCI_ANY_ID, PCI_ANY_ID, 0, 0},
        {0,}
 };
 MODULE_DEVICE_TABLE(pci, nm256_pci_tbl);
 MODULE_LICENSE("GPL");
 
 
-struct pci_driver nm256_pci_driver = {
+static struct pci_driver nm256_pci_driver = {
        .name           = "nm256_audio",
        .id_table       = nm256_pci_tbl,
        .probe          = nm256_probe,
        .remove         = nm256_remove,
 };
 
-MODULE_PARM (usecache, "i");
-MODULE_PARM (buffertop, "i");
-MODULE_PARM (nm256_debug, "i");
-MODULE_PARM (force_load, "i");
+module_param(usecache, bool, 0);
+module_param(buffertop, int, 0);
+module_param(nm256_debug, bool, 0644);
+module_param(force_load, bool, 0);
 
 static int __init do_init_nm256(void)
 {
     printk (KERN_INFO "NeoMagic 256AV/256ZX audio driver, version 1.1p\n");
-    return pci_module_init(&nm256_pci_driver);
+    return pci_register_driver(&nm256_pci_driver);
 }
 
 static void __exit cleanup_nm256 (void)
 {
     pci_unregister_driver(&nm256_pci_driver);
-    pm_unregister_all (&handle_pm_event);
 }
 
 module_init(do_init_nm256);