Commit 81d7724a authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] maestro3: add request_firmware()

Load the ASSP codes using request_firmware(), if possible, instead of
using the built-in blobs.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 2493a6d1
...@@ -587,6 +587,7 @@ config SND_KORG1212 ...@@ -587,6 +587,7 @@ config SND_KORG1212
config SND_MAESTRO3 config SND_MAESTRO3
tristate "ESS Allegro/Maestro3" tristate "ESS Allegro/Maestro3"
depends on SND depends on SND
select FW_LOADER
select SND_AC97_CODEC select SND_AC97_CODEC
help help
Say Y here to include support for soundcards based on ESS Maestro 3 Say Y here to include support for soundcards based on ESS Maestro 3
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/info.h> #include <sound/info.h>
#include <sound/control.h> #include <sound/control.h>
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
#include <sound/mpu401.h> #include <sound/mpu401.h>
#include <sound/ac97_codec.h> #include <sound/ac97_codec.h>
#include <sound/initval.h> #include <sound/initval.h>
#include <asm/byteorder.h>
MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>"); MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("ESS Maestro3 PCI"); MODULE_DESCRIPTION("ESS Maestro3 PCI");
...@@ -864,6 +866,9 @@ struct snd_m3 { ...@@ -864,6 +866,9 @@ struct snd_m3 {
#ifdef CONFIG_PM #ifdef CONFIG_PM
u16 *suspend_mem; u16 *suspend_mem;
#endif #endif
const struct firmware *assp_kernel_image;
const struct firmware *assp_minisrc_image;
}; };
/* /*
...@@ -2132,6 +2137,10 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip) ...@@ -2132,6 +2137,10 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
} }
#define FIRMWARE_IN_THE_KERNEL
#ifdef FIRMWARE_IN_THE_KERNEL
/* /*
* DSP Code images * DSP Code images
*/ */
...@@ -2260,6 +2269,30 @@ static const u16 assp_minisrc_image[] = { ...@@ -2260,6 +2269,30 @@ static const u16 assp_minisrc_image[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
}; };
static const struct firmware assp_kernel = {
.data = (u8 *)assp_kernel_image,
.size = sizeof assp_kernel_image
};
static const struct firmware assp_minisrc = {
.data = (u8 *)assp_minisrc_image,
.size = sizeof assp_minisrc_image
};
#endif /* FIRMWARE_IN_THE_KERNEL */
#ifdef __LITTLE_ENDIAN
static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
#else
static void snd_m3_convert_from_le(const struct firmware *fw)
{
int i;
u16 *data = (u16 *)fw->data;
for (i = 0; i < fw->size / 2; ++i)
le16_to_cpus(&data[i]);
}
#endif
/* /*
* initialize ASSP * initialize ASSP
...@@ -2274,6 +2307,7 @@ static const u16 minisrc_lpf[MINISRC_LPF_LEN] = { ...@@ -2274,6 +2307,7 @@ static const u16 minisrc_lpf[MINISRC_LPF_LEN] = {
static void snd_m3_assp_init(struct snd_m3 *chip) static void snd_m3_assp_init(struct snd_m3 *chip)
{ {
unsigned int i; unsigned int i;
u16 *data;
/* zero kernel data */ /* zero kernel data */
for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++) for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++)
...@@ -2291,10 +2325,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip) ...@@ -2291,10 +2325,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
KDATA_DMA_XFER0); KDATA_DMA_XFER0);
/* write kernel into code memory.. */ /* write kernel into code memory.. */
for (i = 0 ; i < ARRAY_SIZE(assp_kernel_image); i++) { data = (u16 *)chip->assp_kernel_image->data;
for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) {
snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE,
REV_B_CODE_MEMORY_BEGIN + i, REV_B_CODE_MEMORY_BEGIN + i, data[i]);
assp_kernel_image[i]);
} }
/* /*
...@@ -2303,10 +2337,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip) ...@@ -2303,10 +2337,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
* drop it there. It seems that the minisrc doesn't * drop it there. It seems that the minisrc doesn't
* need vectors, so we won't bother with them.. * need vectors, so we won't bother with them..
*/ */
for (i = 0; i < ARRAY_SIZE(assp_minisrc_image); i++) { data = (u16 *)chip->assp_minisrc_image->data;
for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) {
snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE,
0x400 + i, 0x400 + i, data[i]);
assp_minisrc_image[i]);
} }
/* /*
...@@ -2553,6 +2587,15 @@ static int snd_m3_free(struct snd_m3 *chip) ...@@ -2553,6 +2587,15 @@ static int snd_m3_free(struct snd_m3 *chip)
if (chip->iobase) if (chip->iobase)
pci_release_regions(chip->pci); pci_release_regions(chip->pci);
#ifdef FIRMWARE_IN_THE_KERNEL
if (chip->assp_kernel_image != &assp_kernel)
#endif
release_firmware(chip->assp_kernel_image);
#ifdef FIRMWARE_IN_THE_KERNEL
if (chip->assp_minisrc_image != &assp_minisrc)
#endif
release_firmware(chip->assp_minisrc_image);
pci_disable_device(chip->pci); pci_disable_device(chip->pci);
kfree(chip); kfree(chip);
return 0; return 0;
...@@ -2744,6 +2787,30 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, ...@@ -2744,6 +2787,30 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
return -ENOMEM; return -ENOMEM;
} }
err = request_firmware(&chip->assp_kernel_image,
"ess/maestro3_assp_kernel.fw", &pci->dev);
if (err < 0) {
#ifdef FIRMWARE_IN_THE_KERNEL
chip->assp_kernel_image = &assp_kernel;
#else
snd_m3_free(chip);
return err;
#endif
} else
snd_m3_convert_from_le(chip->assp_kernel_image);
err = request_firmware(&chip->assp_minisrc_image,
"ess/maestro3_assp_minisrc.fw", &pci->dev);
if (err < 0) {
#ifdef FIRMWARE_IN_THE_KERNEL
chip->assp_minisrc_image = &assp_minisrc;
#else
snd_m3_free(chip);
return err;
#endif
} else
snd_m3_convert_from_le(chip->assp_minisrc_image);
if ((err = pci_request_regions(pci, card->driver)) < 0) { if ((err = pci_request_regions(pci, card->driver)) < 0) {
snd_m3_free(chip); snd_m3_free(chip);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment