Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100964
b: refs/heads/master
c: b82a82d
h: refs/heads/master
v: v3
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jul 10, 2008
1 parent 46a5243 commit f72af4b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 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: fa6e1cb66e2f9d2d4703e7bd7dd50839bb10e4c3
refs/heads/master: b82a82d0a90af74847ae3e873a241dedf3786fd5
59 changes: 34 additions & 25 deletions trunk/sound/pci/ymfpci/ymfpci_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mutex.h>

#include <sound/core.h>
#include <sound/control.h>
Expand Down Expand Up @@ -2009,11 +2010,34 @@ static struct firmware snd_ymfpci_controller_1e_microcode = {
.size = YDSXG_CTRLLENGTH,
.data = (u8 *)CntrlInst1E,
};

#ifdef __BIG_ENDIAN
static int microcode_swapped;
static DEFINE_MUTEX(microcode_swap);

static void snd_ymfpci_convert_to_le(const struct firmware *fw)
{
int i;
u32 *data = (u32 *)fw->data;

for (i = 0; i < fw->size / 4; ++i)
cpu_to_le32s(&data[i]);
}
#endif

#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
{
#ifdef __BIG_ENDIAN
mutex_lock(&microcode_swap);
if (!microcode_swapped) {
snd_ymfpci_convert_to_le(&snd_ymfpci_dsp_microcode);
snd_ymfpci_convert_to_le(&snd_ymfpci_controller_1e_microcode);
snd_ymfpci_convert_to_le(&snd_ymfpci_controller_microcode);
microcode_swapped = 1;
}
mutex_unlock(&microcode_swap);
#endif

chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
if (chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
Expand All @@ -2029,19 +2053,6 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)

#else /* use fw_loader */

#ifdef __LITTLE_ENDIAN
static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { }
#else
static void snd_ymfpci_convert_from_le(const struct firmware *fw)
{
int i;
u32 *data = (u32 *)fw->data;

for (i = 0; i < fw->size / 4; ++i)
le32_to_cpus(&data[i]);
}
#endif

static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
{
int err, is_1e;
Expand All @@ -2050,9 +2061,7 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw",
&chip->pci->dev);
if (err >= 0) {
if (chip->dsp_microcode->size == YDSXG_DSPLENGTH)
snd_ymfpci_convert_from_le(chip->dsp_microcode);
else {
if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) {
snd_printk(KERN_ERR "DSP microcode has wrong size\n");
err = -EINVAL;
}
Expand All @@ -2067,9 +2076,7 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
err = request_firmware(&chip->controller_microcode, name,
&chip->pci->dev);
if (err >= 0) {
if (chip->controller_microcode->size == YDSXG_CTRLLENGTH)
snd_ymfpci_convert_from_le(chip->controller_microcode);
else {
if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) {
snd_printk(KERN_ERR "controller microcode"
" has wrong size\n");
err = -EINVAL;
Expand All @@ -2090,7 +2097,7 @@ static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
{
int i;
u16 ctrl;
u32 *inst;
const __le32 *inst;

snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000);
snd_ymfpci_disable_dsp(chip);
Expand All @@ -2105,14 +2112,16 @@ static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007);

/* setup DSP instruction code */
inst = (u32 *)chip->dsp_microcode->data;
inst = (const __le32 *)chip->dsp_microcode->data;
for (i = 0; i < YDSXG_DSPLENGTH / 4; i++)
snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), inst[i]);
snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2),
le32_to_cpu(inst[i]));

/* setup control instruction code */
inst = (u32 *)chip->controller_microcode->data;
inst = (const __le32 *)chip->controller_microcode->data;
for (i = 0; i < YDSXG_CTRLLENGTH / 4; i++)
snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), inst[i]);
snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2),
le32_to_cpu(inst[i]));

snd_ymfpci_enable_dsp(chip);
}
Expand Down

0 comments on commit f72af4b

Please sign in to comment.