]> err.no Git - linux-2.6/commitdiff
[ALSA] Minor clean up and fixes for CS5535 audio driver
authorTakashi Iwai <tiwai@suse.de>
Thu, 17 Nov 2005 09:15:37 +0000 (10:15 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:16:29 +0000 (12:16 +0100)
Modules: Documentation,CS5535 driver

Minor clean up and fixes for CS5535 audio driver.
Added an entry in ALSA-Configuration.txt, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Documentation/sound/alsa/ALSA-Configuration.txt
sound/pci/cs5535audio/cs5535audio.c
sound/pci/cs5535audio/cs5535audio.h
sound/pci/cs5535audio/cs5535audio_pcm.c

index 2f27f391c7cc778e87bfc374f4bb6db9ea9b77d2..23d1870d522f2fefb9c76c3276f3bb4fab90c40b 100644 (file)
@@ -410,6 +410,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
 
     The power-management is supported.
     
+  Module snd-cs5535audio
+  ----------------------
+
+    Module for multifunction CS5535 companion PCI device
+
+    Module supports up to 8 cards.
+
   Module snd-dt019x
   -----------------
 
index 920c857fc2230a705da145ed9b0fc177093c47a7..3f4379da4d264f3fe5c0784379788897105ec7b0 100644 (file)
@@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids);
 
 static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout)
 {
-       unsigned long tmp;
+       unsigned int tmp;
        do {
                tmp = cs_readl(cs5535au, ACC_CODEC_CNTL);
                if (!(tmp & CMD_NEW))
@@ -69,11 +69,11 @@ static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout)
 static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au,
                                                        unsigned short reg)
 {
-       unsigned long regdata;
-       unsigned long timeout;
-       unsigned long val;
+       unsigned int regdata;
+       int timeout;
+       unsigned int val;
 
-       regdata = ((unsigned long) reg) << 24;
+       regdata = ((unsigned int) reg) << 24;
        regdata |= ACC_CODEC_CNTL_RD_CMD;
        regdata |= CMD_NEW;
 
@@ -83,24 +83,23 @@ static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au,
        timeout = 50;
        do {
                val = cs_readl(cs5535au, ACC_CODEC_STATUS);
-               if (    (val & STS_NEW) &&
-                       ((unsigned long) reg == ((0xFF000000 & val)>>24)) )
+               if ((val & STS_NEW) && reg == (val >> 24))
                        break;
                msleep(10);
        } while (--timeout);
        if (!timeout)
                snd_printk(KERN_ERR "Failure reading cs5535 codec\n");
 
-       return ((unsigned short) val);
+       return (unsigned short) val;
 }
 
 static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au,
                                   unsigned short reg, unsigned short val)
 {
-       unsigned long regdata;
+       unsigned int regdata;
 
-       regdata = ((unsigned long) reg) << 24;
-       regdata |= (unsigned long) val;
+       regdata = ((unsigned int) reg) << 24;
+       regdata |= val;
        regdata &= CMD_MASK;
        regdata |= CMD_NEW;
        regdata &= ACC_CODEC_CNTL_WR_CMD;
@@ -123,12 +122,6 @@ static unsigned short snd_cs5535audio_ac97_codec_read(ac97_t *ac97,
        return snd_cs5535audio_codec_read(cs5535au, reg);
 }
 
-static void snd_cs5535audio_mixer_free_ac97(ac97_t *ac97)
-{
-       cs5535audio_t *cs5535audio = ac97->private_data;
-       cs5535audio->ac97 = NULL;
-}
-
 static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au)
 {
        snd_card_t *card = cs5535au->card;
@@ -147,10 +140,9 @@ static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au)
        ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM;
        ac97.private_data = cs5535au;
        ac97.pci = cs5535au->pci;
-       ac97.private_free = snd_cs5535audio_mixer_free_ac97;
 
        if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
-               snd_printk("mixer failed\n");
+               snd_printk(KERN_ERR "mixer failed\n");
                return err;
        }
 
@@ -201,8 +193,8 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id,
 
        if (!acc_irq_stat)
                return IRQ_NONE;
-       for (count=0; count < 10; count++) {
-               if (acc_irq_stat & (1<<count)) {
+       for (count = 0; count < 10; count++) {
+               if (acc_irq_stat & (1 << count)) {
                        switch (count) {
                        case IRQ_STS:
                                cs_readl(cs5535au, ACC_GPIO_STATUS);
index e28177fb09917ec0855b449da7f23953dd4683c1..774185e026d4b795eab349216ccab9fc296a02fb 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __SOUND_CS5535AUDIO_H
 #define __SOUND_CS5535AUDIO_H
 
-#define cs_writel(cs5535au, reg, val) outl(val, (int) cs5535au->port + reg)
-#define cs_writeb(cs5535au, reg, val) outb(val, (int) cs5535au->port + reg)
-#define cs_readl(cs5535au, reg)        inl((unsigned short) (cs5535au->port + reg))
-#define cs_readw(cs5535au, reg)        inw((unsigned short) (cs5535au->port + reg))
-#define cs_readb(cs5535au, reg)        inb((unsigned short) (cs5535au->port + reg))
+#define cs_writel(cs5535au, reg, val)  outl(val, (cs5535au)->port + reg)
+#define cs_writeb(cs5535au, reg, val)  outb(val, (cs5535au)->port + reg)
+#define cs_readl(cs5535au, reg)                inl((cs5535au)->port + reg)
+#define cs_readw(cs5535au, reg)                inw((cs5535au)->port + reg)
+#define cs_readb(cs5535au, reg)                inb((cs5535au)->port + reg)
 
 #define CS5535AUDIO_MAX_DESCRIPTORS    128
 
index 5802ed9d57bef02e2a713cd0310b6a54fe58b6cd..d32b23f202cde4991c5bc64d609bee3ff9dd22b2 100644 (file)
@@ -150,8 +150,8 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
                cs5535audio_dma_desc_t *desc =
                        &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i];
                desc->addr = cpu_to_le32(addr);
-               desc->size = period_bytes;
-               desc->ctlreserved = PRD_EOP;
+               desc->size = cpu_to_le32(period_bytes);
+               desc->ctlreserved = cpu_to_le32(PRD_EOP);
                desc_addr += sizeof(cs5535audio_dma_desc_t);
                addr += period_bytes;
        }
@@ -159,7 +159,7 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
        lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods];
        lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr);
        lastdesc->size = 0;
-       lastdesc->ctlreserved = PRD_JMP;
+       lastdesc->ctlreserved = cpu_to_le32(PRD_JMP);
        jmpprd_addr = cpu_to_le32(lastdesc->addr +
                                (sizeof(cs5535audio_dma_desc_t)*periods));
 
@@ -272,34 +272,29 @@ static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd)
 {
        cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream);
        cs5535audio_dma_t *dma = substream->runtime->private_data;
+       int err = 0;
 
+       spin_lock(&cs5535au->reg_lock);
        switch (cmd) {
-               case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-                       spin_lock_irq(&cs5535au->reg_lock);
-                       dma->ops->pause_dma(cs5535au);
-                       spin_unlock_irq(&cs5535au->reg_lock);
-                       break;
-               case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-                       spin_lock_irq(&cs5535au->reg_lock);
-                       dma->ops->enable_dma(cs5535au);
-                       spin_unlock_irq(&cs5535au->reg_lock);
-                       break;
-               case SNDRV_PCM_TRIGGER_START:
-                       spin_lock_irq(&cs5535au->reg_lock);
-                       dma->ops->enable_dma(cs5535au);
-                       spin_unlock_irq(&cs5535au->reg_lock);
-                       break;
-               case SNDRV_PCM_TRIGGER_STOP:
-                       spin_lock_irq(&cs5535au->reg_lock);
-                       dma->ops->disable_dma(cs5535au);
-                       spin_unlock_irq(&cs5535au->reg_lock);
-                       break;
-               default:
-                       snd_printk(KERN_ERR "unhandled trigger\n");
-                       return -EINVAL;
-                       break;
+       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+               dma->ops->pause_dma(cs5535au);
+               break;
+       case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               dma->ops->enable_dma(cs5535au);
+               break;
+       case SNDRV_PCM_TRIGGER_START:
+               dma->ops->enable_dma(cs5535au);
+               break;
+       case SNDRV_PCM_TRIGGER_STOP:
+               dma->ops->disable_dma(cs5535au);
+               break;
+       default:
+               snd_printk(KERN_ERR "unhandled trigger\n");
+               err = -EINVAL;
+               break;
        }
-       return 0;
+       spin_unlock(&cs5535au->reg_lock);
+       return err;
 }
 
 static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t
@@ -375,11 +370,6 @@ static snd_pcm_ops_t snd_cs5535audio_capture_ops = {
        .pointer =      snd_cs5535audio_pcm_pointer,
 };
 
-static void snd_cs5535audio_pcm_free(snd_pcm_t *pcm)
-{
-       snd_pcm_lib_preallocate_free_for_all(pcm);
-}
-
 static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = {
         .type = CS5535AUDIO_DMA_PLAYBACK,
         .enable_dma = cs5535audio_playback_enable_dma,
@@ -417,7 +407,6 @@ int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au)
                                        &snd_cs5535audio_capture_ops);
 
        pcm->private_data = cs5535au;
-       pcm->private_free = snd_cs5535audio_pcm_free;
        pcm->info_flags = 0;
        strcpy(pcm->name, "CS5535 Audio");