Subject: Re: audio interrupt implementation
To: SUNAGAWA Keiki <kei_sun@ba2.so-net.ne.jp>
From: Colin Wood <cwood@ichips.intel.com>
List: port-mac68k
Date: 04/27/1998 11:22:39
SUNAGAWA Keiki wrote:
> 
> I'd been playing asc and got the playing (with coughing,
> anyway) raw sound file. So I plan to implement the audio
> interrupt and have some questions.

Really?  Could you tell me how?  I tried for a month and couldn't get
anything remotely pleasing out of either an EASC or an ASC.  I haven't
looked into it in a while since I've been busy with work and ADB stuff.
 
> In my understanding, the ROM sound driver uses one byte of
> ASCBase + 0x801 to detect if playing sound is done.  The
> VBL_Task routine clears the byte of that address and main
> driver routine updates the sound buffer area.

Well, I'm not entirely sure about that.  ASCBase+0x801 on the ASC seems to
actually toggle whether or not sound is produced.  On the EASC, this isn't
quite the case.  The flag used by VBLTask's is usually a low memory
global, something like SoundDone (that's not it, but I don't have my
disassembled .Sound driver in front of me).  I think that 0x801
enables/disables the scanning of the sound buffers which run from ASCBase
to ASCBase+0x3FF and ASCBase+0x400 to ASCBase+0x7FF (the latter only seems
to be used in double buffered mode, but I'm still not quite sure how that
part works, either).

> To add this feature into NetBSD/mac68k, I looked at
> mac68k/via.c and changed 5th record of the VIA2 interrupt
> handler table from via2_noint to snd_intr then added
> function snd_intr looks like below but it doesn't work.
> 
> /*ARGSUSED*/
> void
> snd_intr(bitarg)
> 	void *bitarg;
> {
> 	caddr_t ad = (caddr_t)0x50f14801;
> 
> 	*ad = 0;
> 	via2_reg(vPCR) &= ~V2IF_ASC;
> 	printf("snd_intr()\n");
> }
> 
> I think that it is needed to map the flag address, but I
> have no idea to do so.  Am I correct?  What should I do
> next?

I tried this as well, but I can't seem to get either the ASC or the EASC
to actually generate an interrupt.  It's a bit frustrating.  I've enabled
the interrupt by setting the proper bits in the vACR and vIFR, I think,
but still nothing.....as for mapping the address properly, take a look at
how the current asc.c code accesses that bit (it does it to toggle sound
on and off for the beep).  Of course, one of my machines is a IIci, so it
doesn't have a real VIA2, and I'm not positive that the RBV's VIA2
emulation registers are at the same addresses.  My other machine is a
Q700, with type 'B' EASC, which is different in a number of ways from the
ASC.  I seem to remember trying this on my SE/30 as well and not getting
good results either.

This will definitely require some more work sometime in the near future...

BTW, have I sent you my C pseudocode for the .Sound driver?  If you want
it, please let me know.

Later.

-- 
Colin Wood                                 cwood@ichips.intel.com
Component Design Engineer - MD6                 Intel Corporation
-----------------------------------------------------------------
I speak only on my own behalf, not for my employer.