As promised: Soft volume mixer controller
Ariff Abdullah
skywizard at MyBSD.org.my
Wed Sep 14 05:15:22 PDT 2005
On Wed, 14 Sep 2005 12:41:20 +0200
Michael Nottebrock <lofi at freebsd.org> 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 at 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 at 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)
More information about the freebsd-multimedia
mailing list