diff options
Diffstat (limited to 'sound/pci/ymfpci/ymfpci_main.c')
-rw-r--r-- | sound/pci/ymfpci/ymfpci_main.c | 74 |
1 files changed, 10 insertions, 64 deletions
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 7129df5f315b..92d49aadf579 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #include <sound/core.h> | 31 | #include <sound/core.h> |
31 | #include <sound/control.h> | 32 | #include <sound/control.h> |
@@ -1993,55 +1994,6 @@ static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip) | |||
1993 | } | 1994 | } |
1994 | } | 1995 | } |
1995 | 1996 | ||
1996 | #ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL | ||
1997 | |||
1998 | #include "ymfpci_image.h" | ||
1999 | |||
2000 | static struct firmware snd_ymfpci_dsp_microcode = { | ||
2001 | .size = YDSXG_DSPLENGTH, | ||
2002 | .data = (u8 *)DspInst, | ||
2003 | }; | ||
2004 | static struct firmware snd_ymfpci_controller_microcode = { | ||
2005 | .size = YDSXG_CTRLLENGTH, | ||
2006 | .data = (u8 *)CntrlInst, | ||
2007 | }; | ||
2008 | static struct firmware snd_ymfpci_controller_1e_microcode = { | ||
2009 | .size = YDSXG_CTRLLENGTH, | ||
2010 | .data = (u8 *)CntrlInst1E, | ||
2011 | }; | ||
2012 | #endif | ||
2013 | |||
2014 | #ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL | ||
2015 | static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) | ||
2016 | { | ||
2017 | chip->dsp_microcode = &snd_ymfpci_dsp_microcode; | ||
2018 | if (chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || | ||
2019 | chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || | ||
2020 | chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || | ||
2021 | chip->device_id == PCI_DEVICE_ID_YAMAHA_754) | ||
2022 | chip->controller_microcode = | ||
2023 | &snd_ymfpci_controller_1e_microcode; | ||
2024 | else | ||
2025 | chip->controller_microcode = | ||
2026 | &snd_ymfpci_controller_microcode; | ||
2027 | return 0; | ||
2028 | } | ||
2029 | |||
2030 | #else /* use fw_loader */ | ||
2031 | |||
2032 | #ifdef __LITTLE_ENDIAN | ||
2033 | static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { } | ||
2034 | #else | ||
2035 | static void snd_ymfpci_convert_from_le(const struct firmware *fw) | ||
2036 | { | ||
2037 | int i; | ||
2038 | u32 *data = (u32 *)fw->data; | ||
2039 | |||
2040 | for (i = 0; i < fw->size / 4; ++i) | ||
2041 | le32_to_cpus(&data[i]); | ||
2042 | } | ||
2043 | #endif | ||
2044 | |||
2045 | static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) | 1997 | static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) |
2046 | { | 1998 | { |
2047 | int err, is_1e; | 1999 | int err, is_1e; |
@@ -2050,9 +2002,7 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) | |||
2050 | err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw", | 2002 | err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw", |
2051 | &chip->pci->dev); | 2003 | &chip->pci->dev); |
2052 | if (err >= 0) { | 2004 | if (err >= 0) { |
2053 | if (chip->dsp_microcode->size == YDSXG_DSPLENGTH) | 2005 | if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) { |
2054 | snd_ymfpci_convert_from_le(chip->dsp_microcode); | ||
2055 | else { | ||
2056 | snd_printk(KERN_ERR "DSP microcode has wrong size\n"); | 2006 | snd_printk(KERN_ERR "DSP microcode has wrong size\n"); |
2057 | err = -EINVAL; | 2007 | err = -EINVAL; |
2058 | } | 2008 | } |
@@ -2067,9 +2017,7 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) | |||
2067 | err = request_firmware(&chip->controller_microcode, name, | 2017 | err = request_firmware(&chip->controller_microcode, name, |
2068 | &chip->pci->dev); | 2018 | &chip->pci->dev); |
2069 | if (err >= 0) { | 2019 | if (err >= 0) { |
2070 | if (chip->controller_microcode->size == YDSXG_CTRLLENGTH) | 2020 | if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) { |
2071 | snd_ymfpci_convert_from_le(chip->controller_microcode); | ||
2072 | else { | ||
2073 | snd_printk(KERN_ERR "controller microcode" | 2021 | snd_printk(KERN_ERR "controller microcode" |
2074 | " has wrong size\n"); | 2022 | " has wrong size\n"); |
2075 | err = -EINVAL; | 2023 | err = -EINVAL; |
@@ -2084,13 +2032,11 @@ MODULE_FIRMWARE("yamaha/ds1_dsp.fw"); | |||
2084 | MODULE_FIRMWARE("yamaha/ds1_ctrl.fw"); | 2032 | MODULE_FIRMWARE("yamaha/ds1_ctrl.fw"); |
2085 | MODULE_FIRMWARE("yamaha/ds1e_ctrl.fw"); | 2033 | MODULE_FIRMWARE("yamaha/ds1e_ctrl.fw"); |
2086 | 2034 | ||
2087 | #endif | ||
2088 | |||
2089 | static void snd_ymfpci_download_image(struct snd_ymfpci *chip) | 2035 | static void snd_ymfpci_download_image(struct snd_ymfpci *chip) |
2090 | { | 2036 | { |
2091 | int i; | 2037 | int i; |
2092 | u16 ctrl; | 2038 | u16 ctrl; |
2093 | u32 *inst; | 2039 | const __le32 *inst; |
2094 | 2040 | ||
2095 | snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000); | 2041 | snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000); |
2096 | snd_ymfpci_disable_dsp(chip); | 2042 | snd_ymfpci_disable_dsp(chip); |
@@ -2105,14 +2051,16 @@ static void snd_ymfpci_download_image(struct snd_ymfpci *chip) | |||
2105 | snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); | 2051 | snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); |
2106 | 2052 | ||
2107 | /* setup DSP instruction code */ | 2053 | /* setup DSP instruction code */ |
2108 | inst = (u32 *)chip->dsp_microcode->data; | 2054 | inst = (const __le32 *)chip->dsp_microcode->data; |
2109 | for (i = 0; i < YDSXG_DSPLENGTH / 4; i++) | 2055 | for (i = 0; i < YDSXG_DSPLENGTH / 4; i++) |
2110 | snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), inst[i]); | 2056 | snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), |
2057 | le32_to_cpu(inst[i])); | ||
2111 | 2058 | ||
2112 | /* setup control instruction code */ | 2059 | /* setup control instruction code */ |
2113 | inst = (u32 *)chip->controller_microcode->data; | 2060 | inst = (const __le32 *)chip->controller_microcode->data; |
2114 | for (i = 0; i < YDSXG_CTRLLENGTH / 4; i++) | 2061 | for (i = 0; i < YDSXG_CTRLLENGTH / 4; i++) |
2115 | snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), inst[i]); | 2062 | snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), |
2063 | le32_to_cpu(inst[i])); | ||
2116 | 2064 | ||
2117 | snd_ymfpci_enable_dsp(chip); | 2065 | snd_ymfpci_enable_dsp(chip); |
2118 | } | 2066 | } |
@@ -2265,10 +2213,8 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip) | |||
2265 | pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); | 2213 | pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); |
2266 | 2214 | ||
2267 | pci_disable_device(chip->pci); | 2215 | pci_disable_device(chip->pci); |
2268 | #ifndef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL | ||
2269 | release_firmware(chip->dsp_microcode); | 2216 | release_firmware(chip->dsp_microcode); |
2270 | release_firmware(chip->controller_microcode); | 2217 | release_firmware(chip->controller_microcode); |
2271 | #endif | ||
2272 | kfree(chip); | 2218 | kfree(chip); |
2273 | return 0; | 2219 | return 0; |
2274 | } | 2220 | } |