X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fens1370.c;h=ca9e34e88f629a5e42614529dbbaec7e80470dfb;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=ff4c797c082c00a6b70d8b13cfa6cfaf5227bd42;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index ff4c797c0..ca9e34e88 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -19,6 +19,13 @@ * */ +/* Power-Management-Code ( CONFIG_PM ) + * for ens1371 only ( FIXME ) + * derived from cs4281.c, atiixp.c and via82xx.c + * using http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c1540.htm + * by Kurt J. Bosch + */ + #include #include #include @@ -27,6 +34,9 @@ #include #include #include +#include +#include + #include #include #include @@ -36,12 +46,9 @@ #else #include #endif -#define SNDRV_GET_ID #include #include -#define chip_t ensoniq_t - #ifndef CHIP1371 #undef CHIP1370 #define CHIP1370 @@ -56,15 +63,14 @@ MODULE_AUTHOR("Jaroslav Kysela , Thomas Sailer "); MODULE_LICENSE("GPL"); -MODULE_CLASSES("{sound}"); #ifdef CHIP1370 MODULE_DESCRIPTION("Ensoniq AudioPCI ES1370"); -MODULE_DEVICES("{{Ensoniq,AudioPCI-97 ES1370}," +MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI-97 ES1370}," "{Creative Labs,SB PCI64/128 (ES1370)}}"); #endif #ifdef CHIP1371 MODULE_DESCRIPTION("Ensoniq/Creative AudioPCI ES1371+"); -MODULE_DEVICES("{{Ensoniq,AudioPCI ES1371/73}," +MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73}," "{Ensoniq,AudioPCI ES1373}," "{Creative Labs,Ectiva EV1938}," "{Creative Labs,SB PCI64/128 (ES1371/73)}," @@ -86,33 +92,31 @@ static int joystick_port[SNDRV_CARDS]; static int joystick[SNDRV_CARDS]; #endif #endif +#ifdef CHIP1371 +static int spdif[SNDRV_CARDS]; +static int lineio[SNDRV_CARDS]; +#endif -MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Ensoniq AudioPCI soundcard."); -MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); -MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s"); +module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for Ensoniq AudioPCI soundcard."); -MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); -MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable Ensoniq AudioPCI soundcard."); -MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); #ifdef SUPPORT_JOYSTICK #ifdef CHIP1371 -MODULE_PARM(joystick_port, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(joystick_port, int, NULL, 0444); MODULE_PARM_DESC(joystick_port, "Joystick port address."); -MODULE_PARM_SYNTAX(joystick_port, SNDRV_ENABLED ",allows:{{0},{1},{0x200},{0x208},{0x210},{0x218}},dialog:list"); #else -MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(joystick, bool, NULL, 0444); MODULE_PARM_DESC(joystick, "Enable joystick."); -MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); #endif #endif /* SUPPORT_JOYSTICK */ - -#ifndef PCI_DEVICE_ID_ENSONIQ_CT5880 -#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 -#endif -#ifndef PCI_DEVICE_ID_ENSONIQ_ES1371 -#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 +#ifdef CHIP1371 +module_param_array(spdif, int, NULL, 0444); +MODULE_PARM_DESC(spdif, "S/PDIF output (-1 = none, 0 = auto, 1 = force)."); +module_param_array(lineio, int, NULL, 0444); +MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 = force)."); #endif /* ES1371 chip ID */ @@ -375,10 +379,9 @@ MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); */ -typedef struct _snd_ensoniq ensoniq_t; - -struct _snd_ensoniq { +struct ensoniq { spinlock_t reg_lock; + struct mutex src_mutex; int irq; @@ -387,7 +390,6 @@ struct _snd_ensoniq { unsigned long capture3size; unsigned long port; - struct resource *res_port; unsigned int mode; unsigned int uartm; /* UART mode */ @@ -400,12 +402,12 @@ struct _snd_ensoniq { union { #ifdef CHIP1371 struct { - ac97_t *ac97; + struct snd_ac97 *ac97; } es1371; #else struct { int pclkdiv_lock; - ak4531_t *ak4531; + struct snd_ak4531 *ak4531; } es1370; #endif } u; @@ -413,39 +415,38 @@ struct _snd_ensoniq { struct pci_dev *pci; unsigned short subsystem_vendor_id; unsigned short subsystem_device_id; - snd_card_t *card; - snd_pcm_t *pcm1; /* DAC1/ADC PCM */ - snd_pcm_t *pcm2; /* DAC2 PCM */ - snd_pcm_substream_t *playback1_substream; - snd_pcm_substream_t *playback2_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm1; /* DAC1/ADC PCM */ + struct snd_pcm *pcm2; /* DAC2 PCM */ + struct snd_pcm_substream *playback1_substream; + struct snd_pcm_substream *playback2_substream; + struct snd_pcm_substream *capture_substream; unsigned int p1_dma_size; unsigned int p2_dma_size; unsigned int c_dma_size; unsigned int p1_period_size; unsigned int p2_period_size; unsigned int c_period_size; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_input; - snd_rawmidi_substream_t *midi_output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_input; + struct snd_rawmidi_substream *midi_output; unsigned int spdif; unsigned int spdif_default; unsigned int spdif_stream; #ifdef CHIP1370 - struct snd_dma_device dma_dev; struct snd_dma_buffer dma_bug; #endif #ifdef SUPPORT_JOYSTICK - struct gameport gameport; + struct gameport *gameport; #endif }; static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs); -static struct pci_device_id snd_audiopci_ids[] = { +static struct pci_device_id snd_audiopci_ids[] __devinitdata = { #ifdef CHIP1370 { 0x1274, 0x5000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1370 */ #endif @@ -468,39 +469,39 @@ MODULE_DEVICE_TABLE(pci, snd_audiopci_ids); #ifdef CHIP1370 static unsigned int snd_es1370_fixed_rates[] = {5512, 11025, 22050, 44100}; -static snd_pcm_hw_constraint_list_t snd_es1370_hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list snd_es1370_hw_constraints_rates = { .count = 4, .list = snd_es1370_fixed_rates, .mask = 0, }; -static ratnum_t es1370_clock = { +static struct snd_ratnum es1370_clock = { .num = ES_1370_SRCLOCK, .den_min = 29, .den_max = 353, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t snd_es1370_hw_constraints_clock = { +static struct snd_pcm_hw_constraint_ratnums snd_es1370_hw_constraints_clock = { .nrats = 1, .rats = &es1370_clock, }; #else -static ratden_t es1371_dac_clock = { +static struct snd_ratden es1371_dac_clock = { .num_min = 3000 * (1 << 15), .num_max = 48000 * (1 << 15), .num_step = 3000, .den = 1 << 15, }; -static snd_pcm_hw_constraint_ratdens_t snd_es1371_hw_constraints_dac_clock = { +static struct snd_pcm_hw_constraint_ratdens snd_es1371_hw_constraints_dac_clock = { .nrats = 1, .rats = &es1371_dac_clock, }; -static ratnum_t es1371_adc_clock = { +static struct snd_ratnum es1371_adc_clock = { .num = 48000 << 15, .den_min = 32768, .den_max = 393216, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t snd_es1371_hw_constraints_adc_clock = { +static struct snd_pcm_hw_constraint_ratnums snd_es1371_hw_constraints_adc_clock = { .nrats = 1, .rats = &es1371_adc_clock, }; @@ -514,7 +515,7 @@ static const unsigned int snd_ensoniq_sample_shift[] = #ifdef CHIP1371 -static unsigned int snd_es1371_wait_src_ready(ensoniq_t * ensoniq) +static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq) { unsigned int t, r = 0; @@ -522,12 +523,14 @@ static unsigned int snd_es1371_wait_src_ready(ensoniq_t * ensoniq) r = inl(ES_REG(ensoniq, 1371_SMPRATE)); if ((r & ES_1371_SRC_RAM_BUSY) == 0) return r; + cond_resched(); } - snd_printk("wait source ready timeout 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_SMPRATE), r); + snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_SMPRATE), r); return 0; } -static unsigned int snd_es1371_src_read(ensoniq_t * ensoniq, unsigned short reg) +static unsigned int snd_es1371_src_read(struct ensoniq * ensoniq, unsigned short reg) { unsigned int temp, i, orig, r; @@ -561,7 +564,7 @@ static unsigned int snd_es1371_src_read(ensoniq_t * ensoniq, unsigned short reg) return temp; } -static void snd_es1371_src_write(ensoniq_t * ensoniq, +static void snd_es1371_src_write(struct ensoniq * ensoniq, unsigned short reg, unsigned short data) { unsigned int r; @@ -577,45 +580,39 @@ static void snd_es1371_src_write(ensoniq_t * ensoniq, #ifdef CHIP1370 -static void snd_es1370_codec_write(ak4531_t *ak4531, +static void snd_es1370_codec_write(struct snd_ak4531 *ak4531, unsigned short reg, unsigned short val) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, ak4531->private_data, return); - unsigned long flags; + struct ensoniq *ensoniq = ak4531->private_data; unsigned long end_time = jiffies + HZ / 10; #if 0 - printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); + printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", + reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); #endif do { - spin_lock_irqsave(&ensoniq->reg_lock, flags); if (!(inl(ES_REG(ensoniq, STATUS)) & ES_1370_CSTAT)) { outw(ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); return; } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); -#if 0 - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); -#endif + schedule_timeout_uninterruptible(1); } while (time_after(end_time, jiffies)); - snd_printk("codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS))); + snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n", + inl(ES_REG(ensoniq, STATUS))); } #endif /* CHIP1370 */ #ifdef CHIP1371 -static void snd_es1371_codec_write(ac97_t *ac97, +static void snd_es1371_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, ac97->private_data, return); - unsigned long flags; + struct ensoniq *ensoniq = ac97->private_data; unsigned int t, x; + mutex_lock(&ensoniq->src_mutex); for (t = 0; t < POLL_COUNT; t++) { - spin_lock_irqsave(&ensoniq->reg_lock, flags); if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { /* save the current state for latter */ x = snd_es1371_wait_src_ready(ensoniq); @@ -625,36 +622,38 @@ static void snd_es1371_codec_write(ac97_t *ac97, /* wait for not busy (state 0) first to avoid transition states */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00000000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00000000) break; } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00010000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00010000) break; } outl(ES_1371_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1371_CODEC)); /* restore SRC reg */ snd_es1371_wait_src_ready(ensoniq); outl(x, ES_REG(ensoniq, 1371_SMPRATE)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + mutex_unlock(&ensoniq->src_mutex); return; } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } - snd_printk("codec write timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); + mutex_unlock(&ensoniq->src_mutex); + snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); } -static unsigned short snd_es1371_codec_read(ac97_t *ac97, +static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, ac97->private_data, return -ENXIO); - unsigned long flags; + struct ensoniq *ensoniq = ac97->private_data; unsigned int t, x, fail = 0; __again: + mutex_lock(&ensoniq->src_mutex); for (t = 0; t < POLL_COUNT; t++) { - spin_lock_irqsave(&ensoniq->reg_lock, flags); if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { /* save the current state for latter */ x = snd_es1371_wait_src_ready(ensoniq); @@ -664,12 +663,14 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, /* wait for not busy (state 0) first to avoid transition states */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00000000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00000000) break; } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00010000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00010000) break; } outl(ES_1371_CODEC_READS(reg), ES_REG(ensoniq, 1371_CODEC)); @@ -684,27 +685,41 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, /* now wait for the stinkin' data (RDY) */ for (t = 0; t < POLL_COUNT; t++) { if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + mutex_unlock(&ensoniq->src_mutex); return ES_1371_CODEC_READ(x); } } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + mutex_unlock(&ensoniq->src_mutex); if (++fail > 10) { - snd_printk("codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), reg, inl(ES_REG(ensoniq, 1371_CODEC))); + snd_printk(KERN_ERR "codec read timeout (final) " + "at 0x%lx, reg = 0x%x [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), reg, + inl(ES_REG(ensoniq, 1371_CODEC))); return 0; } goto __again; } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } - snd_printk("es1371: codec read timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); + mutex_unlock(&ensoniq->src_mutex); + snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); return 0; } -static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_codec_wait(struct snd_ac97 *ac97) +{ + msleep(750); + snd_es1371_codec_read(ac97, AC97_RESET); + snd_es1371_codec_read(ac97, AC97_VENDOR_ID1); + snd_es1371_codec_read(ac97, AC97_VENDOR_ID2); + msleep(50); +} + +static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int n, truncm, freq, result; + mutex_lock(&ensoniq->src_mutex); n = rate / 3000; if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9))) n--; @@ -723,55 +738,70 @@ static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate) 0x8000 | (((119 - truncm) >> 1) << 9) | (n << 4)); } snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_ADC + ES_SMPREG_INT_REGS) & 0x00ff) | - ((freq >> 5) & 0xfc00)); + (snd_es1371_src_read(ensoniq, ES_SMPREG_ADC + + ES_SMPREG_INT_REGS) & 0x00ff) | + ((freq >> 5) & 0xfc00)); snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8); snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8); + mutex_unlock(&ensoniq->src_mutex); } -static void snd_es1371_dac1_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int freq, r; + mutex_lock(&ensoniq->src_mutex); freq = ((rate << 15) + 1500) / 3000; - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)) | ES_1371_DIS_P1; + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P2 | ES_1371_DIS_R1)) | + ES_1371_DIS_P1; outl(r, ES_REG(ensoniq, 1371_SMPRATE)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS) & 0x00ff) | + (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC1 + + ES_SMPREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)); + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P2 | ES_1371_DIS_R1)); outl(r, ES_REG(ensoniq, 1371_SMPRATE)); + mutex_unlock(&ensoniq->src_mutex); } -static void snd_es1371_dac2_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int freq, r; + mutex_lock(&ensoniq->src_mutex); freq = ((rate << 15) + 1500) / 3000; - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)) | ES_1371_DIS_P2; + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P1 | ES_1371_DIS_R1)) | + ES_1371_DIS_P2; outl(r, ES_REG(ensoniq, 1371_SMPRATE)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS) & 0x00ff) | + (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC2 + + ES_SMPREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, + freq & 0x7fff); + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P1 | ES_1371_DIS_R1)); outl(r, ES_REG(ensoniq, 1371_SMPRATE)); + mutex_unlock(&ensoniq->src_mutex); } #endif /* CHIP1371 */ -static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: { 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 == ensoniq->playback1_substream) { @@ -797,7 +827,7 @@ static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) { 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 == ensoniq->playback1_substream) { @@ -830,22 +860,21 @@ static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) * PCM part */ -static int snd_ensoniq_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ensoniq_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_ensoniq_hw_free(snd_pcm_substream_t * substream) +static int snd_ensoniq_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->p1_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -854,8 +883,15 @@ static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) mode |= 0x02; if (runtime->channels > 1) mode |= 0x01; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ensoniq->ctrl &= ~ES_DAC1_EN; +#ifdef CHIP1371 + /* 48k doesn't need SRC (it breaks AC3-passthru) */ + if (runtime->rate == 48000) + ensoniq->ctrl |= ES_1373_BYPASS_P1; + else + ensoniq->ctrl &= ~ES_1373_BYPASS_P1; +#endif outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); outl(runtime->dma_addr, ES_REG(ensoniq, DAC1_FRAME)); @@ -863,7 +899,8 @@ static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl &= ~(ES_P1_LOOP_SEL | ES_P1_PAUSE | ES_P1_SCT_RLD | ES_P1_MODEM); ensoniq->sctrl |= ES_P1_INT_EN | ES_P1_MODEO(mode); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->p1_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, DAC1_COUNT)); + outl((ensoniq->p1_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, DAC1_COUNT)); #ifdef CHIP1370 ensoniq->ctrl &= ~ES_1370_WTSRSELM; switch (runtime->rate) { @@ -873,19 +910,19 @@ static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) case 44100: ensoniq->ctrl |= ES_1370_WTSRSEL(3); break; default: snd_BUG(); } -#else - snd_es1371_dac1_rate(ensoniq, runtime->rate); #endif outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); +#ifndef CHIP1370 + snd_es1371_dac1_rate(ensoniq, runtime->rate); +#endif return 0; } -static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_prepare(struct snd_pcm_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->p2_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -894,7 +931,7 @@ static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) mode |= 0x02; if (runtime->channels > 1) mode |= 0x01; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ensoniq->ctrl &= ~ES_DAC2_EN; outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); @@ -905,26 +942,27 @@ static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl |= ES_P2_INT_EN | ES_P2_MODEO(mode) | ES_P2_END_INCO(mode & 2 ? 2 : 1) | ES_P2_ST_INCO(0); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->p2_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, DAC2_COUNT)); + outl((ensoniq->p2_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, DAC2_COUNT)); #ifdef CHIP1370 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_CAPTURE)) { ensoniq->ctrl &= ~ES_1370_PCLKDIVM; ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate)); ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_PLAY2; } -#else - snd_es1371_dac2_rate(ensoniq, runtime->rate); #endif outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); +#ifndef CHIP1370 + snd_es1371_dac2_rate(ensoniq, runtime->rate); +#endif return 0; } -static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_prepare(struct snd_pcm_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->c_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -933,7 +971,7 @@ static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) mode |= 0x02; if (runtime->channels > 1) mode |= 0x01; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ensoniq->ctrl &= ~ES_ADC_EN; outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); @@ -942,24 +980,26 @@ static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl &= ~(ES_R1_LOOP_SEL | ES_R1_MODEM); ensoniq->sctrl |= ES_R1_INT_EN | ES_R1_MODEO(mode); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->c_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, ADC_COUNT)); + outl((ensoniq->c_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, ADC_COUNT)); #ifdef CHIP1370 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_PLAY2)) { ensoniq->ctrl &= ~ES_1370_PCLKDIVM; ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate)); ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_CAPTURE; } -#else - snd_es1371_adc_rate(ensoniq, runtime->rate); #endif outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); +#ifndef CHIP1370 + snd_es1371_adc_rate(ensoniq, runtime->rate); +#endif return 0; } -static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -974,9 +1014,9 @@ static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(snd_pcm_substream_t * sub return ptr; } -static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -991,9 +1031,9 @@ static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(snd_pcm_substream_t * sub return ptr; } -static snd_pcm_uframes_t snd_ensoniq_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_capture_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -1008,7 +1048,7 @@ static snd_pcm_uframes_t snd_ensoniq_capture_pointer(snd_pcm_substream_t * subst return ptr; } -static snd_pcm_hardware_t snd_ensoniq_playback1 = +static struct snd_pcm_hardware snd_ensoniq_playback1 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1035,7 +1075,7 @@ static snd_pcm_hardware_t snd_ensoniq_playback1 = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ensoniq_playback2 = +static struct snd_pcm_hardware snd_ensoniq_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1055,7 +1095,7 @@ static snd_pcm_hardware_t snd_ensoniq_playback2 = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ensoniq_capture = +static struct snd_pcm_hardware snd_ensoniq_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1074,10 +1114,10 @@ static snd_pcm_hardware_t snd_ensoniq_capture = .fifo_size = 0, }; -static int snd_ensoniq_playback1_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_PLAY1; ensoniq->playback1_substream = substream; @@ -1097,10 +1137,10 @@ static int snd_ensoniq_playback1_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_playback2_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_PLAY2; ensoniq->playback2_substream = substream; @@ -1120,10 +1160,10 @@ static int snd_ensoniq_playback2_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_capture_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_CAPTURE; ensoniq->capture_substream = substream; @@ -1139,46 +1179,44 @@ static int snd_ensoniq_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_playback1_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_close(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->playback1_substream = NULL; ensoniq->mode &= ~ES_MODE_PLAY1; return 0; } -static int snd_ensoniq_playback2_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_close(struct snd_pcm_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->playback2_substream = NULL; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); #ifdef CHIP1370 ensoniq->u.es1370.pclkdiv_lock &= ~ES_MODE_PLAY2; #endif ensoniq->mode &= ~ES_MODE_PLAY2; - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_ensoniq_capture_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_close(struct snd_pcm_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->capture_substream = NULL; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); #ifdef CHIP1370 ensoniq->u.es1370.pclkdiv_lock &= ~ES_MODE_CAPTURE; #endif ensoniq->mode &= ~ES_MODE_CAPTURE; - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static snd_pcm_ops_t snd_ensoniq_playback1_ops = { +static struct snd_pcm_ops snd_ensoniq_playback1_ops = { .open = snd_ensoniq_playback1_open, .close = snd_ensoniq_playback1_close, .ioctl = snd_pcm_lib_ioctl, @@ -1189,7 +1227,7 @@ static snd_pcm_ops_t snd_ensoniq_playback1_ops = { .pointer = snd_ensoniq_playback1_pointer, }; -static snd_pcm_ops_t snd_ensoniq_playback2_ops = { +static struct snd_pcm_ops snd_ensoniq_playback2_ops = { .open = snd_ensoniq_playback2_open, .close = snd_ensoniq_playback2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1200,7 +1238,7 @@ static snd_pcm_ops_t snd_ensoniq_playback2_ops = { .pointer = snd_ensoniq_playback2_pointer, }; -static snd_pcm_ops_t snd_ensoniq_capture_ops = { +static struct snd_pcm_ops snd_ensoniq_capture_ops = { .open = snd_ensoniq_capture_open, .close = snd_ensoniq_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1211,16 +1249,10 @@ static snd_pcm_ops_t snd_ensoniq_capture_ops = { .pointer = snd_ensoniq_capture_pointer, }; -static void snd_ensoniq_pcm_free(snd_pcm_t *pcm) +static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, + struct snd_pcm ** rpcm) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, pcm->private_data, return); - ensoniq->pcm1 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) -{ - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1241,7 +1273,6 @@ static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ensoniq_capture_ops); pcm->private_data = ensoniq; - pcm->private_free = snd_ensoniq_pcm_free; pcm->info_flags = 0; #ifdef CHIP1370 strcpy(pcm->name, "ES1370 DAC2/ADC"); @@ -1258,16 +1289,10 @@ static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t return 0; } -static void snd_ensoniq_pcm_free2(snd_pcm_t *pcm) -{ - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, pcm->private_data, return); - ensoniq->pcm2 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ensoniq_pcm2(struct ensoniq * ensoniq, int device, + struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1286,7 +1311,6 @@ static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ensoniq_playback2_ops); #endif pcm->private_data = ensoniq; - pcm->private_free = snd_ensoniq_pcm_free2; pcm->info_flags = 0; #ifdef CHIP1370 strcpy(pcm->name, "ES1370 DAC1"); @@ -1311,17 +1335,18 @@ static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t * ENS1371 mixer (including SPDIF interface) */ #ifdef CHIP1371 -static int snd_ens1373_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ens1373_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ens1373_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.iec958.status[0] = (ensoniq->spdif_default >> 0) & 0xff; ucontrol->value.iec958.status[1] = (ensoniq->spdif_default >> 8) & 0xff; @@ -1331,10 +1356,10 @@ static int snd_ens1373_spdif_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1345,14 +1370,15 @@ static int snd_ens1373_spdif_default_put(snd_kcontrol_t * kcontrol, spin_lock_irq(&ensoniq->reg_lock); change = ensoniq->spdif_default != val; ensoniq->spdif_default = val; - if (change && ensoniq->playback1_substream == NULL && ensoniq->playback2_substream == NULL) + if (change && ensoniq->playback1_substream == NULL && + ensoniq->playback2_substream == NULL) outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); spin_unlock_irq(&ensoniq->reg_lock); return change; } -static int snd_ens1373_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -1361,10 +1387,10 @@ static int snd_ens1373_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.iec958.status[0] = (ensoniq->spdif_stream >> 0) & 0xff; ucontrol->value.iec958.status[1] = (ensoniq->spdif_stream >> 8) & 0xff; @@ -1374,10 +1400,10 @@ static int snd_ens1373_spdif_stream_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1388,7 +1414,8 @@ static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, spin_lock_irq(&ensoniq->reg_lock); change = ensoniq->spdif_stream != val; ensoniq->spdif_stream = val; - if (change && (ensoniq->playback1_substream != NULL || ensoniq->playback2_substream != NULL)) + if (change && (ensoniq->playback1_substream != NULL || + ensoniq->playback2_substream != NULL)) outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); spin_unlock_irq(&ensoniq->reg_lock); return change; @@ -1398,7 +1425,8 @@ static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_es1371_spdif_info, \ .get = snd_es1371_spdif_get, .put = snd_es1371_spdif_put } -static int snd_es1371_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1371_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1407,9 +1435,10 @@ static int snd_es1371_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_es1371_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1371_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.integer.value[0] = ensoniq->ctrl & ES_1373_SPDIF_THRU ? 1 : 0; @@ -1417,9 +1446,10 @@ static int snd_es1371_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1371_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1371_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int nval1, nval2; int change; @@ -1439,8 +1469,8 @@ static int snd_es1371_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* spdif controls */ -static snd_kcontrol_new_t snd_es1371_mixer_spdif[] __devinitdata = { - ES1371_SPDIF("IEC958 Playback Switch"), +static struct snd_kcontrol_new snd_es1371_mixer_spdif[] __devinitdata = { + ES1371_SPDIF(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH)), { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1465,7 +1495,8 @@ static snd_kcontrol_new_t snd_es1371_mixer_spdif[] __devinitdata = { }; -static int snd_es1373_rear_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1373_rear_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1474,28 +1505,33 @@ static int snd_es1373_rear_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int snd_es1373_rear_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_rear_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int val = 0; spin_lock_irq(&ensoniq->reg_lock); - if ((ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) == ES_1373_REAR_BIT26) + if ((ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26| + ES_1373_REAR_BIT24)) == ES_1373_REAR_BIT26) val = 1; ucontrol->value.integer.value[0] = val; spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_es1373_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_rear_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int nval1; int change; - nval1 = ucontrol->value.integer.value[0] ? ES_1373_REAR_BIT26 : (ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); + nval1 = ucontrol->value.integer.value[0] ? + ES_1373_REAR_BIT26 : (ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); spin_lock_irq(&ensoniq->reg_lock); - change = (ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) != nval1; + change = (ensoniq->cssr & (ES_1373_REAR_BIT27| + ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) != nval1; ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24); ensoniq->cssr |= nval1; outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); @@ -1503,7 +1539,7 @@ static int snd_es1373_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t snd_ens1373_rear __devinitdata = +static struct snd_kcontrol_new snd_ens1373_rear __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 2ch->4ch Copy Switch", @@ -1512,7 +1548,8 @@ static snd_kcontrol_new_t snd_ens1373_rear __devinitdata = .put = snd_es1373_rear_put, }; -static int snd_es1373_line_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1373_line_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1521,9 +1558,10 @@ static int snd_es1373_line_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int snd_es1373_line_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_line_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int val = 0; spin_lock_irq(&ensoniq->reg_lock); @@ -1534,9 +1572,10 @@ static int snd_es1373_line_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_es1373_line_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_line_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int changed; unsigned int ctrl; @@ -1553,7 +1592,7 @@ static int snd_es1373_line_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return changed; } -static snd_kcontrol_new_t snd_ens1373_line __devinitdata = +static struct snd_kcontrol_new snd_ens1373_line __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line In->Rear Out Switch", @@ -1562,9 +1601,9 @@ static snd_kcontrol_new_t snd_ens1373_line __devinitdata = .put = snd_es1373_line_put, }; -static void snd_ensoniq_mixer_free_ac97(ac97_t *ac97) +static void snd_ensoniq_mixer_free_ac97(struct snd_ac97 *ac97) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, ac97->private_data, return); + struct ensoniq *ensoniq = ac97->private_data; ensoniq->u.es1371.ac97 = NULL; } @@ -1581,17 +1620,19 @@ static struct { { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } }; -static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) +static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int has_line) { - snd_card_t *card = ensoniq->card; - ac97_bus_t bus, *pbus; - ac97_t ac97; + struct snd_card *card = ensoniq->card; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err, idx; + static struct snd_ac97_bus_ops ops = { + .write = snd_es1371_codec_write, + .read = snd_es1371_codec_read, + .wait = snd_es1371_codec_wait, + }; - memset(&bus, 0, sizeof(bus)); - bus.write = snd_es1371_codec_write; - bus.read = snd_es1371_codec_read; - if ((err = snd_ac97_bus(card, &bus, &pbus)) < 0) + if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0) return err; memset(&ac97, 0, sizeof(ac97)); @@ -1601,13 +1642,17 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0) return err; for (idx = 0; es1371_spdif_present[idx].vid != (unsigned short)PCI_ANY_ID; idx++) - if (ensoniq->pci->vendor == es1371_spdif_present[idx].vid && - ensoniq->pci->device == es1371_spdif_present[idx].did && - ensoniq->rev == es1371_spdif_present[idx].rev) { - snd_kcontrol_t *kctl; + if ((ensoniq->pci->vendor == es1371_spdif_present[idx].vid && + ensoniq->pci->device == es1371_spdif_present[idx].did && + ensoniq->rev == es1371_spdif_present[idx].rev) || has_spdif > 0) { + struct snd_kcontrol *kctl; int i, index = 0; - ensoniq->spdif_default = ensoniq->spdif_stream = SNDRV_PCM_DEFAULT_CON_SPDIF; + if (has_spdif < 0) + break; + + ensoniq->spdif_default = ensoniq->spdif_stream = + SNDRV_PCM_DEFAULT_CON_SPDIF; outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) @@ -1631,8 +1676,11 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) if (err < 0) return err; } - if ((ensoniq->subsystem_vendor_id == 0x1274) && - (ensoniq->subsystem_device_id == 0x2000)) { /* GA-7DXR */ + if (((ensoniq->subsystem_vendor_id == 0x1274) && + (ensoniq->subsystem_device_id == 0x2000)) || /* GA-7DXR */ + ((ensoniq->subsystem_vendor_id == 0x1458) && + (ensoniq->subsystem_device_id == 0xa000)) || /* GA-8IEXP */ + has_line > 0) { err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line, ensoniq)); if (err < 0) return err; @@ -1650,7 +1698,8 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) .get = snd_ensoniq_control_get, .put = snd_ensoniq_control_put, \ .private_value = mask } -static int snd_ensoniq_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ensoniq_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1659,33 +1708,33 @@ static int snd_ensoniq_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_ensoniq_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ensoniq_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); - unsigned long flags; + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int mask = kcontrol->private_value; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.integer.value[0] = ensoniq->ctrl & mask ? 1 : 0; - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_ensoniq_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ensoniq_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); - unsigned long flags; + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int mask = kcontrol->private_value; unsigned int nval; int change; nval = ucontrol->value.integer.value[0] ? mask : 0; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); change = (ensoniq->ctrl & mask) != nval; ensoniq->ctrl &= ~mask; ensoniq->ctrl |= nval; outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return change; } @@ -1693,23 +1742,23 @@ static int snd_ensoniq_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * ENS1370 mixer */ -static snd_kcontrol_new_t snd_es1370_controls[2] __devinitdata = { +static struct snd_kcontrol_new snd_es1370_controls[2] __devinitdata = { ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0), ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1) }; #define ES1370_CONTROLS ARRAY_SIZE(snd_es1370_controls) -static void snd_ensoniq_mixer_free_ak4531(ak4531_t *ak4531) +static void snd_ensoniq_mixer_free_ak4531(struct snd_ak4531 *ak4531) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, ak4531->private_data, return); + struct ensoniq *ensoniq = ak4531->private_data; ensoniq->u.es1370.ak4531 = NULL; } -static int __devinit snd_ensoniq_1370_mixer(ensoniq_t * ensoniq) +static int __devinit snd_ensoniq_1370_mixer(struct ensoniq * ensoniq) { - snd_card_t *card = ensoniq->card; - ak4531_t ak4531; + struct snd_card *card = ensoniq->card; + struct snd_ak4531 ak4531; unsigned int idx; int err; @@ -1738,71 +1787,132 @@ static int __devinit snd_ensoniq_1370_mixer(ensoniq_t * ensoniq) #endif /* CHIP1370 */ #ifdef SUPPORT_JOYSTICK -static int snd_ensoniq_joystick(ensoniq_t *ensoniq, long port) -{ + #ifdef CHIP1371 - if (port == 1) { /* auto-detect */ - for (port = 0x200; port <= 0x218; port += 8) - if (request_region(port, 8, "ens137x: gameport")) +static int __devinit snd_ensoniq_get_joystick_port(int dev) +{ + switch (joystick_port[dev]) { + case 0: /* disabled */ + case 1: /* auto-detect */ + case 0x200: + case 0x208: + case 0x210: + case 0x218: + return joystick_port[dev]; + + default: + printk(KERN_ERR "ens1371: invalid joystick port %#x", joystick_port[dev]); + return 0; + } +} +#else +static inline int snd_ensoniq_get_joystick_port(int dev) +{ + return joystick[dev] ? 0x200 : 0; +} +#endif + +static int __devinit snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev) +{ + struct gameport *gp; + int io_port; + + io_port = snd_ensoniq_get_joystick_port(dev); + + switch (io_port) { + case 0: + return -ENOSYS; + + case 1: /* auto_detect */ + for (io_port = 0x200; io_port <= 0x218; io_port += 8) + if (request_region(io_port, 8, "ens137x: gameport")) break; - if (port > 0x218) { - snd_printk("no gameport available\n"); + if (io_port > 0x218) { + printk(KERN_WARNING "ens137x: no gameport ports available\n"); return -EBUSY; } - } else -#endif - { - if (!request_region(port, 8, "ens137x: gameport")) { - snd_printk("gameport io port 0x%03x in use", ensoniq->gameport.io); + break; + + default: + if (!request_region(io_port, 8, "ens137x: gameport")) { + printk(KERN_WARNING "ens137x: gameport io port 0x%#x in use\n", + io_port); return -EBUSY; } + break; } - ensoniq->gameport.io = port; + + ensoniq->gameport = gp = gameport_allocate_port(); + if (!gp) { + printk(KERN_ERR "ens137x: cannot allocate memory for gameport\n"); + release_region(io_port, 8); + return -ENOMEM; + } + + gameport_set_name(gp, "ES137x"); + gameport_set_phys(gp, "pci%s/gameport0", pci_name(ensoniq->pci)); + gameport_set_dev_parent(gp, &ensoniq->pci->dev); + gp->io = io_port; + ensoniq->ctrl |= ES_JYSTK_EN; #ifdef CHIP1371 ensoniq->ctrl &= ~ES_1371_JOY_ASELM; - ensoniq->ctrl |= ES_1371_JOY_ASEL((ensoniq->gameport.io - 0x200) / 8); + ensoniq->ctrl |= ES_1371_JOY_ASEL((io_port - 0x200) / 8); #endif outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - gameport_register_port(&ensoniq->gameport); + + gameport_register_port(ensoniq->gameport); + return 0; } -static void snd_ensoniq_joystick_free(ensoniq_t *ensoniq) +static void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { - gameport_unregister_port(&ensoniq->gameport); - ensoniq->ctrl &= ~ES_JYSTK_EN; - outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - release_region(ensoniq->gameport.io, 8); + if (ensoniq->gameport) { + int port = ensoniq->gameport->io; + + gameport_unregister_port(ensoniq->gameport); + ensoniq->gameport = NULL; + ensoniq->ctrl &= ~ES_JYSTK_EN; + outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); + release_region(port, 8); + } } +#else +static inline int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, long port) { return -ENOSYS; } +static inline void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { } #endif /* SUPPORT_JOYSTICK */ /* */ -static void snd_ensoniq_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ensoniq_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, entry->private_data, return); + struct ensoniq *ensoniq = entry->private_data; #ifdef CHIP1370 snd_iprintf(buffer, "Ensoniq AudioPCI ES1370\n\n"); #else snd_iprintf(buffer, "Ensoniq AudioPCI ES1371\n\n"); #endif - snd_iprintf(buffer, "Joystick enable : %s\n", ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); + snd_iprintf(buffer, "Joystick enable : %s\n", + ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); #ifdef CHIP1370 - snd_iprintf(buffer, "MIC +5V bias : %s\n", ensoniq->ctrl & ES_1370_XCTL1 ? "on" : "off"); - snd_iprintf(buffer, "Line In to AOUT : %s\n", ensoniq->ctrl & ES_1370_XCTL0 ? "on" : "off"); + snd_iprintf(buffer, "MIC +5V bias : %s\n", + ensoniq->ctrl & ES_1370_XCTL1 ? "on" : "off"); + snd_iprintf(buffer, "Line In to AOUT : %s\n", + ensoniq->ctrl & ES_1370_XCTL0 ? "on" : "off"); #else - snd_iprintf(buffer, "Joystick port : 0x%x\n", (ES_1371_JOY_ASELI(ensoniq->ctrl) * 8) + 0x200); + snd_iprintf(buffer, "Joystick port : 0x%x\n", + (ES_1371_JOY_ASELI(ensoniq->ctrl) * 8) + 0x200); #endif } -static void __devinit snd_ensoniq_proc_init(ensoniq_t * ensoniq) +static void __devinit snd_ensoniq_proc_init(struct ensoniq * ensoniq) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry)) snd_info_set_text_ops(entry, ensoniq, 1024, snd_ensoniq_proc_read); @@ -1812,12 +1922,9 @@ static void __devinit snd_ensoniq_proc_init(ensoniq_t * ensoniq) */ -static int snd_ensoniq_free(ensoniq_t *ensoniq) +static int snd_ensoniq_free(struct ensoniq *ensoniq) { -#ifdef SUPPORT_JOYSTICK - if (ensoniq->ctrl & ES_JYSTK_EN) - snd_ensoniq_joystick_free(ensoniq); -#endif + snd_ensoniq_free_gameport(ensoniq); if (ensoniq->irq < 0) goto __hw_end; #ifdef CHIP1370 @@ -1832,21 +1939,19 @@ static int snd_ensoniq_free(ensoniq_t *ensoniq) __hw_end: #ifdef CHIP1370 if (ensoniq->dma_bug.area) - snd_dma_free_pages(&ensoniq->dma_dev, &ensoniq->dma_bug); + snd_dma_free_pages(&ensoniq->dma_bug); #endif - if (ensoniq->res_port) { - release_resource(ensoniq->res_port); - kfree_nocheck(ensoniq->res_port); - } if (ensoniq->irq >= 0) - free_irq(ensoniq->irq, (void *)ensoniq); - snd_magic_kfree(ensoniq); + free_irq(ensoniq->irq, ensoniq); + pci_release_regions(ensoniq->pci); + pci_disable_device(ensoniq->pci); + kfree(ensoniq); return 0; } -static int snd_ensoniq_dev_free(snd_device_t *device) +static int snd_ensoniq_dev_free(struct snd_device *device) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, device->device_data, return -ENXIO); + struct ensoniq *ensoniq = device->device_data; return snd_ensoniq_free(ensoniq); } @@ -1875,85 +1980,22 @@ static struct { }; #endif -static int __devinit snd_ensoniq_create(snd_card_t * card, - struct pci_dev *pci, - ensoniq_t ** rensoniq) +static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) { - ensoniq_t *ensoniq; - unsigned short cmdw; - unsigned char cmdb; #ifdef CHIP1371 int idx; + struct pci_dev *pci = ensoniq->pci; #endif - int err; - static snd_device_ops_t ops = { - .dev_free = snd_ensoniq_dev_free, - }; - - *rensoniq = NULL; - if ((err = pci_enable_device(pci)) < 0) - return err; - ensoniq = snd_magic_kcalloc(ensoniq_t, 0, GFP_KERNEL); - if (ensoniq == NULL) - return -ENOMEM; - spin_lock_init(&ensoniq->reg_lock); - ensoniq->card = card; - ensoniq->pci = pci; - ensoniq->irq = -1; - ensoniq->port = pci_resource_start(pci, 0); - if ((ensoniq->res_port = request_region(ensoniq->port, 0x40, "Ensoniq AudioPCI")) == NULL) { - snd_printk("unable to grab ports 0x%lx-0x%lx\n", ensoniq->port, ensoniq->port + 0x40 - 1); - snd_ensoniq_free(ensoniq); - return -EBUSY; - } - if (request_irq(pci->irq, snd_audiopci_interrupt, SA_INTERRUPT|SA_SHIRQ, "Ensoniq AudioPCI", (void *)ensoniq)) { - snd_printk("unable to grab IRQ %d\n", pci->irq); - snd_ensoniq_free(ensoniq); - return -EBUSY; - } - ensoniq->irq = pci->irq; -#ifdef CHIP1370 - memset(&ensoniq->dma_dev, 0, sizeof(ensoniq->dma_dev)); - ensoniq->dma_dev.type = SNDRV_DMA_TYPE_DEV; - ensoniq->dma_dev.dev = snd_dma_pci_data(pci); - if (snd_dma_alloc_pages(&ensoniq->dma_dev, 16, &ensoniq->dma_bug) < 0) { - snd_printk("unable to allocate space for phantom area - dma_bug\n"); - snd_ensoniq_free(ensoniq); - return -EBUSY; - } -#endif - pci_set_master(pci); - pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb); - ensoniq->rev = cmdb; - pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &cmdw); - ensoniq->subsystem_vendor_id = cmdw; - pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw); - ensoniq->subsystem_device_id = cmdw; - snd_ensoniq_proc_init(ensoniq); + /* this code was part of snd_ensoniq_create before intruduction + * of suspend/resume + */ #ifdef CHIP1370 -#if 0 - ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); -#else /* get microphone working */ - ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); -#endif - ensoniq->sctrl = 0; - /* initialize the chips */ outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); outl(ensoniq->dma_bug.addr, ES_REG(ensoniq, PHANTOM_FRAME)); outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); #else - ensoniq->ctrl = 0; - ensoniq->sctrl = 0; - ensoniq->cssr = 0; - for (idx = 0; es1371_amplifier_hack[idx].svid != (unsigned short)PCI_ANY_ID; idx++) - if (ensoniq->subsystem_vendor_id == es1371_amplifier_hack[idx].svid && - ensoniq->subsystem_device_id == es1371_amplifier_hack[idx].sdid) { - ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ - break; - } - /* initialize the chips */ outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); outl(0, ES_REG(ensoniq, 1371_LEGACY)); @@ -1961,21 +2003,10 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, if (pci->vendor == es1371_ac97_reset_hack[idx].vid && pci->device == es1371_ac97_reset_hack[idx].did && ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { - unsigned long tmo; - signed long tmo2; - - ensoniq->cssr |= ES_1371_ST_AC97_RST; outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); /* need to delay around 20ms(bleech) to give some CODECs enough time to wakeup */ - tmo = jiffies + (HZ / 50) + 1; - while (1) { - tmo2 = tmo - jiffies; - if (tmo2 <= 0) - break; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(tmo2); - } + msleep(20); break; } /* AC'97 warm reset to start the bitclk */ @@ -2016,12 +2047,152 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, outb(0x00, ES_REG(ensoniq, UART_RES)); outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); synchronize_irq(ensoniq->irq); +} + +#ifdef CONFIG_PM +static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct ensoniq *ensoniq = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + snd_pcm_suspend_all(ensoniq->pcm1); + snd_pcm_suspend_all(ensoniq->pcm2); + +#ifdef CHIP1371 + snd_ac97_suspend(ensoniq->u.es1371.ac97); +#else + /* try to reset AK4531 */ + outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x02), ES_REG(ensoniq, 1370_CODEC)); + inw(ES_REG(ensoniq, 1370_CODEC)); + udelay(100); + outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x03), ES_REG(ensoniq, 1370_CODEC)); + inw(ES_REG(ensoniq, 1370_CODEC)); + udelay(100); + snd_ak4531_suspend(ensoniq->u.es1370.ak4531); +#endif + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +static int snd_ensoniq_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct ensoniq *ensoniq = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + snd_ensoniq_chip_init(ensoniq); + +#ifdef CHIP1371 + snd_ac97_resume(ensoniq->u.es1371.ac97); +#else + snd_ak4531_resume(ensoniq->u.es1370.ak4531); +#endif + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif /* CONFIG_PM */ + + +static int __devinit snd_ensoniq_create(struct snd_card *card, + struct pci_dev *pci, + struct ensoniq ** rensoniq) +{ + struct ensoniq *ensoniq; + unsigned short cmdw; + unsigned char cmdb; +#ifdef CHIP1371 + int idx; +#endif + int err; + static struct snd_device_ops ops = { + .dev_free = snd_ensoniq_dev_free, + }; + + *rensoniq = NULL; + if ((err = pci_enable_device(pci)) < 0) + return err; + ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL); + if (ensoniq == NULL) { + pci_disable_device(pci); + return -ENOMEM; + } + spin_lock_init(&ensoniq->reg_lock); + mutex_init(&ensoniq->src_mutex); + ensoniq->card = card; + ensoniq->pci = pci; + ensoniq->irq = -1; + if ((err = pci_request_regions(pci, "Ensoniq AudioPCI")) < 0) { + kfree(ensoniq); + pci_disable_device(pci); + return err; + } + ensoniq->port = pci_resource_start(pci, 0); + if (request_irq(pci->irq, snd_audiopci_interrupt, SA_INTERRUPT|SA_SHIRQ, + "Ensoniq AudioPCI", ensoniq)) { + snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + snd_ensoniq_free(ensoniq); + return -EBUSY; + } + ensoniq->irq = pci->irq; +#ifdef CHIP1370 + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), + 16, &ensoniq->dma_bug) < 0) { + snd_printk(KERN_ERR "unable to allocate space for phantom area - dma_bug\n"); + snd_ensoniq_free(ensoniq); + return -EBUSY; + } +#endif + pci_set_master(pci); + pci_read_config_byte(pci, PCI_REVISION_ID, &cmdb); + ensoniq->rev = cmdb; + pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &cmdw); + ensoniq->subsystem_vendor_id = cmdw; + pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &cmdw); + ensoniq->subsystem_device_id = cmdw; +#ifdef CHIP1370 +#if 0 + ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | + ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); +#else /* get microphone working */ + ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); +#endif + ensoniq->sctrl = 0; +#else + ensoniq->ctrl = 0; + ensoniq->sctrl = 0; + ensoniq->cssr = 0; + for (idx = 0; es1371_amplifier_hack[idx].svid != (unsigned short)PCI_ANY_ID; idx++) + if (ensoniq->subsystem_vendor_id == es1371_amplifier_hack[idx].svid && + ensoniq->subsystem_device_id == es1371_amplifier_hack[idx].sdid) { + ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ + break; + } + for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++) + if (pci->vendor == es1371_ac97_reset_hack[idx].vid && + pci->device == es1371_ac97_reset_hack[idx].did && + ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { + ensoniq->cssr |= ES_1371_ST_AC97_RST; + break; + } +#endif + + snd_ensoniq_chip_init(ensoniq); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops)) < 0) { snd_ensoniq_free(ensoniq); return err; } + snd_ensoniq_proc_init(ensoniq); + snd_card_set_dev(card, &pci->dev); *rensoniq = ensoniq; @@ -2032,9 +2203,9 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, * MIDI section */ -static void snd_ensoniq_midi_interrupt(ensoniq_t * ensoniq) +static void snd_ensoniq_midi_interrupt(struct ensoniq * ensoniq) { - snd_rawmidi_t * rmidi = ensoniq->rmidi; + struct snd_rawmidi *rmidi = ensoniq->rmidi; unsigned char status, mask, byte; if (rmidi == NULL) @@ -2047,9 +2218,7 @@ static void snd_ensoniq_midi_interrupt(ensoniq_t * ensoniq) if ((status & mask) == 0) break; byte = inb(ES_REG(ensoniq, UART_DATA)); - spin_unlock(&ensoniq->reg_lock); snd_rawmidi_receive(ensoniq->midi_input, &byte, 1); - spin_lock(&ensoniq->reg_lock); } spin_unlock(&ensoniq->reg_lock); @@ -2071,12 +2240,11 @@ static void snd_ensoniq_midi_interrupt(ensoniq_t * ensoniq) spin_unlock(&ensoniq->reg_lock); } -static int snd_ensoniq_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_input_open(struct snd_rawmidi_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return -ENXIO); + struct ensoniq *ensoniq = substream->rmidi->private_data; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ensoniq->uartm |= ES_MODE_INPUT; ensoniq->midi_input = substream; if (!(ensoniq->uartm & ES_MODE_OUTPUT)) { @@ -2084,16 +2252,15 @@ static int snd_ensoniq_midi_input_open(snd_rawmidi_substream_t * substream) outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); outl(ensoniq->ctrl |= ES_UART_EN, ES_REG(ensoniq, CONTROL)); } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_ensoniq_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_input_close(struct snd_rawmidi_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return -ENXIO); + struct ensoniq *ensoniq = substream->rmidi->private_data; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); if (!(ensoniq->uartm & ES_MODE_OUTPUT)) { outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); outl(ensoniq->ctrl &= ~ES_UART_EN, ES_REG(ensoniq, CONTROL)); @@ -2102,16 +2269,15 @@ static int snd_ensoniq_midi_input_close(snd_rawmidi_substream_t * substream) } ensoniq->midi_input = NULL; ensoniq->uartm &= ~ES_MODE_INPUT; - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_ensoniq_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_output_open(struct snd_rawmidi_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return -ENXIO); + struct ensoniq *ensoniq = substream->rmidi->private_data; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); ensoniq->uartm |= ES_MODE_OUTPUT; ensoniq->midi_output = substream; if (!(ensoniq->uartm & ES_MODE_INPUT)) { @@ -2119,16 +2285,15 @@ static int snd_ensoniq_midi_output_open(snd_rawmidi_substream_t * substream) outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); outl(ensoniq->ctrl |= ES_UART_EN, ES_REG(ensoniq, CONTROL)); } - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_ensoniq_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_output_close(struct snd_rawmidi_substream *substream) { - unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return -ENXIO); + struct ensoniq *ensoniq = substream->rmidi->private_data; - spin_lock_irqsave(&ensoniq->reg_lock, flags); + spin_lock_irq(&ensoniq->reg_lock); if (!(ensoniq->uartm & ES_MODE_INPUT)) { outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); outl(ensoniq->ctrl &= ~ES_UART_EN, ES_REG(ensoniq, CONTROL)); @@ -2137,14 +2302,14 @@ static int snd_ensoniq_midi_output_close(snd_rawmidi_substream_t * substream) } ensoniq->midi_output = NULL; ensoniq->uartm &= ~ES_MODE_OUTPUT; - spin_unlock_irqrestore(&ensoniq->reg_lock, flags); + spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static void snd_ensoniq_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_ensoniq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return); + struct ensoniq *ensoniq = substream->rmidi->private_data; int idx; spin_lock_irqsave(&ensoniq->reg_lock, flags); @@ -2165,10 +2330,10 @@ static void snd_ensoniq_midi_input_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } -static void snd_ensoniq_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_ensoniq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, substream->rmidi->private_data, return); + struct ensoniq *ensoniq = substream->rmidi->private_data; unsigned char byte; spin_lock_irqsave(&ensoniq->reg_lock, flags); @@ -2195,23 +2360,24 @@ static void snd_ensoniq_midi_output_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } -static snd_rawmidi_ops_t snd_ensoniq_midi_output = +static struct snd_rawmidi_ops snd_ensoniq_midi_output = { .open = snd_ensoniq_midi_output_open, .close = snd_ensoniq_midi_output_close, .trigger = snd_ensoniq_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_ensoniq_midi_input = +static struct snd_rawmidi_ops snd_ensoniq_midi_input = { .open = snd_ensoniq_midi_input_open, .close = snd_ensoniq_midi_input_close, .trigger = snd_ensoniq_midi_input_trigger, }; -static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmidi_t **rrawmidi) +static int __devinit snd_ensoniq_midi(struct ensoniq * ensoniq, int device, + struct snd_rawmidi **rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) @@ -2225,7 +2391,8 @@ static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmi #endif snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_ensoniq_midi_output); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_ensoniq_midi_input); - rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; + rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | + SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = ensoniq; ensoniq->rmidi = rmidi; if (rrawmidi) @@ -2239,7 +2406,7 @@ static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmi static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ensoniq_t *ensoniq = snd_magic_cast(ensoniq_t, dev_id, return IRQ_NONE); + struct ensoniq *ensoniq = dev_id; unsigned int status, sctrl; if (ensoniq == NULL) @@ -2276,8 +2443,8 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ensoniq_t *ensoniq; + struct snd_card *card; + struct ensoniq *ensoniq; int err, pcm_devs[2]; if (dev >= SNDRV_CARDS) @@ -2295,6 +2462,7 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = ensoniq; pcm_devs[0] = 0; pcm_devs[1] = 1; #ifdef CHIP1370 @@ -2304,7 +2472,7 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, } #endif #ifdef CHIP1371 - if ((err = snd_ensoniq_1371_mixer(ensoniq)) < 0) { + if ((err = snd_ensoniq_1371_mixer(ensoniq, spdif[dev], lineio[dev])) < 0) { snd_card_free(card); return err; } @@ -2321,22 +2489,9 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, snd_card_free(card); return err; } -#ifdef SUPPORT_JOYSTICK -#ifdef CHIP1371 - switch (joystick_port[dev]) { - case 1: /* auto-detect */ - case 0x200: - case 0x208: - case 0x210: - case 0x218: - snd_ensoniq_joystick(ensoniq, joystick_port[dev]); - break; - } -#else - if (joystick[dev]) - snd_ensoniq_joystick(ensoniq, 0x200); -#endif -#endif /* SUPPORT_JOYSTICK */ + + snd_ensoniq_create_gameport(ensoniq, dev); + strcpy(card->driver, DRIVER_NAME); strcpy(card->shortname, "Ensoniq AudioPCI"); @@ -2367,19 +2522,15 @@ static struct pci_driver driver = { .id_table = snd_audiopci_ids, .probe = snd_audiopci_probe, .remove = __devexit_p(snd_audiopci_remove), +#ifdef CONFIG_PM + .suspend = snd_ensoniq_suspend, + .resume = snd_ensoniq_resume, +#endif }; static int __init alsa_card_ens137x_init(void) { - int err; - - if ((err = pci_module_init(&driver)) < 0) { -#ifdef MODULE - printk(KERN_ERR "Ensoniq AudioPCI soundcard not found or device busy\n"); -#endif - return err; - } - return 0; + return pci_register_driver(&driver); } static void __exit alsa_card_ens137x_exit(void) @@ -2389,36 +2540,3 @@ static void __exit alsa_card_ens137x_exit(void) module_init(alsa_card_ens137x_init) module_exit(alsa_card_ens137x_exit) - -#ifndef MODULE - -/* format is: snd-ens1370=enable,index,id,joystick */ - -static int __init alsa_card_ens137x_setup(char *str) -{ - static unsigned __initdata nr_dev = 0; - - if (nr_dev >= SNDRV_CARDS) - return 0; - (void)(get_option(&str,&enable[nr_dev]) == 2 && - get_option(&str,&index[nr_dev]) == 2 && - get_id(&str,&id[nr_dev]) == 2 -#ifdef SUPPORT_JOYSTICK -#ifdef CHIP1371 - && get_option(&str,&joystick_port[nr_dev]) == 2 -#else - && get_option(&str,&joystick[nr_dev]) == 2 -#endif -#endif - ); - nr_dev++; - return 1; -} - -#if defined(CHIP1370) -__setup("snd-ens1370=", alsa_card_ens137x_setup); -#elif defined(CHIP1371) -__setup("snd-ens1371=", alsa_card_ens137x_setup); -#endif - -#endif /* ifndef MODULE */