1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-29 16:44:03 +00:00

Fix buffer sizes calculation looking into new Linux driver.

Save 112K for SB, 64K for PAS and 64K for MSS.
Since PAS use SB emulation, 176K normally saved for it.
Few minor optimizations added like in Linux driver.
This commit is contained in:
Andrey A. Chernov 1996-01-18 20:54:15 +00:00
parent 29681c973a
commit d9983e87e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13482
5 changed files with 27 additions and 21 deletions

View File

@ -1210,7 +1210,7 @@ ad1848_init (char *name, int io_base, int irq, int dma_playback, int dma_capture
audio_devs[my_dev]->dmachan = dma_playback;
audio_devs[my_dev]->buffcount = 1;
audio_devs[my_dev]->buffsize = DSP_BUFFSIZE * 2;
audio_devs[my_dev]->buffsize = DSP_BUFFSIZE;
audio_devs[my_dev]->devc = devc;
audio_devs[my_dev]->format_mask = ad_format_mask[devc->mode];
nr_ad1848_devs++;

View File

@ -73,10 +73,10 @@ reorganize_buffers (int dev)
sz = 8;
}
sz /= 8; /* #bits -> #bytes */
sz = sr * nc * sz;
sz /= 8; /* #bits -> #bytes */
/*
* Compute a buffer size for time not exeeding 1 second.
* Usually this algorithm gives a buffer size for 0.5 to 1.0 seconds
@ -92,11 +92,11 @@ reorganize_buffers (int dev)
if (dmap->subdivision == 0) /* Not already set */
dmap->subdivision = 1; /* Init to default value */
else
bsz /= dmap->subdivision;
bsz /= dmap->subdivision;
if (bsz < 64)
bsz = 4096; /* Just a sanity check */
if (bsz < 16)
bsz = 16; /* Just a sanity check */
while ((dsp_dev->buffsize * dsp_dev->buffcount) / bsz > MAX_SUB_BUFFERS)
bsz *= 2;
@ -109,11 +109,13 @@ reorganize_buffers (int dev)
* The process has specified the buffer sice with SNDCTL_DSP_SETFRAGMENT or
* the buffer sice computation has already been done.
*/
if (dmap->fragment_size > audio_devs[dev]->buffsize)
dmap->fragment_size = audio_devs[dev]->buffsize;
if (dmap->fragment_size > (audio_devs[dev]->buffsize / 2))
dmap->fragment_size = (audio_devs[dev]->buffsize / 2);
bsz = dmap->fragment_size;
}
bsz &= ~0x03; /* Force size which is multiple of 4 bytes */
/*
* Now computing addresses for the logical buffers
*/
@ -156,6 +158,8 @@ dma_init_buffers (int dev)
dmap->flags = DMA_BUSY; /* Other flags off */
dmap->qlen = dmap->qhead = dmap->qtail = 0;
dmap->nbufs = 1;
dmap->bytes_in_use = audio_devs[dev]->buffsize;
dmap->dma_mode = DMODE_NONE;
}
@ -587,20 +591,19 @@ DMAbuf_getwrbuffer (int dev, char **buf, int *size, int dontblock)
return err;
}
if (dontblock && !space_in_queue (dev)) /* XXX */
#if defined(__FreeBSD__)
return RET_ERROR (EWOULDBLOCK);
#else
return RET_ERROR (EAGAIN);
#endif
DISABLE_INTR (flags);
abort = 0;
while (!space_in_queue (dev) &&
!abort)
{
if (dontblock)
{
RESTORE_INTR (flags);
return RET_ERROR (EAGAIN);
}
/*
* Wait for free space
*/

View File

@ -409,7 +409,7 @@ pas_pcm_init (long mem_start, struct address_info *hw_config)
audio_devs[my_devnum = num_audiodevs++] = &pas_pcm_operations;
audio_devs[my_devnum]->dmachan = hw_config->dma;
audio_devs[my_devnum]->buffcount = 1;
audio_devs[my_devnum]->buffsize = 2 * DSP_BUFFSIZE;
audio_devs[my_devnum]->buffsize = DSP_BUFFSIZE;
}
else
printk ("PAS2: Too many PCM devices available\n");

View File

@ -1191,7 +1191,9 @@ sb_dsp_init (long mem_start, struct address_info *hw_config)
{
audio_devs[my_dev = num_audiodevs++] = &sb_dsp_operations;
audio_devs[my_dev]->buffcount = DSP_BUFFCOUNT;
audio_devs[my_dev]->buffsize = DSP_BUFFSIZE;
audio_devs[my_dev]->buffsize = (
(sbc_major > 2 || sbc_major == 2 && sbc_minor > 0) ?
16 : 8) * 1024;
audio_devs[my_dev]->dmachan = hw_config->dma;
}
else

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: soundcard.c,v 1.39 1995/12/10 02:53:07 bde Exp $
* $Id: soundcard.c,v 1.40 1995/12/11 09:26:16 phk Exp $
*/
#include "sound_config.h"
@ -478,6 +478,8 @@ sound_mem_init (void)
if (audio_devs[dev]->flags & DMA_AUTOMODE)
audio_devs[dev]->buffcount = 1;
audio_devs[dev]->buffsize &= ~0xfff; /* Truncate to n*4k */
if (audio_devs[dev]->dmachan > 3 && audio_devs[dev]->buffsize > 65536)
dma_pagesize = 131072; /* 128k */
else
@ -487,7 +489,6 @@ sound_mem_init (void)
if (audio_devs[dev]->buffsize > dma_pagesize)
audio_devs[dev]->buffsize = dma_pagesize;
audio_devs[dev]->buffsize &= ~0xfff; /* Truncate to n*4k */
if (audio_devs[dev]->buffsize < 4096)
audio_devs[dev]->buffsize = 4096;