Skip to content

Commit

Permalink
[ALSA] korg1212: add request_firmware()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed Feb 9, 2007
1 parent 226968c commit 2493a6d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions sound/pci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ config SND_INTEL8X0M
config SND_KORG1212
tristate "Korg 1212 IO"
depends on SND
select FW_LOADER
select SND_PCM
help
Say Y here to include support for Korg 1212IO soundcards.
Expand Down
45 changes: 36 additions & 9 deletions sound/pci/korg1212/korg1212.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -263,7 +264,15 @@ enum MonitorModeSelector {
#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement
// from the card after sending a command.

#define FIRMWARE_IN_THE_KERNEL

#ifdef FIRMWARE_IN_THE_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
Expand Down Expand Up @@ -345,8 +354,6 @@ struct snd_korg1212 {
struct snd_dma_buffer dma_rec;
struct snd_dma_buffer dma_shared;

u32 dspCodeSize;

u32 DataBufsSize;

struct KorgAudioBuffer * playDataBufsPtr;
Expand Down Expand Up @@ -1223,8 +1230,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);
Expand Down Expand Up @@ -2156,6 +2161,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,
Expand Down Expand Up @@ -2329,26 +2335,47 @@ 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 +
offsetof(struct KorgSharedBuffer, routeData);
korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
offsetof(struct KorgSharedBuffer, AdatTimeCode);

err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
if (err < 0) {
release_firmware(dsp_code);
#ifdef FIRMWARE_IN_THE_KERNEL
dsp_code = &static_dsp_code;
#else
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: can not allocate dsp code memory (%d bytes)\n", dsp_code->size);
snd_korg1212_free(korg1212);
#ifdef FIRMWARE_IN_THE_KERNEL
if (dsp_code != &static_dsp_code)
#endif
release_firmware(dsp_code);
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);

#ifdef FIRMWARE_IN_THE_KERNEL
if (dsp_code != &static_dsp_code)
#endif
release_firmware(dsp_code);

rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);

if (rc)
Expand Down

0 comments on commit 2493a6d

Please sign in to comment.