]> err.no Git - linux-2.6/blobdiff - sound/pci/ca0106/ca0106_main.c
Merge branch 'for-linus' of git://git.alsa-project.org/alsa-kernel
[linux-2.6] / sound / pci / ca0106 / ca0106_main.c
index 252710e4f5c8a8ed8e12360562a0050c8f740ee3..2f8b28add27687cfb63815836a72a06e1050eb92 100644 (file)
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
  */
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -250,6 +249,11 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
           .name   = "MSI K8N Diamond MB [SB0438]",
           .gpio_type = 2,
           .i2c_adc = 1 } ,
+        /* Another MSI K8N Diamond MB, which has apprently a different SSID */
+        { .serial = 0x10091102,
+          .name   = "MSI K8N Diamond MB",
+          .gpio_type = 2,
+          .i2c_adc = 1 } ,
         /* Shuttle XPC SD31P which has an onboard Creative Labs
          * Sound Blaster Live! 24-bit EAX
          * high-definition 7.1 audio processor".
@@ -274,10 +278,11 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
 
 /* hardware definition */
 static struct snd_pcm_hardware snd_ca0106_playback_hw = {
-       .info =                 (SNDRV_PCM_INFO_MMAP | 
-                                SNDRV_PCM_INFO_INTERLEAVED |
-                                SNDRV_PCM_INFO_BLOCK_TRANSFER |
-                                SNDRV_PCM_INFO_MMAP_VALID),
+       .info =                 SNDRV_PCM_INFO_MMAP | 
+                               SNDRV_PCM_INFO_INTERLEAVED |
+                               SNDRV_PCM_INFO_BLOCK_TRANSFER |
+                               SNDRV_PCM_INFO_MMAP_VALID |
+                               SNDRV_PCM_INFO_SYNC_START,
        .formats =              SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
        .rates =                (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
                                 SNDRV_PCM_RATE_192000),
@@ -435,22 +440,22 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
 static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb)
 {
        unsigned long flags;
-       unsigned int enable;
-  
+       unsigned int intr_enable;
+
        spin_lock_irqsave(&emu->emu_lock, flags);
-       enable = inl(emu->port + INTE) | intrenb;
-       outl(enable, emu->port + INTE);
+       intr_enable = inl(emu->port + INTE) | intrenb;
+       outl(intr_enable, emu->port + INTE);
        spin_unlock_irqrestore(&emu->emu_lock, flags);
 }
 
 static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb)
 {
        unsigned long flags;
-       unsigned int enable;
-  
+       unsigned int intr_enable;
+
        spin_lock_irqsave(&emu->emu_lock, flags);
-       enable = inl(emu->port + INTE) & ~intrenb;
-       outl(enable, emu->port + INTE);
+       intr_enable = inl(emu->port + INTE) & ~intrenb;
+       outl(intr_enable, emu->port + INTE);
        spin_unlock_irqrestore(&emu->emu_lock, flags);
 }
 
@@ -507,6 +512,7 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
                 return err;
        if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
                 return err;
+       snd_pcm_set_sync(substream);
 
        if (chip->details->spi_dac && channel_id != PCM_FRONT_CHANNEL) {
                const int reg = spi_dacd_reg[channel_id];
@@ -853,6 +859,9 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
                break;
        }
         snd_pcm_group_for_each_entry(s, substream) {
+               if (snd_pcm_substream_chip(s) != emu ||
+                   s->stream != SNDRV_PCM_STREAM_PLAYBACK)
+                       continue;
                runtime = s->runtime;
                epcm = runtime->private_data;
                channel = epcm->channel_id;
@@ -1110,6 +1119,8 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
                 * So we can fix: snd-malloc: Memory leak?  pages not freed = 8
                 */
        }
+       if (chip->irq >= 0)
+               free_irq(chip->irq, chip);
        // release the data
 #if 1
        if (chip->buffer.area)
@@ -1119,9 +1130,6 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
        // release the i/o port
        release_and_free_resource(chip->res_port);
 
-       // release the irq
-       if (chip->irq >= 0)
-               free_irq(chip->irq, chip);
        pci_disable_device(chip->pci);
        kfree(chip);
        return 0;
@@ -1262,25 +1270,19 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
 static unsigned int spi_dac_init[] = {
        SPI_REG(SPI_LDA1_REG,   SPI_DA_BIT_0dB), /* 0dB dig. attenuation */
        SPI_REG(SPI_RDA1_REG,   SPI_DA_BIT_0dB),
-       SPI_REG(SPI_PL_REG,     0x00),
-       SPI_REG(SPI_PL_REG,     SPI_PL_BIT_L_L | SPI_PL_BIT_R_R),
-       SPI_REG(SPI_FMT_REG,    SPI_FMT_BIT_RJ | SPI_IWL_BIT_24),
+       SPI_REG(SPI_PL_REG,     SPI_PL_BIT_L_L | SPI_PL_BIT_R_R | SPI_IZD_BIT),
+       SPI_REG(SPI_FMT_REG,    SPI_FMT_BIT_I2S | SPI_IWL_BIT_24),
        SPI_REG(SPI_LDA2_REG,   SPI_DA_BIT_0dB),
        SPI_REG(SPI_RDA2_REG,   SPI_DA_BIT_0dB),
        SPI_REG(SPI_LDA3_REG,   SPI_DA_BIT_0dB),
        SPI_REG(SPI_RDA3_REG,   SPI_DA_BIT_0dB),
        SPI_REG(SPI_MASTDA_REG, SPI_DA_BIT_0dB),
        SPI_REG(9,              0x00),
-       SPI_REG(SPI_MS_REG,     0x00),
-       SPI_REG(SPI_MS_REG,     SPI_RATE_BIT_256),
+       SPI_REG(SPI_MS_REG,     SPI_DACD0_BIT | SPI_DACD1_BIT | SPI_DACD2_BIT),
        SPI_REG(12,             0x00),
        SPI_REG(SPI_LDA4_REG,   SPI_DA_BIT_0dB),
-       SPI_REG(SPI_RDA4_REG,   SPI_DA_BIT_0dB),
-       SPI_REG(15,             0x00),
-       SPI_REG(SPI_PL_REG,     SPI_PL_BIT_L_L | SPI_PL_BIT_R_R | SPI_IZD_BIT),
-       SPI_REG(SPI_FMT_REG,    SPI_FMT_BIT_I2S),
-       SPI_REG(SPI_FMT_REG,    SPI_FMT_BIT_I2S | SPI_IWL_BIT_24),
-       SPI_REG(SPI_MS_REG,     SPI_DACD0_BIT | SPI_DACD1_BIT | SPI_DACD2_BIT),
+       SPI_REG(SPI_RDA4_REG,   SPI_DA_BIT_0dB | SPI_DA_BIT_UPDATE),
+       SPI_REG(SPI_DACD4_REG,  0x00),
 };
 
 static unsigned int i2c_adc_init[][2] = {