*BSD News Article 40877


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!news.moneng.mei.com!hookup!news.kei.com!travelers.mail.cornell.edu!newsstand.cit.cornell.edu!news.graphics.cornell.edu!ghost.dsi.unimi.it!maya.dei.unipd.it!sirio.cineca.it!serra.unipi.it!swidir.switch.ch!scsing.switch.ch!news.dfn.de!news.belwue.de!delos.stgt.sub.org!guru.stgt.sub.org!nils
From: nils@guru.stgt.sub.org (Cornelis van der Laan)
Subject: Re: Problems with /dev/audio
Followup-To: comp.os.386bsd.bugs
Reply-To: nils@ims.uni-stuttgart.de
Sender: news@guru.stgt.sub.org (News pseudo-user)
Nntp-Posting-Host: localhost.ims.uni-stuttgart.de
Organization: Mehr Anarchie !
Message-ID: <NILS.95Jan14115006@guru.stgt.sub.org>
References: <3f4qs3$mri@cs.ubc.ca>
In-Reply-To: coatta@frood.nsg.bc.ca's message of 13 Jan 1995 03:08:51 GMT
Date: Sat, 14 Jan 1995 10:50:06 GMT
Lines: 142


In article <3f4qs3$mri@cs.ubc.ca> coatta@frood.nsg.bc.ca (Terry Coatta) writes:

>   I'm running FreeBSD V1.1.5 with an SB16 and /dev/audio seems to be
> slightly non-functional. The problem is not actually with playing sounds,
> which seems to work OK, but that the program using /dev/audio hangs.
> For example:
> 
>    cat my_sound.au > /dev/audio
> 
> plays the contents of the .au file alright, but the command never returns,
> and I eventually have to resort to ctl-C to killit off.
 
Hi, I also had this problem using my Soundblaster 16, although a former
Soundblaster Pro worked without any problems.

Here is a patch that helped me (note that I'm running FreeBSD 1.1.5
and don't know yet about the applicability of this patch to v2.0):

------- Start of forwarded message -------
From: tim@cs.city.ac.uk (Tim Wilkinson)
Newsgroups: list.freebsd-bugs
Subject: [Patch] Fix to SoundBlaster16 to use autoinitialisation.
Date: 1 Nov 94 13:49:47 GMT

All,

We are in the process of setting up a network of Pentium-PCI machines and 
have had trouble with the Soundblaster16 cards which generated audible 
'clicks' when playing sampled sound.  Enclosed is a patch to
'FreeBSD-current' which fixes this problem by allowing the Soundblaster
driver to use the DMA's 'autoinitialisation' mode (like the original
Linux version).

Note that this patch not only modifies the DMA code associated with the
sound blaster, it also modifies the 'isa.c' code to accept an additional
flag (B_RAW) to indicate autoinitialisation is required.  The choice of
this flag was relatively arbitrary (perhaps there is a more suitable one).

----------------------------------------------------------------------------
*** i386/isa/isa.c.orig	Tue Nov  1 13:25:24 1994
--- i386/isa/isa.c	Tue Nov  1 13:21:27 1994
***************
*** 571,576 ****
--- 571,585 ----
  		 * byte mode channels.
  		 */
  		/* set dma channel mode, and reset address ff */
+ 
+ 		/* If B_RAW flag is set, then use autoinitialise mode */
+ 		if (flags & B_RAW) {
+ 		  if (flags & B_READ)
+ 			outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_WRITE|chan);
+ 		  else
+ 			outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_READ|chan);
+ 		}
+ 		else
  		if (flags & B_READ)
  			outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan);
  		else
***************
*** 595,600 ****
--- 604,618 ----
  		 * word mode channels.
  		 */
  		/* set dma channel mode, and reset address ff */
+ 
+ 		/* If B_RAW flag is set, then use autoinitialise mode */
+ 		if (flags & B_RAW) {
+ 		  if (flags & B_READ)
+ 			outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_WRITE|(chan&3));
+ 		  else
+ 			outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_READ|(chan&3));
+ 		}
+ 		else
  		if (flags & B_READ)
  			outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3));
  		else
*** i386/isa/ic/i8237.h.orig	Tue Nov  1 13:20:13 1994
--- i386/isa/ic/i8237.h	Tue Nov  1 13:20:18 1994
***************
*** 6,11 ****
--- 6,12 ----
  
  #define	DMA37MD_SINGLE	0x40	/* single pass mode */
  #define	DMA37MD_CASCADE	0xc0	/* cascade mode */
+ #define	DMA37MD_AUTO	0x50	/* autoinitialise single pass mode */
  #define	DMA37MD_WRITE	0x04	/* read the device, write memory operation */
  #define	DMA37MD_READ	0x08	/* write the device, read memory operation */
  	
*** i386/isa/sound/dmabuf.c.orig	Tue Nov  1 13:25:18 1994
--- i386/isa/sound/dmabuf.c	Tue Nov  1 13:27:11 1994
***************
*** 659,667 ****
        RESTORE_INTR (flags);
  #else /* linux */
  #ifdef __FreeBSD__
!       printk ("sound: Invalid DMA mode for device %d\n", dev);
! 
!       isa_dmastart ((dma_mode == DMA_MODE_READ) ? B_READ : B_WRITE,
  		    (caddr_t)dmap->raw_buf_phys[0],
  		    dmap->bytes_in_use,
  		    chan);
--- 659,665 ----
        RESTORE_INTR (flags);
  #else /* linux */
  #ifdef __FreeBSD__
!       isa_dmastart (B_RAW + ((dma_mode == DMA_MODE_READ) ? B_READ : B_WRITE),
  		    (caddr_t)dmap->raw_buf_phys[0],
  		    dmap->bytes_in_use,
  		    chan);
*** i386/isa/sound/local.h.orig Tue Nov  1 13:44:08 1994
--- i386/isa/sound/local.h      Tue Nov  1 13:44:23 1994
***************
*** 21,27 ****
  #endif
  
  #define DSP_BUFFSIZE 65536
- #define NO_AUTODMA  /* still */
  #define SELECTED_SOUND_OPTIONS        0xffffffff
  #define SOUND_VERSION_STRING "2.90-2"
  #define SOUND_CONFIG_DATE "Thu Sep 29 15:33:39 PDT 1994"
----------------------------------------------------------------------------

Hope this is of use.

Tim Wilkinson (tim@cs.city.ac.uk)

--
  Tim Wilkinson                          tim@cs.city.ac.uk
  Systems Architecture Research Centre   http://web.cs.city.ac.uk/finger?tim
  City University, London EC1V 0HB, UK.

  Tel: +44 171 477 8551                  Fax: +44 171 477 8587

------- End of forwarded message -------

--
----------------------------------------------------------------
Cornelis van der Laan -- nils@ims.uni-stuttgart.de
                      -- nils@guru.stgt.sub.org
# echo Knusper Knusper Knaeuschen > /etc/nologin