X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Ftrident%2Ftrident_synth.c;h=72d36b11bcd3d5fc5fd60b3d6a1889d273310508;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=8f9797d79b99e558138f8765e441b0c3a326358d;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/sound/pci/trident/trident_synth.c b/sound/pci/trident/trident_synth.c index 8f9797d79..72d36b11b 100644 --- a/sound/pci/trident/trident_synth.c +++ b/sound/pci/trident/trident_synth.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -506,7 +507,7 @@ static void sample_private1(trident_t * trident, snd_trident_voice_t * voice, un static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t * instr, char __user *data, long len, int atomic) { - trident_t *trident = snd_magic_cast(trident_t, private_data, return -ENXIO); + trident_t *trident = private_data; int size = instr->size; int shift = 0; @@ -540,12 +541,12 @@ static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t instr->address.memory = memblk->offset; } else { struct snd_dma_buffer dmab; - - if (snd_dma_alloc_pages(&trident->dma_dev, size, &dmab) < 0) + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), + size, &dmab) < 0) return -ENOMEM; if (copy_from_user(dmab.area, data, size)) { - snd_dma_free_pages(&trident->dma_dev, &dmab); + snd_dma_free_pages(&dmab); return -EFAULT; } instr->address.ptr = dmab.area; @@ -559,7 +560,7 @@ static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t static int snd_trident_simple_get_sample(void *private_data, simple_instrument_t * instr, char __user *data, long len, int atomic) { - //trident_t *trident = snd_magic_cast(trident_t, private_data, return -ENXIO); + //trident_t *trident = private_data; int size = instr->size; int shift = 0; @@ -580,9 +581,14 @@ static int snd_trident_simple_get_sample(void *private_data, simple_instrument_t static int snd_trident_simple_remove_sample(void *private_data, simple_instrument_t * instr, int atomic) { - trident_t *trident = snd_magic_cast(trident_t, private_data, return -ENXIO); + trident_t *trident = private_data; int size = instr->size; + if (instr->format & SIMPLE_WAVE_16BIT) + size <<= 1; + if (instr->format & SIMPLE_WAVE_STEREO) + size <<= 1; + if (trident->tlb.entries) { snd_util_memblk_t *memblk = (snd_util_memblk_t*)instr->address.ptr; if (memblk) @@ -590,14 +596,15 @@ static int snd_trident_simple_remove_sample(void *private_data, simple_instrumen else return -EFAULT; } else { - kfree(instr->address.ptr); + struct snd_dma_buffer dmab; + dmab.dev.type = SNDRV_DMA_TYPE_DEV; + dmab.dev.dev = snd_dma_pci_data(trident->pci); + dmab.area = instr->address.ptr; + dmab.addr = instr->address.memory; + dmab.bytes = size; + snd_dma_free_pages(&dmab); } - if (instr->format & SIMPLE_WAVE_16BIT) - size <<= 1; - if (instr->format & SIMPLE_WAVE_STEREO) - size <<= 1; - trident->synth.current_size -= size; if (trident->synth.current_size < 0) /* shouldn't need this check... */ trident->synth.current_size = 0; @@ -838,7 +845,7 @@ static void snd_trident_synth_instr_notify(void *private_data, int what) { int idx; - trident_t *trident = snd_magic_cast(trident_t, private_data, return); + trident_t *trident = private_data; snd_trident_voice_t *pvoice; unsigned long flags;