X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=sound%2Fmips%2Fau1x00.c;h=99e1391b2eb42ffce2d7425621afa0c26134e770;hb=f2a5d6a2ea2fa24573a8ce7ea7a7a2cce42e3588;hp=e66b0144e3b561193b24db34b7168a5100682e53;hpb=d8327c784b51b57dac2c26cfad87dce0d68dfd98;p=safe%2Fjmp%2Flinux-2.6 diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index e66b014..99e1391b 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -36,10 +36,8 @@ #include #include -#include #include #include -#include #include #include #include @@ -192,14 +190,16 @@ au1000_setup_dma_link(struct audio_stream *stream, unsigned int period_bytes, static void au1000_dma_stop(struct audio_stream *stream) { - snd_assert(stream->buffer, return); + if (snd_BUG_ON(!stream->buffer)) + return; disable_dma(stream->dma); } static void au1000_dma_start(struct audio_stream *stream) { - snd_assert(stream->buffer, return); + if (snd_BUG_ON(!stream->buffer)) + return; init_dma(stream->dma); if (get_dma_active_buffer(stream->dma) == 0) { @@ -220,7 +220,7 @@ au1000_dma_start(struct audio_stream *stream) } static irqreturn_t -au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) +au1000_dma_interrupt(int irq, void *dev_id) { struct audio_stream *stream = (struct audio_stream *) dev_id; struct snd_pcm_substream *substream = stream->substream; @@ -258,7 +258,7 @@ au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) static unsigned int rates[] = {8000, 11025, 16000, 22050}; static struct snd_pcm_hw_constraint_list hw_constraints_rates = { - .count = sizeof(rates) / sizeof(rates[0]), + .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, }; @@ -465,13 +465,13 @@ snd_au1000_pcm_new(struct snd_au1000 *au1000) flags = claim_dma_lock(); if ((au1000->stream[PLAYBACK]->dma = request_au1000_dma(DMA_ID_AC97C_TX, - "AC97 TX", au1000_dma_interrupt, SA_INTERRUPT, + "AC97 TX", au1000_dma_interrupt, IRQF_DISABLED, au1000->stream[PLAYBACK])) < 0) { release_dma_lock(flags); return -EBUSY; } if ((au1000->stream[CAPTURE]->dma = request_au1000_dma(DMA_ID_AC97C_RX, - "AC97 RX", au1000_dma_interrupt, SA_INTERRUPT, + "AC97 RX", au1000_dma_interrupt, IRQF_DISABLED, au1000->stream[CAPTURE])) < 0){ release_dma_lock(flags); return -EBUSY; @@ -498,8 +498,8 @@ snd_au1000_ac97_read(struct snd_ac97 *ac97, unsigned short reg) int i; spin_lock(&au1000->ac97_lock); -/* would rather use the interupt than this polling but it works and I can't -get the interupt driven case to work efficiently */ +/* would rather use the interrupt than this polling but it works and I can't +get the interrupt driven case to work efficiently */ for (i = 0; i < 0x5000; i++) if (!(au1000->ac97_ioport->status & AC97C_CP)) break; @@ -535,8 +535,8 @@ snd_au1000_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short int i; spin_lock(&au1000->ac97_lock); -/* would rather use the interupt than this polling but it works and I can't -get the interupt driven case to work efficiently */ +/* would rather use the interrupt than this polling but it works and I can't +get the interrupt driven case to work efficiently */ for (i = 0; i < 0x5000; i++) if (!(au1000->ac97_ioport->status & AC97C_CP)) break; @@ -561,12 +561,13 @@ snd_au1000_ac97_new(struct snd_au1000 *au1000) .read = snd_au1000_ac97_read, }; - if ((au1000->ac97_res_port = request_region(AC97C_CONFIG, - sizeof(struct au1000_ac97_reg), "Au1x00 AC97")) == NULL) { + if ((au1000->ac97_res_port = request_mem_region(CPHYSADDR(AC97C_CONFIG), + 0x100000, "Au1x00 AC97")) == NULL) { snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n"); return -EBUSY; } - au1000->ac97_ioport = (struct au1000_ac97_reg *) au1000->ac97_res_port->start; + au1000->ac97_ioport = (struct au1000_ac97_reg *) + KSEG1ADDR(au1000->ac97_res_port->start); spin_lock_init(&au1000->ac97_lock); @@ -612,14 +613,17 @@ snd_au1000_free(struct snd_card *card) release_and_free_resource(au1000->ac97_res_port); } - if (au1000->stream[PLAYBACK]->dma >= 0) - free_au1000_dma(au1000->stream[PLAYBACK]->dma); - - if (au1000->stream[CAPTURE]->dma >= 0) - free_au1000_dma(au1000->stream[CAPTURE]->dma); + if (au1000->stream[PLAYBACK]) { + if (au1000->stream[PLAYBACK]->dma >= 0) + free_au1000_dma(au1000->stream[PLAYBACK]->dma); + kfree(au1000->stream[PLAYBACK]); + } - kfree(au1000->stream[PLAYBACK]); - kfree(au1000->stream[CAPTURE]); + if (au1000->stream[CAPTURE]) { + if (au1000->stream[CAPTURE]->dma >= 0) + free_au1000_dma(au1000->stream[CAPTURE]->dma); + kfree(au1000->stream[CAPTURE]); + } } @@ -632,21 +636,26 @@ au1000_init(void) struct snd_card *card; struct snd_au1000 *au1000; - card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(struct snd_au1000)); - if (card == NULL) - return -ENOMEM; + err = snd_card_create(-1, "AC97", THIS_MODULE, + sizeof(struct snd_au1000), &card); + if (err < 0) + return err; card->private_free = snd_au1000_free; au1000 = card->private_data; - /* so that snd_au1000_free will work as intended */ au1000->card = card; - au1000->stream[PLAYBACK]->dma = -1; - au1000->stream[CAPTURE]->dma = -1; - au1000->ac97_res_port = NULL; + au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); - au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); + au1000->stream[CAPTURE ] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); + /* so that snd_au1000_free will work as intended */ + au1000->ac97_res_port = NULL; + if (au1000->stream[PLAYBACK]) + au1000->stream[PLAYBACK]->dma = -1; + if (au1000->stream[CAPTURE ]) + au1000->stream[CAPTURE ]->dma = -1; + if (au1000->stream[PLAYBACK] == NULL || - au1000->stream[CAPTURE] == NULL) { + au1000->stream[CAPTURE ] == NULL) { snd_card_free(card); return -ENOMEM; }