X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Femu10k1%2Femu10k1x.c;h=d51290c18167be855d80521d6a03840e129eebbd;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=27dfd8ddddf486d0c0832d72c6140d9274399814;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 27dfd8ddd..d51290c18 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -195,30 +196,26 @@ MODULE_PARM_DESC(enable, "Enable the EMU10K1X soundcard."); * playback. */ -typedef struct snd_emu10k1x_voice emu10k1x_voice_t; -typedef struct snd_emu10k1x emu10k1x_t; -typedef struct snd_emu10k1x_pcm emu10k1x_pcm_t; - -struct snd_emu10k1x_voice { - emu10k1x_t *emu; +struct emu10k1x_voice { + struct emu10k1x *emu; int number; int use; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; }; -struct snd_emu10k1x_pcm { - emu10k1x_t *emu; - snd_pcm_substream_t *substream; - emu10k1x_voice_t *voice; +struct emu10k1x_pcm { + struct emu10k1x *emu; + struct snd_pcm_substream *substream; + struct emu10k1x_voice *voice; unsigned short running; }; -typedef struct { - struct snd_emu10k1x *emu; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; +struct emu10k1x_midi { + struct emu10k1x *emu; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; unsigned int midi_mode; spinlock_t input_lock; spinlock_t output_lock; @@ -226,12 +223,12 @@ typedef struct { int tx_enable, rx_enable; int port; int ipr_tx, ipr_rx; - void (*interrupt)(emu10k1x_t *emu, unsigned int status); -} emu10k1x_midi_t; + void (*interrupt)(struct emu10k1x *emu, unsigned int status); +}; // definition of the chip-specific record -struct snd_emu10k1x { - snd_card_t *card; +struct emu10k1x { + struct snd_card *card; struct pci_dev *pci; unsigned long port; @@ -245,20 +242,20 @@ struct snd_emu10k1x { spinlock_t emu_lock; spinlock_t voice_lock; - ac97_t *ac97; - snd_pcm_t *pcm; + struct snd_ac97 *ac97; + struct snd_pcm *pcm; - emu10k1x_voice_t voices[3]; - emu10k1x_voice_t capture_voice; + struct emu10k1x_voice voices[3]; + struct emu10k1x_voice capture_voice; u32 spdif_bits[3]; // SPDIF out setup struct snd_dma_buffer dma_buffer; - emu10k1x_midi_t midi; + struct emu10k1x_midi midi; }; /* hardware definition */ -static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { +static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -277,7 +274,7 @@ static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { +static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -296,7 +293,7 @@ static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { .fifo_size = 0, }; -static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, +static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, unsigned int reg, unsigned int chn) { @@ -312,7 +309,7 @@ static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, return val; } -static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, +static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -328,7 +325,7 @@ static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -339,7 +336,7 @@ static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -350,7 +347,7 @@ static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) +static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value) { unsigned long flags; @@ -359,17 +356,14 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime) { - emu10k1x_pcm_t *epcm = runtime->private_data; - - if (epcm) - kfree(epcm); + kfree(runtime->private_data); } -static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) +static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice) { - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; @@ -385,11 +379,11 @@ static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) } /* open callback */ -static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { @@ -398,7 +392,7 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) return err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = chip; @@ -413,17 +407,17 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_playback_close(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { epcm->voice = &epcm->emu->voices[substream->pcm->device]; @@ -436,10 +430,10 @@ static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -456,11 +450,11 @@ static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) } /* prepare callback */ -static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int voice = epcm->voice->number; u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -485,12 +479,12 @@ static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) } /* trigger callback */ -static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; int result = 0; @@ -519,11 +513,11 @@ static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, /* pointer callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0; @@ -550,7 +544,7 @@ snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_emu10k1x_playback_ops = { +static struct snd_pcm_ops snd_emu10k1x_playback_ops = { .open = snd_emu10k1x_playback_open, .close = snd_emu10k1x_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -562,11 +556,11 @@ static snd_pcm_ops_t snd_emu10k1x_playback_ops = { }; /* open_capture callback */ -static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) @@ -574,7 +568,7 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) return err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; @@ -590,17 +584,17 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { if (epcm->emu->capture_voice.use) @@ -615,11 +609,11 @@ static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -635,10 +629,10 @@ static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr); snd_emu10k1x_ptr_write(emu, CAPTURE_BUFFER_SIZE, 0, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes @@ -649,12 +643,12 @@ static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) } /* trigger_capture callback */ -static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int result = 0; switch (cmd) { @@ -679,11 +673,11 @@ static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_capture callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr; if (!epcm->running) @@ -696,7 +690,7 @@ snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) return ptr; } -static snd_pcm_ops_t snd_emu10k1x_capture_ops = { +static struct snd_pcm_ops snd_emu10k1x_capture_ops = { .open = snd_emu10k1x_pcm_open_capture, .close = snd_emu10k1x_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -707,10 +701,10 @@ static snd_pcm_ops_t snd_emu10k1x_capture_ops = { .pointer = snd_emu10k1x_pcm_pointer_capture, }; -static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, +static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -721,10 +715,10 @@ static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, return val; } -static void snd_emu10k1x_ac97_write(ac97_t *ac97, +static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); @@ -733,12 +727,12 @@ static void snd_emu10k1x_ac97_write(ac97_t *ac97, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static int snd_emu10k1x_ac97(emu10k1x_t *chip) +static int snd_emu10k1x_ac97(struct emu10k1x *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_emu10k1x_ac97_write, .read = snd_emu10k1x_ac97_read, }; @@ -753,7 +747,7 @@ static int snd_emu10k1x_ac97(emu10k1x_t *chip) return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } -static int snd_emu10k1x_free(emu10k1x_t *chip) +static int snd_emu10k1x_free(struct emu10k1x *chip) { snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); // disable interrupts @@ -762,10 +756,8 @@ static int snd_emu10k1x_free(emu10k1x_t *chip) outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); // release the i/o port - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); + // release the irq if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); @@ -782,9 +774,9 @@ static int snd_emu10k1x_free(emu10k1x_t *chip) return 0; } -static int snd_emu10k1x_dev_free(snd_device_t *device) +static int snd_emu10k1x_dev_free(struct snd_device *device) { - emu10k1x_t *chip = device->device_data; + struct emu10k1x *chip = device->device_data; return snd_emu10k1x_free(chip); } @@ -793,64 +785,56 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, { unsigned int status; - emu10k1x_t *chip = dev_id; - emu10k1x_voice_t *pvoice = chip->voices; + struct emu10k1x *chip = dev_id; + struct emu10k1x_voice *pvoice = chip->voices; int i; int mask; status = inl(chip->port + IPR); - if(status) { - // capture interrupt - if(status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { - emu10k1x_voice_t *pvoice = &chip->capture_voice; - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, - INTE_CAP_0_LOOP | - INTE_CAP_0_HALF_LOOP); - } - - mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; - for(i = 0; i < 3; i++) { - if(status & mask) { - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, mask); - } - pvoice++; - mask <<= 1; - } + if (! status) + return IRQ_NONE; + + // capture interrupt + if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { + struct emu10k1x_voice *pvoice = &chip->capture_voice; + if (pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, + INTE_CAP_0_LOOP | + INTE_CAP_0_HALF_LOOP); + } - if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { - if (chip->midi.interrupt) - chip->midi.interrupt(chip, status); - else - snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); + mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; + for (i = 0; i < 3; i++) { + if (status & mask) { + if (pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, mask); } + pvoice++; + mask <<= 1; + } - // acknowledge the interrupt if necessary - if(status) - outl(status, chip->port+IPR); - -// snd_printk(KERN_INFO "interrupt %08x\n", status); + if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { + if (chip->midi.interrupt) + chip->midi.interrupt(chip, status); + else + snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); } + + // acknowledge the interrupt if necessary + outl(status, chip->port + IPR); + // snd_printk(KERN_INFO "interrupt %08x\n", status); return IRQ_HANDLED; } -static void snd_emu10k1x_pcm_free(snd_pcm_t *pcm) -{ - emu10k1x_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm) +static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; int capture = 0; @@ -863,7 +847,6 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1x_pcm_free; switch(device) { case 0: @@ -901,34 +884,34 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return 0; } -static int __devinit snd_emu10k1x_create(snd_card_t *card, +static int __devinit snd_emu10k1x_create(struct snd_card *card, struct pci_dev *pci, - emu10k1x_t **rchip) + struct emu10k1x **rchip) { - emu10k1x_t *chip; + struct emu10k1x *chip; int err; int ch; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_emu10k1x_dev_free, }; - + *rchip = NULL; - + if ((err = pci_enable_device(pci)) < 0) return err; - if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || - pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { + if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || + pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { snd_printk(KERN_ERR "error to set 28bit mask DMA\n"); pci_disable_device(pci); return -ENXIO; } - - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; } - + chip->card = card; chip->pci = pci; chip->irq = -1; @@ -1022,10 +1005,10 @@ static int __devinit snd_emu10k1x_create(snd_card_t *card, return 0; } -static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; unsigned long value,value1,value2; unsigned long flags; int i; @@ -1050,10 +1033,10 @@ static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, } } -static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; @@ -1067,21 +1050,22 @@ static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, } } -static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) +static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); entry->c.text.write_size = 64; entry->c.text.write = snd_emu10k1x_proc_reg_write; + entry->mode |= S_IWUSR; entry->private_data = emu; } return 0; } -static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1090,20 +1074,20 @@ static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_emu10k1x_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1; return 0; } -static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; @@ -1123,7 +1107,7 @@ static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog/Digital Output Jack", @@ -1132,17 +1116,17 @@ static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = .put = snd_emu10k1x_shared_spdif_put }; -static int snd_emu10k1x_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_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_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; @@ -1152,8 +1136,8 @@ static int snd_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_get_mask(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -1162,10 +1146,10 @@ static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -1182,19 +1166,19 @@ static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = { .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), .count = 3, .info = snd_emu10k1x_spdif_info, .get = snd_emu10k1x_spdif_get_mask }; -static snd_kcontrol_new_t snd_emu10k1x_spdif_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_control = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), .count = 3, .info = snd_emu10k1x_spdif_info, @@ -1202,11 +1186,11 @@ static snd_kcontrol_new_t snd_emu10k1x_spdif_control = .put = snd_emu10k1x_spdif_put }; -static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) { int err; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL) return -ENOMEM; @@ -1227,12 +1211,12 @@ static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) #define EMU10K1X_MIDI_MODE_INPUT (1<<0) #define EMU10K1X_MIDI_MODE_OUTPUT (1<<1) -static inline unsigned char mpu401_read(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int idx) +static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx) { return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0); } -static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, int idx) +static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx) { snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data); } @@ -1249,7 +1233,7 @@ static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, #define MPU401_ENTER_UART 0x3f #define MPU401_ACK 0xfe -static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) +static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu) { int timeout = 100000; for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) @@ -1264,7 +1248,8 @@ static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) */ -static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, unsigned int status) +static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu, + struct emu10k1x_midi *midi, unsigned int status) { unsigned char byte; @@ -1297,12 +1282,13 @@ static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, u spin_unlock(&midi->output_lock); } -static void snd_emu10k1x_midi_interrupt(emu10k1x_t *emu, unsigned int status) +static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status) { do_emu10k1x_midi_interrupt(emu, &emu->midi, status); } -static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsigned char cmd, int ack) +static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, + struct emu10k1x_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -1334,10 +1320,10 @@ static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsig mpu401_read_data(emu, midi)); } -static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1355,10 +1341,10 @@ static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1376,10 +1362,10 @@ static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1397,10 +1383,10 @@ static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1418,10 +1404,10 @@ static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; emu = midi->emu; snd_assert(emu, return); @@ -1431,10 +1417,10 @@ static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, snd_emu10k1x_intr_disable(emu, midi->rx_enable); } -static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1471,30 +1457,31 @@ static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream */ -static snd_rawmidi_ops_t snd_emu10k1x_midi_output = +static struct snd_rawmidi_ops snd_emu10k1x_midi_output = { .open = snd_emu10k1x_midi_output_open, .close = snd_emu10k1x_midi_output_close, .trigger = snd_emu10k1x_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_emu10k1x_midi_input = +static struct snd_rawmidi_ops snd_emu10k1x_midi_input = { .open = snd_emu10k1x_midi_input_open, .close = snd_emu10k1x_midi_input_close, .trigger = snd_emu10k1x_midi_input_trigger, }; -static void snd_emu10k1x_midi_free(snd_rawmidi_t *rmidi) +static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi) { - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)rmidi->private_data; + struct emu10k1x_midi *midi = rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } -static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, int device, char *name) +static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, + struct emu10k1x_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) @@ -1515,9 +1502,9 @@ static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, return 0; } -static int __devinit snd_emu10k1x_midi(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) { - emu10k1x_midi_t *midi = &emu->midi; + struct emu10k1x_midi *midi = &emu->midi; int err; if ((err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)")) < 0) @@ -1536,8 +1523,8 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - emu10k1x_t *chip; + struct snd_card *card; + struct emu10k1x *chip; int err; if (dev >= SNDRV_CARDS) @@ -1608,7 +1595,7 @@ static void __devexit snd_emu10k1x_remove(struct pci_dev *pci) } // PCI IDs -static struct pci_device_id snd_emu10k1x_ids[] = { +static struct pci_device_id snd_emu10k1x_ids[] __devinitdata = { { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Dell OEM version (EMU10K1) */ { 0, } }; @@ -1627,7 +1614,7 @@ static int __init alsa_card_emu10k1x_init(void) { int err; - if ((err = pci_module_init(&driver)) > 0) + if ((err = pci_register_driver(&driver)) > 0) return err; return 0;