[ALSA] Remove superfluous pcm_free callbacks
[linux-2.6.git] / sound / pci / es1938.c
index b492777..d05c3d2 100644 (file)
@@ -76,13 +76,6 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
 #define SUPPORT_JOYSTICK 1
 #endif
 
-#ifndef PCI_VENDOR_ID_ESS
-#define PCI_VENDOR_ID_ESS              0x125d
-#endif
-#ifndef PCI_DEVICE_ID_ESS_ES1938
-#define PCI_DEVICE_ID_ESS_ES1938       0x1969
-#endif
-
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
@@ -274,7 +267,7 @@ static void snd_es1938_mixer_write(es1938_t *chip, unsigned char reg, unsigned c
        outb(val, SLSB_REG(chip, MIXERDATA));
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Mixer reg %02x set to %02x\n", reg, val);
+       snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, val);
 #endif
 }
 
@@ -290,7 +283,7 @@ static int snd_es1938_mixer_read(es1938_t *chip, unsigned char reg)
        data = inb(SLSB_REG(chip, MIXERDATA));
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Mixer reg %02x now is %02x\n", reg, data);
+       snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data);
 #endif
        return data;
 }
@@ -310,7 +303,8 @@ static int snd_es1938_mixer_bits(es1938_t *chip, unsigned char reg, unsigned cha
                new = (old & ~mask) | (val & mask);
                outb(new, SLSB_REG(chip, MIXERDATA));
 #ifdef REG_DEBUG
-               snd_printk("Mixer reg %02x was %02x, set to %02x\n", reg, old, new);
+               snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n",
+                          reg, old, new);
 #endif
        }
        spin_unlock_irqrestore(&chip->mixer_lock, flags);
@@ -330,7 +324,7 @@ static void snd_es1938_write_cmd(es1938_t *chip, unsigned char cmd)
                        return;
                }
        }
-       printk("snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v);
+       printk(KERN_ERR "snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v);
 }
 
 /* -----------------------------------------------------------------
@@ -343,7 +337,7 @@ static int snd_es1938_get_byte(es1938_t *chip)
        for (i = GET_LOOP_TIMEOUT; i; i--)
                if ((v = inb(SLSB_REG(chip, STATUS))) & 0x80)
                        return inb(SLSB_REG(chip, READDATA));
-       snd_printk("get_byte timeout: status 0x02%x\n", v);
+       snd_printk(KERN_ERR "get_byte timeout: status 0x02%x\n", v);
        return -ENODEV;
 }
 
@@ -358,7 +352,7 @@ static void snd_es1938_write(es1938_t *chip, unsigned char reg, unsigned char va
        snd_es1938_write_cmd(chip, val);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Reg %02x set to %02x\n", reg, val);
+       snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, val);
 #endif
 }
 
@@ -375,7 +369,7 @@ static unsigned char snd_es1938_read(es1938_t *chip, unsigned char reg)
        val = snd_es1938_get_byte(chip);
        spin_unlock_irqrestore(&chip->reg_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Reg %02x now is %02x\n", reg, val);
+       snd_printk(KERN_DEBUG "Reg %02x now is %02x\n", reg, val);
 #endif
        return val;
 }
@@ -397,7 +391,8 @@ static int snd_es1938_bits(es1938_t *chip, unsigned char reg, unsigned char mask
                new = (old & ~mask) | (val & mask);
                snd_es1938_write_cmd(chip, new);
 #ifdef REG_DEBUG
-               snd_printk("Reg %02x was %02x, set to %02x\n", reg, old, new);
+               snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x\n",
+                          reg, old, new);
 #endif
        }
        spin_unlock_irqrestore(&chip->reg_lock, flags);
@@ -420,7 +415,7 @@ static void snd_es1938_reset(es1938_t *chip)
                                goto __next;
                }
        }
-       snd_printk("ESS Solo-1 reset failed\n");
+       snd_printk(KERN_ERR "ESS Solo-1 reset failed\n");
 
      __next:
        snd_es1938_write_cmd(chip, ESS_CMD_ENABLEEXT);
@@ -550,10 +545,12 @@ static int snd_es1938_capture_trigger(snd_pcm_substream_t * substream,
        int val;
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
+       case SNDRV_PCM_TRIGGER_RESUME:
                val = 0x0f;
                chip->active |= ADC1;
                break;
        case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
                val = 0x00;
                chip->active &= ~ADC1;
                break;
@@ -570,6 +567,7 @@ static int snd_es1938_playback1_trigger(snd_pcm_substream_t * substream,
        es1938_t *chip = snd_pcm_substream_chip(substream);
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
+       case SNDRV_PCM_TRIGGER_RESUME:
                /* According to the documentation this should be:
                   0x13 but that value may randomly swap stereo channels */
                 snd_es1938_mixer_write(chip, ESSSB_IREG_AUDIO2CONTROL1, 0x92);
@@ -582,6 +580,7 @@ static int snd_es1938_playback1_trigger(snd_pcm_substream_t * substream,
                chip->active |= DAC2;
                break;
        case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
                outb(0, SLIO_REG(chip, AUDIO2MODE));
                snd_es1938_mixer_write(chip, ESSSB_IREG_AUDIO2CONTROL1, 0);
                chip->active &= ~DAC2;
@@ -599,10 +598,12 @@ static int snd_es1938_playback2_trigger(snd_pcm_substream_t * substream,
        int val;
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
+       case SNDRV_PCM_TRIGGER_RESUME:
                val = 5;
                chip->active |= DAC1;
                break;
        case SNDRV_PCM_TRIGGER_STOP:
+       case SNDRV_PCM_TRIGGER_SUSPEND:
                val = 0;
                chip->active &= ~DAC1;
                break;
@@ -999,11 +1000,6 @@ static snd_pcm_ops_t snd_es1938_capture_ops = {
        .copy =         snd_es1938_capture_copy,
 };
 
-static void snd_es1938_free_pcm(snd_pcm_t *pcm)
-{
-       snd_pcm_lib_preallocate_free_for_all(pcm);
-}
-
 static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device)
 {
        snd_pcm_t *pcm;
@@ -1015,7 +1011,6 @@ static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1938_capture_ops);
        
        pcm->private_data = chip;
-       pcm->private_free = snd_es1938_free_pcm;
        pcm->info_flags = 0;
        strcpy(pcm->name, "ESS Solo-1");
 
@@ -1397,7 +1392,8 @@ static int es1938_suspend(snd_card_t *card, pm_message_t state)
                *d = snd_es1938_reg_read(chip, *s);
 
        outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
-
+       if (chip->irq >= 0)
+               free_irq(chip->irq, (void *)chip);  
        pci_disable_device(chip->pci);
        return 0;
 }
@@ -1408,6 +1404,9 @@ static int es1938_resume(snd_card_t *card)
        unsigned char *s, *d;
 
        pci_enable_device(chip->pci);
+       request_irq(chip->pci->irq, snd_es1938_interrupt,
+                   SA_INTERRUPT|SA_SHIRQ, "ES1938", (void *)chip);
+       chip->irq = chip->pci->irq;
        snd_es1938_chip_init(chip);
 
        /* restore mixer-related registers */
@@ -1496,12 +1495,12 @@ static int __devinit snd_es1938_create(snd_card_t * card,
         /* check, if we can restrict PCI DMA transfers to 24 bits */
        if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
            pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
-                snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+               snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                 return -ENXIO;
         }
 
-       chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (chip == NULL) {
                pci_disable_device(pci);
                return -ENOMEM;
@@ -1521,13 +1520,13 @@ static int __devinit snd_es1938_create(snd_card_t * card,
        chip->mpu_port = pci_resource_start(pci, 3);
        chip->game_port = pci_resource_start(pci, 4);
        if (request_irq(pci->irq, snd_es1938_interrupt, SA_INTERRUPT|SA_SHIRQ, "ES1938", (void *)chip)) {
-               snd_printk("unable to grab IRQ %d\n", pci->irq);
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_es1938_free(chip);
                return -EBUSY;
        }
        chip->irq = pci->irq;
 #ifdef ES1938_DDEBUG
-       snd_printk("create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
+       snd_printk(KERN_DEBUG "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
                   chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port);
 #endif