Subject: azalia STAC922x quirk
To: None <tech-kern@netbsd.org>
From: Blair Sadewitz <blair.sadewitz@gmail.com>
List: tech-kern
Date: 02/19/2007 11:42:56
I'm still learning a lot about this specification and driver, so I can
only be of limited help on this:

The STAC9220 by default has an absurdly low output volume.  The
FreeBSD driver has a fixup for this.  I have a STAC9221, and it has
the same problem.

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/sound/pci/hda/hdac.c?rev=1.24&content-type=text/x-cvsweb-markup

Search for 'softpcm' in the file to see the relevant bits.  The code
that does the work is this:

	/*
		 * XXX Temporary quirk for STAC9220, until the parser
		 *     become smarter.
		 */
		if (id == HDA_CODEC_STAC9220) {
			mask |= SOUND_MASK_VOLUME;
			while ((ctl = hdac_audio_ctl_each(devinfo, &i)) !=
			    NULL) {
				if (ctl->widget == NULL || ctl->enable == 0)
					continue;
				if (ctl->widget->nid == 11 && ctl->index == 0) {
					ctl->ossmask = SOUND_MASK_VOLUME;
					ctl->ossval = 100 | (100 << 8);
				} else
					ctl->ossmask &= ~SOUND_MASK_VOLUME;
			}
		} else if (id == HDA_CODEC_STAC9221) {
			mask |= SOUND_MASK_VOLUME;
			while ((ctl = hdac_audio_ctl_each(devinfo, &i)) !=
			    NULL) {
				if (ctl->widget == NULL)
					continue;
				if (ctl->widget->nid == 2 && ctl->index == 0) {
					ctl->enable = 1;
					ctl->ossmask = SOUND_MASK_VOLUME;
					ctl->ossval = 100 | (100 << 8);
				} else if (ctl->enable == 0)
					continue;
				else
					ctl->ossmask &= ~SOUND_MASK_VOLUME;
			}
		} else {
			mix_setparentchild(m, SOUND_MIXER_VOLUME,
			    SOUND_MASK_PCM);
			if (!(mask & SOUND_MASK_VOLUME))
				mix_setrealdev(m, SOUND_MIXER_VOLUME,
				    SOUND_MIXER_NONE);
			while ((ctl = hdac_audio_ctl_each(devinfo, &i)) !=
			    NULL) {
				if (ctl->widget == NULL || ctl->enable == 0)
					continue;
				if (!HDA_FLAG_MATCH(ctl->ossmask,
				    SOUND_MASK_VOLUME | SOUND_MASK_PCM))
					continue;
				if (!(ctl->mute == 1 && ctl->step == 0))
					ctl->enable = 0;
			}
		}
	}

I guess what it does is iterate through the volume widgets and crank them up. ;)
I don't have the time right now to look into this more, but I thought
I'd just put this out there
if anyone had any comments (or an idea of how to implement this for our driver).

I am also trying to figure out how to implement mmap support; my audio
skips too much!

Regards,

--Blair

-- 
Support WFMU-FM: free-form radio for the masses!
<http://www.wfmu.org/>

"The frivolity and boredom which unsettle the established order, the
vague foreboding of something unknown, these are the heralds of
approaching change.  The gradual crumbling that left unaltered the the
face of the whole is cut short by a sunburst which, in one flash,
illuminates the features of the new world."  --G.W.F. Hegel,
_Phenomenology of Spirit_ 5:11