Module Name: src Committed By: jmcneill Date: Mon Oct 24 02:08:23 UTC 2011
Modified Files: src/sys/dev/pci/hdaudio: hdafg.c Log Message: ossaudio's SNDCTL_DSP_GETOSPACE will call AUDIO_SETINFO if the block size isn't a power of two, and since the block size is changing this tells audio(4) to halt output, reconfigure the device, then trigger output again. mplayer's oss driver uses SNDCTL_DSP_GETOSPACE a lot. Instead of simply rounding to 128 bytes as required by the hardware, change hdafg_round_blocksize to return one of 128, 256, 512, 1024, 2048, 4096, or 8192. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/hdaudio/hdafg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/hdaudio/hdafg.c diff -u src/sys/dev/pci/hdaudio/hdafg.c:1.8 src/sys/dev/pci/hdaudio/hdafg.c:1.9 --- src/sys/dev/pci/hdaudio/hdafg.c:1.8 Wed Sep 7 20:34:58 2011 +++ src/sys/dev/pci/hdaudio/hdafg.c Mon Oct 24 02:08:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.8 2011/09/07 20:34:58 jmcneill Exp $ */ +/* $NetBSD: hdafg.c,v 1.9 2011/10/24 02:08:22 jmcneill Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.8 2011/09/07 20:34:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.9 2011/10/24 02:08:22 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -3801,7 +3801,7 @@ hdafg_round_blocksize(void *opaque, int { struct hdaudio_audiodev *ad = opaque; struct hdaudio_stream *st; - int bufsize; + int bufsize, nblksize; st = (mode == AUMODE_PLAY) ? ad->ad_playback : ad->ad_capture; if (st == NULL) { @@ -3810,19 +3810,24 @@ hdafg_round_blocksize(void *opaque, int return 128; } - /* Multiple of 128 */ - blksize &= ~127; - if (blksize <= 0) + if (blksize > 8192) + blksize = 8192; + else if (blksize < 0) blksize = 128; + /* HD audio wants a multiple of 128, and OSS wants a power of 2 */ + for (nblksize = 128; nblksize < blksize; nblksize <<= 1) + ; + + /* Make sure there are enough BDL descriptors */ bufsize = st->st_data.dma_size; - if (bufsize > HDAUDIO_BDL_MAX * blksize) { + if (bufsize > HDAUDIO_BDL_MAX * nblksize) { blksize = bufsize / HDAUDIO_BDL_MAX; - if (blksize & 127) - blksize = (blksize + 127) & ~127; + for (nblksize = 128; nblksize < blksize; nblksize <<= 1) + ; } - return blksize; + return nblksize; } static int