]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/ali5451/ali5451.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-omap-h63xx.git] / sound / pci / ali5451 / ali5451.c
index e1ed59549c5063a76ba0eb200f966ebaa0c268c8..4edf270a7809c3b20fa5997caf23acd42bb72968 100644 (file)
@@ -25,7 +25,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -239,7 +238,7 @@ struct snd_ali_image {
 
 
 struct snd_ali {
-       unsigned long   irq;
+       int             irq;
        unsigned long   port;
        unsigned char   revision;
 
@@ -731,8 +730,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
                return;
        }
 
-       count = 0;
-       while (count++ <= 50000) {
+       for (count = 0; count <= 50000; count++) {
                snd_ali_delay(codec, 6);
                bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
                R2 = bval & 0x1F;
@@ -1250,7 +1248,7 @@ static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream,
                        evoice->substream = substream;
                }
        } else {
-               if (!evoice) {
+               if (evoice) {
                        snd_ali_free_voice(codec, evoice);
                        pvoice->extra = evoice = NULL;
                }
@@ -1267,7 +1265,7 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
        struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
 
        snd_pcm_lib_free_pages(substream);
-       if (!evoice) {
+       if (evoice) {
                snd_ali_free_voice(codec, evoice);
                pvoice->extra = NULL;
        }
@@ -1356,7 +1354,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
                                 VOL,
                                 CTRL,
                                 EC);
-       if (!evoice) {
+       if (evoice) {
                evoice->count = pvoice->count;
                evoice->eso = pvoice->count << 1;
                ESO = evoice->eso - 1;
@@ -1805,40 +1803,32 @@ static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
 .info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
 .put = snd_ali5451_spdif_put, .private_value = value}
 
-static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol,
-                                 struct snd_ctl_elem_info *uinfo)
-{
-        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-        uinfo->count = 1;
-        uinfo->value.integer.min = 0;
-        uinfo->value.integer.max = 1;
-        return 0;
-}
+#define snd_ali5451_spdif_info         snd_ctl_boolean_mono_info
 
 static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ali *codec = kcontrol->private_data;
-       unsigned int enable;
+       unsigned int spdif_enable;
 
-       enable = ucontrol->value.integer.value[0] ? 1 : 0;
+       spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
 
        spin_lock_irq(&codec->reg_lock);
        switch (kcontrol->private_value) {
        case 0:
-               enable = (codec->spdif_mask & 0x02) ? 1 : 0;
+               spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
                break;
        case 1:
-               enable = ((codec->spdif_mask & 0x02) &&
+               spdif_enable = ((codec->spdif_mask & 0x02) &&
                          (codec->spdif_mask & 0x04)) ? 1 : 0;
                break;
        case 2:
-               enable = (codec->spdif_mask & 0x01) ? 1 : 0;
+               spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
                break;
        default:
                break;
        }
-       ucontrol->value.integer.value[0] = enable;
+       ucontrol->value.integer.value[0] = spdif_enable;
        spin_unlock_irq(&codec->reg_lock);
        return 0;
 }
@@ -1847,17 +1837,17 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_ali *codec = kcontrol->private_data;
-       unsigned int change = 0, enable = 0;
+       unsigned int change = 0, spdif_enable = 0;
 
-       enable = ucontrol->value.integer.value[0] ? 1 : 0;
+       spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
 
        spin_lock_irq(&codec->reg_lock);
        switch (kcontrol->private_value) {
        case 0:
                change = (codec->spdif_mask & 0x02) ? 1 : 0;
-               change = change ^ enable;
+               change = change ^ spdif_enable;
                if (change) {
-                       if (enable) {
+                       if (spdif_enable) {
                                codec->spdif_mask |= 0x02;
                                snd_ali_enable_spdif_out(codec);
                        } else {
@@ -1869,9 +1859,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
                break;
        case 1: 
                change = (codec->spdif_mask & 0x04) ? 1 : 0;
-               change = change ^ enable;
+               change = change ^ spdif_enable;
                if (change && (codec->spdif_mask & 0x02)) {
-                       if (enable) {
+                       if (spdif_enable) {
                                codec->spdif_mask |= 0x04;
                                snd_ali_enable_spdif_chnout(codec);
                        } else {
@@ -1882,9 +1872,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
                break;
        case 2:
                change = (codec->spdif_mask & 0x01) ? 1 : 0;
-               change = change ^ enable;
+               change = change ^ spdif_enable;
                if (change) {
-                       if (enable) {
+                       if (spdif_enable) {
                                codec->spdif_mask |= 0x01;
                                snd_ali_enable_spdif_in(codec);
                        } else {
@@ -2057,10 +2047,8 @@ static int snd_ali_free(struct snd_ali * codec)
 {
        if (codec->hw_initialized)
                snd_ali_disable_address_interrupt(codec);
-       if (codec->irq >= 0) {
-               synchronize_irq(codec->irq);
+       if (codec->irq >= 0)
                free_irq(codec->irq, codec);
-       }
        if (codec->port)
                pci_release_regions(codec->pci);
        pci_disable_device(codec->pci);
@@ -2154,7 +2142,7 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
 {
        int err;
 
-       snd_ali_printk("resouces allocation ...\n");
+       snd_ali_printk("resources allocation ...\n");
        err = pci_request_regions(codec->pci, "ALI 5451");
        if (err < 0)
                return err;
@@ -2166,7 +2154,7 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
                return -EBUSY;
        }
        codec->irq = codec->pci->irq;
-       snd_ali_printk("resouces allocated.\n");
+       snd_ali_printk("resources allocated.\n");
        return 0;
 }
 static int snd_ali_dev_free(struct snd_device *device)
@@ -2218,7 +2206,7 @@ static int __devinit snd_ali_create(struct snd_card *card,
        codec->card = card;
        codec->pci = pci;
        codec->irq = -1;
-       pci_read_config_byte(pci, PCI_REVISION_ID, &codec->revision);
+       codec->revision = pci->revision;
        codec->spdif_support = spdif_support;
 
        if (pcm_streams < 1)
@@ -2319,9 +2307,9 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
 
        snd_ali_printk("probe ...\n");
 
-       card = snd_card_new(index, id, THIS_MODULE, 0);
-       if (!card)
-               return -ENOMEM;
+       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       if (err < 0)
+               return err;
 
        err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
        if (err < 0)
@@ -2343,7 +2331,7 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
        strcpy(card->driver, "ALI5451");
        strcpy(card->shortname, "ALI 5451");
        
-       sprintf(card->longname, "%s at 0x%lx, irq %li",
+       sprintf(card->longname, "%s at 0x%lx, irq %i",
                card->shortname, codec->port, codec->irq);
 
        snd_ali_printk("register card.\n");