aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-08-21 09:20:26 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:59:22 -0400
commitc2b1239a9f22f19c53543b460b24507d0e21ea0c (patch)
tree6378247be17a1cf8884b03ea189f25d3ebb3a7a9 /sound/isa
parent33bf17abf98087d7a6eec9476cd767c6e998fc05 (diff)
[ALSA] wavefront - Use standard firmware loader
Use the standard firmware loader for loading ICS2115 OS firmware file. This is the last old bad guy that is still using sys_open() and sys_read() calls, and now all should be gone. The patch also adds the missing description of module options related with wavefront_synth.c. Due to this rewrite, user will have to copy or make symlink the firmware file appropriately to the standard firmware path such as /lib/firmware. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/isa')
-rw-r--r--sound/isa/Kconfig9
-rw-r--r--sound/isa/wavefront/wavefront_synth.c120
2 files changed, 48 insertions, 81 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index ea5084abe60f..6b6aa2c3b85c 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -414,7 +414,7 @@ config SND_SSCAPE
414config SND_WAVEFRONT 414config SND_WAVEFRONT
415 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" 415 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
416 depends on SND 416 depends on SND
417 select FW_LOADER if !SND_WAVEFRONT_FIRMWARE_IN_KERNEL 417 select FW_LOADER
418 select SND_OPL3_LIB 418 select SND_OPL3_LIB
419 select SND_MPU401_UART 419 select SND_MPU401_UART
420 select SND_CS4231_LIB 420 select SND_CS4231_LIB
@@ -430,8 +430,9 @@ config SND_WAVEFRONT_FIRMWARE_IN_KERNEL
430 depends on SND_WAVEFRONT 430 depends on SND_WAVEFRONT
431 default y 431 default y
432 help 432 help
433 Say Y here to include the static firmware built in the kernel 433 Say Y here to include the static firmware for FX DSP built in
434 for the Wavefront driver. If you choose N here, you need to 434 the kernel for the Wavefront driver. If you choose N here,
435 install the firmware files from the alsa-firmware package. 435 you need to install the firmware files from the
436 alsa-firmware package.
436 437
437endmenu 438endmenu
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index bacc51c86587..2da11e8337dd 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -27,6 +27,7 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/time.h> 28#include <linux/time.h>
29#include <linux/wait.h> 29#include <linux/wait.h>
30#include <linux/firmware.h>
30#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
31#include <sound/core.h> 32#include <sound/core.h>
32#include <sound/snd_wavefront.h> 33#include <sound/snd_wavefront.h>
@@ -53,9 +54,8 @@ static int debug_default = 0; /* you can set this to control debugging
53 54
54/* XXX this needs to be made firmware and hardware version dependent */ 55/* XXX this needs to be made firmware and hardware version dependent */
55 56
56static char *ospath = "/etc/sound/wavefront.os"; /* where to find a processed 57#define DEFAULT_OSPATH "wavefront.os"
57 version of the WaveFront OS 58static char *ospath = DEFAULT_OSPATH; /* the firmware file name */
58 */
59 59
60static int wait_usecs = 150; /* This magic number seems to give pretty optimal 60static int wait_usecs = 150; /* This magic number seems to give pretty optimal
61 throughput based on my limited experimentation. 61 throughput based on my limited experimentation.
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(sleep_interval, "how long to sleep when waiting for reply");
97module_param(sleep_tries, int, 0444); 97module_param(sleep_tries, int, 0444);
98MODULE_PARM_DESC(sleep_tries, "how many times to try sleeping during a wait"); 98MODULE_PARM_DESC(sleep_tries, "how many times to try sleeping during a wait");
99module_param(ospath, charp, 0444); 99module_param(ospath, charp, 0444);
100MODULE_PARM_DESC(ospath, "full pathname to processed ICS2115 OS firmware"); 100MODULE_PARM_DESC(ospath, "pathname to processed ICS2115 OS firmware");
101module_param(reset_time, int, 0444); 101module_param(reset_time, int, 0444);
102MODULE_PARM_DESC(reset_time, "how long to wait for a reset to take effect"); 102MODULE_PARM_DESC(reset_time, "how long to wait for a reset to take effect");
103module_param(ramcheck_time, int, 0444); 103module_param(ramcheck_time, int, 0444);
@@ -1938,111 +1938,75 @@ wavefront_reset_to_cleanliness (snd_wavefront_t *dev)
1938 return (1); 1938 return (1);
1939} 1939}
1940 1940
1941#include <linux/fs.h>
1942#include <linux/mm.h>
1943#include <linux/slab.h>
1944#include <linux/unistd.h>
1945#include <linux/syscalls.h>
1946#include <asm/uaccess.h>
1947
1948
1949static int __devinit 1941static int __devinit
1950wavefront_download_firmware (snd_wavefront_t *dev, char *path) 1942wavefront_download_firmware (snd_wavefront_t *dev, char *path)
1951 1943
1952{ 1944{
1953 unsigned char section[WF_SECTION_MAX]; 1945 unsigned char *buf;
1954 signed char section_length; /* yes, just a char; max value is WF_SECTION_MAX */ 1946 int len, err;
1955 int section_cnt_downloaded = 0; 1947 int section_cnt_downloaded = 0;
1956 int fd; 1948 const struct firmware *firmware;
1957 int c;
1958 int i;
1959 mm_segment_t fs;
1960
1961 /* This tries to be a bit cleverer than the stuff Alan Cox did for
1962 the generic sound firmware, in that it actually knows
1963 something about the structure of the Motorola firmware. In
1964 particular, it uses a version that has been stripped of the
1965 20K of useless header information, and had section lengths
1966 added, making it possible to load the entire OS without any
1967 [kv]malloc() activity, since the longest entity we ever read is
1968 42 bytes (well, WF_SECTION_MAX) long.
1969 */
1970
1971 fs = get_fs();
1972 set_fs (get_ds());
1973 1949
1974 if ((fd = sys_open ((char __user *) path, 0, 0)) < 0) { 1950 err = request_firmware(&firmware, path, dev->card->dev);
1975 snd_printk ("Unable to load \"%s\".\n", 1951 if (err < 0) {
1976 path); 1952 snd_printk(KERN_ERR "firmware (%s) download failed!!!\n", path);
1977 return 1; 1953 return 1;
1978 } 1954 }
1979 1955
1980 while (1) { 1956 len = 0;
1981 int x; 1957 buf = firmware->data;
1982 1958 for (;;) {
1983 if ((x = sys_read (fd, (char __user *) &section_length, sizeof (section_length))) != 1959 int section_length = *(signed char *)buf;
1984 sizeof (section_length)) { 1960 if (section_length == 0)
1985 snd_printk ("firmware read error.\n");
1986 goto failure;
1987 }
1988
1989 if (section_length == 0) {
1990 break; 1961 break;
1991 }
1992
1993 if (section_length < 0 || section_length > WF_SECTION_MAX) { 1962 if (section_length < 0 || section_length > WF_SECTION_MAX) {
1994 snd_printk ("invalid firmware section length %d\n", 1963 snd_printk(KERN_ERR
1995 section_length); 1964 "invalid firmware section length %d\n",
1965 section_length);
1996 goto failure; 1966 goto failure;
1997 } 1967 }
1968 buf++;
1969 len++;
1998 1970
1999 if (sys_read (fd, (char __user *) section, section_length) != section_length) { 1971 if (firmware->size < len + section_length) {
2000 snd_printk ("firmware section " 1972 snd_printk(KERN_ERR "firmware section read error.\n");
2001 "read error.\n");
2002 goto failure; 1973 goto failure;
2003 } 1974 }
2004 1975
2005 /* Send command */ 1976 /* Send command */
2006 1977 if (wavefront_write(dev, WFC_DOWNLOAD_OS))
2007 if (wavefront_write (dev, WFC_DOWNLOAD_OS)) {
2008 goto failure; 1978 goto failure;
2009 }
2010 1979
2011 for (i = 0; i < section_length; i++) { 1980 for (; section_length; section_length--) {
2012 if (wavefront_write (dev, section[i])) { 1981 if (wavefront_write(dev, *buf))
2013 goto failure; 1982 goto failure;
2014 } 1983 buf++;
1984 len++;
2015 } 1985 }
2016 1986
2017 /* get ACK */ 1987 /* get ACK */
2018 1988 if (!wavefront_wait(dev, STAT_CAN_READ)) {
2019 if (wavefront_wait (dev, STAT_CAN_READ)) { 1989 snd_printk(KERN_ERR "time out for firmware ACK.\n");
2020 1990 goto failure;
2021 if ((c = inb (dev->data_port)) != WF_ACK) { 1991 }
2022 1992 err = inb(dev->data_port);
2023 snd_printk ("download " 1993 if (err != WF_ACK) {
2024 "of section #%d not " 1994 snd_printk(KERN_ERR
2025 "acknowledged, ack = 0x%x\n", 1995 "download of section #%d not "
2026 section_cnt_downloaded + 1, c); 1996 "acknowledged, ack = 0x%x\n",
2027 goto failure; 1997 section_cnt_downloaded + 1, err);
2028
2029 }
2030
2031 } else {
2032 snd_printk ("time out for firmware ACK.\n");
2033 goto failure; 1998 goto failure;
2034 } 1999 }
2035 2000
2001 section_cnt_downloaded++;
2036 } 2002 }
2037 2003
2038 sys_close (fd); 2004 release_firmware(firmware);
2039 set_fs (fs);
2040 return 0; 2005 return 0;
2041 2006
2042 failure: 2007 failure:
2043 sys_close (fd); 2008 release_firmware(firmware);
2044 set_fs (fs); 2009 snd_printk(KERN_ERR "firmware download failed!!!\n");
2045 snd_printk ("firmware download failed!!!\n");
2046 return 1; 2010 return 1;
2047} 2011}
2048 2012
@@ -2232,3 +2196,5 @@ snd_wavefront_detect (snd_wavefront_card_t *card)
2232 2196
2233 return 0; 2197 return 0;
2234} 2198}
2199
2200MODULE_FIRMWARE(DEFAULT_OSPATH);