aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2006-11-06 03:24:29 -0500
committerJaroslav Kysela <perex@suse.cz>2007-02-09 03:01:17 -0500
commit2493a6d18b1f5df59c7bcfeefcbde70bee146490 (patch)
treedb6f007875198d304b5b35b8532cadd062bf3c1c
parent226968c7afd464b794f34f9ea8cb4bcfe48447dc (diff)
[ALSA] korg1212: add request_firmware()
Load the DSP code using request_firmware(), if possible, instead of using the built-in blob. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
-rw-r--r--sound/pci/Kconfig1
-rw-r--r--sound/pci/korg1212/korg1212.c45
2 files changed, 37 insertions, 9 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index fcbf9673db62..7573997af760 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -576,6 +576,7 @@ config SND_INTEL8X0M
576config SND_KORG1212 576config SND_KORG1212
577 tristate "Korg 1212 IO" 577 tristate "Korg 1212 IO"
578 depends on SND 578 depends on SND
579 select FW_LOADER
579 select SND_PCM 580 select SND_PCM
580 help 581 help
581 Say Y here to include support for Korg 1212IO soundcards. 582 Say Y here to include support for Korg 1212IO soundcards.
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 345eefeedb39..b4e98f36229b 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -28,6 +28,7 @@
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/firmware.h>
31 32
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/info.h> 34#include <sound/info.h>
@@ -263,7 +264,15 @@ enum MonitorModeSelector {
263#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement 264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement
264 // from the card after sending a command. 265 // from the card after sending a command.
265 266
267#define FIRMWARE_IN_THE_KERNEL
268
269#ifdef FIRMWARE_IN_THE_KERNEL
266#include "korg1212-firmware.h" 270#include "korg1212-firmware.h"
271static const struct firmware static_dsp_code = {
272 .data = (u8 *)dspCode,
273 .size = sizeof dspCode
274};
275#endif
267 276
268enum ClockSourceIndex { 277enum ClockSourceIndex {
269 K1212_CLKIDX_AdatAt44_1K = 0, // selects source as ADAT at 44.1 kHz 278 K1212_CLKIDX_AdatAt44_1K = 0, // selects source as ADAT at 44.1 kHz
@@ -345,8 +354,6 @@ struct snd_korg1212 {
345 struct snd_dma_buffer dma_rec; 354 struct snd_dma_buffer dma_rec;
346 struct snd_dma_buffer dma_shared; 355 struct snd_dma_buffer dma_shared;
347 356
348 u32 dspCodeSize;
349
350 u32 DataBufsSize; 357 u32 DataBufsSize;
351 358
352 struct KorgAudioBuffer * playDataBufsPtr; 359 struct KorgAudioBuffer * playDataBufsPtr;
@@ -1223,8 +1230,6 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
1223 1230
1224 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS); 1231 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
1225 1232
1226 memcpy(korg1212->dma_dsp.area, dspCode, korg1212->dspCodeSize);
1227
1228 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, 1233 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
1229 UpperWordSwap(korg1212->dma_dsp.addr), 1234 UpperWordSwap(korg1212->dma_dsp.addr),
1230 0, 0, 0); 1235 0, 0, 0);
@@ -2156,6 +2161,7 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2156 unsigned int i; 2161 unsigned int i;
2157 unsigned ioport_size, iomem_size, iomem2_size; 2162 unsigned ioport_size, iomem_size, iomem2_size;
2158 struct snd_korg1212 * korg1212; 2163 struct snd_korg1212 * korg1212;
2164 const struct firmware *dsp_code;
2159 2165
2160 static struct snd_device_ops ops = { 2166 static struct snd_device_ops ops = {
2161 .dev_free = snd_korg1212_dev_free, 2167 .dev_free = snd_korg1212_dev_free,
@@ -2329,8 +2335,6 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2329 2335
2330#endif // K1212_LARGEALLOC 2336#endif // K1212_LARGEALLOC
2331 2337
2332 korg1212->dspCodeSize = sizeof (dspCode);
2333
2334 korg1212->VolumeTablePhy = korg1212->sharedBufferPhy + 2338 korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
2335 offsetof(struct KorgSharedBuffer, volumeData); 2339 offsetof(struct KorgSharedBuffer, volumeData);
2336 korg1212->RoutingTablePhy = korg1212->sharedBufferPhy + 2340 korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
@@ -2338,17 +2342,40 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2338 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + 2342 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
2339 offsetof(struct KorgSharedBuffer, AdatTimeCode); 2343 offsetof(struct KorgSharedBuffer, AdatTimeCode);
2340 2344
2345 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
2346 if (err < 0) {
2347 release_firmware(dsp_code);
2348#ifdef FIRMWARE_IN_THE_KERNEL
2349 dsp_code = &static_dsp_code;
2350#else
2351 snd_printk(KERN_ERR "firmware not available\n");
2352 snd_korg1212_free(korg1212);
2353 return err;
2354#endif
2355 }
2356
2341 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2357 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2342 korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) { 2358 dsp_code->size, &korg1212->dma_dsp) < 0) {
2343 snd_printk(KERN_ERR "korg1212: can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize); 2359 snd_printk(KERN_ERR "korg1212: can not allocate dsp code memory (%d bytes)\n", dsp_code->size);
2344 snd_korg1212_free(korg1212); 2360 snd_korg1212_free(korg1212);
2361#ifdef FIRMWARE_IN_THE_KERNEL
2362 if (dsp_code != &static_dsp_code)
2363#endif
2364 release_firmware(dsp_code);
2345 return -ENOMEM; 2365 return -ENOMEM;
2346 } 2366 }
2347 2367
2348 K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", 2368 K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
2349 korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize, 2369 korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
2350 stateName[korg1212->cardState]); 2370 stateName[korg1212->cardState]);
2351 2371
2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
2373
2374#ifdef FIRMWARE_IN_THE_KERNEL
2375 if (dsp_code != &static_dsp_code)
2376#endif
2377 release_firmware(dsp_code);
2378
2352 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); 2379 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
2353 2380
2354 if (rc) 2381 if (rc)