diff -urN alsa-resman/pci/au88x0/au88x0_core.c alsa-resman-split/pci/au88x0/au88x0_core.c --- alsa-resman/pci/au88x0/au88x0_core.c 2003-07-10 21:17:38.000000000 -0400 +++ alsa-resman-split/pci/au88x0/au88x0_core.c 2003-07-10 21:42:11.000000000 -0400 @@ -1718,72 +1718,70 @@ out: Mean checkout if != 0. Else mean Checkin resource. restype: Indicates type of resource to be checked in or out. */ -int vortex_adb_checkinout(vortex_t *vortex, int stream, int out, int restype) { - int i, qty = resnum[restype], resmap=0; - - if (out) { - /* Gather used resources by all streams. */ - for (i=0; idma_adb[i].resources[restype]; - } - /* Find and take free resource. */ - for (i=0; i= 0) - vortex->dma_adb[stream].resources[restype] |= (1 << i); - else - vortex->dma_adb[i].resources[restype] |= (1 << i); - //printk("vortex: ResManager: type %d out %d\n", restype, i); - return i; - } - } - } else { - /* Checkin first resource of type restype. */ - for (i=0; idma_adb[stream].resources[restype] & (1 << i)) { - vortex->dma_adb[stream].resources[restype] &= ~(1 << i); - //printk("vortex: ResManager: type %d in %d\n",restype, i); - return i; - } +int vortex_adb_checkin(vortex_t *vortex, int stream, int out, int restype) { + int i, qty = resnum[restype]; + + /* Checkin first resource of type restype. */ + for (i=0; idma_adb[stream].resources[restype] & (1 << i)) { + vortex->dma_adb[stream].resources[restype] &= ~(1 << i); + //printk("vortex: ResManager: type %d in %d\n",restype, i); + return i; } } printk("vortex: ResManager: type %d FATAL\n", restype); return -EBUSY; } +int vortex_adb_checkout(vortex_t *vortex, int stream, int restype) { + int i, qty = resnum[restype], resmap=0; + + /* Gather used resources by all streams. */ + for (i=0; idma_adb[i].resources[restype]; + } + /* Find and take free resource. */ + for (i=0; i= 0) + vortex->dma_adb[stream].resources[restype] |= (1 << i); + else + vortex->dma_adb[i].resources[restype] |= (1 << i); + //printk("vortex: ResManager: type %d out %d\n", restype, i); + return i; + } + } + printk("vortex: ResManager: type %d FATAL\n", restype); + return -EBUSY; +} /* - Allocate nr_ch pcm audio routesif dma < 0. If dma >= 0, existing routes - are deallocated. - dma: DMA engine routes to be deallocated when dma >= 0. - nr_ch: Number of channels to be de/allocated. - dir: direction of stream. Uses same values as substream->stream. - Return: Return allocated DMA or same DMA passed as "dma" when dma >= 0. -*/ -int vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir) { + Allocate nr_ch pcm audio routesif dma < 0. If dma >= 0, existing routes + are deallocated. +dma: DMA engine routes to be deallocated when dma >= 0. +nr_ch: Number of channels to be de/allocated. +dir: direction of stream. Uses same values as substream->stream. +Return: Return allocated DMA or same DMA passed as "dma" when dma >= 0. + */ +int vortex_adb_allocroute(vortex_t *vortex, int nr_ch, int dir) { stream_t *stream; - int n, en; - + int n, en, dma; + if ((nr_ch == 3) || ((dir == SNDRV_PCM_STREAM_CAPTURE)&&(nr_ch > 2))) return -EBUSY; - + spin_lock(vortex->lock); - if (dma >= 0) { - en = 0; - vortex_adb_checkinout(vortex, dma, en, VORTEX_RESOURCE_DMA); - } else { - en = 1; - if ((dma = vortex_adb_checkinout(vortex, -1, en, VORTEX_RESOURCE_DMA)) < 0) - return -EBUSY; - - } + en = 1; + if ((dma = vortex_adb_checkout(vortex, -1, VORTEX_RESOURCE_DMA)) < 0) + return -EBUSY; + stream = &vortex->dma_adb[dma]; stream->dma = dma; stream->dir = dir; - + // FIXME: check for success of checkout or checkin. if (dir == SNDRV_PCM_STREAM_PLAYBACK) { int src, mix=0; - + for (n=0; ndma_adb[dma].nr_ch = nr_ch; spin_unlock(vortex->lock); - if (en) { - printk(KERN_INFO "vortex: alloc %d\n", dma); - //vortex_fifo_adbinitialize(vortex, dma, 0); - udelay(2000); - } else { - printk(KERN_INFO "vortex: de alloc %d\n", dma); - //vortex_fifo_setadbvalid(vortex, dma, 0); - } + printk(KERN_INFO "vortex: alloc %d\n", dma); + //vortex_fifo_adbinitialize(vortex, dma, 0); + udelay(2000); + /* AC97 Codec channel setup. FIXME: this has no effect !! */ if (nr_ch < 4) { /* Copy stereo to rear channel (surround) */ @@ -1835,6 +1829,58 @@ return dma; } + +void vortex_adb_freeroute(vortex_t *vortex, stream_t *stream) { + int n, en; + int dma = stream->dma; + int nr_ch = stream->nr_ch + + if ((nr_ch == 3) || ((dir == SNDRV_PCM_STREAM_CAPTURE)&&(nr_ch > 2))) + return -EBUSY; + + spin_lock(vortex->lock); + en = 0; + vortex_adb_checkin(vortex, dma, VORTEX_RESOURCE_DMA); + + // FIXME: check for success of checkout or checkin. + if (stream->dir == SNDRV_PCM_STREAM_PLAYBACK) { + int src, mix=0; + + for (n=0; nlock); + + printk(KERN_INFO "vortex: de alloc %d\n", dma); + + return; +} /* Set the SampleRate of the SRC's attached to the given DMA engine. */ diff -urN alsa-resman/pci/au88x0/au88x0_pcm.c alsa-resman-split/pci/au88x0/au88x0_pcm.c --- alsa-resman/pci/au88x0/au88x0_pcm.c 2003-07-10 21:17:38.000000000 -0400 +++ alsa-resman-split/pci/au88x0/au88x0_pcm.c 2003-07-10 21:19:11.000000000 -0400 @@ -111,9 +111,9 @@ int dma; /* Dealloc any routes. */ if (stream != NULL) - vortex_adb_allocroute(chip, stream->dma, stream->nr_ch, stream->dir); + vortex_adb_freeroute(chip, stream); /* Alloc routes. */ - dma = vortex_adb_allocroute(chip, -1, params_channels(hw_params), substream->stream); + dma = vortex_adb_allocroute(chip, params_channels(hw_params), substream->stream); stream = substream->runtime->private_data = &chip->dma_adb[dma]; stream->substream = substream; /* Setup Buffers. */ @@ -137,7 +137,7 @@ // Delete audio routes. if (substream->pcm == chip->pcm_adb) { if (stream != NULL) - vortex_adb_allocroute(chip, stream->dma, stream->nr_ch, stream->dir); + vortex_adb_freeroute(chip, stream); } else { if (stream != NULL) vortex_wt_allocroute(chip, stream->dma, 0); diff -urN alsa-resman/pci/au88x0/CVS/Entries alsa-resman-split/pci/au88x0/CVS/Entries --- alsa-resman/pci/au88x0/CVS/Entries 2003-07-10 21:17:25.000000000 -0400 +++ alsa-resman-split/pci/au88x0/CVS/Entries 2003-07-10 20:38:53.000000000 -0400 @@ -32,5 +32,5 @@ /au88x0_eq.h/1.3/Fri Jul 4 23:41:52 2003// /au88x0_eqdata.c/1.2/Fri Jul 4 23:41:52 2003// /au88x0_synth.c/1.2/Fri Jul 4 23:41:53 2003// -/au88x0_core.c/1.27/Fri Jul 11 01:17:25 2003//T1.27 +/au88x0_core.c/1.27/Fri Jul 11 00:24:16 2003//T1.27 D