Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47096
b: refs/heads/master
c: 81d7724
h: refs/heads/master
v: v3
  • Loading branch information
Clemens Ladisch authored and Jaroslav Kysela committed Feb 9, 2007
1 parent 1d1663a commit ba88bad
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2493a6d18b1f5df59c7bcfeefcbde70bee146490
refs/heads/master: 81d7724a8ee84693befbd60d730199ffb3988f29
1 change: 1 addition & 0 deletions trunk/sound/pci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ config SND_KORG1212
config SND_MAESTRO3
tristate "ESS Allegro/Maestro3"
depends on SND
select FW_LOADER
select SND_AC97_CODEC
help
Say Y here to include support for soundcards based on ESS Maestro 3
Expand Down
79 changes: 73 additions & 6 deletions trunk/sound/pci/maestro3.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/control.h>
#include <sound/pcm.h>
#include <sound/mpu401.h>
#include <sound/ac97_codec.h>
#include <sound/initval.h>
#include <asm/byteorder.h>

MODULE_AUTHOR("Zach Brown <zab@zabbo.net>, Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("ESS Maestro3 PCI");
Expand Down Expand Up @@ -864,6 +866,9 @@ struct snd_m3 {
#ifdef CONFIG_PM
u16 *suspend_mem;
#endif

const struct firmware *assp_kernel_image;
const struct firmware *assp_minisrc_image;
};

/*
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -2260,6 +2269,30 @@ static const u16 assp_minisrc_image[] = {
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
Expand All @@ -2274,6 +2307,7 @@ static const u16 minisrc_lpf[MINISRC_LPF_LEN] = {
static void snd_m3_assp_init(struct snd_m3 *chip)
{
unsigned int i;
u16 *data;

/* zero kernel data */
for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++)
Expand All @@ -2291,10 +2325,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
KDATA_DMA_XFER0);

/* 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,
REV_B_CODE_MEMORY_BEGIN + i,
assp_kernel_image[i]);
REV_B_CODE_MEMORY_BEGIN + i, data[i]);
}

/*
Expand All @@ -2303,10 +2337,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
* drop it there. It seems that the minisrc doesn't
* 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,
0x400 + i,
assp_minisrc_image[i]);
0x400 + i, data[i]);
}

/*
Expand Down Expand Up @@ -2553,6 +2587,15 @@ static int snd_m3_free(struct snd_m3 *chip)
if (chip->iobase)
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);
kfree(chip);
return 0;
Expand Down Expand Up @@ -2744,6 +2787,30 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
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) {
snd_m3_free(chip);
return err;
Expand Down

0 comments on commit ba88bad

Please sign in to comment.