Subject: audio (ac97?) problem
To: None <>
From: Brook Milligan <>
List: current-users
Date: 02/21/2002 13:02:40
NetBSD audio wizards,

I am trying to get rat (pkgsrc/mbone/rat) to work and am running into
what appears to be a problem with how /dev/audio is attached via the
esa/ac97 (and perhaps the sb) drivers.  I am running a kernel from the
head of the 1.5-release branch as of a few days ago.  The relevant
portions of all the files seem identical to the head of the current
branch, though.  Also, on this system the audio devices work fine for
playing and recording, as tested by things like xmmix, xmcd, and

Rat interacts with the audio system solely through the simple
interface provided by /dev/audio; it makes no use of /dev/mixer.
During the process of opening /dev/audio, rat sets the play port and
fails.  This is because the audio device driver does not attach any
output ports (see the debugging kernel probe information below from

	audio_attach: inputs ports=0x7, input master=-1, output ports=0x0, output master=-1

The cause of the absence of output ports appears to be a result of the
interaction between audioattach(), which is in audio.c, and the data
structures encoded in ac97.c.  The relevant audioattach() code is:

        for(mi.index = 0; ; mi.index++) {
                if (hwp->query_devinfo(hdlp, &mi) != 0)
                if (mi.type == AUDIO_MIXER_CLASS &&
                    strcmp(, AudioCrecord) == 0)
                        iclass = mi.index;
                if (mi.type == AUDIO_MIXER_CLASS &&
                    strcmp(, AudioCmonitor) == 0)
                        oclass = mi.index;

The input ports are recognized through the AudioCrecord mixer class,
whereas the output ports are recognized through the AudioCmonitor
mixer class.  The definition of source_info[] in ac97.c, however, only
defines these mixer classes:

        { AudioCinputs ,            NULL,           NULL,
        { AudioCoutputs,            NULL,           NULL,
        { AudioCrecord ,            NULL,           NULL,

There is nothing for AudioCmonitor.  Consequently, audioattach() finds
no output ports.

Unless I am misunderstanding the structure of these drivers, it
appears that ac97.c should be defining something to go along with the
AudioCmonitor mixer class so that the output ports are attached
properly.  However, I am not sure what is appropriate to define here.

Please help with suggestions.

A couple of other observations from looking at this code.  Note that
in the above kernel message neither master is defined (both take the
default -1).  I'm not sure if this is another indication of a problem
with the ac97.c data structure or not, but it strikes me as odd.

Also, the definition for the speaker in ac97.c is the following:

        { AudioCinputs,     AudioNspeaker,        NULL,	AUDIO_MIXER_VALUE,
          AC97_REG_PCBEEP_VOLUME, 0x0000, 4, 1, 1,
Almost certainly this should be AudioCoutputs (not inputs), but maybe
there is some unusual meaning to these codes or someone is using their
speaker as a microphone.

Why isn't there a LINE_OUT definition for ac97 stuff?

Finally, there is also nothing defined for AudioCmonitor in the sound
blaster drivers (e.g., isa/sbdsp.c).  And by the way, rat fails in the
same way on a system with such an audio card, though I haven't
installed a diagnostic kernel there to track it down.

Anyway, I would really appreciate assistance from those of you who are
more familiar with the audio system than me.  Specifically, am I on
the right track?  If so, how should the data structures be laid out in
these drivers to handle the AudioCmonitor mixer class that
audioattach() is looking for?

Thanks for your help.