From owner-freebsd-multimedia@FreeBSD.ORG Wed Sep 14 12:15:21 2005 Return-Path: X-Original-To: freebsd-multimedia@freebsd.org Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED9FE16A41F; Wed, 14 Sep 2005 12:15:21 +0000 (GMT) (envelope-from skywizard@MyBSD.org.my) Received: from tomoyo.MyBSD.org.my (tomoyo.mybsd.org.my [202.157.186.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2958F43D45; Wed, 14 Sep 2005 12:15:20 +0000 (GMT) (envelope-from skywizard@MyBSD.org.my) Received: from localhost (localhost [127.0.0.1]) by tomoyo.MyBSD.org.my (Postfix) with ESMTP id 9F0716CC26; Wed, 14 Sep 2005 20:23:21 +0800 (MYT) Received: from tomoyo.MyBSD.org.my ([127.0.0.1]) by localhost (tomoyo.MyBSD.org.my [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 59078-09; Wed, 14 Sep 2005 20:23:20 +0800 (MYT) Received: from kasumi.MyBSD.org.my (unknown [218.111.181.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tomoyo.MyBSD.org.my (Postfix) with ESMTP id 992C66CC25; Wed, 14 Sep 2005 20:23:19 +0800 (MYT) Date: Wed, 14 Sep 2005 20:16:00 +0800 From: Ariff Abdullah To: Michael Nottebrock Message-Id: <20050914201600.383df2ce.skywizard@MyBSD.org.my> In-Reply-To: <200509141241.22914.lofi@freebsd.org> References: <20050913075835.5f055747.skywizard@MyBSD.org.my> <200509140359.33175.lofi@freebsd.org> <20050914101228.4b688886.skywizard@MyBSD.org.my> <200509141241.22914.lofi@freebsd.org> Organization: MyBSD X-Mailer: /usr/local/lib/ruby/1.8/net/smtp.rb Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-antivirus-mail-gateway at TOMOYO.MYBSD.ORG.MY Cc: freebsd-multimedia@freebsd.org Subject: Re: As promised: Soft volume mixer controller X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2005 12:15:22 -0000 On Wed, 14 Sep 2005 12:41:20 +0200 Michael Nottebrock wrote: > On Wednesday, 14. September 2005 04:12, Ariff Abdullah wrote: > > > Can you revisit sys/dev/sound/pcm/ac97.c, look for > > ac97_fix_volume(codec); , and comment or remove it? I just want to > > make sure it is the fault of feeder volume, not something else. > > Yes, that makes vchans work again (and the pcm mixer is binary again, > so I guess I commented out the right line, too). > damn that feeder volume :) > However, it seems I also found another bug related to vchans somewhere > else in that patchset - and one in the current unpatched 5-STABLE: > > I have hw.snd.pcm0.vchans=4 set in /etc/sysctl.conf > > With an unpatched kernel (5-STABLE), this gives me: > > [lofi@kiste]:0:~ > ls -l /dev/dsp* > crw-rw-rw- 1 root wheel 30, 3 14 Sep 12:31 /dev/dsp0.0 > crw-rw-rw- 1 root wheel 30, 0x00010003 14 Sep 12:31 /dev/dsp0.1 > crw-rw-rw- 1 root wheel 30, 0x00020003 14 Sep 12:31 /dev/dsp0.2 > crw-rw-rw- 1 root wheel 30, 0x00030003 14 Sep 12:31 /dev/dsp0.3 > crw-rw-rw- 1 root wheel 30, 0x00040003 14 Sep 12:31 /dev/dsp0.4 > crw-rw-rw- 1 root wheel 30, 0x00050003 14 Sep 12:31 /dev/dsp0.5 > crw-rw-rw- 1 root wheel 30, 5 14 Sep 12:29 /dev/dspW0.0 > crw-rw-rw- 1 root wheel 30, 0x00010005 14 Sep 12:29 /dev/dspW0.1 > crw-rw-rw- 1 root wheel 30, 0x00020005 14 Sep 12:29 /dev/dspW0.2 > crw-rw-rw- 1 root wheel 30, 0x00030005 14 Sep 12:29 /dev/dspW0.3 > crw-rw-rw- 1 root wheel 30, 0x00040005 14 Sep 12:29 /dev/dspW0.4 > crw-rw-rw- 1 root wheel 30, 0x00050005 14 Sep 12:29 /dev/dspW0.5 > crw-rw-rw- 1 root wheel 30, 0x0001000b 14 Sep 12:29 /dev/dspr0.1 > > i.e. six virtual devices rather then four. I have no idea if that has > always been the case or not - I never bothered to actually cound the > devices before, after the four I requested were there! :-) > It has always been the case. It's not a bug (depend on bug definition): dsp0.0 = hardware channel dsp0.1 = master / parent channel (feeder_mix_s16) dsp0.2,3,4,5 = virtual channel Device naming / numbering is mega confusing, I'll address this in future. > With a patched kernel however I get: > > [lofi@kiste]:0:~ > ls -l /dev/dsp* > crw-rw-rw- 1 root wheel 30, 3 14 Sep 12:36 /dev/dsp0.0 > crw-rw-rw- 1 root wheel 30, 0x00020003 14 Sep 12:36 /dev/dsp0.2 > crw-rw-rw- 1 root wheel 30, 0x00030003 14 Sep 12:37 /dev/dsp0.3 > crw-rw-rw- 1 root wheel 30, 0x00040003 14 Sep 12:36 /dev/dsp0.4 > crw-rw-rw- 1 root wheel 30, 0x00050003 14 Sep 12:36 /dev/dsp0.5 > crw-rw-rw- 1 root wheel 30, 0x00060003 14 Sep 12:36 /dev/dsp0.6 > crw-rw-rw- 1 root wheel 30, 5 14 Sep 12:36 /dev/dspW0.0 > crw-rw-rw- 1 root wheel 30, 0x00020005 14 Sep 12:36 /dev/dspW0.2 > crw-rw-rw- 1 root wheel 30, 0x00030005 14 Sep 12:36 /dev/dspW0.3 > crw-rw-rw- 1 root wheel 30, 0x00040005 14 Sep 12:36 /dev/dspW0.4 > crw-rw-rw- 1 root wheel 30, 0x00050005 14 Sep 12:36 /dev/dspW0.5 > crw-rw-rw- 1 root wheel 30, 0x00060005 14 Sep 12:36 /dev/dspW0.6 > crw-rw-rw- 1 root wheel 30, 0x0002000b 14 Sep 12:36 /dev/dspr0.2 > > Note how /dev/dsp(W|r)0.1 are missing and instead I get /dev/dsp(W)0.6 > > and /dev/dspr0.2 ... > Same as above, only that the patched version increase the vchan robustness at the cost of more confusion :) Ok, back to our real problem. Can you uncomment / restore back ac97_fix_volume(codec); , and apply this: --- channel.c.diff BEGIN --- --- sys/dev/sound/pcm/channel.c.orig Wed Sep 14 19:47:43 2005 +++ sys/dev/sound/pcm/channel.c Wed Sep 14 19:48:04 2005 @@ -884,6 +884,7 @@ chn_lockdestroy(c); return ret; +#if 0 } else if (c->direction == PCMDIR_PLAY && c->parentsnddev && (c->parentsnddev->flags & SD_F_SOFTVOL) && c->parentsnddev->mixer_dev) { @@ -899,6 +900,7 @@ CHN_LOCK(c); chn_setvolume(c, vol & 0x7f, (vol >> 8) & 0x7f); CHN_UNLOCK(c); +#endif } return 0; @@ -1331,7 +1333,8 @@ c->feederflags &= ~(1 << FEEDER_VOLUME); if (c->direction == PCMDIR_PLAY && !(c->flags & (CHN_F_VIRTUAL|CHN_F_HAS_SLAVE)) && - c->parentsnddev && (c->parentsnddev->flags & SD_F_SOFTVOL)) + c->parentsnddev && (c->parentsnddev->flags & SD_F_SOFTVOL) && + c->parentsnddev->mixer_dev) c->feederflags |= 1 << FEEDER_VOLUME; flags = c->feederflags; fmtlist = chn_getcaps(c)->fmtlist; @@ -1396,6 +1399,17 @@ } sndbuf_setfmt(c->bufhard, hwfmt); + + if ((flags & (1 << FEEDER_VOLUME))) { + int vol = 100 | (100 << 8); + + CHN_UNLOCK(c); + if (mixer_ioctl(c->parentsnddev->mixer_dev, + MIXER_READ(SOUND_MIXER_PCM), (caddr_t)&vol, -1, NULL) != 0) + device_printf(c->dev, "Soft Volume: Failed to read default value\n"); + CHN_LOCK(c); + chn_setvolume(c, vol & 0x7f, (vol >> 8) & 0x7f); + } return 0; } --- channel.c.diff END --- -- Ariff Abdullah MyBSD http://www.MyBSD.org.my (IPv6/IPv4) http://staff.MyBSD.org.my (IPv6/IPv4) http://tomoyo.MyBSD.org.my (IPv6/IPv4)