diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-05-29 04:58:27 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-07-10 09:26:39 -0400 |
commit | fa6e1cb66e2f9d2d4703e7bd7dd50839bb10e4c3 (patch) | |
tree | ec12ed8ef839812d7ae7af1a3d9454f923986177 /sound/pci | |
parent | c63e87e90abb5d3ecd05d6c6eba94163bf8c1760 (diff) |
maestro3: treat firmware data as const
The maestro3 driver is byte-swapping its firmware to be host-endian in
advance, when it doesn't seem to be necessary -- we could just use
le16_to_cpu() as we load it.
Doing that means that we need to switch the in-tree firmware to be
little-endian too.
Take the least intrusive way of doing this, which is to switch the
existing snd_m3_convert_from_le() function to convert _to_ little-endian
instead, and use it on the in-tree firmware instead of the loaded
firmware. It's a bit suboptimal but doesn't matter much right now
because we're about to remove the special cases for the in-tree version
anyway.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/maestro3.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index a536c59fbea1..9dfba6eff858 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c | |||
@@ -2240,18 +2240,16 @@ static const struct firmware assp_minisrc = { | |||
2240 | .size = sizeof assp_minisrc_image | 2240 | .size = sizeof assp_minisrc_image |
2241 | }; | 2241 | }; |
2242 | 2242 | ||
2243 | #else /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */ | ||
2244 | |||
2245 | #ifdef __LITTLE_ENDIAN | 2243 | #ifdef __LITTLE_ENDIAN |
2246 | static inline void snd_m3_convert_from_le(const struct firmware *fw) { } | 2244 | static inline void snd_m3_convert_to_le(const struct firmware *fw) { } |
2247 | #else | 2245 | #else |
2248 | static void snd_m3_convert_from_le(const struct firmware *fw) | 2246 | static void snd_m3_convert_to_le(const struct firmware *fw) |
2249 | { | 2247 | { |
2250 | int i; | 2248 | int i; |
2251 | u16 *data = (u16 *)fw->data; | 2249 | u16 *data = (u16 *)fw->data; |
2252 | 2250 | ||
2253 | for (i = 0; i < fw->size / 2; ++i) | 2251 | for (i = 0; i < fw->size / 2; ++i) |
2254 | le16_to_cpus(&data[i]); | 2252 | cpu_to_le16s(&data[i]); |
2255 | } | 2253 | } |
2256 | #endif | 2254 | #endif |
2257 | 2255 | ||
@@ -2271,7 +2269,7 @@ static const u16 minisrc_lpf[MINISRC_LPF_LEN] = { | |||
2271 | static void snd_m3_assp_init(struct snd_m3 *chip) | 2269 | static void snd_m3_assp_init(struct snd_m3 *chip) |
2272 | { | 2270 | { |
2273 | unsigned int i; | 2271 | unsigned int i; |
2274 | u16 *data; | 2272 | const u16 *data; |
2275 | 2273 | ||
2276 | /* zero kernel data */ | 2274 | /* zero kernel data */ |
2277 | for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++) | 2275 | for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++) |
@@ -2289,10 +2287,11 @@ static void snd_m3_assp_init(struct snd_m3 *chip) | |||
2289 | KDATA_DMA_XFER0); | 2287 | KDATA_DMA_XFER0); |
2290 | 2288 | ||
2291 | /* write kernel into code memory.. */ | 2289 | /* write kernel into code memory.. */ |
2292 | data = (u16 *)chip->assp_kernel_image->data; | 2290 | data = (const u16 *)chip->assp_kernel_image->data; |
2293 | for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { | 2291 | for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { |
2294 | snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, | 2292 | snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, |
2295 | REV_B_CODE_MEMORY_BEGIN + i, data[i]); | 2293 | REV_B_CODE_MEMORY_BEGIN + i, |
2294 | le16_to_cpu(data[i])); | ||
2296 | } | 2295 | } |
2297 | 2296 | ||
2298 | /* | 2297 | /* |
@@ -2301,10 +2300,10 @@ static void snd_m3_assp_init(struct snd_m3 *chip) | |||
2301 | * drop it there. It seems that the minisrc doesn't | 2300 | * drop it there. It seems that the minisrc doesn't |
2302 | * need vectors, so we won't bother with them.. | 2301 | * need vectors, so we won't bother with them.. |
2303 | */ | 2302 | */ |
2304 | data = (u16 *)chip->assp_minisrc_image->data; | 2303 | data = (const u16 *)chip->assp_minisrc_image->data; |
2305 | for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { | 2304 | for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { |
2306 | snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, | 2305 | snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, |
2307 | 0x400 + i, data[i]); | 2306 | 0x400 + i, le16_to_cpu(data[i])); |
2308 | } | 2307 | } |
2309 | 2308 | ||
2310 | /* | 2309 | /* |
@@ -2749,8 +2748,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, | |||
2749 | if (err < 0) { | 2748 | if (err < 0) { |
2750 | snd_m3_free(chip); | 2749 | snd_m3_free(chip); |
2751 | return err; | 2750 | return err; |
2752 | } else | 2751 | } |
2753 | snd_m3_convert_from_le(chip->assp_kernel_image); | ||
2754 | #endif | 2752 | #endif |
2755 | 2753 | ||
2756 | #ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL | 2754 | #ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL |
@@ -2761,8 +2759,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, | |||
2761 | if (err < 0) { | 2759 | if (err < 0) { |
2762 | snd_m3_free(chip); | 2760 | snd_m3_free(chip); |
2763 | return err; | 2761 | return err; |
2764 | } else | 2762 | } |
2765 | snd_m3_convert_from_le(chip->assp_minisrc_image); | ||
2766 | #endif | 2763 | #endif |
2767 | 2764 | ||
2768 | if ((err = pci_request_regions(pci, card->driver)) < 0) { | 2765 | if ((err = pci_request_regions(pci, card->driver)) < 0) { |
@@ -2915,6 +2912,10 @@ static struct pci_driver driver = { | |||
2915 | 2912 | ||
2916 | static int __init alsa_card_m3_init(void) | 2913 | static int __init alsa_card_m3_init(void) |
2917 | { | 2914 | { |
2915 | #ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL | ||
2916 | snd_m3_convert_to_le(&assp_kernel); | ||
2917 | snd_m3_convert_to_le(&assp_minisrc); | ||
2918 | #endif | ||
2918 | return pci_register_driver(&driver); | 2919 | return pci_register_driver(&driver); |
2919 | } | 2920 | } |
2920 | 2921 | ||