diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2006-01-07 14:40:05 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-01-07 14:40:05 +0000 |
commit | 123656d4cc8c946f578ebd18c2050f5251720428 (patch) | |
tree | 3d5432eff034a3b9cfdc98b37e245abe5695342d /sound/isa | |
parent | a62c80e559809e6c7851ec04d30575e85ad6f6ed (diff) | |
parent | 0aec63e67c69545ca757a73a66f5dcf05fa484bf (diff) | |
download | blackbird-op-linux-123656d4cc8c946f578ebd18c2050f5251720428.tar.gz blackbird-op-linux-123656d4cc8c946f578ebd18c2050f5251720428.zip |
Merge with Linus' kernel.
Diffstat (limited to 'sound/isa')
61 files changed, 4892 insertions, 3903 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 5d6c300ac0d5..ff8fef932786 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -6,12 +6,10 @@ menu "ISA devices" config SND_AD1848_LIB tristate select SND_PCM - select SND_GENERIC_DRIVER config SND_CS4231_LIB tristate select SND_PCM - select SND_GENERIC_DRIVER config SND_AD1816A tristate "Analog Devices SoundPort AD1816A" @@ -41,6 +39,45 @@ config SND_AD1848 To compile this driver as a module, choose M here: the module will be called snd-ad1848. +config SND_ALS100 + tristate "Avance Logic ALS100/ALS120" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + Say Y here to include support for soundcards based on Avance + Logic ALS100, ALS110, ALS120 and ALS200 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-als100. + +config SND_AZT2320 + tristate "Aztech Systems AZT2320" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for soundcards based on the + Aztech Systems AZT2320 chip. + + To compile this driver as a module, choose M here: the module + will be called snd-azt2320. + +config SND_CMI8330 + tristate "C-Media CMI8330" + depends on SND + select SND_AD1848_LIB + help + Say Y here to include support for soundcards based on the + C-Media CMI8330 chip. + + To compile this driver as a module, choose M here: the module + will be called snd-cmi8330. + config SND_CS4231 tristate "Generic Cirrus Logic CS4231 driver" depends on SND @@ -79,6 +116,20 @@ config SND_CS4236 To compile this driver as a module, choose M here: the module will be called snd-cs4236. +config SND_DT019X + tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + Say Y here to include support for soundcards based on the + Diamond Technologies DT-019X or Avance Logic ALS-007 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-dt019x. + config SND_ES968 tristate "Generic ESS ES968 driver" depends on SND && PNP && ISA @@ -97,7 +148,6 @@ config SND_ES1688 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES688 or ES1688 chips. @@ -111,7 +161,6 @@ config SND_ES18XX select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES18xx chips. @@ -127,7 +176,6 @@ config SND_GUSCLASSIC select SND_RAWMIDI select SND_PCM select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Classic soundcards. @@ -142,7 +190,6 @@ config SND_GUSEXTREME select SND_MPU401_UART select SND_PCM select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Extreme soundcards. @@ -156,7 +203,6 @@ config SND_GUSMAX select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound MAX soundcards. @@ -170,7 +216,6 @@ config SND_INTERWAVE select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, @@ -185,7 +230,6 @@ config SND_INTERWAVE_STB select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards with a TEA6330T bass and treble regulator @@ -194,6 +238,19 @@ config SND_INTERWAVE_STB To compile this driver as a module, choose M here: the module will be called snd-interwave-stb. +config SND_OPL3SA2 + tristate "Yamaha OPL3-SA2/SA3" + depends on SND + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3 + chips. + + To compile this driver as a module, choose M here: the module + will be called snd-opl3sa2. + config SND_OPTI92X_AD1848 tristate "OPTi 82C92x - AD1848" depends on SND @@ -228,7 +285,6 @@ config SND_OPTI93X select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for soundcards based on Opti 82C93x chips. @@ -242,7 +298,6 @@ config SND_SB8 select SND_OPL3_LIB select SND_RAWMIDI select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Creative Sound Blaster 1.0/ 2.0/Pro (8-bit) or 100% compatible soundcards. @@ -256,7 +311,6 @@ config SND_SB16 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster 16 soundcards (including the Plug and Play version). @@ -270,7 +324,6 @@ config SND_SBAWE select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster AWE soundcards (including the Plug and Play version). @@ -286,85 +339,6 @@ config SND_SB16_CSP coprocessor can do variable tasks like various compression and decompression algorithms. -config SND_WAVEFRONT - tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for Turtle Beach Maui, Tropez - and Tropez+ soundcards based on the Wavefront chip. - - To compile this driver as a module, choose M here: the module - will be called snd-wavefront. - -config SND_ALS100 - tristate "Avance Logic ALS100/ALS120" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - Say Y here to include support for soundcards based on Avance - Logic ALS100, ALS110, ALS120 and ALS200 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-als100. - -config SND_AZT2320 - tristate "Aztech Systems AZT2320" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for soundcards based on the - Aztech Systems AZT2320 chip. - - To compile this driver as a module, choose M here: the module - will be called snd-azt2320. - -config SND_CMI8330 - tristate "C-Media CMI8330" - depends on SND - select SND_AD1848_LIB - help - Say Y here to include support for soundcards based on the - C-Media CMI8330 chip. - - To compile this driver as a module, choose M here: the module - will be called snd-cmi8330. - -config SND_DT019X - tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - Say Y here to include support for soundcards based on the - Diamond Technologies DT-019X or Avance Logic ALS-007 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-dt019x. - -config SND_OPL3SA2 - tristate "Yamaha OPL3-SA2/SA3" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3 - chips. - - To compile this driver as a module, choose M here: the module - will be called snd-opl3sa2. - config SND_SGALAXY tristate "Aztech Sound Galaxy" depends on SND @@ -389,4 +363,17 @@ config SND_SSCAPE To compile this driver as a module, choose M here: the module will be called snd-sscape. +config SND_WAVEFRONT + tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" + depends on SND + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for Turtle Beach Maui, Tropez + and Tropez+ soundcards based on the Wavefront chip. + + To compile this driver as a module, choose M here: the module + will be called snd-wavefront. + endmenu diff --git a/sound/isa/ad1816a/Makefile b/sound/isa/ad1816a/Makefile index a42b29cf8549..90e00e842e49 100644 --- a/sound/isa/ad1816a/Makefile +++ b/sound/isa/ad1816a/Makefile @@ -3,8 +3,7 @@ # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> # -snd-ad1816a-lib-objs := ad1816a_lib.o -snd-ad1816a-objs := ad1816a.o +snd-ad1816a-objs := ad1816a.o ad1816a_lib.o # Toplevel Module Dependency -obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o snd-ad1816a-lib.o +obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 0eb442ca23d6..7051f7798ed7 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -188,10 +188,10 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard const struct pnp_card_device_id *pid) { int error; - snd_card_t *card; + struct snd_card *card; struct snd_card_ad1816a *acard; - ad1816a_t *chip; - opl3_t *opl3; + struct snd_ad1816a *chip; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_ad1816a))) == NULL) @@ -282,10 +282,8 @@ static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card, static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver ad1816a_pnpc_driver = { @@ -294,20 +292,22 @@ static struct pnp_card_driver ad1816a_pnpc_driver = { .id_table = snd_ad1816a_pnpids, .probe = snd_ad1816a_pnp_detect, .remove = __devexit_p(snd_ad1816a_pnp_remove), + /* FIXME: suspend/resume */ }; static int __init alsa_card_ad1816a_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&ad1816a_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&ad1816a_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&ad1816a_pnpc_driver); +#ifdef MODULE printk(KERN_ERR "no AD1816A based soundcards found.\n"); - } #endif /* MODULE */ - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_ad1816a_exit(void) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 7ae02396cae2..ac0d808fff57 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -30,11 +30,7 @@ #include <asm/io.h> #include <asm/dma.h> -MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); -MODULE_DESCRIPTION("lowlevel code for Analog Devices AD1816A chip"); -MODULE_LICENSE("GPL"); - -static inline int snd_ad1816a_busy_wait(ad1816a_t *chip) +static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip) { int timeout; @@ -46,34 +42,34 @@ static inline int snd_ad1816a_busy_wait(ad1816a_t *chip) return -EBUSY; } -static inline unsigned char snd_ad1816a_in(ad1816a_t *chip, unsigned char reg) +static inline unsigned char snd_ad1816a_in(struct snd_ad1816a *chip, unsigned char reg) { snd_ad1816a_busy_wait(chip); return inb(AD1816A_REG(reg)); } -static inline void snd_ad1816a_out(ad1816a_t *chip, unsigned char reg, +static inline void snd_ad1816a_out(struct snd_ad1816a *chip, unsigned char reg, unsigned char value) { snd_ad1816a_busy_wait(chip); outb(value, AD1816A_REG(reg)); } -static inline void snd_ad1816a_out_mask(ad1816a_t *chip, unsigned char reg, +static inline void snd_ad1816a_out_mask(struct snd_ad1816a *chip, unsigned char reg, unsigned char mask, unsigned char value) { snd_ad1816a_out(chip, reg, (value & mask) | (snd_ad1816a_in(chip, reg) & ~mask)); } -static unsigned short snd_ad1816a_read(ad1816a_t *chip, unsigned char reg) +static unsigned short snd_ad1816a_read(struct snd_ad1816a *chip, unsigned char reg) { snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); return snd_ad1816a_in(chip, AD1816A_INDIR_DATA_LOW) | (snd_ad1816a_in(chip, AD1816A_INDIR_DATA_HIGH) << 8); } -static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg, +static void snd_ad1816a_write(struct snd_ad1816a *chip, unsigned char reg, unsigned short value) { snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); @@ -81,7 +77,7 @@ static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg, snd_ad1816a_out(chip, AD1816A_INDIR_DATA_HIGH, (value >> 8) & 0xff); } -static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg, +static void snd_ad1816a_write_mask(struct snd_ad1816a *chip, unsigned char reg, unsigned short mask, unsigned short value) { snd_ad1816a_write(chip, reg, @@ -89,7 +85,7 @@ static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg, } -static unsigned char snd_ad1816a_get_format(ad1816a_t *chip, +static unsigned char snd_ad1816a_get_format(struct snd_ad1816a *chip, unsigned int format, int channels) { unsigned char retval = AD1816A_FMT_LINEAR_8; @@ -110,7 +106,7 @@ static unsigned char snd_ad1816a_get_format(ad1816a_t *chip, return (channels > 1) ? (retval | AD1816A_FMT_STEREO) : retval; } -static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode) +static int snd_ad1816a_open(struct snd_ad1816a *chip, unsigned int mode) { unsigned long flags; @@ -146,7 +142,7 @@ static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode) return 0; } -static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode) +static void snd_ad1816a_close(struct snd_ad1816a *chip, unsigned int mode) { unsigned long flags; @@ -178,7 +174,7 @@ static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode) } -static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what, +static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what, int channel, int cmd) { int error = 0; @@ -204,36 +200,36 @@ static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what, return error; } -static int snd_ad1816a_playback_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ad1816a_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd); } -static int snd_ad1816a_capture_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd); } -static int snd_ad1816a_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ad1816a_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); unsigned long flags; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size, rate; spin_lock_irqsave(&chip->lock, flags); @@ -261,11 +257,11 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_prepare(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); unsigned long flags; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size, rate; spin_lock_irqsave(&chip->lock, flags); @@ -294,9 +290,9 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream) } -static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ad1816a_playback_pointer(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->mode & AD1816A_MODE_PLAYBACK)) return 0; @@ -304,9 +300,9 @@ static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ad1816a_capture_pointer(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->mode & AD1816A_MODE_CAPTURE)) return 0; @@ -317,7 +313,7 @@ static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substr static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ad1816a_t *chip = dev_id; + struct snd_ad1816a *chip = dev_id; unsigned char status; spin_lock(&chip->lock); @@ -340,7 +336,7 @@ static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs * } -static snd_pcm_hardware_t snd_ad1816a_playback = { +static struct snd_pcm_hardware snd_ad1816a_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | @@ -359,7 +355,7 @@ static snd_pcm_hardware_t snd_ad1816a_playback = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ad1816a_capture = { +static struct snd_pcm_hardware snd_ad1816a_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | @@ -379,32 +375,32 @@ static snd_pcm_hardware_t snd_ad1816a_capture = { }; #if 0 /* not used now */ -static int snd_ad1816a_timer_close(snd_timer_t *timer) +static int snd_ad1816a_timer_close(struct snd_timer *timer) { - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); snd_ad1816a_close(chip, AD1816A_MODE_TIMER); return 0; } -static int snd_ad1816a_timer_open(snd_timer_t *timer) +static int snd_ad1816a_timer_open(struct snd_timer *timer) { - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); snd_ad1816a_open(chip, AD1816A_MODE_TIMER); return 0; } -static unsigned long snd_ad1816a_timer_resolution(snd_timer_t *timer) +static unsigned long snd_ad1816a_timer_resolution(struct snd_timer *timer) { snd_assert(timer != NULL, return 0); return 10000; } -static int snd_ad1816a_timer_start(snd_timer_t *timer) +static int snd_ad1816a_timer_start(struct snd_timer *timer) { unsigned short bits; unsigned long flags; - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); bits = snd_ad1816a_read(chip, AD1816A_INTERRUPT_ENABLE); @@ -419,10 +415,10 @@ static int snd_ad1816a_timer_start(snd_timer_t *timer) return 0; } -static int snd_ad1816a_timer_stop(snd_timer_t *timer) +static int snd_ad1816a_timer_stop(struct snd_timer *timer) { unsigned long flags; - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); snd_ad1816a_write_mask(chip, AD1816A_INTERRUPT_ENABLE, @@ -432,7 +428,7 @@ static int snd_ad1816a_timer_stop(snd_timer_t *timer) return 0; } -static struct _snd_timer_hardware snd_ad1816a_timer_table = { +static struct snd_timer_hardware snd_ad1816a_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 10000, .ticks = 65535, @@ -445,10 +441,10 @@ static struct _snd_timer_hardware snd_ad1816a_timer_table = { #endif /* not used now */ -static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int error; if ((error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK)) < 0) @@ -461,10 +457,10 @@ static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int error; if ((error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE)) < 0) @@ -477,18 +473,18 @@ static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_playback_close(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_close(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_ad1816a_close(chip, AD1816A_MODE_PLAYBACK); return 0; } -static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_close(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_ad1816a_close(chip, AD1816A_MODE_CAPTURE); @@ -496,7 +492,7 @@ static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream) } -static void snd_ad1816a_init(ad1816a_t *chip) +static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip) { unsigned long flags; @@ -516,7 +512,7 @@ static void snd_ad1816a_init(ad1816a_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_ad1816a_probe(ad1816a_t *chip) +static int __devinit snd_ad1816a_probe(struct snd_ad1816a *chip) { unsigned long flags; @@ -540,7 +536,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip) return 0; } -static int snd_ad1816a_free(ad1816a_t *chip) +static int snd_ad1816a_free(struct snd_ad1816a *chip) { release_and_free_resource(chip->res_port); if (chip->irq >= 0) @@ -557,13 +553,13 @@ static int snd_ad1816a_free(ad1816a_t *chip) return 0; } -static int snd_ad1816a_dev_free(snd_device_t *device) +static int snd_ad1816a_dev_free(struct snd_device *device) { - ad1816a_t *chip = device->device_data; + struct snd_ad1816a *chip = device->device_data; return snd_ad1816a_free(chip); } -static const char *snd_ad1816a_chip_id(ad1816a_t *chip) +static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip) { switch (chip->hardware) { case AD1816A_HW_AD1816A: return "AD1816A"; @@ -576,15 +572,15 @@ static const char *snd_ad1816a_chip_id(ad1816a_t *chip) } } -int snd_ad1816a_create(snd_card_t *card, - unsigned long port, int irq, int dma1, int dma2, - ad1816a_t **rchip) +int __devinit snd_ad1816a_create(struct snd_card *card, + unsigned long port, int irq, int dma1, int dma2, + struct snd_ad1816a **rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ad1816a_dev_free, }; int error; - ad1816a_t *chip; + struct snd_ad1816a *chip; *rchip = NULL; @@ -640,7 +636,7 @@ int snd_ad1816a_create(snd_card_t *card, return 0; } -static snd_pcm_ops_t snd_ad1816a_playback_ops = { +static struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -651,7 +647,7 @@ static snd_pcm_ops_t snd_ad1816a_playback_ops = { .pointer = snd_ad1816a_playback_pointer, }; -static snd_pcm_ops_t snd_ad1816a_capture_ops = { +static struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -662,17 +658,10 @@ static snd_pcm_ops_t snd_ad1816a_capture_ops = { .pointer = snd_ad1816a_capture_pointer, }; -static void snd_ad1816a_pcm_free(snd_pcm_t *pcm) -{ - ad1816a_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) +int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) { int error; - snd_pcm_t *pcm; + struct snd_pcm *pcm; if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm))) return error; @@ -681,7 +670,6 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1816a_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_ad1816a_pcm_free; pcm->info_flags = (chip->dma1 == chip->dma2 ) ? SNDRV_PCM_INFO_JOINT_DUPLEX : 0; strcpy(pcm->name, snd_ad1816a_chip_id(chip)); @@ -698,16 +686,10 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) } #if 0 /* not used now */ -static void snd_ad1816a_timer_free(snd_timer_t *timer) +int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer) { - ad1816a_t *chip = timer->private_data; - chip->timer = NULL; -} - -int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer) -{ - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; int error; tid.dev_class = SNDRV_TIMER_CLASS_CARD; @@ -719,7 +701,6 @@ int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer) return error; strcpy(timer->name, snd_ad1816a_chip_id(chip)); timer->private_data = chip; - timer->private_free = snd_ad1816a_timer_free; chip->timer = timer; timer->hw = snd_ad1816a_timer_table; if (rtimer) @@ -732,7 +713,7 @@ int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer) * */ -static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "Line", "Mix", "CD", "Synth", "Video", @@ -748,9 +729,9 @@ static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short val; @@ -762,9 +743,9 @@ static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short val; int change; @@ -786,7 +767,7 @@ static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_ad1816a_get_single, .put = snd_ad1816a_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -797,9 +778,9 @@ static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -814,9 +795,9 @@ static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -843,7 +824,7 @@ static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_ad1816a_get_double, .put = snd_ad1816a_put_double, \ .private_value = reg | (shift_left << 8) | (shift_right << 12) | (mask << 16) | (invert << 24) } -static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -854,9 +835,9 @@ static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; @@ -877,9 +858,9 @@ static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; @@ -906,7 +887,7 @@ static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_ad1816a_controls[] = { +static struct snd_kcontrol_new snd_ad1816a_controls[] __devinitdata = { AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1), AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1), AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1), @@ -941,9 +922,9 @@ AD1816A_SINGLE("3D Control - Switch", AD1816A_3D_PHAT_CTRL, 15, 1, 1), AD1816A_SINGLE("3D Control - Level", AD1816A_3D_PHAT_CTRL, 0, 15, 0), }; -int snd_ad1816a_mixer(ad1816a_t *chip) +int __devinit snd_ad1816a_mixer(struct snd_ad1816a *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; @@ -959,19 +940,3 @@ int snd_ad1816a_mixer(ad1816a_t *chip) } return 0; } - -EXPORT_SYMBOL(snd_ad1816a_create); -EXPORT_SYMBOL(snd_ad1816a_pcm); -EXPORT_SYMBOL(snd_ad1816a_mixer); - -static int __init alsa_ad1816a_init(void) -{ - return 0; -} - -static void __exit alsa_ad1816a_exit(void) -{ -} - -module_init(alsa_ad1816a_init) -module_exit(alsa_ad1816a_exit) diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 3ebcc482b07a..e091bbeffd2a 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -23,6 +23,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/time.h> #include <linux/wait.h> #include <linux/moduleparam.h> @@ -60,14 +62,15 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 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 snd_card_t *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *devices[SNDRV_CARDS]; -static int __init snd_card_ad1848_probe(int dev) +static int __init snd_ad1848_probe(struct platform_device *pdev) { - snd_card_t *card; - ad1848_t *chip; - snd_pcm_t *pcm; + int dev = pdev->id; + struct snd_card *card; + struct snd_ad1848 *chip; + struct snd_pcm *pcm; int err; if (port[dev] == SNDRV_AUTO_PORT) { @@ -93,6 +96,7 @@ static int __init snd_card_ad1848_probe(int 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; @@ -109,13 +113,12 @@ static int __init snd_card_ad1848_probe(int dev) if (thinkpad[dev]) strcat(card->longname, " [Thinkpad]"); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_ad1848_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -123,29 +126,95 @@ static int __init snd_card_ad1848_probe(int dev) return err; } -static int __init alsa_card_ad1848_init(void) +static int __devexit snd_ad1848_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; +} + +static int snd_ad1848_resume(struct platform_device *pdev) { - int dev, cards; + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) - if (snd_card_ad1848_probe(dev) >= 0) - cards++; + chip->resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif +#define SND_AD1848_DRIVER "snd_ad1848" + +static struct platform_driver snd_ad1848_driver = { + .probe = snd_ad1848_probe, + .remove = __devexit_p(snd_ad1848_remove), +#ifdef CONFIG_PM + .suspend = snd_ad1848_suspend, + .resume = snd_ad1848_resume, +#endif + .driver = { + .name = SND_AD1848_DRIVER + }, +}; + +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 && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_AD1848_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "AD1848 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_ad1848_unregister_all(); + return err; } static void __exit alsa_card_ad1848_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_ad1848_cards[idx]); + snd_ad1848_unregister_all(); } module_init(alsa_card_ad1848_init) diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 891bacc94f68..b78530d7ea90 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -24,7 +24,6 @@ #include <linux/delay.h> #include <linux/init.h> #include <linux/interrupt.h> -#include <linux/pm.h> #include <linux/slab.h> #include <linux/ioport.h> #include <sound/core.h> @@ -69,7 +68,7 @@ static unsigned int rates[14] = { 27042, 32000, 33075, 37800, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = 14, .list = rates, .mask = 0, @@ -99,7 +98,7 @@ static unsigned char snd_ad1848_original_image[16] = * Basic I/O functions */ -void snd_ad1848_out(ad1848_t *chip, +void snd_ad1848_out(struct snd_ad1848 *chip, unsigned char reg, unsigned char value) { @@ -119,7 +118,7 @@ void snd_ad1848_out(ad1848_t *chip, #endif } -static void snd_ad1848_dout(ad1848_t *chip, +static void snd_ad1848_dout(struct snd_ad1848 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -131,7 +130,7 @@ static void snd_ad1848_dout(ad1848_t *chip, mb(); } -static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg) +static unsigned char snd_ad1848_in(struct snd_ad1848 *chip, unsigned char reg) { int timeout; @@ -148,7 +147,7 @@ static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg) #if 0 -static void snd_ad1848_debug(ad1848_t *chip) +static void snd_ad1848_debug(struct snd_ad1848 *chip) { printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip, REGSEL))); printk(" STATUS = 0x%02x\n", inb(AD1848P(chip, STATUS))); @@ -176,7 +175,7 @@ static void snd_ad1848_debug(ad1848_t *chip) * AD1848 detection / MCE routines */ -static void snd_ad1848_mce_up(ad1848_t *chip) +static void snd_ad1848_mce_up(struct snd_ad1848 *chip) { unsigned long flags; int timeout; @@ -197,7 +196,7 @@ static void snd_ad1848_mce_up(ad1848_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_ad1848_mce_down(ad1848_t *chip) +static void snd_ad1848_mce_down(struct snd_ad1848 *chip) { unsigned long flags; int timeout; @@ -279,7 +278,7 @@ static unsigned int snd_ad1848_get_count(unsigned char format, return size; } -static int snd_ad1848_trigger(ad1848_t *chip, unsigned char what, +static int snd_ad1848_trigger(struct snd_ad1848 *chip, unsigned char what, int channel, int cmd) { int result = 0; @@ -324,7 +323,7 @@ static unsigned char snd_ad1848_get_rate(unsigned int rate) return freq_bits[13]; } -static int snd_ad1848_ioctl(snd_pcm_substream_t * substream, +static int snd_ad1848_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { return snd_pcm_lib_ioctl(substream, cmd, arg); @@ -348,7 +347,7 @@ static unsigned char snd_ad1848_get_format(int format, int channels) return rformat; } -static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute) +static void snd_ad1848_calibrate_mute(struct snd_ad1848 *chip, int mute) { unsigned long flags; @@ -372,7 +371,7 @@ static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_params) +static void snd_ad1848_set_data_format(struct snd_ad1848 *chip, struct snd_pcm_hw_params *hw_params) { if (hw_params == NULL) { chip->image[AD1848_DATA_FORMAT] = 0x20; @@ -384,7 +383,7 @@ static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_p // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]); } -static int snd_ad1848_open(ad1848_t *chip, unsigned int mode) +static int snd_ad1848_open(struct snd_ad1848 *chip, unsigned int mode) { unsigned long flags; @@ -438,7 +437,7 @@ static int snd_ad1848_open(ad1848_t *chip, unsigned int mode) return 0; } -static void snd_ad1848_close(ad1848_t *chip) +static void snd_ad1848_close(struct snd_ad1848 *chip) { unsigned long flags; @@ -479,24 +478,24 @@ static void snd_ad1848_close(ad1848_t *chip) * ok.. exported functions.. */ -static int snd_ad1848_playback_trigger(snd_pcm_substream_t * substream, +static int snd_ad1848_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); return snd_ad1848_trigger(chip, AD1848_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd); } -static int snd_ad1848_capture_trigger(snd_pcm_substream_t * substream, +static int snd_ad1848_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); return snd_ad1848_trigger(chip, AD1848_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd); } -static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1848_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); unsigned long flags; int err; @@ -513,15 +512,15 @@ static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ad1848_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_prepare(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -537,10 +536,10 @@ static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1848_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); unsigned long flags; int err; @@ -557,15 +556,15 @@ static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ad1848_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_prepare(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -583,7 +582,7 @@ static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream) static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ad1848_t *chip = dev_id; + struct snd_ad1848 *chip = dev_id; if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && (chip->mode & AD1848_MODE_RUNNING)) @@ -595,9 +594,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ad1848_playback_pointer(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE)) @@ -606,9 +605,9 @@ static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ad1848_capture_pointer(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE)) @@ -621,7 +620,7 @@ static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substr */ -static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) { +static void snd_ad1848_thinkpad_twiddle(struct snd_ad1848 *chip, int on) { int tmp; @@ -642,33 +641,34 @@ static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) { } #ifdef CONFIG_PM -static int snd_ad1848_suspend(snd_card_t *card, pm_message_t state) +static void snd_ad1848_suspend(struct snd_ad1848 *chip) { - ad1848_t *chip = card->pm_private_data; - snd_pcm_suspend_all(chip->pcm); - /* FIXME: save registers? */ - if (chip->thinkpad_flag) snd_ad1848_thinkpad_twiddle(chip, 0); - - return 0; } -static int snd_ad1848_resume(snd_card_t *card) +static void snd_ad1848_resume(struct snd_ad1848 *chip) { - ad1848_t *chip = card->pm_private_data; + int i; if (chip->thinkpad_flag) snd_ad1848_thinkpad_twiddle(chip, 1); - /* FIXME: restore registers? */ + /* clear any pendings IRQ */ + inb(AD1848P(chip, STATUS)); + outb(0, AD1848P(chip, STATUS)); + mb(); - return 0; + snd_ad1848_mce_down(chip); + for (i = 0; i < 16; i++) + snd_ad1848_out(chip, i, chip->image[i]); + snd_ad1848_mce_up(chip); + snd_ad1848_mce_down(chip); } #endif /* CONFIG_PM */ -static int snd_ad1848_probe(ad1848_t * chip) +static int snd_ad1848_probe(struct snd_ad1848 * chip) { unsigned long flags; int i, id, rev, ad1847; @@ -748,7 +748,7 @@ static int snd_ad1848_probe(ad1848_t * chip) */ -static snd_pcm_hardware_t snd_ad1848_playback = +static struct snd_pcm_hardware snd_ad1848_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -767,7 +767,7 @@ static snd_pcm_hardware_t snd_ad1848_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ad1848_capture = +static struct snd_pcm_hardware snd_ad1848_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -790,10 +790,10 @@ static snd_pcm_hardware_t snd_ad1848_capture = */ -static int snd_ad1848_playback_open(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_open(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0) @@ -806,10 +806,10 @@ static int snd_ad1848_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_open(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_open(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0) @@ -822,9 +822,9 @@ static int snd_ad1848_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_playback_close(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_close(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); chip->mode &= ~AD1848_MODE_PLAY; chip->playback_substream = NULL; @@ -832,9 +832,9 @@ static int snd_ad1848_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_close(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); chip->mode &= ~AD1848_MODE_CAPTURE; chip->capture_substream = NULL; @@ -842,7 +842,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_free(ad1848_t *chip) +static int snd_ad1848_free(struct snd_ad1848 *chip) { release_and_free_resource(chip->res_port); if (chip->irq >= 0) @@ -855,13 +855,13 @@ static int snd_ad1848_free(ad1848_t *chip) return 0; } -static int snd_ad1848_dev_free(snd_device_t *device) +static int snd_ad1848_dev_free(struct snd_device *device) { - ad1848_t *chip = device->device_data; + struct snd_ad1848 *chip = device->device_data; return snd_ad1848_free(chip); } -static const char *snd_ad1848_chip_id(ad1848_t *chip) +static const char *snd_ad1848_chip_id(struct snd_ad1848 *chip) { switch (chip->hardware) { case AD1848_HW_AD1847: return "AD1847"; @@ -872,16 +872,16 @@ static const char *snd_ad1848_chip_id(ad1848_t *chip) } } -int snd_ad1848_create(snd_card_t * card, +int snd_ad1848_create(struct snd_card *card, unsigned long port, int irq, int dma, unsigned short hardware, - ad1848_t ** rchip) + struct snd_ad1848 ** rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ad1848_dev_free, }; - ad1848_t *chip; + struct snd_ad1848 *chip; int err; *rchip = NULL; @@ -919,7 +919,6 @@ int snd_ad1848_create(snd_card_t * card, chip->thinkpad_flag = 1; chip->hardware = AD1848_HW_DETECT; /* reset */ snd_ad1848_thinkpad_twiddle(chip, 1); - snd_card_set_isa_pm_callback(card, snd_ad1848_suspend, snd_ad1848_resume, chip); } if (snd_ad1848_probe(chip) < 0) { @@ -933,11 +932,16 @@ int snd_ad1848_create(snd_card_t * card, return err; } +#ifdef CONFIG_PM + chip->suspend = snd_ad1848_suspend; + chip->resume = snd_ad1848_resume; +#endif + *rchip = chip; return 0; } -static snd_pcm_ops_t snd_ad1848_playback_ops = { +static struct snd_pcm_ops snd_ad1848_playback_ops = { .open = snd_ad1848_playback_open, .close = snd_ad1848_playback_close, .ioctl = snd_ad1848_ioctl, @@ -948,7 +952,7 @@ static snd_pcm_ops_t snd_ad1848_playback_ops = { .pointer = snd_ad1848_playback_pointer, }; -static snd_pcm_ops_t snd_ad1848_capture_ops = { +static struct snd_pcm_ops snd_ad1848_capture_ops = { .open = snd_ad1848_capture_open, .close = snd_ad1848_capture_close, .ioctl = snd_ad1848_ioctl, @@ -959,16 +963,9 @@ static snd_pcm_ops_t snd_ad1848_capture_ops = { .pointer = snd_ad1848_capture_pointer, }; -static void snd_ad1848_pcm_free(snd_pcm_t *pcm) -{ - ad1848_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) +int snd_ad1848_pcm(struct snd_ad1848 *chip, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "AD1848", device, 1, 1, &pcm)) < 0) @@ -977,7 +974,6 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1848_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1848_capture_ops); - pcm->private_free = snd_ad1848_pcm_free; pcm->private_data = chip; pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; strcpy(pcm->name, snd_ad1848_chip_id(chip)); @@ -992,7 +988,7 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) return 0; } -const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction) +const struct snd_pcm_ops *snd_ad1848_get_pcm_ops(int direction) { return direction == SNDRV_PCM_STREAM_PLAYBACK ? &snd_ad1848_playback_ops : &snd_ad1848_capture_ops; @@ -1002,7 +998,7 @@ const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction) * MIXER part */ -static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line", "Aux", "Mic", "Mix" @@ -1017,9 +1013,9 @@ static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -1029,9 +1025,9 @@ static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1052,7 +1048,7 @@ static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1063,9 +1059,9 @@ static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1080,9 +1076,9 @@ static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1103,7 +1099,7 @@ static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1114,9 +1110,9 @@ static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1136,9 +1132,9 @@ static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1175,9 +1171,9 @@ static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* */ -int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value) +int snd_ad1848_add_ctl(struct snd_ad1848 *chip, const char *name, int index, int type, unsigned long value) { - static snd_kcontrol_new_t newctls[] = { + static struct snd_kcontrol_new newctls[] = { [AD1848_MIX_SINGLE] = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_ad1848_info_single, @@ -1197,7 +1193,7 @@ int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, un .put = snd_ad1848_put_mux, }, }; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; int err; ctl = snd_ctl_new1(&newctls[type], chip); @@ -1230,10 +1226,10 @@ AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK, 0, 1, 0), AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0) }; -int snd_ad1848_mixer(ad1848_t *chip) +int snd_ad1848_mixer(struct snd_ad1848 *chip) { - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; unsigned int idx; int err; diff --git a/sound/isa/als100.c b/sound/isa/als100.c index ac8f13664983..9b77c17b3f66 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -83,6 +83,7 @@ struct snd_card_als100 { struct pnp_dev *dev; struct pnp_dev *devmpu; struct pnp_dev *devopl; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_als100_pnpids[] = { @@ -203,15 +204,15 @@ static int __init snd_card_als100_probe(int dev, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_als100 *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_als100))) == NULL) return -ENOMEM; - acard = (struct snd_card_als100 *)card->private_data; + acard = card->private_data; if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { snd_card_free(card); @@ -228,6 +229,7 @@ static int __init snd_card_als100_probe(int dev, snd_card_free(card); return error; } + acard->chip = chip; strcpy(card->driver, "ALS100"); strcpy(card->shortname, "Avance Logic ALS100"); @@ -299,32 +301,61 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_als100 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; } +static int snd_als100_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_als100 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pnp_card_driver als100_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "als100", .id_table = snd_als100_pnpids, .probe = snd_als100_pnp_detect, .remove = __devexit_p(snd_als100_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_als100_pnp_suspend, + .resume = snd_als100_pnp_resume, +#endif }; static int __init alsa_card_als100_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&als100_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&als100_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&als100_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_als100_exit(void) diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index bb41c6ec2f43..a530691bf4f7 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -93,6 +93,7 @@ struct snd_card_azt2320 { int dev_no; struct pnp_dev *dev; struct pnp_dev *devmpu; + struct snd_cs4231 *chip; }; static struct pnp_card_device_id snd_azt2320_pnpids[] = { @@ -227,10 +228,10 @@ static int __devinit snd_card_azt2320_probe(int dev, const struct pnp_card_device_id *pid) { int error; - snd_card_t *card; + struct snd_card *card; struct snd_card_azt2320 *acard; - cs4231_t *chip; - opl3_t *opl3; + struct snd_cs4231 *chip; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_azt2320))) == NULL) @@ -329,32 +330,59 @@ static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card, static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_azt2320 *acard = card->private_data; + struct snd_cs4231 *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; } +static int snd_azt2320_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_azt2320 *acard = card->private_data; + struct snd_cs4231 *chip = acard->chip; + + chip->resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pnp_card_driver azt2320_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "azt2320", .id_table = snd_azt2320_pnpids, .probe = snd_azt2320_pnp_detect, .remove = __devexit_p(snd_azt2320_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_azt2320_pnp_suspend, + .resume = snd_azt2320_pnp_resume, +#endif }; static int __init alsa_card_azt2320_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&azt2320_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&azt2320_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&azt2320_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no AZT2320 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_azt2320_exit(void) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 5252206ea388..bd8e23818460 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -45,6 +45,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/pnp.h> #include <linux/moduleparam.h> @@ -106,6 +108,9 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); module_param_array(wssdma, int, NULL, 0444); MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #define CMI8330_RMUX3D 16 #define CMI8330_MUTEMUX 17 #define CMI8330_OUTPUTVOL 18 @@ -137,27 +142,25 @@ static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] = 0x0 /* 26 - cd-in rec gain */ }; -typedef int (*snd_pcm_open_callback_t)(snd_pcm_substream_t *); +typedef int (*snd_pcm_open_callback_t)(struct snd_pcm_substream *); struct snd_cmi8330 { #ifdef CONFIG_PNP struct pnp_dev *cap; struct pnp_dev *play; #endif - snd_card_t *card; - ad1848_t *wss; - sb_t *sb; + struct snd_card *card; + struct snd_ad1848 *wss; + struct snd_sb *sb; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct snd_cmi8330_stream { - snd_pcm_ops_t ops; + struct snd_pcm_ops ops; snd_pcm_open_callback_t open; void *private_data; /* sb or wss */ } streams[2]; }; -static snd_card_t *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP static struct pnp_card_device_id snd_cmi8330_pnpids[] = { @@ -231,7 +234,7 @@ static unsigned char cmi8330_sb_init_values[][2] __initdata = { }; -static int __devinit cmi8330_add_sb_mixers(sb_t *chip) +static int __devinit cmi8330_add_sb_mixers(struct snd_sb *chip) { int idx, err; unsigned long flags; @@ -256,7 +259,7 @@ static int __devinit cmi8330_add_sb_mixers(sb_t *chip) } #endif -static int __devinit snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard) +static int __devinit snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard) { unsigned int idx; int err; @@ -370,7 +373,7 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, #define CMI_AD_STREAM SNDRV_PCM_STREAM_PLAYBACK #endif -static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream) +static int snd_cmi8330_playback_open(struct snd_pcm_substream *substream) { struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); @@ -379,7 +382,7 @@ static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream) return chip->streams[SNDRV_PCM_STREAM_PLAYBACK].open(substream); } -static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) +static int snd_cmi8330_capture_open(struct snd_pcm_substream *substream) { struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); @@ -388,15 +391,10 @@ static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) return chip->streams[SNDRV_PCM_STREAM_CAPTURE].open(substream); } -static void snd_cmi8330_pcm_free(snd_pcm_t *pcm) +static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) { - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) -{ - snd_pcm_t *pcm; - const snd_pcm_ops_t *ops; + struct snd_pcm *pcm; + const struct snd_pcm_ops *ops; int err; static snd_pcm_open_callback_t cmi_open_callbacks[2] = { snd_cmi8330_playback_open, @@ -407,7 +405,6 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) return err; strcpy(pcm->name, "CMI8330"); pcm->private_data = chip; - pcm->private_free = snd_cmi8330_pcm_free; /* SB16 */ ops = snd_sb16dsp_get_pcm_ops(CMI_SB_STREAM); @@ -435,6 +432,31 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) } +#ifdef CONFIG_PM +static int snd_cmi8330_suspend(struct snd_card *card) +{ + struct snd_cmi8330 *acard = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(acard->pcm); + acard->wss->suspend(acard->wss); + snd_sbmixer_suspend(acard->sb); + return 0; +} + +static int snd_cmi8330_resume(struct snd_card *card) +{ + struct snd_cmi8330 *acard = card->private_data; + + snd_sbdsp_reset(acard->sb); + snd_sbmixer_suspend(acard->sb); + acard->wss->resume(acard->wss); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + + /* */ @@ -446,44 +468,28 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) #define PFX "cmi8330: " -static int __devinit snd_cmi8330_probe(int dev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_cmi8330_card_new(int dev) { - snd_card_t *card; + struct snd_card *card; struct snd_cmi8330 *acard; - int i, err; - - if (! is_isapnp_selected(dev)) { - if (wssport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify wssport\n"); - return -EINVAL; - } - if (sbport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify sbport\n"); - return -EINVAL; - } - } card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_cmi8330)); if (card == NULL) { snd_printk(KERN_ERR PFX "could not get a new card\n"); - return -ENOMEM; + return NULL; } - acard = (struct snd_cmi8330 *)card->private_data; + acard = card->private_data; acard->card = card; + return card; +} -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { - snd_printk(KERN_ERR PFX "PnP detection failed\n"); - goto _err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif +static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) +{ + struct snd_cmi8330 *acard; + int i, err; + acard = card->private_data; if ((err = snd_ad1848_create(card, wssport[dev] + 4, wssirq[dev], @@ -491,12 +497,11 @@ static int __devinit snd_cmi8330_probe(int dev, AD1848_HW_DETECT, &acard->wss)) < 0) { snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); - goto _err; + return err; } if (acard->wss->hardware != AD1848_HW_CMI8330) { snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); - err = -ENODEV; - goto _err; + return -ENODEV; } if ((err = snd_sbdsp_create(card, sbport[dev], @@ -506,11 +511,11 @@ static int __devinit snd_cmi8330_probe(int dev, sbdma16[dev], SB_HW_AUTO, &acard->sb)) < 0) { snd_printk(KERN_ERR PFX "(SB16) device busy??\n"); - goto _err; + return err; } if (acard->sb->hardware != SB_HW_16) { snd_printk(KERN_ERR PFX "(SB16) not found during probe\n"); - goto _err; + return err; } snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */ @@ -519,12 +524,12 @@ static int __devinit snd_cmi8330_probe(int dev, if ((err = snd_cmi8330_mixer(card, acard)) < 0) { snd_printk(KERN_ERR PFX "failed to create mixers\n"); - goto _err; + return err; } if ((err = snd_cmi8330_pcm(card, acard)) < 0) { snd_printk(KERN_ERR PFX "failed to create pcms\n"); - goto _err; + return err; } strcpy(card->driver, "CMI8330/C3D"); @@ -535,49 +540,120 @@ static int __devinit snd_cmi8330_probe(int dev, wssirq[dev], wssdma[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + return snd_card_register(card); +} - if ((err = snd_card_register(card)) < 0) - goto _err; +static int __init snd_cmi8330_nonpnp_probe(struct platform_device *pdev) +{ + struct snd_card *card; + int err; + int dev = pdev->id; + + if (wssport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify wssport\n"); + return -EINVAL; + } + if (sbport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify sbport\n"); + return -EINVAL; + } - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_cmi8330_legacy[dev] = card; + card = snd_cmi8330_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cmi8330_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(pdev, card); return 0; +} - _err: - snd_card_free(card); - return err; +static int snd_cmi8330_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#ifdef CONFIG_PM +static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_cmi8330_suspend(platform_get_drvdata(dev)); +} + +static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) +{ + return snd_cmi8330_resume(platform_get_drvdata(dev)); +} +#endif + +#define CMI8330_DRIVER "snd_cmi8330" + +static struct platform_driver snd_cmi8330_driver = { + .probe = snd_cmi8330_nonpnp_probe, + .remove = snd_cmi8330_nonpnp_remove, +#ifdef CONFIG_PM + .suspend = snd_cmi8330_nonpnp_suspend, + .resume = snd_cmi8330_nonpnp_resume, +#endif + .driver = { + .name = CMI8330_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_cmi8330_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; + if (enable[dev] && isapnp[dev]) + break; } - return -ENODEV; + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cmi8330_card_new(dev); + if (! card) + return -ENOMEM; + if ((res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_printk(KERN_ERR PFX "PnP detection failed\n"); + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_cmi8330_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_cmi8330_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_cmi8330_suspend(pnp_get_card_drvdata(pcard)); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +static int snd_cmi8330_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_cmi8330_resume(pnp_get_card_drvdata(pcard)); } +#endif static struct pnp_card_driver cmi8330_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, @@ -585,47 +661,68 @@ static struct pnp_card_driver cmi8330_pnpc_driver = { .id_table = snd_cmi8330_pnpids, .probe = snd_cmi8330_pnp_detect, .remove = __devexit_p(snd_cmi8330_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cmi8330_pnp_suspend, + .resume = snd_cmi8330_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cmi8330_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&cmi8330_pnpc_driver); + 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 dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(CMI8330_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + platform_devices[i] = device; + cards++; + } + + err = pnp_register_card_driver(&cmi8330_pnpc_driver); + if (err >= 0) { + pnp_registered = 1; + cards += err; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&cmi8330_pnpc_driver); -#endif if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&cmi8330_pnpc_driver); -#endif #ifdef MODULE snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cmi8330_unregister_all(); + return err; } static void __exit alsa_card_cmi8330_exit(void) { - int i; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&cmi8330_pnpc_driver); -#endif - for (i = 0; i < SNDRV_CARDS; i++) - snd_card_free(snd_cmi8330_legacy[i]); + snd_cmi8330_unregister_all(); } module_init(alsa_card_cmi8330_init) diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index 9be5416bcb92..ab67b5c2590d 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -22,6 +22,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/time.h> #include <linux/wait.h> #include <linux/moduleparam.h> @@ -64,15 +66,15 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); -static snd_card_t *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *devices[SNDRV_CARDS]; -static int __init snd_card_cs4231_probe(int dev) +static int __init snd_cs4231_probe(struct platform_device *pdev) { - snd_card_t *card; - struct snd_card_cs4231 *acard; - snd_pcm_t *pcm = NULL; - cs4231_t *chip; + int dev = pdev->id; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_cs4231 *chip; int err; if (port[dev] == SNDRV_AUTO_PORT) { @@ -90,7 +92,6 @@ static int __init snd_card_cs4231_probe(int dev) card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - acard = (struct snd_card_cs4231 *)card->private_data; if ((err = snd_cs4231_create(card, port[dev], -1, irq[dev], dma1[dev], @@ -98,6 +99,7 @@ static int __init snd_card_cs4231_probe(int dev) CS4231_HW_DETECT, 0, &chip)) < 0) goto _err; + card->private_data = chip; if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) goto _err; @@ -125,12 +127,12 @@ static int __init snd_card_cs4231_probe(int dev) printk(KERN_WARNING "cs4231: MPU401 not detected\n"); } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_cs4231_cards[dev] = card; + + platform_set_drvdata(pdev, card); return 0; _err: @@ -138,29 +140,97 @@ static int __init snd_card_cs4231_probe(int dev) return err; } -static int __init alsa_card_cs4231_init(void) +static int __devexit snd_cs4231_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) +{ + struct snd_card *card; + struct snd_cs4231 *chip; + card = platform_get_drvdata(dev); + 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) +{ + struct snd_card *card; + struct snd_cs4231 *chip; + card = platform_get_drvdata(dev); + 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 = { + .probe = snd_cs4231_probe, + .remove = __devexit_p(snd_cs4231_remove), +#ifdef CONFIG_PM + .suspend = snd_cs4231_suspend, + .resume = snd_cs4231_resume, +#endif + .driver = { + .name = SND_CS4231_DRIVER + }, +}; + +static void __init_or_module snd_cs4231_unregister_all(void) { - int dev, cards; + int i; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_card_cs4231_probe(dev) >= 0) - cards++; + 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 && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_CS4231_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; } if (!cards) { #ifdef MODULE printk(KERN_ERR "CS4231 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cs4231_unregister_all(); + return err; } static void __exit alsa_card_cs4231_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_cs4231_cards[idx]); + snd_cs4231_unregister_all(); } module_init(alsa_card_cs4231_init) diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 4af769030beb..eab7eb59b5f7 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -73,13 +73,13 @@ static unsigned int rates[14] = { 27042, 32000, 33075, 37800, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = 14, .list = rates, .mask = 0, }; -static int snd_cs4231_xrate(snd_pcm_runtime_t *runtime) +static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime) { return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); } @@ -124,49 +124,17 @@ static unsigned char snd_cs4231_original_image[32] = * Basic I/O functions */ -#if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT) -#define __CS4231_INLINE__ inline -#else -#define __CS4231_INLINE__ /* nothing */ -#endif - -static __CS4231_INLINE__ void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) +static inline void cs4231_outb(struct snd_cs4231 *chip, u8 offset, u8 val) { -#ifdef EBUS_SUPPORT - if (chip->ebus->flag) { - writeb(val, chip->port + (offset << 2)); - } else { -#endif -#ifdef SBUS_SUPPORT - sbus_writeb(val, chip->port + (offset << 2)); -#endif -#ifdef EBUS_SUPPORT - } -#endif -#ifdef LEGACY_SUPPORT outb(val, chip->port + offset); -#endif } -static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset) +static inline u8 cs4231_inb(struct snd_cs4231 *chip, u8 offset) { -#ifdef EBUS_SUPPORT - if (chip->ebus_flag) { - return readb(chip->port + (offset << 2)); - } else { -#endif -#ifdef SBUS_SUPPORT - return sbus_readb(chip->port + (offset << 2)); -#endif -#ifdef EBUS_SUPPORT - } -#endif -#ifdef LEGACY_SUPPORT return inb(chip->port + offset); -#endif } -static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, +static void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg, unsigned char mask, unsigned char value) { int timeout; @@ -193,7 +161,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, } } -static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char value) +static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -206,7 +174,7 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val mb(); } -void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) +void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -227,7 +195,7 @@ void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) #endif } -unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) +unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) { int timeout; @@ -244,7 +212,7 @@ unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) return cs4231_inb(chip, CS4231P(REG)); } -void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) +void snd_cs4236_ext_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val) { cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); @@ -255,7 +223,7 @@ void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) #endif } -unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) +unsigned char snd_cs4236_ext_in(struct snd_cs4231 *chip, unsigned char reg) { cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); @@ -273,7 +241,7 @@ unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) #if 0 -static void snd_cs4231_debug(cs4231_t *chip) +static void snd_cs4231_debug(struct snd_cs4231 *chip) { printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL))); printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS))); @@ -317,7 +285,7 @@ static void snd_cs4231_debug(cs4231_t *chip) * CS4231 detection / MCE routines */ -static void snd_cs4231_busy_wait(cs4231_t *chip) +static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) { int timeout; @@ -331,7 +299,7 @@ static void snd_cs4231_busy_wait(cs4231_t *chip) udelay(10); } -void snd_cs4231_mce_up(cs4231_t *chip) +void snd_cs4231_mce_up(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -352,7 +320,7 @@ void snd_cs4231_mce_up(cs4231_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -void snd_cs4231_mce_down(cs4231_t *chip) +void snd_cs4231_mce_down(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -431,14 +399,14 @@ static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size return size; } -static int snd_cs4231_trigger(snd_pcm_substream_t *substream, +static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); int result = 0; unsigned int what; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; int do_start; #if 0 @@ -500,7 +468,7 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) return freq_bits[13]; } -static unsigned char snd_cs4231_get_format(cs4231_t *chip, +static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) { @@ -522,7 +490,7 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip, return rformat; } -static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) +static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) { unsigned long flags; @@ -556,8 +524,8 @@ static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4231_playback_format(cs4231_t *chip, - snd_pcm_hw_params_t *params, +static void snd_cs4231_playback_format(struct snd_cs4231 *chip, + struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; @@ -595,8 +563,8 @@ static void snd_cs4231_playback_format(cs4231_t *chip, up(&chip->mce_mutex); } -static void snd_cs4231_capture_format(cs4231_t *chip, - snd_pcm_hw_params_t *params, +static void snd_cs4231_capture_format(struct snd_cs4231 *chip, + struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; @@ -642,20 +610,20 @@ static void snd_cs4231_capture_format(cs4231_t *chip, * Timer interface */ -static unsigned long snd_cs4231_timer_resolution(snd_timer_t * timer) +static unsigned long snd_cs4231_timer_resolution(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); if (chip->hardware & CS4231_HW_CS4236B_MASK) return 14467; else return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; } -static int snd_cs4231_timer_start(snd_timer_t * timer) +static int snd_cs4231_timer_start(struct snd_timer * timer) { unsigned long flags; unsigned int ticks; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->reg_lock, flags); ticks = timer->sticks; if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || @@ -669,17 +637,17 @@ static int snd_cs4231_timer_start(snd_timer_t * timer) return 0; } -static int snd_cs4231_timer_stop(snd_timer_t * timer) +static int snd_cs4231_timer_stop(struct snd_timer * timer) { unsigned long flags; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->reg_lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } -static void snd_cs4231_init(cs4231_t *chip) +static void snd_cs4231_init(struct snd_cs4231 *chip) { unsigned long flags; @@ -737,7 +705,7 @@ static void snd_cs4231_init(cs4231_t *chip) #endif } -static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) +static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -773,7 +741,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) return 0; } -static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) +static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -824,21 +792,21 @@ static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) * timer open/close */ -static int snd_cs4231_timer_open(snd_timer_t * timer) +static int snd_cs4231_timer_open(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_open(chip, CS4231_MODE_TIMER); return 0; } -static int snd_cs4231_timer_close(snd_timer_t * timer) +static int snd_cs4231_timer_close(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_close(chip, CS4231_MODE_TIMER); return 0; } -static struct _snd_timer_hardware snd_cs4231_timer_table = +static struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, @@ -854,10 +822,10 @@ static struct _snd_timer_hardware snd_cs4231_timer_table = * ok.. exported functions.. */ -static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; int err; @@ -869,16 +837,15 @@ static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -#ifdef LEGACY_SUPPORT -static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -896,12 +863,11 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) #endif return 0; } -#endif /* LEGACY_SUPPORT */ -static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; int err; @@ -913,16 +879,15 @@ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -#ifdef LEGACY_SUPPORT -static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -942,9 +907,8 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } -#endif -static void snd_cs4231_overrange(cs4231_t *chip) +static void snd_cs4231_overrange(struct snd_cs4231 *chip) { unsigned long flags; unsigned char res; @@ -958,7 +922,7 @@ static void snd_cs4231_overrange(cs4231_t *chip) irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs4231_t *chip = dev_id; + struct snd_cs4231 *chip = dev_id; unsigned char status; status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); @@ -998,10 +962,9 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_HANDLED; } -#ifdef LEGACY_SUPPORT -static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) @@ -1010,9 +973,9 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) @@ -1020,13 +983,12 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); return bytes_to_frames(substream->runtime, ptr); } -#endif /* LEGACY_SUPPORT */ /* */ -static int snd_cs4231_probe(cs4231_t *chip) +static int snd_cs4231_probe(struct snd_cs4231 *chip) { unsigned long flags; int i, id, rev; @@ -1190,7 +1152,7 @@ static int snd_cs4231_probe(cs4231_t *chip) */ -static snd_pcm_hardware_t snd_cs4231_playback = +static struct snd_pcm_hardware snd_cs4231_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1211,7 +1173,7 @@ static snd_pcm_hardware_t snd_cs4231_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_cs4231_capture = +static struct snd_pcm_hardware snd_cs4231_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1236,10 +1198,10 @@ static snd_pcm_hardware_t snd_cs4231_capture = */ -static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_playback; @@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) chip->hardware == CS4231_HW_CS4239) runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; -#ifdef LEGACY_SUPPORT snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); @@ -1261,29 +1222,23 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) return err; } -#endif if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { -#ifdef LEGACY_SUPPORT if (chip->release_dma) chip->release_dma(chip, chip->dma_private_data, chip->dma1); -#endif snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } chip->playback_substream = substream; -#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) - chip->p_periods_sent = 0; -#endif snd_pcm_set_sync(substream); chip->rate_constraint(runtime); return 0; } -static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_capture; @@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) chip->hardware == CS4231_HW_CS4239) runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; -#ifdef LEGACY_SUPPORT snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); @@ -1301,37 +1255,31 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) return err; } -#endif if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { -#ifdef LEGACY_SUPPORT if (chip->release_dma) chip->release_dma(chip, chip->dma_private_data, chip->dma2); -#endif snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } chip->capture_substream = substream; -#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) - chip->c_periods_sent = 0; -#endif snd_pcm_set_sync(substream); chip->rate_constraint(runtime); return 0; } -static int snd_cs4231_playback_close(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_cs4231_close(chip, CS4231_MODE_PLAY); return 0; } -static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_cs4231_close(chip, CS4231_MODE_RECORD); @@ -1341,13 +1289,12 @@ static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) #ifdef CONFIG_PM /* lowlevel suspend callback for CS4231 */ -static void snd_cs4231_suspend(cs4231_t *chip) +static void snd_cs4231_suspend(struct snd_cs4231 *chip) { int reg; unsigned long flags; - if (chip->pcm) - snd_pcm_suspend_all(chip->pcm); + snd_pcm_suspend_all(chip->pcm); spin_lock_irqsave(&chip->reg_lock, flags); for (reg = 0; reg < 32; reg++) chip->image[reg] = snd_cs4231_in(chip, reg); @@ -1355,11 +1302,11 @@ static void snd_cs4231_suspend(cs4231_t *chip) } /* lowlevel resume callback for CS4231 */ -static void snd_cs4231_resume(cs4231_t *chip) +static void snd_cs4231_resume(struct snd_cs4231 *chip) { int reg; unsigned long flags; - int timeout; + /* int timeout; */ snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); @@ -1373,7 +1320,7 @@ static void snd_cs4231_resume(cs4231_t *chip) } } spin_unlock_irqrestore(&chip->reg_lock, flags); -#if 0 +#if 1 snd_cs4231_mce_down(chip); #else /* The following is a workaround to avoid freeze after resume on TP600E. @@ -1395,27 +1342,9 @@ static void snd_cs4231_resume(cs4231_t *chip) snd_cs4231_busy_wait(chip); #endif } - -static int snd_cs4231_pm_suspend(snd_card_t *card, pm_message_t state) -{ - cs4231_t *chip = card->pm_private_data; - if (chip->suspend) - chip->suspend(chip); - return 0; -} - -static int snd_cs4231_pm_resume(snd_card_t *card) -{ - cs4231_t *chip = card->pm_private_data; - if (chip->resume) - chip->resume(chip); - return 0; -} #endif /* CONFIG_PM */ -#ifdef LEGACY_SUPPORT - -static int snd_cs4231_free(cs4231_t *chip) +static int snd_cs4231_free(struct snd_cs4231 *chip) { release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_cport); @@ -1438,15 +1367,13 @@ static int snd_cs4231_free(cs4231_t *chip) return 0; } -static int snd_cs4231_dev_free(snd_device_t *device) +static int snd_cs4231_dev_free(struct snd_device *device) { - cs4231_t *chip = device->device_data; + struct snd_cs4231 *chip = device->device_data; return snd_cs4231_free(chip); } -#endif /* LEGACY_SUPPORT */ - -const char *snd_cs4231_chip_id(cs4231_t *chip) +const char *snd_cs4231_chip_id(struct snd_cs4231 *chip) { switch (chip->hardware) { case CS4231_HW_CS4231: return "CS4231"; @@ -1466,12 +1393,12 @@ const char *snd_cs4231_chip_id(cs4231_t *chip) } } -static int snd_cs4231_new(snd_card_t * card, +static int snd_cs4231_new(struct snd_card *card, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; *rchip = NULL; chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -1493,20 +1420,18 @@ static int snd_cs4231_new(snd_card_t * card, return 0; } -#ifdef LEGACY_SUPPORT - -int snd_cs4231_create(snd_card_t * card, +int snd_cs4231_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs4231_dev_free, }; - cs4231_t *chip; + struct snd_cs4231 *chip; int err; err = snd_cs4231_new(card, hardware, hwshare, &chip); @@ -1559,10 +1484,12 @@ int snd_cs4231_create(snd_card_t * card, } snd_cs4231_init(chip); +#if 0 if (chip->hardware & CS4231_HW_CS4232_MASK) { if (chip->res_cport == NULL) snd_printk("CS4232 control port features are not accessible\n"); } +#endif /* Register device */ if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { @@ -1574,16 +1501,13 @@ int snd_cs4231_create(snd_card_t * card, /* Power Management */ chip->suspend = snd_cs4231_suspend; chip->resume = snd_cs4231_resume; - snd_card_set_isa_pm_callback(card, snd_cs4231_pm_suspend, snd_cs4231_pm_resume, chip); #endif *rchip = chip; return 0; } -#endif /* LEGACY_SUPPORT */ - -static snd_pcm_ops_t snd_cs4231_playback_ops = { +static struct snd_pcm_ops snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1594,7 +1518,7 @@ static snd_pcm_ops_t snd_cs4231_playback_ops = { .pointer = snd_cs4231_playback_pointer, }; -static snd_pcm_ops_t snd_cs4231_capture_ops = { +static struct snd_pcm_ops snd_cs4231_capture_ops = { .open = snd_cs4231_capture_open, .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1605,16 +1529,9 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { .pointer = snd_cs4231_capture_pointer, }; -static void snd_cs4231_pcm_free(snd_pcm_t *pcm) +int snd_cs4231_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm) { - cs4231_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) -{ - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0) @@ -1629,7 +1546,6 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) /* global setup */ pcm->private_data = chip; - pcm->private_free = snd_cs4231_pcm_free; pcm->info_flags = 0; if (chip->single_dma) pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; @@ -1637,27 +1553,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_cs4231_chip_id(chip)); -#ifdef LEGACY_SUPPORT snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); -#else -# ifdef EBUS_SUPPORT - if (chip->ebus_flag) { - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->dev_u.pdev, - 64*1024, 128*1024); - } else { -# endif -# ifdef SBUS_SUPPORT - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS, - chip->dev_u.sdev, - 64*1024, 128*1024); -# endif -# ifdef EBUS_SUPPORT - } -# endif -#endif chip->pcm = pcm; if (rpcm) @@ -1665,16 +1563,16 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) return 0; } -static void snd_cs4231_timer_free(snd_timer_t *timer) +static void snd_cs4231_timer_free(struct snd_timer *timer) { - cs4231_t *chip = timer->private_data; + struct snd_cs4231 *chip = timer->private_data; chip->timer = NULL; } -int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) +int snd_cs4231_timer(struct snd_cs4231 *chip, int device, struct snd_timer **rtimer) { - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; int err; /* Timer initialization */ @@ -1699,7 +1597,7 @@ int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) * MIXER part */ -static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line", "Aux", "Mic", "Mix" @@ -1711,7 +1609,7 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u "Line", "Synth", "Mic", "Mix" }; char **ptexts = texts; - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); snd_assert(chip->card != NULL, return -EINVAL); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1729,9 +1627,9 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4231_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -1741,9 +1639,9 @@ static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4231_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1764,7 +1662,7 @@ static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1775,9 +1673,9 @@ int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo return 0; } -int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1792,9 +1690,9 @@ int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return 0; } -int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1815,7 +1713,7 @@ int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return change; } -int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1826,9 +1724,9 @@ int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo return 0; } -int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1848,9 +1746,9 @@ int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return 0; } -int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1879,7 +1777,7 @@ int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return change; } -static snd_kcontrol_new_t snd_cs4231_controls[] = { +static struct snd_kcontrol_new snd_cs4231_controls[] = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), @@ -1905,9 +1803,9 @@ CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1) }; -int snd_cs4231_mixer(cs4231_t *chip) +int snd_cs4231_mixer(struct snd_cs4231 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index d60a55e6a0b1..e1683337e6cd 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -21,6 +21,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/pnp.h> #include <linux/moduleparam.h> @@ -122,7 +124,14 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnpc_registered; +#ifdef CS4232 +static int pnp_registered; +#endif + struct snd_card_cs4236 { + struct snd_cs4231 *chip; struct resource *res_sb_port; #ifdef CONFIG_PNP struct pnp_dev *wss; @@ -131,33 +140,26 @@ struct snd_card_cs4236 { #endif }; -static snd_card_t *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP -#define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401) } \ - } -#define ISAPNP_CS4232_1(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ - ISAPNP_DEVICE_ID('P', 'N', 'P', _mpu401) } \ - } -#define ISAPNP_CS4232_WOMPU(_va, _vb, _vc, _device, _wss, _ctrl) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl) } \ - } - +#ifdef CS4232 +/* + * PNP BIOS + */ +static const struct pnp_device_id snd_cs4232_pnpbiosids[] = { + { .id = "CSC0100" }, + { .id = "CSC0000" }, + /* Guillemot Turtlebeach something appears to be cs4232 compatible + * (untested) */ + { .id = "GIM0100" }, + { .id = "" } +}; +MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids); +#endif /* CS4232 */ #ifdef CS4232 +#define CS423X_DRIVER "snd_cs4232" +#define CS423X_ISAPNP_DRIVER "cs4232_isapnp" static struct pnp_card_device_id snd_cs423x_pnpids[] = { /* Philips PCA70PS */ { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, @@ -177,6 +179,8 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { { .id = "" } /* end */ }; #else /* CS4236 */ +#define CS423X_DRIVER "snd_cs4236" +#define CS423X_ISAPNP_DRIVER "cs4236_isapnp" static struct pnp_card_device_id snd_cs423x_pnpids[] = { /* Intel Marlin Spike Motherboard - CS4235 */ { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, @@ -261,37 +265,12 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); -static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, - struct pnp_card_link *card, - const struct pnp_card_device_id *id) +/* WSS initialization */ +static int __devinit snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) { - struct pnp_dev *pdev; - struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); int err; - if (!cfg) - return -ENOMEM; - - acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); - if (acard->wss == NULL) { - kfree(cfg); - return -EBUSY; - } - acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); - if (acard->ctrl == NULL) { - kfree(cfg); - return -EBUSY; - } - if (id->devs[2].id[0]) { - acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); - if (acard->mpu == NULL) { - kfree(cfg); - return -EBUSY; - } - } - - /* WSS initialization */ - pdev = acard->wss; pnp_init_resource_table(cfg); if (port[dev] != SNDRV_AUTO_PORT) pnp_resource_change(&cfg->port_resource[0], port[dev], 4); @@ -310,7 +289,6 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { - kfree(cfg); printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n"); return -EBUSY; } @@ -325,63 +303,124 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, port[dev], fm_port[dev], sb_port[dev]); snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n", irq[dev], dma1[dev], dma2[dev]); - /* CTRL initialization */ - if (acard->ctrl && cport[dev] > 0) { - pdev = acard->ctrl; - pnp_init_resource_table(cfg); - if (cport[dev] != SNDRV_AUTO_PORT) - pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); - err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0) - snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); - err = pnp_activate_dev(pdev); - if (err < 0) { - kfree(cfg); - printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); - return -EBUSY; - } - cport[dev] = pnp_port_start(pdev, 0); - snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); + return 0; +} + +/* CTRL initialization */ +static int __devinit snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) +{ + int err; + + pnp_init_resource_table(cfg); + if (cport[dev] != SNDRV_AUTO_PORT) + pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); + err = pnp_manual_config_dev(pdev, cfg, 0); + if (err < 0) + snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); + err = pnp_activate_dev(pdev); + if (err < 0) { + printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); + return -EBUSY; } - /* MPU initialization */ - if (acard->mpu && mpu_port[dev] > 0) { - pdev = acard->mpu; - pnp_init_resource_table(cfg); - if (mpu_port[dev] != SNDRV_AUTO_PORT) - pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); - if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) - pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); - err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0) - snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); - err = pnp_activate_dev(pdev); - if (err < 0) { - printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); - mpu_port[dev] = SNDRV_AUTO_PORT; - mpu_irq[dev] = SNDRV_AUTO_IRQ; + cport[dev] = pnp_port_start(pdev, 0); + snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); + return 0; +} + +/* MPU initialization */ +static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) +{ + int err; + + pnp_init_resource_table(cfg); + if (mpu_port[dev] != SNDRV_AUTO_PORT) + pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); + if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) + pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); + err = pnp_manual_config_dev(pdev, cfg, 0); + if (err < 0) + snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); + err = pnp_activate_dev(pdev); + if (err < 0) { + printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); + mpu_port[dev] = SNDRV_AUTO_PORT; + mpu_irq[dev] = SNDRV_AUTO_IRQ; + } else { + mpu_port[dev] = pnp_port_start(pdev, 0); + if (mpu_irq[dev] >= 0 && + pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { + mpu_irq[dev] = pnp_irq(pdev, 0); } else { - mpu_port[dev] = pnp_port_start(pdev, 0); - if (mpu_irq[dev] >= 0 && - pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { - mpu_irq[dev] = pnp_irq(pdev, 0); - } else { - mpu_irq[dev] = -1; /* disable interrupt */ - } + mpu_irq[dev] = -1; /* disable interrupt */ } - snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); + } + snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); + return 0; +} + +#ifdef CS4232 +static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard, + struct pnp_dev *pdev) +{ + struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + + if (!cfg) + return -ENOMEM; + if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) { + kfree(cfg); + return -EBUSY; } kfree(cfg); + cport[dev] = -1; return 0; } -#endif /* CONFIG_PNP */ +#endif -static void snd_card_cs4236_free(snd_card_t *card) +static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard, + struct pnp_card_link *card, + const struct pnp_card_device_id *id) { - struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; + struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + + if (!cfg) + return -ENOMEM; + + acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); + if (acard->wss == NULL) + goto error; + acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); + if (acard->ctrl == NULL) + goto error; + if (id->devs[2].id[0]) { + acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); + if (acard->mpu == NULL) + goto error; + } - if (acard) - release_and_free_resource(acard->res_sb_port); + /* WSS initialization */ + if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) + goto error; + + /* CTRL initialization */ + if (acard->ctrl && cport[dev] > 0) { + if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl, cfg) < 0) + goto error; + } + /* MPU initialization */ + if (acard->mpu && mpu_port[dev] > 0) { + if (snd_cs423x_pnp_init_mpu(dev, acard->ctrl, cfg) < 0) + goto error; + } + kfree(cfg); + return 0; + + error: + kfree(cfg); + return -EBUSY; } +#endif /* CONFIG_PNP */ #ifdef CONFIG_PNP #define is_isapnp_selected(dev) isapnp[dev] @@ -389,46 +428,38 @@ static void snd_card_cs4236_free(snd_card_t *card) #define is_isapnp_selected(dev) 0 #endif -static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static void snd_card_cs4236_free(struct snd_card *card) { - snd_card_t *card; - struct snd_card_cs4236 *acard; - snd_pcm_t *pcm = NULL; - cs4231_t *chip; - opl3_t *opl3; - int err; + struct snd_card_cs4236 *acard = card->private_data; + + release_and_free_resource(acard->res_sb_port); +} + +static struct snd_card *snd_cs423x_card_new(int dev) +{ + struct snd_card *card; - if (! is_isapnp_selected(dev)) { - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify port\n"); - return -EINVAL; - } - if (cport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify cport\n"); - return -EINVAL; - } - } card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_cs4236)); if (card == NULL) - return -ENOMEM; - acard = (struct snd_card_cs4236 *)card->private_data; + return NULL; card->private_free = snd_card_cs4236_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { - printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); - goto _err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif + return card; +} + +static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) +{ + struct snd_card_cs4236 *acard; + struct snd_pcm *pcm; + struct snd_cs4231 *chip; + struct snd_opl3 *opl3; + int err; + + acard = card->private_data; if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); - err = -EBUSY; - goto _err; + return -EBUSY; } #ifdef CS4232 @@ -441,13 +472,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, CS4231_HW_DETECT, 0, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) - goto _err; + return err; if ((err = snd_cs4231_mixer(chip)) < 0) - goto _err; + return err; #else /* CS4236 */ if ((err = snd_cs4236_create(card, @@ -459,13 +491,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, CS4231_HW_DETECT, 0, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) - goto _err; + return err; if ((err = snd_cs4236_mixer(chip)) < 0) - goto _err; + return err; #endif strcpy(card->driver, pcm->name); strcpy(card->shortname, pcm->name); @@ -478,7 +511,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) - goto _err; + return err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, @@ -487,7 +520,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, printk(KERN_WARNING IDENT ": OPL3 not detected\n"); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) - goto _err; + return err; } } @@ -501,95 +534,279 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, printk(KERN_WARNING IDENT ": MPU401 not detected\n"); } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + return snd_card_register(card); +} - if ((err = snd_card_register(card)) < 0) - goto _err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_cs4236_legacy[dev] = card; +static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int err; + + if (port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "specify port\n"); + return -EINVAL; + } + if (cport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "specify cport\n"); + return -EINVAL; + } + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + + platform_set_drvdata(pdev, card); return 0; +} - _err: - snd_card_free(card); - return err; +static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#ifdef CONFIG_PM +static int snd_cs423x_suspend(struct snd_card *card) +{ + struct snd_card_cs4236 *acard = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + acard->chip->suspend(acard->chip); + return 0; +} + +static int snd_cs423x_resume(struct snd_card *card) +{ + struct snd_card_cs4236 *acard = card->private_data; + acard->chip->resume(acard->chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} + +static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_cs423x_suspend(platform_get_drvdata(dev)); +} + +static int snd_cs423x_nonpnp_resume(struct platform_device *dev) +{ + return snd_cs423x_resume(platform_get_drvdata(dev)); +} +#endif + +static struct platform_driver cs423x_nonpnp_driver = { + .probe = snd_cs423x_nonpnp_probe, + .remove = __devexit_p(snd_cs423x_nonpnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cs423x_nonpnp_suspend, + .resume = snd_cs423x_nonpnp_resume, +#endif + .driver = { + .name = CS423X_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +#ifdef CS4232 +static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev, + const struct pnp_device_id *id) { static int dev; + int err; + struct snd_card *card; + + if (pnp_device_is_isapnp(pdev)) + return -ENOENT; /* we have another procedure - card */ + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) { + printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n"); + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_drvdata(pdev, card); + dev++; + return 0; +} + +static void __devexit snd_cs4232_pnp_remove(struct pnp_dev * pdev) +{ + snd_card_free(pnp_get_drvdata(pdev)); + pnp_set_drvdata(pdev, NULL); +} + +#ifdef CONFIG_PM +static int snd_cs4232_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) +{ + return snd_cs423x_suspend(pnp_get_drvdata(pdev)); +} + +static int snd_cs4232_pnp_resume(struct pnp_dev *pdev) +{ + return snd_cs423x_resume(pnp_get_drvdata(pdev)); +} +#endif + +static struct pnp_driver cs4232_pnp_driver = { + .name = "cs4232-pnpbios", + .id_table = snd_cs4232_pnpbiosids, + .probe = snd_cs4232_pnpbios_detect, + .remove = __devexit_p(snd_cs4232_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cs4232_pnp_suspend, + .resume = snd_cs4232_pnp_resume, +#endif +}; +#endif /* CS4232 */ + +static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) +{ + static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_card_cs423x_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) { + printk(KERN_ERR "isapnp detection failed and probing for " IDENT + " is not supported\n"); + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return res; } - return -ENODEV; + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } -static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) +static void __devexit snd_cs423x_pnpc_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_cs423x_suspend(pnp_get_card_drvdata(pcard)); +} + +static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard) +{ + return snd_cs423x_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver cs423x_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, - .name = "cs423x", + .name = CS423X_ISAPNP_DRIVER, .id_table = snd_cs423x_pnpids, - .probe = snd_cs423x_pnp_detect, - .remove = __devexit_p(snd_cs423x_pnp_remove), + .probe = snd_cs423x_pnpc_detect, + .remove = __devexit_p(snd_cs423x_pnpc_remove), +#ifdef CONFIG_PM + .suspend = snd_cs423x_pnpc_suspend, + .resume = snd_cs423x_pnpc_resume, +#endif }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cs423x_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&cs423x_pnpc_driver); +#ifdef CS4232 + if (pnp_registered) + pnp_unregister_driver(&cs4232_pnp_driver); +#endif + 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 dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(CS423X_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + platform_devices[i] = device; + cards++; + } +#ifdef CS4232 + i = pnp_register_driver(&cs4232_pnp_driver); + if (i >= 0) { + pnp_registered = 1; + cards += i; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&cs423x_pnpc_driver); #endif + i = pnp_register_card_driver(&cs423x_pnpc_driver); + if (i >= 0) { + pnpc_registered = 1; + cards += i; + } if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&cs423x_pnpc_driver); -#endif #ifdef MODULE printk(KERN_ERR IDENT " soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cs423x_unregister_all(); + return err; } static void __exit alsa_card_cs423x_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&cs423x_pnpc_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_cs4236_legacy[idx]); + snd_cs423x_unregister_all(); } module_init(alsa_card_cs423x_init) diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 1adb88d5f8f4..e36981d64ec5 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -122,13 +122,13 @@ static unsigned char snd_cs4236_ext_map[18] = { * */ -static void snd_cs4236_ctrl_out(cs4231_t *chip, unsigned char reg, unsigned char val) +static void snd_cs4236_ctrl_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val) { outb(reg, chip->cport + 3); outb(chip->cimage[reg] = val, chip->cport + 4); } -static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg) +static unsigned char snd_cs4236_ctrl_in(struct snd_cs4231 *chip, unsigned char reg) { outb(reg, chip->cport + 3); return inb(chip->cport + 4); @@ -140,7 +140,7 @@ static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg) #define CLOCKS 8 -static ratnum_t clocks[CLOCKS] = { +static struct snd_ratnum clocks[CLOCKS] = { { .num = 16934400, .den_min = 353, .den_max = 353, .den_step = 1 }, { .num = 16934400, .den_min = 529, .den_max = 529, .den_step = 1 }, { .num = 16934400, .den_min = 617, .den_max = 617, .den_step = 1 }, @@ -151,12 +151,12 @@ static ratnum_t clocks[CLOCKS] = { { .num = 16934400/16, .den_min = 21, .den_max = 192, .den_step = 1 } }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = CLOCKS, .rats = clocks, }; -static int snd_cs4236_xrate(snd_pcm_runtime_t *runtime) +static int snd_cs4236_xrate(struct snd_pcm_runtime *runtime) { return snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_clocks); @@ -181,7 +181,7 @@ static unsigned char divisor_to_rate_register(unsigned int divisor) } } -static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char pdfr) +static void snd_cs4236_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; unsigned char rate = divisor_to_rate_register(params->rate_den); @@ -195,7 +195,7 @@ static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *para spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char cdfr) +static void snd_cs4236_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; unsigned char rate = divisor_to_rate_register(params->rate_den); @@ -211,7 +211,7 @@ static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *param #ifdef CONFIG_PM -static void snd_cs4236_suspend(cs4231_t *chip) +static void snd_cs4236_suspend(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -226,7 +226,7 @@ static void snd_cs4236_suspend(cs4231_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4236_resume(cs4231_t *chip) +static void snd_cs4236_resume(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -261,15 +261,15 @@ static void snd_cs4236_resume(cs4231_t *chip) #endif /* CONFIG_PM */ -int snd_cs4236_create(snd_card_t * card, +int snd_cs4236_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; unsigned char ver1, ver2; unsigned int reg; int err; @@ -352,9 +352,9 @@ int snd_cs4236_create(snd_card_t * card, return 0; } -int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) +int snd_cs4236_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_cs4231_pcm(chip, device, &pcm)) < 0) @@ -375,7 +375,7 @@ int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -386,9 +386,9 @@ static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -403,9 +403,9 @@ static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -432,9 +432,9 @@ static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_cs4236_get_singlec, .put = snd_cs4236_put_singlec, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -449,9 +449,9 @@ static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -478,7 +478,7 @@ static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -489,9 +489,9 @@ static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -511,9 +511,9 @@ static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -554,9 +554,9 @@ static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -576,9 +576,9 @@ static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs4236_put_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -618,9 +618,9 @@ static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) return (vol < 64) ? 63 - vol : 64 + (71 - vol); } -static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -630,9 +630,9 @@ static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem return 0; } -static int snd_cs4236_put_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1, val2; @@ -677,9 +677,9 @@ static inline int snd_cs4235_mixer_output_accu_set_volume(int vol) return 1 << 5; } -static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4235_get_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -689,9 +689,9 @@ static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return 0; } -static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1, val2; @@ -708,7 +708,7 @@ static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return change; } -static snd_kcontrol_new_t snd_cs4236_controls[] = { +static struct snd_kcontrol_new snd_cs4236_controls[] = { CS4236_DOUBLE("Master Digital Playback Switch", 0, CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), CS4236_DOUBLE("Master Digital Capture Switch", 0, CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), @@ -759,7 +759,7 @@ CS4231_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) }; -static snd_kcontrol_new_t snd_cs4235_controls[] = { +static struct snd_kcontrol_new snd_cs4235_controls[] = { CS4231_DOUBLE("Master Switch", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), CS4231_DOUBLE("Master Volume", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), @@ -812,9 +812,9 @@ CS4231_DOUBLE("Analog Loopback Switch", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT .get = snd_cs4236_get_iec958_switch, .put = snd_cs4236_put_iec958_switch, \ .private_value = 1 << 16 } -static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -832,9 +832,9 @@ static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short enable, val; @@ -868,7 +868,7 @@ static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return change; } -static snd_kcontrol_new_t snd_cs4236_iec958_controls[] = { +static struct snd_kcontrol_new snd_cs4236_iec958_controls[] = { CS4236_IEC958_ENABLE("IEC958 Output Enable", 0), CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0), CS4236_SINGLEC("IEC958 Output User", 0, 4, 5, 1, 0), @@ -877,12 +877,12 @@ CS4236_SINGLEC("IEC958 Output Channel Status Low", 0, 5, 1, 127, 0), CS4236_SINGLEC("IEC958 Output Channel Status High", 0, 6, 0, 255, 0) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4235[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4237[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Center", 0, 2, 0, 15, 1), @@ -890,19 +890,19 @@ CS4236_SINGLEC("3D Control - Mono", 0, 3, 6, 1, 0), CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4238[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Volume", 0, 2, 0, 15, 1), CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) }; -int snd_cs4236_mixer(cs4231_t *chip) +int snd_cs4236_mixer(struct snd_cs4231 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx, count; int err; - snd_kcontrol_new_t *kcontrol; + struct snd_kcontrol_new *kcontrol; snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); card = chip->card; diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c index db7c3397b323..50e7bc5ef561 100644 --- a/sound/isa/dt019x.c +++ b/sound/isa/dt019x.c @@ -74,6 +74,7 @@ struct snd_card_dt019x { struct pnp_dev *dev; struct pnp_dev *devmpu; struct pnp_dev *devopl; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_dt019x_pnpids[] = { @@ -188,15 +189,15 @@ static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_dt019x *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_dt019x))) == NULL) return -ENOMEM; - acard = (struct snd_card_dt019x *)card->private_data; + acard = card->private_data; snd_card_set_dev(card, &pcard->card->dev); if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { @@ -214,6 +215,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, snd_card_free(card); return error; } + acard->chip = chip; strcpy(card->driver, "DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X"); @@ -290,32 +292,61 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_dt019x *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_dt019x *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pnp_card_driver dt019x_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "dt019x", .id_table = snd_dt019x_pnpids, .probe = snd_dt019x_pnp_probe, .remove = __devexit_p(snd_dt019x_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_dt019x_pnp_suspend, + .resume = snd_dt019x_pnp_resume, +#endif }; static int __init alsa_card_dt019x_init(void) { int cards = 0; - cards += pnp_register_card_driver(&dt019x_pnpc_driver); - -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&dt019x_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&dt019x_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_dt019x_exit(void) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 26a7d335ed8e..50d23cf3d7cc 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -20,16 +20,17 @@ */ #include <sound/driver.h> -#include <asm/dma.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/time.h> #include <linux/wait.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/es1688.h> #include <sound/mpu401.h> #include <sound/opl3.h> -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -68,19 +69,20 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); -static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *devices[SNDRV_CARDS]; #define PFX "es1688: " -static int __init snd_audiodrive_probe(int dev) +static int __init snd_es1688_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int xirq, xdma, xmpu_irq; - snd_card_t *card; - es1688_t *chip; - opl3_t *opl3; - snd_pcm_t *pcm; + 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); @@ -105,10 +107,30 @@ static int __init snd_audiodrive_probe(int dev) } } - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xirq, xmpu_irq, xdma, - ES1688_HW_AUTO, &chip)) < 0) - goto _err; + 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 ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) goto _err; @@ -136,13 +158,12 @@ static int __init snd_audiodrive_probe(int dev) goto _err; } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_audiodrive_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -150,53 +171,70 @@ static int __init snd_audiodrive_probe(int dev) return err; } -static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport) +static int snd_es1688_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_audiodrive_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define ES1688_DRIVER "snd_es1688" + +static struct platform_driver snd_es1688_driver = { + .probe = snd_es1688_probe, + .remove = snd_es1688_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = ES1688_DRIVER + }, +}; + +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) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards = 0, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_audiodrive_probe(dev) >= 0) - cards++; + int i, cards, err; + + err = platform_driver_register(&snd_es1688_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(ES1688_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; } - i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_legacy_auto_probe); - if (i > 0) - cards += i; - if (!cards) { #ifdef MODULE printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_es1688_unregister_all(); + return err; } static void __exit alsa_card_es1688_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_audiodrive_cards[idx]); + snd_es1688_unregister_all(); } module_init(alsa_card_es1688_init) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 2edc9c9f0445..702ad51ee9d5 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -36,7 +36,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("ESS ESx688 lowlevel module"); MODULE_LICENSE("GPL"); -static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val) +static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val) { int i; @@ -51,7 +51,7 @@ static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val) return 0; } -static int snd_es1688_dsp_get_byte(es1688_t *chip) +static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip) { int i; @@ -62,7 +62,7 @@ static int snd_es1688_dsp_get_byte(es1688_t *chip) return -ENODEV; } -static int snd_es1688_write(es1688_t *chip, +static int snd_es1688_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data) { if (!snd_es1688_dsp_command(chip, reg)) @@ -70,7 +70,7 @@ static int snd_es1688_write(es1688_t *chip, return snd_es1688_dsp_command(chip, data); } -static int snd_es1688_read(es1688_t *chip, unsigned char reg) +static int snd_es1688_read(struct snd_es1688 *chip, unsigned char reg) { /* Read a byte from an extended mode register of ES1688 */ if (!snd_es1688_dsp_command(chip, 0xc0)) @@ -80,7 +80,7 @@ static int snd_es1688_read(es1688_t *chip, unsigned char reg) return snd_es1688_dsp_get_byte(chip); } -void snd_es1688_mixer_write(es1688_t *chip, +void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data) { outb(reg, ES1688P(chip, MIXER_ADDR)); @@ -89,7 +89,7 @@ void snd_es1688_mixer_write(es1688_t *chip, udelay(10); } -static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg) +static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned char reg) { unsigned char result; @@ -100,7 +100,7 @@ static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg) return result; } -static int snd_es1688_reset(es1688_t *chip) +static int snd_es1688_reset(struct snd_es1688 *chip) { int i; @@ -117,7 +117,7 @@ static int snd_es1688_reset(es1688_t *chip) return 0; } -static int snd_es1688_probe(es1688_t *chip) +static int snd_es1688_probe(struct snd_es1688 *chip) { unsigned long flags; unsigned short major, minor, hw; @@ -191,7 +191,7 @@ static int snd_es1688_probe(es1688_t *chip) return 0; } -static int snd_es1688_init(es1688_t * chip, int enable) +static int snd_es1688_init(struct snd_es1688 * chip, int enable) { static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; unsigned long flags; @@ -283,7 +283,7 @@ static int snd_es1688_init(es1688_t * chip, int enable) */ -static ratnum_t clocks[2] = { +static struct snd_ratnum clocks[2] = { { .num = 795444, .den_min = 1, @@ -298,14 +298,14 @@ static ratnum_t clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = 2, .rats = clocks, }; -static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream) +static void snd_es1688_set_rate(struct snd_es1688 *chip, struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int bits, divider; if (runtime->rate_num == clocks[0].num) @@ -319,13 +319,13 @@ static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream) snd_es1688_write(chip, 0xa2, divider); } -static int snd_es1688_ioctl(snd_pcm_substream_t * substream, +static int snd_es1688_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value) +static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value) { int val; @@ -350,22 +350,22 @@ static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value) return 0; } -static int snd_es1688_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es1688_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_es1688_hw_free(snd_pcm_substream_t * substream) +static int snd_es1688_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream) +static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -415,18 +415,18 @@ static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_playback_trigger(snd_pcm_substream_t * substream, +static int snd_es1688_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); return snd_es1688_trigger(chip, cmd, 0x05); } -static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream) +static int snd_es1688_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -472,16 +472,16 @@ static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_capture_trigger(snd_pcm_substream_t * substream, +static int snd_es1688_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); return snd_es1688_trigger(chip, cmd, 0x0f); } static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es1688_t *chip = dev_id; + struct snd_es1688 *chip = dev_id; if (chip->trigger_value == 0x05) /* ok.. playback is active */ snd_pcm_period_elapsed(chip->playback_substream); @@ -492,9 +492,9 @@ static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1688_playback_pointer(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->trigger_value != 0x05) @@ -503,9 +503,9 @@ static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1688_capture_pointer(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->trigger_value != 0x0f) @@ -518,7 +518,7 @@ static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substr */ -static snd_pcm_hardware_t snd_es1688_playback = +static struct snd_pcm_hardware snd_es1688_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -536,7 +536,7 @@ static snd_pcm_hardware_t snd_es1688_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_es1688_capture = +static struct snd_pcm_hardware snd_es1688_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -558,10 +558,10 @@ static snd_pcm_hardware_t snd_es1688_capture = */ -static int snd_es1688_playback_open(snd_pcm_substream_t * substream) +static int snd_es1688_playback_open(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->capture_substream != NULL) return -EAGAIN; @@ -572,10 +572,10 @@ static int snd_es1688_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_capture_open(snd_pcm_substream_t * substream) +static int snd_es1688_capture_open(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->playback_substream != NULL) return -EAGAIN; @@ -586,23 +586,23 @@ static int snd_es1688_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_playback_close(snd_pcm_substream_t * substream) +static int snd_es1688_playback_close(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; return 0; } -static int snd_es1688_capture_close(snd_pcm_substream_t * substream) +static int snd_es1688_capture_close(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; return 0; } -static int snd_es1688_free(es1688_t *chip) +static int snd_es1688_free(struct snd_es1688 *chip) { if (chip->res_port) { snd_es1688_init(chip, 0); @@ -618,33 +618,33 @@ static int snd_es1688_free(es1688_t *chip) return 0; } -static int snd_es1688_dev_free(snd_device_t *device) +static int snd_es1688_dev_free(struct snd_device *device) { - es1688_t *chip = device->device_data; + struct snd_es1688 *chip = device->device_data; return snd_es1688_free(chip); } -static const char *snd_es1688_chip_id(es1688_t *chip) +static const char *snd_es1688_chip_id(struct snd_es1688 *chip) { static char tmp[16]; sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f); return tmp; } -int snd_es1688_create(snd_card_t * card, +int snd_es1688_create(struct snd_card *card, unsigned long port, unsigned long mpu_port, int irq, int mpu_irq, int dma8, unsigned short hardware, - es1688_t **rchip) + struct snd_es1688 **rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_es1688_dev_free, }; - es1688_t *chip; + struct snd_es1688 *chip; int err; *rchip = NULL; @@ -702,7 +702,7 @@ int snd_es1688_create(snd_card_t * card, return 0; } -static snd_pcm_ops_t snd_es1688_playback_ops = { +static struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, .ioctl = snd_es1688_ioctl, @@ -713,7 +713,7 @@ static snd_pcm_ops_t snd_es1688_playback_ops = { .pointer = snd_es1688_playback_pointer, }; -static snd_pcm_ops_t snd_es1688_capture_ops = { +static struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, .ioctl = snd_es1688_ioctl, @@ -724,16 +724,9 @@ static snd_pcm_ops_t snd_es1688_capture_ops = { .pointer = snd_es1688_capture_pointer, }; -static void snd_es1688_pcm_free(snd_pcm_t *pcm) +int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm) { - es1688_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) -{ - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) @@ -743,7 +736,6 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1688_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_es1688_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; sprintf(pcm->name, snd_es1688_chip_id(chip)); chip->pcm = pcm; @@ -761,7 +753,7 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) * MIXER part */ -static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[9] = { "Mic", "Mic Master", "CD", "AOUT", @@ -777,16 +769,16 @@ static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_es1688_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7; return 0; } -static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval, nval; int change; @@ -809,7 +801,7 @@ static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_es1688_get_single, .put = snd_es1688_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -820,9 +812,9 @@ static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -837,9 +829,9 @@ static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -868,7 +860,7 @@ static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_es1688_get_double, .put = snd_es1688_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -879,9 +871,9 @@ static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -913,9 +905,9 @@ static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -976,7 +968,7 @@ static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_es1688_controls[] = { +static struct snd_kcontrol_new snd_es1688_controls[] = { ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0), ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0), ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0), @@ -1011,9 +1003,9 @@ static unsigned char snd_es1688_init_table[][2] = { { ES1688_REC_DEV, 0x17 } }; -int snd_es1688_mixer(es1688_t *chip) +int snd_es1688_mixer(struct snd_es1688 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; unsigned char reg, val; diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 970e2aaade27..bf5de0782eb0 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -65,28 +65,28 @@ #include <sound/driver.h> -#include <asm/io.h> -#include <asm/dma.h> #include <linux/init.h> -#include <linux/pm.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/pnp.h> #include <linux/isapnp.h> #include <linux/moduleparam.h> +#include <asm/io.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/control.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/mpu401.h> #include <sound/opl3.h> -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> #define PFX "es18xx: " -struct _snd_es18xx { +struct snd_es18xx { unsigned long port; /* port of ESS chip */ unsigned long mpu_port; /* MPU-401 port of ESS chip */ unsigned long fm_port; /* FM port */ @@ -107,18 +107,18 @@ struct _snd_es18xx { unsigned int dma1_shift; unsigned int dma2_shift; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_a_substream; - snd_pcm_substream_t *capture_a_substream; - snd_pcm_substream_t *playback_b_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_a_substream; + struct snd_pcm_substream *capture_a_substream; + struct snd_pcm_substream *playback_b_substream; - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; - snd_kcontrol_t *hw_volume; - snd_kcontrol_t *hw_switch; - snd_kcontrol_t *master_volume; - snd_kcontrol_t *master_switch; + struct snd_kcontrol *hw_volume; + struct snd_kcontrol *hw_switch; + struct snd_kcontrol *master_volume; + struct snd_kcontrol *master_switch; spinlock_t reg_lock; spinlock_t mixer_lock; @@ -128,6 +128,14 @@ struct _snd_es18xx { #endif }; +struct snd_audiodrive { + struct snd_es18xx *chip; +#ifdef CONFIG_PNP + struct pnp_dev *dev; + struct pnp_dev *devc; +#endif +}; + #define AUDIO1_IRQ 0x01 #define AUDIO2_IRQ 0x02 #define HWV_IRQ 0x04 @@ -155,8 +163,6 @@ struct _snd_es18xx { #define ES18XX_PM_FM 0x020 #define ES18XX_PM_SUS 0x080 -typedef struct _snd_es18xx es18xx_t; - /* Lowlevel */ #define DAC1 0x01 @@ -164,7 +170,7 @@ typedef struct _snd_es18xx es18xx_t; #define DAC2 0x04 #define MILLISECOND 10000 -static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val) +static int snd_es18xx_dsp_command(struct snd_es18xx *chip, unsigned char val) { int i; @@ -177,7 +183,7 @@ static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val) return -EINVAL; } -static int snd_es18xx_dsp_get_byte(es18xx_t *chip) +static int snd_es18xx_dsp_get_byte(struct snd_es18xx *chip) { int i; @@ -191,7 +197,7 @@ static int snd_es18xx_dsp_get_byte(es18xx_t *chip) #undef REG_DEBUG -static int snd_es18xx_write(es18xx_t *chip, +static int snd_es18xx_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; @@ -210,7 +216,7 @@ static int snd_es18xx_write(es18xx_t *chip, return ret; } -static int snd_es18xx_read(es18xx_t *chip, unsigned char reg) +static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int ret, data; @@ -232,7 +238,7 @@ static int snd_es18xx_read(es18xx_t *chip, unsigned char reg) } /* Return old value */ -static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg, +static int snd_es18xx_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { int ret; @@ -270,7 +276,7 @@ static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg, return ret; } -static inline void snd_es18xx_mixer_write(es18xx_t *chip, +static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; @@ -283,7 +289,7 @@ static inline void snd_es18xx_mixer_write(es18xx_t *chip, #endif } -static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg) +static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int data; @@ -298,7 +304,7 @@ static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg) } /* Return old value */ -static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg, +static inline int snd_es18xx_mixer_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { unsigned char old, new, oval; @@ -319,7 +325,7 @@ static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg, return oval; } -static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg, +static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned char reg, unsigned char mask) { int old, expected, new; @@ -339,7 +345,7 @@ static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg, } -static int snd_es18xx_reset(es18xx_t *chip) +static int snd_es18xx_reset(struct snd_es18xx *chip) { int i; outb(0x03, chip->port + 0x06); @@ -351,7 +357,7 @@ static int snd_es18xx_reset(es18xx_t *chip) return 0; } -static int snd_es18xx_reset_fifo(es18xx_t *chip) +static int snd_es18xx_reset_fifo(struct snd_es18xx *chip) { outb(0x02, chip->port + 0x06); inb(chip->port + 0x06); @@ -359,7 +365,7 @@ static int snd_es18xx_reset_fifo(es18xx_t *chip) return 0; } -static ratnum_t new_clocks[2] = { +static struct snd_ratnum new_clocks[2] = { { .num = 793800, .den_min = 1, @@ -374,12 +380,12 @@ static ratnum_t new_clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t new_hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = { .nrats = 2, .rats = new_clocks, }; -static ratnum_t old_clocks[2] = { +static struct snd_ratnum old_clocks[2] = { { .num = 795444, .den_min = 1, @@ -394,18 +400,18 @@ static ratnum_t old_clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t old_hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks = { .nrats = 2, .rats = old_clocks, }; -static void snd_es18xx_rate_set(es18xx_t *chip, - snd_pcm_substream_t *substream, +static void snd_es18xx_rate_set(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int mode) { unsigned int bits, div0; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->caps & ES18XX_NEW_RATE) { if (runtime->rate_num == new_clocks[0].num) bits = 128 - runtime->rate_den; @@ -435,10 +441,10 @@ static void snd_es18xx_rate_set(es18xx_t *chip, } } -static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; @@ -463,15 +469,15 @@ static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_es18xx_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_es18xx_playback1_prepare(es18xx_t *chip, - snd_pcm_substream_t *substream) +static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -496,8 +502,8 @@ static int snd_es18xx_playback1_prepare(es18xx_t *chip, return 0; } -static int snd_es18xx_playback1_trigger(es18xx_t *chip, - snd_pcm_substream_t * substream, +static int snd_es18xx_playback1_trigger(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int cmd) { switch (cmd) { @@ -546,10 +552,10 @@ static int snd_es18xx_playback1_trigger(es18xx_t *chip, return 0; } -static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; @@ -569,10 +575,10 @@ static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream) +static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -608,10 +614,10 @@ static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream, +static int snd_es18xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -637,10 +643,10 @@ static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_es18xx_playback2_prepare(es18xx_t *chip, - snd_pcm_substream_t *substream) +static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -674,8 +680,8 @@ static int snd_es18xx_playback2_prepare(es18xx_t *chip, return 0; } -static int snd_es18xx_playback2_trigger(es18xx_t *chip, - snd_pcm_substream_t *substream, +static int snd_es18xx_playback2_trigger(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int cmd) { switch (cmd) { @@ -714,19 +720,19 @@ static int snd_es18xx_playback2_trigger(es18xx_t *chip, return 0; } -static int snd_es18xx_playback_prepare(snd_pcm_substream_t *substream) +static int snd_es18xx_playback_prepare(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) return snd_es18xx_playback1_prepare(chip, substream); else return snd_es18xx_playback2_prepare(chip, substream); } -static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream, +static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) return snd_es18xx_playback1_trigger(chip, substream, cmd); else @@ -735,7 +741,7 @@ static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream, static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es18xx_t *chip = dev_id; + struct snd_es18xx *chip = dev_id; unsigned char status; if (chip->caps & ES18XX_CONTROL) { @@ -795,9 +801,9 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int pos; if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { @@ -813,9 +819,9 @@ static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * subst } } -static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int pos; if (!(chip->active & ADC1)) @@ -824,7 +830,7 @@ static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substr return pos >> chip->dma1_shift; } -static snd_pcm_hardware_t snd_es18xx_playback = +static struct snd_pcm_hardware snd_es18xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | @@ -844,7 +850,7 @@ static snd_pcm_hardware_t snd_es18xx_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_es18xx_capture = +static struct snd_pcm_hardware snd_es18xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | @@ -864,10 +870,10 @@ static snd_pcm_hardware_t snd_es18xx_capture = .fifo_size = 0, }; -static int snd_es18xx_playback_open(snd_pcm_substream_t * substream) +static int snd_es18xx_playback_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { if ((chip->caps & ES18XX_DUPLEX_MONO) && @@ -889,10 +895,10 @@ static int snd_es18xx_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_capture_open(snd_pcm_substream_t * substream) +static int snd_es18xx_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (chip->playback_b_substream) return -EAGAIN; @@ -907,9 +913,9 @@ static int snd_es18xx_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_playback_close(snd_pcm_substream_t * substream) +static int snd_es18xx_playback_close(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) chip->playback_a_substream = NULL; @@ -920,9 +926,9 @@ static int snd_es18xx_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_capture_close(snd_pcm_substream_t * substream) +static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); chip->capture_a_substream = NULL; snd_pcm_lib_free_pages(substream); @@ -933,7 +939,7 @@ static int snd_es18xx_capture_close(snd_pcm_substream_t * substream) * MIXER part */ -static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "Mic", "Mic Master", "CD", "AOUT", @@ -949,16 +955,16 @@ static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_es18xx_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = snd_es18xx_mixer_read(chip, 0x1c) & 0x07; return 0; } -static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char val = ucontrol->value.enumerated.item[0]; if (val > 7) @@ -966,7 +972,7 @@ static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return snd_es18xx_mixer_bits(chip, 0x1c, 0x07, val) != val; } -static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -975,17 +981,17 @@ static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_es18xx_get_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char val = snd_es18xx_mixer_read(chip, 0x50); ucontrol->value.integer.value[0] = !!(val & 8); return 0; } -static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char oval, nval; int change; nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; @@ -998,7 +1004,7 @@ static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_ return change; } -static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1007,15 +1013,15 @@ static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es18xx_get_hw_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = snd_es18xx_mixer_read(chip, 0x61) & 0x3f; ucontrol->value.integer.value[1] = snd_es18xx_mixer_read(chip, 0x63) & 0x3f; return 0; } -static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -1024,24 +1030,24 @@ static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es18xx_get_hw_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = !(snd_es18xx_mixer_read(chip, 0x61) & 0x40); ucontrol->value.integer.value[1] = !(snd_es18xx_mixer_read(chip, 0x63) & 0x40); return 0; } -static void snd_es18xx_hwv_free(snd_kcontrol_t *kcontrol) +static void snd_es18xx_hwv_free(struct snd_kcontrol *kcontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); chip->master_volume = NULL; chip->master_switch = NULL; chip->hw_volume = NULL; chip->hw_switch = NULL; } -static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg, +static int snd_es18xx_reg_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { if (reg < 0xa0) @@ -1050,7 +1056,7 @@ static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg, return snd_es18xx_bits(chip, reg, mask, val); } -static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg) +static int snd_es18xx_reg_read(struct snd_es18xx *chip, unsigned char reg) { if (reg < 0xa0) return snd_es18xx_mixer_read(chip, reg); @@ -1064,7 +1070,7 @@ static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg) .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1075,9 +1081,9 @@ static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1091,9 +1097,9 @@ static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1114,7 +1120,7 @@ static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_es18xx_get_double, .put = snd_es18xx_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1125,9 +1131,9 @@ static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1150,9 +1156,9 @@ static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1185,7 +1191,7 @@ static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_es18xx_base_controls[] = { +static struct snd_kcontrol_new snd_es18xx_base_controls[] = { ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), @@ -1207,10 +1213,10 @@ ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), } }; -static snd_kcontrol_new_t snd_es18xx_mono_in_control = +static struct snd_kcontrol_new snd_es18xx_mono_in_control = ES18XX_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0); -static snd_kcontrol_new_t snd_es18xx_recmix_controls[] = { +static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), @@ -1220,16 +1226,16 @@ ES18XX_DOUBLE("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0), ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) }; -static snd_kcontrol_new_t snd_es18xx_pcm1_controls[] = { +static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0), }; -static snd_kcontrol_new_t snd_es18xx_pcm2_controls[] = { +static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0) }; -static snd_kcontrol_new_t snd_es18xx_spatializer_controls[] = { +static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -1240,13 +1246,13 @@ ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), } }; -static snd_kcontrol_new_t snd_es18xx_micpre1_control = +static struct snd_kcontrol_new snd_es18xx_micpre1_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0); -static snd_kcontrol_new_t snd_es18xx_micpre2_control = +static struct snd_kcontrol_new snd_es18xx_micpre2_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0); -static snd_kcontrol_new_t snd_es18xx_hw_volume_controls[] = { +static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Hardware Master Playback Volume", @@ -1265,7 +1271,7 @@ ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), }; #if 0 -static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) +static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) { int data; unsigned long flags; @@ -1277,7 +1283,7 @@ static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) } #endif -static void __devinit snd_es18xx_config_write(es18xx_t *chip, +static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { /* No need for spinlocks, this function is used only in @@ -1289,7 +1295,7 @@ static void __devinit snd_es18xx_config_write(es18xx_t *chip, #endif } -static int __devinit snd_es18xx_initialize(es18xx_t *chip) +static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) { int mask = 0; @@ -1438,7 +1444,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip) return 0; } -static int __devinit snd_es18xx_identify(es18xx_t *chip) +static int __devinit snd_es18xx_identify(struct snd_es18xx *chip) { int hi,lo; @@ -1504,7 +1510,7 @@ static int __devinit snd_es18xx_identify(es18xx_t *chip) return 0; } -static int __devinit snd_es18xx_probe(es18xx_t *chip) +static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) { if (snd_es18xx_identify(chip) < 0) { snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); @@ -1544,7 +1550,7 @@ static int __devinit snd_es18xx_probe(es18xx_t *chip) return snd_es18xx_initialize(chip); } -static snd_pcm_ops_t snd_es18xx_playback_ops = { +static struct snd_pcm_ops snd_es18xx_playback_ops = { .open = snd_es18xx_playback_open, .close = snd_es18xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1555,7 +1561,7 @@ static snd_pcm_ops_t snd_es18xx_playback_ops = { .pointer = snd_es18xx_playback_pointer, }; -static snd_pcm_ops_t snd_es18xx_capture_ops = { +static struct snd_pcm_ops snd_es18xx_capture_ops = { .open = snd_es18xx_capture_open, .close = snd_es18xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1566,27 +1572,19 @@ static snd_pcm_ops_t snd_es18xx_capture_ops = { .pointer = snd_es18xx_capture_pointer, }; -static void snd_es18xx_pcm_free(snd_pcm_t *pcm) -{ - es18xx_t *codec = pcm->private_data; - codec->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm) +static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; char str[16]; int err; if (rpcm) *rpcm = NULL; sprintf(str, "ES%x", chip->version); - if (chip->caps & ES18XX_PCM2) { + if (chip->caps & ES18XX_PCM2) err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); - } else { + else err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); - } if (err < 0) return err; @@ -1595,7 +1593,6 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc /* global setup */ pcm->private_data = chip; - pcm->private_free = snd_es18xx_pcm_free; pcm->info_flags = 0; if (chip->caps & ES18XX_DUPLEX_SAME) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; @@ -1616,9 +1613,12 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc /* Power Management support functions */ #ifdef CONFIG_PM -static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state) +static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) { - es18xx_t *chip = card->pm_private_data; + struct snd_audiodrive *acard = card->private_data; + struct snd_es18xx *chip = acard->chip; + + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); @@ -1631,18 +1631,20 @@ static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_es18xx_resume(snd_card_t *card) +static int snd_es18xx_resume(struct snd_card *card) { - es18xx_t *chip = card->pm_private_data; + struct snd_audiodrive *acard = card->private_data; + struct snd_es18xx *chip = acard->chip; /* restore PM register, we won't wake till (not 0x07) i/o activity though */ snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ -static int snd_es18xx_free(es18xx_t *chip) +static int snd_es18xx_free(struct snd_es18xx *chip) { release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_ctrl_port); @@ -1661,21 +1663,21 @@ static int snd_es18xx_free(es18xx_t *chip) return 0; } -static int snd_es18xx_dev_free(snd_device_t *device) +static int snd_es18xx_dev_free(struct snd_device *device) { - es18xx_t *chip = device->device_data; + struct snd_es18xx *chip = device->device_data; return snd_es18xx_free(chip); } -static int __devinit snd_es18xx_new_device(snd_card_t * card, +static int __devinit snd_es18xx_new_device(struct snd_card *card, unsigned long port, unsigned long mpu_port, unsigned long fm_port, int irq, int dma1, int dma2, - es18xx_t ** rchip) + struct snd_es18xx ** rchip) { - es18xx_t *chip; - static snd_device_ops_t ops = { + struct snd_es18xx *chip; + static struct snd_device_ops ops = { .dev_free = snd_es18xx_dev_free, }; int err; @@ -1736,9 +1738,9 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card, return 0; } -static int __devinit snd_es18xx_mixer(es18xx_t *chip) +static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) { - snd_card_t *card; + struct snd_card *card; int err; unsigned int idx; @@ -1747,7 +1749,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip) strcpy(card->mixername, chip->pcm->name); for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip); if (chip->caps & ES18XX_HWV) { switch (idx) { @@ -1805,7 +1807,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip) } if (chip->caps & ES18XX_HWV) { for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip); if (idx == 0) chip->hw_volume = kctl; @@ -1875,14 +1877,8 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); -struct snd_audiodrive { -#ifdef CONFIG_PNP - struct pnp_dev *dev; - struct pnp_dev *devc; -#endif -}; - -static snd_card_t *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; #ifdef CONFIG_PNP @@ -1989,227 +1985,281 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, #define is_isapnp_selected(dev) 0 #endif -static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_es18xx_card_new(int dev) { - static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; - static int possible_dmas[] = {1, 0, 3, 5, -1}; - int xirq, xdma1, xdma2; - snd_card_t *card; - struct snd_audiodrive *acard; - es18xx_t *chip; - opl3_t *opl3; - int err; - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, + return snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_audiodrive)); - if (card == NULL) - return -ENOMEM; - acard = (struct snd_audiodrive *)card->private_data; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_audiodrive_pnp(dev, acard, pcard, pid)) < 0) { - snd_card_free(card); - return err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif +} - 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; - } - } +static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) +{ + struct snd_audiodrive *acard = card->private_data; + struct snd_es18xx *chip; + struct snd_opl3 *opl3; + int err; if ((err = snd_es18xx_new_device(card, port[dev], mpu_port[dev], fm_port[dev], - xirq, xdma1, xdma2, + irq[dev], dma1[dev], dma2[dev], &chip)) < 0) - goto _err; + return err; + acard->chip = chip; sprintf(card->driver, "ES%x", chip->version); + sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version); - if (xdma1 != xdma2) + if (dma1[dev] != dma2[dev]) sprintf(card->longname, "%s at 0x%lx, irq %d, dma1 %d, dma2 %d", card->shortname, chip->port, - xirq, xdma1, xdma2); + irq[dev], dma1[dev], dma2[dev]); else sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", card->shortname, chip->port, - xirq, xdma1); + irq[dev], dma1[dev]); if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) - goto _err; + return err; if ((err = snd_es18xx_mixer(chip)) < 0) - goto _err; + return err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) - goto _err; + return err; } } if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, chip->mpu_port, 0, - xirq, 0, + irq[dev], 0, &chip->rmidi)) < 0) - goto _err; + return err; } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - - /* Power Management */ - snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip); + return snd_card_register(card); +} - if ((err = snd_card_register(card)) < 0) - goto _err; +static int __init snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card *card; + int err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_audiodrive_legacy[dev] = card; + card = snd_es18xx_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_audiodrive_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); return 0; - - _err: - snd_card_free(card); - return err; } -static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) +static int __init snd_es18xx_nonpnp_probe(struct platform_device *pdev) { - static int dev; - int res; + 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}; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - port[dev] = xport; - res = snd_audiodrive_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma1[dev] == SNDRV_AUTO_DMA) { + if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[dev] == SNDRV_AUTO_DMA) { + if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) { + return snd_es18xx_nonpnp_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); + if (! err) + return 0; + } + return err; } - return -ENODEV; } +static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_es18xx_suspend(platform_get_drvdata(dev), state); +} + +static int snd_es18xx_nonpnp_resume(struct platform_device *dev) +{ + return snd_es18xx_resume(platform_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), +#ifdef CONFIG_PM + .suspend = snd_es18xx_nonpnp_suspend, + .resume = snd_es18xx_nonpnp_resume, +#endif + .driver = { + .name = ES18XX_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_audiodrive_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; - return -ENODEV; + card = snd_es18xx_card_new(dev); + if (! card) + return -ENOMEM; + + if ((res = snd_audiodrive_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_audiodrive_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_audiodrive_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_es18xx_suspend(pnp_get_card_drvdata(pcard), state); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +static int snd_audiodrive_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_es18xx_resume(pnp_get_card_drvdata(pcard)); } +#endif + static struct pnp_card_driver es18xx_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "es18xx", .id_table = snd_audiodrive_pnpids, .probe = snd_audiodrive_pnp_detect, .remove = __devexit_p(snd_audiodrive_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_audiodrive_pnp_suspend, + .resume = snd_audiodrive_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_es18xx_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&es18xx_pnpc_driver); + 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) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1}; - int dev, cards = 0, i; + int i, err, cards = 0; - /* legacy non-auto cards at first */ - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(ES18XX_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + platform_devices[i] = device; + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_probe_legacy_port); - if (i > 0) - cards += i; -#ifdef CONFIG_PNP - /* ISA PnP cards at last */ i = pnp_register_card_driver(&es18xx_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } -#endif if(!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&es18xx_pnpc_driver); -#endif #ifdef MODULE snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_es18xx_unregister_all(); + return err; } static void __exit alsa_card_es18xx_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&es18xx_pnpc_driver); -#endif - for(idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_audiodrive_legacy[idx]); + snd_es18xx_unregister_all(); } module_init(alsa_card_es18xx_init) diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c index ef1b2e9832e4..930f4bc56f34 100644 --- a/sound/isa/gus/gus_dma.c +++ b/sound/isa/gus/gus_dma.c @@ -25,7 +25,7 @@ #include <sound/core.h> #include <sound/gus.h> -static void snd_gf1_dma_ack(snd_gus_card_t * gus) +static void snd_gf1_dma_ack(struct snd_gus_card * gus) { unsigned long flags; @@ -35,7 +35,7 @@ static void snd_gf1_dma_ack(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_dma_program(snd_gus_card_t * gus, +static void snd_gf1_dma_program(struct snd_gus_card * gus, unsigned int addr, unsigned long buf_addr, unsigned int count, @@ -91,9 +91,9 @@ static void snd_gf1_dma_program(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus) +static struct snd_gf1_dma_block *snd_gf1_dma_next_block(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; /* PCM block have bigger priority than synthesizer one */ if (gus->gf1.dma_data_pcm) { @@ -123,9 +123,9 @@ static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus) } -static void snd_gf1_dma_interrupt(snd_gus_card_t * gus) +static void snd_gf1_dma_interrupt(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; snd_gf1_dma_ack(gus); if (gus->gf1.dma_ack) @@ -147,7 +147,7 @@ static void snd_gf1_dma_interrupt(snd_gus_card_t * gus) #endif } -int snd_gf1_dma_init(snd_gus_card_t * gus) +int snd_gf1_dma_init(struct snd_gus_card * gus) { down(&gus->dma_mutex); gus->gf1.dma_shared++; @@ -164,9 +164,9 @@ int snd_gf1_dma_init(snd_gus_card_t * gus) return 0; } -int snd_gf1_dma_done(snd_gus_card_t * gus) +int snd_gf1_dma_done(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; down(&gus->dma_mutex); gus->gf1.dma_shared--; @@ -189,13 +189,13 @@ int snd_gf1_dma_done(snd_gus_card_t * gus) return 0; } -int snd_gf1_dma_transfer_block(snd_gus_card_t * gus, - snd_gf1_dma_block_t * __block, +int snd_gf1_dma_transfer_block(struct snd_gus_card * gus, + struct snd_gf1_dma_block * __block, int atomic, int synth) { unsigned long flags; - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL); if (block == NULL) { diff --git a/sound/isa/gus/gus_dram.c b/sound/isa/gus/gus_dram.c index 22120b868b5c..f22fe7967fcc 100644 --- a/sound/isa/gus/gus_dram.c +++ b/sound/isa/gus/gus_dram.c @@ -26,7 +26,7 @@ #include <sound/info.h> -static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer, +static int snd_gus_dram_poke(struct snd_gus_card *gus, char __user *_buffer, unsigned int address, unsigned int size) { unsigned long flags; @@ -57,13 +57,13 @@ static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer, } -int snd_gus_dram_write(snd_gus_card_t *gus, char __user *buffer, +int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer, unsigned int address, unsigned int size) { return snd_gus_dram_poke(gus, buffer, address, size); } -static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer, +static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer, unsigned int address, unsigned int size, int rom) { @@ -95,7 +95,7 @@ static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer, return 0; } -int snd_gus_dram_read(snd_gus_card_t *gus, char __user *buffer, +int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer, unsigned int address, unsigned int size, int rom) { diff --git a/sound/isa/gus/gus_instr.c b/sound/isa/gus/gus_instr.c index 591a9a17feb5..d0c38e1856ef 100644 --- a/sound/isa/gus/gus_instr.c +++ b/sound/isa/gus/gus_instr.c @@ -28,11 +28,11 @@ * */ -int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (wave->format & IWFFFF_WAVE_ROM) @@ -58,19 +58,19 @@ int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, return 0; } -int snd_gus_iwffff_get_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, wave->format & IWFFFF_WAVE_ROM ? 1 : 0); } -int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; if (wave->format & IWFFFF_WAVE_ROM) return 0; /* it's probably ok - verify the address? */ @@ -81,11 +81,11 @@ int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, * */ -int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (wave->format & GF1_WAVE_STEREO) @@ -109,18 +109,18 @@ int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, return 0; } -int snd_gus_gf1_get_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0); } -int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); } @@ -129,11 +129,11 @@ int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, * */ -int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (instr->format & SIMPLE_WAVE_STEREO) @@ -156,18 +156,18 @@ int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, return 0; } -int snd_gus_simple_get_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0); } -int snd_gus_simple_remove_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory); } diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c index 8d5752b23787..9b1fe292de4d 100644 --- a/sound/isa/gus/gus_io.c +++ b/sound/isa/gus/gus_io.c @@ -25,7 +25,7 @@ #include <sound/core.h> #include <sound/gus.h> -void snd_gf1_delay(snd_gus_card_t * gus) +void snd_gf1_delay(struct snd_gus_card * gus) { int i; @@ -44,7 +44,7 @@ void snd_gf1_delay(snd_gus_card_t * gus) * big UltraClick (tm) elimination... */ -static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +static inline void __snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { unsigned char value; @@ -58,7 +58,7 @@ static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) mb(); } -static inline void __snd_gf1_write8(snd_gus_card_t * gus, +static inline void __snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -68,7 +68,7 @@ static inline void __snd_gf1_write8(snd_gus_card_t * gus, mb(); } -static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus, +static inline unsigned char __snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg) { outb(reg, gus->gf1.reg_regsel); @@ -76,7 +76,7 @@ static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus, return inb(gus->gf1.reg_data8); } -static inline void __snd_gf1_write16(snd_gus_card_t * gus, +static inline void __snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { outb(reg, gus->gf1.reg_regsel); @@ -85,7 +85,7 @@ static inline void __snd_gf1_write16(snd_gus_card_t * gus, mb(); } -static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus, +static inline unsigned short __snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg) { outb(reg, gus->gf1.reg_regsel); @@ -93,7 +93,7 @@ static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus, return inw(gus->gf1.reg_data16); } -static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus, +static inline void __snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { outb(reg, gus->gf1.reg_timerctrl); @@ -104,7 +104,7 @@ static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus, inb(gus->gf1.reg_timerctrl); } -static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, +static inline void __snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, int w_16bit) { if (gus->gf1.enh_mode) { @@ -117,7 +117,7 @@ static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, __snd_gf1_write16(gus, reg + 1, (unsigned short) (addr << 5)); } -static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus, +static inline unsigned int __snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { unsigned int res; @@ -138,49 +138,49 @@ static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus, * ======================================================================= */ -void snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { __snd_gf1_ctrl_stop(gus, reg); } -void snd_gf1_write8(snd_gus_card_t * gus, +void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { __snd_gf1_write8(gus, reg, data); } -unsigned char snd_gf1_look8(snd_gus_card_t * gus, unsigned char reg) +unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg) { return __snd_gf1_look8(gus, reg); } -void snd_gf1_write16(snd_gus_card_t * gus, +void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { __snd_gf1_write16(gus, reg, data); } -unsigned short snd_gf1_look16(snd_gus_card_t * gus, unsigned char reg) +unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg) { return __snd_gf1_look16(gus, reg); } -void snd_gf1_adlib_write(snd_gus_card_t * gus, +void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { __snd_gf1_adlib_write(gus, reg, data); } -void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, +void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit) { __snd_gf1_write_addr(gus, reg, addr, w_16bit); } -unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, +unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { @@ -191,7 +191,7 @@ unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, */ -void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; @@ -200,7 +200,7 @@ void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_i_write8(snd_gus_card_t * gus, +void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -211,7 +211,7 @@ void snd_gf1_i_write8(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg) +unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; unsigned char res; @@ -222,7 +222,7 @@ unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg) return res; } -void snd_gf1_i_write16(snd_gus_card_t * gus, +void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { @@ -233,7 +233,7 @@ void snd_gf1_i_write16(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) +unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; unsigned short res; @@ -246,7 +246,7 @@ unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) #if 0 -void snd_gf1_i_adlib_write(snd_gus_card_t * gus, +void snd_gf1_i_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -257,7 +257,7 @@ void snd_gf1_i_adlib_write(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, +void snd_gf1_i_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit) { unsigned long flags; @@ -270,7 +270,7 @@ void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, #endif /* 0 */ #ifdef CONFIG_SND_DEBUG -static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, +static unsigned int snd_gf1_i_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { unsigned int res; @@ -287,7 +287,7 @@ static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, */ -void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr) +void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr) { outb(0x43, gus->gf1.reg_regsel); mb(); @@ -299,7 +299,7 @@ void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr) mb(); } -void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data) +void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data) { unsigned long flags; @@ -316,7 +316,7 @@ void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data) spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) +unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr) { unsigned long flags; unsigned char res; @@ -337,7 +337,7 @@ unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) #if 0 -void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) +void snd_gf1_pokew(struct snd_gus_card * gus, unsigned int addr, unsigned short data) { unsigned long flags; @@ -360,7 +360,7 @@ void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr) +unsigned short snd_gf1_peekw(struct snd_gus_card * gus, unsigned int addr) { unsigned long flags; unsigned short res; @@ -385,7 +385,7 @@ unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr) return res; } -void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, +void snd_gf1_dram_setmem(struct snd_gus_card * gus, unsigned int addr, unsigned short value, unsigned int count) { unsigned long port; @@ -415,7 +415,7 @@ void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, #endif /* 0 */ -void snd_gf1_select_active_voices(snd_gus_card_t * gus) +void snd_gf1_select_active_voices(struct snd_gus_card * gus) { unsigned short voices; @@ -443,7 +443,7 @@ void snd_gf1_select_active_voices(snd_gus_card_t * gus) #ifdef CONFIG_SND_DEBUG -void snd_gf1_print_voice_registers(snd_gus_card_t * gus) +void snd_gf1_print_voice_registers(struct snd_gus_card * gus) { unsigned char mode; int voice, ctrl; @@ -477,7 +477,7 @@ void snd_gf1_print_voice_registers(snd_gus_card_t * gus) #if 0 -void snd_gf1_print_global_registers(snd_gus_card_t * gus) +void snd_gf1_print_global_registers(struct snd_gus_card * gus) { unsigned char global_mode = 0x00; @@ -504,7 +504,7 @@ void snd_gf1_print_global_registers(snd_gus_card_t * gus) } } -void snd_gf1_print_setup_registers(snd_gus_card_t * gus) +void snd_gf1_print_setup_registers(struct snd_gus_card * gus) { printk(KERN_INFO " -S- mix control = 0x%x\n", inb(GUSP(gus, MIXCNTRLREG))); printk(KERN_INFO " -S- IRQ status = 0x%x\n", inb(GUSP(gus, IRQSTAT))); @@ -523,7 +523,7 @@ void snd_gf1_print_setup_registers(snd_gus_card_t * gus) } } -void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count, int w_16bit) +void snd_gf1_peek_print_block(struct snd_gus_card * gus, unsigned int addr, int count, int w_16bit) { if (!w_16bit) { while (count-- > 0) diff --git a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c index 1e2a15eb8106..c19ba2910b72 100644 --- a/sound/isa/gus/gus_irq.c +++ b/sound/isa/gus/gus_irq.c @@ -32,7 +32,7 @@ irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - snd_gus_card_t * gus = dev_id; + struct snd_gus_card * gus = dev_id; unsigned char status; int loop = 100; int handled = 0; @@ -54,7 +54,7 @@ __again: if (status & (0x20 | 0x40)) { unsigned int already, _current_; unsigned char voice_status, voice; - snd_gus_voice_t *pvoice; + struct snd_gus_voice *pvoice; already = 0; while (((voice_status = snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ)) & 0xc0) != 0xc0) { @@ -107,11 +107,11 @@ __again: } #ifdef CONFIG_SND_DEBUG -static void snd_gus_irq_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_gus_irq_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_gus_card_t *gus; - snd_gus_voice_t *pvoice; + struct snd_gus_card *gus; + struct snd_gus_voice *pvoice; int idx; gus = entry->private_data; @@ -131,9 +131,9 @@ static void snd_gus_irq_info_read(snd_info_entry_t *entry, } } -void snd_gus_irq_profile_init(snd_gus_card_t *gus) +void snd_gus_irq_profile_init(struct snd_gus_card *gus) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(gus->card, "gusirq", &entry)) snd_info_set_text_ops(entry, gus, 1024, snd_gus_irq_info_read); diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 4f57ff4ab351..6d15b3d18a87 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -35,21 +35,21 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards"); MODULE_LICENSE("GPL"); -static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); +static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches); -int snd_gus_use_inc(snd_gus_card_t * gus) +int snd_gus_use_inc(struct snd_gus_card * gus) { if (!try_module_get(gus->card->module)) return 0; return 1; } -void snd_gus_use_dec(snd_gus_card_t * gus) +void snd_gus_use_dec(struct snd_gus_card * gus) { module_put(gus->card->module); } -static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gus_joystick_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -58,17 +58,17 @@ static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_gus_joystick_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gus_joystick_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = gus->joystick_dac & 31; return 0; } -static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gus_joystick_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval; @@ -82,7 +82,7 @@ static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_gus_joystick_control = { +static struct snd_kcontrol_new snd_gus_joystick_control = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "Joystick Speed", .info = snd_gus_joystick_info, @@ -90,7 +90,7 @@ static snd_kcontrol_new_t snd_gus_joystick_control = { .put = snd_gus_joystick_put }; -static void snd_gus_init_control(snd_gus_card_t *gus) +static void snd_gus_init_control(struct snd_gus_card *gus) { if (!gus->ace_flag) snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus)); @@ -100,7 +100,7 @@ static void snd_gus_init_control(snd_gus_card_t *gus) * */ -static int snd_gus_free(snd_gus_card_t *gus) +static int snd_gus_free(struct snd_gus_card *gus) { if (gus->gf1.res_port2 == NULL) goto __hw_end; @@ -129,24 +129,24 @@ static int snd_gus_free(snd_gus_card_t *gus) return 0; } -static int snd_gus_dev_free(snd_device_t *device) +static int snd_gus_dev_free(struct snd_device *device) { - snd_gus_card_t *gus = device->device_data; + struct snd_gus_card *gus = device->device_data; return snd_gus_free(gus); } -int snd_gus_create(snd_card_t * card, +int snd_gus_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, int timer_dev, int voices, int pcm_channels, int effect, - snd_gus_card_t **rgus) + struct snd_gus_card **rgus) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_gus_dev_free, }; @@ -238,7 +238,7 @@ int snd_gus_create(snd_card_t * card, * Memory detection routine for plain GF1 soundcards */ -static int snd_gus_detect_memory(snd_gus_card_t * gus) +static int snd_gus_detect_memory(struct snd_gus_card * gus) { int l, idx, local; unsigned char d; @@ -273,9 +273,9 @@ static int snd_gus_detect_memory(snd_gus_card_t * gus) return 0; /* some memory were detected */ } -static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches) +static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches) { - snd_card_t *card; + struct snd_card *card; unsigned long flags; int irq, dma1, dma2; static unsigned char irqs[16] = @@ -360,11 +360,11 @@ static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches) return 0; } -static int snd_gus_check_version(snd_gus_card_t * gus) +static int snd_gus_check_version(struct snd_gus_card * gus) { unsigned long flags; unsigned char val, rev; - snd_card_t *card; + struct snd_card *card; card = gus->card; spin_lock_irqsave(&gus->reg_lock, flags); @@ -409,14 +409,14 @@ static int snd_gus_check_version(snd_gus_card_t * gus) } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_gus_seq_dev_free(snd_seq_device_t *seq_dev) +static void snd_gus_seq_dev_free(struct snd_seq_device *seq_dev) { - snd_gus_card_t *gus = seq_dev->private_data; + struct snd_gus_card *gus = seq_dev->private_data; gus->seq_dev = NULL; } #endif -int snd_gus_initialize(snd_gus_card_t *gus) +int snd_gus_initialize(struct snd_gus_card *gus) { int err; @@ -432,9 +432,9 @@ int snd_gus_initialize(snd_gus_card_t *gus) return err; #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(gus->card, 1, SNDRV_SEQ_DEV_ID_GUS, - sizeof(snd_gus_card_t*), &gus->seq_dev) >= 0) { + sizeof(struct snd_gus_card *), &gus->seq_dev) >= 0) { strcpy(gus->seq_dev->name, "GUS"); - *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; + *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; gus->seq_dev->private_data = gus; gus->seq_dev->private_free = snd_gus_seq_dev_free; } diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index 2e23f2a8c627..e8bdb860a19f 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c @@ -27,11 +27,11 @@ #include <sound/info.h> #ifdef CONFIG_SND_DEBUG -static void snd_gf1_mem_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer); +static void snd_gf1_mem_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer); #endif -void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) +void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup) { if (!xup) { down(&alloc->memory_mutex); @@ -40,12 +40,12 @@ void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) } } -static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, - snd_gf1_mem_block_t * block) +static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc, + struct snd_gf1_mem_block * block) { - snd_gf1_mem_block_t *pblock, *nblock; + struct snd_gf1_mem_block *pblock, *nblock; - nblock = (snd_gf1_mem_block_t *) kmalloc(sizeof(snd_gf1_mem_block_t), GFP_KERNEL); + nblock = kmalloc(sizeof(struct snd_gf1_mem_block), GFP_KERNEL); if (nblock == NULL) return NULL; *nblock = *block; @@ -76,7 +76,7 @@ static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, return nblock; } -int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) +int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block) { if (block->share) { /* ok.. shared block */ block->share--; @@ -106,10 +106,10 @@ int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) return 0; } -static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, +static struct snd_gf1_mem_block *snd_gf1_mem_look(struct snd_gf1_mem * alloc, unsigned int address) { - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; for (block = alloc->first; block; block = block->next) { if (block->ptr == address) { @@ -119,10 +119,10 @@ static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, return NULL; } -static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, +static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc, unsigned int *share_id) { - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; if (!share_id[0] && !share_id[1] && !share_id[2] && !share_id[3]) @@ -133,14 +133,14 @@ static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, return NULL; } -static int snd_gf1_mem_find(snd_gf1_mem_t * alloc, - snd_gf1_mem_block_t * block, +static int snd_gf1_mem_find(struct snd_gf1_mem * alloc, + struct snd_gf1_mem_block * block, unsigned int size, int w_16, int align) { - snd_gf1_bank_info_t *info = w_16 ? alloc->banks_16 : alloc->banks_8; + struct snd_gf1_bank_info *info = w_16 ? alloc->banks_16 : alloc->banks_8; unsigned int idx, boundary; int size1; - snd_gf1_mem_block_t *pblock; + struct snd_gf1_mem_block *pblock; unsigned int ptr1, ptr2; align--; @@ -186,11 +186,11 @@ static int snd_gf1_mem_find(snd_gf1_mem_t * alloc, return -ENOMEM; } -snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, +struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner, char *name, int size, int w_16, int align, unsigned int *share_id) { - snd_gf1_mem_block_t block, *nblock; + struct snd_gf1_mem_block block, *nblock; snd_gf1_mem_lock(alloc, 0); if (share_id != NULL) { @@ -220,10 +220,10 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, return nblock; } -int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address) +int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address) { int result; - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; snd_gf1_mem_lock(alloc, 0); if ((block = snd_gf1_mem_look(alloc, address)) != NULL) { @@ -235,12 +235,12 @@ int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address) return -EINVAL; } -int snd_gf1_mem_init(snd_gus_card_t * gus) +int snd_gf1_mem_init(struct snd_gus_card * gus) { - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t block; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block block; #ifdef CONFIG_SND_DEBUG - snd_info_entry_t *entry; + struct snd_info_entry *entry; #endif alloc = &gus->gf1.mem_alloc; @@ -272,10 +272,10 @@ int snd_gf1_mem_init(snd_gus_card_t * gus) return 0; } -int snd_gf1_mem_done(snd_gus_card_t * gus) +int snd_gf1_mem_done(struct snd_gus_card * gus) { - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t *block, *nblock; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block *block, *nblock; alloc = &gus->gf1.mem_alloc; block = alloc->first; @@ -288,12 +288,12 @@ int snd_gf1_mem_done(snd_gus_card_t * gus) } #ifdef CONFIG_SND_DEBUG -static void snd_gf1_mem_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_gf1_mem_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_gus_card_t *gus; - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block *block; unsigned int total, used; int i; diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c index 7f96ac237f3c..4080255007d5 100644 --- a/sound/isa/gus/gus_mem_proc.c +++ b/sound/isa/gus/gus_mem_proc.c @@ -25,20 +25,20 @@ #include <sound/gus.h> #include <sound/info.h> -typedef struct gus_proc_private { +struct gus_proc_private { int rom; /* data are in ROM */ unsigned int address; unsigned int size; - snd_gus_card_t * gus; -} gus_proc_private_t; + struct snd_gus_card * gus; +}; -static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_data, +static long snd_gf1_mem_proc_dump(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - gus_proc_private_t *priv = entry->private_data; - snd_gus_card_t *gus = priv->gus; + struct gus_proc_private *priv = entry->private_data; + struct snd_gus_card *gus = priv->gus; int err; size = count; @@ -52,13 +52,13 @@ static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_da return 0; } -static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry, +static long long snd_gf1_mem_proc_llseek(struct snd_info_entry *entry, void *private_file_data, struct file *file, long long offset, int orig) { - gus_proc_private_t *priv = entry->private_data; + struct gus_proc_private *priv = entry->private_data; switch (orig) { case 0: /* SEEK_SET */ @@ -78,9 +78,9 @@ static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry, return file->f_pos; } -static void snd_gf1_mem_proc_free(snd_info_entry_t *entry) +static void snd_gf1_mem_proc_free(struct snd_info_entry *entry) { - gus_proc_private_t *priv = entry->private_data; + struct gus_proc_private *priv = entry->private_data; kfree(priv); } @@ -89,12 +89,12 @@ static struct snd_info_entry_ops snd_gf1_mem_proc_ops = { .llseek = snd_gf1_mem_proc_llseek, }; -int snd_gf1_mem_proc_init(snd_gus_card_t * gus) +int snd_gf1_mem_proc_init(struct snd_gus_card * gus) { int idx; char name[16]; - gus_proc_private_t *priv; - snd_info_entry_t *entry; + struct gus_proc_private *priv; + struct snd_info_entry *entry; for (idx = 0; idx < 4; idx++) { if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { diff --git a/sound/isa/gus/gus_mixer.c b/sound/isa/gus/gus_mixer.c index a051094d510e..acc25a297200 100644 --- a/sound/isa/gus/gus_mixer.c +++ b/sound/isa/gus/gus_mixer.c @@ -36,7 +36,7 @@ .get = snd_gf1_get_single, .put = snd_gf1_put_single, \ .private_value = shift | (invert << 8) } -static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gf1_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -45,9 +45,9 @@ static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; @@ -57,9 +57,9 @@ static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; @@ -86,7 +86,7 @@ static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_ics_get_double, .put = snd_ics_put_double, \ .private_value = addr } -static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ics_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -95,9 +95,9 @@ static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ics_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int addr = kcontrol->private_value & 0xff; unsigned char left, right; @@ -111,9 +111,9 @@ static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ics_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int addr = kcontrol->private_value & 0xff; int change; @@ -146,13 +146,13 @@ static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t snd_gf1_controls[] = { +static struct snd_kcontrol_new snd_gf1_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), GF1_SINGLE("Line Switch", 0, 0, 1), GF1_SINGLE("Mic Switch", 0, 2, 0) }; -static snd_kcontrol_new_t snd_ics_controls[] = { +static struct snd_kcontrol_new snd_ics_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV), ICS_DOUBLE("Synth Playback Volume", 0, SNDRV_ICS_GF1_DEV), @@ -163,9 +163,9 @@ ICS_DOUBLE("Mic Playback Volume", 0, SNDRV_ICS_MIC_DEV), ICS_DOUBLE("CD Playback Volume", 0, SNDRV_ICS_CD_DEV) }; -int snd_gf1_new_mixer(snd_gus_card_t * gus) +int snd_gf1_new_mixer(struct snd_gus_card * gus) { - snd_card_t *card; + struct snd_card *card; unsigned int idx, max; int err; diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 1cc89fb67bf2..d0829393ec8a 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -42,12 +42,12 @@ #define SNDRV_GF1_PCM_PFLG_ACTIVE (1<<0) #define SNDRV_GF1_PCM_PFLG_NEUTRAL (2<<0) -typedef struct { - snd_gus_card_t * gus; - snd_pcm_substream_t * substream; +struct gus_pcm_private { + struct snd_gus_card * gus; + struct snd_pcm_substream *substream; spinlock_t lock; unsigned int voices; - snd_gus_voice_t *pvoices[2]; + struct snd_gus_voice *pvoices[2]; unsigned int memory; unsigned short flags; unsigned char voice_ctrl, ramp_ctrl; @@ -58,13 +58,13 @@ typedef struct { wait_queue_head_t sleep; atomic_t dma_count; int final_volume; -} gus_pcm_private_t; +}; static int snd_gf1_pcm_use_dma = 1; -static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_data) +static void snd_gf1_pcm_block_change_ack(struct snd_gus_card * gus, void *private_data) { - gus_pcm_private_t *pcmp = private_data; + struct gus_pcm_private *pcmp = private_data; if (pcmp) { atomic_dec(&pcmp->dma_count); @@ -72,14 +72,14 @@ static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_dat } } -static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_block_change(struct snd_pcm_substream *substream, unsigned int offset, unsigned int addr, unsigned int count) { - snd_gf1_dma_block_t block; - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gf1_dma_block block; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; count += offset & 31; offset &= ~31; @@ -101,11 +101,11 @@ static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream, return 0; } -static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream) +static void snd_gf1_pcm_trigger_up(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; - snd_gus_card_t * gus = pcmp->gus; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; + struct snd_gus_card * gus = pcmp->gus; unsigned long flags; unsigned char voice_ctrl, ramp_ctrl; unsigned short rate; @@ -179,10 +179,11 @@ static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pvoice) +static void snd_gf1_pcm_interrupt_wave(struct snd_gus_card * gus, + struct snd_gus_voice *pvoice) { - gus_pcm_private_t * pcmp; - snd_pcm_runtime_t * runtime; + struct gus_pcm_private * pcmp; + struct snd_pcm_runtime *runtime; unsigned char voice_ctrl, ramp_ctrl; unsigned int idx; unsigned int end, step; @@ -261,11 +262,12 @@ static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pv #endif } -static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t * pvoice) +static void snd_gf1_pcm_interrupt_volume(struct snd_gus_card * gus, + struct snd_gus_voice * pvoice) { unsigned short vol; int cvoice; - gus_pcm_private_t *pcmp = pvoice->private_data; + struct gus_pcm_private *pcmp = pvoice->private_data; /* stop ramp, but leave rollover bit untouched */ spin_lock(&gus->reg_lock); @@ -289,11 +291,11 @@ static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t * spin_unlock(&gus->reg_lock); } -static void snd_gf1_pcm_volume_change(snd_gus_card_t * gus) +static void snd_gf1_pcm_volume_change(struct snd_gus_card * gus) { } -static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, +static int snd_gf1_pcm_poke_block(struct snd_gus_card *gus, unsigned char *buf, unsigned int pos, unsigned int count, int w16, int invert) { @@ -341,14 +343,14 @@ static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, return 0; } -static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, +static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, int voice, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int bpos, len; bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); @@ -360,7 +362,7 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, if (snd_gf1_pcm_use_dma && len > 32) { return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); } else { - snd_gus_card_t *gus = pcmp->gus; + struct snd_gus_card *gus = pcmp->gus; int err, w16, invert; w16 = (snd_pcm_format_width(runtime->format) == 16); @@ -371,13 +373,13 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, return 0; } -static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, +static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int bpos, len; bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); @@ -388,7 +390,7 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, if (snd_gf1_pcm_use_dma && len > 32) { return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); } else { - snd_gus_card_t *gus = pcmp->gus; + struct snd_gus_card *gus = pcmp->gus; int err, w16, invert; w16 = (snd_pcm_format_width(runtime->format) == 16); @@ -399,18 +401,18 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, return 0; } -static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; if (err > 0) { /* change */ - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; if (pcmp->memory > 0) { snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory); pcmp->memory = 0; @@ -448,10 +450,10 @@ static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; snd_pcm_lib_free_pages(substream); if (pcmp->pvoices[0]) { @@ -469,10 +471,10 @@ static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; pcmp->bpos = 0; pcmp->dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -481,12 +483,12 @@ static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; int voice; if (cmd == SNDRV_PCM_TRIGGER_START) { @@ -507,11 +509,11 @@ static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream, return 0; } -static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int pos; unsigned char voice_ctrl; @@ -529,22 +531,22 @@ static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * subs return pos; } -static ratnum_t clock = { +static struct snd_ratnum clock = { .num = 9878400/16, .den_min = 2, .den_max = 257, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = 1, .rats = &clock, }; -static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_gf1_pcm_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->c_dma_size = params_buffer_bytes(hw_params); gus->c_period_size = params_period_bytes(hw_params); @@ -559,15 +561,15 @@ static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream, return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_gf1_pcm_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_prepare(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_gf1_i_write8(gus, SNDRV_GF1_GB_RECORD_RATE, runtime->rate_den - 2); snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ @@ -576,10 +578,10 @@ static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); int val; if (cmd == SNDRV_PCM_TRIGGER_START) { @@ -597,15 +599,15 @@ static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream, return 0; } -static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); int pos = snd_dma_pointer(gus->gf1.dma2, gus->c_period_size); pos = bytes_to_frames(substream->runtime, (gus->c_pos + pos) % gus->c_dma_size); return pos; } -static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus) +static void snd_gf1_pcm_interrupt_dma_read(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL); /* Sampling Control Register */ @@ -617,7 +619,7 @@ static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus) } } -static snd_pcm_hardware_t snd_gf1_pcm_playback = +static struct snd_pcm_hardware snd_gf1_pcm_playback = { .info = SNDRV_PCM_INFO_NONINTERLEAVED, .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | @@ -635,7 +637,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_gf1_pcm_capture = +static struct snd_pcm_hardware snd_gf1_pcm_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -653,16 +655,16 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture = .fifo_size = 0, }; -static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) +static void snd_gf1_pcm_playback_free(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) +static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream) { - gus_pcm_private_t *pcmp; - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct gus_pcm_private *pcmp; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL); @@ -690,11 +692,11 @@ static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_close(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; if (!wait_event_timeout(pcmp->sleep, (atomic_read(&pcmp->dma_count) <= 0), 2*HZ)) snd_printk(KERN_ERR "gf1 pcm - serious DMA problem\n"); @@ -703,10 +705,10 @@ static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->gf1.interrupt_handler_dma_read = snd_gf1_pcm_interrupt_dma_read; gus->pcm_cap_substream = substream; @@ -718,23 +720,16 @@ static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_close(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_close(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->pcm_cap_substream = NULL; snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_DMA_READ); return 0; } -static void snd_gf1_pcm_free(snd_pcm_t *pcm) -{ - snd_gus_card_t *gus = pcm->private_data; - gus->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gf1_pcm_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -743,9 +738,9 @@ static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_pcm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&gus->pcm_volume_level_lock, flags); @@ -755,15 +750,15 @@ static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_pcm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned int idx; unsigned short val1, val2, vol; - gus_pcm_private_t *pcmp; - snd_gus_voice_t *pvoice; + struct gus_pcm_private *pcmp; + struct snd_gus_voice *pvoice; val1 = ucontrol->value.integer.value[0] & 127; val2 = ucontrol->value.integer.value[1] & 127; @@ -797,7 +792,7 @@ static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_gf1_pcm_volume_control = +static struct snd_kcontrol_new snd_gf1_pcm_volume_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Volume", @@ -806,7 +801,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control = .put = snd_gf1_pcm_volume_put }; -static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 = +static struct snd_kcontrol_new snd_gf1_pcm_volume_control1 = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "GPCM Playback Volume", @@ -815,7 +810,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 = .put = snd_gf1_pcm_volume_put }; -static snd_pcm_ops_t snd_gf1_pcm_playback_ops = { +static struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .open = snd_gf1_pcm_playback_open, .close = snd_gf1_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -828,7 +823,7 @@ static snd_pcm_ops_t snd_gf1_pcm_playback_ops = { .silence = snd_gf1_pcm_playback_silence, }; -static snd_pcm_ops_t snd_gf1_pcm_capture_ops = { +static struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .open = snd_gf1_pcm_capture_open, .close = snd_gf1_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -839,12 +834,12 @@ static snd_pcm_ops_t snd_gf1_pcm_capture_ops = { .pointer = snd_gf1_pcm_capture_pointer, }; -int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pcm_t ** rpcm) +int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm) { - snd_card_t *card; - snd_kcontrol_t *kctl; - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_card *card; + struct snd_kcontrol *kctl; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int capture, err; if (rpcm) @@ -860,7 +855,6 @@ int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pc if (err < 0) return err; pcm->private_data = gus; - pcm->private_free = snd_gf1_pcm_free; /* playback setup */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops); diff --git a/sound/isa/gus/gus_reset.c b/sound/isa/gus/gus_reset.c index 90710969ef7f..b263655c4116 100644 --- a/sound/isa/gus/gus_reset.c +++ b/sound/isa/gus/gus_reset.c @@ -25,52 +25,52 @@ #include <sound/core.h> #include <sound/gus.h> -extern void snd_gf1_timers_init(snd_gus_card_t * gus); -extern void snd_gf1_timers_done(snd_gus_card_t * gus); -extern int snd_gf1_synth_init(snd_gus_card_t * gus); -extern void snd_gf1_synth_done(snd_gus_card_t * gus); +extern void snd_gf1_timers_init(struct snd_gus_card * gus); +extern void snd_gf1_timers_done(struct snd_gus_card * gus); +extern int snd_gf1_synth_init(struct snd_gus_card * gus); +extern void snd_gf1_synth_done(struct snd_gus_card * gus); /* * ok.. default interrupt handlers... */ -static void snd_gf1_default_interrupt_handler_midi_out(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_midi_out(struct snd_gus_card * gus) { snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20); } -static void snd_gf1_default_interrupt_handler_midi_in(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_midi_in(struct snd_gus_card * gus) { snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80); } -static void snd_gf1_default_interrupt_handler_timer1(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_timer1(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4); } -static void snd_gf1_default_interrupt_handler_timer2(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_timer2(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8); } -static void snd_gf1_default_interrupt_handler_wave_and_volume(snd_gus_card_t * gus, snd_gus_voice_t * voice) +static void snd_gf1_default_interrupt_handler_wave_and_volume(struct snd_gus_card * gus, struct snd_gus_voice * voice) { snd_gf1_i_ctrl_stop(gus, 0x00); snd_gf1_i_ctrl_stop(gus, 0x0d); } -static void snd_gf1_default_interrupt_handler_dma_write(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_dma_write(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, 0x41, 0x00); } -static void snd_gf1_default_interrupt_handler_dma_read(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_dma_read(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, 0x49, 0x00); } -void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) +void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what) { if (what & SNDRV_GF1_HANDLER_MIDI_OUT) gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out; @@ -81,7 +81,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) if (what & SNDRV_GF1_HANDLER_TIMER2) gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2; if (what & SNDRV_GF1_HANDLER_VOICE) { - snd_gus_voice_t *voice; + struct snd_gus_voice *voice; voice = &gus->gf1.voices[what & 0xffff]; voice->handler_wave = @@ -99,7 +99,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) */ -static void snd_gf1_clear_regs(snd_gus_card_t * gus) +static void snd_gf1_clear_regs(struct snd_gus_card * gus) { unsigned long flags; @@ -111,7 +111,7 @@ static void snd_gf1_clear_regs(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_look_regs(snd_gus_card_t * gus) +static void snd_gf1_look_regs(struct snd_gus_card * gus) { unsigned long flags; @@ -127,7 +127,7 @@ static void snd_gf1_look_regs(snd_gus_card_t * gus) * put selected GF1 voices to initial stage... */ -void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice) +void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice) { unsigned long flags; @@ -141,7 +141,7 @@ void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice) spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) +void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice) { unsigned long flags; @@ -161,7 +161,7 @@ void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) #endif } -static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, +static void snd_gf1_clear_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max) { unsigned long flags; @@ -203,7 +203,7 @@ static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, } } -void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max) +void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max) { unsigned long flags; short i, ramp_ok; @@ -232,8 +232,8 @@ void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned sh snd_gf1_clear_voices(gus, v_min, v_max); } -static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus, - snd_gus_voice_t * pvoice, +static void snd_gf1_alloc_voice_use(struct snd_gus_card * gus, + struct snd_gus_voice * pvoice, int type, int client, int port) { pvoice->use = 1; @@ -255,9 +255,9 @@ static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus, } } -snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port) +struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port) { - snd_gus_voice_t *pvoice; + struct snd_gus_voice *pvoice; unsigned long flags; int idx; @@ -289,10 +289,10 @@ snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, return NULL; } -void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice) +void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice) { unsigned long flags; - void (*private_free)(snd_gus_voice_t *voice); + void (*private_free)(struct snd_gus_voice *voice); void *private_data; if (voice == NULL || !voice->use) @@ -317,7 +317,7 @@ void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice) * call this function only by start of driver */ -int snd_gf1_start(snd_gus_card_t * gus) +int snd_gf1_start(struct snd_gus_card * gus) { unsigned long flags; unsigned int i; @@ -400,7 +400,7 @@ int snd_gf1_start(snd_gus_card_t * gus) * call this function only by shutdown of driver */ -int snd_gf1_stop(snd_gus_card_t * gus) +int snd_gf1_stop(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */ snd_gf1_stop_voices(gus, 0, 31); /* stop all voices */ diff --git a/sound/isa/gus/gus_sample.c b/sound/isa/gus/gus_sample.c index 4290e03acd51..9e0c55ab25b2 100644 --- a/sound/isa/gus/gus_sample.c +++ b/sound/isa/gus/gus_sample.c @@ -28,9 +28,9 @@ * */ -static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v) +static void select_instrument(struct snd_gus_card * gus, struct snd_gus_voice * v) { - snd_seq_kinstr_t *instr; + struct snd_seq_kinstr *instr; #if 0 printk("select instrument: cluster = %li, std = 0x%x, bank = %i, prg = %i\n", @@ -53,7 +53,8 @@ static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v) * */ -static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_sample(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); @@ -67,7 +68,8 @@ static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t select_instrument(p->gus, v); } -static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_cluster(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); @@ -75,50 +77,58 @@ static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_ select_instrument(p->gus, v); } -static void event_start(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_start(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_start) v->sample_ops->sample_start(p->gus, v, ev->data.sample.param.position); } -static void event_stop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_stop(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, ev->data.sample.param.stop_mode); } -static void event_freq(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_freq(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_freq) v->sample_ops->sample_freq(p->gus, v, ev->data.sample.param.frequency); } -static void event_volume(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_volume(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_volume) v->sample_ops->sample_volume(p->gus, v, &ev->data.sample.param.volume); } -static void event_loop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_loop(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_loop) v->sample_ops->sample_loop(p->gus, v, &ev->data.sample.param.loop); } -static void event_position(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_position(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_pos) v->sample_ops->sample_pos(p->gus, v, ev->data.sample.param.position); } -static void event_private1(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_private1(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_private1) v->sample_ops->sample_private1(p->gus, v, (unsigned char *)&ev->data.sample.param.raw8); } -typedef void (gus_sample_event_handler_t)(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v); - +typedef void (gus_sample_event_handler_t)(struct snd_seq_event *ev, + struct snd_gus_port *p, + struct snd_gus_voice *v); static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { event_sample, event_cluster, @@ -131,11 +141,11 @@ static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { event_private1 }; -void snd_gus_sample_event(snd_seq_event_t *ev, snd_gus_port_t *p) +void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p) { int idx, voice; - snd_gus_card_t *gus = p->gus; - snd_gus_voice_t *v; + struct snd_gus_card *gus = p->gus; + struct snd_gus_voice *v; unsigned long flags; idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE; diff --git a/sound/isa/gus/gus_simple.c b/sound/isa/gus/gus_simple.c index dfed85b58b3a..dcad6ed0198c 100644 --- a/sound/isa/gus/gus_simple.c +++ b/sound/isa/gus/gus_simple.c @@ -29,19 +29,19 @@ * */ -static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice); - -static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position); -static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode); -static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq); -static void sample_volume(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume); -static void sample_loop(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop); -static void sample_pos(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_position_t position); -static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data); - -static snd_gus_sample_ops_t sample_ops = { +static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice); + +static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position); +static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode); +static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq); +static void sample_volume(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume); +static void sample_loop(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop); +static void sample_pos(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position); +static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data); + +static struct snd_gus_sample_ops sample_ops = { sample_start, sample_stop, sample_freq, @@ -53,13 +53,13 @@ static snd_gus_sample_ops_t sample_ops = { #if 0 -static void note_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, int wait); -static void note_wait(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void note_off(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void note_volume(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_pitchbend(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_vibrato(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_tremolo(snd_gus_card_t *card, snd_gus_voice_t *voice); +static void note_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int wait); +static void note_wait(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void note_off(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void note_volume(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_pitchbend(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_vibrato(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_tremolo(struct snd_gus_card *card, struct snd_gus_voice *voice); static struct snd_gus_note_handlers note_commands = { note_stop, @@ -71,7 +71,7 @@ static struct snd_gus_note_handlers note_commands = { note_tremolo }; -static void chn_trigger_down(snd_gus_card_t *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); +static void chn_trigger_down(struct snd_gus_card *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note ); static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 ); @@ -83,14 +83,14 @@ static struct ULTRA_STRU_INSTRUMENT_CHANNEL_COMMANDS channel_commands = { #endif -static void do_volume_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void do_pan_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); +static void do_volume_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void do_pan_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); /* * */ -static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); snd_gf1_stop_voice(gus, voice->number); @@ -102,7 +102,7 @@ static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice) spin_unlock(&gus->event_lock); } -static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); if (voice->flags & SNDRV_GF1_VFLG_RUNNING) @@ -112,7 +112,7 @@ static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice) spin_unlock(&gus->event_lock); } -static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); if ((voice->flags & (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) == @@ -125,7 +125,7 @@ static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice) * */ -static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void do_volume_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) { unsigned short next, rate, old_volume; int program_next_ramp; @@ -229,7 +229,7 @@ static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) } } -static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void do_pan_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) { unsigned long flags; unsigned char old_pan; @@ -276,7 +276,7 @@ static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) #endif } -static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsigned short pan) +static void set_enhanced_pan(struct snd_gus_card *gus, struct snd_gus_voice *voice, unsigned short pan) { unsigned long flags; unsigned short vlo, vro; @@ -307,13 +307,13 @@ static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsign * */ -static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) +static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) { unsigned long flags; unsigned int begin, addr, addr_end, addr_start; int w_16; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); if (instr == NULL) @@ -397,7 +397,7 @@ static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_po snd_seq_instr_free_use(gus->gf1.ilist, instr); } -static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode) +static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode) { unsigned char control; unsigned long flags; @@ -433,7 +433,7 @@ static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_sto } } -static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq) +static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq) { unsigned long flags; @@ -444,7 +444,7 @@ static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_fre spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume) +static void sample_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume) { if (volume->volume >= 0) { volume->volume &= 0x3fff; @@ -471,13 +471,13 @@ static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_e } } -static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop) +static void sample_loop(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop) { unsigned long flags; int w_16 = voice->control & 0x04; unsigned int begin, addr_start, addr_end; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; #if 0 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); @@ -500,13 +500,13 @@ static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_ snd_seq_instr_free_use(gus->gf1.ilist, instr); } -static void sample_pos(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) +static void sample_pos(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) { unsigned long flags; int w_16 = voice->control & 0x04; unsigned int begin, addr; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; #if 0 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); @@ -537,7 +537,7 @@ static unsigned char get_effects_mask( ultra_card_t *card, int value ) #endif -static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data) +static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data) { #if 0 unsigned long flags; @@ -624,7 +624,7 @@ static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned #endif -void snd_gf1_simple_init(snd_gus_voice_t *voice) +void snd_gf1_simple_init(struct snd_gus_voice *voice) { voice->handler_wave = interrupt_wave; voice->handler_volume = interrupt_volume; diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c index f51c386ee192..85a1b051f09a 100644 --- a/sound/isa/gus/gus_synth.c +++ b/sound/isa/gus/gus_synth.c @@ -34,10 +34,10 @@ MODULE_LICENSE("GPL"); * */ -static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port) +static void snd_gus_synth_free_voices(struct snd_gus_card * gus, int client, int port) { int idx; - snd_gus_voice_t * voice; + struct snd_gus_voice * voice; for (idx = 0; idx < 32; idx++) { voice = &gus->gf1.voices[idx]; @@ -46,11 +46,11 @@ static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port } } -static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_gus_synth_use(void *private_data, struct snd_seq_port_subscribe *info) { - snd_gus_port_t * port = (snd_gus_port_t *)private_data; - snd_gus_card_t * gus = port->gus; - snd_gus_voice_t * voice; + struct snd_gus_port * port = private_data; + struct snd_gus_card * gus = port->gus; + struct snd_gus_voice * voice; unsigned int idx; if (info->voices > 32) @@ -74,10 +74,10 @@ static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info) return 0; } -static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_gus_synth_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - snd_gus_port_t * port = (snd_gus_port_t *)private_data; - snd_gus_card_t * gus = port->gus; + struct snd_gus_port * port = private_data; + struct snd_gus_card * gus = port->gus; down(&gus->register_mutex); snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port); @@ -90,19 +90,19 @@ static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *inf * */ -static void snd_gus_synth_free_private_instruments(snd_gus_port_t *p, int client) +static void snd_gus_synth_free_private_instruments(struct snd_gus_port *p, int client) { - snd_seq_instr_header_t ifree; + struct snd_seq_instr_header ifree; memset(&ifree, 0, sizeof(ifree)); ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE; snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); } -static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, +static int snd_gus_synth_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_gus_port_t * p = (snd_gus_port_t *) private_data; + struct snd_gus_port * p = private_data; snd_assert(p != NULL, return -EINVAL); if (ev->type >= SNDRV_SEQ_EVENT_SAMPLE && @@ -131,12 +131,12 @@ static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, } static void snd_gus_synth_instr_notify(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int what) { unsigned int idx; - snd_gus_card_t *gus = private_data; - snd_gus_voice_t *pvoice; + struct snd_gus_card *gus = private_data; + struct snd_gus_voice *pvoice; unsigned long flags; spin_lock_irqsave(&gus->event_lock, flags); @@ -160,16 +160,16 @@ static void snd_gus_synth_instr_notify(void *private_data, static void snd_gus_synth_free_port(void *private_data) { - snd_gus_port_t * p = (snd_gus_port_t *)private_data; + struct snd_gus_port * p = private_data; if (p) snd_midi_channel_free_set(p->chset); } -static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) +static int snd_gus_synth_create_port(struct snd_gus_card * gus, int idx) { - snd_gus_port_t * p; - snd_seq_port_callback_t callbacks; + struct snd_gus_port * p; + struct snd_seq_port_callback callbacks; char name[32]; int result; @@ -210,46 +210,28 @@ static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) * */ -static int snd_gus_synth_new_device(snd_seq_device_t *dev) +static int snd_gus_synth_new_device(struct snd_seq_device *dev) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; int client, i; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t *cinfo; - snd_seq_port_subscribe_t sub; - snd_iwffff_ops_t *iwops; - snd_gf1_ops_t *gf1ops; - snd_simple_ops_t *simpleops; - - gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + struct snd_seq_port_subscribe sub; + struct snd_iwffff_ops *iwops; + struct snd_gf1_ops *gf1ops; + struct snd_simple_ops *simpleops; + + gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (gus == NULL) return -EINVAL; init_MUTEX(&gus->register_mutex); gus->gf1.seq_client = -1; - cinfo = kmalloc(sizeof(*cinfo), GFP_KERNEL); - if (! cinfo) - return -ENOMEM; - /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = gus; - callbacks.allow_output = callbacks.allow_input = 1; client = gus->gf1.seq_client = - snd_seq_create_kernel_client(gus->card, 1, &callbacks); - if (client < 0) { - kfree(cinfo); + snd_seq_create_kernel_client(gus->card, 1, gus->interwave ? + "AMD InterWave" : "GF1"); + if (client < 0) return client; - } - - /* change name of client */ - memset(cinfo, 0, sizeof(*cinfo)); - cinfo->client = client; - cinfo->type = KERNEL_CLIENT; - sprintf(cinfo->name, gus->interwave ? "AMD InterWave" : "GF1"); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, cinfo); - kfree(cinfo); for (i = 0; i < 4; i++) snd_gus_synth_create_port(gus, i); @@ -293,11 +275,11 @@ static int snd_gus_synth_new_device(snd_seq_device_t *dev) return 0; } -static int snd_gus_synth_delete_device(snd_seq_device_t *dev) +static int snd_gus_synth_delete_device(struct snd_seq_device *dev) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; - gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (gus == NULL) return -EINVAL; @@ -312,13 +294,13 @@ static int snd_gus_synth_delete_device(snd_seq_device_t *dev) static int __init alsa_gus_synth_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_gus_synth_new_device, snd_gus_synth_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_GUS, &ops, - sizeof(snd_gus_card_t*)); + sizeof(struct snd_gus_card *)); } static void __exit alsa_gus_synth_exit(void) diff --git a/sound/isa/gus/gus_timer.c b/sound/isa/gus/gus_timer.c index 9876603ff6c1..a43b662f17c7 100644 --- a/sound/isa/gus/gus_timer.c +++ b/sound/isa/gus/gus_timer.c @@ -30,12 +30,12 @@ * Timer 1 - 80us */ -static int snd_gf1_timer1_start(snd_timer_t * timer) +static int snd_gf1_timer1_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -48,11 +48,11 @@ static int snd_gf1_timer1_start(snd_timer_t * timer) return 0; } -static int snd_gf1_timer1_stop(snd_timer_t * timer) +static int snd_gf1_timer1_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -66,12 +66,12 @@ static int snd_gf1_timer1_stop(snd_timer_t * timer) * Timer 2 - 320us */ -static int snd_gf1_timer2_start(snd_timer_t * timer) +static int snd_gf1_timer2_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -84,11 +84,11 @@ static int snd_gf1_timer2_start(snd_timer_t * timer) return 0; } -static int snd_gf1_timer2_stop(snd_timer_t * timer) +static int snd_gf1_timer2_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -102,18 +102,18 @@ static int snd_gf1_timer2_stop(snd_timer_t * timer) */ -static void snd_gf1_interrupt_timer1(snd_gus_card_t * gus) +static void snd_gf1_interrupt_timer1(struct snd_gus_card * gus) { - snd_timer_t *timer = gus->gf1.timer1; + struct snd_timer *timer = gus->gf1.timer1; if (timer == NULL) return; snd_timer_interrupt(timer, timer->sticks); } -static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus) +static void snd_gf1_interrupt_timer2(struct snd_gus_card * gus) { - snd_timer_t *timer = gus->gf1.timer2; + struct snd_timer *timer = gus->gf1.timer2; if (timer == NULL) return; @@ -124,7 +124,7 @@ static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus) */ -static struct _snd_timer_hardware snd_gf1_timer1 = +static struct snd_timer_hardware snd_gf1_timer1 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 80000, @@ -133,7 +133,7 @@ static struct _snd_timer_hardware snd_gf1_timer1 = .stop = snd_gf1_timer1_stop, }; -static struct _snd_timer_hardware snd_gf1_timer2 = +static struct snd_timer_hardware snd_gf1_timer2 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 320000, @@ -142,22 +142,22 @@ static struct _snd_timer_hardware snd_gf1_timer2 = .stop = snd_gf1_timer2_stop, }; -static void snd_gf1_timer1_free(snd_timer_t *timer) +static void snd_gf1_timer1_free(struct snd_timer *timer) { - snd_gus_card_t *gus = timer->private_data; + struct snd_gus_card *gus = timer->private_data; gus->gf1.timer1 = NULL; } -static void snd_gf1_timer2_free(snd_timer_t *timer) +static void snd_gf1_timer2_free(struct snd_timer *timer) { - snd_gus_card_t *gus = timer->private_data; + struct snd_gus_card *gus = timer->private_data; gus->gf1.timer2 = NULL; } -void snd_gf1_timers_init(snd_gus_card_t * gus) +void snd_gf1_timers_init(struct snd_gus_card * gus) { - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; if (gus->gf1.timer1 != NULL || gus->gf1.timer2 != NULL) return; @@ -190,7 +190,7 @@ void snd_gf1_timers_init(snd_gus_card_t * gus) gus->gf1.timer2 = timer; } -void snd_gf1_timers_done(snd_gus_card_t * gus) +void snd_gf1_timers_done(struct snd_gus_card * gus) { snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_TIMER1 | SNDRV_GF1_HANDLER_TIMER2); if (gus->gf1.timer1) { diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c index fbc95e99105c..654290a8b21c 100644 --- a/sound/isa/gus/gus_uart.c +++ b/sound/isa/gus/gus_uart.c @@ -26,7 +26,7 @@ #include <sound/core.h> #include <sound/gus.h> -static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus) +static void snd_gf1_interrupt_midi_in(struct snd_gus_card * gus) { int count; unsigned char stat, data, byte; @@ -61,7 +61,7 @@ static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus) } } -static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus) +static void snd_gf1_interrupt_midi_out(struct snd_gus_card * gus) { char byte; unsigned long flags; @@ -81,7 +81,7 @@ static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close) +static void snd_gf1_uart_reset(struct snd_gus_card * gus, int close) { snd_gf1_uart_cmd(gus, 0x03); /* reset */ if (!close && gus->uart_enable) { @@ -90,10 +90,10 @@ static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close) } } -static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -109,10 +109,10 @@ static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; int i; gus = substream->rmidi->private_data; @@ -136,10 +136,10 @@ static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -151,10 +151,10 @@ static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -166,9 +166,9 @@ static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_gf1_uart_input_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; unsigned long flags; gus = substream->rmidi->private_data; @@ -184,10 +184,10 @@ static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_gf1_uart_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; char byte; int timeout; @@ -222,23 +222,23 @@ static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static snd_rawmidi_ops_t snd_gf1_uart_output = +static struct snd_rawmidi_ops snd_gf1_uart_output = { .open = snd_gf1_uart_output_open, .close = snd_gf1_uart_output_close, .trigger = snd_gf1_uart_output_trigger, }; -static snd_rawmidi_ops_t snd_gf1_uart_input = +static struct snd_rawmidi_ops snd_gf1_uart_input = { .open = snd_gf1_uart_input_open, .close = snd_gf1_uart_input_close, .trigger = snd_gf1_uart_input_trigger, }; -int snd_gf1_rawmidi_new(snd_gus_card_t * gus, int device, snd_rawmidi_t ** rrawmidi) +int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c index b3382fec5298..dbbc0a6d7659 100644 --- a/sound/isa/gus/gus_volume.c +++ b/sound/isa/gus/gus_volume.c @@ -72,7 +72,7 @@ unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol) return rvol | (m >> (8 - e)); } -unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, +unsigned int snd_gf1_calc_ramp_rate(struct snd_gus_card * gus, unsigned short start, unsigned short end, unsigned int us) @@ -112,7 +112,7 @@ unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, #endif /* 0 */ -unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) +unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq16) { freq16 >>= 3; if (freq16 < 50) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 39cef38835ca..d1165b96fa3f 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -20,14 +20,15 @@ */ #include <sound/driver.h> -#include <asm/dma.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/time.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/gus.h> -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -70,11 +71,12 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); -static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusclassic: " -static int __init snd_gusclassic_detect(snd_gus_card_t * gus) +static int __init snd_gusclassic_detect(struct snd_gus_card * gus) { unsigned char d; @@ -93,7 +95,7 @@ static int __init snd_gusclassic_detect(snd_gus_card_t * gus) return 0; } -static void __init snd_gusclassic_init(int dev, snd_gus_card_t * gus) +static void __init snd_gusclassic_init(int dev, struct snd_gus_card * gus) { gus->equal_irq = 0; gus->codec_flag = 0; @@ -101,20 +103,19 @@ static void __init snd_gusclassic_init(int dev, snd_gus_card_t * gus) gus->joystick_dac = joystick_dac[dev]; } -static int __init snd_gusclassic_probe(int dev) +static int __init snd_gusclassic_probe(struct platform_device *pdev) { + 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; - snd_card_t *card; - struct snd_gusclassic *guscard; - snd_gus_card_t *gus = NULL; + 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; - guscard = (struct snd_gusclassic *)card->private_data; if (pcm_channels[dev] < 2) pcm_channels[dev] = 2; @@ -143,12 +144,31 @@ static int __init snd_gusclassic_probe(int dev) } } - - if ((err = snd_gus_create(card, - port[dev], - xirq, xdma1, xdma2, - 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) + 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; if ((err = snd_gusclassic_detect(gus)) < 0) @@ -178,13 +198,12 @@ static int __init snd_gusclassic_probe(int dev) if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_gusclassic_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -192,53 +211,70 @@ static int __init snd_gusclassic_probe(int dev) return err; } -static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) +static int snd_gusclassic_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusclassic_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define GUSCLASSIC_DRIVER "snd_gusclassic" + +static struct platform_driver snd_gusclassic_driver = { + .probe = snd_gusclassic_probe, + .remove = snd_gusclassic_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSCLASSIC_DRIVER + }, +}; + +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) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusclassic_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusclassic_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusclassic_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSCLASSIC_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_gusclassic_unregister_all(); + return err; } static void __exit alsa_card_gusclassic_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusclassic_cards[idx]); + snd_gusclassic_unregister_all(); } module_init(alsa_card_gusclassic_init) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index d2e7cb1df537..239f16e6b9ee 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -20,11 +20,13 @@ */ #include <sound/driver.h> -#include <asm/dma.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/time.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/gus.h> #include <sound/es1688.h> @@ -85,14 +87,15 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); -static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusextreme: " static int __init snd_gusextreme_detect(int dev, - snd_card_t * card, - snd_gus_card_t * gus, - es1688_t *es1688) + struct snd_card *card, + struct snd_gus_card * gus, + struct snd_es1688 *es1688) { unsigned long flags; unsigned char d; @@ -139,15 +142,15 @@ static int __init snd_gusextreme_detect(int dev, return 0; } -static void __init snd_gusextreme_init(int dev, snd_gus_card_t * gus) +static void __init snd_gusextreme_init(int dev, struct snd_gus_card * gus) { gus->joystick_dac = joystick_dac[dev]; } -static int __init snd_gusextreme_mixer(es1688_t *chip) +static int __init snd_gusextreme_mixer(struct snd_es1688 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; int err; memset(&id1, 0, sizeof(id1)); @@ -166,24 +169,23 @@ static int __init snd_gusextreme_mixer(es1688_t *chip) return 0; } -static int __init snd_gusextreme_probe(int dev) +static int __init snd_gusextreme_probe(struct platform_device *pdev) { + 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; - snd_card_t *card; - struct snd_gusextreme *acard; - snd_gus_card_t *gus; - es1688_t *es1688; - opl3_t *opl3; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_es1688 *es1688; + struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - acard = (struct snd_gusextreme *)card->private_data; xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { @@ -223,10 +225,29 @@ static int __init snd_gusextreme_probe(int dev) } } - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xess_irq, xmpu_irq, xess_dma, - ES1688_HW_1688, &es1688)) < 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) goto out; + if (gf1_port[dev] < 0) gf1_port[dev] = port[dev] + 0x20; if ((err = snd_gus_create(card, @@ -287,13 +308,12 @@ static int __init snd_gusextreme_probe(int dev) 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); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto out; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto out; - snd_gusextreme_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; out: @@ -301,60 +321,70 @@ static int __init snd_gusextreme_probe(int dev) return err; } -static int __init snd_gusextreme_legacy_auto_probe(unsigned long xport) +static int snd_gusextreme_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define GUSEXTREME_DRIVER "snd_gusextreme" + +static struct platform_driver snd_gusextreme_driver = { + .probe = snd_gusextreme_probe, + .remove = snd_gusextreme_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSEXTREME_DRIVER + }, +}; + +static void __init_or_module snd_gusextreme_unregister_all(void) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusextreme_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + 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) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusextreme_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusextreme_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusextreme_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSEXTREME_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_gusextreme_unregister_all(); + return err; } static void __exit alsa_card_gusextreme_exit(void) { - int idx; - snd_card_t *card; - struct snd_gusextreme *acard; - - for (idx = 0; idx < SNDRV_CARDS; idx++) { - card = snd_gusextreme_cards[idx]; - if (card == NULL) - continue; - acard = (struct snd_gusextreme *)card->private_data; - snd_card_free(snd_gusextreme_cards[idx]); - } + snd_gusextreme_unregister_all(); } module_init(alsa_card_gusextreme_init) diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 0bb44b519340..d4d2b2a517d5 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -20,15 +20,16 @@ */ #include <sound/driver.h> -#include <asm/dma.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/time.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/gus.h> #include <sound/cs4231.h> -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -71,20 +72,20 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver."); 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; - snd_card_t *card; - snd_gus_card_t *gus; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_cs4231 *cs4231; unsigned short gus_status_reg; unsigned short pcm_status_reg; }; -static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "gusmax: " -static int __init snd_gusmax_detect(snd_gus_card_t * gus) +static int __init snd_gusmax_detect(struct snd_gus_card * gus) { unsigned char d; @@ -126,7 +127,7 @@ static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_RETVAL(handled); } -static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * gus) +static void __init snd_gusmax_init(int dev, struct snd_card *card, struct snd_gus_card * gus) { gus->equal_irq = 1; gus->codec_flag = 1; @@ -144,10 +145,10 @@ static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * #define CS4231_PRIVATE( left, right, shift, mute ) \ ((left << 24)|(right << 16)|(shift<<8)|mute) -static int __init snd_gusmax_mixer(cs4231_t *chip) +static int __init snd_gusmax_mixer(struct snd_cs4231 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; int err; memset(&id1, 0, sizeof(id1)); @@ -193,7 +194,7 @@ static int __init snd_gusmax_mixer(cs4231_t *chip) return 0; } -static void snd_gusmax_free(snd_card_t *card) +static void snd_gusmax_free(struct snd_card *card) { struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data; @@ -203,14 +204,15 @@ static void snd_gusmax_free(snd_card_t *card) free_irq(maxcard->irq, (void *)maxcard); } -static int __init snd_gusmax_probe(int dev) +static int __init snd_gusmax_probe(struct platform_device *pdev) { + 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; - snd_card_t *card; - snd_gus_card_t *gus = NULL; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus = NULL; + struct snd_cs4231 *cs4231; struct snd_gusmax *maxcard; card = snd_card_new(index[dev], id[dev], THIS_MODULE, @@ -247,12 +249,32 @@ static int __init snd_gusmax_probe(int dev) } } - if ((err = snd_gus_create(card, - port[dev], - -xirq, xdma1, xdma2, - 0, channels[dev], - pcm_channels[dev], - 0, &gus)) < 0) + 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 { + 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; if ((err = snd_gusmax_detect(gus)) < 0) @@ -310,15 +332,15 @@ static int __init snd_gusmax_probe(int dev) if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; - snd_gusmax_cards[dev] = card; + + platform_set_drvdata(pdev, card); return 0; _err: @@ -326,53 +348,70 @@ static int __init snd_gusmax_probe(int dev) return err; } -static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) +static int snd_gusmax_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusmax_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define GUSMAX_DRIVER "snd_gusmax" + +static struct platform_driver snd_gusmax_driver = { + .probe = snd_gusmax_probe, + .remove = snd_gusmax_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSMAX_DRIVER + }, +}; + +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) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusmax_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusmax_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + err = platform_driver_register(&snd_gusmax_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSMAX_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_gusmax_unregister_all(); + return err; } static void __exit alsa_card_gusmax_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusmax_cards[idx]); + snd_gusmax_unregister_all(); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index f703a9f4257c..9838d992b101 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -23,19 +23,20 @@ */ #include <sound/driver.h> -#include <asm/dma.h> -#include <linux/delay.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> +#include <linux/delay.h> #include <linux/slab.h> #include <linux/pnp.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/gus.h> #include <sound/cs4231.h> #ifdef SNDRV_STB #include <sound/tea6330t.h> #endif -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -75,8 +76,12 @@ static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; #ifdef SNDRV_STB #define PFX "interwave-stb: " +#define INTERWAVE_DRIVER "snd_interwave_stb" +#define INTERWAVE_PNP_DRIVER "interwave-stb" #else #define PFX "interwave: " +#define INTERWAVE_DRIVER "snd_interwave" +#define INTERWAVE_PNP_DRIVER "interwave" #endif module_param_array(index, int, NULL, 0444); @@ -110,11 +115,14 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); 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; - snd_card_t *card; - snd_gus_card_t *gus; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_cs4231 *cs4231; #ifdef SNDRV_STB struct resource *i2c_res; #endif @@ -128,7 +136,6 @@ struct snd_interwave { #endif }; -static snd_card_t *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -160,7 +167,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids); #ifdef SNDRV_STB -static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) +static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int data) { unsigned long port = bus->private_value; @@ -171,7 +178,7 @@ static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) udelay(10); } -static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) +static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus) { unsigned long port = bus->private_value; unsigned char res; @@ -183,7 +190,7 @@ static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) return res; } -static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) +static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack) { unsigned long port = bus->private_value; unsigned char res; @@ -197,19 +204,19 @@ static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) return res; } -static snd_i2c_bit_ops_t snd_interwave_i2c_bit_ops = { +static struct snd_i2c_bit_ops snd_interwave_i2c_bit_ops = { .setlines = snd_interwave_i2c_setlines, .getclock = snd_interwave_i2c_getclockline, .getdata = snd_interwave_i2c_getdataline, }; static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, - snd_gus_card_t * gus, int dev, - snd_i2c_bus_t **rbus) + struct snd_gus_card * gus, int dev, + struct snd_i2c_bus **rbus) { unsigned long port; - snd_i2c_bus_t *bus; - snd_card_t *card = iwcard->card; + struct snd_i2c_bus *bus; + struct snd_card *card = iwcard->card; char name[32]; int err; @@ -246,10 +253,10 @@ static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, #endif static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, - snd_gus_card_t * gus, + struct snd_gus_card * gus, int dev #ifdef SNDRV_STB - , snd_i2c_bus_t **rbus + , struct snd_i2c_bus **rbus #endif ) { @@ -314,7 +321,7 @@ static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs return IRQ_RETVAL(handled); } -static void __devinit snd_interwave_reset(snd_gus_card_t * gus) +static void __devinit snd_interwave_reset(struct snd_gus_card * gus) { snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00); udelay(160); @@ -322,7 +329,7 @@ static void __devinit snd_interwave_reset(snd_gus_card_t * gus) udelay(160); } -static void __devinit snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes) +static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *sizes) { unsigned int idx; unsigned int local; @@ -371,7 +378,7 @@ struct rom_hdr { /* 511 */ unsigned char csum; }; -static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) +static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus) { static unsigned int lmc[13] = { @@ -470,7 +477,7 @@ static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) snd_interwave_reset(gus); } -static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) +static void __devinit snd_interwave_init(int dev, struct snd_gus_card * gus) { unsigned long flags; @@ -492,17 +499,17 @@ static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) } -static snd_kcontrol_new_t snd_interwave_controls[] = { +static struct snd_kcontrol_new snd_interwave_controls[] = { CS4231_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("Master Playback Volume", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 0, 0, 31, 1), CS4231_DOUBLE("Mic Playback Switch", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Mic Playback Volume", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 0, 0, 31, 1) }; -static int __devinit snd_interwave_mixer(cs4231_t *chip) +static int __devinit snd_interwave_mixer(struct snd_cs4231 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; unsigned int idx; int err; @@ -631,9 +638,9 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, } #endif /* CONFIG_PNP */ -static void snd_interwave_free(snd_card_t *card) +static void snd_interwave_free(struct snd_card *card) { - struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; + struct snd_interwave *iwcard = card->private_data; if (iwcard == NULL) return; @@ -644,76 +651,52 @@ static void snd_interwave_free(snd_card_t *card) free_irq(iwcard->irq, (void *)iwcard); } -static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_interwave_card_new(int dev) { - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; - int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_interwave *iwcard; - cs4231_t *cs4231; - snd_gus_card_t *gus; -#ifdef SNDRV_STB - snd_i2c_bus_t *i2c_bus; -#endif - snd_pcm_t *pcm; - char *str; - int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_interwave)); if (card == NULL) - return -ENOMEM; - iwcard = (struct snd_interwave *)card->private_data; + return NULL; + iwcard = card->private_data; iwcard->card = card; iwcard->irq = -1; card->private_free = snd_interwave_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) - goto _err; - snd_card_set_dev(card, &pcard->card->dev); - } + return card; +} + +static int __devinit snd_interwave_probe(struct snd_card *card, int dev) +{ + int xirq, xdma1, xdma2; + struct snd_interwave *iwcard = card->private_data; + struct snd_cs4231 *cs4231; + struct snd_gus_card *gus; +#ifdef SNDRV_STB + struct snd_i2c_bus *i2c_bus; #endif + struct snd_pcm *pcm; + char *str; + int err; + 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; - } - } if ((err = snd_gus_create(card, port[dev], -xirq, xdma1, xdma2, 0, 32, pcm_channels[dev], effect[dev], &gus)) < 0) - goto _err; + return err; if ((err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB , &i2c_bus #endif )) < 0) - goto _err; + return err; iwcard->gus_status_reg = gus->gf1.reg_irqstat; iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; @@ -721,12 +704,12 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); if ((err = snd_gus_initialize(gus)) < 0) - goto _err; + return err; - if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { + if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, + "InterWave", iwcard)) { snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); - err = -EBUSY; - goto _err; + return -EBUSY; } iwcard->irq = xirq; @@ -738,30 +721,30 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, &cs4231)) < 0) - goto _err; + return err; if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) - goto _err; + return err; sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); strcat(pcm->name, " (codec)"); if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) - goto _err; + return err; if ((err = snd_cs4231_mixer(cs4231)) < 0) - goto _err; + return err; if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) - goto _err; + return err; } if ((err = snd_interwave_mixer(cs4231)) < 0) - goto _err; + return err; #ifdef SNDRV_STB { - snd_ctl_elem_id_t id1, id2; + struct snd_ctl_elem_id id1, id2; memset(&id1, 0, sizeof(id1)); memset(&id2, 0, sizeof(id2)); id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -769,19 +752,19 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, strcpy(id2.name, id1.name); id2.index = 1; if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; strcpy(id1.name, "Master Playback Volume"); strcpy(id2.name, id1.name); if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) - goto _err; + return err; } #endif gus->uart_enable = midi[dev]; if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) - goto _err; + return err; #ifndef SNDRV_STB str = "AMD InterWave"; @@ -800,139 +783,198 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) - goto _err; + return err; iwcard->cs4231 = cs4231; iwcard->gus = gus; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_interwave_legacy[dev++] = card; return 0; +} - _err: - snd_card_free(card); - return err; +static int __init snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card *card; + int err; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); + return 0; } -static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) +static int __init snd_interwave_nonpnp_probe(struct platform_device *pdev) { - static int dev; - int res; + 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}; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) - continue; -#endif - port[dev] = xport; - res = snd_interwave_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } } - return -ENODEV; + if (dma1[dev] == SNDRV_AUTO_DMA) { + if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[dev] == SNDRV_AUTO_DMA) { + if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) + return snd_interwave_nonpnp_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); + if (! err) + return 0; + } + return err; + } +} + +static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_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), + /* FIXME: suspend,resume */ + .driver = { + .name = INTERWAVE_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_interwave_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - - return -ENODEV; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver interwave_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, - .name = "interwave", + .name = INTERWAVE_PNP_DRIVER, .id_table = snd_interwave_pnpids, .probe = snd_interwave_pnp_detect, .remove = __devexit_p(snd_interwave_pnp_remove), + /* FIXME: suspend,resume */ }; #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 cards = 0, i; - static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; + if ((err = platform_driver_register(&snd_interwave_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (!snd_interwave_probe(dev, NULL, NULL)) { - cards++; - continue; + device = platform_device_register_simple(INTERWAVE_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; } -#ifdef MODULE - printk(KERN_ERR "InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); -#endif + platform_devices[i] = device; + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_interwave_probe_legacy_port); - if (i > 0) - cards += i; -#ifdef CONFIG_PNP + /* ISA PnP cards */ i = pnp_register_card_driver(&interwave_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; -#endif + } if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif #ifdef MODULE printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_interwave_unregister_all(); + return err; } static void __exit alsa_card_interwave_exit(void) { - int dev; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_interwave_legacy[dev]); + snd_interwave_unregister_all(); } module_init(alsa_card_interwave_init) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 47cabda792b6..ca359e0c674b 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -21,6 +21,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/interrupt.h> #include <linux/pm.h> #include <linux/slab.h> @@ -88,6 +90,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); 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]; +static int pnp_registered; +static int pnpc_registered; + /* control ports */ #define OPL3SA2_PM_CTRL 0x01 #define OPL3SA2_SYS_CTRL 0x02 @@ -115,34 +121,23 @@ MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: #define OPL3SA2_PM_D0 0x00 #define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX) -typedef struct snd_opl3sa2 opl3sa2_t; - struct snd_opl3sa2 { - snd_card_t *card; + struct snd_card *card; int version; /* 2 or 3 */ unsigned long port; /* control port */ struct resource *res_port; /* control port resource */ int irq; int single_dma; spinlock_t reg_lock; - snd_hwdep_t *synth; - snd_rawmidi_t *rmidi; - cs4231_t *cs4231; -#ifdef CONFIG_PNP - struct pnp_dev *dev; -#endif + struct snd_hwdep *synth; + struct snd_rawmidi *rmidi; + struct snd_cs4231 *cs4231; unsigned char ctlregs[0x20]; int ymode; /* SL added */ - snd_kcontrol_t *master_switch; - snd_kcontrol_t *master_volume; -#ifdef CONFIG_PM - void (*cs4231_suspend)(cs4231_t *); - void (*cs4231_resume)(cs4231_t *); -#endif + struct snd_kcontrol *master_switch; + struct snd_kcontrol *master_volume; }; -static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "opl3sa2: " #ifdef CONFIG_PNP @@ -176,7 +171,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids); /* read control port (w/o spinlock) */ -static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) +static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) { unsigned char result; #if 0 @@ -192,7 +187,7 @@ static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) } /* read control port (with spinlock) */ -static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) +static unsigned char snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) { unsigned long flags; unsigned char result; @@ -204,7 +199,7 @@ static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) } /* write control port (w/o spinlock) */ -static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) +static void __snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) { #if 0 outb(0x1d, port); /* password */ @@ -215,7 +210,7 @@ static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned cha } /* write control port (with spinlock) */ -static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) +static void snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -223,9 +218,9 @@ static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char spin_unlock_irqrestore(&chip->reg_lock, flags); } -static int __init snd_opl3sa2_detect(opl3sa2_t *chip) +static int __init snd_opl3sa2_detect(struct snd_opl3sa2 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned long port; unsigned char tmp, tmp1; char str[2]; @@ -298,7 +293,7 @@ static int __init snd_opl3sa2_detect(opl3sa2_t *chip) static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned short status; - opl3sa2_t *chip = dev_id; + struct snd_opl3sa2 *chip = dev_id; int handled = 0; if (chip == NULL || chip->card == NULL) @@ -340,7 +335,7 @@ static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs * .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opl3sa2_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -351,9 +346,9 @@ static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -368,9 +363,9 @@ static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -398,7 +393,7 @@ static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opl3sa2_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -409,9 +404,9 @@ static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -431,9 +426,9 @@ static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -471,31 +466,31 @@ static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_opl3sa2_controls[] = { +static struct snd_kcontrol_new snd_opl3sa2_controls[] = { OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1), OPL3SA2_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1), OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), OPL3SA2_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1) }; -static snd_kcontrol_new_t snd_opl3sa2_tone_controls[] = { +static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0) }; -static void snd_opl3sa2_master_free(snd_kcontrol_t *kcontrol) +static void snd_opl3sa2_master_free(struct snd_kcontrol *kcontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); chip->master_switch = NULL; chip->master_volume = NULL; } -static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) +static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; - snd_kcontrol_t *kctl; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -505,21 +500,29 @@ static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) /* reassign AUX0 to CD */ strcpy(id1.name, "Aux Playback Switch"); strcpy(id2.name, "CD Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "CD Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* reassign AUX1 to FM */ strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; strcpy(id2.name, "FM Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "FM Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* add OPL3SA2 controls */ for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0) @@ -539,22 +542,21 @@ static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) /* Power Management support functions */ #ifdef CONFIG_PM -static int snd_opl3sa2_suspend(snd_card_t *card, pm_message_t state) +static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) { - opl3sa2_t *chip = card->pm_private_data; - - snd_pcm_suspend_all(chip->cs4231->pcm); /* stop before saving regs */ - chip->cs4231_suspend(chip->cs4231); + struct snd_opl3sa2 *chip = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->cs4231->suspend(chip->cs4231); /* power down */ snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3); return 0; } -static int snd_opl3sa2_resume(snd_card_t *card) +static int snd_opl3sa2_resume(struct snd_card *card) { - opl3sa2_t *chip = card->pm_private_data; + struct snd_opl3sa2 *chip = card->private_data; int i; /* power up */ @@ -570,26 +572,25 @@ static int snd_opl3sa2_resume(snd_card_t *card) snd_opl3sa2_write(chip, i, chip->ctlregs[i]); } /* restore cs4231 */ - chip->cs4231_resume(chip->cs4231); + chip->cs4231->resume(chip->cs4231); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ #ifdef CONFIG_PNP -static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, - struct pnp_dev *pdev, - int isapnp) +static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, + struct pnp_dev *pdev) { struct pnp_resource_table * cfg; int err; - if (!isapnp && pnp_device_is_isapnp(pdev)) - return -ENOENT; /* we have another procedure - card */ - cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); - if (!cfg) + if (!cfg) { + snd_printk(KERN_ERR PFX "cannot allocate pnp cfg\n"); return -ENOMEM; + } /* PnP initialization */ pnp_init_resource_table(cfg); if (sb_port[dev] != SNDRV_AUTO_PORT) @@ -609,8 +610,8 @@ static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, if (irq[dev] != SNDRV_AUTO_IRQ) pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0 && isapnp) - snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); + if (err < 0) + snd_printk(KERN_WARNING "PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { kfree(cfg); @@ -630,111 +631,47 @@ static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]); kfree(cfg); - chip->dev = pdev; return 0; } - -static int __init snd_opl3sa2_cpnp(int dev, opl3sa2_t *chip, - struct pnp_card_link *card, - const struct pnp_card_device_id *id) -{ - struct pnp_dev *pdev; - struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); - - if (!cfg) - return -ENOMEM; - pdev = pnp_request_card_device(card, id->devs[0].id, NULL); - if (pdev == NULL) { - kfree(cfg); - return -EBUSY; - } - return snd_opl3sa2_pnp(dev, chip, pdev, 1); -} #endif /* CONFIG_PNP */ -static int snd_opl3sa2_free(opl3sa2_t *chip) +static void snd_opl3sa2_free(struct snd_card *card) { + struct snd_opl3sa2 *chip = card->private_data; if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); release_and_free_resource(chip->res_port); - kfree(chip); - return 0; } -static int snd_opl3sa2_dev_free(snd_device_t *device) -{ - opl3sa2_t *chip = device->device_data; - return snd_opl3sa2_free(chip); -} - -#ifdef CONFIG_PNP -#define is_isapnp_selected(dev) isapnp[dev] -#else -#define is_isapnp_selected(dev) 0 -#endif - -static int __devinit snd_opl3sa2_probe(int dev, - struct pnp_dev *pdev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_opl3sa2_card_new(int dev) { - int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_opl3sa2 *chip; - cs4231_t *cs4231; - opl3_t *opl3; - static snd_device_ops_t ops = { - .dev_free = snd_opl3sa2_dev_free, - }; - int err; - - if (! is_isapnp_selected(dev)) { - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify port\n"); - return -EINVAL; - } - if (wss_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify wss_port\n"); - return -EINVAL; - } - if (fm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify fm_port\n"); - return -EINVAL; - } - if (midi_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify midi_port\n"); - return -EINVAL; - } - } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_opl3sa2)); if (card == NULL) - return -ENOMEM; + return NULL; strcpy(card->driver, "OPL3SA2"); strcpy(card->shortname, "Yamaha OPL3-SA2"); - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) { - err = -ENOMEM; - goto __error; - } + chip = card->private_data; spin_lock_init(&chip->reg_lock); chip->irq = -1; - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) - goto __error; -#ifdef CONFIG_PNP - if (pdev) { - if ((err = snd_opl3sa2_pnp(dev, chip, pdev, 0)) < 0) - goto __error; - snd_card_set_dev(card, &pdev->dev); - } - if (pcard) { - if ((err = snd_opl3sa2_cpnp(dev, chip, pcard, pid)) < 0) - goto __error; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif - chip->ymode = opl3sa3_ymode[dev] & 0x03 ; /* initialise this card from supplied (or default) parameter*/ chip->card = card; + card->private_free = snd_opl3sa2_free; + return card; +} + +static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev) +{ + int xirq, xdma1, xdma2; + struct snd_opl3sa2 *chip; + struct snd_cs4231 *cs4231; + struct snd_opl3 *opl3; + int err; + + /* initialise this card from supplied (or default) parameter*/ + chip = card->private_data; + chip->ymode = opl3sa3_ymode[dev] & 0x03 ; chip->port = port[dev]; xirq = irq[dev]; xdma1 = dma1[dev]; @@ -742,11 +679,10 @@ static int __devinit snd_opl3sa2_probe(int dev, if (xdma2 < 0) chip->single_dma = 1; if ((err = snd_opl3sa2_detect(chip)) < 0) - goto __error; - if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) { + return err; + if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", chip)) { snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq); - err = -ENODEV; - goto __error; + return -ENODEV; } chip->irq = xirq; if ((err = snd_cs4231_create(card, @@ -756,179 +692,303 @@ static int __devinit snd_opl3sa2_probe(int dev, CS4231_HWSHARE_IRQ, &cs4231)) < 0) { snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4); - goto __error; + return err; } chip->cs4231 = cs4231; if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) - goto __error; + return err; if ((err = snd_cs4231_mixer(cs4231)) < 0) - goto __error; + return err; if ((err = snd_opl3sa2_mixer(chip)) < 0) - goto __error; + return err; if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0) - goto __error; + return err; if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { if ((err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) - goto __error; + return err; if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) - goto __error; + return err; if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0) - goto __error; + return err; } if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2, midi_port[dev], 0, xirq, 0, &chip->rmidi)) < 0) - goto __error; + return err; } -#ifdef CONFIG_PM - chip->cs4231_suspend = chip->cs4231->suspend; - chip->cs4231_resume = chip->cs4231->resume; - /* now clear callbacks for cs4231 */ - chip->cs4231->suspend = NULL; - chip->cs4231->resume = NULL; - snd_card_set_isa_pm_callback(card, snd_opl3sa2_suspend, snd_opl3sa2_resume, chip); -#endif - sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", card->shortname, chip->port, xirq, xdma1); if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto __error; - - if ((err = snd_card_register(card)) < 0) - goto __error; - - if (pdev) - pnp_set_drvdata(pdev, card); - else if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_opl3sa2_legacy[dev] = card; - return 0; - - __error: - snd_card_free(card); - return err; + return snd_card_register(card); } #ifdef CONFIG_PNP static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, const struct pnp_device_id *id) { - static int dev; - int res; + static int dev; + int err; + struct snd_card *card; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_opl3sa2_probe(dev, pdev, NULL, NULL); - if (res < 0) - return res; - dev++; - return 0; - } - return -ENODEV; + if (pnp_device_is_isapnp(pdev)) + return -ENOENT; /* we have another procedure - card */ + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_drvdata(pdev, card); + dev++; + return 0; } static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev) { - snd_card_t *card = (snd_card_t *) pnp_get_drvdata(pdev); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_drvdata(pdev)); + pnp_set_drvdata(pdev, NULL); +} + +#ifdef CONFIG_PM +static int snd_opl3sa2_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) +{ + return snd_opl3sa2_suspend(pnp_get_drvdata(pdev), state); } +static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev) +{ + return snd_opl3sa2_resume(pnp_get_drvdata(pdev)); +} +#endif static struct pnp_driver opl3sa2_pnp_driver = { .name = "opl3sa2-pnpbios", .id_table = snd_opl3sa2_pnpbiosids, .probe = snd_opl3sa2_pnp_detect, .remove = __devexit_p(snd_opl3sa2_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_pnp_suspend, + .resume = snd_opl3sa2_pnp_resume, +#endif }; -static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card, +static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, const struct pnp_card_device_id *id) { - static int dev; - int res; + static int dev; + struct pnp_dev *pdev; + int err; + struct snd_card *card; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) - continue; - res = snd_opl3sa2_probe(dev, NULL, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - return -ENODEV; + pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); + if (pdev == NULL) { + snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n", + id->devs[0].id); + return -EBUSY; + } + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_opl3sa2_pnp_csuspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_opl3sa2_suspend(pnp_get_card_drvdata(pcard), state); +} +static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard) +{ + return snd_opl3sa2_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver opl3sa2_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "opl3sa2", .id_table = snd_opl3sa2_pnpids, .probe = snd_opl3sa2_pnp_cdetect, .remove = __devexit_p(snd_opl3sa2_pnp_cremove), +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_pnp_csuspend, + .resume = snd_opl3sa2_pnp_cresume, +#endif }; #endif /* CONFIG_PNP */ +static int __init snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) +{ + struct snd_card *card; + int err; + int dev = pdev->id; + + if (port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify port\n"); + return -EINVAL; + } + if (wss_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify wss_port\n"); + return -EINVAL; + } + if (fm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify fm_port\n"); + return -EINVAL; + } + if (midi_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify midi_port\n"); + return -EINVAL; + } + + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(pdev, card); + return 0; +} + +static int snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); +} + +static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) +{ + return snd_opl3sa2_resume(platform_get_drvdata(dev)); +} +#endif + +#define OPL3SA2_DRIVER "snd_opl3sa2" + +static struct platform_driver snd_opl3sa2_nonpnp_driver = { + .probe = snd_opl3sa2_nonpnp_probe, + .remove = snd_opl3sa2_nonpnp_remove, +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_nonpnp_suspend, + .resume = snd_opl3sa2_nonpnp_resume, +#endif + .driver = { + .name = OPL3SA2_DRIVER + }, +}; + +static void __init_or_module snd_opl3sa2_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&opl3sa2_pnpc_driver); + if (pnp_registered) + pnp_unregister_driver(&opl3sa2_pnp_driver); + 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 dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; + if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (snd_opl3sa2_probe(dev, NULL, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(OPL3SA2_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + platform_devices[i] = device; + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_driver(&opl3sa2_pnp_driver); - cards += pnp_register_card_driver(&opl3sa2_pnpc_driver); -#endif + + err = pnp_register_driver(&opl3sa2_pnp_driver); + if (err >= 0) { + pnp_registered = 1; + cards += err; + } + err = pnp_register_card_driver(&opl3sa2_pnpc_driver); + if (err >= 0) { + pnpc_registered = 1; + cards += err; + } + if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); #endif -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); -#endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_opl3sa2_unregister_all(); + return err; } static void __exit alsa_card_opl3sa2_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_opl3sa2_legacy[idx]); + snd_opl3sa2_unregister_all(); } module_init(alsa_card_opl3sa2_init) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index b94339f8306f..1ea3944ef7ab 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -24,13 +24,15 @@ #include <sound/driver.h> -#include <asm/io.h> -#include <asm/dma.h> -#include <linux/delay.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> +#include <linux/delay.h> #include <linux/slab.h> #include <linux/pnp.h> #include <linux/moduleparam.h> +#include <asm/io.h> +#include <asm/dma.h> #include <sound/core.h> #ifdef CS4231 #include <sound/cs4231.h> @@ -120,8 +122,6 @@ MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver."); #define OPTi9XX_MC_REG(n) n -typedef struct _snd_opti9xx opti9xx_t; - #ifdef OPTi93X #define OPTi93X_INDEX 0x00 @@ -193,16 +193,14 @@ typedef struct _snd_opti9xx opti9xx_t; #define OPTi93X_IRQ_CAPTURE 0x08 -typedef struct _snd_opti93x opti93x_t; - -struct _snd_opti93x { +struct snd_opti93x { unsigned long port; struct resource *res_port; int irq; int dma1; int dma2; - opti9xx_t *chip; + struct snd_opti9xx *chip; unsigned short hardware; unsigned char image[32]; @@ -212,10 +210,10 @@ struct _snd_opti93x { spinlock_t lock; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned int p_dma_size; unsigned int c_dma_size; }; @@ -227,7 +225,7 @@ struct _snd_opti93x { #endif /* OPTi93X */ -struct _snd_opti9xx { +struct snd_opti9xx { unsigned short hardware; unsigned char password; char name[7]; @@ -260,8 +258,8 @@ struct _snd_opti9xx { #endif /* CONFIG_PNP */ }; -static int snd_opti9xx_first_hit = 1; -static snd_card_t *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; +static int snd_opti9xx_pnp_is_probed; +static struct platform_device *snd_opti9xx_platform_device; #ifdef CONFIG_PNP @@ -296,7 +294,7 @@ static char * snd_opti9xx_names[] = { }; -static long snd_legacy_find_free_ioport(long *port_table, long size) +static long __init snd_legacy_find_free_ioport(long *port_table, long size) { while (*port_table != -1) { if (request_region(*port_table, size, "ALSA test")) { @@ -308,7 +306,7 @@ static long snd_legacy_find_free_ioport(long *port_table, long size) return -1; } -static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) +static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) { static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; @@ -363,7 +361,7 @@ static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) return 0; } -static unsigned char snd_opti9xx_read(opti9xx_t *chip, +static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, unsigned char reg) { unsigned long flags; @@ -406,7 +404,7 @@ static unsigned char snd_opti9xx_read(opti9xx_t *chip, return retval; } -static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg, +static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, unsigned char value) { unsigned long flags; @@ -453,7 +451,7 @@ static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg, (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) -static int __devinit snd_opti9xx_configure(opti9xx_t *chip) +static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) { unsigned char wss_base_bits; unsigned char irq_bits; @@ -684,7 +682,7 @@ static unsigned char snd_opti93x_default_image[32] = }; -static int snd_opti93x_busy_wait(opti93x_t *chip) +static int snd_opti93x_busy_wait(struct snd_opti93x *chip) { int timeout; @@ -696,14 +694,14 @@ static int snd_opti93x_busy_wait(opti93x_t *chip) return -EBUSY; } -static unsigned char snd_opti93x_in(opti93x_t *chip, unsigned char reg) +static unsigned char snd_opti93x_in(struct snd_opti93x *chip, unsigned char reg) { snd_opti93x_busy_wait(chip); outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX)); return inb(OPTi93X_PORT(chip, DATA)); } -static void snd_opti93x_out(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out(struct snd_opti93x *chip, unsigned char reg, unsigned char value) { snd_opti93x_busy_wait(chip); @@ -711,13 +709,13 @@ static void snd_opti93x_out(opti93x_t *chip, unsigned char reg, outb(value, OPTi93X_PORT(chip, DATA)); } -static void snd_opti93x_out_image(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out_image(struct snd_opti93x *chip, unsigned char reg, unsigned char value) { snd_opti93x_out(chip, reg, chip->image[reg] = value); } -static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out_mask(struct snd_opti93x *chip, unsigned char reg, unsigned char mask, unsigned char value) { snd_opti93x_out_image(chip, reg, @@ -725,7 +723,7 @@ static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg, } -static void snd_opti93x_mce_up(opti93x_t *chip) +static void snd_opti93x_mce_up(struct snd_opti93x *chip) { snd_opti93x_busy_wait(chip); @@ -734,7 +732,7 @@ static void snd_opti93x_mce_up(opti93x_t *chip) outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX)); } -static void snd_opti93x_mce_down(opti93x_t *chip) +static void snd_opti93x_mce_down(struct snd_opti93x *chip) { snd_opti93x_busy_wait(chip); @@ -746,7 +744,7 @@ static void snd_opti93x_mce_down(opti93x_t *chip) #define snd_opti93x_mute_reg(chip, reg, mute) \ snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]); -static void snd_opti93x_mute(opti93x_t *chip, int mute) +static void snd_opti93x_mute(struct snd_opti93x *chip, int mute) { mute = mute ? 1 : 0; if (chip->mute == mute) @@ -798,7 +796,7 @@ static unsigned int rates[] = { 5512, 6615, 8000, 9600, 11025, 16000, 44100, 48000 }; #define RATES ARRAY_SIZE(rates) -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = RATES, .list = rates, .mask = 0, @@ -820,7 +818,7 @@ static unsigned char snd_opti93x_get_freq(unsigned int rate) return bits[RATES-1]; } -static unsigned char snd_opti93x_get_format(opti93x_t *chip, +static unsigned char snd_opti93x_get_format(struct snd_opti93x *chip, unsigned int format, int channels) { unsigned char retval = OPTi93X_LINEAR_8; @@ -845,7 +843,7 @@ static unsigned char snd_opti93x_get_format(opti93x_t *chip, } -static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) +static void snd_opti93x_playback_format(struct snd_opti93x *chip, unsigned char fmt) { unsigned char mask; @@ -859,7 +857,7 @@ static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) snd_opti93x_mute(chip, 0); } -static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) +static void snd_opti93x_capture_format(struct snd_opti93x *chip, unsigned char fmt) { snd_opti93x_mute(chip, 1); @@ -875,7 +873,7 @@ static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) } -static int snd_opti93x_open(opti93x_t *chip, unsigned int mode) +static int snd_opti93x_open(struct snd_opti93x *chip, unsigned int mode) { unsigned long flags; @@ -899,7 +897,7 @@ static int snd_opti93x_open(opti93x_t *chip, unsigned int mode) return 0; } -static void snd_opti93x_close(opti93x_t *chip, unsigned int mode) +static void snd_opti93x_close(struct snd_opti93x *chip, unsigned int mode) { unsigned long flags; @@ -926,10 +924,10 @@ static void snd_opti93x_close(opti93x_t *chip, unsigned int mode) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_opti93x_trigger(snd_pcm_substream_t *substream, +static int snd_opti93x_trigger(struct snd_pcm_substream *substream, unsigned char what, int cmd) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -937,7 +935,7 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream, { unsigned int what = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == chip->playback_substream) { @@ -964,36 +962,36 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_opti93x_playback_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_opti93x_playback_trigger(struct snd_pcm_substream *substream, int cmd) { return snd_opti93x_trigger(substream, OPTi93X_PLAYBACK_ENABLE, cmd); } -static int snd_opti93x_capture_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_opti93x_capture_trigger(struct snd_pcm_substream *substream, int cmd) { return snd_opti93x_trigger(substream, OPTi93X_CAPTURE_ENABLE, cmd); } -static int snd_opti93x_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_opti93x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_opti93x_hw_free(snd_pcm_substream_t * substream) +static int snd_opti93x_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream) +static int snd_opti93x_playback_prepare(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned char format; unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -1023,10 +1021,10 @@ static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_prepare(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned char format; unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -1055,9 +1053,9 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) return 0; } -static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_opti93x_playback_pointer(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE)) @@ -1067,9 +1065,9 @@ static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_opti93x_capture_pointer(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE)) @@ -1080,7 +1078,7 @@ static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substr } -static void snd_opti93x_overrange(opti93x_t *chip) +static void snd_opti93x_overrange(struct snd_opti93x *chip) { unsigned long flags; @@ -1094,7 +1092,7 @@ static void snd_opti93x_overrange(opti93x_t *chip) static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - opti93x_t *codec = dev_id; + struct snd_opti93x *codec = dev_id; unsigned char status; status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11)); @@ -1109,7 +1107,7 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs * } -static snd_pcm_hardware_t snd_opti93x_playback = { +static struct snd_pcm_hardware snd_opti93x_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | @@ -1127,7 +1125,7 @@ static snd_pcm_hardware_t snd_opti93x_playback = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_opti93x_capture = { +static struct snd_pcm_hardware snd_opti93x_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | @@ -1145,11 +1143,11 @@ static snd_pcm_hardware_t snd_opti93x_capture = { .fifo_size = 0, }; -static int snd_opti93x_playback_open(snd_pcm_substream_t *substream) +static int snd_opti93x_playback_open(struct snd_pcm_substream *substream) { int error; - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0) return error; @@ -1161,11 +1159,11 @@ static int snd_opti93x_playback_open(snd_pcm_substream_t *substream) return error; } -static int snd_opti93x_capture_open(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_open(struct snd_pcm_substream *substream) { int error; - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0) return error; @@ -1177,18 +1175,18 @@ static int snd_opti93x_capture_open(snd_pcm_substream_t *substream) return error; } -static int snd_opti93x_playback_close(snd_pcm_substream_t *substream) +static int snd_opti93x_playback_close(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_opti93x_close(chip, OPTi93X_MODE_PLAY); return 0; } -static int snd_opti93x_capture_close(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_close(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE); @@ -1196,7 +1194,7 @@ static int snd_opti93x_capture_close(snd_pcm_substream_t *substream) } -static void snd_opti93x_init(opti93x_t *chip) +static void snd_opti93x_init(struct snd_opti93x *chip) { unsigned long flags; int i; @@ -1211,7 +1209,7 @@ static void snd_opti93x_init(opti93x_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_opti93x_probe(opti93x_t *chip) +static int snd_opti93x_probe(struct snd_opti93x *chip) { unsigned long flags; unsigned char val; @@ -1223,7 +1221,7 @@ static int snd_opti93x_probe(opti93x_t *chip) return (val == 0x0a) ? 0 : -ENODEV; } -static int snd_opti93x_free(opti93x_t *chip) +static int snd_opti93x_free(struct snd_opti93x *chip) { release_and_free_resource(chip->res_port); if (chip->dma1 >= 0) { @@ -1241,13 +1239,13 @@ static int snd_opti93x_free(opti93x_t *chip) return 0; } -static int snd_opti93x_dev_free(snd_device_t *device) +static int snd_opti93x_dev_free(struct snd_device *device) { - opti93x_t *chip = device->device_data; + struct snd_opti93x *chip = device->device_data; return snd_opti93x_free(chip); } -static const char *snd_opti93x_chip_id(opti93x_t *codec) +static const char *snd_opti93x_chip_id(struct snd_opti93x *codec) { switch (codec->hardware) { case OPTi9XX_HW_82C930: return "82C930"; @@ -1257,15 +1255,15 @@ static const char *snd_opti93x_chip_id(opti93x_t *codec) } } -static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, +static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip, int dma1, int dma2, - opti93x_t **rcodec) + struct snd_opti93x **rcodec) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_opti93x_dev_free, }; int error; - opti93x_t *codec; + struct snd_opti93x *codec; *rcodec = NULL; codec = kzalloc(sizeof(*codec), GFP_KERNEL); @@ -1324,7 +1322,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, return 0; } -static snd_pcm_ops_t snd_opti93x_playback_ops = { +static struct snd_pcm_ops snd_opti93x_playback_ops = { .open = snd_opti93x_playback_open, .close = snd_opti93x_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1335,7 +1333,7 @@ static snd_pcm_ops_t snd_opti93x_playback_ops = { .pointer = snd_opti93x_playback_pointer, }; -static snd_pcm_ops_t snd_opti93x_capture_ops = { +static struct snd_pcm_ops snd_opti93x_capture_ops = { .open = snd_opti93x_capture_open, .close = snd_opti93x_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1346,17 +1344,10 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = { .pointer = snd_opti93x_capture_pointer, }; -static void snd_opti93x_pcm_free(snd_pcm_t *pcm) -{ - opti93x_t *codec = pcm->private_data; - codec->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) +static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm **rpcm) { int error; - snd_pcm_t *pcm; + struct snd_pcm *pcm; if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm))) return error; @@ -1365,7 +1356,6 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops); pcm->private_data = codec; - pcm->private_free = snd_opti93x_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_opti93x_chip_id(codec)); @@ -1384,7 +1374,7 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) * MIXER part */ -static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line1", "Aux", "Mic", "Mix" @@ -1399,9 +1389,9 @@ static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -1411,9 +1401,9 @@ static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1442,7 +1432,7 @@ static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1453,9 +1443,9 @@ static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1470,9 +1460,9 @@ static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1507,7 +1497,7 @@ static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ do { xctl.private_value &= ~0x0000ffff; \ xctl.private_value |= left_reg | (right_reg << 8); } while (0) -static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1518,9 +1508,9 @@ static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1540,9 +1530,9 @@ static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1571,7 +1561,7 @@ static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_opti93x_controls[] = { +static struct snd_kcontrol_new snd_opti93x_controls[] = { 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), @@ -1597,10 +1587,10 @@ OPTi93X_DOUBLE("Capture Volume", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 0 } }; -static int snd_opti93x_mixer(opti93x_t *chip) +static int snd_opti93x_mixer(struct snd_opti93x *chip) { - snd_card_t *card; - snd_kcontrol_new_t knew; + struct snd_card *card; + struct snd_kcontrol_new knew; int err; unsigned int idx; @@ -1632,7 +1622,7 @@ static int snd_opti93x_mixer(opti93x_t *chip) #endif /* OPTi93X */ -static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) +static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) { int i, err; @@ -1686,8 +1676,8 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) } #ifdef CONFIG_PNP -static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link *card, - const struct pnp_card_device_id *pid) +static int __init 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,195 +1768,35 @@ static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link } #endif /* CONFIG_PNP */ -#if 0 -static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip, - snd_card_t *card) -{ - int error, i, pnp = 0; - -#ifdef CONFIG_PNP - pnp = chip->dev != NULL; -#endif /* CONFIG_PNP */ - -#ifndef OPTi93X - if (chip->chip->hardware == OPTi9XX_HW_82C928) - mpu_port = -1; -#endif /* OPTi93X */ - error = 0; - if (!pnp && (mpu_port == SNDRV_DEFAULT_PORT1)) { - for (i = 0; possible_mpu_ports[i] != -1; i++) - if (!snd_register_ioport(card, possible_mpu_ports[i], 2, - DRIVER_NAME" - MPU-401", NULL)) { - mpu_port = possible_mpu_ports[i]; - break; - } - if (mpu_port == SNDRV_DEFAULT_PORT1) - error = -EBUSY; - } - else - error = (mpu_port == -1) ? -ENODEV : - snd_register_ioport(card, mpu_port, 2, - DRIVER_NAME" - MPU-401", NULL); - if (error) - chip->chip->mpu_port = -1; - else if (pnp && (irq == mpu_irq)) - chip->chip->mpu_irq = mpu_irq; - else if (!snd_register_interrupt(card, - DRIVER_NAME" - MPU-401", - mpu_irq, SNDRV_IRQ_TYPE_ISA, - snd_card_opti9xx_mpu_interrupt, chip, - pnp ? no_alternatives : possible_mpu_irqs, - &chip->mpuirqptr)) { - chip->chip->mpu_port = mpu_port; - chip->chip->mpu_irq = chip->mpuirqptr->irq; - } - else - chip->chip->mpu_port = -1; - - if (!pnp && (port == SNDRV_DEFAULT_PORT1)) { - for (i = 0; possible_ports[i] != -1; i++) - if (!snd_register_ioport(card, possible_ports[i], 8, - DRIVER_NAME" - WSS", NULL)) { - port = possible_ports[i]; - break; - } - if (port == SNDRV_DEFAULT_PORT1) - return -EBUSY; - } - else if ((error = snd_register_ioport(card, port, 8, - DRIVER_NAME" - WSS", NULL)) < 0) - return error; - chip->chip->wss_base = port; - if ((error = snd_register_interrupt(card, DRIVER_NAME" - WSS", - irq, SNDRV_IRQ_TYPE_ISA, - snd_card_opti9xx_interrupt, chip, - pnp ? no_alternatives : possible_irqs, - &chip->irqptr)) < 0) - return error; - chip->chip->irq = chip->irqptr->irq; - if ((error = snd_register_dma_channel(card, -#if defined(CS4231) || defined(OPTi93X) - DRIVER_NAME" - WSS playback", -#else - DRIVER_NAME" - WSS", -#endif /* CS4231 || OPTi93X */ - dma1, SNDRV_DMA_TYPE_ISA, dma1_size, - pnp ? no_alternatives : possible_dma1s, - &chip->dma1ptr)) < 0) - return error; - chip->chip->dma1 = chip->dma1ptr->dma; -#if defined(CS4231) || defined(OPTi93X) - if ((error = snd_register_dma_channel(card, DRIVER_NAME" - WSS capture", - dma2, SNDRV_DMA_TYPE_ISA, dma2_size, - pnp ? no_alternatives : - possible_dma2s[chip->dma1ptr->dma], - &chip->dma2ptr)) < 0) - return error; - chip->chip->dma2 = chip->dma2ptr->dma; -#endif /* CS4231 || OPTi93X */ - - if (snd_register_ioport(card, - pnp ? fm_port : fm_port = 0x388, 4, - DRIVER_NAME" - OPL", NULL) < 0) - fm_port = -1; - chip->chip->fm_port = fm_port; - - return 0; -} -#endif - -static void snd_card_opti9xx_free(snd_card_t *card) +static void snd_card_opti9xx_free(struct snd_card *card) { - opti9xx_t *chip = (opti9xx_t *)card->private_data; + struct snd_opti9xx *chip = card->private_data; if (chip) release_and_free_resource(chip->res_mc_base); } -static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static int __init snd_opti9xx_probe(struct snd_card *card) { static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; - static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; -#ifdef OPTi93X - static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; -#else - static int possible_irqs[] = {9, 10, 11, 7, -1}; -#endif /* OPTi93X */ - static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dma1s[] = {3, 1, 0, -1}; -#if defined(CS4231) || defined(OPTi93X) - static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; -#endif /* CS4231 || OPTi93X */ int error; - opti9xx_t *chip; + struct snd_opti9xx *chip = card->private_data; #if defined(OPTi93X) - opti93x_t *codec; + struct snd_opti93x *codec; #elif defined(CS4231) - cs4231_t *codec; - snd_timer_t *timer; + struct snd_cs4231 *codec; + struct snd_timer *timer; #else - ad1848_t *codec; + struct snd_ad1848 *codec; #endif - snd_card_t *card; - snd_pcm_t *pcm; - snd_rawmidi_t *rmidi; - snd_hwdep_t *synth; -#ifdef CONFIG_PNP - int hw; -#endif /* CONFIG_PNP */ - - if (pcard && !snd_opti9xx_first_hit) - return -EBUSY; - if (!(card = snd_card_new(index, id, THIS_MODULE, - sizeof(opti9xx_t)))) - return -ENOMEM; - card->private_free = snd_card_opti9xx_free; - chip = (opti9xx_t *)card->private_data; - -#ifdef CONFIG_PNP - if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) { - switch (hw) { - case 0x0924: - hw = OPTi9XX_HW_82C924; - break; - case 0x0925: - hw = OPTi9XX_HW_82C925; - break; - case 0x0931: - hw = OPTi9XX_HW_82C931; - break; - default: - snd_card_free(card); - return -ENODEV; - } - - if ((error = snd_opti9xx_init(chip, hw))) { - snd_card_free(card); - return error; - } - if (hw <= OPTi9XX_HW_82C930) - chip->mc_base -= 0x80; - snd_card_set_dev(card, &pcard->card->dev); - } else { -#endif /* CONFIG_PNP */ - if ((error = snd_card_opti9xx_detect(card, chip)) < 0) { - snd_card_free(card); - return error; - } - if ((error = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return error; - } -#ifdef CONFIG_PNP - } -#endif /* CONFIG_PNP */ + struct snd_pcm *pcm; + struct snd_rawmidi *rmidi; + struct snd_hwdep *synth; if (! chip->res_mc_base && - (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) { - snd_card_free(card); + (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, + "OPTi9xx MC")) == NULL) return -ENOMEM; - } chip->wss_base = port; chip->fm_port = fm_port; @@ -1980,110 +1810,42 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, if (chip->wss_base == SNDRV_AUTO_PORT) { if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { - snd_card_free(card); snd_printk("unable to find a free WSS port\n"); return -EBUSY; } } -#ifdef CONFIG_PNP - if (!isapnp) { -#endif - if (chip->mpu_port == SNDRV_AUTO_PORT) { - if ((chip->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free MPU401 port\n"); - return -EBUSY; - } - } - if (chip->irq == SNDRV_AUTO_IRQ) { - if ((chip->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; - } - } - if (chip->mpu_irq == SNDRV_AUTO_IRQ) { - if ((chip->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free MPU401 IRQ\n"); - return -EBUSY; - } - } - if (chip->dma1 == SNDRV_AUTO_DMA) { - if ((chip->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; - } - } -#if defined(CS4231) || defined(OPTi93X) - if (chip->dma2 == SNDRV_AUTO_DMA) { - if ((chip->dma2 = snd_legacy_find_free_dma(possible_dma2s[chip->dma1 % 4])) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; - } - } -#endif - -#ifdef CONFIG_PNP - } -#endif - - if ((error = snd_opti9xx_configure(chip))) { - snd_card_free(card); + if ((error = snd_opti9xx_configure(chip))) return error; - } #if defined(OPTi93X) - if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) { - snd_card_free(card); + if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) return error; - } - if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_opti93x_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_opti93x_mixer(codec)) < 0) return error; - } #elif defined(CS4231) if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1, chip->irq, chip->dma1, chip->dma2, CS4231_HW_DETECT, 0, - &codec)) < 0) { - snd_card_free(card); + &codec)) < 0) return error; - } - if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_cs4231_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_mixer(codec)) < 0) return error; - } - if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) return error; - } #else if ((error = snd_ad1848_create(card, chip->wss_base + 4, chip->irq, chip->dma1, - AD1848_HW_DETECT, &codec)) < 0) { - snd_card_free(card); + AD1848_HW_DETECT, &codec)) < 0) return error; - } - if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_ad1848_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_ad1848_mixer(codec)) < 0) return error; - } #endif strcpy(card->driver, chip->name); sprintf(card->shortname, "OPTi %s", card->driver); @@ -2103,15 +1865,16 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, chip->mpu_port, 0, chip->mpu_irq, SA_INTERRUPT, &rmidi))) - snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port); + snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", + chip->mpu_port); if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { - opl3_t *opl3 = NULL; + struct snd_opl3 *opl3 = NULL; #ifndef OPTi93X if (chip->hardware == OPTi9XX_HW_82C928 || chip->hardware == OPTi9XX_HW_82C929 || chip->hardware == OPTi9XX_HW_82C924) { - opl4_t *opl4; + struct snd_opl4 *opl4; /* assume we have an OPL4 */ snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); @@ -2129,89 +1892,230 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, chip->fm_port, chip->fm_port + 2, OPL3_HW_AUTO, 0, &opl3) < 0) { - snd_printk("no OPL device at 0x%lx-0x%lx\n", + snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", chip->fm_port, chip->fm_port + 4 - 1); } if (opl3) { - if ((error = snd_opl3_timer_new(opl3, #ifdef CS4231 - 1, 2)) < 0) { + const int t1dev = 1; #else - 0, 1)) < 0) { -#endif /* CS4231 */ - snd_card_free(card); + const int t1dev = 0; +#endif + if ((error = snd_opl3_timer_new(opl3, t1dev, t1dev+1)) < 0) return error; - } - if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) { - snd_card_free(card); + if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) return error; - } } } - if ((error = snd_card_register(card))) { + return snd_card_register(card); +} + +static struct snd_card *snd_opti9xx_card_new(void) +{ + struct snd_card *card; + + card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx)); + if (! card) + return NULL; + card->private_free = snd_card_opti9xx_free; + return card; +} + +static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) +{ + struct snd_card *card; + int error; + static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; +#ifdef OPTi93X + static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; +#else + static int possible_irqs[] = {9, 10, 11, 7, -1}; +#endif /* OPTi93X */ + static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; + static int possible_dma1s[] = {3, 1, 0, -1}; +#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"); + return -EBUSY; + } + } + if (irq == SNDRV_AUTO_IRQ) { + if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (mpu_irq == SNDRV_AUTO_IRQ) { + if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { + snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); + return -EBUSY; + } + } + if (dma1 == SNDRV_AUTO_DMA) { + if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { + snd_printk(KERN_ERR "unable to find a free DMA1\n"); + return -EBUSY; + } + } +#if defined(CS4231) || defined(OPTi93X) + if (dma2 == SNDRV_AUTO_DMA) { + if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) { + snd_printk("unable to find a free DMA2\n"); + return -EBUSY; + } + } +#endif + + card = snd_opti9xx_card_new(); + if (! card) + return -ENOMEM; + + if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) { snd_card_free(card); return error; } - snd_opti9xx_first_hit = 0; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_opti9xx_legacy = card; + snd_card_set_dev(card, &devptr->dev); + if ((error = snd_opti9xx_probe(card)) < 0) { + snd_card_free(card); + return error; + } + platform_set_drvdata(devptr, card); + return 0; +} + +static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_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), + /* FIXME: suspend/resume */ + .driver = { + .name = DRIVER_NAME + }, +}; + #ifdef CONFIG_PNP -static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) +static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card; + int error, hw; + struct snd_opti9xx *chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); - snd_opti9xx_first_hit = 0; + if (snd_opti9xx_pnp_is_probed) + return -EBUSY; + if (! isapnp) + return -ENODEV; + card = snd_opti9xx_card_new(); + if (! card) + return -ENOMEM; + chip = card->private_data; + + hw = snd_card_opti9xx_pnp(chip, pcard, pid); + switch (hw) { + case 0x0924: + hw = OPTi9XX_HW_82C924; + break; + case 0x0925: + hw = OPTi9XX_HW_82C925; + break; + case 0x0931: + hw = OPTi9XX_HW_82C931; + break; + default: + snd_card_free(card); + return -ENODEV; + } + + if ((error = snd_opti9xx_init(chip, hw))) { + snd_card_free(card); + return error; + } + if (hw <= OPTi9XX_HW_82C930) + chip->mc_base -= 0x80; + snd_card_set_dev(card, &pcard->card->dev); + if ((error = snd_opti9xx_probe(card)) < 0) { + snd_card_free(card); + return error; + } + pnp_set_card_drvdata(pcard, card); + snd_opti9xx_pnp_is_probed = 1; + return 0; +} + +static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) +{ + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); + snd_opti9xx_pnp_is_probed = 0; } static struct pnp_card_driver opti9xx_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "opti9xx", .id_table = snd_opti9xx_pnpids, - .probe = snd_card_opti9xx_probe, + .probe = snd_opti9xx_pnp_probe, .remove = __devexit_p(snd_opti9xx_pnp_remove), }; #endif -static int __init alsa_card_opti9xx_init(void) -{ - int cards, error; - #ifdef CONFIG_PNP - cards = pnp_register_card_driver(&opti9xx_pnpc_driver); +#define is_isapnp_selected() isapnp #else - cards = 0; -#endif - if (cards == 0 && (error = snd_card_opti9xx_probe(NULL, NULL)) < 0) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&opti9xx_pnpc_driver); +#define is_isapnp_selected() 0 #endif -#ifdef MODULE #ifdef OPTi93X - printk(KERN_ERR "no OPTi 82C93x soundcard found\n"); +#define CHIP_NAME "82C93x" #else - printk(KERN_ERR "no OPTi 82C92x soundcard found\n"); -#endif /* OPTi93X */ +#define CHIP_NAME "82C92x" #endif - return error; + +static int __init alsa_card_opti9xx_init(void) +{ + int error; + struct platform_device *device; + + pnp_register_card_driver(&opti9xx_pnpc_driver); + if (snd_opti9xx_pnp_is_probed) + return 0; + 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)) { + snd_opti9xx_platform_device = device; + return 0; + } + platform_driver_unregister(&snd_opti9xx_driver); } - return 0; + pnp_unregister_card_driver(&opti9xx_pnpc_driver); +#ifdef MODULE + printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n"); +#endif + return -ENODEV; } static void __exit alsa_card_opti9xx_exit(void) { -#ifdef CONFIG_PNP + if (!snd_opti9xx_pnp_is_probed) { + platform_device_unregister(snd_opti9xx_platform_device); + platform_driver_unregister(&snd_opti9xx_driver); + } pnp_unregister_card_driver(&opti9xx_pnpc_driver); -#endif - if (snd_opti9xx_legacy) - snd_card_free(snd_opti9xx_legacy); } module_init(alsa_card_opti9xx_init) diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index b09c6575e01a..c0b8d61b75e7 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -45,7 +45,7 @@ * directly. The macros handle the port number and command word. */ /* Write a word */ -void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) +void snd_emu8000_poke(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val) { unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -58,7 +58,7 @@ void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsig } /* Read a word */ -unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int reg) +unsigned short snd_emu8000_peek(struct snd_emu8000 *emu, unsigned int port, unsigned int reg) { unsigned short res; unsigned long flags; @@ -73,7 +73,7 @@ unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int } /* Write a double word */ -void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) +void snd_emu8000_poke_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val) { unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -87,7 +87,7 @@ void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, un } /* Read a double word */ -unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int reg) +unsigned int snd_emu8000_peek_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg) { unsigned short low; unsigned int res; @@ -107,7 +107,7 @@ unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int * Set up / close a channel to be used for DMA. */ /*exported*/ void -snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode) +snd_emu8000_dma_chan(struct snd_emu8000 *emu, int ch, int mode) { unsigned right_bit = (mode & EMU8000_RAM_RIGHT) ? 0x01000000 : 0; mode &= EMU8000_RAM_MODE_MASK; @@ -132,7 +132,7 @@ snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode) /* */ static void __init -snd_emu8000_read_wait(emu8000_t *emu) +snd_emu8000_read_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -144,7 +144,7 @@ snd_emu8000_read_wait(emu8000_t *emu) /* */ static void __init -snd_emu8000_write_wait(emu8000_t *emu) +snd_emu8000_write_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -157,7 +157,7 @@ snd_emu8000_write_wait(emu8000_t *emu) * detect a card at the given port */ static int __init -snd_emu8000_detect(emu8000_t *emu) +snd_emu8000_detect(struct snd_emu8000 *emu) { /* Initialise */ EMU8000_HWCF1_WRITE(emu, 0x0059); @@ -183,7 +183,7 @@ snd_emu8000_detect(emu8000_t *emu) * intiailize audio channels */ static void __init -init_audio(emu8000_t *emu) +init_audio(struct snd_emu8000 *emu) { int ch; @@ -224,7 +224,7 @@ init_audio(emu8000_t *emu) * initialize DMA address */ static void __init -init_dma(emu8000_t *emu) +init_dma(struct snd_emu8000 *emu) { EMU8000_SMALR_WRITE(emu, 0); EMU8000_SMARR_WRITE(emu, 0); @@ -328,7 +328,7 @@ static unsigned short init4[128] /*__devinitdata*/ = { * is meant to work */ static void __init -send_array(emu8000_t *emu, unsigned short *data, int size) +send_array(struct snd_emu8000 *emu, unsigned short *data, int size) { int i; unsigned short *p; @@ -350,7 +350,7 @@ send_array(emu8000_t *emu, unsigned short *data, int size) * initialisation sequence in the adip. */ static void __init -init_arrays(emu8000_t *emu) +init_arrays(struct snd_emu8000 *emu) { send_array(emu, init1, ARRAY_SIZE(init1)/4); @@ -376,7 +376,7 @@ init_arrays(emu8000_t *emu) * reallocating between read and write. */ static void __init -size_dram(emu8000_t *emu) +size_dram(struct snd_emu8000 *emu) { int i, size; @@ -455,7 +455,7 @@ size_dram(emu8000_t *emu) * and therefore lose 2 voices. */ /*exported*/ void -snd_emu8000_init_fm(emu8000_t *emu) +snd_emu8000_init_fm(struct snd_emu8000 *emu) { unsigned long flags; @@ -501,7 +501,7 @@ snd_emu8000_init_fm(emu8000_t *emu) * The main initialization routine. */ static void __init -snd_emu8000_init_hw(emu8000_t *emu) +snd_emu8000_init_hw(struct snd_emu8000 *emu) { int i; @@ -585,7 +585,7 @@ static unsigned short treble_parm[12][9] = { * set Emu8000 digital equalizer; from 0 to 11 [-12dB - 12dB] */ /*exported*/ void -snd_emu8000_update_equalizer(emu8000_t *emu) +snd_emu8000_update_equalizer(struct snd_emu8000 *emu) { unsigned short w; int bass = emu->bass_level; @@ -628,17 +628,17 @@ snd_emu8000_update_equalizer(emu8000_t *emu) /* user can define chorus modes up to 32 */ #define SNDRV_EMU8000_CHORUS_NUMBERS 32 -typedef struct soundfont_chorus_fx_t { +struct soundfont_chorus_fx { unsigned short feedback; /* feedback level (0xE600-0xE6FF) */ unsigned short delay_offset; /* delay (0-0x0DA3) [1/44100 sec] */ unsigned short lfo_depth; /* LFO depth (0xBC00-0xBCFF) */ unsigned int delay; /* right delay (0-0xFFFFFFFF) [1/256/44100 sec] */ unsigned int lfo_freq; /* LFO freq LFO freq (0-0xFFFFFFFF) */ -} soundfont_chorus_fx_t; +}; /* 5 parameters for each chorus mode; 3 x 16bit, 2 x 32bit */ static char chorus_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; -static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { +static struct soundfont_chorus_fx chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { {0xE600, 0x03F6, 0xBC2C ,0x00000000, 0x0000006D}, /* chorus 1 */ {0xE608, 0x031A, 0xBC6E, 0x00000000, 0x0000017C}, /* chorus 2 */ {0xE610, 0x031A, 0xBC84, 0x00000000, 0x00000083}, /* chorus 3 */ @@ -650,9 +650,9 @@ static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { }; /*exported*/ int -snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, long len) +snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len) { - soundfont_chorus_fx_t rec; + struct soundfont_chorus_fx rec; if (mode < SNDRV_EMU8000_CHORUS_PREDEFINED || mode >= SNDRV_EMU8000_CHORUS_NUMBERS) { snd_printk(KERN_WARNING "invalid chorus mode %d for uploading\n", mode); return -EINVAL; @@ -665,7 +665,7 @@ snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, lon } /*exported*/ void -snd_emu8000_update_chorus_mode(emu8000_t *emu) +snd_emu8000_update_chorus_mode(struct snd_emu8000 *emu) { int effect = emu->chorus_mode; if (effect < 0 || effect >= SNDRV_EMU8000_CHORUS_NUMBERS || @@ -699,15 +699,15 @@ snd_emu8000_update_chorus_mode(emu8000_t *emu) /* user can define reverb modes up to 32 */ #define SNDRV_EMU8000_REVERB_NUMBERS 32 -typedef struct soundfont_reverb_fx_t { +struct soundfont_reverb_fx { unsigned short parms[28]; -} soundfont_reverb_fx_t; +}; /* reverb mode settings; write the following 28 data of 16 bit length * on the corresponding ports in the reverb_cmds array */ static char reverb_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; -static soundfont_reverb_fx_t reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = { +static struct soundfont_reverb_fx reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = { {{ /* room 1 */ 0xB488, 0xA450, 0x9550, 0x84B5, 0x383A, 0x3EB5, 0x72F4, 0x72A4, 0x7254, 0x7204, 0x7204, 0x7204, 0x4416, 0x4516, @@ -777,9 +777,9 @@ static struct reverb_cmd_pair { }; /*exported*/ int -snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, long len) +snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len) { - soundfont_reverb_fx_t rec; + struct soundfont_reverb_fx rec; if (mode < SNDRV_EMU8000_REVERB_PREDEFINED || mode >= SNDRV_EMU8000_REVERB_NUMBERS) { snd_printk(KERN_WARNING "invalid reverb mode %d for uploading\n", mode); @@ -793,7 +793,7 @@ snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, lon } /*exported*/ void -snd_emu8000_update_reverb_mode(emu8000_t *emu) +snd_emu8000_update_reverb_mode(struct snd_emu8000 *emu) { int effect = emu->reverb_mode; int i; @@ -819,7 +819,7 @@ snd_emu8000_update_reverb_mode(emu8000_t *emu) /* * bass/treble */ -static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_bass_treble_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -828,17 +828,17 @@ static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int mixer_bass_treble_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_bass_treble_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->treble_level : emu->bass_level; return 0; } -static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_bass_treble_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -857,7 +857,7 @@ static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t mixer_bass_control = +static struct snd_kcontrol_new mixer_bass_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Bass", @@ -867,7 +867,7 @@ static snd_kcontrol_new_t mixer_bass_control = .private_value = 0, }; -static snd_kcontrol_new_t mixer_treble_control = +static struct snd_kcontrol_new mixer_treble_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Treble", @@ -880,7 +880,7 @@ static snd_kcontrol_new_t mixer_treble_control = /* * chorus/reverb mode */ -static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_chorus_reverb_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -889,17 +889,17 @@ static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int mixer_chorus_reverb_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_chorus_reverb_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->chorus_mode : emu->reverb_mode; return 0; } -static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_chorus_reverb_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -924,7 +924,7 @@ static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t mixer_chorus_mode_control = +static struct snd_kcontrol_new mixer_chorus_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Chorus Mode", @@ -934,7 +934,7 @@ static snd_kcontrol_new_t mixer_chorus_mode_control = .private_value = 1, }; -static snd_kcontrol_new_t mixer_reverb_mode_control = +static struct snd_kcontrol_new mixer_reverb_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Reverb Mode", @@ -947,7 +947,7 @@ static snd_kcontrol_new_t mixer_reverb_mode_control = /* * FM OPL3 chorus/reverb depth */ -static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_fm_depth_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -956,17 +956,17 @@ static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int mixer_fm_depth_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_fm_depth_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->fm_chorus_depth : emu->fm_reverb_depth; return 0; } -static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_fm_depth_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -986,7 +986,7 @@ static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t mixer_fm_chorus_depth_control = +static struct snd_kcontrol_new mixer_fm_chorus_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Chorus Depth", @@ -996,7 +996,7 @@ static snd_kcontrol_new_t mixer_fm_chorus_depth_control = .private_value = 1, }; -static snd_kcontrol_new_t mixer_fm_reverb_depth_control = +static struct snd_kcontrol_new mixer_fm_reverb_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Reverb Depth", @@ -1007,7 +1007,7 @@ static snd_kcontrol_new_t mixer_fm_reverb_depth_control = }; -static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = { +static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = { &mixer_bass_control, &mixer_treble_control, &mixer_chorus_mode_control, @@ -1020,7 +1020,7 @@ static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = { * create and attach mixer elements for WaveTable treble/bass controls */ static int __init -snd_emu8000_create_mixer(snd_card_t *card, emu8000_t *emu) +snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu) { int i, err = 0; @@ -1049,7 +1049,7 @@ __error: /* * free resources */ -static int snd_emu8000_free(emu8000_t *hw) +static int snd_emu8000_free(struct snd_emu8000 *hw) { release_and_free_resource(hw->res_port1); release_and_free_resource(hw->res_port2); @@ -1060,9 +1060,9 @@ static int snd_emu8000_free(emu8000_t *hw) /* */ -static int snd_emu8000_dev_free(snd_device_t *device) +static int snd_emu8000_dev_free(struct snd_device *device) { - emu8000_t *hw = device->device_data; + struct snd_emu8000 *hw = device->device_data; return snd_emu8000_free(hw); } @@ -1070,12 +1070,13 @@ static int snd_emu8000_dev_free(snd_device_t *device) * initialize and register emu8000 synth device. */ int __init -snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_device_t **awe_ret) +snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, + struct snd_seq_device **awe_ret) { - snd_seq_device_t *awe; - emu8000_t *hw; + struct snd_seq_device *awe; + struct snd_emu8000 *hw; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_emu8000_dev_free, }; @@ -1127,9 +1128,9 @@ snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_d } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000, - sizeof(emu8000_t*), &awe) >= 0) { + sizeof(struct snd_emu8000*), &awe) >= 0) { strcpy(awe->name, "EMU-8000"); - *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; + *(struct snd_emu8000 **)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; } #else awe = NULL; diff --git a/sound/isa/sb/emu8000_callback.c b/sound/isa/sb/emu8000_callback.c index 1cc4101a17a4..9a3c71cc2e07 100644 --- a/sound/isa/sb/emu8000_callback.c +++ b/sound/isa/sb/emu8000_callback.c @@ -25,27 +25,30 @@ /* * prototypes */ -static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port); -static int start_voice(snd_emux_voice_t *vp); -static void trigger_voice(snd_emux_voice_t *vp); -static void release_voice(snd_emux_voice_t *vp); -static void update_voice(snd_emux_voice_t *vp, int update); -static void reset_voice(snd_emux_t *emu, int ch); -static void terminate_voice(snd_emux_voice_t *vp); -static void sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset); +static struct snd_emux_voice *get_voice(struct snd_emux *emu, + struct snd_emux_port *port); +static int start_voice(struct snd_emux_voice *vp); +static void trigger_voice(struct snd_emux_voice *vp); +static void release_voice(struct snd_emux_voice *vp); +static void update_voice(struct snd_emux_voice *vp, int update); +static void reset_voice(struct snd_emux *emu, int ch); +static void terminate_voice(struct snd_emux_voice *vp); +static void sysex(struct snd_emux *emu, char *buf, int len, int parsed, + struct snd_midi_channel_set *chset); #ifdef CONFIG_SND_SEQUENCER_OSS -static int oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2); +static int oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2); #endif -static int load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len); - -static void set_pitch(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_volume(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_pan(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp); -static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch); +static int load_fx(struct snd_emux *emu, int type, int mode, + const void __user *buf, long len); + +static void set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int ch); /* * Ensure a value is between two points @@ -58,7 +61,7 @@ static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch); /* * set up operators */ -static snd_emux_operators_t emu8000_ops = { +static struct snd_emux_operators emu8000_ops = { .owner = THIS_MODULE, .get_voice = get_voice, .prepare = start_voice, @@ -78,7 +81,7 @@ static snd_emux_operators_t emu8000_ops = { }; void -snd_emu8000_ops_setup(emu8000_t *hw) +snd_emu8000_ops_setup(struct snd_emu8000 *hw) { hw->emu->ops = emu8000_ops; } @@ -89,10 +92,10 @@ snd_emu8000_ops_setup(emu8000_t *hw) * Terminate a voice */ static void -release_voice(snd_emux_voice_t *vp) +release_voice(struct snd_emux_voice *vp) { int dcysusv; - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease; @@ -105,9 +108,9 @@ release_voice(snd_emux_voice_t *vp) /* */ static void -terminate_voice(snd_emux_voice_t *vp) +terminate_voice(struct snd_emux_voice *vp) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; EMU8000_DCYSUSV_WRITE(hw, vp->ch, 0x807F); @@ -117,9 +120,9 @@ terminate_voice(snd_emux_voice_t *vp) /* */ static void -update_voice(snd_emux_voice_t *vp, int update) +update_voice(struct snd_emux_voice *vp, int update) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; if (update & SNDRV_EMUX_UPDATE_VOLUME) @@ -149,12 +152,12 @@ update_voice(snd_emux_voice_t *vp, int update) * The channel index (vp->ch) must be initialized in this routine. * In Emu8k, it is identical with the array index. */ -static snd_emux_voice_t * -get_voice(snd_emux_t *emu, snd_emux_port_t *port) +static struct snd_emux_voice * +get_voice(struct snd_emux *emu, struct snd_emux_port *port) { int i; - snd_emux_voice_t *vp; - emu8000_t *hw; + struct snd_emux_voice *vp; + struct snd_emu8000 *hw; /* what we are looking for, in order of preference */ enum { @@ -227,13 +230,13 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) /* */ static int -start_voice(snd_emux_voice_t *vp) +start_voice(struct snd_emux_voice *vp) { unsigned int temp; int ch; int addr; - snd_midi_channel_t *chan; - emu8000_t *hw; + struct snd_midi_channel *chan; + struct snd_emu8000 *hw; hw = vp->hw; ch = vp->ch; @@ -307,11 +310,11 @@ start_voice(snd_emux_voice_t *vp) * Start envelope */ static void -trigger_voice(snd_emux_voice_t *vp) +trigger_voice(struct snd_emux_voice *vp) { int ch = vp->ch; unsigned int temp; - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; @@ -329,9 +332,9 @@ trigger_voice(snd_emux_voice_t *vp) * reset voice parameters */ static void -reset_voice(snd_emux_t *emu, int ch) +reset_voice(struct snd_emux *emu, int ch) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); @@ -342,7 +345,7 @@ reset_voice(snd_emux_t *emu, int ch) * Set the pitch of a possibly playing note. */ static void -set_pitch(emu8000_t *hw, snd_emux_voice_t *vp) +set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { EMU8000_IP_WRITE(hw, vp->ch, vp->apitch); } @@ -351,7 +354,7 @@ set_pitch(emu8000_t *hw, snd_emux_voice_t *vp) * Set the volume of a possibly already playing note */ static void -set_volume(emu8000_t *hw, snd_emux_voice_t *vp) +set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { int ifatn; @@ -365,7 +368,7 @@ set_volume(emu8000_t *hw, snd_emux_voice_t *vp) * Set pan and loop start address. */ static void -set_pan(emu8000_t *hw, snd_emux_voice_t *vp) +set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned int temp; @@ -376,7 +379,7 @@ set_pan(emu8000_t *hw, snd_emux_voice_t *vp) #define MOD_SENSE 18 static void -set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp) +set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned short fmmod; short pitch; @@ -394,14 +397,14 @@ set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp) /* set tremolo (lfo1) volume & frequency */ static void -set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp) +set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { EMU8000_TREMFRQ_WRITE(hw, vp->ch, vp->reg.parm.tremfrq); } /* set lfo2 pitch & frequency */ static void -set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp) +set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned short fm2frq2; short pitch; @@ -419,7 +422,7 @@ set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp) /* set filterQ */ static void -set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp) +set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned int addr; addr = EMU8000_CCCA_READ(hw, vp->ch) & 0xffffff; @@ -431,7 +434,7 @@ set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp) * set the envelope & LFO parameters to the default values */ static void -snd_emu8000_tweak_voice(emu8000_t *emu, int i) +snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int i) { /* set all mod/vol envelope shape to minimum */ EMU8000_ENVVOL_WRITE(emu, i, 0x8000); @@ -453,9 +456,9 @@ snd_emu8000_tweak_voice(emu8000_t *emu, int i) * sysex callback */ static void -sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset) +sysex(struct snd_emux *emu, char *buf, int len, int parsed, struct snd_midi_channel_set *chset) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; @@ -478,9 +481,9 @@ sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *c * OSS ioctl callback */ static int -oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2) +oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; @@ -523,9 +526,9 @@ oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2) */ static int -load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len) +load_fx(struct snd_emux *emu, int type, int mode, const void __user *buf, long len) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; /* skip header */ diff --git a/sound/isa/sb/emu8000_local.h b/sound/isa/sb/emu8000_local.h index ea4996a895fc..2ac77f10bb4e 100644 --- a/sound/isa/sb/emu8000_local.h +++ b/sound/isa/sb/emu8000_local.h @@ -30,14 +30,17 @@ #include <sound/emu8000_reg.h> /* emu8000_patch.c */ -int snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *data, long count); -int snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); -void snd_emu8000_sample_reset(snd_emux_t *rec); +int snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count); +int snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); +void snd_emu8000_sample_reset(struct snd_emux *rec); /* emu8000_callback.c */ -void snd_emu8000_ops_setup(emu8000_t *emu); +void snd_emu8000_ops_setup(struct snd_emu8000 *emu); /* emu8000_pcm.c */ -int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index); +int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index); #endif /* __EMU8000_LOCAL_H */ diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index 2fea67e71c78..80b1cf84a1ae 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -32,7 +32,7 @@ MODULE_PARM_DESC(emu8000_reset_addr, "reset write address at each time (makes sl * Open up channels. */ static int -snd_emu8000_open_dma(emu8000_t *emu, int write) +snd_emu8000_open_dma(struct snd_emu8000 *emu, int write) { int i; @@ -59,7 +59,7 @@ snd_emu8000_open_dma(emu8000_t *emu, int write) * Close all dram channels. */ static void -snd_emu8000_close_dma(emu8000_t *emu) +snd_emu8000_close_dma(struct snd_emu8000 *emu) { int i; @@ -106,7 +106,7 @@ read_word(const void __user *buf, int offset, int mode) /* */ static void -snd_emu8000_write_wait(emu8000_t *emu) +snd_emu8000_write_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -128,7 +128,7 @@ snd_emu8000_write_wait(emu8000_t *emu) * working. */ static inline void -write_word(emu8000_t *emu, int *offset, unsigned short data) +write_word(struct snd_emu8000 *emu, int *offset, unsigned short data) { if (emu8000_reset_addr) { if (emu8000_reset_addr > 1) @@ -144,15 +144,16 @@ write_word(emu8000_t *emu, int *offset, unsigned short data) * the generic soundfont routines as a callback. */ int -snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, const void __user *data, long count) +snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count) { int i; int rc; int offset; int truesize; int dram_offset, dram_start; - emu8000_t *emu; + struct snd_emu8000 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); @@ -282,7 +283,8 @@ snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, * free a sample block */ int -snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr) +snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr) { if (sp->block) { snd_util_mem_free(hdr, sp->block); @@ -296,7 +298,7 @@ snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t * sample_reset callback - terminate voices */ void -snd_emu8000_sample_reset(snd_emux_t *rec) +snd_emu8000_sample_reset(struct snd_emux *rec) { snd_emux_terminate_all(rec); } diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index b323beeeda15..91dc3d83e2cf 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -46,14 +46,12 @@ */ -typedef struct snd_emu8k_pcm emu8k_pcm_t; - struct snd_emu8k_pcm { - emu8000_t *emu; - snd_pcm_substream_t *substream; + struct snd_emu8000 *emu; + struct snd_pcm_substream *substream; unsigned int allocated_bytes; - snd_util_memblk_t *block; + struct snd_util_memblk *block; unsigned int offset; unsigned int buf_size; unsigned int period_size; @@ -77,7 +75,7 @@ struct snd_emu8k_pcm { * open up channels for the simultaneous data transfer and playback */ static int -emu8k_open_dram_for_pcm(emu8000_t *emu, int channels) +emu8k_open_dram_for_pcm(struct snd_emu8000 *emu, int channels) { int i; @@ -113,7 +111,7 @@ emu8k_open_dram_for_pcm(emu8000_t *emu, int channels) /* */ static void -snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) +snd_emu8000_write_wait(struct snd_emu8000 *emu, int can_schedule) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { if (can_schedule) { @@ -128,7 +126,7 @@ snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) * close all channels */ static void -emu8k_close_dram(emu8000_t *emu) +emu8k_close_dram(struct snd_emu8000 *emu) { int i; @@ -156,7 +154,7 @@ static int calc_rate_offset(int hz) /* */ -static snd_pcm_hardware_t emu8k_pcm_hw = { +static struct snd_pcm_hardware emu8k_pcm_hw = { #ifdef USE_NONINTERLEAVE .info = SNDRV_PCM_INFO_NONINTERLEAVED, #else @@ -180,7 +178,7 @@ static snd_pcm_hardware_t emu8k_pcm_hw = { /* * get the current position at the given channel from CCCA register */ -static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch) +static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch) { int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff; val -= rec->loop_start[ch] - 1; @@ -194,7 +192,7 @@ static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch) */ static void emu8k_pcm_timer_func(unsigned long data) { - emu8k_pcm_t *rec = (emu8k_pcm_t *)data; + struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data; int ptr, delta; spin_lock(&rec->timer_lock); @@ -226,11 +224,11 @@ static void emu8k_pcm_timer_func(unsigned long data) * open pcm * creating an instance here */ -static int emu8k_pcm_open(snd_pcm_substream_t *subs) +static int emu8k_pcm_open(struct snd_pcm_substream *subs) { - emu8000_t *emu = snd_pcm_substream_chip(subs); - emu8k_pcm_t *rec; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_emu8000 *emu = snd_pcm_substream_chip(subs); + struct snd_emu8k_pcm *rec; + struct snd_pcm_runtime *runtime = subs->runtime; rec = kzalloc(sizeof(*rec), GFP_KERNEL); if (! rec) @@ -256,9 +254,9 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs) return 0; } -static int emu8k_pcm_close(snd_pcm_substream_t *subs) +static int emu8k_pcm_close(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; kfree(rec); subs->runtime->private_data = NULL; return 0; @@ -281,9 +279,9 @@ static int calc_pitch_target(int pitch) /* * set up the voice */ -static void setup_voice(emu8k_pcm_t *rec, int ch) +static void setup_voice(struct snd_emu8k_pcm *rec, int ch) { - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; unsigned int temp; /* channel to be silent and idle */ @@ -334,10 +332,10 @@ static void setup_voice(emu8k_pcm_t *rec, int ch) /* * trigger the voice */ -static void start_voice(emu8k_pcm_t *rec, int ch) +static void start_voice(struct snd_emu8k_pcm *rec, int ch) { unsigned long flags; - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; unsigned int temp, aux; int pt = calc_pitch_target(rec->pitch); @@ -370,10 +368,10 @@ static void start_voice(emu8k_pcm_t *rec, int ch) /* * stop the voice immediately */ -static void stop_voice(emu8k_pcm_t *rec, int ch) +static void stop_voice(struct snd_emu8k_pcm *rec, int ch) { unsigned long flags; - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); @@ -386,9 +384,9 @@ static void stop_voice(emu8k_pcm_t *rec, int ch) spin_unlock_irqrestore(&rec->timer_lock, flags); } -static int emu8k_pcm_trigger(snd_pcm_substream_t *subs, int cmd) +static int emu8k_pcm_trigger(struct snd_pcm_substream *subs, int cmd) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; int ch; switch (cmd) { @@ -428,7 +426,7 @@ do { \ #ifdef USE_NONINTERLEAVE /* copy one channel block */ -static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, int count) +static int emu8k_transfer_block(struct snd_emu8000 *emu, int offset, unsigned short *buf, int count) { EMU8000_SMALW_WRITE(emu, offset); while (count > 0) { @@ -442,14 +440,14 @@ static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, return 0; } -static int emu8k_pcm_copy(snd_pcm_substream_t *subs, +static int emu8k_pcm_copy(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); if (voice == -1) { @@ -469,7 +467,7 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs, } /* make a channel block silence */ -static int emu8k_silence_block(emu8000_t *emu, int offset, int count) +static int emu8k_silence_block(struct snd_emu8000 *emu, int offset, int count) { EMU8000_SMALW_WRITE(emu, offset); while (count > 0) { @@ -480,13 +478,13 @@ static int emu8k_silence_block(emu8000_t *emu, int offset, int count) return 0; } -static int emu8k_pcm_silence(snd_pcm_substream_t *subs, +static int emu8k_pcm_silence(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); if (voice == -1 && rec->voices == 1) @@ -508,14 +506,14 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs, * copy the interleaved data can be done easily by using * DMA "left" and "right" channels on emu8k engine. */ -static int emu8k_pcm_copy(snd_pcm_substream_t *subs, +static int emu8k_pcm_copy(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; unsigned short __user *buf = src; snd_emu8000_write_wait(emu, 1); @@ -539,13 +537,13 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs, return 0; } -static int emu8k_pcm_silence(snd_pcm_substream_t *subs, +static int emu8k_pcm_silence(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); EMU8000_SMALW_WRITE(emu, rec->loop_start[0] + pos); @@ -567,10 +565,10 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs, /* * allocate a memory block */ -static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw_params) +static int emu8k_pcm_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw_params) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->block) { /* reallocation - release the old block */ @@ -592,9 +590,9 @@ static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs, /* * free the memory block */ -static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs) +static int emu8k_pcm_hw_free(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->block) { int ch; @@ -610,9 +608,9 @@ static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs) /* */ -static int emu8k_pcm_prepare(snd_pcm_substream_t *subs) +static int emu8k_pcm_prepare(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate); rec->last_ptr = 0; @@ -656,16 +654,16 @@ static int emu8k_pcm_prepare(snd_pcm_substream_t *subs) return 0; } -static snd_pcm_uframes_t emu8k_pcm_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->running) return emu8k_get_curpos(rec, 0); return 0; } -static snd_pcm_ops_t emu8k_pcm_ops = { +static struct snd_pcm_ops emu8k_pcm_ops = { .open = emu8k_pcm_open, .close = emu8k_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -679,15 +677,15 @@ static snd_pcm_ops_t emu8k_pcm_ops = { }; -static void snd_emu8000_pcm_free(snd_pcm_t *pcm) +static void snd_emu8000_pcm_free(struct snd_pcm *pcm) { - emu8000_t *emu = pcm->private_data; + struct snd_emu8000 *emu = pcm->private_data; emu->pcm = NULL; } -int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index) +int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(card, "Emu8000 PCM", index, 1, 0, &pcm)) < 0) diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c index f68e217416a6..3d72742b342f 100644 --- a/sound/isa/sb/emu8000_synth.c +++ b/sound/isa/sb/emu8000_synth.c @@ -33,12 +33,12 @@ MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu8000 */ -static int snd_emu8000_new_device(snd_seq_device_t *dev) +static int snd_emu8000_new_device(struct snd_seq_device *dev) { - emu8000_t *hw; - snd_emux_t *emu; + struct snd_emu8000 *hw; + struct snd_emux *emu; - hw = *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (hw == NULL) return -EINVAL; @@ -92,9 +92,9 @@ static int snd_emu8000_new_device(snd_seq_device_t *dev) /* * free all resources */ -static int snd_emu8000_delete_device(snd_seq_device_t *dev) +static int snd_emu8000_delete_device(struct snd_seq_device *dev) { - emu8000_t *hw; + struct snd_emu8000 *hw; if (dev->driver_data == NULL) return 0; /* no synth was allocated actually */ @@ -118,11 +118,12 @@ static int snd_emu8000_delete_device(snd_seq_device_t *dev) static int __init alsa_emu8000_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_emu8000_new_device, snd_emu8000_delete_device, }; - return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops, sizeof(emu8000_t*)); + return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops, + sizeof(struct snd_emu8000*)); } static void __exit alsa_emu8000_exit(void) diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c index c859917c14db..9da80bfa3027 100644 --- a/sound/isa/sb/es968.c +++ b/sound/isa/sb/es968.c @@ -58,6 +58,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver."); struct snd_card_es968 { struct pnp_dev *dev; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_es968_pnpids[] = { @@ -72,7 +73,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids); static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; if (chip->open & SB_OPEN_PCM) { return snd_sb8dsp_interrupt(chip); @@ -128,14 +129,14 @@ static int __init snd_card_es968_probe(int dev, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_es968 *acard; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_es968))) == NULL) return -ENOMEM; - acard = (struct snd_card_es968 *)card->private_data; + acard = card->private_data; if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { snd_card_free(card); return error; @@ -151,6 +152,7 @@ static int __init snd_card_es968_probe(int dev, snd_card_free(card); return error; } + acard->chip = chip; if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { snd_card_free(card); @@ -200,30 +202,59 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card, static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_es968_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_es968 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; } +static int snd_es968_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_es968 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pnp_card_driver es968_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "es968", .id_table = snd_es968_pnpids, .probe = snd_es968_pnp_detect, .remove = __devexit_p(snd_es968_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_es968_pnp_suspend, + .resume = snd_es968_pnp_resume, +#endif }; static int __init alsa_card_es968_init(void) { int cards = pnp_register_card_driver(&es968_pnpc_driver); -#ifdef MODULE - if (cards == 0) { + if (cards <= 0) { pnp_unregister_card_driver(&es968_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no ES968 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_es968_exit(void) diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index c2fa451bc8f0..c0be7a5a3425 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -24,6 +24,8 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/pnp.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/moduleparam.h> #include <sound/core.h> #include <sound/sb.h> @@ -32,7 +34,6 @@ #include <sound/opl3.h> #include <sound/emu8000.h> #include <sound/seq_device.h> -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include <sound/initval.h> @@ -127,8 +128,14 @@ module_param_array(seq_ports, int, NULL, 0444); 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 + struct snd_card_sb16 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ + struct snd_sb *chip; #ifdef CONFIG_PNP int dev_no; struct pnp_dev *dev; @@ -138,8 +145,6 @@ struct snd_card_sb16 { #endif }; -static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP static struct pnp_card_device_id snd_sb16_pnpids[] = { @@ -339,9 +344,9 @@ __wt_error: #endif /* CONFIG_PNP */ -static void snd_sb16_free(snd_card_t *card) +static void snd_sb16_free(struct snd_card *card) { - struct snd_card_sb16 *acard = (struct snd_card_sb16 *)card->private_data; + struct snd_card_sb16 *acard = card->private_data; if (acard == NULL) return; @@ -354,73 +359,32 @@ static void snd_sb16_free(snd_card_t *card) #define is_isapnp_selected(dev) 0 #endif -static int __init snd_sb16_probe(int dev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_sb16_card_new(int dev) +{ + struct snd_card *card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_sb16)); + if (card == NULL) + return NULL; + card->private_free = snd_sb16_free; + return card; +} + +static int __init snd_sb16_probe(struct snd_card *card, int dev) { - static int possible_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dmas8[] = {1, 3, 0, -1}; - static int possible_dmas16[] = {5, 6, 7, -1}; int xirq, xdma8, xdma16; - sb_t *chip; - snd_card_t *card; - struct snd_card_sb16 *acard; - opl3_t *opl3; - snd_hwdep_t *synth = NULL; + struct snd_sb *chip; + struct snd_card_sb16 *acard = card->private_data; + struct snd_opl3 *opl3; + struct snd_hwdep *synth = NULL; #ifdef CONFIG_SND_SB16_CSP - snd_hwdep_t *xcsp = NULL; + struct snd_hwdep *xcsp = NULL; #endif unsigned long flags; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_sb16)); - if (card == NULL) - return -ENOMEM; - acard = (struct snd_card_sb16 *) card->private_data; - card->private_free = snd_sb16_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) - goto _err; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif - xirq = irq[dev]; xdma8 = dma8[dev]; xdma16 = dma16[dev]; - if (! is_isapnp_selected(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; - } - } - if (xdma8 == SNDRV_AUTO_DMA) { - if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); - err = -EBUSY; - goto _err; - } - } - if (xdma16 == SNDRV_AUTO_DMA) { - if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); - err = -EBUSY; - goto _err; - } - } - /* non-PnP FM port address is hardwired with base port address */ - fm_port[dev] = port[dev]; - /* block the 0x388 port to avoid PnP conflicts */ - acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); -#ifdef SNDRV_SBAWE_EMU8000 - /* non-PnP AWE port address is hardwired with base port address */ - awe_port[dev] = port[dev] + 0x400; -#endif - } if ((err = snd_sbdsp_create(card, port[dev], @@ -430,19 +394,19 @@ static int __init snd_sb16_probe(int dev, xdma16, SB_HW_AUTO, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if (chip->hardware != SB_HW_16) { snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]); - err = -ENODEV; - goto _err; + return -ENODEV; } chip->mpu_port = mpu_port[dev]; if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) - goto _err; + return err; - if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) - goto _err; + if ((err = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0) + return err; strcpy(card->driver, #ifdef SNDRV_SBAWE_EMU8000 @@ -464,7 +428,7 @@ static int __init snd_sb16_probe(int dev, if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, chip->mpu_port, 0, xirq, 0, &chip->rmidi)) < 0) - goto _err; + return err; chip->rmidi_callback = snd_mpu401_uart_interrupt; } @@ -487,12 +451,12 @@ static int __init snd_sb16_probe(int dev, int seqdev = 1; #endif if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) - goto _err; + return err; } } if ((err = snd_sbmixer_new(chip)) < 0) - goto _err; + return err; #ifdef CONFIG_SND_SB16_CSP /* CSP chip on SB16ASP/AWE32 */ @@ -512,7 +476,7 @@ static int __init snd_sb16_probe(int dev, seq_ports[dev], NULL)) < 0) { snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); - goto _err; + return err; } } #endif @@ -524,56 +488,168 @@ static int __init snd_sb16_probe(int dev, (mic_agc[dev] ? 0x00 : 0x01)); spin_unlock_irqrestore(&chip->mixer_lock, flags); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) - goto _err; + return err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_sb16_legacy[dev] = card; return 0; +} - _err: - snd_card_free(card); - return err; +#ifdef CONFIG_PM +static int snd_sb16_suspend(struct snd_card *card, pm_message_t state) +{ + struct snd_card_sb16 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; } -static int __init snd_sb16_probe_legacy_port(unsigned long xport) +static int snd_sb16_resume(struct snd_card *card) { - static int dev; - int res; + struct snd_card_sb16 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - port[dev] = xport; - res = snd_sb16_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +static int __init snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card_sb16 *acard; + struct snd_card *card; + int err; + + card = snd_sb16_card_new(dev); + if (! card) + return -ENOMEM; + + acard = card->private_data; + /* non-PnP FM port address is hardwired with base port address */ + fm_port[dev] = port[dev]; + /* block the 0x388 port to avoid PnP conflicts */ + acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); +#ifdef SNDRV_SBAWE_EMU8000 + /* non-PnP AWE port address is hardwired with base port address */ + awe_port[dev] = port[dev] + 0x400; +#endif + + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_sb16_probe(card, dev)) < 0) { + snd_card_free(card); + return err; } - return -ENODEV; + platform_set_drvdata(devptr, card); + return 0; } + +static int __init snd_sb16_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + int err; + static int possible_irqs[] = {5, 9, 10, 7, -1}; + static int possible_dmas8[] = {1, 3, 0, -1}; + static int possible_dmas16[] = {5, 6, 7, -1}; + + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma8[dev] == SNDRV_AUTO_DMA) { + if ((dma8[dev] = snd_legacy_find_free_dma(possible_dmas8)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); + return -EBUSY; + } + } + if (dma16[dev] == SNDRV_AUTO_DMA) { + if ((dma16[dev] = snd_legacy_find_free_dma(possible_dmas16)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) + return snd_sb16_nonpnp_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); + if (! err) + return 0; + } + return err; + } +} + +static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_sb16_suspend(platform_get_drvdata(dev), state); +} + +static int snd_sb16_nonpnp_resume(struct platform_device *dev) +{ + return snd_sb16_resume(platform_get_drvdata(dev)); +} +#endif + +#ifdef SNDRV_SBAWE +#define SND_SB16_DRIVER "snd_sbawe" +#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), +#ifdef CONFIG_PM + .suspend = snd_sb16_nonpnp_suspend, + .resume = snd_sb16_nonpnp_resume, +#endif + .driver = { + .name = SND_SB16_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || !isapnp[dev]) continue; - res = snd_sb16_probe(dev, card, id); - if (res < 0) + card = snd_sb16_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 || + (res = snd_sb16_probe(card, dev)) < 0) { + snd_card_free(card); return res; + } + pnp_set_card_drvdata(pcard, card); dev++; return 0; } @@ -583,57 +659,82 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +#ifdef CONFIG_PM +static int snd_sb16_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_sb16_suspend(pnp_get_card_drvdata(pcard), state); } +static int snd_sb16_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_sb16_resume(pnp_get_card_drvdata(pcard)); +} +#endif static struct pnp_card_driver sb16_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, +#ifdef SNDRV_SBAWE + .name = "sbawe", +#else .name = "sb16", +#endif .id_table = snd_sb16_pnpids, .probe = snd_sb16_pnp_detect, .remove = __devexit_p(snd_sb16_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_sb16_pnp_suspend, + .resume = snd_sb16_pnp_resume, +#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 dev, cards = 0, i; - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1}; + int i, err, cards = 0; - /* legacy non-auto cards at first */ - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - if (!snd_sb16_probe(dev, NULL, NULL)) { - cards++; + if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; + device = platform_device_register_simple(SND_SB16_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; } -#ifdef MODULE - snd_printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); -#endif + platform_devices[i] = device; + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port); - if (i > 0) - cards += i; - #ifdef CONFIG_PNP /* PnP cards at last */ i = pnp_register_card_driver(&sb16_pnpc_driver); - if (i >0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } #endif if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); #ifdef SNDRV_SBAWE_EMU8000 @@ -642,21 +743,19 @@ static int __init alsa_card_sb16_init(void) snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); #endif #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_sb16_unregister_all(); + return err; } static void __exit alsa_card_sb16_exit(void) { - int dev; - -#ifdef CONFIG_PNP - /* PnP cards first */ - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_sb16_legacy[dev]); + snd_sb16_unregister_all(); } module_init(alsa_card_sb16_init) diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 7192d4c758e6..9c2b5efbacbf 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -72,46 +72,47 @@ struct desc_header { /* * prototypes */ -static void snd_sb_csp_free(snd_hwdep_t *hw); -static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file); -static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg); -static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file); - -static int csp_detect(sb_t *chip, int *version); -static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val); -static int set_register(sb_t *chip, unsigned char reg, unsigned char val); -static int read_register(sb_t *chip, unsigned char reg); -static int set_mode_register(sb_t *chip, unsigned char mode); -static int get_version(sb_t *chip); - -static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * code); -static int snd_sb_csp_unload(snd_sb_csp_t * p); -static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags); -static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode); -static int snd_sb_csp_check_version(snd_sb_csp_t * p); - -static int snd_sb_csp_use(snd_sb_csp_t * p); -static int snd_sb_csp_unuse(snd_sb_csp_t * p); -static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels); -static int snd_sb_csp_stop(snd_sb_csp_t * p); -static int snd_sb_csp_pause(snd_sb_csp_t * p); -static int snd_sb_csp_restart(snd_sb_csp_t * p); - -static int snd_sb_qsound_build(snd_sb_csp_t * p); -static void snd_sb_qsound_destroy(snd_sb_csp_t * p); -static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p); - -static int init_proc_entry(snd_sb_csp_t * p, int device); -static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); +static void snd_sb_csp_free(struct snd_hwdep *hw); +static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file); +static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg); +static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file); + +static int csp_detect(struct snd_sb *chip, int *version); +static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val); +static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val); +static int read_register(struct snd_sb *chip, unsigned char reg); +static int set_mode_register(struct snd_sb *chip, unsigned char mode); +static int get_version(struct snd_sb *chip); + +static int snd_sb_csp_riff_load(struct snd_sb_csp * p, + struct snd_sb_csp_microcode __user * code); +static int snd_sb_csp_unload(struct snd_sb_csp * p); +static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags); +static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode); +static int snd_sb_csp_check_version(struct snd_sb_csp * p); + +static int snd_sb_csp_use(struct snd_sb_csp * p); +static int snd_sb_csp_unuse(struct snd_sb_csp * p); +static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels); +static int snd_sb_csp_stop(struct snd_sb_csp * p); +static int snd_sb_csp_pause(struct snd_sb_csp * p); +static int snd_sb_csp_restart(struct snd_sb_csp * p); + +static int snd_sb_qsound_build(struct snd_sb_csp * p); +static void snd_sb_qsound_destroy(struct snd_sb_csp * p); +static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p); + +static int init_proc_entry(struct snd_sb_csp * p, int device); +static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); /* * Detect CSP chip and create a new instance */ -int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) +int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep) { - snd_sb_csp_t *p; + struct snd_sb_csp *p; int version, err; - snd_hwdep_t *hw; + struct snd_hwdep *hw; if (rhwdep) *rhwdep = NULL; @@ -158,9 +159,9 @@ int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) /* * free_private for hwdep instance */ -static void snd_sb_csp_free(snd_hwdep_t *hwdep) +static void snd_sb_csp_free(struct snd_hwdep *hwdep) { - snd_sb_csp_t *p = hwdep->private_data; + struct snd_sb_csp *p = hwdep->private_data; if (p) { if (p->running & SNDRV_SB_CSP_ST_RUNNING) snd_sb_csp_stop(p); @@ -173,20 +174,20 @@ static void snd_sb_csp_free(snd_hwdep_t *hwdep) /* * open the device exclusively */ -static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file) +static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file) { - snd_sb_csp_t *p = hw->private_data; + struct snd_sb_csp *p = hw->private_data; return (snd_sb_csp_use(p)); } /* * ioctl for hwdep device: */ -static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) +static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - snd_sb_csp_t *p = hw->private_data; - snd_sb_csp_info_t info; - snd_sb_csp_start_t start_info; + struct snd_sb_csp *p = hw->private_data; + struct snd_sb_csp_info info; + struct snd_sb_csp_start start_info; int err; snd_assert(p != NULL, return -EINVAL); @@ -217,7 +218,7 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm /* load CSP microcode */ case SNDRV_SB_CSP_IOCTL_LOAD_CODE: err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? - -EBUSY : snd_sb_csp_riff_load(p, (snd_sb_csp_microcode_t __user *) arg)); + -EBUSY : snd_sb_csp_riff_load(p, (struct snd_sb_csp_microcode __user *) arg)); break; case SNDRV_SB_CSP_IOCTL_UNLOAD_CODE: err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? @@ -251,9 +252,9 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm /* * close the device */ -static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file) +static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file) { - snd_sb_csp_t *p = hw->private_data; + struct snd_sb_csp *p = hw->private_data; return (snd_sb_csp_unuse(p)); } @@ -262,7 +263,7 @@ static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file) /* * acquire device */ -static int snd_sb_csp_use(snd_sb_csp_t * p) +static int snd_sb_csp_use(struct snd_sb_csp * p) { down(&p->access_mutex); if (p->used) { @@ -279,7 +280,7 @@ static int snd_sb_csp_use(snd_sb_csp_t * p) /* * release device */ -static int snd_sb_csp_unuse(snd_sb_csp_t * p) +static int snd_sb_csp_unuse(struct snd_sb_csp * p) { down(&p->access_mutex); p->used--; @@ -292,9 +293,10 @@ static int snd_sb_csp_unuse(snd_sb_csp_t * p) * load microcode via ioctl: * code is user-space pointer */ -static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * mcode) +static int snd_sb_csp_riff_load(struct snd_sb_csp * p, + struct snd_sb_csp_microcode __user * mcode) { - snd_sb_csp_mc_header_t info; + struct snd_sb_csp_mc_header info; unsigned char __user *data_ptr; unsigned char __user *data_end; @@ -449,7 +451,7 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user /* * unload CSP microcode */ -static int snd_sb_csp_unload(snd_sb_csp_t * p) +static int snd_sb_csp_unload(struct snd_sb_csp * p) { if (p->running & SNDRV_SB_CSP_ST_RUNNING) return -EBUSY; @@ -472,7 +474,7 @@ static int snd_sb_csp_unload(snd_sb_csp_t * p) /* * send command sequence to DSP */ -static inline int command_seq(sb_t *chip, const unsigned char *seq, int size) +static inline int command_seq(struct snd_sb *chip, const unsigned char *seq, int size) { int i; for (i = 0; i < size; i++) { @@ -485,7 +487,7 @@ static inline int command_seq(sb_t *chip, const unsigned char *seq, int size) /* * set CSP codec parameter */ -static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val) +static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val) { unsigned char dsp_cmd[3]; @@ -502,7 +504,7 @@ static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val) /* * set CSP register */ -static int set_register(sb_t *chip, unsigned char reg, unsigned char val) +static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val) { unsigned char dsp_cmd[3]; @@ -516,7 +518,7 @@ static int set_register(sb_t *chip, unsigned char reg, unsigned char val) * read CSP register * return < 0 -> error */ -static int read_register(sb_t *chip, unsigned char reg) +static int read_register(struct snd_sb *chip, unsigned char reg) { unsigned char dsp_cmd[2]; @@ -529,7 +531,7 @@ static int read_register(sb_t *chip, unsigned char reg) /* * set CSP mode register */ -static int set_mode_register(sb_t *chip, unsigned char mode) +static int set_mode_register(struct snd_sb *chip, unsigned char mode) { unsigned char dsp_cmd[2]; @@ -542,7 +544,7 @@ static int set_mode_register(sb_t *chip, unsigned char mode) * Detect CSP * return 0 if CSP exists. */ -static int csp_detect(sb_t *chip, int *version) +static int csp_detect(struct snd_sb *chip, int *version) { unsigned char csp_test1, csp_test2; unsigned long flags; @@ -579,7 +581,7 @@ static int csp_detect(sb_t *chip, int *version) /* * get CSP version number */ -static int get_version(sb_t *chip) +static int get_version(struct snd_sb *chip) { unsigned char dsp_cmd[2]; @@ -593,7 +595,7 @@ static int get_version(sb_t *chip) /* * check if the CSP version is valid */ -static int snd_sb_csp_check_version(snd_sb_csp_t * p) +static int snd_sb_csp_check_version(struct snd_sb_csp * p) { if (p->version < 0x10 || p->version > 0x1f) { snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version); @@ -605,7 +607,7 @@ static int snd_sb_csp_check_version(snd_sb_csp_t * p) /* * download microcode to CSP (microcode should have one "main" block). */ -static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size, int load_flags) +static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int size, int load_flags) { int status, i; int err; @@ -671,7 +673,7 @@ static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size, return result; } -static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags) +static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) { int err = -ENOMEM; unsigned char *kbuf = kmalloc(size, GFP_KERNEL); @@ -691,7 +693,7 @@ static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *bu * autoload hardware codec if necessary * return 0 if CSP is loaded and ready to run (p->running != 0) */ -static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode) +static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode) { unsigned long flags; int err = 0; @@ -763,7 +765,7 @@ static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode /* * start CSP */ -static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels) +static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels) { unsigned char s_type; /* sample type */ unsigned char mixL, mixR; @@ -842,7 +844,7 @@ static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels) /* * stop CSP */ -static int snd_sb_csp_stop(snd_sb_csp_t * p) +static int snd_sb_csp_stop(struct snd_sb_csp * p) { int result; unsigned char mixL, mixR; @@ -883,7 +885,7 @@ static int snd_sb_csp_stop(snd_sb_csp_t * p) /* * pause CSP codec and hold DMA transfer */ -static int snd_sb_csp_pause(snd_sb_csp_t * p) +static int snd_sb_csp_pause(struct snd_sb_csp * p) { int result; unsigned long flags; @@ -903,7 +905,7 @@ static int snd_sb_csp_pause(snd_sb_csp_t * p) /* * restart CSP codec and resume DMA transfer */ -static int snd_sb_csp_restart(snd_sb_csp_t * p) +static int snd_sb_csp_restart(struct snd_sb_csp * p) { int result; unsigned long flags; @@ -926,7 +928,7 @@ static int snd_sb_csp_restart(snd_sb_csp_t * p) * QSound mixer control for PCM */ -static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb_qsound_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -935,17 +937,17 @@ static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_sb_qsound_switch_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = p->q_enabled ? 1 : 0; return 0; } -static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval; @@ -958,7 +960,7 @@ static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return change; } -static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb_qsound_space_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -967,9 +969,9 @@ static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_space_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&p->q_lock, flags); @@ -979,9 +981,9 @@ static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_space_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval1, nval2; @@ -1001,7 +1003,7 @@ static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t snd_sb_qsound_switch = { +static struct snd_kcontrol_new snd_sb_qsound_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Switch", .info = snd_sb_qsound_switch_info, @@ -1009,7 +1011,7 @@ static snd_kcontrol_new_t snd_sb_qsound_switch = { .put = snd_sb_qsound_switch_put }; -static snd_kcontrol_new_t snd_sb_qsound_space = { +static struct snd_kcontrol_new snd_sb_qsound_space = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Space", .info = snd_sb_qsound_space_info, @@ -1017,9 +1019,9 @@ static snd_kcontrol_new_t snd_sb_qsound_space = { .put = snd_sb_qsound_space_put }; -static int snd_sb_qsound_build(snd_sb_csp_t * p) +static int snd_sb_qsound_build(struct snd_sb_csp * p) { - snd_card_t * card; + struct snd_card *card; int err; snd_assert(p != NULL, return -EINVAL); @@ -1042,9 +1044,9 @@ static int snd_sb_qsound_build(snd_sb_csp_t * p) return err; } -static void snd_sb_qsound_destroy(snd_sb_csp_t * p) +static void snd_sb_qsound_destroy(struct snd_sb_csp * p) { - snd_card_t * card; + struct snd_card *card; unsigned long flags; snd_assert(p != NULL, return); @@ -1068,7 +1070,7 @@ static void snd_sb_qsound_destroy(snd_sb_csp_t * p) * Transfer qsound parameters to CSP, * function should be called from interrupt routine */ -static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p) +static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p) { int err = -ENXIO; @@ -1093,19 +1095,19 @@ static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p) /* * proc interface */ -static int init_proc_entry(snd_sb_csp_t * p, int device) +static int init_proc_entry(struct snd_sb_csp * p, int device) { char name[16]; - snd_info_entry_t *entry; + struct snd_info_entry *entry; sprintf(name, "cspD%d", device); if (! snd_card_proc_new(p->chip->card, name, &entry)) snd_info_set_text_ops(entry, p, 1024, info_read); return 0; } -static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_sb_csp_t *p = entry->private_data; + struct snd_sb_csp *p = entry->private_data; snd_iprintf(buffer, "Creative Signal Processor [v%d.%d]\n", (p->version >> 4), (p->version & 0x0f)); snd_iprintf(buffer, "State: %cx%c%c%c\n", ((p->running & SNDRV_SB_CSP_ST_QSOUND) ? 'Q' : '-'), diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 556b95e3e22f..f183f1845a36 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -50,10 +50,10 @@ MODULE_DESCRIPTION("Routines for control of 16-bit SoundBlaster cards and clones MODULE_LICENSE("GPL"); #ifdef CONFIG_SND_SB16_CSP -static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -98,10 +98,10 @@ static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime } } -static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_capture_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -136,10 +136,10 @@ static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_update(sb_t *chip) +static void snd_sb16_csp_update(struct snd_sb *chip) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->qpos_changed) { spin_lock(&chip->reg_lock); @@ -149,11 +149,11 @@ static void snd_sb16_csp_update(sb_t *chip) } } -static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_playback_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { /* CSP decoders (QSound excluded) support only 16bit transfers */ if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -168,10 +168,10 @@ static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_playback_close(sb_t *chip) +static void snd_sb16_csp_playback_close(struct snd_sb *chip) { if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->ops.csp_stop(csp) == 0) { csp->ops.csp_unuse(csp); @@ -180,11 +180,11 @@ static void snd_sb16_csp_playback_close(sb_t *chip) } } -static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_capture_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { /* CSP coders support only 16bit transfers */ if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -199,10 +199,10 @@ static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_capture_close(sb_t *chip) +static void snd_sb16_csp_capture_close(struct snd_sb *chip) { if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->ops.csp_stop(csp) == 0) { csp->ops.csp_unuse(csp); @@ -221,7 +221,7 @@ static void snd_sb16_csp_capture_close(sb_t *chip) #endif -static void snd_sb16_setup_rate(sb_t *chip, +static void snd_sb16_setup_rate(struct snd_sb *chip, unsigned short rate, int channel) { @@ -244,23 +244,23 @@ static void snd_sb16_setup_rate(sb_t *chip, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static int snd_sb16_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sb16_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sb16_hw_free(snd_pcm_substream_t * substream) +static int snd_sb16_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream) +static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char format; unsigned int size, count, dma; @@ -298,19 +298,21 @@ static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream, +static int snd_sb16_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_PLAYBACK; snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ if (chip->mode & SB_RATE_LOCK_CAPTURE) @@ -324,11 +326,11 @@ static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream) +static int snd_sb16_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char format; unsigned int size, count, dma; @@ -365,19 +367,21 @@ static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream, +static int snd_sb16_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_CAPTURE; snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ if (chip->mode & SB_RATE_LOCK_PLAYBACK) @@ -393,7 +397,7 @@ static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream, irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; unsigned char status; int ok; @@ -443,9 +447,9 @@ irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) */ -static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb16_playback_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int dma; size_t ptr; @@ -454,9 +458,9 @@ static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substre return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb16_capture_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int dma; size_t ptr; @@ -469,7 +473,7 @@ static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substrea */ -static snd_pcm_hardware_t snd_sb16_playback = +static struct snd_pcm_hardware snd_sb16_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -487,7 +491,7 @@ static snd_pcm_hardware_t snd_sb16_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sb16_capture = +static struct snd_pcm_hardware snd_sb16_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -509,11 +513,11 @@ static snd_pcm_hardware_t snd_sb16_capture = * open/close */ -static int snd_sb16_playback_open(snd_pcm_substream_t * substream) +static int snd_sb16_playback_open(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irqsave(&chip->open_lock, flags); if (chip->mode & SB_MODE_PLAYBACK) { @@ -566,10 +570,10 @@ static int snd_sb16_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_playback_close(snd_pcm_substream_t * substream) +static int snd_sb16_playback_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); snd_sb16_csp_playback_close(chip); spin_lock_irqsave(&chip->open_lock, flags); @@ -579,11 +583,11 @@ static int snd_sb16_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_open(snd_pcm_substream_t * substream) +static int snd_sb16_capture_open(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irqsave(&chip->open_lock, flags); if (chip->mode & SB_MODE_CAPTURE) { @@ -636,10 +640,10 @@ static int snd_sb16_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_close(snd_pcm_substream_t * substream) +static int snd_sb16_capture_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); snd_sb16_csp_capture_close(chip); spin_lock_irqsave(&chip->open_lock, flags); @@ -653,7 +657,7 @@ static int snd_sb16_capture_close(snd_pcm_substream_t * substream) * DMA control interface */ -static int snd_sb16_set_dma_mode(sb_t *chip, int what) +static int snd_sb16_set_dma_mode(struct snd_sb *chip, int what) { if (chip->dma8 < 0 || chip->dma16 < 0) { snd_assert(what == 0, return -EINVAL); @@ -671,7 +675,7 @@ static int snd_sb16_set_dma_mode(sb_t *chip, int what) return 0; } -static int snd_sb16_get_dma_mode(sb_t *chip) +static int snd_sb16_get_dma_mode(struct snd_sb *chip) { if (chip->dma8 < 0 || chip->dma16 < 0) return 0; @@ -685,7 +689,7 @@ static int snd_sb16_get_dma_mode(sb_t *chip) } } -static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb16_dma_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Auto", "Playback", "Capture" @@ -700,9 +704,9 @@ static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16_dma_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_sb *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -711,9 +715,9 @@ static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_sb *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char nval, oval; int change; @@ -728,7 +732,7 @@ static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return change; } -static snd_kcontrol_new_t snd_sb16_dma_control = { +static struct snd_kcontrol_new snd_sb16_dma_control = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "16-bit DMA Allocation", .info = snd_sb16_dma_control_info, @@ -740,7 +744,7 @@ static snd_kcontrol_new_t snd_sb16_dma_control = { * Initialization part */ -int snd_sb16dsp_configure(sb_t * chip) +int snd_sb16dsp_configure(struct snd_sb * chip) { unsigned long flags; unsigned char irqreg = 0, dmareg = 0, mpureg; @@ -829,7 +833,7 @@ int snd_sb16dsp_configure(sb_t * chip) return 0; } -static snd_pcm_ops_t snd_sb16_playback_ops = { +static struct snd_pcm_ops snd_sb16_playback_ops = { .open = snd_sb16_playback_open, .close = snd_sb16_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -840,7 +844,7 @@ static snd_pcm_ops_t snd_sb16_playback_ops = { .pointer = snd_sb16_playback_pointer, }; -static snd_pcm_ops_t snd_sb16_capture_ops = { +static struct snd_pcm_ops snd_sb16_capture_ops = { .open = snd_sb16_capture_open, .close = snd_sb16_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -851,15 +855,10 @@ static snd_pcm_ops_t snd_sb16_capture_ops = { .pointer = snd_sb16_capture_pointer, }; -static void snd_sb16dsp_pcm_free(snd_pcm_t *pcm) +int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) -{ - snd_card_t *card = chip->card; - snd_pcm_t *pcm; + struct snd_card *card = chip->card; + struct snd_pcm *pcm; int err; if (rpcm) @@ -869,7 +868,6 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->private_data = chip; - pcm->private_free = snd_sb16dsp_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops); @@ -888,7 +886,7 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) return 0; } -const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction) +const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction) { return direction == SNDRV_PCM_STREAM_PLAYBACK ? &snd_sb16_playback_ops : &snd_sb16_capture_ops; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 0bc0a3afdabc..60ee79cd14a3 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -21,13 +21,14 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/ioport.h> #include <linux/moduleparam.h> #include <sound/core.h> #include <sound/sb.h> #include <sound/opl3.h> -#define SNDRV_LEGACY_AUTO_PROBE #include <sound/initval.h> MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); @@ -55,15 +56,16 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver."); 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; }; -static snd_card_t *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; if (chip->open & SB_OPEN_PCM) { return snd_sb8dsp_interrupt(chip); @@ -72,7 +74,7 @@ static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs } } -static void snd_sb8_free(snd_card_t *card) +static void snd_sb8_free(struct snd_card *card) { struct snd_sb8 *acard = (struct snd_sb8 *)card->private_data; @@ -81,32 +83,57 @@ static void snd_sb8_free(snd_card_t *card) release_and_free_resource(acard->fm_res); } -static int __init snd_sb8_probe(int dev) +static int __init snd_sb8_probe(struct platform_device *pdev) { - sb_t *chip; - snd_card_t *card; + int dev = pdev->id; + struct snd_sb *chip; + struct snd_card *card; struct snd_sb8 *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_sb8)); if (card == NULL) return -ENOMEM; - acard = (struct snd_sb8 *)card->private_data; + acard = card->private_data; card->private_free = snd_sb8_free; /* block the 0x388 port to avoid PnP conflicts */ acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); - if ((err = snd_sbdsp_create(card, port[dev], irq[dev], - snd_sb8_interrupt, - dma8[dev], - -1, - SB_HW_AUTO, - &chip)) < 0) - goto _err; - + if (port[dev] != SNDRV_AUTO_PORT) { + if ((err = snd_sbdsp_create(card, port[dev], irq[dev], + snd_sb8_interrupt, + dma8[dev], + -1, + SB_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_sbdsp_create(card, possible_ports[i], + irq[dev], + snd_sb8_interrupt, + dma8[dev], + -1, + SB_HW_AUTO, + &chip); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + if (i >= ARRAY_SIZE(possible_ports)) + goto _err; + } + acard->chip = chip; + if (chip->hardware >= SB_HW_16) { if (chip->hardware == SB_HW_ALS100) snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n", @@ -153,13 +180,12 @@ static int __init snd_sb8_probe(int dev) chip->port, irq[dev], dma8[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_sb8_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -167,53 +193,99 @@ static int __init snd_sb8_probe(int dev) return err; } -static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport) +static int snd_sb8_remove(struct platform_device *pdev) +{ + snd_card_free(platform_get_drvdata(pdev)); + platform_set_drvdata(pdev, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(dev); + struct snd_sb8 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_sb8_resume(struct platform_device *dev) +{ + struct snd_card *card = platform_get_drvdata(dev); + struct snd_sb8 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_SB8_DRIVER "snd_sb8" + +static struct platform_driver snd_sb8_driver = { + .probe = snd_sb8_probe, + .remove = snd_sb8_remove, +#ifdef CONFIG_PM + .suspend = snd_sb8_suspend, + .resume = snd_sb8_resume, +#endif + .driver = { + .name = SND_SB8_DRIVER + }, +}; + +static void __init_or_module snd_sb8_unregister_all(void) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_sb8_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + 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) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_sb8_probe(dev) >= 0) - cards++; + int i, cards, err; + + err = platform_driver_register(&snd_sb8_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_SB8_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; } - i = snd_legacy_auto_probe(possible_ports, snd_card_sb8_legacy_auto_probe); - if (i > 0) - cards += i; - if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_sb8_unregister_all(); + return err; } static void __exit alsa_card_sb8_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_sb8_cards[idx]); + snd_sb8_unregister_all(); } module_init(alsa_card_sb8_init) diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 5ddc6e41d909..aea9e5ec7b36 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -46,19 +46,19 @@ MODULE_LICENSE("GPL"); #define SB8_DEN(v) ((SB8_CLOCK + (v) / 2) / (v)) #define SB8_RATE(v) (SB8_CLOCK / SB8_DEN(v)) -static ratnum_t clock = { +static struct snd_ratnum clock = { .num = SB8_CLOCK, .den_min = 1, .den_max = 256, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clock = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clock = { .nrats = 1, .rats = &clock, }; -static ratnum_t stereo_clocks[] = { +static struct snd_ratnum stereo_clocks[] = { { .num = SB8_CLOCK, .den_min = SB8_DEN(22050), @@ -73,10 +73,10 @@ static ratnum_t stereo_clocks[] = { } }; -static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_sb8_hw_constraint_rate_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (c->min > 1) { unsigned int num = 0, den = 0; int err = snd_interval_ratnum(hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE), @@ -90,22 +90,22 @@ static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params, return 0; } -static int snd_sb8_hw_constraint_channels_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_sb8_hw_constraint_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > SB8_RATE(22050) || r->max <= SB8_RATE(11025)) { - snd_interval_t t = { .min = 1, .max = 1 }; + struct snd_interval t = { .min = 1, .max = 1 }; return snd_interval_refine(hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS), &t); } return 0; } -static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream) +static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mixreg, rate, size, count; rate = runtime->rate; @@ -178,11 +178,11 @@ static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, +static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, int cmd) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int count; spin_lock_irqsave(&chip->reg_lock, flags); @@ -197,7 +197,7 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: if (chip->playback_format == SB_DSP_HI_OUTPUT_AUTO) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_sbdsp_reset(chip); if (runtime->channels > 1) { spin_lock(&chip->mixer_lock); @@ -215,23 +215,23 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_sb8_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sb8_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sb8_hw_free(snd_pcm_substream_t * substream) +static int snd_sb8_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream) +static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mixreg, rate, size, count; rate = runtime->rate; @@ -290,11 +290,11 @@ static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, +static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, int cmd) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int count; spin_lock_irqsave(&chip->reg_lock, flags); @@ -309,7 +309,7 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: if (chip->capture_format == SB_DSP_HI_INPUT_AUTO) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_sbdsp_reset(chip); if (runtime->channels > 1) { /* restore input filter status */ @@ -329,10 +329,10 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, return 0; } -irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) +irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_sb_ack_8bit(chip); switch (chip->mode) { @@ -354,9 +354,9 @@ irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->mode != SB_MODE_PLAYBACK_8) @@ -365,9 +365,9 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substrea return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->mode != SB_MODE_CAPTURE_8) @@ -380,7 +380,7 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream */ -static snd_pcm_hardware_t snd_sb8_playback = +static struct snd_pcm_hardware snd_sb8_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -399,7 +399,7 @@ static snd_pcm_hardware_t snd_sb8_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sb8_capture = +static struct snd_pcm_hardware snd_sb8_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -422,10 +422,10 @@ static snd_pcm_hardware_t snd_sb8_capture = * */ -static int snd_sb8_open(snd_pcm_substream_t *substream) +static int snd_sb8_open(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); @@ -468,10 +468,10 @@ static int snd_sb8_open(snd_pcm_substream_t *substream) return 0; } -static int snd_sb8_close(snd_pcm_substream_t *substream) +static int snd_sb8_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; chip->capture_substream = NULL; @@ -485,7 +485,7 @@ static int snd_sb8_close(snd_pcm_substream_t *substream) * Initialization part */ -static snd_pcm_ops_t snd_sb8_playback_ops = { +static struct snd_pcm_ops snd_sb8_playback_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, @@ -496,7 +496,7 @@ static snd_pcm_ops_t snd_sb8_playback_ops = { .pointer = snd_sb8_playback_pointer, }; -static snd_pcm_ops_t snd_sb8_capture_ops = { +static struct snd_pcm_ops snd_sb8_capture_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, @@ -507,15 +507,10 @@ static snd_pcm_ops_t snd_sb8_capture_ops = { .pointer = snd_sb8_capture_pointer, }; -static void snd_sb8dsp_pcm_free(snd_pcm_t *pcm) +int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm) -{ - snd_card_t *card = chip->card; - snd_pcm_t *pcm; + struct snd_card *card = chip->card; + struct snd_pcm *pcm; int err; if (rpcm) @@ -525,7 +520,6 @@ int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm) sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; pcm->private_data = chip; - pcm->private_free = snd_sb8dsp_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index d2c633a40e74..c549aceea294 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -36,9 +36,9 @@ */ -irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) +irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb * chip) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int max = 64; char byte; @@ -63,10 +63,10 @@ irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) */ -static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; unsigned int valid_open_flags; chip = substream->rmidi->private_data; @@ -90,10 +90,10 @@ static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; unsigned int valid_open_flags; chip = substream->rmidi->private_data; @@ -117,10 +117,10 @@ static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -135,10 +135,10 @@ static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -153,10 +153,10 @@ static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_sb8dsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -176,10 +176,10 @@ static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, i spin_unlock_irqrestore(&chip->open_lock, flags); } -static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream) +static void snd_sb8dsp_midi_output_write(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; char byte; int max = 32; @@ -214,8 +214,8 @@ static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream) static void snd_sb8dsp_midi_output_timer(unsigned long data) { - snd_rawmidi_substream_t * substream = (snd_rawmidi_substream_t *) data; - sb_t * chip = substream->rmidi->private_data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data; + struct snd_sb * chip = substream->rmidi->private_data; unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); @@ -225,10 +225,10 @@ static void snd_sb8dsp_midi_output_timer(unsigned long data) snd_sb8dsp_midi_output_write(substream); } -static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -256,23 +256,23 @@ static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream, */ -static snd_rawmidi_ops_t snd_sb8dsp_midi_output = +static struct snd_rawmidi_ops snd_sb8dsp_midi_output = { .open = snd_sb8dsp_midi_output_open, .close = snd_sb8dsp_midi_output_close, .trigger = snd_sb8dsp_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_sb8dsp_midi_input = +static struct snd_rawmidi_ops snd_sb8dsp_midi_input = { .open = snd_sb8dsp_midi_input_open, .close = snd_sb8dsp_midi_input_close, .trigger = snd_sb8dsp_midi_input_trigger, }; -int snd_sb8dsp_midi(sb_t *chip, int device, snd_rawmidi_t ** rrawmidi) +int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 603e923b5d2f..f343a8211d2d 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -41,7 +41,7 @@ MODULE_LICENSE("GPL"); #undef IO_DEBUG -int snd_sbdsp_command(sb_t *chip, unsigned char val) +int snd_sbdsp_command(struct snd_sb *chip, unsigned char val) { int i; #ifdef IO_DEBUG @@ -56,7 +56,7 @@ int snd_sbdsp_command(sb_t *chip, unsigned char val) return 0; } -int snd_sbdsp_get_byte(sb_t *chip) +int snd_sbdsp_get_byte(struct snd_sb *chip) { int val; int i; @@ -73,7 +73,7 @@ int snd_sbdsp_get_byte(sb_t *chip) return -ENODEV; } -int snd_sbdsp_reset(sb_t *chip) +int snd_sbdsp_reset(struct snd_sb *chip) { int i; @@ -92,7 +92,7 @@ int snd_sbdsp_reset(sb_t *chip) return -ENODEV; } -static int snd_sbdsp_version(sb_t * chip) +static int snd_sbdsp_version(struct snd_sb * chip) { unsigned int result = -ENODEV; @@ -102,7 +102,7 @@ static int snd_sbdsp_version(sb_t * chip) return result; } -static int snd_sbdsp_probe(sb_t * chip) +static int snd_sbdsp_probe(struct snd_sb * chip) { int version; int major, minor; @@ -176,7 +176,7 @@ static int snd_sbdsp_probe(sb_t * chip) return 0; } -static int snd_sbdsp_free(sb_t *chip) +static int snd_sbdsp_free(struct snd_sb *chip) { if (chip->res_port) release_and_free_resource(chip->res_port); @@ -196,24 +196,24 @@ static int snd_sbdsp_free(sb_t *chip) return 0; } -static int snd_sbdsp_dev_free(snd_device_t *device) +static int snd_sbdsp_dev_free(struct snd_device *device) { - sb_t *chip = device->device_data; + struct snd_sb *chip = device->device_data; return snd_sbdsp_free(chip); } -int snd_sbdsp_create(snd_card_t *card, +int snd_sbdsp_create(struct snd_card *card, unsigned long port, int irq, irqreturn_t (*irq_handler)(int, void *, struct pt_regs *), int dma8, int dma16, unsigned short hardware, - sb_t **r_chip) + struct snd_sb **r_chip) { - sb_t *chip; + struct snd_sb *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_sbdsp_dev_free, }; @@ -293,6 +293,10 @@ EXPORT_SYMBOL(snd_sbmixer_write); EXPORT_SYMBOL(snd_sbmixer_read); EXPORT_SYMBOL(snd_sbmixer_new); EXPORT_SYMBOL(snd_sbmixer_add_ctl); +#ifdef CONFIG_PM +EXPORT_SYMBOL(snd_sbmixer_suspend); +EXPORT_SYMBOL(snd_sbmixer_resume); +#endif /* * INIT part diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 5a926a452d38..1a6ee344dddb 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -29,7 +29,7 @@ #undef IO_DEBUG -void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data) +void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data) { outb(reg, SBP(chip, MIXER_ADDR)); udelay(10); @@ -40,7 +40,7 @@ void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data) #endif } -unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg) +unsigned char snd_sbmixer_read(struct snd_sb *chip, unsigned char reg) { unsigned char result; @@ -58,7 +58,7 @@ unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg) * Single channel mixer element */ -static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sbmixer_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -69,9 +69,9 @@ static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0xff; @@ -85,9 +85,9 @@ static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0x07; @@ -110,7 +110,7 @@ static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ * Double channel mixer element */ -static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sbmixer_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -121,9 +121,9 @@ static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -141,9 +141,9 @@ static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -181,7 +181,7 @@ static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ * DT-019x / ALS-007 capture/input switch */ -static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[5] = { "CD", "Mic", "Line", "Synth", "Master" @@ -196,9 +196,9 @@ static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dt019x_input_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval; @@ -232,9 +232,9 @@ static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval, oval; @@ -273,7 +273,7 @@ static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * SBPRO input multiplexer */ -static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Mic", "CD", "Line" @@ -289,9 +289,9 @@ static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * } -static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb8mixer_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval; @@ -312,9 +312,9 @@ static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb8mixer_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval, oval; @@ -346,7 +346,7 @@ static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * SB16 input switch */ -static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb16mixer_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 4; @@ -355,9 +355,9 @@ static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_i return 0; } -static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16mixer_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; @@ -376,9 +376,9 @@ static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return 0; } -static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16mixer_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; @@ -410,9 +410,9 @@ static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va */ /* */ -int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsigned long value) +int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value) { - static snd_kcontrol_new_t newctls[] = { + static struct snd_kcontrol_new newctls[] = { [SB_MIX_SINGLE] = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_sbmixer_info_single, @@ -444,7 +444,7 @@ int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsig .put = snd_dt019x_input_sw_put, }, }; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; int err; ctl = snd_ctl_new1(&newctls[type], chip); @@ -669,25 +669,34 @@ static unsigned char snd_dt019x_init_values[][2] = { /* * ALS4000 specific mixer elements */ -/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl ! */ -static struct sbmix_elem snd_als4000_ctl_mono_output_switch = - SB_SINGLE("Mono Output Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); -/* FIXME: mono input switch also available on DT019X ? */ -static struct sbmix_elem snd_als4000_ctl_mono_input_switch = - SB_SINGLE("Mono Input Switch", SB_DT019X_OUTPUT_SW2, 0, 1); +/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl! */ +static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = + SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); +static struct sbmix_elem snd_als4000_ctl_master_mono_capture_route = + SB_SINGLE("Master Mono Capture Route", SB_ALS4000_MONO_IO_CTRL, 6, 0x03); +/* FIXME: mono playback switch also available on DT019X? */ +static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = + SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); -static struct sbmix_elem snd_als4000_ctl_mixer_out_to_in = - SB_SINGLE("Mixer Out To In", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); -/* FIXME: 3D needs much more sophisticated controls, many more features ! */ -static struct sbmix_elem snd_als4000_ctl_3d_output_switch = - SB_SINGLE("3D Output Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); -static struct sbmix_elem snd_als4000_ctl_3d_output_ratio = - SB_SINGLE("3D Output Ratio", SB_ALS4000_3D_SND_FX, 0, 0x07); -static struct sbmix_elem snd_als4000_ctl_3d_poweroff_switch = +static struct sbmix_elem snd_als4000_ctl_mixer_loopback = + SB_SINGLE("Analog Loopback", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); +/* FIXME: functionality of 3D controls might be swapped, I didn't find + * a description of how to identify what is supposed to be what */ +static struct sbmix_elem snd_als4000_3d_control_switch = + SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); +static struct sbmix_elem snd_als4000_3d_control_ratio = + SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07); +static struct sbmix_elem snd_als4000_3d_control_freq = + /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ + SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03); +static struct sbmix_elem snd_als4000_3d_control_delay = + /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, + * but what ALSA 3D attribute is that actually? "Center", "Depth", + * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ + SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); +static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); -static struct sbmix_elem snd_als4000_ctl_3d_delay = - SB_SINGLE("3D Delay", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); #ifdef NOT_AVAILABLE static struct sbmix_elem snd_als4000_ctl_fmdac = SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); @@ -716,13 +725,15 @@ static struct sbmix_elem *snd_als4000_controls[] = { &snd_sb16_ctl_pc_speaker_vol, &snd_sb16_ctl_capture_vol, &snd_sb16_ctl_play_vol, - &snd_als4000_ctl_mono_output_switch, - &snd_als4000_ctl_mono_input_switch, - &snd_als4000_ctl_mixer_out_to_in, - &snd_als4000_ctl_3d_output_switch, - &snd_als4000_ctl_3d_output_ratio, - &snd_als4000_ctl_3d_delay, - &snd_als4000_ctl_3d_poweroff_switch, + &snd_als4000_ctl_master_mono_playback_switch, + &snd_als4000_ctl_master_mono_capture_route, + &snd_als4000_ctl_mono_playback_switch, + &snd_als4000_ctl_mixer_loopback, + &snd_als4000_3d_control_switch, + &snd_als4000_3d_control_ratio, + &snd_als4000_3d_control_freq, + &snd_als4000_3d_control_delay, + &snd_als4000_3d_control_poweroff_switch, #ifdef NOT_AVAILABLE &snd_als4000_ctl_fmdac, &snd_als4000_ctl_qsound, @@ -747,7 +758,7 @@ static unsigned char snd_als4000_init_values[][2] = { /* */ -static int snd_sbmixer_init(sb_t *chip, +static int snd_sbmixer_init(struct snd_sb *chip, struct sbmix_elem **controls, int controls_count, unsigned char map[][2], @@ -755,7 +766,7 @@ static int snd_sbmixer_init(sb_t *chip, char *name) { unsigned long flags; - snd_card_t *card = chip->card; + struct snd_card *card = chip->card; int idx, err; /* mixer reset */ @@ -779,9 +790,9 @@ static int snd_sbmixer_init(sb_t *chip, return 0; } -int snd_sbmixer_new(sb_t *chip) +int snd_sbmixer_new(struct snd_sb *chip) { - snd_card_t * card; + struct snd_card *card; int err; snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); @@ -842,3 +853,140 @@ int snd_sbmixer_new(sb_t *chip) } return 0; } + +#ifdef CONFIG_PM +static unsigned char sb20_saved_regs[] = { + SB_DSP20_MASTER_DEV, + SB_DSP20_PCM_DEV, + SB_DSP20_FM_DEV, + SB_DSP20_CD_DEV, +}; + +static unsigned char sbpro_saved_regs[] = { + SB_DSP_MASTER_DEV, + SB_DSP_PCM_DEV, + SB_DSP_PLAYBACK_FILT, + SB_DSP_FM_DEV, + SB_DSP_CD_DEV, + SB_DSP_LINE_DEV, + SB_DSP_MIC_DEV, + SB_DSP_CAPTURE_SOURCE, + SB_DSP_CAPTURE_FILT, +}; + +static unsigned char sb16_saved_regs[] = { + SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, + SB_DSP4_3DSE, + SB_DSP4_BASS_DEV, SB_DSP4_BASS_DEV + 1, + SB_DSP4_TREBLE_DEV, SB_DSP4_TREBLE_DEV + 1, + SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, + SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, + SB_DSP4_OUTPUT_SW, + SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, + SB_DSP4_LINE_DEV, SB_DSP4_LINE_DEV + 1, + SB_DSP4_MIC_DEV, + SB_DSP4_SPEAKER_DEV, + SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1, + SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1, + SB_DSP4_MIC_AGC +}; + +static unsigned char dt019x_saved_regs[] = { + SB_DT019X_MASTER_DEV, + SB_DT019X_PCM_DEV, + SB_DT019X_SYNTH_DEV, + SB_DT019X_CD_DEV, + SB_DT019X_MIC_DEV, + SB_DT019X_SPKR_DEV, + SB_DT019X_LINE_DEV, + SB_DSP4_OUTPUT_SW, + SB_DT019X_OUTPUT_SW2, + SB_DT019X_CAPTURE_SW, +}; + +static unsigned char als4000_saved_regs[] = { + SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, + SB_DSP4_OUTPUT_SW, + SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, + SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, + SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, + SB_DSP4_MIC_AGC, + SB_DSP4_MIC_DEV, + SB_DSP4_SPEAKER_DEV, + SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1, + SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1, + SB_DT019X_OUTPUT_SW2, + SB_ALS4000_MONO_IO_CTRL, + SB_ALS4000_MIC_IN_GAIN, + SB_ALS4000_3D_SND_FX, + SB_ALS4000_3D_TIME_DELAY, +}; + +static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +{ + unsigned char *val = chip->saved_regs; + snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return); + for (; num_regs; num_regs--) + *val++ = snd_sbmixer_read(chip, *regs++); +} + +static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +{ + unsigned char *val = chip->saved_regs; + snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return); + for (; num_regs; num_regs--) + snd_sbmixer_write(chip, *regs++, *val++); +} + +void snd_sbmixer_suspend(struct snd_sb *chip) +{ + switch (chip->hardware) { + case SB_HW_20: + case SB_HW_201: + save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); + break; + case SB_HW_PRO: + save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); + break; + case SB_HW_16: + case SB_HW_ALS100: + save_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); + break; + case SB_HW_ALS4000: + save_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs)); + break; + case SB_HW_DT019X: + save_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs)); + break; + default: + break; + } +} + +void snd_sbmixer_resume(struct snd_sb *chip) +{ + switch (chip->hardware) { + case SB_HW_20: + case SB_HW_201: + restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); + break; + case SB_HW_PRO: + restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); + break; + case SB_HW_16: + case SB_HW_ALS100: + restore_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); + break; + case SB_HW_ALS4000: + restore_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs)); + break; + case SB_HW_DT019X: + restore_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs)); + break; + default: + break; + } +} +#endif diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 52f2294da62b..0dbbb35b242c 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -22,12 +22,14 @@ */ #include <sound/driver.h> -#include <asm/dma.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/time.h> #include <linux/interrupt.h> #include <linux/moduleparam.h> +#include <asm/dma.h> #include <sound/core.h> #include <sound/sb.h> #include <sound/ad1848.h> @@ -62,11 +64,11 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); 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 -static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "sgalaxy: " /* @@ -75,7 +77,7 @@ static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define AD1848P1( port, x ) ( port + c_d_c_AD1848##x ) -/* from lowlevel/sb/sb.c - to avoid having to allocate a sb_t for the */ +/* from lowlevel/sb/sb.c - to avoid having to allocate a struct snd_sb for the */ /* short time we actually need it.. */ static int snd_sgalaxy_sbdsp_reset(unsigned long port) @@ -180,10 +182,10 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7 AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) }; -static int __init snd_sgalaxy_mixer(ad1848_t *chip) +static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; unsigned int idx; int err; @@ -216,13 +218,14 @@ static int __init snd_sgalaxy_mixer(ad1848_t *chip) return 0; } -static int __init snd_sgalaxy_probe(int dev) +static int __init snd_sgalaxy_probe(struct platform_device *devptr) { + 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; - snd_card_t *card; - ad1848_t *chip; + struct snd_card *card; + struct snd_ad1848 *chip; if (sbport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify SB port\n"); @@ -260,6 +263,7 @@ static int __init snd_sgalaxy_probe(int dev) xirq, xdma1, AD1848_HW_DETECT, &chip)) < 0) goto _err; + card->private_data = chip; if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { snd_printdd(PFX "error creating new ad1848 PCM device\n"); @@ -279,13 +283,12 @@ static int __init snd_sgalaxy_probe(int dev) sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", wssport[dev], xirq, xdma1); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_sgalaxy_cards[dev] = card; + platform_set_drvdata(devptr, card); return 0; _err: @@ -293,30 +296,98 @@ static int __init snd_sgalaxy_probe(int dev) return err; } +static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; +} + +static int snd_sgalaxy_resume(struct platform_device *pdev) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + chip->resume(chip); + snd_ad1848_out(chip, SGALAXY_AUXC_LEFT, chip->image[SGALAXY_AUXC_LEFT]); + snd_ad1848_out(chip, SGALAXY_AUXC_RIGHT, chip->image[SGALAXY_AUXC_RIGHT]); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_SGALAXY_DRIVER "snd_sgalaxy" + +static struct platform_driver snd_sgalaxy_driver = { + .probe = snd_sgalaxy_probe, + .remove = __devexit_p(snd_sgalaxy_remove), +#ifdef CONFIG_PM + .suspend = snd_sgalaxy_suspend, + .resume = snd_sgalaxy_resume, +#endif + .driver = { + .name = SND_SGALAXY_DRIVER + }, +}; + +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 dev, cards; + int i, cards, err; + + err = platform_driver_register(&snd_sgalaxy_driver); + if (err < 0) + return err; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_sgalaxy_probe(dev) >= 0) - cards++; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_SGALAXY_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices[i] = device; + cards++; } if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } - return 0; + + errout: + snd_sgalaxy_unregister_all(); + return err; } static void __exit alsa_card_sgalaxy_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_sgalaxy_cards[idx]); + snd_sgalaxy_unregister_all(); } module_init(alsa_card_sgalaxy_init) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 11588067fa4f..5fb981c0a281 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -23,6 +23,8 @@ #include <sound/driver.h> #include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/pnp.h> #include <linux/spinlock.h> @@ -65,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver."); module_param_array(dma, int, NULL, 0444); MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); + +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; #ifdef CONFIG_PNP static struct pnp_card_device_id sscape_pnpids[] = { @@ -75,8 +80,6 @@ static struct pnp_card_device_id sscape_pnpids[] = { MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); #endif -static snd_card_t *sscape_card[SNDRV_CARDS]; - #define MPU401_IO(i) ((i) + 0) #define MIDI_DATA_IO(i) ((i) + 0) @@ -127,9 +130,9 @@ struct soundscape { int codec_type; int ic_type; struct resource *io_res; - cs4231_t *chip; - mpu401_t *mpu; - snd_hwdep_t *hw; + struct snd_cs4231 *chip; + struct snd_mpu401 *mpu; + struct snd_hwdep *hw; /* * The MIDI device won't work until we've loaded @@ -144,17 +147,17 @@ struct soundscape { #define INVALID_IRQ ((unsigned)-1) -static inline struct soundscape *get_card_soundscape(snd_card_t * c) +static inline struct soundscape *get_card_soundscape(struct snd_card *c) { return (struct soundscape *) (c->private_data); } -static inline struct soundscape *get_mpu401_soundscape(mpu401_t * mpu) +static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) { return (struct soundscape *) (mpu->private_data); } -static inline struct soundscape *get_hwdep_soundscape(snd_hwdep_t * hw) +static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw) { return (struct soundscape *) (hw->private_data); } @@ -308,7 +311,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, * * NOTE: This check is based upon observation, not documentation. */ -static inline int verify_mpu401(const mpu401_t * mpu) +static inline int verify_mpu401(const struct snd_mpu401 * mpu) { return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80); } @@ -316,7 +319,7 @@ static inline int verify_mpu401(const mpu401_t * mpu) /* * This is apparently the standard way to initailise an MPU-401 */ -static inline void initialise_mpu401(const mpu401_t * mpu) +static inline void initialise_mpu401(const struct snd_mpu401 * mpu) { outb(0, MIDI_DATA_IO(mpu->port)); } @@ -335,7 +338,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base) /* * Do the necessary ALSA-level cleanup to deallocate our driver ... */ -static void soundscape_free(snd_card_t * c) +static void soundscape_free(struct snd_card *c) { register struct soundscape *sscape = get_card_soundscape(c); release_and_free_resource(sscape->io_res); @@ -613,7 +616,7 @@ static int sscape_upload_microcode(struct soundscape *sscape, * simultaneously, and that we can't open it at all if * someone is using the MIDI device. */ -static int sscape_hw_open(snd_hwdep_t * hw, struct file *file) +static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) { register struct soundscape *sscape = get_hwdep_soundscape(hw); unsigned long flags; @@ -632,7 +635,7 @@ static int sscape_hw_open(snd_hwdep_t * hw, struct file *file) return err; } -static int sscape_hw_release(snd_hwdep_t * hw, struct file *file) +static int sscape_hw_release(struct snd_hwdep * hw, struct file *file) { register struct soundscape *sscape = get_hwdep_soundscape(hw); unsigned long flags; @@ -643,7 +646,7 @@ static int sscape_hw_release(snd_hwdep_t * hw, struct file *file) return 0; } -static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, +static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { struct soundscape *sscape = get_hwdep_soundscape(hw); @@ -692,8 +695,8 @@ static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, /* * Mixer control for the SoundScape's MIDI device. */ -static int sscape_midi_info(snd_kcontrol_t * ctl, - snd_ctl_elem_info_t * uinfo) +static int sscape_midi_info(struct snd_kcontrol *ctl, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -702,11 +705,11 @@ static int sscape_midi_info(snd_kcontrol_t * ctl, return 0; } -static int sscape_midi_get(snd_kcontrol_t * kctl, - snd_ctl_elem_value_t * uctl) +static int sscape_midi_get(struct snd_kcontrol *kctl, + struct snd_ctl_elem_value *uctl) { - cs4231_t *chip = snd_kcontrol_chip(kctl); - snd_card_t *card = chip->card; + struct snd_cs4231 *chip = snd_kcontrol_chip(kctl); + struct snd_card *card = chip->card; register struct soundscape *s = get_card_soundscape(card); unsigned long flags; @@ -722,11 +725,11 @@ static int sscape_midi_get(snd_kcontrol_t * kctl, return 0; } -static int sscape_midi_put(snd_kcontrol_t * kctl, - snd_ctl_elem_value_t * uctl) +static int sscape_midi_put(struct snd_kcontrol *kctl, + struct snd_ctl_elem_value *uctl) { - cs4231_t *chip = snd_kcontrol_chip(kctl); - snd_card_t *card = chip->card; + struct snd_cs4231 *chip = snd_kcontrol_chip(kctl); + struct snd_card *card = chip->card; register struct soundscape *s = get_card_soundscape(card); unsigned long flags; int change; @@ -763,7 +766,7 @@ static int sscape_midi_put(snd_kcontrol_t * kctl, return change; } -static snd_kcontrol_new_t midi_mixer_ctl = { +static struct snd_kcontrol_new midi_mixer_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "MIDI", .info = sscape_midi_info, @@ -849,7 +852,7 @@ static int __devinit detect_sscape(struct soundscape *s) * to crash the machine. Also check that someone isn't using the hardware * IOCTL device. */ -static int mpu401_open(mpu401_t * mpu) +static int mpu401_open(struct snd_mpu401 * mpu) { int err; @@ -875,7 +878,7 @@ static int mpu401_open(mpu401_t * mpu) return err; } -static void mpu401_close(mpu401_t * mpu) +static void mpu401_close(struct snd_mpu401 * mpu) { register struct soundscape *sscape = get_mpu401_soundscape(mpu); unsigned long flags; @@ -888,10 +891,10 @@ static void mpu401_close(mpu401_t * mpu) /* * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. */ -static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long port, int irq) +static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) { struct soundscape *sscape = get_card_soundscape(card); - snd_rawmidi_t *rawmidi; + struct snd_rawmidi *rawmidi; int err; #define MPU401_SHARE_HARDWARE 1 @@ -900,7 +903,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long port, MPU401_SHARE_HARDWARE, irq, SA_INTERRUPT, &rawmidi)) == 0) { - mpu401_t *mpu = (mpu401_t *) rawmidi->private_data; + struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; mpu->open_input = mpu401_open; mpu->open_output = mpu401_open; mpu->close_input = mpu401_close; @@ -919,7 +922,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long * Override for the CS4231 playback format function. * The AD1845 has much simpler format and rate selection. */ -static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) +static void ad1845_playback_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format) { unsigned long flags; unsigned rate = params_rate(params); @@ -955,7 +958,7 @@ static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params * Override for the CS4231 capture format function. * The AD1845 has much simpler format and rate selection. */ -static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) +static void ad1845_capture_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format) { unsigned long flags; unsigned rate = params_rate(params); @@ -993,10 +996,10 @@ static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params, * try to support at least some of the extra bits by overriding * some of the CS4231 callback. */ -static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, int dma1) +static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq, int dma1) { register struct soundscape *sscape = get_card_soundscape(card); - cs4231_t *chip; + struct snd_cs4231 *chip; int err; #define CS4231_SHARE_HARDWARE (CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2) @@ -1009,7 +1012,7 @@ static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, in CS4231_HW_DETECT, CS4231_HWSHARE_DMA1, &chip)) == 0) { unsigned long flags; - snd_pcm_t *pcm; + struct snd_pcm *pcm; #define AD1845_FREQ_SEL_ENABLE 0x08 @@ -1080,48 +1083,18 @@ static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, in } -struct params -{ - int index; - const char *id; - unsigned port; - int irq; - int mpu_irq; - int dma1; -}; - - -static inline struct params* -init_params(struct params *params, - int index, - const char *id, - unsigned port, - int irq, - int mpu_irq, - int dma1) -{ - params->index = index; - params->id = id; - params->port = port; - params->irq = irq; - params->mpu_irq = mpu_irq; - params->dma1 = (dma1 & 0x03); - - return params; -} - - /* * Create an ALSA soundcard entry for the SoundScape, using * the given list of port, IRQ and DMA resources. */ -static int __devinit create_sscape(const struct params *params, snd_card_t **rcardp) +static int __devinit create_sscape(int dev, struct snd_card **rcardp) { - snd_card_t *card; + struct snd_card *card; register struct soundscape *sscape; register unsigned dma_cfg; unsigned irq_cfg; unsigned mpu_irq_cfg; + unsigned xport; struct resource *io_res; unsigned long flags; int err; @@ -1129,32 +1102,33 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca /* * Check that the user didn't pass us garbage data ... */ - irq_cfg = get_irq_config(params->irq); + irq_cfg = get_irq_config(irq[dev]); if (irq_cfg == INVALID_IRQ) { - snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->irq); + snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); return -ENXIO; } - mpu_irq_cfg = get_irq_config(params->mpu_irq); + mpu_irq_cfg = get_irq_config(mpu_irq[dev]); if (mpu_irq_cfg == INVALID_IRQ) { - printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->mpu_irq); + printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); return -ENXIO; } + xport = port[dev]; /* * Grab IO ports that we will need to probe so that we * can detect and control this hardware ... */ - if ((io_res = request_region(params->port, 8, "SoundScape")) == NULL) { - snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", params->port); + if ((io_res = request_region(xport, 8, "SoundScape")) == NULL) { + snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport); return -EBUSY; } /* * Grab both DMA channels (OK, only one for now) ... */ - if ((err = request_dma(params->dma1, "SoundScape")) < 0) { - snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", params->dma1); + if ((err = request_dma(dma[dev], "SoundScape")) < 0) { + snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]); goto _release_region; } @@ -1162,7 +1136,8 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca * Create a new ALSA sound card entry, in anticipation * of detecting our hardware ... */ - if ((card = snd_card_new(params->index, params->id, THIS_MODULE, sizeof(struct soundscape))) == NULL) { + if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct soundscape))) == NULL) { err = -ENOMEM; goto _release_dma; } @@ -1171,7 +1146,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca spin_lock_init(&sscape->lock); spin_lock_init(&sscape->fwlock); sscape->io_res = io_res; - sscape->io_base = params->port; + sscape->io_base = xport; if (!detect_sscape(sscape)) { printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); @@ -1180,7 +1155,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca } printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", - sscape->io_base, params->irq, params->dma1); + sscape->io_base, irq[dev], dma[dev]); /* * Now create the hardware-specific device so that we can @@ -1223,7 +1198,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); sscape_write_unsafe(sscape->io_base, - GA_CDCFG_REG, 0x09 | DMA_8BIT | (params->dma1 << 4) | (irq_cfg << 1)); + GA_CDCFG_REG, 0x09 | DMA_8BIT | (dma[dev] << 4) | (irq_cfg << 1)); spin_unlock_irqrestore(&sscape->lock, flags); @@ -1231,15 +1206,15 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca * We have now enabled the codec chip, and so we should * detect the AD1845 device ... */ - if ((err = create_ad1845(card, CODEC_IO(params->port), params->irq, params->dma1)) < 0) { + if ((err = create_ad1845(card, CODEC_IO(xport), irq[dev], dma[dev])) < 0) { printk(KERN_ERR "sscape: No AD1845 device at 0x%x, IRQ %d\n", - CODEC_IO(params->port), params->irq); + CODEC_IO(xport), irq[dev]); goto _release_card; } #define MIDI_DEVNUM 0 - if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(params->port), params->mpu_irq)) < 0) { + if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(xport), mpu_irq[dev])) < 0) { printk(KERN_ERR "sscape: Failed to create MPU-401 device at 0x%x\n", - MPU401_IO(params->port)); + MPU401_IO(xport)); goto _release_card; } @@ -1271,7 +1246,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca snd_card_free(card); _release_dma: - free_dma(params->dma1); + free_dma(dma[dev]); _release_region: release_and_free_resource(io_res); @@ -1280,44 +1255,66 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca } -static int sscape_cards __devinitdata; -static struct params sscape_params[SNDRV_CARDS] __devinitdata; +static int __init snd_sscape_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int ret; + + dma[dev] &= 0x03; + ret = create_sscape(dev, &card); + if (ret < 0) + return ret; + snd_card_set_dev(card, &pdev->dev); + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + return ret; + } + platform_set_drvdata(pdev, card); + return 0; +} + +static int __devexit snd_sscape_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define SSCAPE_DRIVER "snd_sscape" + +static struct platform_driver snd_sscape_driver = { + .probe = snd_sscape_probe, + .remove = __devexit_p(snd_sscape_remove), + /* FIXME: suspend/resume */ + .driver = { + .name = SSCAPE_DRIVER + }, +}; #ifdef CONFIG_PNP static inline int __devinit get_next_autoindex(int i) { - while ((i < SNDRV_CARDS) && (port[i] != SNDRV_AUTO_PORT)) { + while (i < SNDRV_CARDS && port[i] != SNDRV_AUTO_PORT) ++i; - } /* while */ - return i; } -static inline int __devinit is_port_known(unsigned io, struct params *params, int cards) -{ - while (--cards >= 0) { - if (params[cards].port == io) - return 1; - } /* while */ - - return 0; -} - static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { - struct pnp_dev *dev; static int idx = 0; + struct pnp_dev *dev; + struct snd_card *card; int ret; /* * Allow this function to fail *quietly* if all the ISA PnP * devices were configured using module parameters instead. */ - if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) { + if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) return -ENOSPC; - } /* * We have found a candidate ISA PnP card. Now we @@ -1339,66 +1336,45 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, /* * Check that we still have room for another sound card ... */ - if (sscape_cards >= SNDRV_CARDS) { - printk(KERN_ERR "sscape: No room for another ALSA device\n"); - return -ENOSPC; - } - - ret = -ENODEV; - dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); - if (dev) { - struct params *this; - if (!pnp_is_active(dev)) { - if (pnp_activate_dev(dev) < 0) { - printk(KERN_INFO "sscape: device is inactive\n"); - return -EBUSY; - } - } - /* - * Read the correct parameters off the ISA PnP bus ... - */ - this = init_params(&sscape_params[sscape_cards], - index[idx], - id[idx], - pnp_port_start(dev, 0), - pnp_irq(dev, 0), - pnp_irq(dev, 1), - pnp_dma(dev, 0)); + if (! dev) + return -ENODEV; - /* - * Do we know about this sound card already? - */ - if ( !is_port_known(this->port, sscape_params, sscape_cards) ) { - snd_card_t *card; - - ret = create_sscape(this, &card); - if (ret < 0) - return ret; - snd_card_set_dev(card, &pcard->card->dev); - - if ((ret = snd_card_register(card)) < 0) { - printk(KERN_ERR "sscape: Failed to register sound card\n"); - snd_card_free(card); - return ret; - } - - pnp_set_card_drvdata(pcard, card); - ++sscape_cards; - ++idx; + if (!pnp_is_active(dev)) { + if (pnp_activate_dev(dev) < 0) { + printk(KERN_INFO "sscape: device is inactive\n"); + return -EBUSY; } } + /* + * Read the correct parameters off the ISA PnP bus ... + */ + port[idx] = pnp_port_start(dev, 0); + irq[idx] = pnp_irq(dev, 0); + mpu_irq[idx] = pnp_irq(dev, 1); + dma[idx] = pnp_dma(dev, 0) & 0x03; + + ret = create_sscape(idx, &card); + if (ret < 0) + return ret; + snd_card_set_dev(card, &pcard->card->dev); + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + snd_card_free(card); + return ret; + } + + pnp_set_card_drvdata(pcard, card); + ++idx; + return ret; } static void __devexit sscape_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - + snd_card_free(pnp_get_card_drvdata(pcard)); pnp_set_card_drvdata(pcard, NULL); - snd_card_disconnect(card); - snd_card_free_in_thread(card); } static struct pnp_card_driver sscape_pnpc_driver = { @@ -1411,11 +1387,25 @@ static struct pnp_card_driver sscape_pnpc_driver = { #endif /* CONFIG_PNP */ -static int __init sscape_manual_probe(struct params *params) +static void __init_or_module sscape_unregister_all(void) { - int ret; - unsigned i; - snd_card_t *card; + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&sscape_pnpc_driver); + 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) { /* @@ -1430,52 +1420,36 @@ static int __init sscape_manual_probe(struct params *params) /* * 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) ) { + 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 -ENXIO; + ret = -ENXIO; + goto errout; } /* * This cards looks OK ... */ - init_params(params, index[i], id[i], port[i], irq[i], mpu_irq[i], dma[i]); - - ret = create_sscape(params, &card); - if (ret < 0) - return ret; - - if ((ret = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return ret; - } - if ((ret = snd_card_register(card)) < 0) { - printk(KERN_ERR "sscape: Failed to register sound card\n"); - snd_card_free(card); - return ret; + device = platform_device_register_simple(SSCAPE_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + ret = PTR_ERR(device); + goto errout; } - - sscape_card[sscape_cards] = card; - params++; - sscape_cards++; - } /* for */ - + platform_devices[i] = device; + } return 0; -} + errout: + sscape_unregister_all(); + return ret; +} static void sscape_exit(void) { - unsigned i; - -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sscape_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(sscape_card); ++i) { - snd_card_free(sscape_card[i]); - } /* for */ + sscape_unregister_all(); } @@ -1489,24 +1463,11 @@ 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(sscape_params); - if (ret < 0) { - int i; - for (i = 0; i < sscape_cards; ++i) - snd_card_free(sscape_card[i]); + ret = sscape_manual_probe(); + if (ret < 0) return ret; - } - -#ifdef CONFIG_PNP - if (sscape_cards < SNDRV_CARDS) { - ret = pnp_register_card_driver(&sscape_pnpc_driver); - if (ret < 0) { - sscape_exit(); - return ret; - } - } -#endif - + if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0) + pnp_registered = 1; return 0; } diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 1818f1013c3f..a6dcb2f970ca 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -23,6 +23,8 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/slab.h> +#include <linux/err.h> +#include <linux/platform_device.h> #include <linux/pnp.h> #include <linux/moduleparam.h> #include <sound/core.h> @@ -81,7 +83,9 @@ 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 snd_card_t *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #ifdef CONFIG_PNP @@ -240,7 +244,7 @@ snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *c cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); } - snd_printk ("CS4232 MPU: port=0x%lx, irq=%i\n", + snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n", cs4232_mpu_port[dev], cs4232_mpu_irq[dev]); } @@ -279,12 +283,12 @@ static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, return IRQ_HANDLED; } -static snd_hwdep_t * __devinit -snd_wavefront_new_synth (snd_card_t *card, +static struct snd_hwdep * __devinit +snd_wavefront_new_synth (struct snd_card *card, int hw_dev, snd_wavefront_card_t *acard) { - snd_hwdep_t *wavefront_synth; + struct snd_hwdep *wavefront_synth; if (snd_wavefront_detect (acard) < 0) { return NULL; @@ -305,17 +309,17 @@ snd_wavefront_new_synth (snd_card_t *card, return wavefront_synth; } -static snd_hwdep_t * __devinit -snd_wavefront_new_fx (snd_card_t *card, +static struct snd_hwdep * __devinit +snd_wavefront_new_fx (struct snd_card *card, int hw_dev, snd_wavefront_card_t *acard, unsigned long port) { - snd_hwdep_t *fx_processor; + struct snd_hwdep *fx_processor; if (snd_wavefront_fx_start (&acard->wavefront)) { - snd_printk ("cannot initialize YSS225 FX processor"); + snd_printk (KERN_ERR "cannot initialize YSS225 FX processor"); return NULL; } @@ -332,22 +336,22 @@ snd_wavefront_new_fx (snd_card_t *card, static snd_wavefront_mpu_id internal_id = internal_mpu; static snd_wavefront_mpu_id external_id = external_mpu; -static snd_rawmidi_t * __devinit -snd_wavefront_new_midi (snd_card_t *card, +static struct snd_rawmidi *__devinit +snd_wavefront_new_midi (struct snd_card *card, int midi_dev, snd_wavefront_card_t *acard, unsigned long port, snd_wavefront_mpu_id mpu) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; static int first = 1; if (first) { first = 0; acard->wavefront.midi.base = port; if (snd_wavefront_midi_start (acard)) { - snd_printk ("cannot initialize MIDI interface\n"); + snd_printk (KERN_ERR "cannot initialize MIDI interface\n"); return NULL; } } @@ -374,7 +378,7 @@ snd_wavefront_new_midi (snd_card_t *card, } static void -snd_wavefront_free(snd_card_t *card) +snd_wavefront_free(struct snd_card *card) { snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data; @@ -385,42 +389,17 @@ snd_wavefront_free(snd_card_t *card) } } -static int __devinit -snd_wavefront_probe (int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_wavefront_card_new(int dev) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; - cs4231_t *chip; - snd_hwdep_t *wavefront_synth; - snd_rawmidi_t *ics2115_internal_rmidi = NULL; - snd_rawmidi_t *ics2115_external_rmidi = NULL; - snd_hwdep_t *fx_processor; - int hw_dev = 0, midi_dev = 0, err; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif - if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify CS4232 port\n"); - return -EINVAL; - } - if (ics2115_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify ICS2115 port\n"); - return -ENODEV; - } -#ifdef CONFIG_PNP - } -#endif - card = snd_card_new (index[dev], - id[dev], - THIS_MODULE, + card = snd_card_new (index[dev], id[dev], THIS_MODULE, sizeof(snd_wavefront_card_t)); + if (card == NULL) + return NULL; - if (card == NULL) { - return -ENOMEM; - } - acard = (snd_wavefront_card_t *)card->private_data; + acard = card->private_data; acard->wavefront.irq = -1; spin_lock_init(&acard->wavefront.irq_lock); init_waitqueue_head(&acard->wavefront.interrupt_sleeper); @@ -428,18 +407,19 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, spin_lock_init(&acard->wavefront.midi.virtual); card->private_free = snd_wavefront_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if (snd_wavefront_pnp (dev, acard, pcard, pid) < 0) { - if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk ("isapnp detection failed\n"); - snd_card_free (card); - return -ENODEV; - } - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif /* CONFIG_PNP */ + return card; +} + +static int __devinit +snd_wavefront_probe (struct snd_card *card, int dev) +{ + snd_wavefront_card_t *acard = card->private_data; + struct snd_cs4231 *chip; + struct snd_hwdep *wavefront_synth; + struct snd_rawmidi *ics2115_internal_rmidi = NULL; + struct snd_rawmidi *ics2115_external_rmidi = NULL; + struct snd_hwdep *fx_processor; + int hw_dev = 0, midi_dev = 0, err; /* --------- PCM --------------- */ @@ -450,52 +430,46 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, dma1[dev], dma2[dev], CS4231_HW_DETECT, 0, &chip)) < 0) { - snd_card_free(card); - snd_printk ("can't allocate CS4231 device\n"); + snd_printk (KERN_ERR "can't allocate CS4231 device\n"); return err; } - if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) { - snd_card_free(card); + if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) return err; - } - if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) { - snd_card_free(card); + + if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) return err; - } /* ---------- OPL3 synth --------- */ if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { - opl3_t *opl3; + struct snd_opl3 *opl3; if ((err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, OPL3_HW_OPL3_CS, 0, &opl3)) < 0) { - snd_printk ("can't allocate or detect OPL3 synth\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n"); return err; } - if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) { - snd_card_free(card); + if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) return err; - } hw_dev++; } /* ------- ICS2115 Wavetable synth ------- */ - if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, "ICS2115")) == NULL) { - snd_printk("unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", ics2115_port[dev], ics2115_port[dev] + 16 - 1); - snd_card_free(card); + if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, + "ICS2115")) == NULL) { + snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", + ics2115_port[dev], ics2115_port[dev] + 16 - 1); return -EBUSY; } - if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, SA_INTERRUPT, "ICS2115", (void *)acard)) { - snd_printk("unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); - snd_card_free(card); + if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, + SA_INTERRUPT, "ICS2115", acard)) { + snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); return -EBUSY; } @@ -503,8 +477,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, acard->wavefront.base = ics2115_port[dev]; if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) { - snd_printk ("can't create WaveFront synth device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't create WaveFront synth device\n"); return -ENOMEM; } @@ -515,8 +488,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, /* --------- Mixer ------------ */ if ((err = snd_cs4231_mixer(chip)) < 0) { - snd_printk ("can't allocate mixer device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate mixer device\n"); return err; } @@ -528,8 +500,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, cs4232_mpu_irq[dev], SA_INTERRUPT, NULL)) < 0) { - snd_printk ("can't allocate CS4232 MPU-401 device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n"); return err; } midi_dev++; @@ -545,8 +516,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], internal_mpu); if (ics2115_internal_rmidi == NULL) { - snd_printk ("can't setup ICS2115 internal MIDI device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n"); return -ENOMEM; } midi_dev++; @@ -562,8 +532,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], external_mpu); if (ics2115_external_rmidi == NULL) { - snd_printk ("can't setup ICS2115 external MIDI device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n"); return -ENOMEM; } midi_dev++; @@ -577,8 +546,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, acard, ics2115_port[dev]); if (fx_processor == NULL) { - snd_printk ("can't setup FX device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup FX device\n"); return -ENOMEM; } @@ -619,49 +587,97 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], ics2115_irq[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return err; + return snd_card_register(card); +} + +static int __init snd_wavefront_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int err; + + if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk("specify CS4232 port\n"); + return -EINVAL; + } + if (ics2115_port[dev] == SNDRV_AUTO_PORT) { + snd_printk("specify ICS2115 port\n"); + return -ENODEV; } - if ((err = snd_card_register(card)) < 0) { + card = snd_wavefront_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_wavefront_probe(card, dev)) < 0) { snd_card_free(card); return err; } - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_wavefront_legacy[dev] = card; + + platform_set_drvdata(pdev, card); return 0; -} +} + +static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_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), + /* FIXME: suspend, resume */ + .driver = { + .name = WAVEFRONT_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_wavefront_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - - return -ENODEV; + static int dev; + struct snd_card *card; + int res; + + for ( ; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_wavefront_card_new(dev); + if (! card) + return -ENOMEM; + + if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) { + if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk (KERN_ERR "isapnp detection failed\n"); + snd_card_free (card); + return -ENODEV; + } + } + snd_card_set_dev(card, &pcard->card->dev); + + if ((res = snd_wavefront_probe(card, dev)) < 0) + return res; + + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver wavefront_pnpc_driver = { @@ -670,48 +686,68 @@ static struct pnp_card_driver wavefront_pnpc_driver = { .id_table = snd_wavefront_pnpids, .probe = snd_wavefront_pnp_detect, .remove = __devexit_p(snd_wavefront_pnp_remove), + /* FIXME: suspend,resume */ }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_wavefront_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&wavefront_pnpc_driver); + 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 cards = 0; - int dev; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; + int i, err, cards = 0; + + if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (snd_wavefront_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(WAVEFRONT_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + platform_devices[i] = device; + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&wavefront_pnpc_driver); -#endif + + i = pnp_register_card_driver(&wavefront_pnpc_driver); + if (i >= 0) { + pnp_registered = 1; + cards += i; + } + if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&wavefront_pnpc_driver); -#endif #ifdef MODULE printk (KERN_ERR "No WaveFront cards found or devices busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_wavefront_unregister_all(); + return err; } static void __exit alsa_card_wavefront_exit(void) { - int idx; - -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&wavefront_pnpc_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_wavefront_legacy[idx]); + snd_wavefront_unregister_all(); } module_init(alsa_card_wavefront_init) diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 32379688eed4..180661c5ffdc 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -460,7 +460,7 @@ snd_wavefront_fx_detect (snd_wavefront_t *dev) } int -snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) +snd_wavefront_fx_open (struct snd_hwdep *hw, struct file *file) { if (!try_module_get(hw->card->module)) @@ -470,7 +470,7 @@ snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) +snd_wavefront_fx_release (struct snd_hwdep *hw, struct file *file) { module_put(hw->card->module); @@ -478,11 +478,11 @@ snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file, +snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file, unsigned int cmd, unsigned long arg) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; snd_wavefront_t *dev; wavefront_fx_info r; diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c index 6f51d64fb565..15888ba2169b 100644 --- a/sound/isa/wavefront/wavefront_midi.c +++ b/sound/isa/wavefront/wavefront_midi.c @@ -91,10 +91,10 @@ write_data (snd_wavefront_midi_t *midi, unsigned char byte) } static snd_wavefront_midi_t * -get_wavefront_midi (snd_rawmidi_substream_t *substream) +get_wavefront_midi (struct snd_rawmidi_substream *substream) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; if (substream == NULL || substream->rmidi == NULL) @@ -230,7 +230,7 @@ static void snd_wavefront_midi_output_write(snd_wavefront_card_t *card) } } -static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -252,7 +252,7 @@ static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -274,7 +274,7 @@ static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -295,7 +295,7 @@ static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -315,7 +315,7 @@ static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_wavefront_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_wavefront_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -355,7 +355,7 @@ static void snd_wavefront_midi_output_timer(unsigned long data) snd_wavefront_midi_output_write(card); } -static void snd_wavefront_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -401,7 +401,7 @@ snd_wavefront_midi_interrupt (snd_wavefront_card_t *card) { unsigned long flags; snd_wavefront_midi_t *midi; - static snd_rawmidi_substream_t *substream = NULL; + static struct snd_rawmidi_substream *substream = NULL; static int mpu = external_mpu; int max = 128; unsigned char byte; @@ -554,14 +554,14 @@ snd_wavefront_midi_start (snd_wavefront_card_t *card) return 0; } -snd_rawmidi_ops_t snd_wavefront_midi_output = +struct snd_rawmidi_ops snd_wavefront_midi_output = { .open = snd_wavefront_midi_output_open, .close = snd_wavefront_midi_output_close, .trigger = snd_wavefront_midi_output_trigger, }; -snd_rawmidi_ops_t snd_wavefront_midi_input = +struct snd_rawmidi_ops snd_wavefront_midi_input = { .open = snd_wavefront_midi_input_open, .close = snd_wavefront_midi_input_close, diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index abd79b781412..679d0ae97e4f 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -144,13 +144,13 @@ MODULE_PARM_DESC(osrun_time, "how many seconds to wait for the ICS2115 OS"); static int wavefront_delete_sample (snd_wavefront_t *, int sampnum); static int wavefront_find_free_sample (snd_wavefront_t *); -typedef struct { +struct wavefront_command { int cmd; char *action; unsigned int read_cnt; unsigned int write_cnt; int need_ack; -} wavefront_command; +}; static struct { int errno; @@ -170,7 +170,7 @@ static struct { #define NEEDS_ACK 1 -static wavefront_command wavefront_commands[] = { +static struct wavefront_command wavefront_commands[] = { { WFC_SET_SYNTHVOL, "set synthesizer volume", 0, 1, NEEDS_ACK }, { WFC_GET_SYNTHVOL, "get synthesizer volume", 1, 0, 0}, { WFC_SET_NVOICES, "set number of voices", 0, 1, NEEDS_ACK }, @@ -249,7 +249,7 @@ wavefront_errorstr (int errnum) return "Unknown WaveFront error"; } -static wavefront_command * +static struct wavefront_command * wavefront_get_command (int cmd) { @@ -261,7 +261,7 @@ wavefront_get_command (int cmd) } } - return (wavefront_command *) 0; + return NULL; } static inline int @@ -345,9 +345,9 @@ snd_wavefront_cmd (snd_wavefront_t *dev, int ack; unsigned int i; int c; - wavefront_command *wfcmd; + struct wavefront_command *wfcmd; - if ((wfcmd = wavefront_get_command (cmd)) == (wavefront_command *) 0) { + if ((wfcmd = wavefront_get_command (cmd)) == NULL) { snd_printk ("command 0x%x not supported.\n", cmd); return 1; @@ -1625,7 +1625,7 @@ wavefront_synth_control (snd_wavefront_card_t *acard, } int -snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) +snd_wavefront_synth_open (struct snd_hwdep *hw, struct file *file) { if (!try_module_get(hw->card->module)) @@ -1635,7 +1635,7 @@ snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) +snd_wavefront_synth_release (struct snd_hwdep *hw, struct file *file) { module_put(hw->card->module); @@ -1643,18 +1643,18 @@ snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file, +snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_t *dev; snd_wavefront_card_t *acard; wavefront_control *wc; void __user *argp = (void __user *)arg; int err; - card = (snd_card_t *) hw->card; + card = (struct snd_card *) hw->card; snd_assert(card != NULL, return -ENODEV); |