GIT 7b901db29e4c858cfa6bcbb30ecd9a1bbea5755f git+ssh://master.kernel.org/pub/scm/linux/kernel/git/perex/alsa.git#mm commit Author: Tobin Davis Date: Mon Feb 26 16:07:42 2007 +0100 [ALSA] hda-codec - Fix logic error in headphone mute for Conexant codecs This patch fixes a logic error introduced in the previous patch. Without it, speaker automute mutes the speakers when headphones are removed and unmutes when headphones are plugged in. This was reported by Gregorio Guidi after getting the earlier patch off this mailing list. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit beb0d9c1359c860371132c3239ee3baa1bab2946 Author: Takashi Iwai Date: Mon Feb 26 16:00:34 2007 +0100 [ALSA] hda-codec - Add missing Mic Boost for AD1986A codec Added the missing 'Mic Boost' switch for AD1986A codec. This influences largely on the recording level of mic-input on some boards. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit d0259f8acb8faf6ca9baebfeafa3cb993cf22969 Author: Takashi Iwai Date: Mon Feb 26 15:56:46 2007 +0100 [ALSA] hda-codec - Allow model=generic always for generic parser Accept model=generic option to specify the generic parser regardless of codec chips. This is helpful for testing and debugging. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 295e8c3e7ab6ff195066b78351fb257029f2f87f Author: Takashi Iwai Date: Mon Feb 26 15:55:43 2007 +0100 [ALSA] Enable Kconfig options for external firmwares Some drivers are already ifdefs for enabling external firmwares but not defined in Kconfig. Now they appear as the kernel configs. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7e323357402cac5eb5e6f753a317f23410baa174 Author: Takashi Iwai Date: Thu Feb 22 16:07:21 2007 +0100 [ALSA] mpu401 - Add MPU401_INFO_UART_ONLY bitflag Added MPU401_INFO_UART_ONLY bitflag to avoid issueing UART_ENTER command at opening streams. Some devices support only UART mode and give errors to UART_ENTER. A new module option, uart_enter, is added to snd-mpu401 driver. For UART-only devices, set uart_enter=0. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 8012090f11149098e56123e23315e716ab76814c Author: Takashi Iwai Date: Thu Feb 22 13:31:08 2007 +0100 [ALSA] bt87x - Add ATI TV-Wonder to the supported list Added ATI TV-Wonder (1002:0001) to the supported list. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit de0334f608f0ffe3fc6a1d124ec838f7a3919491 Author: vignesh babu Date: Thu Feb 22 13:23:01 2007 +0100 [ALSA] is_power_of_2 in rtctimer.c Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2 Signed-off-by: vignesh babu Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7bbe13b94ef01d3b1e13d01e8c759e922539f1e7 Author: Takashi Iwai Date: Thu Feb 22 12:58:27 2007 +0100 [ALSA] ac97 - Make patch functions static Include ac97_patch.c from the main ac97_codec.c in order to make bunch of patch_*() functions static. This helps optimization. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 5f4e639b0ccaafffee6f0a924679357118c8dfcd Author: Takashi Iwai Date: Thu Feb 22 12:52:53 2007 +0100 [ALSA] Add snd_pcm_group_for_each_entry() for code cleanup Added a new macro snd_pcm_group_for_each_entry() just for code cleanup. Old macros, snd_pcm_group_for_each() and snd_pcm_group_substream_entry(), are removed. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7b437aa7096a11f99bb6eac0042fb31108044711 Author: Takashi Iwai Date: Thu Feb 22 12:50:54 2007 +0100 [ALSA] Port the rest of ALSA ISA drivers to isa_driver Port the rest of ALSA ISA drivers to use isa_driver framework instead of platform_driver. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 99fdb6a987fa864533777335c51be12f584369c2 Author: Takashi Iwai Date: Thu Feb 22 12:47:25 2007 +0100 [ALSA] ac97 - Add Thinkpad X31 and R40 to AD1981x blacklist Added Thinkpad X31 and R40 to AD1981x line/HP-jack-sense blacklist for avoiding the harmful mixer controls. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit ddb03a9aebbcdc8a1710be4fc960b9977a068871 Author: Takashi Iwai Date: Mon Feb 19 15:27:33 2007 +0100 [ALSA] Add missing sysfs device assignment for ALSA PCI drivers Added the missing sysfs device assignment for ALSA PCI drivers. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c839459698219dd2dd96d81a318ccac5590b70c5 Author: Rene Herman Date: Mon Feb 19 13:07:50 2007 +0100 [ALSA] gusextreme: set codec_flag The gusextreme driver neglects to set the gus->codec_flag meaning snd_gf1_pcm_new() allocates a second 'PCM Playback Volume' control, which makes the driver fail to load. Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 86fd8198497cccaf29afcf407dc9e6a82619e7e5 Author: Rene Herman Date: Mon Feb 19 13:07:17 2007 +0100 [ALSA] isa_bus: gusextreeme gusextreme: port to isa_bus infrastructure Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 2dfff9672161980603ec273b762a366928008f5c Author: Rene Herman Date: Mon Feb 19 13:05:02 2007 +0100 [ALSA] isa_bus: gusclassic gusclassic: port to isa_bus infrastructure Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit dc74ddd6310a49ae8482ea92afe472e48983d7da Author: Rene Herman Date: Mon Feb 19 13:01:45 2007 +0100 [ALSA] es1688 - code clean-up Seperate out the legacy probing into its own function, improving readability. Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 458d1100be56eb3e93f5add7f60212c8f5fb9f11 Author: Takashi Iwai Date: Fri Feb 16 13:27:18 2007 +0100 [ALSA] hda-codec - Define pin configs for MacBooks Define pin configs for MacBook and MacBook Pro with STAC92xx codecs. The latter is detected automatically by checking codec SSID now. Also, fixed the documentation regarding available modeliof sigmatel codec chips. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit cb585ada961bbf3950e2e6f421cc6169c9dc2844 Author: Takashi Iwai Date: Thu Feb 15 19:29:26 2007 +0100 [ALSA] hda-codec - Add missing Mic Boost controls for ALC262 Added missing Mic Boost controls for ALC262 codec chip. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit c0405929f2d13ed0c2b400b2d70ab3016c361d1a Author: Takashi Iwai Date: Thu Feb 15 18:23:41 2007 +0100 [ALSA] hda-codec - Fix models for some lpatops/mobos Added the missing models for some laptops / mobos: ASUS z35m, ASRock board Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 1941d3cf2643027fcef87a9915d8af9d82747b06 Author: Liam Girdwood Date: Wed Feb 14 15:23:57 2007 +0100 [ALSA] soc - WM9712 PCM volume This patch suggested by Joe Sauer adds PCM playback volume kcontrol for the WM9712. Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 49325ac99a6272a4df89c7d7f7016c6752798a05 Author: Joe Sauer Date: Wed Feb 14 15:23:11 2007 +0100 [ALSA] soc - Fix WM9712 register cache entry This patch by Joe Sauer fixes the WM9712 codec register cache value for register 0x08. Value should be 0x0f0f and not 0xf0f0. Signed-off-by: Joe Sauer Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 9137d4308a41c387fac63d95c71e983e6e5b2f2e Author: Rene Herman Date: Wed Feb 14 13:26:17 2007 +0100 [ALSA] isa_bus: es1688 es1688: port to isa_bus infrastructure. very slight reorganization of the auto-probe code to be a bit easier on the eye (if not the senses). Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 24400d9132771de1dce03bc1030f9d8549561ef0 Author: Rene Herman Date: Wed Feb 14 13:23:38 2007 +0100 [ALSA] isa_bus: cs4231 cs4231: port to isa_bus infrastructure. Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 327b24d91ccc2c98752f5c50b9145b999da2c549 Author: Tobin Davis Date: Thu Feb 15 17:46:18 2007 +0100 [ALSA] hda-codec - Add method for configuring Mac Pro without PCI SSID This patch adds a switch to configure systems that do not provide PCI SSID's for HD Audio like Mac Pro with ALC885. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 33254405d17468a09c2359baa6c12c87a4f24c30 Author: Rene Herman Date: Wed Feb 14 13:23:16 2007 +0100 [ALSA] isa_bus: adlib adlib: port to isa_bus infrastructure. Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 610acfd87ea25643d01ef56d847cd633ec9b4450 Author: Rene Herman Date: Wed Feb 14 13:22:41 2007 +0100 [ALSA] isa_bus: ad1848 ad1848: port to isa_bus infrastructure Signed-off-by: Rene Herman Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 601826babf006e11af73952e52033b060aea4291 Author: Graeme Gregory Date: Wed Feb 14 13:20:46 2007 +0100 [ALSA] ASoC Samsung S3C24xx build This patch builds the Samsung S3C24xx audio DMA and I2S drivers. Signed-off-by: Graeme Gregory Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit f3ea4b85a36b4d2ce8685f19fca73cf59b3dd62e Author: Ben Dooks Date: Wed Feb 14 13:20:03 2007 +0100 [ALSA] ASoC Samsung S3C24xx audio DMA This patch by Ben Dooks from Simtec Electronics adds ASoC audio DMA support for the Samsung S3C24xx CPU. Signed-off-by: Ben Dooks Signed-off-by: Graeme Gregory Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 7d86904b6e32a1037984320d04929c7f0f00926c Author: Ben Dooks Date: Wed Feb 14 13:17:49 2007 +0100 [ALSA] ASoC Samsung S3C24xx I2S support This patch by Ben Dooks from Simtec Electronics adds ASoC I2S support for the Samsung S3C24xx CPU. Signed-off-by: Ben Dooks Signed-off-by: Graeme Gregory Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela commit 76312657021f9427962f3a5c3e8e2eb80e18ebda Author: Takashi Iwai Date: Wed Feb 14 00:59:17 2007 +0100 [ALSA] hda-codec - Add LFE support on Dell M90 Added LFE support on Dell M90 laptop. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela Documentation/sound/alsa/ALSA-Configuration.txt | 13 + include/sound/mpu401.h | 1 include/sound/pcm.h | 7 sound/core/pcm_native.c | 27 - sound/core/rtctimer.c | 3 sound/drivers/mpu401/mpu401.c | 12 - sound/drivers/mpu401/mpu401_uart.c | 18 + sound/isa/Kconfig | 22 + sound/isa/ad1848/ad1848.c | 167 +++----- sound/isa/adlib.c | 122 ++---- sound/isa/cmi8330.c | 111 ++---- sound/isa/cs423x/cs4231.c | 213 +++++------ sound/isa/cs423x/cs4231_lib.c | 4 sound/isa/cs423x/cs4236.c | 125 +++--- sound/isa/es1688/es1688.c | 251 ++++++------ sound/isa/es18xx.c | 106 ++--- sound/isa/gus/gusclassic.c | 292 ++++++--------- sound/isa/gus/gusextreme.c | 379 +++++++++---------- sound/isa/gus/gusmax.c | 67 +-- sound/isa/gus/interwave.c | 101 ++--- sound/isa/opl3sa2.c | 123 ++---- sound/isa/opti9xx/miro.c | 74 ++-- sound/isa/opti9xx/opti92x-ad1848.c | 98 ++--- sound/isa/sb/sb16.c | 107 ++--- sound/isa/sb/sb16_csp.c | 6 sound/isa/sb/sb8.c | 86 ++-- sound/isa/sgalaxy.c | 103 ++--- sound/isa/sscape.c | 116 ++---- sound/isa/wavefront/wavefront.c | 107 ++--- sound/isa/wavefront/wavefront_fx.c | 8 sound/pci/Kconfig | 32 +- sound/pci/ac97/Makefile | 2 sound/pci/ac97/ac97_codec.c | 43 +- sound/pci/ac97/ac97_local.h | 55 --- sound/pci/ac97/ac97_patch.c | 96 ++--- sound/pci/ac97/ac97_patch.h | 110 +++-- sound/pci/ac97/ac97_pcm.c | 1 sound/pci/ali5451/ali5451.c | 6 sound/pci/bt87x.c | 2 sound/pci/ca0106/ca0106_main.c | 4 sound/pci/echoaudio/echoaudio.c | 6 sound/pci/emu10k1/p16v.c | 4 sound/pci/ens1370.c | 8 sound/pci/hda/hda_codec.c | 3 sound/pci/hda/patch_analog.c | 3 sound/pci/hda/patch_conexant.c | 8 sound/pci/hda/patch_realtek.c | 23 + sound/pci/hda/patch_sigmatel.c | 35 ++ sound/pci/ice1712/ice1712.c | 4 sound/pci/ice1712/ice1724.c | 4 sound/pci/korg1212/korg1212.c | 10 sound/pci/maestro3.c | 14 - sound/pci/pcxhr/pcxhr.c | 7 sound/pci/riptide/riptide.c | 2 sound/pci/rme32.c | 7 sound/pci/rme9652/hdsp.c | 8 sound/pci/rme9652/hdspm.c | 10 sound/pci/rme9652/rme9652.c | 8 sound/pci/trident/trident_main.c | 4 sound/pci/ymfpci/ymfpci_main.c | 12 - sound/soc/Kconfig | 1 sound/soc/Makefile | 2 sound/soc/codecs/wm9712.c | 3 sound/soc/s3c24xx/Kconfig | 16 + sound/soc/s3c24xx/Makefile | 6 sound/soc/s3c24xx/s3c24xx-i2s.c | 439 ++++++++++++++++++++++ sound/soc/s3c24xx/s3c24xx-i2s.h | 35 ++ sound/soc/s3c24xx/s3c24xx-pcm.c | 462 +++++++++++++++++++++++ sound/soc/s3c24xx/s3c24xx-pcm.h | 32 ++ sound/sparc/cs4231.c | 3 70 files changed, 2457 insertions(+), 1942 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index c30ff1b..86ce5fd 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -895,10 +895,16 @@ Prior to version 0.9.0rc4 options had a can be adjusted. Appearing only when compiled with $CONFIG_SND_DEBUG=y - STAC9200/9205/9220/9221/9254 + STAC9200/9205/9254 + ref Reference board + + STAC9220/9221 ref Reference board 3stack D945 3stack 5stack D945 5stack + SPDIF + macmini Intel Mac Mini + macbook Intel Mac Book + macbook-pro Intel Mac Book Pro STAC9202/9250/9251 ref Reference board, base config @@ -914,6 +920,10 @@ Prior to version 0.9.0rc4 options had a vaio Setup for VAIO FE550G/SZ110 vaio-ar Setup for VAIO AR + The model name "genric" is treated as a special case. When this + model is given, the driver uses the generic codec parser without + "codec-patch". It's sometimes good for testing and debugging. + If the default configuration doesn't work and one of the above matches with your device, report it together with the PCI subsystem ID (output of "lspci -nv") to ALSA BTS or alsa-devel @@ -1268,6 +1278,7 @@ Prior to version 0.9.0rc4 options had a port - port number or -1 (disable) irq - IRQ number or -1 (disable) pnp - PnP detection - 0 = disable, 1 = enable (default) + uart_enter - Issue UART_ENTER command at open - bool, default = on This module supports multiple devices and PnP. diff --git a/include/sound/mpu401.h b/include/sound/mpu401.h index 8c88267..d5c1396 100644 --- a/include/sound/mpu401.h +++ b/include/sound/mpu401.h @@ -50,6 +50,7 @@ #define MPU401_INFO_OUTPUT (1 << 1) /* o #define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ #define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ #define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ +#define MPU401_INFO_UART_ONLY (1 << 5) /* No ENTER_UART cmd needed */ #define MPU401_MODE_BIT_INPUT 0 #define MPU401_MODE_BIT_OUTPUT 1 diff --git a/include/sound/pcm.h b/include/sound/pcm.h index deff5a9..73334e0 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -603,11 +603,8 @@ do { \ read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \ } while (0) -#define snd_pcm_group_for_each(pos, substream) \ - list_for_each(pos, &substream->group->substreams) - -#define snd_pcm_group_substream_entry(pos) \ - list_entry(pos, struct snd_pcm_substream, link_list) +#define snd_pcm_group_for_each_entry(s, substream) \ + list_for_each_entry(s, &substream->group->substreams, link_list) static inline int snd_pcm_running(struct snd_pcm_substream *substream) { diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 3e276fc..952f395 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -713,26 +713,22 @@ static int snd_pcm_action_group(struct a struct snd_pcm_substream *substream, int state, int do_lock) { - struct list_head *pos; struct snd_pcm_substream *s = NULL; struct snd_pcm_substream *s1; int res = 0; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (do_lock && s != substream) spin_lock(&s->self_group.lock); res = ops->pre_action(s, state); if (res < 0) goto _unlock; } - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { res = ops->do_action(s, state); if (res < 0) { if (ops->undo_action) { - snd_pcm_group_for_each(pos, substream) { - s1 = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s1, substream) { if (s1 == s) /* failed stream */ break; ops->undo_action(s1, state); @@ -742,15 +738,13 @@ static int snd_pcm_action_group(struct a goto _unlock; } } - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { ops->post_action(s, state); } _unlock: if (do_lock) { /* unlock streams */ - snd_pcm_group_for_each(pos, substream) { - s1 = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s1, substream) { if (s1 != substream) spin_unlock(&s1->self_group.lock); if (s1 == s) /* end */ @@ -1439,7 +1433,7 @@ static int snd_pcm_drain(struct snd_pcm_ { struct snd_card *card; struct snd_pcm_runtime *runtime; - struct list_head *pos; + struct snd_pcm_substream *s; int result = 0; int i, num_drecs; struct drain_rec *drec, drec_tmp, *d; @@ -1474,8 +1468,7 @@ static int snd_pcm_drain(struct snd_pcm_ /* count only playback streams */ num_drecs = 0; - snd_pcm_group_for_each(pos, substream) { - struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { runtime = s->runtime; if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { d = &drec[num_drecs++]; @@ -1675,7 +1668,7 @@ static void relink_to_local(struct snd_p static int snd_pcm_unlink(struct snd_pcm_substream *substream) { - struct list_head *pos; + struct snd_pcm_substream *s; int res = 0; down_write(&snd_pcm_link_rwsem); @@ -1687,8 +1680,8 @@ static int snd_pcm_unlink(struct snd_pcm list_del(&substream->link_list); substream->group->count--; if (substream->group->count == 1) { /* detach the last stream, too */ - snd_pcm_group_for_each(pos, substream) { - relink_to_local(snd_pcm_group_substream_entry(pos)); + snd_pcm_group_for_each_entry(s, substream) { + relink_to_local(s); break; } kfree(substream->group); diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c index 9f7b32e..7cd5e8f 100644 --- a/sound/core/rtctimer.c +++ b/sound/core/rtctimer.c @@ -24,6 +24,7 @@ #include #include #include #include +#include #include #include @@ -129,7 +130,7 @@ static int __init rtctimer_init(void) struct snd_timer *timer; if (rtctimer_freq < 2 || rtctimer_freq > 8192 || - (rtctimer_freq & (rtctimer_freq - 1)) != 0) { + !is_power_of_2(rtctimer_freq)) { snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); return -EINVAL; diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index 2de181a..1d563e5 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -42,6 +42,7 @@ static int pnp[SNDRV_CARDS] = {[0 ... (S #endif static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ +static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for MPU-401 device."); @@ -57,6 +58,8 @@ module_param_array(port, long, NULL, 044 MODULE_PARM_DESC(port, "Port # for MPU-401 device."); module_param_array(irq, int, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); +module_param_array(uart_enter, bool, NULL, 0444); +MODULE_PARM_DESC(uart_enter, "Issue UART_ENTER command at open."); static struct platform_device *platform_devices[SNDRV_CARDS]; static int pnp_registered; @@ -80,10 +83,11 @@ static int snd_mpu401_create(int dev, st strcat(card->longname, "polled"); } - if ((err = snd_mpu401_uart_new(card, 0, - MPU401_HW_MPU401, - port[dev], 0, - irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) { + err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], + uart_enter[dev] ? 0 : MPU401_INFO_UART_ONLY, + irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, + NULL); + if (err < 0) { printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); goto _err; } diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 3daa9fa..85aedc3 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -266,6 +266,16 @@ #endif return 0; } +static int snd_mpu401_do_reset(struct snd_mpu401 *mpu) +{ + if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) + return -EIO; + if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) && + snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) + return -EIO; + return 0; +} + /* * input/output open/close - protected by open_mutex in rawmidi.c */ @@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(st if (mpu->open_input && (err = mpu->open_input(mpu)) < 0) return err; if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) { - if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) - goto error_out; - if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) + if (snd_mpu401_do_reset(mpu) < 0) goto error_out; } mpu->substream_input = substream; @@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(s if (mpu->open_output && (err = mpu->open_output(mpu)) < 0) return err; if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { - if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) - goto error_out; - if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) + if (snd_mpu401_do_reset(mpu) < 0) goto error_out; } mpu->substream_output = substream; diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 4e3a972..c855e35 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -358,12 +358,21 @@ config SND_SBAWE config SND_SB16_CSP bool "Sound Blaster 16/AWE CSP support" depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC) - select FW_LOADER help Say Y here to include support for the CSP core. This special coprocessor can do variable tasks like various compression and decompression algorithms. +config SND_SB16_CSP_FIRMWARE_IN_KERNEL + bool "In-kernel firmware for SB16 CSP" + depends on SND_SB16_CSP + select FW_LOADER + default y + help + Say Y here to include the static firmware built in the kernel + for SB16 CSP controller. If you choose N here, the external + firmware files from alsa-plugins pacakge are necessary. + config SND_SGALAXY tristate "Aztech Sound Galaxy" depends on SND @@ -391,7 +400,6 @@ config SND_SSCAPE config SND_WAVEFRONT tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" depends on SND - select FW_LOADER select SND_OPL3_LIB select SND_MPU401_UART select SND_CS4231_LIB @@ -402,4 +410,14 @@ config SND_WAVEFRONT To compile this driver as a module, choose M here: the module will be called snd-wavefront. +config SND_WAVEFRONT_FIRMWARE_IN_KERNEL + bool "In-kernel firmware for Wavefront" + depends on SND_WAVEFRONT + select FW_LOADER + default y + help + Say Y here to include the static firmware built in the kernel + for Wavefront driver. If you choose N here, the external + firmware files from alsa-plugins pacakge are necessary. + endmenu diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 74e501d..d09a7fa 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,8 +32,11 @@ #include #include #include +#define CRD_NAME "Generic AD1848/AD1847/CS4248" +#define DEV_NAME "ad1848" + +MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Tugrul Galatali , Jaroslav Kysela "); -MODULE_DESCRIPTION("AD1848/AD1847/CS4248"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848}," "{Analog Devices,AD1847}," @@ -48,95 +51,98 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEF static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */ module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for AD1848 soundcard."); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for AD1848 soundcard."); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable AD1848 soundcard."); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); module_param_array(port, long, NULL, 0444); -MODULE_PARM_DESC(port, "Port # for AD1848 driver."); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); module_param_array(irq, int, NULL, 0444); -MODULE_PARM_DESC(irq, "IRQ # for AD1848 driver."); +MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); module_param_array(dma1, int, NULL, 0444); -MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); +MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver."); module_param_array(thinkpad, bool, NULL, 0444); MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); -static struct platform_device *devices[SNDRV_CARDS]; +static int __devinit snd_ad1848_match(struct device *dev, unsigned int n) +{ + if (!enable[n]) + return 0; + if (port[n] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); + return 0; + } + if (irq[n] == SNDRV_AUTO_IRQ) { + snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id); + return 0; + } + if (dma1[n] == SNDRV_AUTO_DMA) { + snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id); + return 0; + } + return 1; +} -static int __devinit snd_ad1848_probe(struct platform_device *pdev) +static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n) { - int dev = pdev->id; struct snd_card *card; struct snd_ad1848 *chip; struct snd_pcm *pcm; - int err; + int error; - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "ad1848: specify port\n"); + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); + if (!card) return -EINVAL; - } - if (irq[dev] == SNDRV_AUTO_IRQ) { - snd_printk(KERN_ERR "ad1848: specify irq\n"); - return -EINVAL; - } - if (dma1[dev] == SNDRV_AUTO_DMA) { - snd_printk(KERN_ERR "ad1848: specify dma1\n"); - return -EINVAL; - } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + error = snd_ad1848_create(card, port[n], irq[n], dma1[n], + thinkpad[n] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip); + if (error < 0) + goto out; - if ((err = snd_ad1848_create(card, port[dev], - irq[dev], - dma1[dev], - thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, - &chip)) < 0) - goto _err; card->private_data = chip; - if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) - goto _err; + error = snd_ad1848_pcm(chip, 0, &pcm); + if (error < 0) + goto out; - if ((err = snd_ad1848_mixer(chip)) < 0) - goto _err; + error = snd_ad1848_mixer(chip); + if (error < 0) + goto out; strcpy(card->driver, "AD1848"); strcpy(card->shortname, pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - pcm->name, chip->port, irq[dev], dma1[dev]); - - if (thinkpad[dev]) + pcm->name, chip->port, irq[n], dma1[n]); + if (thinkpad[n]) strcat(card->longname, " [Thinkpad]"); - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, dev); - if ((err = snd_card_register(card)) < 0) - goto _err; + error = snd_card_register(card); + if (error < 0) + goto out; - platform_set_drvdata(pdev, card); + dev_set_drvdata(dev, card); return 0; - _err: - snd_card_free(card); - return err; +out: snd_card_free(card); + return error; } -static int __devexit snd_ad1848_remove(struct platform_device *devptr) +static int __devexit snd_ad1848_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } #ifdef CONFIG_PM -static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state) +static int snd_ad1848_suspend(struct device *dev, unsigned int n, pm_message_t state) { - struct snd_card *card = platform_get_drvdata(pdev); + struct snd_card *card = dev_get_drvdata(dev); struct snd_ad1848 *chip = card->private_data; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); @@ -144,9 +150,9 @@ static int snd_ad1848_suspend(struct pla return 0; } -static int snd_ad1848_resume(struct platform_device *pdev) +static int snd_ad1848_resume(struct device *dev, unsigned int n) { - struct snd_card *card = platform_get_drvdata(pdev); + struct snd_card *card = dev_get_drvdata(dev); struct snd_ad1848 *chip = card->private_data; chip->resume(chip); @@ -155,9 +161,8 @@ static int snd_ad1848_resume(struct plat } #endif -#define SND_AD1848_DRIVER "snd_ad1848" - -static struct platform_driver snd_ad1848_driver = { +static struct isa_driver snd_ad1848_driver = { + .match = snd_ad1848_match, .probe = snd_ad1848_probe, .remove = __devexit_p(snd_ad1848_remove), #ifdef CONFIG_PM @@ -165,57 +170,19 @@ #ifdef CONFIG_PM .resume = snd_ad1848_resume, #endif .driver = { - .name = SND_AD1848_DRIVER - }, + .name = DEV_NAME + } }; -static void __init_or_module snd_ad1848_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_ad1848_driver); -} - static int __init alsa_card_ad1848_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_ad1848_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(SND_AD1848_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "AD1848 soundcard not found or device busy\n"); -#endif - snd_ad1848_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS); } static void __exit alsa_card_ad1848_exit(void) { - snd_ad1848_unregister_all(); + isa_unregister_driver(&snd_ad1848_driver); } -module_init(alsa_card_ad1848_init) -module_exit(alsa_card_ad1848_exit) +module_init(alsa_card_ad1848_init); +module_exit(alsa_card_ad1848_exit); diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c index 1124344..d687207 100644 --- a/sound/isa/adlib.c +++ b/sound/isa/adlib.c @@ -5,13 +5,13 @@ #include #include #include -#include +#include #include #include #include #define CRD_NAME "AdLib FM" -#define DRV_NAME "snd_adlib" +#define DEV_NAME "adlib" MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Rene Herman"); @@ -31,133 +31,99 @@ MODULE_PARM_DESC(enable, "Enable " CRD_N module_param_array(port, long, NULL, 0444); MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); -static struct platform_device *devices[SNDRV_CARDS]; +static int __devinit snd_adlib_match(struct device *dev, unsigned int n) +{ + if (!enable[n]) + return 0; + + if (port[n] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); + return 0; + } + return 1; +} static void snd_adlib_free(struct snd_card *card) { release_and_free_resource(card->private_data); } -static int __devinit snd_adlib_probe(struct platform_device *device) +static int __devinit snd_adlib_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_opl3 *opl3; + int error; - int error, i = device->id; - - if (port[i] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR DRV_NAME ": please specify port\n"); - error = -EINVAL; - goto out0; - } - - card = snd_card_new(index[i], id[i], THIS_MODULE, 0); + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); if (!card) { - snd_printk(KERN_ERR DRV_NAME ": could not create card\n"); - error = -EINVAL; - goto out0; + snd_printk(KERN_ERR "%s: could not create card\n", dev->bus_id); + return -EINVAL; } - card->private_data = request_region(port[i], 4, CRD_NAME); + card->private_data = request_region(port[n], 4, CRD_NAME); if (!card->private_data) { - snd_printk(KERN_ERR DRV_NAME ": could not grab ports\n"); + snd_printk(KERN_ERR "%s: could not grab ports\n", dev->bus_id); error = -EBUSY; - goto out1; + goto out; } card->private_free = snd_adlib_free; - error = snd_opl3_create(card, port[i], port[i] + 2, OPL3_HW_AUTO, 1, &opl3); + strcpy(card->driver, DEV_NAME); + strcpy(card->shortname, CRD_NAME); + sprintf(card->longname, CRD_NAME " at %#lx", port[n]); + + error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); if (error < 0) { - snd_printk(KERN_ERR DRV_NAME ": could not create OPL\n"); - goto out1; + snd_printk(KERN_ERR "%s: could not create OPL\n", dev->bus_id); + goto out; } error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); if (error < 0) { - snd_printk(KERN_ERR DRV_NAME ": could not create FM\n"); - goto out1; + snd_printk(KERN_ERR "%s: could not create FM\n", dev->bus_id); + goto out; } - strcpy(card->driver, DRV_NAME); - strcpy(card->shortname, CRD_NAME); - sprintf(card->longname, CRD_NAME " at %#lx", port[i]); - - snd_card_set_dev(card, &device->dev); + snd_card_set_dev(card, dev); error = snd_card_register(card); if (error < 0) { - snd_printk(KERN_ERR DRV_NAME ": could not register card\n"); - goto out1; + snd_printk(KERN_ERR "%s: could not register card\n", dev->bus_id); + goto out; } - platform_set_drvdata(device, card); + dev_set_drvdata(dev, card); return 0; -out1: snd_card_free(card); -out0: return error; +out: snd_card_free(card); + return error; } -static int __devexit snd_adlib_remove(struct platform_device *device) +static int __devexit snd_adlib_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(device)); - platform_set_drvdata(device, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } -static struct platform_driver snd_adlib_driver = { +static struct isa_driver snd_adlib_driver = { + .match = snd_adlib_match, .probe = snd_adlib_probe, .remove = __devexit_p(snd_adlib_remove), .driver = { - .name = DRV_NAME + .name = DEV_NAME } }; static int __init alsa_card_adlib_init(void) { - int i, cards; - - if (platform_driver_register(&snd_adlib_driver) < 0) { - snd_printk(KERN_ERR DRV_NAME ": could not register driver\n"); - return -ENODEV; - } - - for (cards = 0, i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - - if (!enable[i]) - continue; - - device = platform_device_register_simple(DRV_NAME, i, NULL, 0); - if (IS_ERR(device)) - continue; - - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - - devices[i] = device; - cards++; - } - - if (!cards) { -#ifdef MODULE - printk(KERN_ERR CRD_NAME " soundcard not found or device busy\n"); -#endif - platform_driver_unregister(&snd_adlib_driver); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS); } static void __exit alsa_card_adlib_exit(void) { - int i; - - for (i = 0; i < SNDRV_CARDS; i++) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_adlib_driver); + isa_unregister_driver(&snd_adlib_driver); } module_init(alsa_card_adlib_init); diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index c09a800..456156d 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -108,7 +108,6 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8 module_param_array(wssdma, int, NULL, 0444); MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); -static struct platform_device *platform_devices[SNDRV_CARDS]; #ifdef CONFIG_PNP static int pnp_registered; #endif @@ -547,60 +546,70 @@ static int __devinit snd_cmi8330_probe(s return snd_card_register(card); } -static int __devinit snd_cmi8330_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_cmi8330_isa_match(struct device *pdev, + unsigned int dev) { - struct snd_card *card; - int err; - int dev = pdev->id; - + if (!enable[dev] || is_isapnp_selected(dev)) + return 0; if (wssport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify wssport\n"); - return -EINVAL; + return 0; } if (sbport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify sbport\n"); - return -EINVAL; + return 0; } + return 1; +} + +static int __devinit snd_cmi8330_isa_probe(struct device *pdev, + unsigned int dev) +{ + struct snd_card *card; + int err; card = snd_cmi8330_card_new(dev); if (! card) return -ENOMEM; - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_cmi8330_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devexit snd_cmi8330_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_cmi8330_isa_remove(struct device *devptr, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #ifdef CONFIG_PM -static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +static int snd_cmi8330_isa_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - return snd_cmi8330_suspend(platform_get_drvdata(dev)); + return snd_cmi8330_suspend(dev_get_drvdata(dev)); } -static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) +static int snd_cmi8330_isa_resume(struct device *dev, unsigned int n) { - return snd_cmi8330_resume(platform_get_drvdata(dev)); + return snd_cmi8330_resume(dev_get_drvdata(dev)); } #endif #define CMI8330_DRIVER "snd_cmi8330" -static struct platform_driver snd_cmi8330_driver = { - .probe = snd_cmi8330_nonpnp_probe, - .remove = __devexit_p(snd_cmi8330_nonpnp_remove), +static struct isa_driver snd_cmi8330_driver = { + .match = snd_cmi8330_isa_match, + .probe = snd_cmi8330_isa_probe, + .remove = __devexit_p(snd_cmi8330_isa_remove), #ifdef CONFIG_PM - .suspend = snd_cmi8330_nonpnp_suspend, - .resume = snd_cmi8330_nonpnp_resume, + .suspend = snd_cmi8330_isa_suspend, + .resume = snd_cmi8330_isa_resume, #endif .driver = { .name = CMI8330_DRIVER @@ -609,8 +618,6 @@ #endif #ifdef CONFIG_PNP -static unsigned int __devinitdata cmi8330_pnp_devices; - static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -640,7 +647,6 @@ static int __devinit snd_cmi8330_pnp_det } pnp_set_card_drvdata(pcard, card); dev++; - cmi8330_pnp_devices++; return 0; } @@ -675,63 +681,28 @@ #endif }; #endif /* CONFIG_PNP */ -static void __init_or_module snd_cmi8330_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnp_registered) - pnp_unregister_card_driver(&cmi8330_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_cmi8330_driver); -} - static int __init alsa_card_cmi8330_init(void) { - int i, err, cards = 0; + int err; - if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0) + err = isa_register_driver(&snd_cmi8330_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i] || is_isapnp_selected(i)) - continue; - device = platform_device_register_simple(CMI8330_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - cards++; - } - #ifdef CONFIG_PNP err = pnp_register_card_driver(&cmi8330_pnpc_driver); - if (!err) { + if (!err) pnp_registered = 1; - cards += cmi8330_pnp_devices; - } #endif - - if (!cards) { -#ifdef MODULE - snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); -#endif - snd_cmi8330_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_cmi8330_exit(void) { - snd_cmi8330_unregister_all(); +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&cmi8330_pnpc_driver); +#endif + isa_unregister_driver(&snd_cmi8330_driver); } module_init(alsa_card_cmi8330_init) diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index 696a5c8..ac40411 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,8 +32,11 @@ #include #include #include +#define CRD_NAME "Generic CS4231" +#define DEV_NAME "cs4231" + +MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Generic CS4231"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}"); @@ -48,132 +51,136 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEF static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for CS4231 soundcard."); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for CS4231 soundcard."); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable CS4231 soundcard."); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); module_param_array(port, long, NULL, 0444); -MODULE_PARM_DESC(port, "Port # for CS4231 driver."); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); module_param_array(mpu_port, long, NULL, 0444); -MODULE_PARM_DESC(mpu_port, "MPU-401 port # for CS4231 driver."); +MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver."); module_param_array(irq, int, NULL, 0444); -MODULE_PARM_DESC(irq, "IRQ # for CS4231 driver."); +MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); module_param_array(mpu_irq, int, NULL, 0444); -MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for CS4231 driver."); +MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver."); module_param_array(dma1, int, NULL, 0444); -MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); +MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver."); module_param_array(dma2, int, NULL, 0444); -MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); +MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver."); -static struct platform_device *devices[SNDRV_CARDS]; +static int __devinit snd_cs4231_match(struct device *dev, unsigned int n) +{ + if (!enable[n]) + return 0; + if (port[n] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id); + return 0; + } + if (irq[n] == SNDRV_AUTO_IRQ) { + snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id); + return 0; + } + if (dma1[n] == SNDRV_AUTO_DMA) { + snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id); + return 0; + } + return 1; +} -static int __init snd_cs4231_probe(struct platform_device *pdev) +static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n) { - int dev = pdev->id; struct snd_card *card; - struct snd_pcm *pcm; struct snd_cs4231 *chip; - int err; + struct snd_pcm *pcm; + int error; - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify port\n"); - return -EINVAL; - } - if (irq[dev] == SNDRV_AUTO_IRQ) { - snd_printk(KERN_ERR "specify irq\n"); - return -EINVAL; - } - if (dma1[dev] == SNDRV_AUTO_DMA) { - snd_printk(KERN_ERR "specify dma1\n"); + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); + if (!card) return -EINVAL; - } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; - if ((err = snd_cs4231_create(card, port[dev], -1, - irq[dev], - dma1[dev], - dma2[dev], - CS4231_HW_DETECT, - 0, &chip)) < 0) - goto _err; + + error = snd_cs4231_create(card, port[n], -1, irq[n], dma1[n], dma2[n], + CS4231_HW_DETECT, 0, &chip); + if (error < 0) + goto out; + card->private_data = chip; - if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) - goto _err; + error = snd_cs4231_pcm(chip, 0, &pcm); + if (error < 0) + goto out; strcpy(card->driver, "CS4231"); strcpy(card->shortname, pcm->name); + sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - pcm->name, chip->port, irq[dev], dma1[dev]); - if (dma2[dev] >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); - - if ((err = snd_cs4231_mixer(chip)) < 0) - goto _err; - if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) - goto _err; - - if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { - if (mpu_irq[dev] == SNDRV_AUTO_IRQ) - mpu_irq[dev] = -1; + pcm->name, chip->port, irq[n], dma1[n]); + if (dma2[n] >= 0) + sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); + + error = snd_cs4231_mixer(chip); + if (error < 0) + goto out; + + error = snd_cs4231_timer(chip, 0, NULL); + if (error < 0) + goto out; + + if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) { + if (mpu_irq[n] == SNDRV_AUTO_IRQ) + mpu_irq[n] = -1; if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, - mpu_port[dev], 0, - mpu_irq[dev], - mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, + mpu_port[n], 0, mpu_irq[n], + mpu_irq[n] >= 0 ? IRQF_DISABLED : 0, NULL) < 0) - printk(KERN_WARNING "cs4231: MPU401 not detected\n"); + printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id); } - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, dev); - if ((err = snd_card_register(card)) < 0) - goto _err; + error = snd_card_register(card); + if (error < 0) + goto out; - platform_set_drvdata(pdev, card); + dev_set_drvdata(dev, card); return 0; - _err: - snd_card_free(card); - return err; +out: snd_card_free(card); + return error; } -static int __devexit snd_cs4231_remove(struct platform_device *devptr) +static int __devexit snd_cs4231_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } #ifdef CONFIG_PM -static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) +static int snd_cs4231_suspend(struct device *dev, unsigned int n, pm_message_t state) { - struct snd_card *card; - struct snd_cs4231 *chip; - card = platform_get_drvdata(dev); + struct snd_card *card = dev_get_drvdata(dev); + struct snd_cs4231 *chip = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); - chip = card->private_data; chip->suspend(chip); return 0; } -static int snd_cs4231_resume(struct platform_device *dev) +static int snd_cs4231_resume(struct device *dev, unsigned int n) { - struct snd_card *card; - struct snd_cs4231 *chip; - card = platform_get_drvdata(dev); - chip = card->private_data; + struct snd_card *card = dev_get_drvdata(dev); + struct snd_cs4231 *chip = card->private_data; + chip->resume(chip); snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif -#define SND_CS4231_DRIVER "snd_cs4231" - -static struct platform_driver snd_cs4231_driver = { +static struct isa_driver snd_cs4231_driver = { + .match = snd_cs4231_match, .probe = snd_cs4231_probe, .remove = __devexit_p(snd_cs4231_remove), #ifdef CONFIG_PM @@ -181,57 +188,19 @@ #ifdef CONFIG_PM .resume = snd_cs4231_resume, #endif .driver = { - .name = SND_CS4231_DRIVER - }, + .name = DEV_NAME + } }; -static void __init_or_module snd_cs4231_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_cs4231_driver); -} - static int __init alsa_card_cs4231_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_cs4231_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(SND_CS4231_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "CS4231 soundcard not found or device busy\n"); -#endif - snd_cs4231_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS); } static void __exit alsa_card_cs4231_exit(void) { - snd_cs4231_unregister_all(); + isa_unregister_driver(&snd_cs4231_driver); } -module_init(alsa_card_cs4231_init) -module_exit(alsa_card_cs4231_exit) +module_init(alsa_card_cs4231_init); +module_exit(alsa_card_cs4231_exit); diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 75c7c5f..914d77b 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -405,7 +405,6 @@ static int snd_cs4231_trigger(struct snd struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); int result = 0; unsigned int what; - struct list_head *pos; struct snd_pcm_substream *s; int do_start; @@ -425,8 +424,7 @@ #endif } what = 0; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == chip->playback_substream) { what |= CS4231_PLAYBACK_ENABLE; snd_pcm_trigger_done(s, substream); diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 07ffd5c..7d9d4d5 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -126,14 +126,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDE module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); -static struct platform_device *platform_devices[SNDRV_CARDS]; #ifdef CONFIG_PNP static int pnpc_registered; #ifdef CS4232 static int pnp_registered; #endif #endif /* CONFIG_PNP */ -static unsigned int snd_cs423x_devices; struct snd_card_cs4236 { struct snd_cs4231 *chip; @@ -542,38 +540,55 @@ #endif return snd_card_register(card); } -static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_cs423x_isa_match(struct device *pdev, + unsigned int dev) { - int dev = pdev->id; - struct snd_card *card; - int err; + if (!enable[dev] || is_isapnp_selected(dev)) + return 0; if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify port\n"); - return -EINVAL; + snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id); + return 0; } if (cport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify cport\n"); - return -EINVAL; + snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id); + return 0; + } + if (irq[dev] == SNDRV_AUTO_IRQ) { + snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); + return 0; } + if (dma1[dev] == SNDRV_AUTO_DMA) { + snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id); + return 0; + } + return 1; +} + +static int __devinit snd_cs423x_isa_probe(struct device *pdev, + unsigned int dev) +{ + struct snd_card *card; + int err; card = snd_cs423x_card_new(dev); if (! card) return -ENOMEM; - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_cs423x_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_cs423x_isa_remove(struct device *pdev, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(pdev)); + dev_set_drvdata(pdev, NULL); return 0; } @@ -594,23 +609,25 @@ static int snd_cs423x_resume(struct snd_ return 0; } -static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - return snd_cs423x_suspend(platform_get_drvdata(dev)); + return snd_cs423x_suspend(dev_get_drvdata(dev)); } -static int snd_cs423x_nonpnp_resume(struct platform_device *dev) +static int snd_cs423x_isa_resume(struct device *dev, unsigned int n) { - return snd_cs423x_resume(platform_get_drvdata(dev)); + return snd_cs423x_resume(dev_get_drvdata(dev)); } #endif -static struct platform_driver cs423x_nonpnp_driver = { - .probe = snd_cs423x_nonpnp_probe, - .remove = __devexit_p(snd_cs423x_nonpnp_remove), +static struct isa_driver cs423x_isa_driver = { + .match = snd_cs423x_isa_match, + .probe = snd_cs423x_isa_probe, + .remove = __devexit_p(snd_cs423x_isa_remove), #ifdef CONFIG_PM - .suspend = snd_cs423x_nonpnp_suspend, - .resume = snd_cs423x_nonpnp_resume, + .suspend = snd_cs423x_isa_suspend, + .resume = snd_cs423x_isa_resume, #endif .driver = { .name = CS423X_DRIVER @@ -651,7 +668,6 @@ static int __devinit snd_cs4232_pnpbios_ } pnp_set_drvdata(pdev, card); dev++; - snd_cs423x_devices++; return 0; } @@ -715,7 +731,6 @@ static int __devinit snd_cs423x_pnpc_det } pnp_set_card_drvdata(pcard, card); dev++; - snd_cs423x_devices++; return 0; } @@ -750,45 +765,13 @@ #endif }; #endif /* CONFIG_PNP */ -static void __init_or_module snd_cs423x_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnpc_registered) - pnp_unregister_card_driver(&cs423x_pnpc_driver); -#ifdef CS4232 - if (pnp_registered) - pnp_unregister_driver(&cs4232_pnp_driver); -#endif -#endif /* CONFIG_PNP */ - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&cs423x_nonpnp_driver); -} - static int __init alsa_card_cs423x_init(void) { - int i, err; + int err; - if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) + err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i] || is_isapnp_selected(i)) - continue; - device = platform_device_register_simple(CS423X_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - snd_cs423x_devices++; - } #ifdef CONFIG_PNP #ifdef CS4232 err = pnp_register_driver(&cs4232_pnp_driver); @@ -799,20 +782,20 @@ #endif if (!err) pnpc_registered = 1; #endif /* CONFIG_PNP */ - - if (!snd_cs423x_devices) { -#ifdef MODULE - printk(KERN_ERR IDENT " soundcard not found or device busy\n"); -#endif - snd_cs423x_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_cs423x_exit(void) { - snd_cs423x_unregister_all(); +#ifdef CONFIG_PNP + if (pnpc_registered) + pnp_unregister_card_driver(&cs423x_pnpc_driver); +#ifdef CS4232 + if (pnp_registered) + pnp_unregister_driver(&cs4232_pnp_driver); +#endif +#endif /* CONFIG_PNP */ + isa_unregister_driver(&cs423x_isa_driver); } module_init(alsa_card_cs423x_init) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 65f97ff..edc3987 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,8 +35,11 @@ #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include +#define CRD_NAME "Generic ESS ES1688/ES688 AudioDrive" +#define DEV_NAME "es1688" + +MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("ESS ESx688 AudioDrive"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100}," "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102}," @@ -53,189 +56,157 @@ static int mpu_irq[SNDRV_CARDS] = SNDRV_ static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */ module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for ESx688 soundcard."); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for ESx688 soundcard."); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable ESx688 soundcard."); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); module_param_array(port, long, NULL, 0444); -MODULE_PARM_DESC(port, "Port # for ESx688 driver."); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); module_param_array(mpu_port, long, NULL, 0444); -MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ESx688 driver."); +MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver."); module_param_array(irq, int, NULL, 0444); -MODULE_PARM_DESC(irq, "IRQ # for ESx688 driver."); +MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); module_param_array(mpu_irq, int, NULL, 0444); -MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); +MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver."); module_param_array(dma8, int, NULL, 0444); -MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); - -static struct platform_device *devices[SNDRV_CARDS]; +MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver."); -#define PFX "es1688: " +static int __devinit snd_es1688_match(struct device *dev, unsigned int n) +{ + return enable[n]; +} -static int __devinit snd_es1688_probe(struct platform_device *pdev) +static int __devinit snd_es1688_legacy_create(struct snd_card *card, + struct device *dev, unsigned int n, struct snd_es1688 **rchip) { - int dev = pdev->id; + static long possible_ports[] = {0x220, 0x240, 0x260}; static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_dmas[] = {1, 3, 0, -1}; - int xirq, xdma, xmpu_irq; - struct snd_card *card; - struct snd_es1688 *chip; - struct snd_opl3 *opl3; - struct snd_pcm *pcm; - int err; - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; - - xirq = irq[dev]; - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; + + int i, error; + + if (irq[n] == SNDRV_AUTO_IRQ) { + irq[n] = snd_legacy_find_free_irq(possible_irqs); + if (irq[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", + dev->bus_id); + return -EBUSY; } } - xmpu_irq = mpu_irq[dev]; - xdma = dma8[dev]; - if (xdma == SNDRV_AUTO_DMA) { - if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); - err = -EBUSY; - goto _err; + if (dma8[n] == SNDRV_AUTO_DMA) { + dma8[n] = snd_legacy_find_free_dma(possible_dmas); + if (dma8[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free DMA\n", + dev->bus_id); + return -EBUSY; } } - if (port[dev] != SNDRV_AUTO_PORT) { - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xirq, xmpu_irq, xdma, - ES1688_HW_AUTO, &chip)) < 0) - goto _err; - } else { - /* auto-probe legacy ports */ - static unsigned long possible_ports[] = { - 0x220, 0x240, 0x260, - }; - int i; - for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { - err = snd_es1688_create(card, possible_ports[i], - mpu_port[dev], - xirq, xmpu_irq, xdma, - ES1688_HW_AUTO, &chip); - if (err >= 0) { - port[dev] = possible_ports[i]; - break; - } - } - if (i >= ARRAY_SIZE(possible_ports)) - goto _err; - } + if (port[n] != SNDRV_AUTO_PORT) + return snd_es1688_create(card, port[n], mpu_port[n], irq[n], + mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip); + + i = 0; + do { + port[n] = possible_ports[i]; + error = snd_es1688_create(card, port[n], mpu_port[n], irq[n], + mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip); + } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); + + return error; +} + +static int __devinit snd_es1688_probe(struct device *dev, unsigned int n) +{ + struct snd_card *card; + struct snd_es1688 *chip; + struct snd_opl3 *opl3; + struct snd_pcm *pcm; + int error; + + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); + if (!card) + return -EINVAL; + + error = snd_es1688_legacy_create(card, dev, n, &chip); + if (error < 0) + goto out; - if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) - goto _err; + error = snd_es1688_pcm(chip, 0, &pcm); + if (error < 0) + goto out; - if ((err = snd_es1688_mixer(chip)) < 0) - goto _err; + error = snd_es1688_mixer(chip); + if (error < 0) + goto out; strcpy(card->driver, "ES1688"); strcpy(card->shortname, pcm->name); - sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma); - - if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) { - printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->port); - } else { - if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) - goto _err; + sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, + chip->port, chip->irq, chip->dma8); + + if (snd_opl3_create(card, chip->port, chip->port + 2, + OPL3_HW_OPL3, 0, &opl3) < 0) + printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n", + dev->bus_id, chip->port); + else { + error = snd_opl3_hwdep_new(opl3, 0, 1, NULL); + if (error < 0) + goto out; } - if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) { - if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, - chip->mpu_port, 0, - xmpu_irq, - IRQF_DISABLED, - NULL)) < 0) - goto _err; + if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ && + chip->mpu_port > 0) { + error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, + chip->mpu_port, 0, + mpu_irq[n], IRQF_DISABLED, NULL); + if (error < 0) + goto out; } - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, dev); - if ((err = snd_card_register(card)) < 0) - goto _err; + error = snd_card_register(card); + if (error < 0) + goto out; - platform_set_drvdata(pdev, card); + dev_set_drvdata(dev, card); return 0; - _err: - snd_card_free(card); - return err; +out: snd_card_free(card); + return error; } -static int __devexit snd_es1688_remove(struct platform_device *devptr) +static int __devexit snd_es1688_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } -#define ES1688_DRIVER "snd_es1688" - -static struct platform_driver snd_es1688_driver = { +static struct isa_driver snd_es1688_driver = { + .match = snd_es1688_match, .probe = snd_es1688_probe, - .remove = __devexit_p(snd_es1688_remove), - /* FIXME: suspend/resume */ + .remove = snd_es1688_remove, +#if 0 /* FIXME */ + .suspend = snd_es1688_suspend, + .resume = snd_es1688_resume, +#endif .driver = { - .name = ES1688_DRIVER - }, + .name = DEV_NAME + } }; -static void __init_or_module snd_es1688_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_es1688_driver); -} - static int __init alsa_card_es1688_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_es1688_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(ES1688_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n"); -#endif - snd_es1688_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_es1688_driver, SNDRV_CARDS); } static void __exit alsa_card_es1688_exit(void) { - snd_es1688_unregister_all(); + isa_unregister_driver(&snd_es1688_driver); } -module_init(alsa_card_es1688_init) -module_exit(alsa_card_es1688_exit) +module_init(alsa_card_es1688_init); +module_exit(alsa_card_es1688_exit); diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 725c115..12b61af 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -80,7 +80,7 @@ #include #include #include -#include +#include #include #include #include @@ -2035,8 +2035,6 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18 module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); -static struct platform_device *platform_devices[SNDRV_CARDS]; - #ifdef CONFIG_PNP static int pnp_registered, pnpc_registered; @@ -2237,7 +2235,12 @@ static int __devinit snd_audiodrive_prob return snd_card_register(card); } -static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) +static int __devinit snd_es18xx_isa_match(struct device *pdev, unsigned int dev) +{ + return enable[dev] && !is_isapnp_selected(dev); +} + +static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr) { struct snd_card *card; int err; @@ -2245,18 +2248,17 @@ static int __devinit snd_es18xx_nonpnp_p card = snd_es18xx_card_new(dev); if (! card) return -ENOMEM; - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, devptr); if ((err = snd_audiodrive_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(devptr, card); + dev_set_drvdata(devptr, card); return 0; } -static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_es18xx_isa_probe(struct device *pdev, unsigned int dev) { - int dev = pdev->id; int err; static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; static int possible_dmas[] = {1, 0, 3, 5, -1}; @@ -2281,13 +2283,13 @@ static int __devinit snd_es18xx_nonpnp_p } if (port[dev] != SNDRV_AUTO_PORT) { - return snd_es18xx_nonpnp_probe1(dev, pdev); + return snd_es18xx_isa_probe1(dev, pdev); } else { static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; - err = snd_es18xx_nonpnp_probe1(dev, pdev); + err = snd_es18xx_isa_probe1(dev, pdev); if (! err) return 0; } @@ -2295,33 +2297,36 @@ static int __devinit snd_es18xx_nonpnp_p } } -static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_es18xx_isa_remove(struct device *devptr, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #ifdef CONFIG_PM -static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +static int snd_es18xx_isa_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - return snd_es18xx_suspend(platform_get_drvdata(dev), state); + return snd_es18xx_suspend(dev_get_drvdata(dev), state); } -static int snd_es18xx_nonpnp_resume(struct platform_device *dev) +static int snd_es18xx_isa_resume(struct device *dev, unsigned int n) { - return snd_es18xx_resume(platform_get_drvdata(dev)); + return snd_es18xx_resume(dev_get_drvdata(dev)); } #endif #define ES18XX_DRIVER "snd_es18xx" -static struct platform_driver snd_es18xx_nonpnp_driver = { - .probe = snd_es18xx_nonpnp_probe, - .remove = __devexit_p(snd_es18xx_nonpnp_remove), +static struct isa_driver snd_es18xx_isa_driver = { + .match = snd_es18xx_isa_match, + .probe = snd_es18xx_isa_probe, + .remove = __devexit_p(snd_es18xx_isa_remove), #ifdef CONFIG_PM - .suspend = snd_es18xx_nonpnp_suspend, - .resume = snd_es18xx_nonpnp_resume, + .suspend = snd_es18xx_isa_suspend, + .resume = snd_es18xx_isa_resume, #endif .driver = { .name = ES18XX_DRIVER @@ -2330,8 +2335,6 @@ #endif #ifdef CONFIG_PNP -static unsigned int __devinitdata es18xx_pnp_devices; - static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, const struct pnp_device_id *id) { @@ -2362,7 +2365,6 @@ static int __devinit snd_audiodrive_pnp_ } pnp_set_drvdata(pdev, card); dev++; - es18xx_pnp_devices++; return 0; } @@ -2424,7 +2426,6 @@ static int __devinit snd_audiodrive_pnpc pnp_set_card_drvdata(pcard, card); dev++; - es18xx_pnp_devices++; return 0; } @@ -2460,44 +2461,14 @@ #endif }; #endif /* CONFIG_PNP */ -static void __init_or_module snd_es18xx_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnpc_registered) - pnp_unregister_card_driver(&es18xx_pnpc_driver); - if (pnp_registered) - pnp_unregister_driver(&es18xx_pnp_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); -} - static int __init alsa_card_es18xx_init(void) { - int i, err, cards = 0; + int err; - if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0) + err = isa_register_driver(&snd_es18xx_isa_driver, SNDRV_CARDS); + if (err < 0) return err; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i] || is_isapnp_selected(i)) - continue; - device = platform_device_register_simple(ES18XX_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - cards++; - } - #ifdef CONFIG_PNP err = pnp_register_driver(&es18xx_pnp_driver); if (!err) @@ -2505,22 +2476,19 @@ #ifdef CONFIG_PNP err = pnp_register_card_driver(&es18xx_pnpc_driver); if (!err) pnpc_registered = 1; - cards += es18xx_pnp_devices; -#endif - - if(!cards) { -#ifdef MODULE - snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); #endif - snd_es18xx_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_es18xx_exit(void) { - snd_es18xx_unregister_all(); +#ifdef CONFIG_PNP + if (pnpc_registered) + pnp_unregister_card_driver(&es18xx_pnpc_driver); + if (pnp_registered) + pnp_unregister_driver(&es18xx_pnp_driver); +#endif + isa_unregister_driver(&snd_es18xx_isa_driver); } module_init(alsa_card_es18xx_init) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 0395e2e..8f23f43 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,8 +33,11 @@ #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include +#define CRD_NAME "Gravis UltraSound Classic" +#define DEV_NAME "gusclassic" + +MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Gravis UltraSound Classic"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}"); @@ -51,32 +54,80 @@ static int channels[SNDRV_CARDS] = {[0 . static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for GUS Classic soundcard."); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for GUS Classic soundcard."); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable GUS Classic soundcard."); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); module_param_array(port, long, NULL, 0444); -MODULE_PARM_DESC(port, "Port # for GUS Classic driver."); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); module_param_array(irq, int, NULL, 0444); -MODULE_PARM_DESC(irq, "IRQ # for GUS Classic driver."); +MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); module_param_array(dma1, int, NULL, 0444); -MODULE_PARM_DESC(dma1, "DMA1 # for GUS Classic driver."); +MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver."); module_param_array(dma2, int, NULL, 0444); -MODULE_PARM_DESC(dma2, "DMA2 # for GUS Classic driver."); +MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver."); module_param_array(joystick_dac, int, NULL, 0444); -MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Classic driver."); +MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver."); module_param_array(channels, int, NULL, 0444); -MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); +MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver."); module_param_array(pcm_channels, int, NULL, 0444); -MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); +MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver."); + +static int __devinit snd_gusclassic_match(struct device *dev, unsigned int n) +{ + return enable[n]; +} + +static int __devinit snd_gusclassic_create(struct snd_card *card, + struct device *dev, unsigned int n, struct snd_gus_card **rgus) +{ + static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260}; + static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; + static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; + + int i, error; + + if (irq[n] == SNDRV_AUTO_IRQ) { + irq[n] = snd_legacy_find_free_irq(possible_irqs); + if (irq[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", + dev->bus_id); + return -EBUSY; + } + } + if (dma1[n] == SNDRV_AUTO_DMA) { + dma1[n] = snd_legacy_find_free_dma(possible_dmas); + if (dma1[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free DMA1\n", + dev->bus_id); + return -EBUSY; + } + } + if (dma2[n] == SNDRV_AUTO_DMA) { + dma2[n] = snd_legacy_find_free_dma(possible_dmas); + if (dma2[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free DMA2\n", + dev->bus_id); + return -EBUSY; + } + } -static struct platform_device *devices[SNDRV_CARDS]; + if (port[n] != SNDRV_AUTO_PORT) + return snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n], + 0, channels[n], pcm_channels[n], 0, rgus); + i = 0; + do { + port[n] = possible_ports[i]; + error = snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n], + 0, channels[n], pcm_channels[n], 0, rgus); + } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); -#define PFX "gusclassic: " + return error; +} -static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus) +static int __devinit snd_gusclassic_detect(struct snd_gus_card *gus) { unsigned char d; @@ -95,187 +146,104 @@ static int __devinit snd_gusclassic_dete return 0; } -static void __devinit snd_gusclassic_init(int dev, struct snd_gus_card * gus) -{ - gus->equal_irq = 0; - gus->codec_flag = 0; - gus->max_flag = 0; - gus->joystick_dac = joystick_dac[dev]; -} - -static int __devinit snd_gusclassic_probe(struct platform_device *pdev) +static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n) { - int dev = pdev->id; - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; - static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; - int xirq, xdma1, xdma2; struct snd_card *card; - struct snd_gus_card *gus = NULL; - int err; - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; - if (pcm_channels[dev] < 2) - pcm_channels[dev] = 2; - - xirq = irq[dev]; - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; - } - } - xdma1 = dma1[dev]; - if (xdma1 == SNDRV_AUTO_DMA) { - if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; - } - } - xdma2 = dma2[dev]; - if (xdma2 == SNDRV_AUTO_DMA) { - if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; - } - } + struct snd_gus_card *gus; + int error; - if (port[dev] != SNDRV_AUTO_PORT) { - err = snd_gus_create(card, - port[dev], - xirq, xdma1, xdma2, - 0, channels[dev], pcm_channels[dev], - 0, &gus); - } else { - /* auto-probe legacy ports */ - static unsigned long possible_ports[] = { - 0x220, 0x230, 0x240, 0x250, 0x260, - }; - int i; - for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { - err = snd_gus_create(card, - possible_ports[i], - xirq, xdma1, xdma2, - 0, channels[dev], pcm_channels[dev], - 0, &gus); - if (err >= 0) { - port[dev] = possible_ports[i]; - break; - } - } - } - if (err < 0) - goto _err; + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); + if (!card) + return -EINVAL; - if ((err = snd_gusclassic_detect(gus)) < 0) - goto _err; + if (pcm_channels[n] < 2) + pcm_channels[n] = 2; - snd_gusclassic_init(dev, gus); - if ((err = snd_gus_initialize(gus)) < 0) - goto _err; + error = snd_gusclassic_create(card, dev, n, &gus); + if (error < 0) + goto out; + error = snd_gusclassic_detect(gus); + if (error < 0) + goto out; + + gus->joystick_dac = joystick_dac[n]; + + error = snd_gus_initialize(gus); + if (error < 0) + goto out; + + error = -ENODEV; if (gus->max_flag || gus->ess_flag) { - snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); - err = -ENODEV; - goto _err; + snd_printk(KERN_ERR "%s: GUS Classic or ACE soundcard was " + "not detected at 0x%lx\n", dev->bus_id, gus->gf1.port); + goto out; } - if ((err = snd_gf1_new_mixer(gus)) < 0) - goto _err; + error = snd_gf1_new_mixer(gus); + if (error < 0) + goto out; - if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) - goto _err; + error = snd_gf1_pcm_new(gus, 0, 0, NULL); + if (error < 0) + goto out; if (!gus->ace_flag) { - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) - goto _err; + error = snd_gf1_rawmidi_new(gus, 0, NULL); + if (error < 0) + goto out; } - sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); - if (xdma2 >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - snd_card_set_dev(card, &pdev->dev); + sprintf(card->longname + strlen(card->longname), + " at 0x%lx, irq %d, dma %d", + gus->gf1.port, gus->gf1.irq, gus->gf1.dma1); - if ((err = snd_card_register(card)) < 0) - goto _err; + if (gus->gf1.dma2 >= 0) + sprintf(card->longname + strlen(card->longname), + "&%d", gus->gf1.dma2); - platform_set_drvdata(pdev, card); + snd_card_set_dev(card, dev); + + error = snd_card_register(card); + if (error < 0) + goto out; + + dev_set_drvdata(dev, card); return 0; - _err: - snd_card_free(card); - return err; +out: snd_card_free(card); + return error; } -static int __devexit snd_gusclassic_remove(struct platform_device *devptr) +static int __devexit snd_gusclassic_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } -#define GUSCLASSIC_DRIVER "snd_gusclassic" - -static struct platform_driver snd_gusclassic_driver = { +static struct isa_driver snd_gusclassic_driver = { + .match = snd_gusclassic_match, .probe = snd_gusclassic_probe, .remove = __devexit_p(snd_gusclassic_remove), - /* FIXME: suspend/resume */ +#if 0 /* FIXME */ + .suspend = snd_gusclassic_suspend, + .remove = snd_gusclassic_remove, +#endif .driver = { - .name = GUSCLASSIC_DRIVER - }, + .name = DEV_NAME + } }; -static void __init_or_module snd_gusclassic_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_gusclassic_driver); -} - static int __init alsa_card_gusclassic_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_gusclassic_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(GUSCLASSIC_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); -#endif - snd_gusclassic_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS); } static void __exit alsa_card_gusclassic_exit(void) { - snd_gusclassic_unregister_all(); + isa_unregister_driver(&snd_gusclassic_driver); } -module_init(alsa_card_gusclassic_init) -module_exit(alsa_card_gusclassic_exit) +module_init(alsa_card_gusclassic_init); +module_exit(alsa_card_gusclassic_exit); diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 4f55fc3..0aeaa6c 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,8 +37,11 @@ #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include +#define CRD_NAME "Gravis UltraSound Extreme" +#define DEV_NAME "gusextreme" + +MODULE_DESCRIPTION(CRD_NAME); MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Gravis UltraSound Extreme"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}"); @@ -59,43 +62,107 @@ static int channels[SNDRV_CARDS] = {[0 . static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for GUS Extreme soundcard."); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for GUS Extreme soundcard."); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable GUS Extreme soundcard."); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); module_param_array(port, long, NULL, 0444); -MODULE_PARM_DESC(port, "Port # for GUS Extreme driver."); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); module_param_array(gf1_port, long, NULL, 0444); -MODULE_PARM_DESC(gf1_port, "GF1 port # for GUS Extreme driver (optional)."); +MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional)."); module_param_array(mpu_port, long, NULL, 0444); -MODULE_PARM_DESC(mpu_port, "MPU-401 port # for GUS Extreme driver."); +MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver."); module_param_array(irq, int, NULL, 0444); -MODULE_PARM_DESC(irq, "IRQ # for GUS Extreme driver."); +MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); module_param_array(mpu_irq, int, NULL, 0444); -MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for GUS Extreme driver."); +MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver."); module_param_array(gf1_irq, int, NULL, 0444); -MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for GUS Extreme driver."); +MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver."); module_param_array(dma8, int, NULL, 0444); -MODULE_PARM_DESC(dma8, "8-bit DMA # for GUS Extreme driver."); +MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver."); module_param_array(dma1, int, NULL, 0444); -MODULE_PARM_DESC(dma1, "GF1 DMA # for GUS Extreme driver."); +MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver."); module_param_array(joystick_dac, int, NULL, 0444); -MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Extreme driver."); +MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver."); module_param_array(channels, int, NULL, 0444); -MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); +MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver."); module_param_array(pcm_channels, int, NULL, 0444); -MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); +MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver."); + +static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n) +{ + return enable[n]; +} + +static int __devinit snd_gusextreme_es1688_create(struct snd_card *card, + struct device *dev, unsigned int n, struct snd_es1688 **rchip) +{ + static long possible_ports[] = {0x220, 0x240, 0x260}; + static int possible_irqs[] = {5, 9, 10, 7, -1}; + static int possible_dmas[] = {1, 3, 0, -1}; + + int i, error; + + if (irq[n] == SNDRV_AUTO_IRQ) { + irq[n] = snd_legacy_find_free_irq(possible_irqs); + if (irq[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free IRQ " + "for ES1688\n", dev->bus_id); + return -EBUSY; + } + } + if (dma8[n] == SNDRV_AUTO_DMA) { + dma8[n] = snd_legacy_find_free_dma(possible_dmas); + if (dma8[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free DMA " + "for ES1688\n", dev->bus_id); + return -EBUSY; + } + } -static struct platform_device *devices[SNDRV_CARDS]; + if (port[n] != SNDRV_AUTO_PORT) + return snd_es1688_create(card, port[n], mpu_port[n], irq[n], + mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); + i = 0; + do { + port[n] = possible_ports[i]; + error = snd_es1688_create(card, port[n], mpu_port[n], irq[n], + mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); + } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); -#define PFX "gusextreme: " + return error; +} -static int __devinit snd_gusextreme_detect(int dev, - struct snd_card *card, - struct snd_gus_card * gus, - struct snd_es1688 *es1688) +static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card, + struct device *dev, unsigned int n, struct snd_gus_card **rgus) +{ + static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1}; + static int possible_dmas[] = {5, 6, 7, 3, 1, -1}; + + if (gf1_irq[n] == SNDRV_AUTO_IRQ) { + gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs); + if (gf1_irq[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free IRQ " + "for GF1\n", dev->bus_id); + return -EBUSY; + } + } + if (dma1[n] == SNDRV_AUTO_DMA) { + dma1[n] = snd_legacy_find_free_dma(possible_dmas); + if (dma1[n] < 0) { + snd_printk(KERN_ERR "%s: unable to find a free DMA " + "for GF1\n", dev->bus_id); + return -EBUSY; + } + } + return snd_gus_create(card, gf1_port[n], gf1_irq[n], dma1[n], -1, + 0, channels[n], pcm_channels[n], 0, rgus); +} + +static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus, + struct snd_es1688 *es1688) { unsigned long flags; unsigned char d; @@ -117,12 +184,13 @@ static int __devinit snd_gusextreme_dete spin_lock_irqsave(&es1688->mixer_lock, flags); snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */ spin_unlock_irqrestore(&es1688->mixer_lock, flags); + spin_lock_irqsave(&es1688->reg_lock, flags); - outb(gf1_port[dev] & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); + outb(gus->gf1.port & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); outb(0, 0x201); - outb(gf1_port[dev] & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); + outb(gus->gf1.port & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); outb(0, 0x201); - outb(gf1_port[dev] & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); + outb(gus->gf1.port & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); spin_unlock_irqrestore(&es1688->reg_lock, flags); udelay(100); @@ -139,253 +207,172 @@ static int __devinit snd_gusextreme_dete snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -EIO; } - return 0; -} -static void __devinit snd_gusextreme_init(int dev, struct snd_gus_card * gus) -{ - gus->joystick_dac = joystick_dac[dev]; + return 0; } static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) { struct snd_card *card = chip->card; struct snd_ctl_elem_id id1, id2; - int err; + int error; memset(&id1, 0, sizeof(id1)); memset(&id2, 0, sizeof(id2)); id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + /* reassign AUX to SYNTHESIZER */ strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "Synth Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - return err; + error = snd_ctl_rename_id(card, &id1, &id2); + if (error < 0) + return error; + /* reassign Master Playback Switch to Synth Playback Switch */ strcpy(id1.name, "Master Playback Switch"); strcpy(id2.name, "Synth Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - return err; + error = snd_ctl_rename_id(card, &id1, &id2); + if (error < 0) + return error; + return 0; } -static int __devinit snd_gusextreme_probe(struct platform_device *pdev) +static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n) { - int dev = pdev->id; - static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; - static int possible_ess_dmas[] = {1, 3, 0, -1}; - static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; - int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; struct snd_card *card; struct snd_gus_card *gus; struct snd_es1688 *es1688; struct snd_opl3 *opl3; - int err; + int error; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); - if (card == NULL) - return -ENOMEM; + card = snd_card_new(index[n], id[n], THIS_MODULE, 0); + if (!card) + return -EINVAL; - xgf1_irq = gf1_irq[dev]; - if (xgf1_irq == SNDRV_AUTO_IRQ) { - if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n"); - err = -EBUSY; - goto out; - } - } - xess_irq = irq[dev]; - if (xess_irq == SNDRV_AUTO_IRQ) { - if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n"); - err = -EBUSY; - goto out; - } - } - if (mpu_port[dev] == SNDRV_AUTO_PORT) - mpu_port[dev] = 0; - xmpu_irq = mpu_irq[dev]; - if (xmpu_irq > 15) - xmpu_irq = -1; - xgf1_dma = dma1[dev]; - if (xgf1_dma == SNDRV_AUTO_DMA) { - if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n"); - err = -EBUSY; - goto out; - } - } - xess_dma = dma8[dev]; - if (xess_dma == SNDRV_AUTO_DMA) { - if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n"); - err = -EBUSY; - goto out; - } - } + if (mpu_port[n] == SNDRV_AUTO_PORT) + mpu_port[n] = 0; - if (port[dev] != SNDRV_AUTO_PORT) { - err = snd_es1688_create(card, port[dev], mpu_port[dev], - xess_irq, xmpu_irq, xess_dma, - ES1688_HW_1688, &es1688); - } else { - /* auto-probe legacy ports */ - static unsigned long possible_ports[] = {0x220, 0x240, 0x260}; - int i; - for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { - err = snd_es1688_create(card, - possible_ports[i], - mpu_port[dev], - xess_irq, xmpu_irq, xess_dma, - ES1688_HW_1688, &es1688); - if (err >= 0) { - port[dev] = possible_ports[i]; - break; - } - } - } - if (err < 0) + if (mpu_irq[n] > 15) + mpu_irq[n] = -1; + + error = snd_gusextreme_es1688_create(card, dev, n, &es1688); + if (error < 0) goto out; - if (gf1_port[dev] < 0) - gf1_port[dev] = port[dev] + 0x20; - if ((err = snd_gus_create(card, - gf1_port[dev], - xgf1_irq, - xgf1_dma, - -1, - 0, channels[dev], - pcm_channels[dev], 0, - &gus)) < 0) + if (gf1_port[n] < 0) + gf1_port[n] = es1688->port + 0x20; + + error = snd_gusextreme_gus_card_create(card, dev, n, &gus); + if (error < 0) goto out; - if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) + error = snd_gusextreme_detect(gus, es1688); + if (error < 0) goto out; - snd_gusextreme_init(dev, gus); - if ((err = snd_gus_initialize(gus)) < 0) + gus->joystick_dac = joystick_dac[n]; + + error = snd_gus_initialize(gus); + if (error < 0) goto out; + error = -ENODEV; if (!gus->ess_flag) { - snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); - err = -ENODEV; + snd_printk(KERN_ERR "%s: GUS Extreme soundcard was not " + "detected at 0x%lx\n", dev->bus_id, gus->gf1.port); goto out; } - if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) + gus->codec_flag = 1; + + error = snd_es1688_pcm(es1688, 0, NULL); + if (error < 0) goto out; - if ((err = snd_es1688_mixer(es1688)) < 0) + error = snd_es1688_mixer(es1688); + if (error < 0) goto out; snd_component_add(card, "ES1688"); - if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + + if (pcm_channels[n] > 0) { + error = snd_gf1_pcm_new(gus, 1, 1, NULL); + if (error < 0) goto out; } - if ((err = snd_gf1_new_mixer(gus)) < 0) + + error = snd_gf1_new_mixer(gus); + if (error < 0) goto out; - if ((err = snd_gusextreme_mixer(es1688)) < 0) + error = snd_gusextreme_mixer(es1688); + if (error < 0) goto out; if (snd_opl3_create(card, es1688->port, es1688->port + 2, - OPL3_HW_OPL3, 0, &opl3) < 0) { - printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); - } else { - if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) + OPL3_HW_OPL3, 0, &opl3) < 0) + printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n", + dev->bus_id, es1688->port); + else { + error = snd_opl3_hwdep_new(opl3, 0, 2, NULL); + if (error < 0) goto out; } - if (es1688->mpu_port >= 0x300 && - (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, - es1688->mpu_port, 0, - xmpu_irq, - IRQF_DISABLED, - NULL)) < 0) - goto out; + if (es1688->mpu_port >= 0x300) { + error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, + es1688->mpu_port, 0, + mpu_irq[n], IRQF_DISABLED, NULL); + if (error < 0) + goto out; + } - sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", - es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); + sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, " + "irq %i&%i, dma %i&%i", es1688->port, + gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8); - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, dev); - if ((err = snd_card_register(card)) < 0) + error = snd_card_register(card); + if (error < 0) goto out; - platform_set_drvdata(pdev, card); + dev_set_drvdata(dev, card); return 0; - out: - snd_card_free(card); - return err; +out: snd_card_free(card); + return error; } -static int __devexit snd_gusextreme_remove(struct platform_device *devptr) +static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(dev)); + dev_set_drvdata(dev, NULL); return 0; } -#define GUSEXTREME_DRIVER "snd_gusextreme" - -static struct platform_driver snd_gusextreme_driver = { +static struct isa_driver snd_gusextreme_driver = { + .match = snd_gusextreme_match, .probe = snd_gusextreme_probe, - .remove = __devexit_p(snd_gusextreme_remove), - /* FIXME: suspend/resume */ + .remove = snd_gusextreme_remove, +#if 0 /* FIXME */ + .suspend = snd_gusextreme_suspend, + .resume = snd_gusextreme_resume, +#endif .driver = { - .name = GUSEXTREME_DRIVER - }, + .name = DEV_NAME + } }; -static void __init_or_module snd_gusextreme_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_gusextreme_driver); -} - static int __init alsa_card_gusextreme_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_gusextreme_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(GUSEXTREME_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); -#endif - snd_gusextreme_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS); } static void __exit alsa_card_gusextreme_exit(void) { - snd_gusextreme_unregister_all(); + isa_unregister_driver(&snd_gusextreme_driver); } -module_init(alsa_card_gusextreme_init) -module_exit(alsa_card_gusextreme_exit) +module_init(alsa_card_gusextreme_init); +module_exit(alsa_card_gusextreme_exit); diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index d1ad90c..a0d2f8f 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,8 +72,6 @@ MODULE_PARM_DESC(channels, "Used GF1 cha module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); -static struct platform_device *devices[SNDRV_CARDS]; - struct snd_gusmax { int irq; struct snd_card *card; @@ -205,9 +203,13 @@ static void snd_gusmax_free(struct snd_c free_irq(maxcard->irq, (void *)maxcard); } -static int __devinit snd_gusmax_probe(struct platform_device *pdev) +static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev) +{ + return enable[dev]; +} + +static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev) { - int dev = pdev->id; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; @@ -333,7 +335,7 @@ static int __devinit snd_gusmax_probe(st if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_card_register(card)) < 0) goto _err; @@ -341,7 +343,7 @@ static int __devinit snd_gusmax_probe(st maxcard->gus = gus; maxcard->cs4231 = cs4231; - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; _err: @@ -349,16 +351,17 @@ static int __devinit snd_gusmax_probe(st return err; } -static int __devexit snd_gusmax_remove(struct platform_device *devptr) +static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #define GUSMAX_DRIVER "snd_gusmax" -static struct platform_driver snd_gusmax_driver = { +static struct isa_driver snd_gusmax_driver = { + .match = snd_gusmax_match, .probe = snd_gusmax_probe, .remove = __devexit_p(snd_gusmax_remove), /* FIXME: suspend/resume */ @@ -367,52 +370,14 @@ static struct platform_driver snd_gusmax }, }; -static void __init_or_module snd_gusmax_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_gusmax_driver); -} - static int __init alsa_card_gusmax_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_gusmax_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(GUSMAX_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); -#endif - snd_gusmax_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS); } static void __exit alsa_card_gusmax_exit(void) { - snd_gusmax_unregister_all(); + isa_unregister_driver(&snd_gusmax_driver); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 4ec2d79..3e46572 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -115,9 +115,6 @@ MODULE_PARM_DESC(pcm_channels, "Reserved module_param_array(effect, int, NULL, 0444); MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); -static struct platform_device *platform_devices[SNDRV_CARDS]; -static int pnp_registered; - struct snd_interwave { int irq; struct snd_card *card; @@ -138,6 +135,7 @@ #endif #ifdef CONFIG_PNP +static int pnp_registered; static struct pnp_card_device_id snd_interwave_pnpids[] = { #ifndef SNDRV_STB @@ -793,7 +791,7 @@ #endif return 0; } -static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) +static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr) { struct snd_card *card; int err; @@ -802,18 +800,30 @@ static int __devinit snd_interwave_nonpn if (! card) return -ENOMEM; - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, devptr); if ((err = snd_interwave_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(devptr, card); + dev_set_drvdata(devptr, card); return 0; } -static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_interwave_isa_match(struct device *pdev, + unsigned int dev) +{ + if (!enable[dev]) + return 0; +#ifdef CONFIG_PNP + if (isapnp[dev]) + return 0; +#endif + return 1; +} + +static int __devinit snd_interwave_isa_probe(struct device *pdev, + unsigned int dev) { - int dev = pdev->id; int err; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; @@ -838,13 +848,13 @@ static int __devinit snd_interwave_nonpn } if (port[dev] != SNDRV_AUTO_PORT) - return snd_interwave_nonpnp_probe1(dev, pdev); + return snd_interwave_isa_probe1(dev, pdev); else { static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; - err = snd_interwave_nonpnp_probe1(dev, pdev); + err = snd_interwave_isa_probe1(dev, pdev); if (! err) return 0; } @@ -852,16 +862,17 @@ static int __devinit snd_interwave_nonpn } } -static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } -static struct platform_driver snd_interwave_driver = { - .probe = snd_interwave_nonpnp_probe, - .remove = __devexit_p(snd_interwave_nonpnp_remove), +static struct isa_driver snd_interwave_driver = { + .match = snd_interwave_isa_match, + .probe = snd_interwave_isa_probe, + .remove = __devexit_p(snd_interwave_isa_remove), /* FIXME: suspend,resume */ .driver = { .name = INTERWAVE_DRIVER @@ -869,8 +880,6 @@ static struct platform_driver snd_interw }; #ifdef CONFIG_PNP -static unsigned int __devinitdata interwave_pnp_devices; - static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -900,7 +909,6 @@ static int __devinit snd_interwave_pnp_d } pnp_set_card_drvdata(pcard, card); dev++; - interwave_pnp_devices++; return 0; } @@ -921,64 +929,29 @@ static struct pnp_card_driver interwave_ #endif /* CONFIG_PNP */ -static void __init_or_module snd_interwave_unregister_all(void) -{ - int i; - - if (pnp_registered) - pnp_unregister_card_driver(&interwave_pnpc_driver); - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_interwave_driver); -} - static int __init alsa_card_interwave_init(void) { - int i, err, cards = 0; + int err; - if ((err = platform_driver_register(&snd_interwave_driver)) < 0) + err = isa_register_driver(&snd_interwave_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; #ifdef CONFIG_PNP - if (isapnp[i]) - continue; -#endif - device = platform_device_register_simple(INTERWAVE_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - cards++; - } - /* ISA PnP cards */ err = pnp_register_card_driver(&interwave_pnpc_driver); - if (!err) { + if (!err) pnp_registered = 1; - cards += interwave_pnp_devices;; - } - - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif - snd_interwave_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_interwave_exit(void) { - snd_interwave_unregister_all(); +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&interwave_pnpc_driver); +#endif + isa_unregister_driver(&snd_interwave_driver); } module_init(alsa_card_interwave_init) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index f3db686..50a812f 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -91,12 +91,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3- module_param_array(opl3sa3_ymode, int, NULL, 0444); MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); -static struct platform_device *platform_devices[SNDRV_CARDS]; #ifdef CONFIG_PNP static int pnp_registered; static int pnpc_registered; #endif -static unsigned int snd_opl3sa2_devices; /* control ports */ #define OPL3SA2_PM_CTRL 0x01 @@ -783,7 +781,6 @@ static int __devinit snd_opl3sa2_pnp_det } pnp_set_drvdata(pdev, card); dev++; - snd_opl3sa2_devices++; return 0; } @@ -850,7 +847,6 @@ static int __devinit snd_opl3sa2_pnp_cde } pnp_set_card_drvdata(pcard, card); dev++; - snd_opl3sa2_devices++; return 0; } @@ -884,116 +880,95 @@ #endif }; #endif /* CONFIG_PNP */ -static int __devinit snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_opl3sa2_isa_match(struct device *pdev, + unsigned int dev) { - struct snd_card *card; - int err; - int dev = pdev->id; - + if (!enable[dev]) + return 0; +#ifdef CONFIG_PNP + if (isapnp[dev]) + return 0; +#endif if (port[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify port\n"); - return -EINVAL; + return 0; } if (wss_port[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify wss_port\n"); - return -EINVAL; + return 0; } if (fm_port[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify fm_port\n"); - return -EINVAL; + return 0; } if (midi_port[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify midi_port\n"); - return -EINVAL; + return 0; } + return 1; +} + +static int __devinit snd_opl3sa2_isa_probe(struct device *pdev, + unsigned int dev) +{ + struct snd_card *card; + int err; card = snd_opl3sa2_card_new(dev); if (! card) return -ENOMEM; - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_opl3sa2_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devexit snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_opl3sa2_isa_remove(struct device *devptr, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #ifdef CONFIG_PM -static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); + return snd_opl3sa2_suspend(dev_get_drvdata(dev), state); } -static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) +static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n) { - return snd_opl3sa2_resume(platform_get_drvdata(dev)); + return snd_opl3sa2_resume(dev_get_drvdata(dev)); } #endif #define OPL3SA2_DRIVER "snd_opl3sa2" -static struct platform_driver snd_opl3sa2_nonpnp_driver = { - .probe = snd_opl3sa2_nonpnp_probe, - .remove = __devexit( snd_opl3sa2_nonpnp_remove), +static struct isa_driver snd_opl3sa2_isa_driver = { + .match = snd_opl3sa2_isa_match, + .probe = snd_opl3sa2_isa_probe, + .remove = __devexit( snd_opl3sa2_isa_remove), #ifdef CONFIG_PM - .suspend = snd_opl3sa2_nonpnp_suspend, - .resume = snd_opl3sa2_nonpnp_resume, + .suspend = snd_opl3sa2_isa_suspend, + .resume = snd_opl3sa2_isa_resume, #endif .driver = { .name = OPL3SA2_DRIVER }, }; -static void __init_or_module snd_opl3sa2_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnpc_registered) - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - if (pnp_registered) - pnp_unregister_driver(&opl3sa2_pnp_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); -} - static int __init alsa_card_opl3sa2_init(void) { - int i, err; + int err; - if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) + err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; -#ifdef CONFIG_PNP - if (isapnp[i]) - continue; -#endif - device = platform_device_register_simple(OPL3SA2_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - snd_opl3sa2_devices++; - } - #ifdef CONFIG_PNP err = pnp_register_driver(&opl3sa2_pnp_driver); if (!err) @@ -1002,20 +977,18 @@ #ifdef CONFIG_PNP if (!err) pnpc_registered = 1; #endif - - if (!snd_opl3sa2_devices) { -#ifdef MODULE - snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); -#endif - snd_opl3sa2_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_opl3sa2_exit(void) { - snd_opl3sa2_unregister_all(); +#ifdef CONFIG_PNP + if (pnpc_registered) + pnp_unregister_card_driver(&opl3sa2_pnpc_driver); + if (pnp_registered) + pnp_unregister_driver(&opl3sa2_pnp_driver); +#endif + isa_unregister_driver(&snd_opl3sa2_isa_driver); } module_init(alsa_card_opl3sa2_init) diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 1dd9837..33471bd 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -139,8 +139,6 @@ static void snd_miro_proc_init(struct sn #define DRIVER_NAME "snd-miro" -static struct platform_device *device; - static char * snd_opti9xx_names[] = { "unkown", "82C928", "82C929", @@ -558,7 +556,7 @@ static int snd_miro_put_double(struct sn return change; } -static struct snd_kcontrol_new snd_miro_controls[] = { +static struct snd_kcontrol_new snd_miro_controls[] __devinitdata = { MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER), MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC), MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE), @@ -570,7 +568,7 @@ MIRO_DOUBLE("Aux Playback Volume", 2, AC /* Equalizer with seven bands (only PCM20) from -12dB up to +12dB on each band */ -static struct snd_kcontrol_new snd_miro_eq_controls[] = { +static struct snd_kcontrol_new snd_miro_eq_controls[] __devinitdata = { MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1), MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2), MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3), @@ -580,15 +578,15 @@ MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7), }; -static struct snd_kcontrol_new snd_miro_radio_control[] = { +static struct snd_kcontrol_new snd_miro_radio_control[] __devinitdata = { MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1), }; -static struct snd_kcontrol_new snd_miro_line_control[] = { +static struct snd_kcontrol_new snd_miro_line_control[] __devinitdata = { MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1), }; -static struct snd_kcontrol_new snd_miro_preamp_control[] = { +static struct snd_kcontrol_new snd_miro_preamp_control[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost", @@ -598,7 +596,7 @@ static struct snd_kcontrol_new snd_miro_ .put = snd_miro_put_preamp, }}; -static struct snd_kcontrol_new snd_miro_amp_control[] = { +static struct snd_kcontrol_new snd_miro_amp_control[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line Boost", @@ -608,7 +606,7 @@ static struct snd_kcontrol_new snd_miro_ .put = snd_miro_put_amp, }}; -static struct snd_kcontrol_new snd_miro_capture_control[] = { +static struct snd_kcontrol_new snd_miro_capture_control[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Capture Switch", @@ -618,7 +616,7 @@ static struct snd_kcontrol_new snd_miro_ .put = snd_miro_put_capture, }}; -static unsigned char aci_init_values[][2] __initdata = { +static unsigned char aci_init_values[][2] __devinitdata = { { ACI_SET_MUTE, 0x00 }, { ACI_SET_POWERAMP, 0x00 }, { ACI_SET_PREAMP, 0x00 }, @@ -641,7 +639,7 @@ static unsigned char aci_init_values[][2 { ACI_SET_MASTER + 1, 0x20 }, }; -static int __init snd_set_aci_init_values(struct snd_miro *miro) +static int __devinit snd_set_aci_init_values(struct snd_miro *miro) { int idx, error; @@ -751,7 +749,8 @@ static long snd_legacy_find_free_ioport( return -1; } -static int __init snd_miro_init(struct snd_miro *chip, unsigned short hardware) +static int __devinit snd_miro_init(struct snd_miro *chip, + unsigned short hardware) { static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; @@ -962,7 +961,7 @@ static void snd_miro_proc_read(struct sn snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); } -static void __init snd_miro_proc_init(struct snd_miro * miro) +static void __devinit snd_miro_proc_init(struct snd_miro * miro) { struct snd_info_entry *entry; @@ -974,7 +973,7 @@ static void __init snd_miro_proc_init(st * Init */ -static int __init snd_miro_configure(struct snd_miro *chip) +static int __devinit snd_miro_configure(struct snd_miro *chip) { unsigned char wss_base_bits; unsigned char irq_bits; @@ -1131,7 +1130,8 @@ __skip_mpu: return 0; } -static int __init snd_card_miro_detect(struct snd_card *card, struct snd_miro *chip) +static int __devinit snd_card_miro_detect(struct snd_card *card, + struct snd_miro *chip) { int i, err; unsigned char value; @@ -1157,7 +1157,8 @@ static int __init snd_card_miro_detect(s return -ENODEV; } -static int __init snd_card_miro_aci_detect(struct snd_card *card, struct snd_miro * miro) +static int __devinit snd_card_miro_aci_detect(struct snd_card *card, + struct snd_miro * miro) { unsigned char regval; int i; @@ -1213,7 +1214,12 @@ static void snd_card_miro_free(struct sn release_and_free_resource(miro->res_mc_base); } -static int __init snd_miro_probe(struct platform_device *devptr) +static int __devinit snd_miro_match(struct device *devptr, unsigned int n) +{ + return 1; +} + +static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) { static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; @@ -1399,25 +1405,26 @@ static int __init snd_miro_probe(struct return error; } - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, devptr); if ((error = snd_card_register(card))) { snd_card_free(card); return error; } - platform_set_drvdata(devptr, card); + dev_set_drvdata(devptr, card); return 0; } -static int __devexit snd_miro_remove(struct platform_device *devptr) +static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } -static struct platform_driver snd_miro_driver = { +static struct isa_driver snd_miro_driver = { + .match = snd_miro_match, .probe = snd_miro_probe, .remove = __devexit_p(snd_miro_remove), /* FIXME: suspend/resume */ @@ -1428,27 +1435,12 @@ static struct platform_driver snd_miro_d static int __init alsa_card_miro_init(void) { - int error; - - if ((error = platform_driver_register(&snd_miro_driver)) < 0) - return error; - device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); - if (! IS_ERR(device)) { - if (platform_get_drvdata(device)) - return 0; - platform_device_unregister(device); - } -#ifdef MODULE - printk(KERN_ERR "no miro soundcard found\n"); -#endif - platform_driver_unregister(&snd_miro_driver); - return PTR_ERR(device); + return isa_register_driver(&snd_miro_driver, 1); } static void __exit alsa_card_miro_exit(void) { - platform_device_unregister(device); - platform_driver_unregister(&snd_miro_driver); + isa_unregister_driver(&snd_miro_driver); } module_init(alsa_card_miro_init) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index df22737..95d0ab1 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -259,7 +259,6 @@ #endif /* CONFIG_PNP */ }; static int snd_opti9xx_pnp_is_probed; -static struct platform_device *snd_opti9xx_platform_device; #ifdef CONFIG_PNP @@ -294,7 +293,7 @@ static char * snd_opti9xx_names[] = { }; -static long __init snd_legacy_find_free_ioport(long *port_table, long size) +static long __devinit snd_legacy_find_free_ioport(long *port_table, long size) { while (*port_table != -1) { if (request_region(*port_table, size, "ALSA test")) { @@ -306,7 +305,8 @@ static long __init snd_legacy_find_free_ return -1; } -static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) +static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, + unsigned short hardware) { static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; @@ -451,7 +451,7 @@ #define snd_opti9xx_write_mask(chip, reg (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) -static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) +static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) { unsigned char wss_base_bits; unsigned char irq_bits; @@ -934,10 +934,8 @@ static int snd_opti93x_trigger(struct sn case SNDRV_PCM_TRIGGER_STOP: { unsigned int what = 0; - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == chip->playback_substream) { what |= OPTi93X_PLAYBACK_ENABLE; snd_pcm_trigger_done(s, substream); @@ -1561,7 +1559,7 @@ static int snd_opti93x_put_double(struct return change; } -static struct snd_kcontrol_new snd_opti93x_controls[] = { +static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = { OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), @@ -1622,7 +1620,8 @@ static int snd_opti93x_mixer(struct snd_ #endif /* OPTi93X */ -static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) +static int __devinit snd_card_opti9xx_detect(struct snd_card *card, + struct snd_opti9xx *chip) { int i, err; @@ -1676,8 +1675,9 @@ #endif /* OPTi93X */ } #ifdef CONFIG_PNP -static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, - const struct pnp_card_device_id *pid) +static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, + struct pnp_card_link *card, + const struct pnp_card_device_id *pid) { struct pnp_dev *pdev; struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); @@ -1778,7 +1778,7 @@ static void snd_card_opti9xx_free(struct release_and_free_resource(chip->res_mc_base); } -static int __init snd_opti9xx_probe(struct snd_card *card) +static int __devinit snd_opti9xx_probe(struct snd_card *card) { static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; int error; @@ -1924,7 +1924,18 @@ static struct snd_card *snd_opti9xx_card return card; } -static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) +static int __devinit snd_opti9xx_isa_match(struct device *devptr, + unsigned int dev) +{ + if (snd_opti9xx_pnp_is_probed) + return 0; + if (isapnp) + return 0; + return 1; +} + +static int __devinit snd_opti9xx_isa_probe(struct device *devptr, + unsigned int dev) { struct snd_card *card; int error; @@ -1940,9 +1951,6 @@ #if defined(CS4231) || defined(OPTi93X) static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; #endif /* CS4231 || OPTi93X */ - if (snd_opti9xx_pnp_is_probed) - return -EBUSY; - if (mpu_port == SNDRV_AUTO_PORT) { if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); @@ -1984,25 +1992,27 @@ #endif snd_card_free(card); return error; } - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, devptr); if ((error = snd_opti9xx_probe(card)) < 0) { snd_card_free(card); return error; } - platform_set_drvdata(devptr, card); + dev_set_drvdata(devptr, card); return 0; } -static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_opti9xx_isa_remove(struct device *devptr, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } -static struct platform_driver snd_opti9xx_driver = { - .probe = snd_opti9xx_nonpnp_probe, - .remove = __devexit_p(snd_opti9xx_nonpnp_remove), +static struct isa_driver snd_opti9xx_driver = { + .match = snd_opti9xx_isa_match, + .probe = snd_opti9xx_isa_probe, + .remove = __devexit_p(snd_opti9xx_isa_remove), /* FIXME: suspend/resume */ .driver = { .name = DRIVER_NAME @@ -2010,8 +2020,8 @@ static struct platform_driver snd_opti9x }; #ifdef CONFIG_PNP -static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { struct snd_card *card; int error, hw; @@ -2074,11 +2084,6 @@ static struct pnp_card_driver opti9xx_pn }; #endif -#ifdef CONFIG_PNP -#define is_isapnp_selected() isapnp -#else -#define is_isapnp_selected() 0 -#endif #ifdef OPTi93X #define CHIP_NAME "82C93x" #else @@ -2087,42 +2092,19 @@ #endif static int __init alsa_card_opti9xx_init(void) { - int error; - struct platform_device *device; - #ifdef CONFIG_PNP pnp_register_card_driver(&opti9xx_pnpc_driver); if (snd_opti9xx_pnp_is_probed) return 0; #endif - if (! is_isapnp_selected()) { - error = platform_driver_register(&snd_opti9xx_driver); - if (error < 0) - return error; - device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); - if (!IS_ERR(device)) { - if (platform_get_drvdata(device)) { - snd_opti9xx_platform_device = device; - return 0; - } - platform_device_unregister(device); - } - platform_driver_unregister(&snd_opti9xx_driver); - } -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&opti9xx_pnpc_driver); -#endif -#ifdef MODULE - printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n"); -#endif - return -ENODEV; + return isa_register_driver(&snd_opti9xx_driver, 1); } static void __exit alsa_card_opti9xx_exit(void) { if (!snd_opti9xx_pnp_is_probed) { - platform_device_unregister(snd_opti9xx_platform_device); - platform_driver_unregister(&snd_opti9xx_driver); + isa_unregister_driver(&snd_opti9xx_driver); + return; } #ifdef CONFIG_PNP pnp_unregister_card_driver(&opti9xx_pnpc_driver); diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index d64e67f..8b734a2 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -25,7 +25,7 @@ #include #include #include #include -#include +#include #include #include #include @@ -128,7 +128,6 @@ module_param_array(seq_ports, int, NULL, MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); #endif -static struct platform_device *platform_devices[SNDRV_CARDS]; #ifdef CONFIG_PNP static int pnp_registered; #endif @@ -519,7 +518,7 @@ static int snd_sb16_resume(struct snd_ca } #endif -static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) +static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev) { struct snd_card_sb16 *acard; struct snd_card *card; @@ -539,19 +538,23 @@ #ifdef SNDRV_SBAWE_EMU8000 awe_port[dev] = port[dev] + 0x400; #endif - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, pdev); if ((err = snd_sb16_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(devptr, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_sb16_isa_match(struct device *pdev, unsigned int dev) +{ + return enable[dev] && !is_isapnp_selected(dev); +} + +static int __devinit snd_sb16_isa_probe(struct device *pdev, unsigned int dev) { - int dev = pdev->id; int err; static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_dmas8[] = {1, 3, 0, -1}; @@ -577,13 +580,13 @@ static int __devinit snd_sb16_nonpnp_pro } if (port[dev] != SNDRV_AUTO_PORT) - return snd_sb16_nonpnp_probe1(dev, pdev); + return snd_sb16_isa_probe1(dev, pdev); else { static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; - err = snd_sb16_nonpnp_probe1(dev, pdev); + err = snd_sb16_isa_probe1(dev, pdev); if (! err) return 0; } @@ -591,22 +594,23 @@ static int __devinit snd_sb16_nonpnp_pro } } -static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_sb16_isa_remove(struct device *pdev, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(pdev)); + dev_set_drvdata(pdev, NULL); return 0; } #ifdef CONFIG_PM -static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +static int snd_sb16_isa_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - return snd_sb16_suspend(platform_get_drvdata(dev), state); + return snd_sb16_suspend(dev_get_drvdata(dev), state); } -static int snd_sb16_nonpnp_resume(struct platform_device *dev) +static int snd_sb16_isa_resume(struct device *dev, unsigned int n) { - return snd_sb16_resume(platform_get_drvdata(dev)); + return snd_sb16_resume(dev_get_drvdata(dev)); } #endif @@ -616,12 +620,13 @@ #else #define SND_SB16_DRIVER "snd_sb16" #endif -static struct platform_driver snd_sb16_nonpnp_driver = { - .probe = snd_sb16_nonpnp_probe, - .remove = __devexit_p(snd_sb16_nonpnp_remove), +static struct isa_driver snd_sb16_isa_driver = { + .match = snd_sb16_isa_match, + .probe = snd_sb16_isa_probe, + .remove = __devexit_p(snd_sb16_isa_remove), #ifdef CONFIG_PM - .suspend = snd_sb16_nonpnp_suspend, - .resume = snd_sb16_nonpnp_resume, + .suspend = snd_sb16_isa_suspend, + .resume = snd_sb16_isa_resume, #endif .driver = { .name = SND_SB16_DRIVER @@ -630,8 +635,6 @@ #endif #ifdef CONFIG_PNP -static unsigned int __devinitdata sb16_pnp_devices; - static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -653,7 +656,6 @@ static int __devinit snd_sb16_pnp_detect } pnp_set_card_drvdata(pcard, card); dev++; - sb16_pnp_devices++; return 0; } @@ -695,68 +697,29 @@ #endif #endif /* CONFIG_PNP */ -static void __init_or_module snd_sb16_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnp_registered) - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_sb16_nonpnp_driver); -} - static int __init alsa_card_sb16_init(void) { - int i, err, cards = 0; + int err; - if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0) + err = isa_register_driver(&snd_sb16_isa_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i] || is_isapnp_selected(i)) - continue; - device = platform_device_register_simple(SND_SB16_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - cards++; - } #ifdef CONFIG_PNP /* PnP cards at last */ err = pnp_register_card_driver(&sb16_pnpc_driver); - if (!err) { + if (!err) pnp_registered = 1; - cards += sb16_pnp_devices; - } -#endif - - if (!cards) { -#ifdef MODULE - snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); -#ifdef SNDRV_SBAWE_EMU8000 - snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n"); -#else - snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); #endif -#endif - snd_sb16_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_sb16_exit(void) { - snd_sb16_unregister_all(); +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&sb16_pnpc_driver); +#endif + isa_unregister_driver(&snd_sb16_isa_driver); } module_init(alsa_card_sb16_init) diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 3d9d7e0..ef71e50 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -690,9 +690,7 @@ static int snd_sb_csp_load_user(struct s return err; } -#define FIRMWARE_IN_THE_KERNEL - -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL #include "sb16_csp_codecs.h" static const struct firmware snd_sb_csp_static_programs[] = { @@ -724,7 +722,7 @@ static int snd_sb_csp_firmware_load(stru if (err >= 0) p->csp_programs[index] = program; else { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL program = &snd_sb_csp_static_programs[index]; #else return err; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index be1e83e..b7de1bc 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,8 +56,6 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 dri module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); -static struct platform_device *devices[SNDRV_CARDS]; - struct snd_sb8 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct snd_sb *chip; @@ -83,9 +81,23 @@ static void snd_sb8_free(struct snd_card release_and_free_resource(acard->fm_res); } -static int __devinit snd_sb8_probe(struct platform_device *pdev) +static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev) +{ + if (!enable[dev]) + return 0; + if (irq[dev] == SNDRV_AUTO_IRQ) { + snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); + return 0; + } + if (dma8[dev] == SNDRV_AUTO_DMA) { + snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id); + return 0; + } + return 1; +} + +static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev) { - int dev = pdev->id; struct snd_sb *chip; struct snd_card *card; struct snd_sb8 *acard; @@ -180,12 +192,12 @@ static int __devinit snd_sb8_probe(struc chip->port, irq[dev], dma8[dev]); - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_card_register(card)) < 0) goto _err; - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; _err: @@ -193,17 +205,18 @@ static int __devinit snd_sb8_probe(struc return err; } -static int __devexit snd_sb8_remove(struct platform_device *pdev) +static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev) { - snd_card_free(platform_get_drvdata(pdev)); - platform_set_drvdata(pdev, NULL); + snd_card_free(dev_get_drvdata(pdev)); + dev_set_drvdata(pdev, NULL); return 0; } #ifdef CONFIG_PM -static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) +static int snd_sb8_suspend(struct device *dev, unsigned int n, + pm_message_t state) { - struct snd_card *card = platform_get_drvdata(dev); + struct snd_card *card = dev_get_drvdata(dev); struct snd_sb8 *acard = card->private_data; struct snd_sb *chip = acard->chip; @@ -213,9 +226,9 @@ static int snd_sb8_suspend(struct platfo return 0; } -static int snd_sb8_resume(struct platform_device *dev) +static int snd_sb8_resume(struct device *dev, unsigned int n) { - struct snd_card *card = platform_get_drvdata(dev); + struct snd_card *card = dev_get_drvdata(dev); struct snd_sb8 *acard = card->private_data; struct snd_sb *chip = acard->chip; @@ -228,7 +241,8 @@ #endif #define SND_SB8_DRIVER "snd_sb8" -static struct platform_driver snd_sb8_driver = { +static struct isa_driver snd_sb8_driver = { + .match = snd_sb8_match, .probe = snd_sb8_probe, .remove = __devexit_p(snd_sb8_remove), #ifdef CONFIG_PM @@ -240,52 +254,14 @@ #endif }, }; -static void __init_or_module snd_sb8_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_sb8_driver); -} - static int __init alsa_card_sb8_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_sb8_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(SND_SB8_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); -#endif - snd_sb8_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS); } static void __exit alsa_card_sb8_exit(void) { - snd_sb8_unregister_all(); + isa_unregister_driver(&snd_sb8_driver); } module_init(alsa_card_sb8_init) diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 4fcd0f4..19e0b0e 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -64,8 +64,6 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound G module_param_array(dma1, int, NULL, 0444); MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); -static struct platform_device *devices[SNDRV_CARDS]; - #define SGALAXY_AUXC_LEFT 18 #define SGALAXY_AUXC_RIGHT 19 @@ -96,7 +94,8 @@ static int snd_sgalaxy_sbdsp_reset(unsig return 0; } -static int __init snd_sgalaxy_sbdsp_command(unsigned long port, unsigned char val) +static int __devinit snd_sgalaxy_sbdsp_command(unsigned long port, + unsigned char val) { int i; @@ -114,7 +113,7 @@ static irqreturn_t snd_sgalaxy_dummy_int return IRQ_NONE; } -static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) +static int __devinit snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) { static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20, -1, -1, -1, -1}; @@ -161,7 +160,7 @@ #endif return 0; } -static int __init snd_sgalaxy_detect(int dev, int irq, int dma) +static int __devinit snd_sgalaxy_detect(int dev, int irq, int dma) { #if 0 snd_printdd(PFX "switching to WSS mode\n"); @@ -182,7 +181,7 @@ AD1848_DOUBLE("Aux Playback Switch", 0, AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) }; -static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) +static int __devinit snd_sgalaxy_mixer(struct snd_ad1848 *chip) { struct snd_card *card = chip->card; struct snd_ctl_elem_id id1, id2; @@ -218,23 +217,29 @@ static int __init snd_sgalaxy_mixer(stru return 0; } -static int __init snd_sgalaxy_probe(struct platform_device *devptr) +static int __devinit snd_sgalaxy_match(struct device *devptr, unsigned int dev) { - int dev = devptr->id; - static int possible_irqs[] = {7, 9, 10, 11, -1}; - static int possible_dmas[] = {1, 3, 0, -1}; - int err, xirq, xdma1; - struct snd_card *card; - struct snd_ad1848 *chip; - + if (!enable[dev]) + return 0; if (sbport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify SB port\n"); - return -EINVAL; + return 0; } if (wssport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify WSS port\n"); - return -EINVAL; + return 0; } + return 1; +} + +static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) +{ + static int possible_irqs[] = {7, 9, 10, 11, -1}; + static int possible_dmas[] = {1, 3, 0, -1}; + int err, xirq, xdma1; + struct snd_card *card; + struct snd_ad1848 *chip; + card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -283,12 +288,12 @@ static int __init snd_sgalaxy_probe(stru sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", wssport[dev], xirq, xdma1); - snd_card_set_dev(card, &devptr->dev); + snd_card_set_dev(card, devptr); if ((err = snd_card_register(card)) < 0) goto _err; - platform_set_drvdata(devptr, card); + dev_set_drvdata(devptr, card); return 0; _err: @@ -296,17 +301,18 @@ static int __init snd_sgalaxy_probe(stru return err; } -static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) +static int __devexit snd_sgalaxy_remove(struct device *devptr, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #ifdef CONFIG_PM -static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) +static int snd_sgalaxy_suspend(struct device *pdev, unsigned int n, + pm_message_t state) { - struct snd_card *card = platform_get_drvdata(pdev); + struct snd_card *card = dev_get_drvdata(pdev); struct snd_ad1848 *chip = card->private_data; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); @@ -314,9 +320,9 @@ static int snd_sgalaxy_suspend(struct pl return 0; } -static int snd_sgalaxy_resume(struct platform_device *pdev) +static int snd_sgalaxy_resume(struct device *pdev, unsigned int n) { - struct snd_card *card = platform_get_drvdata(pdev); + struct snd_card *card = dev_get_drvdata(pdev); struct snd_ad1848 *chip = card->private_data; chip->resume(chip); @@ -330,7 +336,8 @@ #endif #define SND_SGALAXY_DRIVER "snd_sgalaxy" -static struct platform_driver snd_sgalaxy_driver = { +static struct isa_driver snd_sgalaxy_driver = { + .match = snd_sgalaxy_match, .probe = snd_sgalaxy_probe, .remove = __devexit_p(snd_sgalaxy_remove), #ifdef CONFIG_PM @@ -342,52 +349,14 @@ #endif }, }; -static void __init_or_module snd_sgalaxy_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_sgalaxy_driver); -} - static int __init alsa_card_sgalaxy_init(void) { - int i, cards, err; - - err = platform_driver_register(&snd_sgalaxy_driver); - if (err < 0) - return err; - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; - device = platform_device_register_simple(SND_SGALAXY_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); -#endif - snd_sgalaxy_unregister_all(); - return -ENODEV; - } - return 0; + return isa_register_driver(&snd_sgalaxy_driver, SNDRV_CARDS); } static void __exit alsa_card_sgalaxy_exit(void) { - snd_sgalaxy_unregister_all(); + isa_unregister_driver(&snd_sgalaxy_driver); } module_init(alsa_card_sgalaxy_init) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index b1f2582..369de44 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,8 +68,6 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # module_param_array(dma, int, NULL, 0444); MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); -static struct platform_device *platform_devices[SNDRV_CARDS]; - #ifdef CONFIG_PNP static int pnp_registered; static struct pnp_card_device_id sscape_pnpids[] = { @@ -1254,9 +1252,27 @@ #define MIDI_DEVNUM 0 } -static int __devinit snd_sscape_probe(struct platform_device *pdev) +static int __devinit snd_sscape_match(struct device *pdev, unsigned int i) +{ + /* + * Make sure we were given ALL of the other parameters. + */ + if (port[i] == SNDRV_AUTO_PORT) + return 0; + + if (irq[i] == SNDRV_AUTO_IRQ || + mpu_irq[i] == SNDRV_AUTO_IRQ || + dma[i] == SNDRV_AUTO_DMA) { + printk(KERN_INFO + "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); + return 0; + } + + return 1; +} + +static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) { - int dev = pdev->id; struct snd_card *card; int ret; @@ -1264,25 +1280,26 @@ static int __devinit snd_sscape_probe(st ret = create_sscape(dev, &card); if (ret < 0) return ret; - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((ret = snd_card_register(card)) < 0) { printk(KERN_ERR "sscape: Failed to register sound card\n"); return ret; } - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devexit snd_sscape_remove(struct platform_device *devptr) +static int __devexit snd_sscape_remove(struct device *devptr, unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #define SSCAPE_DRIVER "snd_sscape" -static struct platform_driver snd_sscape_driver = { +static struct isa_driver snd_sscape_driver = { + .match = snd_sscape_match, .probe = snd_sscape_probe, .remove = __devexit_p(snd_sscape_remove), /* FIXME: suspend/resume */ @@ -1386,72 +1403,6 @@ static struct pnp_card_driver sscape_pnp #endif /* CONFIG_PNP */ -static void __init_or_module sscape_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnp_registered) - pnp_unregister_card_driver(&sscape_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_sscape_driver); -} - -static int __init sscape_manual_probe(void) -{ - struct platform_device *device; - int i, ret; - - ret = platform_driver_register(&snd_sscape_driver); - if (ret < 0) - return ret; - - for (i = 0; i < SNDRV_CARDS; ++i) { - /* - * We do NOT probe for ports. - * If we're not given a port number for this - * card then we completely ignore this line - * of parameters. - */ - if (port[i] == SNDRV_AUTO_PORT) - continue; - - /* - * Make sure we were given ALL of the other parameters. - */ - if (irq[i] == SNDRV_AUTO_IRQ || - mpu_irq[i] == SNDRV_AUTO_IRQ || - dma[i] == SNDRV_AUTO_DMA) { - printk(KERN_INFO - "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); - sscape_unregister_all(); - return -ENXIO; - } - - /* - * This cards looks OK ... - */ - device = platform_device_register_simple(SSCAPE_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - } - return 0; -} - -static void sscape_exit(void) -{ - sscape_unregister_all(); -} - - static int __init sscape_init(void) { int ret; @@ -1462,7 +1413,7 @@ static int __init sscape_init(void) * of allocating cards, because the operator is * S-P-E-L-L-I-N-G it out for us... */ - ret = sscape_manual_probe(); + ret = isa_register_driver(&snd_sscape_driver, SNDRV_CARDS); if (ret < 0) return ret; #ifdef CONFIG_PNP @@ -1472,5 +1423,14 @@ #endif return 0; } +static void __exit sscape_exit(void) +{ +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&sscape_pnpc_driver); +#endif + isa_unregister_driver(&snd_sscape_driver); +} + module_init(sscape_init); module_exit(sscape_exit); diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index e2fdd5f..6f14327 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -24,7 +24,7 @@ #include #include #include #include -#include +#include #include #include #include @@ -83,8 +83,6 @@ MODULE_PARM_DESC(fm_port, "FM port #."); module_param_array(use_cs4232_midi, bool, NULL, 0444); MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); -static struct platform_device *platform_devices[SNDRV_CARDS]; - #ifdef CONFIG_PNP static int pnp_registered; @@ -588,46 +586,59 @@ snd_wavefront_probe (struct snd_card *ca return snd_card_register(card); } -static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev) +static int __devinit snd_wavefront_isa_match(struct device *pdev, + unsigned int dev) { - int dev = pdev->id; - struct snd_card *card; - int err; - + if (!enable[dev]) + return 0; +#ifdef CONFIG_PNP + if (isapnp[dev]) + return 0; +#endif if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { snd_printk("specify CS4232 port\n"); - return -EINVAL; + return 0; } if (ics2115_port[dev] == SNDRV_AUTO_PORT) { snd_printk("specify ICS2115 port\n"); - return -ENODEV; + return 0; } + return 1; +} + +static int __devinit snd_wavefront_isa_probe(struct device *pdev, + unsigned int dev) +{ + struct snd_card *card; + int err; card = snd_wavefront_card_new(dev); if (! card) return -ENOMEM; - snd_card_set_dev(card, &pdev->dev); + snd_card_set_dev(card, pdev); if ((err = snd_wavefront_probe(card, dev)) < 0) { snd_card_free(card); return err; } - platform_set_drvdata(pdev, card); + dev_set_drvdata(pdev, card); return 0; } -static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) +static int __devexit snd_wavefront_isa_remove(struct device *devptr, + unsigned int dev) { - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); + snd_card_free(dev_get_drvdata(devptr)); + dev_set_drvdata(devptr, NULL); return 0; } #define WAVEFRONT_DRIVER "snd_wavefront" -static struct platform_driver snd_wavefront_driver = { - .probe = snd_wavefront_nonpnp_probe, - .remove = __devexit_p(snd_wavefront_nonpnp_remove), +static struct isa_driver snd_wavefront_driver = { + .match = snd_wavefront_isa_match, + .probe = snd_wavefront_isa_probe, + .remove = __devexit_p(snd_wavefront_isa_remove), /* FIXME: suspend, resume */ .driver = { .name = WAVEFRONT_DRIVER @@ -636,8 +647,6 @@ static struct platform_driver snd_wavefr #ifdef CONFIG_PNP -static unsigned int __devinitdata wavefront_pnp_devices; - static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -670,7 +679,6 @@ static int __devinit snd_wavefront_pnp_d pnp_set_card_drvdata(pcard, card); dev++; - wavefront_pnp_devices++; return 0; } @@ -691,67 +699,28 @@ static struct pnp_card_driver wavefront_ #endif /* CONFIG_PNP */ -static void __init_or_module snd_wavefront_unregister_all(void) -{ - int i; - -#ifdef CONFIG_PNP - if (pnp_registered) - pnp_unregister_card_driver(&wavefront_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) - platform_device_unregister(platform_devices[i]); - platform_driver_unregister(&snd_wavefront_driver); -} - static int __init alsa_card_wavefront_init(void) { - int i, err, cards = 0; + int err; - if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) + err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS); + if (err < 0) return err; - - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (! enable[i]) - continue; -#ifdef CONFIG_PNP - if (isapnp[i]) - continue; -#endif - device = platform_device_register_simple(WAVEFRONT_DRIVER, - i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - platform_devices[i] = device; - cards++; - } - #ifdef CONFIG_PNP err = pnp_register_card_driver(&wavefront_pnpc_driver); - if (!err) { + if (!err) pnp_registered = 1; - cards += wavefront_pnp_devices; - } -#endif - - if (!cards) { -#ifdef MODULE - printk (KERN_ERR "No WaveFront cards found or devices busy\n"); #endif - snd_wavefront_unregister_all(); - return -ENODEV; - } return 0; } static void __exit alsa_card_wavefront_exit(void) { - snd_wavefront_unregister_all(); +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&wavefront_pnpc_driver); +#endif + isa_unregister_driver(&snd_wavefront_driver); } module_init(alsa_card_wavefront_init) diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 15331ed..3a8c056 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -35,9 +35,7 @@ #define FX_AUTO_INCR 0x04 /* auto- #define WAIT_IDLE 0xff -#define FIRMWARE_IN_THE_KERNEL - -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL #include "yss225.c" static const struct firmware yss225_registers_firmware = { .data = (u8 *)yss225_registers, @@ -266,7 +264,7 @@ snd_wavefront_fx_start (snd_wavefront_t err = request_firmware(&firmware, "yamaha/yss225_registers.bin", dev->card->dev); if (err < 0) { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL firmware = &yss225_registers_firmware; #else err = -1; @@ -295,7 +293,7 @@ #endif err = 0; out: -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL if (firmware != &yss225_registers_firmware) #endif release_firmware(firmware); diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 1bcfb3a..12dfda3 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -576,7 +576,6 @@ config SND_INTEL8X0M config SND_KORG1212 tristate "Korg 1212 IO" depends on SND - select FW_LOADER select SND_PCM help Say Y here to include support for Korg 1212IO soundcards. @@ -584,6 +583,16 @@ config SND_KORG1212 To compile this driver as a module, choose M here: the module will be called snd-korg1212. +config SND_KORG1212_FIRMWARE_IN_KERNEL + bool "In-kernel firmware for Korg1212 driver" + depends on SND_KORG1212 + select FW_LOADER + default y + help + Say Y here to include the static firmware built in the kernel + for Korg1212 driver. If you choose N here, the external + firmware files from alsa-plugins pacakge are necessary. + config SND_MAESTRO3 tristate "ESS Allegro/Maestro3" depends on SND @@ -596,6 +605,16 @@ config SND_MAESTRO3 To compile this driver as a module, choose M here: the module will be called snd-maestro3. +config SND_MAESTRO3_FIRMWARE_IN_KERNEL + bool "In-kernel firmware for Maestro3 driver" + depends on SND_MAESTRO3 + select FW_LOADER + default y + help + Say Y here to include the static firmware built in the kernel + for Maestro3 driver. If you choose N here, the external + firmware files from alsa-plugins pacakge are necessary. + config SND_MIXART tristate "Digigram miXart" depends on SND @@ -737,7 +756,6 @@ config SND_VX222 config SND_YMFPCI tristate "Yamaha YMF724/740/744/754" depends on SND - select FW_LOADER select SND_OPL3_LIB select SND_MPU401_UART select SND_AC97_CODEC @@ -748,6 +766,16 @@ config SND_YMFPCI To compile this driver as a module, choose M here: the module will be called snd-ymfpci. +config SND_YMFPCI_FIRMWARE_IN_KERNEL + bool "In-kernel firmware for YMFPCI driver" + depends on SND_YMFPCI + select FW_LOADER + default y + help + Say Y here to include the static firmware built in the kernel + for YMFPCI driver. If you choose N here, the external + firmware files from alsa-plugins pacakge are necessary. + config SND_AC97_POWER_SAVE bool "AC97 Power-Saving Mode" depends on SND_AC97_CODEC && EXPERIMENTAL diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile index 3c32221..f5d4718 100644 --- a/sound/pci/ac97/Makefile +++ b/sound/pci/ac97/Makefile @@ -3,7 +3,7 @@ # Makefile for ALSA # Copyright (c) 2001 by Jaroslav Kysela # -snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_patch.o +snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ifneq ($(CONFIG_PROC_FS),) snd-ac97-codec-objs += ac97_proc.o diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index a9eec2a..4a86bf9 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -35,9 +35,9 @@ #include #include #include #include -#include "ac97_local.h" #include "ac97_id.h" -#include "ac97_patch.h" + +#include "ac97_patch.c" MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); @@ -432,7 +432,8 @@ static int snd_ac97_ad18xx_update_pcm_bi * Controls */ -int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; @@ -446,7 +447,8 @@ int snd_ac97_info_enum_double(struct snd return 0; } -int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; @@ -462,7 +464,8 @@ int snd_ac97_get_enum_double(struct snd_ return 0; } -int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; @@ -508,7 +511,8 @@ static void snd_ac97_page_restore(struct } /* volume and switch controls */ -int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; int shift = (kcontrol->private_value >> 8) & 0x0f; @@ -521,7 +525,8 @@ int snd_ac97_info_volsw(struct snd_kcont return 0; } -int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; @@ -544,7 +549,8 @@ int snd_ac97_get_volsw(struct snd_kcontr return 0; } -int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; @@ -646,7 +652,7 @@ AC97_ENUM("Mic Select", std_enum[3]), AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0) }; -const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0), AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0) }; @@ -817,7 +823,7 @@ static int snd_ac97_put_spsa(struct snd_ return change; } -const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { +static const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -1097,7 +1103,7 @@ static void check_volume_resolution(stru } } -int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) +static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) { unsigned short mask, val, orig, res; @@ -1137,7 +1143,8 @@ static inline int printable(unsigned int return x; } -struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97) +static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, + struct snd_ac97 * ac97) { struct snd_kcontrol_new template; memcpy(&template, _template, sizeof(template)); @@ -2544,7 +2551,8 @@ static void set_ctl_name(char *dst, cons } /* remove the control with the given name and optional suffix */ -int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix) +static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, + const char *suffix) { struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); @@ -2563,7 +2571,8 @@ static struct snd_kcontrol *ctl_find(str } /* rename the control with the given name and optional suffix */ -int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) +static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, + const char *dst, const char *suffix) { struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); if (kctl) { @@ -2574,14 +2583,16 @@ int snd_ac97_rename_ctl(struct snd_ac97 } /* rename both Volume and Switch controls - don't check the return value */ -void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst) +static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, + const char *dst) { snd_ac97_rename_ctl(ac97, src, dst, "Switch"); snd_ac97_rename_ctl(ac97, src, dst, "Volume"); } /* swap controls */ -int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) +static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, + const char *s2, const char *suffix) { struct snd_kcontrol *kctl1, *kctl2; kctl1 = ctl_find(ac97, s1, suffix); diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h index a6244c7..78745c5 100644 --- a/sound/pci/ac97/ac97_local.h +++ b/sound/pci/ac97/ac97_local.h @@ -22,59 +22,8 @@ * */ -#define AC97_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) -#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26)) -#define AC97_SINGLE(xname, reg, shift, mask, invert) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \ - .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ - .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) } -#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \ - .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ - .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) } -#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \ - .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ - .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } - -/* enum control */ -struct ac97_enum { - unsigned char reg; - unsigned char shift_l; - unsigned char shift_r; - unsigned short mask; - const char **texts; -}; - -#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ -{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ - .mask = xmask, .texts = xtexts } -#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \ - AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts) -#define AC97_ENUM(xname, xenum) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_enum_double, \ - .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \ - .private_value = (unsigned long)&xenum } - -/* ac97_codec.c */ -extern const struct snd_kcontrol_new snd_ac97_controls_3d[]; -extern const struct snd_kcontrol_new snd_ac97_controls_spdif[]; -struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97); -void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem); -int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); -int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit); -int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix); -int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix); -int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix); -void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst); -void snd_ac97_restore_status(struct snd_ac97 *ac97); -void snd_ac97_restore_iec958(struct snd_ac97 *ac97); -int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); -int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); - +void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, + int modem); int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value); diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index bfc2fed..6ec8cc5 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -23,20 +23,8 @@ * */ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include "ac97_patch.h" -#include "ac97_id.h" #include "ac97_local.h" +#include "ac97_patch.h" /* * Chip specific initialization @@ -390,7 +378,7 @@ static struct snd_ac97_build_ops patch_y .build_post_spdif = patch_yamaha_ymf753_post_spdif }; -int patch_yamaha_ymf753(struct snd_ac97 * ac97) +static int patch_yamaha_ymf753(struct snd_ac97 * ac97) { /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com. This chip has nonstandard and extended behaviour with regard to its S/PDIF output. @@ -436,7 +424,7 @@ static struct snd_ac97_build_ops patch_w .build_specific = patch_wolfson_wm9703_specific, }; -int patch_wolfson03(struct snd_ac97 * ac97) +static int patch_wolfson03(struct snd_ac97 * ac97) { ac97->build_ops = &patch_wolfson_wm9703_ops; return 0; @@ -467,7 +455,7 @@ static struct snd_ac97_build_ops patch_w .build_specific = patch_wolfson_wm9704_specific, }; -int patch_wolfson04(struct snd_ac97 * ac97) +static int patch_wolfson04(struct snd_ac97 * ac97) { /* WM9704M/9704Q */ ac97->build_ops = &patch_wolfson_wm9704_ops; @@ -489,7 +477,7 @@ static struct snd_ac97_build_ops patch_w .build_specific = patch_wolfson_wm9705_specific, }; -int patch_wolfson05(struct snd_ac97 * ac97) +static int patch_wolfson05(struct snd_ac97 * ac97) { /* WM9705, WM9710 */ ac97->build_ops = &patch_wolfson_wm9705_ops; @@ -625,7 +613,7 @@ static struct snd_ac97_build_ops patch_w .build_specific = patch_wolfson_wm9711_specific, }; -int patch_wolfson11(struct snd_ac97 * ac97) +static int patch_wolfson11(struct snd_ac97 * ac97) { /* WM9711, WM9712 */ ac97->build_ops = &patch_wolfson_wm9711_ops; @@ -824,7 +812,7 @@ #ifdef CONFIG_PM #endif }; -int patch_wolfson13(struct snd_ac97 * ac97) +static int patch_wolfson13(struct snd_ac97 * ac97) { /* WM9713, WM9714 */ ac97->build_ops = &patch_wolfson_wm9713_ops; @@ -844,7 +832,7 @@ int patch_wolfson13(struct snd_ac97 * ac /* * Tritech codec */ -int patch_tritech_tr28028(struct snd_ac97 * ac97) +static int patch_tritech_tr28028(struct snd_ac97 * ac97) { snd_ac97_write_cache(ac97, 0x26, 0x0300); snd_ac97_write_cache(ac97, 0x26, 0x0000); @@ -922,7 +910,7 @@ static struct snd_ac97_build_ops patch_s .build_specific = patch_sigmatel_stac97xx_specific }; -int patch_sigmatel_stac9700(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9700(struct snd_ac97 * ac97) { ac97->build_ops = &patch_sigmatel_stac9700_ops; return 0; @@ -969,7 +957,7 @@ static struct snd_ac97_build_ops patch_s .build_specific = patch_sigmatel_stac9708_specific }; -int patch_sigmatel_stac9708(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9708(struct snd_ac97 * ac97) { unsigned int codec72, codec6c; @@ -995,7 +983,7 @@ int patch_sigmatel_stac9708(struct snd_a return 0; } -int patch_sigmatel_stac9721(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9721(struct snd_ac97 * ac97) { ac97->build_ops = &patch_sigmatel_stac9700_ops; if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) { @@ -1009,7 +997,7 @@ int patch_sigmatel_stac9721(struct snd_a return 0; } -int patch_sigmatel_stac9744(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9744(struct snd_ac97 * ac97) { // patch for SigmaTel ac97->build_ops = &patch_sigmatel_stac9700_ops; @@ -1021,7 +1009,7 @@ int patch_sigmatel_stac9744(struct snd_a return 0; } -int patch_sigmatel_stac9756(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9756(struct snd_ac97 * ac97) { // patch for SigmaTel ac97->build_ops = &patch_sigmatel_stac9700_ops; @@ -1198,7 +1186,7 @@ static struct snd_ac97_build_ops patch_s .build_specific = patch_sigmatel_stac9758_specific }; -int patch_sigmatel_stac9758(struct snd_ac97 * ac97) +static int patch_sigmatel_stac9758(struct snd_ac97 * ac97) { static unsigned short regs[4] = { AC97_SIGMATEL_OUTSEL, @@ -1272,7 +1260,7 @@ static struct snd_ac97_build_ops patch_c .build_spdif = patch_cirrus_build_spdif }; -int patch_cirrus_spdif(struct snd_ac97 * ac97) +static int patch_cirrus_spdif(struct snd_ac97 * ac97) { /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers. WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh* @@ -1293,7 +1281,7 @@ int patch_cirrus_spdif(struct snd_ac97 * return 0; } -int patch_cirrus_cs4299(struct snd_ac97 * ac97) +static int patch_cirrus_cs4299(struct snd_ac97 * ac97) { /* force the detection of PC Beep */ ac97->flags |= AC97_HAS_PC_BEEP; @@ -1329,7 +1317,7 @@ static struct snd_ac97_build_ops patch_c .build_spdif = patch_conexant_build_spdif }; -int patch_conexant(struct snd_ac97 * ac97) +static int patch_conexant(struct snd_ac97 * ac97) { ac97->build_ops = &patch_conexant_ops; ac97->flags |= AC97_CX_SPDIF; @@ -1338,7 +1326,7 @@ int patch_conexant(struct snd_ac97 * ac9 return 0; } -int patch_cx20551(struct snd_ac97 *ac97) +static int patch_cx20551(struct snd_ac97 *ac97) { snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01); return 0; @@ -1430,7 +1418,7 @@ static const struct snd_ac97_res_table a { } /* terminator */ }; -int patch_ad1819(struct snd_ac97 * ac97) +static int patch_ad1819(struct snd_ac97 * ac97) { unsigned short scfg; @@ -1507,7 +1495,7 @@ #ifdef CONFIG_PM #endif }; -int patch_ad1881(struct snd_ac97 * ac97) +static int patch_ad1881(struct snd_ac97 * ac97) { static const char cfg_idxs[3][2] = { {2, 1}, @@ -1595,7 +1583,7 @@ #ifdef CONFIG_PM #endif }; -int patch_ad1885(struct snd_ac97 * ac97) +static int patch_ad1885(struct snd_ac97 * ac97) { patch_ad1881(ac97); /* This is required to deal with the Intel D815EEAL2 */ @@ -1622,7 +1610,7 @@ #ifdef CONFIG_PM #endif }; -int patch_ad1886(struct snd_ac97 * ac97) +static int patch_ad1886(struct snd_ac97 * ac97) { patch_ad1881(ac97); /* Presario700 workaround */ @@ -1790,6 +1778,8 @@ static const struct snd_kcontrol_new snd * (SS vendor << 16 | device) */ static unsigned int ad1981_jacks_blacklist[] = { + 0x10140523, /* Thinkpad R40 */ + 0x10140534, /* Thinkpad X31 */ 0x10140537, /* Thinkpad T41p */ 0x10140554, /* Thinkpad T42p/R50p */ 0 /* end */ @@ -1842,7 +1832,7 @@ static void check_ad1981_hp_jack_sense(s snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); } -int patch_ad1981a(struct snd_ac97 *ac97) +static int patch_ad1981a(struct snd_ac97 *ac97) { patch_ad1881(ac97); ac97->build_ops = &patch_ad1981a_build_ops; @@ -1875,7 +1865,7 @@ #ifdef CONFIG_PM #endif }; -int patch_ad1981b(struct snd_ac97 *ac97) +static int patch_ad1981b(struct snd_ac97 *ac97) { patch_ad1881(ac97); ac97->build_ops = &patch_ad1981b_build_ops; @@ -2010,7 +2000,7 @@ #endif .update_jacks = ad1888_update_jacks, }; -int patch_ad1888(struct snd_ac97 * ac97) +static int patch_ad1888(struct snd_ac97 * ac97) { unsigned short misc; @@ -2048,7 +2038,7 @@ #endif .update_jacks = ad1888_update_jacks, }; -int patch_ad1980(struct snd_ac97 * ac97) +static int patch_ad1980(struct snd_ac97 * ac97) { patch_ad1888(ac97); ac97->build_ops = &patch_ad1980_build_ops; @@ -2163,7 +2153,7 @@ #endif .update_jacks = ad1985_update_jacks, }; -int patch_ad1985(struct snd_ac97 * ac97) +static int patch_ad1985(struct snd_ac97 * ac97) { unsigned short misc; @@ -2463,7 +2453,7 @@ #endif .update_jacks = ad1986_update_jacks, }; -int patch_ad1986(struct snd_ac97 * ac97) +static int patch_ad1986(struct snd_ac97 * ac97) { patch_ad1881(ac97); ac97->build_ops = &patch_ad1986_build_ops; @@ -2556,7 +2546,7 @@ static struct snd_ac97_build_ops patch_a .update_jacks = alc650_update_jacks }; -int patch_alc650(struct snd_ac97 * ac97) +static int patch_alc650(struct snd_ac97 * ac97) { unsigned short val; @@ -2708,7 +2698,7 @@ static struct snd_ac97_build_ops patch_a .update_jacks = alc655_update_jacks }; -int patch_alc655(struct snd_ac97 * ac97) +static int patch_alc655(struct snd_ac97 * ac97) { unsigned int val; @@ -2810,7 +2800,7 @@ static struct snd_ac97_build_ops patch_a .update_jacks = alc850_update_jacks }; -int patch_alc850(struct snd_ac97 *ac97) +static int patch_alc850(struct snd_ac97 *ac97) { ac97->build_ops = &patch_alc850_ops; @@ -2870,7 +2860,7 @@ static struct snd_ac97_build_ops patch_c .update_jacks = cm9738_update_jacks }; -int patch_cm9738(struct snd_ac97 * ac97) +static int patch_cm9738(struct snd_ac97 * ac97) { ac97->build_ops = &patch_cm9738_ops; /* FIXME: can anyone confirm below? */ @@ -2962,7 +2952,7 @@ static struct snd_ac97_build_ops patch_c .update_jacks = cm9739_update_jacks }; -int patch_cm9739(struct snd_ac97 * ac97) +static int patch_cm9739(struct snd_ac97 * ac97) { unsigned short val; @@ -3136,7 +3126,7 @@ static struct snd_ac97_build_ops patch_c .update_jacks = cm9761_update_jacks }; -int patch_cm9761(struct snd_ac97 *ac97) +static int patch_cm9761(struct snd_ac97 *ac97) { unsigned short val; @@ -3231,7 +3221,7 @@ static struct snd_ac97_build_ops patch_c .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ }; -int patch_cm9780(struct snd_ac97 *ac97) +static int patch_cm9780(struct snd_ac97 *ac97) { unsigned short val; @@ -3274,7 +3264,7 @@ static struct snd_ac97_build_ops patch_v .build_specific = patch_vt1616_specific }; -int patch_vt1616(struct snd_ac97 * ac97) +static int patch_vt1616(struct snd_ac97 * ac97) { ac97->build_ops = &patch_vt1616_ops; return 0; @@ -3283,7 +3273,7 @@ int patch_vt1616(struct snd_ac97 * ac97) /* * VT1617A codec */ -int patch_vt1617a(struct snd_ac97 * ac97) +static int patch_vt1617a(struct snd_ac97 * ac97) { /* bring analog power consumption to normal, like WinXP driver * for EPIA SP @@ -3333,7 +3323,7 @@ static struct snd_ac97_build_ops patch_i .update_jacks = it2646_update_jacks }; -int patch_it2646(struct snd_ac97 * ac97) +static int patch_it2646(struct snd_ac97 * ac97) { ac97->build_ops = &patch_it2646_ops; /* full DAC volume */ @@ -3366,7 +3356,7 @@ static struct snd_ac97_build_ops patch_s .build_specific = patch_si3036_specific, }; -int mpatch_si3036(struct snd_ac97 * ac97) +static int mpatch_si3036(struct snd_ac97 * ac97) { ac97->build_ops = &patch_si3036_ops; snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); @@ -3398,7 +3388,7 @@ static struct snd_ac97_res_table lm4550_ { } /* terminator */ }; -int patch_lm4550(struct snd_ac97 *ac97) +static int patch_lm4550(struct snd_ac97 *ac97) { ac97->res_table = lm4550_restbl; return 0; @@ -3433,7 +3423,7 @@ static struct snd_ac97_build_ops patch_u .build_specific = patch_ucb1400_specific, }; -int patch_ucb1400(struct snd_ac97 * ac97) +static int patch_ucb1400(struct snd_ac97 * ac97) { ac97->build_ops = &patch_ucb1400_ops; /* enable headphone driver and smart low power mode by default */ diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h index 555d1c9..fd341ce 100644 --- a/sound/pci/ac97/ac97_patch.h +++ b/sound/pci/ac97/ac97_patch.h @@ -22,44 +22,72 @@ * */ -int patch_yamaha_ymf753(struct snd_ac97 * ac97); -int patch_wolfson00(struct snd_ac97 * ac97); -int patch_wolfson03(struct snd_ac97 * ac97); -int patch_wolfson04(struct snd_ac97 * ac97); -int patch_wolfson05(struct snd_ac97 * ac97); -int patch_wolfson11(struct snd_ac97 * ac97); -int patch_wolfson13(struct snd_ac97 * ac97); -int patch_tritech_tr28028(struct snd_ac97 * ac97); -int patch_sigmatel_stac9700(struct snd_ac97 * ac97); -int patch_sigmatel_stac9708(struct snd_ac97 * ac97); -int patch_sigmatel_stac9721(struct snd_ac97 * ac97); -int patch_sigmatel_stac9744(struct snd_ac97 * ac97); -int patch_sigmatel_stac9756(struct snd_ac97 * ac97); -int patch_sigmatel_stac9758(struct snd_ac97 * ac97); -int patch_cirrus_cs4299(struct snd_ac97 * ac97); -int patch_cirrus_spdif(struct snd_ac97 * ac97); -int patch_conexant(struct snd_ac97 * ac97); -int patch_cx20551(struct snd_ac97 * ac97); -int patch_ad1819(struct snd_ac97 * ac97); -int patch_ad1881(struct snd_ac97 * ac97); -int patch_ad1885(struct snd_ac97 * ac97); -int patch_ad1886(struct snd_ac97 * ac97); -int patch_ad1888(struct snd_ac97 * ac97); -int patch_ad1980(struct snd_ac97 * ac97); -int patch_ad1981a(struct snd_ac97 * ac97); -int patch_ad1981b(struct snd_ac97 * ac97); -int patch_ad1985(struct snd_ac97 * ac97); -int patch_ad1986(struct snd_ac97 * ac97); -int patch_alc650(struct snd_ac97 * ac97); -int patch_alc655(struct snd_ac97 * ac97); -int patch_alc850(struct snd_ac97 * ac97); -int patch_cm9738(struct snd_ac97 * ac97); -int patch_cm9739(struct snd_ac97 * ac97); -int patch_cm9761(struct snd_ac97 * ac97); -int patch_cm9780(struct snd_ac97 * ac97); -int patch_vt1616(struct snd_ac97 * ac97); -int patch_vt1617a(struct snd_ac97 * ac97); -int patch_it2646(struct snd_ac97 * ac97); -int patch_ucb1400(struct snd_ac97 * ac97); -int mpatch_si3036(struct snd_ac97 * ac97); -int patch_lm4550(struct snd_ac97 * ac97); +#define AC97_SINGLE_VALUE(reg,shift,mask,invert) \ + ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \ + ((invert) << 24)) +#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \ + (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26)) +#define AC97_SINGLE(xname, reg, shift, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_ac97_info_volsw, \ + .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ + .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) } +#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_ac97_info_volsw, \ + .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ + .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) } +#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ + .info = snd_ac97_info_volsw, \ + .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ + .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } + +/* enum control */ +struct ac97_enum { + unsigned char reg; + unsigned char shift_l; + unsigned char shift_r; + unsigned short mask; + const char **texts; +}; + +#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ +{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ + .mask = xmask, .texts = xtexts } +#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \ + AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts) +#define AC97_ENUM(xname, xenum) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_ac97_info_enum_double, \ + .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \ + .private_value = (unsigned long)&xenum } + +/* ac97_codec.c */ +static const struct snd_kcontrol_new snd_ac97_controls_3d[]; +static const struct snd_kcontrol_new snd_ac97_controls_spdif[]; +static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, + struct snd_ac97 * ac97); +static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit); +static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, + const char *suffix); +static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, + const char *dst, const char *suffix); +static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, + const char *s2, const char *suffix); +static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, + const char *dst); +static void snd_ac97_restore_status(struct snd_ac97 *ac97); +static void snd_ac97_restore_iec958(struct snd_ac97 *ac97); +static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c index 3758d07..4281e6d 100644 --- a/sound/pci/ac97/ac97_pcm.c +++ b/sound/pci/ac97/ac97_pcm.c @@ -34,7 +34,6 @@ #include #include #include #include -#include "ac97_patch.h" #include "ac97_id.h" #include "ac97_local.h" diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 9327ab2..cd2fe37 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1224,7 +1224,6 @@ static int snd_ali_trigger(struct snd_pc { struct snd_ali *codec = snd_pcm_substream_chip(substream); - struct list_head *pos; struct snd_pcm_substream *s; unsigned int what, whati, capture_flag; struct snd_ali_voice *pvoice = NULL, *evoice = NULL; @@ -1243,8 +1242,7 @@ static int snd_ali_trigger(struct snd_pc } what = whati = capture_flag = 0; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { pvoice = s->runtime->private_data; evoice = pvoice->extra; @@ -2312,6 +2310,8 @@ static int __devinit snd_ali_create(stru return err; } + snd_card_set_dev(card, &pci->dev); + /* initialise synth voices*/ for (i = 0; i < ALI_CHANNELS; i++ ) { codec->synth.voices[i].number = i; diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index e9b029e..9eb95a2 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_id BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), /* Viewcast Osprey 200 */ BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), + /* ATI TV-Wonder */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000), /* Leadtek Winfast tv 2000xp delux */ BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000), /* Voodoo TV 200 */ diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index ea6712b..48f3f17 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -775,7 +775,6 @@ static int snd_ca0106_pcm_trigger_playba struct snd_ca0106_pcm *epcm; int channel; int result = 0; - struct list_head *pos; struct snd_pcm_substream *s; u32 basic = 0; u32 extended = 0; @@ -790,8 +789,7 @@ static int snd_ca0106_pcm_trigger_playba running=0; break; } - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { runtime = s->runtime; epcm = runtime->private_data; channel = epcm->channel_id; diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 6a428b8..f27b6a7 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -705,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_su struct audiopipe *pipe = runtime->private_data; int i, err; u32 channelmask = 0; - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { for (i = 0; i < DSP_MAXPIPES; i++) { if (s == chip->substream[i]) { channelmask |= 1 << i; @@ -2033,6 +2031,8 @@ static int __devinit snd_echo_probe(stru if (card == NULL) return -ENOMEM; + snd_card_set_dev(card, &pci->dev); + if ((err = snd_echo_create(card, pci, &chip)) < 0) { snd_card_free(card); return err; diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 465f8d5..7ee19c6 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -433,7 +433,6 @@ static int snd_p16v_pcm_trigger_playback struct snd_emu10k1_pcm *epcm; int channel; int result = 0; - struct list_head *pos; struct snd_pcm_substream *s; u32 basic = 0; u32 inte = 0; @@ -448,8 +447,7 @@ static int snd_p16v_pcm_trigger_playback running = 0; break; } - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { runtime = s->runtime; epcm = runtime->private_data; channel = substream->pcm->device-emu->p16v_device_offset; diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 425b167..6a0ddcf 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -798,10 +798,8 @@ static int snd_ensoniq_trigger(struct sn case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: { unsigned int what = 0; - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == ensoniq->playback1_substream) { what |= ES_P1_PAUSE; snd_pcm_trigger_done(s, substream); @@ -824,10 +822,8 @@ static int snd_ensoniq_trigger(struct sn case SNDRV_PCM_TRIGGER_STOP: { unsigned int what = 0; - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == ensoniq->playback1_substream) { what |= ES_DAC1_EN; snd_pcm_trigger_done(s, substream); diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 8f34fb4..4c0a6a5 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -573,7 +573,8 @@ int snd_hda_codec_new(struct hda_bus *bu 0); } - codec->preset = find_codec_preset(codec); + if (strcmp(codec->bus->modelname, "generic")) + codec->preset = find_codec_preset(codec); if (! *bus->card->mixername) snd_hda_get_codec_name(codec, bus->card->mixername, sizeof(bus->card->mixername)); diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 38977bc..00ace59 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -523,6 +523,7 @@ static struct snd_kcontrol_new ad1986a_m HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), @@ -570,6 +571,7 @@ static struct snd_kcontrol_new ad1986a_l HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), @@ -658,6 +660,7 @@ static struct snd_kcontrol_new ad1986a_l HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), { diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 23a1c75..46e93c6 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -629,10 +629,12 @@ static int cxt5045_hp_master_vol_put(str static void cxt5045_hp_automute(struct hda_codec *codec) { struct conexant_spec *spec = codec->spec; - unsigned int bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; + unsigned int bits; spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + + bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); } @@ -979,10 +981,12 @@ static int cxt5047_hp_master_vol_put(str static void cxt5047_hp_automute(struct hda_codec *codec) { struct conexant_spec *spec = codec->spec; - unsigned int bits = spec->hp_present || !spec->cur_eapd ? 0x80 : 0; + unsigned int bits; spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + + bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits); snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits); /* Mute/Unmute PCM 2 for good measure - some systems need this */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 145682b..c5bb545 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4942,9 +4942,16 @@ static int patch_alc882(struct hda_codec alc882_cfg_tbl); if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { - printk(KERN_INFO "hda_codec: Unknown model for ALC882, " - "trying auto-probe from BIOS...\n"); - board_config = ALC882_AUTO; + /* Pick up systems that don't supply PCI SSID */ + switch (codec->subsystem_id) { + case 0x106b0c00: /* Mac Pro */ + board_config = ALC885_MACPRO; + break; + default: + printk(KERN_INFO "hda_codec: Unknown model for ALC882, " + "trying auto-probe from BIOS...\n"); + board_config = ALC882_AUTO; + } } if (board_config == ALC882_AUTO) { @@ -5917,8 +5924,10 @@ static struct snd_kcontrol_new alc262_ba HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), @@ -5937,8 +5946,10 @@ static struct snd_kcontrol_new alc262_hi HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ @@ -5955,8 +5966,10 @@ static struct snd_kcontrol_new alc262_HP HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), @@ -5977,6 +5990,7 @@ static struct snd_kcontrol_new alc262_HP HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), @@ -5989,6 +6003,7 @@ static struct snd_kcontrol_new alc262_HP static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), { } /* end */ }; @@ -7806,6 +7821,7 @@ static struct snd_pci_quirk alc861_cfg_t SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), + SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), {} }; @@ -8319,6 +8335,7 @@ static const char *alc861vd_models[ALC86 }; static struct snd_pci_quirk alc861vd_cfg_tbl[] = { + SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index f7ef9c5..4c7b039 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -59,6 +59,8 @@ enum { STAC_D945GTP3, STAC_D945GTP5, STAC_MACMINI, + STAC_MACBOOK, + STAC_MACBOOK_PRO, STAC_922X_MODELS }; @@ -461,6 +463,8 @@ static struct snd_pci_quirk stac9200_cfg "Dell Inspiron E1705/9400", STAC_REF), SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, "Dell XPS M1710", STAC_REF), + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, + "Dell Precision M90", STAC_REF), {} /* terminator */ }; @@ -519,11 +523,25 @@ static unsigned int d945gtp5_pin_configs 0x02a19320, 0x40000100, }; +static unsigned int macbook_pin_configs[10] = { + 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110, + 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e, + 0x400000fc, 0x400000fb, +}; + +static unsigned int macbook_pro_pin_configs[10] = { + 0x0221401f, 0x90a70120, 0x01813024, 0x01014010, + 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e, + 0x400000fc, 0x400000fb, +}; + static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { [STAC_D945_REF] = ref922x_pin_configs, [STAC_D945GTP3] = d945gtp3_pin_configs, [STAC_D945GTP5] = d945gtp5_pin_configs, [STAC_MACMINI] = d945gtp5_pin_configs, + [STAC_MACBOOK] = macbook_pin_configs, + [STAC_MACBOOK_PRO] = macbook_pro_pin_configs, }; static const char *stac922x_models[STAC_922X_MODELS] = { @@ -531,6 +549,8 @@ static const char *stac922x_models[STAC_ [STAC_D945GTP5] = "5stack", [STAC_D945GTP3] = "3stack", [STAC_MACMINI] = "macmini", + [STAC_MACBOOK] = "macbook", + [STAC_MACBOOK_PRO] = "macbook-pro", }; static struct snd_pci_quirk stac922x_cfg_tbl[] = { @@ -1864,6 +1884,18 @@ static int patch_stac922x(struct hda_cod spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, stac922x_models, stac922x_cfg_tbl); + if (spec->board_config == STAC_MACMINI) { + spec->gpio_mute = 1; + /* Intel Macs have all same PCI SSID, so we need to check + * codec SSID to distinguish the exact models + */ + switch (codec->subsystem_id) { + case 0x106b1e00: + spec->board_config = STAC_MACBOOK_PRO; + break; + } + } + again: if (spec->board_config < 0) { snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " @@ -1904,9 +1936,6 @@ static int patch_stac922x(struct hda_cod return err; } - if (spec->board_config == STAC_MACMINI) - spec->gpio_mute = 1; - codec->patch_ops = stac92xx_patch_ops; return 0; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 830a1bb..e880469 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -977,11 +977,9 @@ static int snd_ice1712_pro_trigger(struc { unsigned int what = 0; unsigned int old; - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == ice->playback_pro_substream) { what |= ICE1712_PLAYBACK_START; snd_pcm_trigger_done(s, substream); diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 1127ebd..3f2aca2 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -337,13 +337,11 @@ static int snd_vt1724_pcm_trigger(struct struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); unsigned char what; unsigned char old; - struct list_head *pos; struct snd_pcm_substream *s; what = 0; - snd_pcm_group_for_each(pos, substream) { + snd_pcm_group_for_each_entry(s, substream) { const struct vt1724_pcm_reg *reg; - s = snd_pcm_group_substream_entry(pos); reg = s->runtime->private_data; what |= reg->start; snd_pcm_trigger_done(s, substream); diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 21d0899..e2e59ca 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -264,9 +264,7 @@ #define STOPCARD_DELAY 300 / #define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement // from the card after sending a command. -#define FIRMWARE_IN_THE_KERNEL - -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL #include "korg1212-firmware.h" static const struct firmware static_dsp_code = { .data = (u8 *)dspCode, @@ -2345,7 +2343,7 @@ #endif // K1212_LARGEALLOC err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); if (err < 0) { release_firmware(dsp_code); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL dsp_code = &static_dsp_code; #else snd_printk(KERN_ERR "firmware not available\n"); @@ -2358,7 +2356,7 @@ #endif dsp_code->size, &korg1212->dma_dsp) < 0) { snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); snd_korg1212_free(korg1212); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL if (dsp_code != &static_dsp_code) #endif release_firmware(dsp_code); @@ -2371,7 +2369,7 @@ #endif memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL if (dsp_code != &static_dsp_code) #endif release_firmware(dsp_code); diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 4526904..9badbb3 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2101,9 +2101,7 @@ static int __devinit snd_m3_mixer(struct } -#define FIRMWARE_IN_THE_KERNEL - -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL /* * DSP Code images @@ -2242,7 +2240,7 @@ static const struct firmware assp_minisr .size = sizeof assp_minisrc_image }; -#endif /* FIRMWARE_IN_THE_KERNEL */ +#endif /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */ #ifdef __LITTLE_ENDIAN static inline void snd_m3_convert_from_le(const struct firmware *fw) { } @@ -2550,11 +2548,11 @@ #endif if (chip->iobase) pci_release_regions(chip->pci); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL if (chip->assp_kernel_image != &assp_kernel) #endif release_firmware(chip->assp_kernel_image); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL if (chip->assp_minisrc_image != &assp_minisrc) #endif release_firmware(chip->assp_minisrc_image); @@ -2750,7 +2748,7 @@ snd_m3_create(struct snd_card *card, str err = request_firmware(&chip->assp_kernel_image, "ess/maestro3_assp_kernel.fw", &pci->dev); if (err < 0) { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL chip->assp_kernel_image = &assp_kernel; #else snd_m3_free(chip); @@ -2762,7 +2760,7 @@ #endif err = request_firmware(&chip->assp_minisrc_image, "ess/maestro3_assp_minisrc.fw", &pci->dev); if (err < 0) { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL chip->assp_minisrc_image = &assp_minisrc; #else snd_m3_free(chip); diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index d974134..e1bdeed 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -638,7 +638,6 @@ #endif static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) { struct pcxhr_stream *stream; - struct list_head *pos; struct snd_pcm_substream *s; int i; @@ -646,8 +645,7 @@ static int pcxhr_trigger(struct snd_pcm_ case SNDRV_PCM_TRIGGER_START: snd_printdd("SNDRV_PCM_TRIGGER_START\n"); i = 0; - snd_pcm_group_for_each(pos, subs) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, subs) { stream = s->runtime->private_data; stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; snd_pcm_trigger_done(s, subs); @@ -672,8 +670,7 @@ static int pcxhr_trigger(struct snd_pcm_ break; case SNDRV_PCM_TRIGGER_STOP: snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); - snd_pcm_group_for_each(pos, subs) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, subs) { stream = s->runtime->private_data; stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; if (pcxhr_set_stream_state(stream)) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 5e1d5d2..952625d 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1919,6 +1919,8 @@ snd_riptide_create(struct snd_card *card return err; } + snd_card_set_dev(card, &pci->dev); + *rchip = chip; return 0; } diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 6bb7ac6..618653e 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1078,12 +1078,10 @@ static int snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct rme32 *rme32 = snd_pcm_substream_chip(substream); - struct list_head *pos; struct snd_pcm_substream *s; spin_lock(&rme32->lock); - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s != rme32->playback_substream && s != rme32->capture_substream) continue; @@ -1110,8 +1108,7 @@ snd_rme32_pcm_trigger(struct snd_pcm_sub /* prefill playback buffer */ if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) { - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == rme32->playback_substream) { s->ops->ack(s); break; diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 89b3c7f..6540037 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -3780,11 +3780,9 @@ static int snd_hdsp_reset(struct snd_pcm else runtime->status->hw_ptr = 0; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; struct snd_pcm_runtime *oruntime = other->runtime; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { oruntime->status->hw_ptr = runtime->status->hw_ptr; break; @@ -3933,10 +3931,8 @@ static int snd_hdsp_trigger(struct snd_p other = hdsp->playback_substream; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { snd_pcm_trigger_done(s, substream); if (cmd == SNDRV_PCM_TRIGGER_START) diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index e0215ac..d2ae638 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -3575,11 +3575,9 @@ static int snd_hdspm_reset(struct snd_pc else runtime->status->hw_ptr = 0; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; struct snd_pcm_runtime *oruntime = other->runtime; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { oruntime->status->hw_ptr = runtime->status->hw_ptr; @@ -3791,10 +3789,8 @@ static int snd_hdspm_trigger(struct snd_ other = hdspm->playback_substream; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { snd_pcm_trigger_done(s, substream); if (cmd == SNDRV_PCM_TRIGGER_START) @@ -4468,6 +4464,8 @@ static int __devinit snd_hdspm_probe(str hdspm->dev = dev; hdspm->pci = pci; + snd_card_set_dev(card, &pci->dev); + if ((err = snd_hdspm_create(card, hdspm, precise_ptr[dev], enable_monitor[dev])) < 0) { diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index cc3bdec..bd7dbd2 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -1992,11 +1992,9 @@ static int snd_rme9652_reset(struct snd_ else runtime->status->hw_ptr = 0; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; struct snd_pcm_runtime *oruntime = other->runtime; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { oruntime->status->hw_ptr = runtime->status->hw_ptr; break; @@ -2140,10 +2138,8 @@ static int snd_rme9652_trigger(struct sn other = rme9652->playback_substream; if (other) { - struct list_head *pos; struct snd_pcm_substream *s; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if (s == other) { snd_pcm_trigger_done(s, substream); if (cmd == SNDRV_PCM_TRIGGER_START) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 3bff321..7ca6062 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -1540,7 +1540,6 @@ static int snd_trident_trigger(struct sn { struct snd_trident *trident = snd_pcm_substream_chip(substream); - struct list_head *pos; struct snd_pcm_substream *s; unsigned int what, whati, capture_flag, spdif_flag; struct snd_trident_voice *voice, *evoice; @@ -1563,8 +1562,7 @@ static int snd_trident_trigger(struct sn what = whati = capture_flag = spdif_flag = 0; spin_lock(&trident->reg_lock); val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; - snd_pcm_group_for_each(pos, substream) { - s = snd_pcm_group_substream_entry(pos); + snd_pcm_group_for_each_entry(s, substream) { if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { voice = s->runtime->private_data; evoice = voice->extra; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index fd12674..b34c3bc 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1998,9 +1998,7 @@ static void snd_ymfpci_disable_dsp(struc } } -#define FIRMWARE_IN_THE_KERNEL - -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL #include "ymfpci_image.h" @@ -2047,7 +2045,7 @@ static int snd_ymfpci_request_firmware(s } } if (err < 0) { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL chip->dsp_microcode = &snd_ymfpci_dsp_microcode; #else return err; @@ -2070,7 +2068,7 @@ #endif } } if (err < 0) { -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL chip->controller_microcode = is_1e ? &snd_ymfpci_controller_1e_microcode : &snd_ymfpci_controller_microcode; @@ -2259,11 +2257,11 @@ #endif pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); pci_disable_device(chip->pci); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode) #endif release_firmware(chip->dsp_microcode); -#ifdef FIRMWARE_IN_THE_KERNEL +#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL if (chip->controller_microcode != &snd_ymfpci_controller_microcode && chip->controller_microcode != &snd_ymfpci_controller_1e_microcode) #endif diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index ec821a5..74a5f5f 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -24,6 +24,7 @@ menu "SoC Platforms" depends on SND_SOC source "sound/soc/at91/Kconfig" source "sound/soc/pxa/Kconfig" +source "sound/soc/s3c24xx/Kconfig" endmenu # Supported codecs diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 98e6f49..0ae2e49 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,4 +1,4 @@ snd-soc-core-objs := soc-core.o soc-dapm.o obj-$(CONFIG_SND_SOC) += snd-soc-core.o -obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ +obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 92a6487..ee7a691 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -39,7 +39,7 @@ static int ac97_write(struct snd_soc_cod */ static const u16 wm9712_reg[] = { 0x6174, 0x8000, 0x8000, 0x8000, // 6 - 0xf0f0, 0xaaa0, 0xc008, 0x6808, // e + 0x0f0f, 0xaaa0, 0xc008, 0x6808, // e 0xe808, 0xaaa0, 0xad00, 0x8000, // 16 0xe808, 0x3000, 0x8000, 0x0000, // 1e 0x0000, 0x0000, 0x0000, 0x000f, // 26 @@ -96,6 +96,7 @@ SOC_DOUBLE("Speaker Playback Volume", AC SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1), SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE,15, 1, 1), +SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1), SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0), SOC_SINGLE("Speaker Playback Invert Switch", AC97_MASTER, 6, 1, 0), diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig new file mode 100644 index 0000000..433da9f --- /dev/null +++ b/sound/soc/s3c24xx/Kconfig @@ -0,0 +1,16 @@ +menu "SoC Audio for the Samsung S3C24XX" + +config SND_S3C24XX_SOC + tristate "SoC Audio for the Samsung S3C24XX chips" + depends on ARCH_S3C2410 && SND + select SND_PCM + help + Say Y or M if you want to add support for codecs attached to + the S3C24XX AC97, I2S or SSP interface. You will also need + to select the audio interfaces to support below. + +config SND_S3C24XX_SOC_I2S + tristate + +endmenu + diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile new file mode 100644 index 0000000..6f0fffc --- /dev/null +++ b/sound/soc/s3c24xx/Makefile @@ -0,0 +1,6 @@ +# S3c24XX Platform Support +snd-soc-s3c24xx-objs := s3c24xx-pcm.o +snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o + +obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o +obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c new file mode 100644 index 0000000..df655a5 --- /dev/null +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -0,0 +1,439 @@ +/* + * s3c24xx-i2s.c -- ALSA Soc Audio Layer + * + * (c) 2006 Wolfson Microelectronics PLC. + * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com + * + * (c) 2004-2005 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * + * Revision history + * 11th Dec 2006 Merged with Simtec driver + * 10th Nov 2006 Initial version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "s3c24xx-pcm.h" +#include "s3c24xx-i2s.h" + +#define S3C24XX_I2S_DEBUG 0 +#if S3C24XX_I2S_DEBUG +#define DBG(x...) printk(KERN_DEBUG x) +#else +#define DBG(x...) +#endif + +static struct s3c2410_dma_client s3c24xx_dma_client_out = { + .name = "I2S PCM Stereo out" +}; + +static struct s3c2410_dma_client s3c24xx_dma_client_in = { + .name = "I2S PCM Stereo in" +}; + +static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_out = { + .client = &s3c24xx_dma_client_out, + .channel = DMACH_I2S_OUT, + .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO +}; + +static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_in = { + .client = &s3c24xx_dma_client_in, + .channel = DMACH_I2S_IN, + .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO +}; + +struct s3c24xx_i2s_info { + void __iomem *regs; + struct clk *iis_clk; +}; +static struct s3c24xx_i2s_info s3c24xx_i2s; + +static void s3c24xx_snd_txctrl(int on) +{ + u32 iisfcon; + u32 iiscon; + u32 iismod; + + DBG("Entered %s\n", __FUNCTION__); + + iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); + iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); + iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); + + DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + + if (on) { + iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE; + iiscon |= S3C2410_IISCON_TXDMAEN | S3C2410_IISCON_IISEN; + iiscon &= ~S3C2410_IISCON_TXIDLE; + iismod |= S3C2410_IISMOD_TXMODE; + + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); + writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); + } else { + /* note, we have to disable the FIFOs otherwise bad things + * seem to happen when the DMA stops. According to the + * Samsung supplied kernel, this should allow the DMA + * engine and FIFOs to reset. If this isn't allowed, the + * DMA engine will simply freeze randomly. + */ + + iisfcon &= ~S3C2410_IISFCON_TXENABLE; + iisfcon &= ~S3C2410_IISFCON_TXDMA; + iiscon |= S3C2410_IISCON_TXIDLE; + iiscon &= ~S3C2410_IISCON_TXDMAEN; + iismod &= ~S3C2410_IISMOD_TXMODE; + + writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); + writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + } + + DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); +} + +static void s3c24xx_snd_rxctrl(int on) +{ + u32 iisfcon; + u32 iiscon; + u32 iismod; + + DBG("Entered %s\n", __FUNCTION__); + + iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); + iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); + iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); + + DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + + if (on) { + iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE; + iiscon |= S3C2410_IISCON_RXDMAEN | S3C2410_IISCON_IISEN; + iiscon &= ~S3C2410_IISCON_RXIDLE; + iismod |= S3C2410_IISMOD_RXMODE; + + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); + writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); + } else { + /* note, we have to disable the FIFOs otherwise bad things + * seem to happen when the DMA stops. According to the + * Samsung supplied kernel, this should allow the DMA + * engine and FIFOs to reset. If this isn't allowed, the + * DMA engine will simply freeze randomly. + */ + + iisfcon &= ~S3C2410_IISFCON_RXENABLE; + iisfcon &= ~S3C2410_IISFCON_RXDMA; + iiscon |= S3C2410_IISCON_RXIDLE; + iiscon &= ~S3C2410_IISCON_RXDMAEN; + iismod &= ~S3C2410_IISMOD_RXMODE; + + writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON); + writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + } + + DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); +} + +/* + * Wait for the LR signal to allow synchronisation to the L/R clock + * from the codec. May only be needed for slave mode. + */ +static int s3c24xx_snd_lrsync(void) +{ + u32 iiscon; + unsigned long timeout = jiffies + msecs_to_jiffies(5); + + DBG("Entered %s\n", __FUNCTION__); + + while (1) { + iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); + if (iiscon & S3C2410_IISCON_LRINDEX) + break; + + if (timeout < jiffies) + return -ETIMEDOUT; + } + + return 0; +} + +/* + * Check whether CPU is the master or slave + */ +static inline int s3c24xx_snd_is_clkmaster(void) +{ + DBG("Entered %s\n", __FUNCTION__); + + return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1; +} + +/* + * Set S3C24xx I2S DAI format + */ +static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai, + unsigned int fmt) +{ + u32 iismod; + + DBG("Entered %s\n", __FUNCTION__); + + iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); + DBG("hw_params r: IISMOD: %lx \n", iismod); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + iismod |= S3C2410_IISMOD_SLAVE; + break; + case SND_SOC_DAIFMT_CBS_CFS: + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_LEFT_J: + iismod |= S3C2410_IISMOD_MSB; + break; + case SND_SOC_DAIFMT_I2S: + break; + default: + return -EINVAL; + } + + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + DBG("hw_params w: IISMOD: %lx \n", iismod); + return 0; +} + +static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + u32 iismod; + + DBG("Entered %s\n", __FUNCTION__); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; + else + rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in; + + /* Working copies of register */ + iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); + DBG("hw_params r: IISMOD: %lx\n", iismod); + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S8: + break; + case SNDRV_PCM_FORMAT_S16_LE: + iismod |= S3C2410_IISMOD_16BIT; + break; + } + + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + DBG("hw_params w: IISMOD: %lx\n", iismod); + return 0; +} + +static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd) +{ + int ret = 0; + + DBG("Entered %s\n", __FUNCTION__); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + if (!s3c24xx_snd_is_clkmaster()) { + ret = s3c24xx_snd_lrsync(); + if (ret) + goto exit_err; + } + + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + s3c24xx_snd_rxctrl(1); + else + s3c24xx_snd_txctrl(1); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + s3c24xx_snd_rxctrl(0); + else + s3c24xx_snd_txctrl(0); + break; + default: + ret = -EINVAL; + break; + } + +exit_err: + return ret; +} + +/* + * Set S3C24xx Clock source + */ +static int s3c24xx_i2s_set_sysclk(struct snd_soc_cpu_dai *cpu_dai, + int clk_id, unsigned int freq, int dir) +{ + u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); + + DBG("Entered %s\n", __FUNCTION__); + + iismod &= ~S3C2440_IISMOD_MPLL; + + switch (clk_id) { + case S3C24XX_CLKSRC_PCLK: + break; + case S3C24XX_CLKSRC_MPLL: + iismod |= S3C2440_IISMOD_MPLL; + break; + default: + return -EINVAL; + } + + writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); + return 0; +} + +/* + * Set S3C24xx Clock dividers + */ +static int s3c24xx_i2s_set_clkdiv(struct snd_soc_cpu_dai *cpu_dai, + int div_id, int div) +{ + u32 reg; + + DBG("Entered %s\n", __FUNCTION__); + + switch (div_id) { + case S3C24XX_DIV_MCLK: + reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~S3C2410_IISMOD_FS_MASK; + writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD); + break; + case S3C24XX_DIV_BCLK: + reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~(S3C2410_IISMOD_384FS); + writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD); + break; + case S3C24XX_DIV_PRESCALER: + writel(div, s3c24xx_i2s.regs + S3C2410_IISPSR); + reg = readl(s3c24xx_i2s.regs + S3C2410_IISCON); + writel(reg | S3C2410_IISCON_PSCEN, s3c24xx_i2s.regs + S3C2410_IISCON); + break; + default: + return -EINVAL; + } + + return 0; +} + +/* + * To avoid duplicating clock code, allow machine driver to + * get the clockrate from here. + */ +u32 s3c24xx_i2s_get_clockrate(void) +{ + return clk_get_rate(s3c24xx_i2s.iis_clk); +} +EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate); + +static int s3c24xx_i2s_probe(struct platform_device *pdev) +{ + DBG("Entered %s\n", __FUNCTION__); + + s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); + if (s3c24xx_i2s.regs == NULL) + return -ENXIO; + + s3c24xx_i2s.iis_clk=clk_get(&pdev->dev, "iis"); + if (s3c24xx_i2s.iis_clk == NULL) { + DBG("failed to get iis_clock\n"); + return -ENODEV; + } + clk_enable(s3c24xx_i2s.iis_clk); + + /* Configure the I2S pins in correct mode */ + s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK); + s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK); + s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK); + s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI); + s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO); + + writel(S3C2410_IISCON_IISEN, s3c24xx_i2s.regs + S3C2410_IISCON); + + s3c24xx_snd_txctrl(0); + s3c24xx_snd_rxctrl(0); + + return 0; +} + +#define S3C24XX_I2S_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + +struct snd_soc_cpu_dai s3c24xx_i2s_dai = { + .name = "s3c24xx-i2s", + .id = 0, + .type = SND_SOC_DAI_I2S, + .probe = s3c24xx_i2s_probe, + .playback = { + .channels_min = 2, + .channels_max = 2, + .rates = S3C24XX_I2S_RATES, + .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, + .capture = { + .channels_min = 2, + .channels_max = 2, + .rates = S3C24XX_I2S_RATES, + .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, + .ops = { + .trigger = s3c24xx_i2s_trigger, + .hw_params = s3c24xx_i2s_hw_params,}, + .dai_ops = { + .set_fmt = s3c24xx_i2s_set_fmt, + .set_clkdiv = s3c24xx_i2s_set_clkdiv, + .set_sysclk = s3c24xx_i2s_set_sysclk, + }, +}; +EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai); + +/* Module information */ +MODULE_AUTHOR("Ben Dooks, "); +MODULE_DESCRIPTION("s3c24xx I2S SoC Interface"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.h b/sound/soc/s3c24xx/s3c24xx-i2s.h new file mode 100644 index 0000000..f9ca04e --- /dev/null +++ b/sound/soc/s3c24xx/s3c24xx-i2s.h @@ -0,0 +1,35 @@ +/* + * s3c24xx-i2s.c -- ALSA Soc Audio Layer + * + * Copyright 2005 Wolfson Microelectronics PLC. + * Author: Graeme Gregory + * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 10th Nov 2006 Initial version. + */ + +#ifndef S3C24XXI2S_H_ +#define S3C24XXI2S_H_ + +/* clock sources */ +#define S3C24XX_CLKSRC_PCLK 0 +#define S3C24XX_CLKSRC_MPLL 1 + +/* Clock dividers */ +#define S3C24XX_DIV_MCLK 0 +#define S3C24XX_DIV_BCLK 1 +#define S3C24XX_DIV_PRESCALER 2 + +/* prescaler */ +#define S3C24XX_PRESCALE(a,b) \ + (((a - 1) << S3C2410_IISPSR_INTSHIFT) | ((b - 1) << S3C2410_IISPSR_EXTSHFIT)) + +u32 s3c24xx_i2s_get_clockrate(void); + +#endif /*S3C24XXI2S_H_*/ diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c new file mode 100644 index 0000000..f1c0b9f --- /dev/null +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c @@ -0,0 +1,462 @@ +/* + * s3c24xx-pcm.c -- ALSA Soc Audio Layer + * + * (c) 2006 Wolfson Microelectronics PLC. + * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com + * + * (c) 2004-2005 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Revision history + * 11th Dec 2006 Merged with Simtec driver + * 10th Nov 2006 Initial version. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "s3c24xx-pcm.h" + +#define S3C24XX_PCM_DEBUG 0 +#if S3C24XX_PCM_DEBUG +#define DBG(x...) printk(KERN_DEBUG x) +#else +#define DBG(x...) +#endif + +static const struct snd_pcm_hardware s3c24xx_pcm_hardware = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_U16_LE | + SNDRV_PCM_FMTBIT_U8 | + SNDRV_PCM_FMTBIT_S8, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 128*1024, + .period_bytes_min = PAGE_SIZE, + .period_bytes_max = PAGE_SIZE*2, + .periods_min = 2, + .periods_max = 128, + .fifo_size = 32, +}; + +struct s3c24xx_runtime_data { + spinlock_t lock; + int state; + unsigned int dma_loaded; + unsigned int dma_limit; + unsigned int dma_period; + dma_addr_t dma_start; + dma_addr_t dma_pos; + dma_addr_t dma_end; + struct s3c24xx_pcm_dma_params *params; +}; + +/* s3c24xx_pcm_enqueue + * + * place a dma buffer onto the queue for the dma system + * to handle. +*/ +static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream) +{ + struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; + dma_addr_t pos = prtd->dma_pos; + int ret; + + DBG("Entered %s\n", __FUNCTION__); + + while ( prtd->dma_loaded < prtd->dma_limit) { + unsigned long len = prtd->dma_period; + + DBG("dma_loaded: %d\n",prtd->dma_loaded); + + if ((pos + len) > prtd->dma_end) { + len = prtd->dma_end - pos; + DBG(KERN_DEBUG "%s: corrected dma len %ld\n", + __FUNCTION__, len); + } + + ret = s3c2410_dma_enqueue(prtd->params->channel, substream, pos, len); + + if (ret == 0) { + prtd->dma_loaded++; + pos += prtd->dma_period; + if (pos >= prtd->dma_end) + pos = prtd->dma_start; + } else + break; + } + + prtd->dma_pos = pos; +} + +static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel, + void *dev_id, int size, + enum s3c2410_dma_buffresult result) +{ + struct snd_pcm_substream *substream = dev_id; + struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; + + DBG("Entered %s\n", __FUNCTION__); + + if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR) + return; + + if (substream) + snd_pcm_period_elapsed(substream); + + spin_lock(&prtd->lock); + if (prtd->state & ST_RUNNING) { + prtd->dma_loaded--; + s3c24xx_pcm_enqueue(substream); + } + + spin_unlock(&prtd->lock); +} + +static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct s3c24xx_runtime_data *prtd = runtime->private_data; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct s3c24xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data; + unsigned long totbytes = params_buffer_bytes(params); + int ret=0; + + DBG("Entered %s\n", __FUNCTION__); + + /* return if this is a bufferless transfer e.g. + * codec <--> BT codec or GSM modem -- lg FIXME */ + if (!dma) + return 0; + + /* prepare DMA */ + prtd->params = dma; + + DBG("params %p, client %p, channel %d\n", prtd->params, + prtd->params->client, prtd->params->channel); + + ret = s3c2410_dma_request(prtd->params->channel, + prtd->params->client, NULL); + + if (ret) { + DBG(KERN_ERR "failed to get dma channel\n"); + return ret; + } + + /* channel needs configuring for mem=>device, increment memory addr, + * sync to pclk, half-word transfers to the IIS-FIFO. */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + s3c2410_dma_devconfig(prtd->params->channel, + S3C2410_DMASRC_MEM, S3C2410_DISRCC_INC | + S3C2410_DISRCC_APB, prtd->params->dma_addr); + + s3c2410_dma_config(prtd->params->channel, + 2, S3C2410_DCON_SYNC_PCLK | S3C2410_DCON_HANDSHAKE); + } else { + s3c2410_dma_config(prtd->params->channel, + 2, S3C2410_DCON_HANDSHAKE | S3C2410_DCON_SYNC_PCLK); + + s3c2410_dma_devconfig(prtd->params->channel, + S3C2410_DMASRC_HW, 0x3, + prtd->params->dma_addr); + } + + s3c2410_dma_set_buffdone_fn(prtd->params->channel, + s3c24xx_audio_buffdone); + + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + + runtime->dma_bytes = totbytes; + + spin_lock_irq(&prtd->lock); + prtd->dma_loaded = 0; + prtd->dma_limit = runtime->hw.periods_min; + prtd->dma_period = params_period_bytes(params); + prtd->dma_start = runtime->dma_addr; + prtd->dma_pos = prtd->dma_start; + prtd->dma_end = prtd->dma_start + totbytes; + spin_unlock_irq(&prtd->lock); + + return 0; +} + +static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream) +{ + struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; + + DBG("Entered %s\n", __FUNCTION__); + + /* TODO - do we need to ensure DMA flushed */ + snd_pcm_set_runtime_buffer(substream, NULL); + + if(prtd->params) { + s3c2410_dma_free(prtd->params->channel, prtd->params->client); + prtd->params = NULL; + } + + return 0; +} + +static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; + int ret = 0; + + DBG("Entered %s\n", __FUNCTION__); + + /* return if this is a bufferless transfer e.g. + * codec <--> BT codec or GSM modem -- lg FIXME */ + if (!prtd->params) + return 0; + + /* flush the DMA channel */ + s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_FLUSH); + prtd->dma_loaded = 0; + prtd->dma_pos = prtd->dma_start; + + /* enqueue dma buffers */ + s3c24xx_pcm_enqueue(substream); + + return ret; +} + +static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; + int ret = 0; + + DBG("Entered %s\n", __FUNCTION__); + + spin_lock(&prtd->lock); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + prtd->state |= ST_RUNNING; + s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_START); + s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STARTED); + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + prtd->state &= ~ST_RUNNING; + s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STOP); + break; + + default: + ret = -EINVAL; + break; + } + + spin_unlock(&prtd->lock); + + return ret; +} + +static snd_pcm_uframes_t s3c24xx_pcm_pointer(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct s3c24xx_runtime_data *prtd = runtime->private_data; + unsigned long res; + dma_addr_t src, dst; + + DBG("Entered %s\n", __FUNCTION__); + + spin_lock(&prtd->lock); + s3c2410_dma_getposition(prtd->params->channel, &src, &dst); + + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + res = dst - prtd->dma_start; + else + res = src - prtd->dma_start; + + spin_unlock(&prtd->lock); + + DBG("Pointer %x %x\n",src,dst); + + /* we seem to be getting the odd error from the pcm library due + * to out-of-bounds pointers. this is maybe due to the dma engine + * not having loaded the new values for the channel before being + * callled... (todo - fix ) + */ + + if (res >= snd_pcm_lib_buffer_bytes(substream)) { + if (res == snd_pcm_lib_buffer_bytes(substream)) + res = 0; + } + + return bytes_to_frames(substream->runtime, res); +} + +static int s3c24xx_pcm_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct s3c24xx_runtime_data *prtd; + + int ret; + + DBG("Entered %s\n", __FUNCTION__); + + snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware); + + prtd = kzalloc(sizeof(struct s3c24xx_runtime_data), GFP_KERNEL); + if (prtd == NULL) + return -ENOMEM; + + runtime->private_data = prtd; + return 0; +} + +static int s3c24xx_pcm_close(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct s3c24xx_runtime_data *prtd = runtime->private_data; + + DBG("Entered %s\n", __FUNCTION__); + + if(prtd) + kfree(prtd); + else + DBG("s3c24xx_pcm_close called with prtd == NULL\n"); + + return 0; +} + +static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + DBG("Entered %s\n", __FUNCTION__); + + return dma_mmap_writecombine(substream->pcm->card->dev, vma, + runtime->dma_area, + runtime->dma_addr, + runtime->dma_bytes); +} + +static struct snd_pcm_ops s3c24xx_pcm_ops = { + .open = s3c24xx_pcm_open, + .close = s3c24xx_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = s3c24xx_pcm_hw_params, + .hw_free = s3c24xx_pcm_hw_free, + .prepare = s3c24xx_pcm_prepare, + .trigger = s3c24xx_pcm_trigger, + .pointer = s3c24xx_pcm_pointer, + .mmap = s3c24xx_pcm_mmap, +}; + +static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) +{ + struct snd_pcm_substream *substream = pcm->streams[stream].substream; + struct snd_dma_buffer *buf = &substream->dma_buffer; + size_t size = s3c24xx_pcm_hardware.buffer_bytes_max; + + DBG("Entered %s\n", __FUNCTION__); + + buf->dev.type = SNDRV_DMA_TYPE_DEV; + buf->dev.dev = pcm->card->dev; + buf->private_data = NULL; + buf->area = dma_alloc_writecombine(pcm->card->dev, size, + &buf->addr, GFP_KERNEL); + if (!buf->area) + return -ENOMEM; + buf->bytes = size; + return 0; +} + +static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm) +{ + struct snd_pcm_substream *substream; + struct snd_dma_buffer *buf; + int stream; + + DBG("Entered %s\n", __FUNCTION__); + + for (stream = 0; stream < 2; stream++) { + substream = pcm->streams[stream].substream; + if (!substream) + continue; + + buf = &substream->dma_buffer; + if (!buf->area) + continue; + + dma_free_writecombine(pcm->card->dev, buf->bytes, + buf->area, buf->addr); + buf->area = NULL; + } +} + +static u64 s3c24xx_pcm_dmamask = DMA_32BIT_MASK; + +static int s3c24xx_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai, + struct snd_pcm *pcm) +{ + int ret = 0; + + DBG("Entered %s\n", __FUNCTION__); + + if (!card->dev->dma_mask) + card->dev->dma_mask = &s3c24xx_pcm_dmamask; + if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask = 0xffffffff; + + if (dai->playback.channels_min) { + ret = s3c24xx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + goto out; + } + + if (dai->capture.channels_min) { + ret = s3c24xx_pcm_preallocate_dma_buffer(pcm, + SNDRV_PCM_STREAM_CAPTURE); + if (ret) + goto out; + } + out: + return ret; +} + +struct snd_soc_platform s3c24xx_soc_platform = { + .name = "s3c24xx-audio", + .pcm_ops = &s3c24xx_pcm_ops, + .pcm_new = s3c24xx_pcm_new, + .pcm_free = s3c24xx_pcm_free_dma_buffers, +}; + +EXPORT_SYMBOL_GPL(s3c24xx_soc_platform); + +MODULE_AUTHOR("Ben Dooks, "); +MODULE_DESCRIPTION("Samsung S3C24XX PCM DMA module"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.h b/sound/soc/s3c24xx/s3c24xx-pcm.h new file mode 100644 index 0000000..5dced4a --- /dev/null +++ b/sound/soc/s3c24xx/s3c24xx-pcm.h @@ -0,0 +1,32 @@ +/* + * s3c24xx-pcm.h -- + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * ALSA PCM interface for the Samsung S3C24xx CPU + */ + +#ifndef _S3C24XX_PCM_H +#define _S3C24XX_PCM_H + +#define ST_RUNNING (1<<0) +#define ST_OPENED (1<<1) + +struct s3c24xx_pcm_dma_params { + struct s3c2410_dma_client *client; /* stream identifier */ + int channel; /* Channel ID */ + dma_addr_t dma_addr; +}; + +#define S3C24XX_DAI_I2S 0 + +extern struct snd_soc_cpu_dai s3c24xx_i2s_dai; + +/* platform data */ +extern struct snd_soc_platform s3c24xx_soc_platform; +extern struct snd_ac97_bus_ops s3c24xx_ac97_ops; + +#endif diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index f5956d5..6a6f23a 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -661,10 +661,9 @@ static int snd_cs4231_trigger(struct snd { unsigned int what = 0; struct snd_pcm_substream *s; - struct list_head *pos; unsigned long flags; - snd_pcm_group_for_each(pos, substream) { + snd_pcm_group_for_each_entry(s, substream) { s = snd_pcm_group_substream_entry(pos); if (s == chip->playback_substream) { what |= CS4231_PLAYBACK_ENABLE;