[ALSA] remove incorrect usage of SNDRV_PCM_INFO_SYNC_START and snd_pcm_set_sync()
[deliverable/linux.git] / sound / pci / korg1212 / korg1212.c
index 345eefeedb394628c9f8ffb224fc54ce278ebb76..c4af57fb5af15d28cc92fa759e217be664a7639d 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/wait.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
+#include <linux/firmware.h>
 
 #include <sound/core.h>
 #include <sound/info.h>
@@ -263,7 +264,13 @@ enum MonitorModeSelector {
 #define COMMAND_ACK_DELAY   13         // number of RTC ticks to wait for an acknowledgement
                                        //    from the card after sending a command.
 
+#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
 #include "korg1212-firmware.h"
+static const struct firmware static_dsp_code = {
+       .data = (u8 *)dspCode,
+       .size = sizeof dspCode
+};
+#endif
 
 enum ClockSourceIndex {
    K1212_CLKIDX_AdatAt44_1K = 0,    // selects source as ADAT at 44.1 kHz
@@ -345,8 +352,6 @@ struct snd_korg1212 {
         struct snd_dma_buffer dma_rec;
        struct snd_dma_buffer dma_shared;
 
-        u32 dspCodeSize;
-
        u32 DataBufsSize;
 
         struct KorgAudioBuffer  * playDataBufsPtr;
@@ -411,6 +416,9 @@ struct snd_korg1212 {
 MODULE_DESCRIPTION("korg1212");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+MODULE_FIRMWARE("korg/k1212.dsp");
+#endif
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;         /* ID for this card */
@@ -1223,8 +1231,6 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
 
         snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
 
-        memcpy(korg1212->dma_dsp.area, dspCode, korg1212->dspCodeSize);
-
         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
                                      UpperWordSwap(korg1212->dma_dsp.addr),
                                      0, 0, 0);
@@ -1385,8 +1391,6 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream)
        K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n",
                           stateName[korg1212->cardState]);
 
-        snd_pcm_set_sync(substream);    // ???
-
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_playback_info;
@@ -1416,8 +1420,6 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream)
        K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n",
                           stateName[korg1212->cardState]);
 
-        snd_pcm_set_sync(substream);
-
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_capture_info;
@@ -2156,6 +2158,7 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
         unsigned int i;
        unsigned ioport_size, iomem_size, iomem2_size;
         struct snd_korg1212 * korg1212;
+       const struct firmware *dsp_code;
 
         static struct snd_device_ops ops = {
                 .dev_free = snd_korg1212_dev_free,
@@ -2329,8 +2332,6 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
 
 #endif // K1212_LARGEALLOC
 
-        korg1212->dspCodeSize = sizeof (dspCode);
-
         korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
                offsetof(struct KorgSharedBuffer, volumeData);
         korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
@@ -2338,17 +2339,38 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
         korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
                offsetof(struct KorgSharedBuffer, AdatTimeCode);
 
+#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+       dsp_code = &static_dsp_code;
+#else
+       err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
+       if (err < 0) {
+               release_firmware(dsp_code);
+               snd_printk(KERN_ERR "firmware not available\n");
+               snd_korg1212_free(korg1212);
+               return err;
+       }
+#endif
+
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
-                               korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
-               snd_printk(KERN_ERR "korg1212: can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize);
+                               dsp_code->size, &korg1212->dma_dsp) < 0) {
+               snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
                 snd_korg1212_free(korg1212);
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+               release_firmware(dsp_code);
+#endif
                 return -ENOMEM;
         }
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
-                  korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize,
+                  korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
                   stateName[korg1212->cardState]);
 
+       memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
+
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+       release_firmware(dsp_code);
+#endif
+
        rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
 
        if (rc)
This page took 0.027173 seconds and 5 git commands to generate.