aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt44
-rw-r--r--sound/isa/Kconfig9
-rw-r--r--sound/isa/wavefront/wavefront_synth.c120
3 files changed, 92 insertions, 81 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index d7660549bb91..3df33ea8bae6 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -1716,8 +1716,52 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1716 dma2 - DMA2 # for CS4232 PCM interface. 1716 dma2 - DMA2 # for CS4232 PCM interface.
1717 isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) 1717 isapnp - ISA PnP detection - 0 = disable, 1 = enable (default)
1718 1718
1719 The below are options for wavefront_synth features:
1720 wf_raw - Assume that we need to boot the OS (default:no)
1721 If yes, then during driver loading, the state of the board is
1722 ignored, and we reset the board and load the firmware anyway.
1723 fx_raw - Assume that the FX process needs help (default:yes)
1724 If false, we'll leave the FX processor in whatever state it is
1725 when the driver is loaded. The default is to download the
1726 microprogram and associated coefficients to set it up for
1727 "default" operation, whatever that means.
1728 debug_default - Debug parameters for card initialization
1729 wait_usecs - How long to wait without sleeping, usecs
1730 (default:150)
1731 This magic number seems to give pretty optimal throughput
1732 based on my limited experimentation.
1733 If you want to play around with it and find a better value, be
1734 my guest. Remember, the idea is to get a number that causes us
1735 to just busy wait for as many WaveFront commands as possible,
1736 without coming up with a number so large that we hog the whole
1737 CPU.
1738 Specifically, with this number, out of about 134,000 status
1739 waits, only about 250 result in a sleep.
1740 sleep_interval - How long to sleep when waiting for reply
1741 (default: 100)
1742 sleep_tries - How many times to try sleeping during a wait
1743 (default: 50)
1744 ospath - Pathname to processed ICS2115 OS firmware
1745 (default:wavefront.os)
1746 The path name of the ISC2115 OS firmware. In the recent
1747 version, it's handled via firmware loader framework, so it
1748 must be installed in the proper path, typically,
1749 /lib/firmware.
1750 reset_time - How long to wait for a reset to take effect
1751 (default:2)
1752 ramcheck_time - How many seconds to wait for the RAM test
1753 (default:20)
1754 osrun_time - How many seconds to wait for the ICS2115 OS
1755 (default:10)
1756
1719 This module supports multiple cards and ISA PnP. 1757 This module supports multiple cards and ISA PnP.
1720 1758
1759 Note: the firmware file "wavefront.os" was located in the earlier
1760 version in /etc. Now it's loaded via firmware loader, and
1761 must be in the proper firmware path, such as /lib/firmware.
1762 Copy (or symlink) the file appropriately if you get an error
1763 regarding firmware downloading after upgrading the kernel.
1764
1721 Module snd-sonicvibes 1765 Module snd-sonicvibes
1722 --------------------- 1766 ---------------------
1723 1767
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);