X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fisa%2Fopti9xx%2Fopti92x-ad1848.c;h=c4fbf6fffd0cf5158e0366720376446df338c88f;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=3888d5c61bc65f5d581d79b66a99e3459d83e8d0;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 3888d5c61..c4fbf6fff 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #ifdef CS4231 #include @@ -48,23 +49,21 @@ #endif #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA -#define SNDRV_GET_ID #include MODULE_AUTHOR("Massimo Piccioni "); -MODULE_CLASSES("{sound}"); MODULE_LICENSE("GPL"); #ifdef OPTi93X MODULE_DESCRIPTION("OPTi93X"); -MODULE_DEVICES("{{OPTi,82C931/3}}"); +MODULE_SUPPORTED_DEVICE("{{OPTi,82C931/3}}"); #else /* OPTi93X */ #ifdef CS4231 MODULE_DESCRIPTION("OPTi92X - CS4231"); -MODULE_DEVICES("{{OPTi,82C924 (CS4231)}," +MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (CS4231)}," "{OPTi,82C925 (CS4231)}}"); #else /* CS4231 */ MODULE_DESCRIPTION("OPTi92X - AD1848"); -MODULE_DEVICES("{{OPTi,82C924 (AD1848)}," +MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)}," "{OPTi,82C925 (AD1848)}," "{OAK,Mozart}}"); #endif /* CS4231 */ @@ -84,40 +83,29 @@ static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ #endif /* CS4231 || OPTi93X */ -MODULE_PARM(index, "i"); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for opti9xx based soundcard."); -MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); -MODULE_PARM(id, "s"); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for opti9xx based soundcard."); -MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); -//MODULE_PARM(enable, "i"); +//module_param(enable, bool, 0444); //MODULE_PARM_DESC(enable, "Enable opti9xx soundcard."); -//MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); -MODULE_PARM(isapnp, "i"); +module_param(isapnp, bool, 0444); MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); -MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); -MODULE_PARM(port, "l"); +module_param(port, long, 0444); MODULE_PARM_DESC(port, "WSS port # for opti9xx driver."); -MODULE_PARM_SYNTAX(port, SNDRV_PORT_DESC); -MODULE_PARM(mpu_port, "l"); +module_param(mpu_port, long, 0444); MODULE_PARM_DESC(mpu_port, "MPU-401 port # for opti9xx driver."); -MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(fm_port, "l"); +module_param(fm_port, long, 0444); MODULE_PARM_DESC(fm_port, "FM port # for opti9xx driver."); -MODULE_PARM_SYNTAX(fm_port, SNDRV_PORT_DESC); -MODULE_PARM(irq, "i"); +module_param(irq, int, 0444); MODULE_PARM_DESC(irq, "WSS irq # for opti9xx driver."); -MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC); -MODULE_PARM(mpu_irq, "i"); +module_param(mpu_irq, int, 0444); MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for opti9xx driver."); -MODULE_PARM_SYNTAX(mpu_irq, SNDRV_IRQ_DESC); -MODULE_PARM(dma1, "i"); +module_param(dma1, int, 0444); MODULE_PARM_DESC(dma1, "1st dma # for opti9xx driver."); -MODULE_PARM_SYNTAX(dma1, SNDRV_DMA_DESC); #if defined(CS4231) || defined(OPTi93X) -MODULE_PARM(dma2, "i"); +module_param(dma2, int, 0444); MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver."); -MODULE_PARM_SYNTAX(dma2, SNDRV_DMA_DESC); #endif /* CS4231 || OPTi93X */ #define OPTi9XX_HW_DETECT 0 @@ -474,7 +462,6 @@ static int __devinit snd_opti9xx_configure(opti9xx_t *chip) unsigned char dma_bits; unsigned char mpu_port_bits = 0; unsigned char mpu_irq_bits; - unsigned long flags; switch (chip->hardware) { #ifndef OPTi93X @@ -601,9 +588,11 @@ __skip_base: dma_bits |= 0x04; #endif /* CS4231 || OPTi93X */ - spin_lock_irqsave(&chip->lock, flags); +#ifndef OPTi93X + outb(irq_bits << 3 | dma_bits, chip->wss_base); +#else /* OPTi93X */ snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); - spin_unlock_irqrestore(&chip->lock, flags); +#endif /* OPTi93X */ __skip_resources: if (chip->hardware > OPTi9XX_HW_82C928) { @@ -660,8 +649,6 @@ __skip_mpu: #ifdef OPTi93X -#define chip_t opti93x_t - static unsigned char snd_opti93x_default_image[32] = { 0x00, /* 00/00 - l_mixout_outctrl */ @@ -763,15 +750,10 @@ static void snd_opti93x_mce_down(opti93x_t *chip) static void snd_opti93x_mute(opti93x_t *chip, int mute) { - unsigned long flags; - - spin_lock_irqsave(&chip->lock, flags); - mute = mute ? 1 : 0; - if (chip->mute == mute) { - spin_unlock_irqrestore(&chip->lock, flags); + if (chip->mute == mute) return; - } + chip->mute = mute; snd_opti93x_mute_reg(chip, OPTi93X_CD_LEFT_INPUT, mute); @@ -796,8 +778,6 @@ static void snd_opti93x_mute(opti93x_t *chip, int mute) snd_opti93x_mute_reg(chip, OPTi93X_MIC_RIGHT_INPUT, mute); snd_opti93x_mute_reg(chip, OPTi93X_OUT_LEFT, mute); snd_opti93x_mute_reg(chip, OPTi93X_OUT_RIGHT, mute); - - spin_unlock_irqrestore(&chip->lock, flags); } @@ -818,7 +798,7 @@ static unsigned int snd_opti93x_get_count(unsigned char format, static unsigned int rates[] = { 5512, 6615, 8000, 9600, 11025, 16000, 18900, 22050, 27428, 32000, 33075, 37800, 44100, 48000 }; -#define RATES sizeof(rates) / sizeof(rates[0]) +#define RATES ARRAY_SIZE(rates) static snd_pcm_hw_constraint_list_t hw_constraints_rates = { .count = RATES, @@ -869,10 +849,8 @@ static unsigned char snd_opti93x_get_format(opti93x_t *chip, static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) { - unsigned long flags; unsigned char mask; - spin_lock_irqsave(&chip->lock, flags); snd_opti93x_mute(chip, 1); snd_opti93x_mce_up(chip); @@ -881,14 +859,10 @@ static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) snd_opti93x_mce_down(chip); snd_opti93x_mute(chip, 0); - spin_unlock_irqrestore(&chip->lock, flags); } static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) { - unsigned long flags; - - spin_lock_irqsave(&chip->lock, flags); snd_opti93x_mute(chip, 1); snd_opti93x_mce_up(chip); @@ -900,7 +874,6 @@ static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) snd_opti93x_mce_down(chip); snd_opti93x_mute(chip, 0); - spin_unlock_irqrestore(&chip->lock, flags); } @@ -1124,7 +1097,7 @@ static void snd_opti93x_overrange(opti93x_t *chip) irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - opti93x_t *codec = snd_magic_cast(opti93x_t, dev_id, return IRQ_NONE); + opti93x_t *codec = dev_id; unsigned char status; status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11)); @@ -1270,13 +1243,13 @@ static int snd_opti93x_free(opti93x_t *chip) if (chip->irq >= 0) { free_irq(chip->irq, chip); } - snd_magic_kfree(chip); + kfree(chip); return 0; } static int snd_opti93x_dev_free(snd_device_t *device) { - opti93x_t *chip = snd_magic_cast(opti93x_t, device->device_data, return -ENXIO); + opti93x_t *chip = device->device_data; return snd_opti93x_free(chip); } @@ -1301,7 +1274,7 @@ int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, opti93x_t *codec; *rcodec = NULL; - codec = snd_magic_kcalloc(opti93x_t, 0, GFP_KERNEL); + codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; codec->irq = -1; @@ -1381,7 +1354,7 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = { static void snd_opti93x_pcm_free(snd_pcm_t *pcm) { - opti93x_t *codec = snd_magic_cast(opti93x_t, pcm->private_data, return); + opti93x_t *codec = pcm->private_data; codec->pcm = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1604,8 +1577,6 @@ static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -#define OPTi93X_CONTROLS (sizeof(snd_opti93x_controls)/sizeof(snd_kcontrol_new_t)) - static snd_kcontrol_new_t 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), @@ -1645,7 +1616,7 @@ int snd_opti93x_mixer(opti93x_t *chip) strcpy(card->mixername, snd_opti93x_chip_id(chip)); - for (idx = 0; idx < OPTi93X_CONTROLS; idx++) { + for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { knew = snd_opti93x_controls[idx]; if (chip->hardware == OPTi9XX_HW_82C930) { if (strstr(knew.name, "FM")) /* skip FM controls */ @@ -2253,47 +2224,3 @@ static void __exit alsa_card_opti9xx_exit(void) module_init(alsa_card_opti9xx_init) module_exit(alsa_card_opti9xx_exit) - -#ifndef MODULE - -/* format is: snd-opti9xx=enable,index,id,isapnp, - port,mpu_port,fm_port, - irq,mpu_irq, - dma1,[dma2] */ - -static int __init alsa_card_opti9xx_setup(char *str) -{ - int __attribute__ ((__unused__)) enable = 1; - int __attribute__ ((__unused__)) pnp = INT_MAX; - - (void)(get_option(&str,&enable) == 2 && - get_option(&str,&index) == 2 && - get_id(&str,&id) == 2 && - get_option(&str,&pnp) == 2 && - get_option_long(&str,&port) == 2 && - get_option_long(&str,&mpu_port) == 2 && - get_option_long(&str,&fm_port) == 2 && - get_option(&str,&irq) == 2 && - get_option(&str,&mpu_irq) == 2 && - get_option(&str,&dma1) == 2 -#if defined(CS4231) || defined(OPTi93X) - && - get_option(&str,&dma2) == 2 -#endif - ); -#ifdef CONFIG_PNP - if (pnp != INT_MAX) - isapnp = pnp; -#endif - return 1; -} - -#if defined(OPTi93X) -__setup("snd-opti93x=", alsa_card_opti9xx_setup); -#elif defined(CS4231) -__setup("snd-opti92x-cs4231=", alsa_card_opti9xx_setup); -#else -__setup("snd-opti92x-ad1848=", alsa_card_opti9xx_setup); -#endif - -#endif /* ifndef MODULE */