2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * (C) 1997 Luigi Rizzo (luigi@iet.unipi.it)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <dev/sound/pcm/sound.h>
29 #include <dev/sound/pcm/vchan.h>
30 #include <dev/sound/pcm/dsp.h>
31 #include <sys/sysctl.h>
33 #include "feeder_if.h"
35 SND_DECLARE_FILE("$FreeBSD$");
37 devclass_t pcm_devclass;
39 int pcm_veto_load = 1;
43 TUNABLE_INT("hw.snd.unit", &snd_unit);
46 int snd_maxautovchans = 4;
47 TUNABLE_INT("hw.snd.maxautovchans", &snd_maxautovchans);
49 SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver");
51 static int sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose);
53 struct sysctl_ctx_list *
54 snd_sysctl_tree(device_t dev)
56 struct snddev_info *d = device_get_softc(dev);
58 return &d->sysctl_tree;
62 snd_sysctl_tree_top(device_t dev)
64 struct snddev_info *d = device_get_softc(dev);
66 return d->sysctl_tree_top;
70 snd_mtxcreate(const char *desc, const char *type)
75 m = malloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO);
78 mtx_init(m, desc, type, MTX_DEF);
81 return (void *)0xcafebabe;
91 /* mtx_assert(mtx, MA_OWNED); */
98 snd_mtxassert(void *m)
104 mtx_assert(mtx, MA_OWNED);
120 snd_mtxunlock(void *m)
130 snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
133 flags &= INTR_MPSAFE;
134 flags |= INTR_TYPE_AV;
136 flags = INTR_TYPE_AV;
138 return bus_setup_intr(dev, res, flags, hand, param, cookiep);
141 #ifndef PCM_DEBUG_MTX
143 pcm_lock(struct snddev_info *d)
145 snd_mtxlock(d->lock);
149 pcm_unlock(struct snddev_info *d)
151 snd_mtxunlock(d->lock);
156 pcm_getfakechan(struct snddev_info *d)
162 pcm_setvchans(struct snddev_info *d, int newcnt)
164 struct snddev_channel *sce = NULL;
165 struct pcm_channel *c = NULL;
166 int err = 0, vcnt, dcnt, i;
170 if (!(d->flags & SD_F_AUTOVCHAN)) {
175 vcnt = d->vchancount;
176 dcnt = d->playcount + d->reccount;
178 if (newcnt < 0 || (dcnt + newcnt) > (PCMMAXCHAN + 1)) {
186 /* add new vchans - find a parent channel first */
187 SLIST_FOREACH(sce, &d->channels, link) {
190 if (c->direction == PCMDIR_PLAY &&
191 ((c->flags & CHN_F_HAS_VCHAN) ||
193 !(c->flags & (CHN_F_BUSY | CHN_F_VIRTUAL)))))
200 c->flags |= CHN_F_BUSY;
201 while (err == 0 && newcnt > vcnt) {
202 if (dcnt > PCMMAXCHAN) {
203 device_printf(d->dev, "%s: Maximum channel reached.\n", __func__);
206 err = vchan_create(c);
210 } else if (err == E2BIG && newcnt > vcnt)
211 device_printf(d->dev, "%s: err=%d Maximum channel reached.\n", __func__, err);
214 c->flags &= ~CHN_F_BUSY;
216 } else if (newcnt < vcnt) {
217 #define ORPHAN_CDEVT(cdevt) \
218 ((cdevt) == NULL || ((cdevt)->si_drv1 == NULL && \
219 (cdevt)->si_drv2 == NULL))
220 while (err == 0 && newcnt < vcnt) {
222 SLIST_FOREACH(sce, &d->channels, link) {
225 if (c->direction == PCMDIR_PLAY &&
226 (c->flags & CHN_F_VIRTUAL) &&
228 if (!(c->flags & CHN_F_BUSY) &&
229 ORPHAN_CDEVT(sce->dsp_devt) &&
230 ORPHAN_CDEVT(sce->dspW_devt) &&
231 ORPHAN_CDEVT(sce->audio_devt) &&
232 ORPHAN_CDEVT(sce->dspr_devt))
235 * Either we're busy, or our cdev
236 * has been stolen by dsp_clone().
237 * Skip, and increase newcnt.
239 if (!(c->flags & CHN_F_BUSY))
240 device_printf(d->dev,
241 "%s: <%s> somebody steal my cdev!\n",
252 err = vchan_destroy(c);
256 device_printf(d->dev,
257 "%s: WARNING: vchan_destroy() failed!",
267 /* return error status and a locked channel */
269 pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction,
270 pid_t pid, int chnum)
272 struct pcm_channel *c;
273 struct snddev_channel *sce;
278 /* scan for a free channel */
279 SLIST_FOREACH(sce, &d->channels, link) {
282 if (c->direction == direction && !(c->flags & CHN_F_BUSY)) {
283 if (chnum < 0 || sce->chan_num == chnum) {
284 c->flags |= CHN_F_BUSY;
290 if (sce->chan_num == chnum) {
291 if (c->direction != direction)
293 else if (c->flags & CHN_F_BUSY)
299 } else if (c->direction == direction && (c->flags & CHN_F_BUSY))
304 /* no channel available */
305 if (chnum == -1 && direction == PCMDIR_PLAY && d->vchancount > 0 &&
306 d->vchancount < snd_maxautovchans &&
307 d->devcount <= PCMMAXCHAN) {
308 err = pcm_setvchans(d, d->vchancount + 1);
318 /* release a locked channel and unlock it */
320 pcm_chnrelease(struct pcm_channel *c)
323 c->flags &= ~CHN_F_BUSY;
330 pcm_chnref(struct pcm_channel *c, int ref)
341 pcm_inprog(struct snddev_info *d, int delta)
357 pcm_setmaxautovchans(struct snddev_info *d, int num)
359 if (num > 0 && d->vchancount == 0)
361 else if (num == 0 && d->vchancount > 0)
367 sysctl_hw_snd_unit(SYSCTL_HANDLER_ARGS)
369 struct snddev_info *d;
373 error = sysctl_handle_int(oidp, &unit, sizeof(unit), req);
374 if (error == 0 && req->newptr != NULL) {
375 if (unit < 0 || (pcm_devclass != NULL &&
376 unit >= devclass_get_maxunit(pcm_devclass)))
378 d = devclass_get_softc(pcm_devclass, unit);
379 if (d == NULL || SLIST_EMPTY(&d->channels))
385 SYSCTL_PROC(_hw_snd, OID_AUTO, unit, CTLTYPE_INT | CTLFLAG_RW,
386 0, sizeof(int), sysctl_hw_snd_unit, "I", "");
390 sysctl_hw_snd_maxautovchans(SYSCTL_HANDLER_ARGS)
392 struct snddev_info *d;
395 v = snd_maxautovchans;
396 error = sysctl_handle_int(oidp, &v, sizeof(v), req);
397 if (error == 0 && req->newptr != NULL) {
398 if (v < 0 || v > PCMMAXCHAN)
400 if (pcm_devclass != NULL && v != snd_maxautovchans) {
401 for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
402 d = devclass_get_softc(pcm_devclass, i);
405 pcm_setmaxautovchans(d, v);
408 snd_maxautovchans = v;
412 SYSCTL_PROC(_hw_snd, OID_AUTO, maxautovchans, CTLTYPE_INT | CTLFLAG_RW,
413 0, sizeof(int), sysctl_hw_snd_maxautovchans, "I", "");
416 pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo)
418 struct snddev_channel *sce;
419 struct pcm_channel *ch, *c;
421 uint32_t flsearch = 0;
422 int direction, err, rpnum, *pnum;
427 direction = PCMDIR_PLAY;
428 pnum = &d->playcount;
433 direction = PCMDIR_REC;
439 direction = PCMDIR_PLAY;
440 pnum = &d->vchancount;
441 flsearch = CHN_F_VIRTUAL;
448 ch = malloc(sizeof(*ch), M_DEVBUF, M_WAITOK | M_ZERO);
452 ch->methods = kobj_create(cls, M_DEVBUF, M_WAITOK);
459 snd_mtxlock(d->lock);
462 SLIST_FOREACH(sce, &d->channels, link) {
464 if (direction != c->direction ||
465 (c->flags & CHN_F_VIRTUAL) != flsearch)
467 if (ch->num == c->num)
471 device_printf(d->dev,
472 "%s: %s channel numbering screwed (Expect: %d, Got: %d)\n",
473 __func__, dirs, ch->num, c->num);
475 goto retry_num_search;
479 goto retry_num_search_out;
482 SLIST_FOREACH(sce, &d->channels, link) {
484 if (direction != c->direction ||
485 (c->flags & CHN_F_VIRTUAL) != flsearch)
487 if (ch->num == c->num) {
489 goto retry_num_search;
493 retry_num_search_out:
494 if (*pnum != rpnum) {
495 device_printf(d->dev,
496 "%s: WARNING: pnum screwed : dirs=%s, pnum=%d, rpnum=%d\n",
497 __func__, dirs, *pnum, rpnum);
501 snd_mtxunlock(d->lock);
504 ch->parentsnddev = d;
505 ch->parentchannel = parent;
507 snprintf(ch->name, CHN_NAMELEN, "%s:%s:%d", device_get_nameunit(ch->dev), dirs, ch->num);
509 err = chn_init(ch, devinfo, dir, direction);
511 device_printf(d->dev, "chn_init(%s) failed: err = %d\n", ch->name, err);
512 kobj_delete(ch->methods, M_DEVBUF);
514 snd_mtxlock(d->lock);
516 snd_mtxunlock(d->lock);
525 pcm_chn_destroy(struct pcm_channel *ch)
527 struct snddev_info *d;
530 d = ch->parentsnddev;
533 device_printf(d->dev, "chn_kill(%s) failed, err = %d\n", ch->name, err);
537 kobj_delete(ch->methods, M_DEVBUF);
544 pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch)
546 struct snddev_channel *sce, *tmp, *after;
548 int device = device_get_unit(d->dev);
552 * Note it's confusing nomenclature.
554 * device -> pcm_device
555 * unit -> pcm_channel
556 * channel -> snddev_channel
561 sce = malloc(sizeof(*sce), M_DEVBUF, M_WAITOK | M_ZERO);
566 snd_mtxlock(d->lock);
571 SLIST_FOREACH(tmp, &d->channels, link) {
572 if (sce->chan_num == tmp->chan_num)
576 device_printf(d->dev,
577 "%s: cdev numbering screwed (Expect: %d, Got: %d)\n",
578 __func__, sce->chan_num, tmp->chan_num);
580 goto retry_chan_num_search;
585 goto retry_chan_num_search_out;
586 retry_chan_num_search:
588 * Look for possible channel numbering collision. This may not
589 * be optimized, but it will ensure that no collision occured.
590 * Can be considered cheap since none of the locking/unlocking
591 * operations involved.
595 SLIST_FOREACH(tmp, &d->channels, link) {
596 if (sce->chan_num == tmp->chan_num) {
598 goto retry_chan_num_search;
600 if (sce->chan_num > tmp->chan_num)
604 retry_chan_num_search_out:
606 * Don't overflow PCMMKMINOR / PCMMAXCHAN.
608 if (sce->chan_num > PCMMAXCHAN) {
609 snd_mtxunlock(d->lock);
610 device_printf(d->dev,
611 "%s: WARNING: sce->chan_num overflow! (%d)\n",
612 __func__, sce->chan_num);
616 if (d->devcount != rdevcount) {
617 device_printf(d->dev,
618 "%s: WARNING: devcount screwed! d->devcount=%u, rdevcount=%u\n",
619 __func__, d->devcount, rdevcount);
620 d->devcount = rdevcount;
624 SLIST_INSERT_HEAD(&d->channels, sce, link);
626 SLIST_INSERT_AFTER(after, sce, link);
631 SLIST_FOREACH(tmp, &d->channels, link) {
632 if (cnum != tmp->chan_num)
633 device_printf(d->dev,
634 "%s: WARNING: inconsistent cdev numbering! (Expect: %d, Got: %d)\n",
635 __func__, cnum, tmp->chan_num);
641 namelen = strlen(ch->name);
642 if ((CHN_NAMELEN - namelen) > 10) { /* ":dspXX.YYY" */
643 snprintf(ch->name + namelen,
644 CHN_NAMELEN - namelen, ":dsp%d.%d",
645 device, sce->chan_num);
647 snd_mtxunlock(d->lock);
650 * I will revisit these someday, and nuke it mercilessly..
652 sce->dsp_devt = make_dev(&dsp_cdevsw,
653 PCMMKMINOR(device, SND_DEV_DSP, sce->chan_num),
654 UID_ROOT, GID_WHEEL, 0666, "dsp%d.%d",
655 device, sce->chan_num);
657 sce->dspW_devt = make_dev(&dsp_cdevsw,
658 PCMMKMINOR(device, SND_DEV_DSP16, sce->chan_num),
659 UID_ROOT, GID_WHEEL, 0666, "dspW%d.%d",
660 device, sce->chan_num);
662 sce->audio_devt = make_dev(&dsp_cdevsw,
663 PCMMKMINOR(device, SND_DEV_AUDIO, sce->chan_num),
664 UID_ROOT, GID_WHEEL, 0666, "audio%d.%d",
665 device, sce->chan_num);
667 if (ch->direction == PCMDIR_REC)
668 sce->dspr_devt = make_dev(&dsp_cdevsw,
669 PCMMKMINOR(device, SND_DEV_DSPREC,
670 sce->chan_num), UID_ROOT, GID_WHEEL,
671 0666, "dspr%d.%d", device, sce->chan_num);
677 pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch)
679 struct snddev_channel *sce;
684 if (!mtx_owned(d->lock)) {
685 snd_mtxlock(d->lock);
690 SLIST_FOREACH(sce, &d->channels, link) {
691 if (sce->channel == ch)
696 snd_mtxunlock(d->lock);
700 SLIST_REMOVE(&d->channels, sce, snddev_channel, link);
702 if (ch->flags & CHN_F_VIRTUAL)
704 else if (ch->direction == PCMDIR_REC)
711 snd_mtxunlock(d->lock);
719 pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
721 struct snddev_info *d = device_get_softc(dev);
722 struct pcm_channel *ch;
725 ch = pcm_chn_create(d, NULL, cls, dir, devinfo);
727 device_printf(d->dev, "pcm_chn_create(%s, %d, %p) failed\n", cls->name, dir, devinfo);
731 err = pcm_chn_add(d, ch);
733 device_printf(d->dev, "pcm_chn_add(%s) failed, err=%d\n", ch->name, err);
742 pcm_killchan(device_t dev)
744 struct snddev_info *d = device_get_softc(dev);
745 struct snddev_channel *sce;
746 struct pcm_channel *ch;
749 sce = SLIST_FIRST(&d->channels);
752 error = pcm_chn_remove(d, sce->channel);
755 return (pcm_chn_destroy(ch));
759 pcm_setstatus(device_t dev, char *str)
761 struct snddev_info *d = device_get_softc(dev);
763 snd_mtxlock(d->lock);
764 strncpy(d->status, str, SND_STATUSLEN);
765 snd_mtxunlock(d->lock);
766 if (snd_maxautovchans > 0)
772 pcm_getflags(device_t dev)
774 struct snddev_info *d = device_get_softc(dev);
780 pcm_setflags(device_t dev, uint32_t val)
782 struct snddev_info *d = device_get_softc(dev);
788 pcm_getdevinfo(device_t dev)
790 struct snddev_info *d = device_get_softc(dev);
796 pcm_getbuffersize(device_t dev, unsigned int min, unsigned int deflt, unsigned int max)
798 struct snddev_info *d = device_get_softc(dev);
802 if (resource_int_value(device_get_name(dev), device_get_unit(dev), "buffersize", &sz) == 0) {
806 device_printf(dev, "'buffersize=%d' hint is out of range (%d-%d), using %d\n", x, min, max, sz);
813 device_printf(dev, "'buffersize=%d' hint is not a power of 2, using %d\n", sz, x);
826 pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
828 struct snddev_info *d = device_get_softc(dev);
831 device_printf(dev, "disabled due to an error while initialising: %d\n", pcm_veto_load);
836 d->lock = snd_mtxcreate(device_get_nameunit(dev), "sound cdev");
840 * d->flags should be cleared by the allocator of the softc.
841 * We cannot clear this field here because several devices set
842 * this flag before calling pcm_register().
847 d->devinfo = devinfo;
854 SLIST_INIT(&d->channels);
856 if ((numplay == 0 || numrec == 0) && numplay != numrec)
857 d->flags |= SD_F_SIMPLEX;
859 d->fakechan = fkchan_setup(dev);
860 chn_init(d->fakechan, NULL, 0, 0);
863 sysctl_ctx_init(&d->sysctl_tree);
864 d->sysctl_tree_top = SYSCTL_ADD_NODE(&d->sysctl_tree,
865 SYSCTL_STATIC_CHILDREN(_hw_snd), OID_AUTO,
866 device_get_nameunit(dev), CTLFLAG_RD, 0, "");
867 if (d->sysctl_tree_top == NULL) {
868 sysctl_ctx_free(&d->sysctl_tree);
871 SYSCTL_ADD_INT(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)),
872 OID_AUTO, "buffersize", CTLFLAG_RD, &d->bufsz, 0, "");
875 d->flags |= SD_F_AUTOVCHAN;
879 sndstat_register(dev, d->status, sndstat_prepare_pcm);
882 snd_mtxfree(d->lock);
887 pcm_unregister(device_t dev)
889 struct snddev_info *d = device_get_softc(dev);
890 struct snddev_channel *sce;
891 struct pcmchan_children *pce;
892 struct pcm_channel *ch;
894 if (sndstat_acquire() != 0) {
895 device_printf(dev, "unregister: sndstat busy\n");
899 snd_mtxlock(d->lock);
901 device_printf(dev, "unregister: operation in progress\n");
902 snd_mtxunlock(d->lock);
907 SLIST_FOREACH(sce, &d->channels, link) {
909 if (ch->refcount > 0) {
910 device_printf(dev, "unregister: channel %s busy (pid %d)\n", ch->name, ch->pid);
911 snd_mtxunlock(d->lock);
917 if (mixer_uninit(dev) == EBUSY) {
918 device_printf(dev, "unregister: mixer busy\n");
919 snd_mtxunlock(d->lock);
924 SLIST_FOREACH(sce, &d->channels, link) {
926 destroy_dev(sce->dsp_devt);
927 sce->dsp_devt = NULL;
929 if (sce->dspW_devt) {
930 destroy_dev(sce->dspW_devt);
931 sce->dspW_devt = NULL;
933 if (sce->audio_devt) {
934 destroy_dev(sce->audio_devt);
935 sce->audio_devt = NULL;
937 if (sce->dspr_devt) {
938 destroy_dev(sce->dspr_devt);
939 sce->dspr_devt = NULL;
945 pce = SLIST_FIRST(&ch->children);
946 while (pce != NULL) {
948 device_printf(d->dev, "<%s> removing <%s>\n",
949 ch->name, (pce->channel != NULL) ?
950 pce->channel->name : "unknown");
952 SLIST_REMOVE(&ch->children, pce, pcmchan_children, link);
954 pce = SLIST_FIRST(&ch->children);
959 d->sysctl_tree_top = NULL;
960 sysctl_ctx_free(&d->sysctl_tree);
964 SLIST_FOREACH(sce, &d->channels, link) {
968 if (!SLIST_EMPTY(&ch->children))
969 device_printf(d->dev, "%s: WARNING: <%s> dangling child!\n",
973 while (!SLIST_EMPTY(&d->channels))
976 chn_kill(d->fakechan);
977 fkchan_kill(d->fakechan);
980 device_printf(d->dev, "%s: devcount=%u, playcount=%u, "
981 "reccount=%u, vchancount=%u\n",
982 __func__, d->devcount, d->playcount, d->reccount,
985 snd_mtxunlock(d->lock);
986 snd_mtxfree(d->lock);
987 sndstat_unregister(dev);
992 /************************************************************************/
995 sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
997 struct snddev_info *d;
998 struct snddev_channel *sce;
999 struct pcm_channel *c;
1000 struct pcm_feeder *f;
1006 d = device_get_softc(dev);
1010 snd_mtxlock(d->lock);
1011 if (!SLIST_EMPTY(&d->channels)) {
1013 SLIST_FOREACH(sce, &d->channels, link) {
1015 if (c->direction == PCMDIR_PLAY) {
1016 if (c->flags & CHN_F_VIRTUAL)
1023 sbuf_printf(s, " (%dp/%dr/%dv channels%s%s)", d->playcount, d->reccount, d->vchancount,
1024 (d->flags & SD_F_SIMPLEX)? "" : " duplex",
1026 (device_get_unit(dev) == snd_unit)? " default" : ""
1033 snd_mtxunlock(d->lock);
1037 SLIST_FOREACH(sce, &d->channels, link) {
1040 KASSERT(c->bufhard != NULL && c->bufsoft != NULL,
1041 ("hosed pcm channel setup"));
1043 sbuf_printf(s, "\n\t");
1045 /* it would be better to indent child channels */
1046 sbuf_printf(s, "%s[%s]: ", c->parentchannel? c->parentchannel->name : "", c->name);
1047 sbuf_printf(s, "spd %d", c->speed);
1048 if (c->speed != sndbuf_getspd(c->bufhard))
1049 sbuf_printf(s, "/%d", sndbuf_getspd(c->bufhard));
1050 sbuf_printf(s, ", fmt 0x%08x", c->format);
1051 if (c->format != sndbuf_getfmt(c->bufhard))
1052 sbuf_printf(s, "/0x%08x", sndbuf_getfmt(c->bufhard));
1053 sbuf_printf(s, ", flags 0x%08x, 0x%08x", c->flags, c->feederflags);
1055 sbuf_printf(s, ", pid %d", c->pid);
1056 sbuf_printf(s, "\n\t");
1058 sbuf_printf(s, "interrupts %d, ", c->interrupts);
1059 if (c->direction == PCMDIR_REC)
1060 sbuf_printf(s, "overruns %d, hfree %d, sfree %d [b:%d/%d/%d|bs:%d/%d/%d]",
1061 c->xruns, sndbuf_getfree(c->bufhard), sndbuf_getfree(c->bufsoft),
1062 sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
1063 sndbuf_getblkcnt(c->bufhard),
1064 sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
1065 sndbuf_getblkcnt(c->bufsoft));
1067 sbuf_printf(s, "underruns %d, ready %d [b:%d/%d/%d|bs:%d/%d/%d]",
1068 c->xruns, sndbuf_getready(c->bufsoft),
1069 sndbuf_getsize(c->bufhard), sndbuf_getblksz(c->bufhard),
1070 sndbuf_getblkcnt(c->bufhard),
1071 sndbuf_getsize(c->bufsoft), sndbuf_getblksz(c->bufsoft),
1072 sndbuf_getblkcnt(c->bufsoft));
1073 sbuf_printf(s, "\n\t");
1075 sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC)? "hardware" : "userland");
1076 sbuf_printf(s, " -> ");
1078 while (f->source != NULL)
1081 sbuf_printf(s, "%s", f->class->name);
1082 if (f->desc->type == FEEDER_FMT)
1083 sbuf_printf(s, "(0x%08x -> 0x%08x)", f->desc->in, f->desc->out);
1084 if (f->desc->type == FEEDER_RATE)
1085 sbuf_printf(s, "(%d -> %d)", FEEDER_GET(f, FEEDRATE_SRC), FEEDER_GET(f, FEEDRATE_DST));
1086 if (f->desc->type == FEEDER_ROOT || f->desc->type == FEEDER_MIXER ||
1087 f->desc->type == FEEDER_VOLUME)
1088 sbuf_printf(s, "(0x%08x)", f->desc->out);
1089 sbuf_printf(s, " -> ");
1092 sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC)? "userland" : "hardware");
1095 sbuf_printf(s, " (mixer only)");
1096 snd_mtxunlock(d->lock);
1101 /************************************************************************/
1103 #ifdef SND_DYNSYSCTL
1105 sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS)
1107 struct snddev_info *d;
1112 newcnt = d->vchancount;
1113 err = sysctl_handle_int(oidp, &newcnt, sizeof(newcnt), req);
1115 if (err == 0 && req->newptr != NULL && d->vchancount != newcnt)
1116 err = pcm_setvchans(d, newcnt);
1122 /************************************************************************/
1125 sound_modevent(module_t mod, int type, void *data)
1128 return (midi_modevent(mod, type, data));
1134 DEV_MODULE(sound, sound_modevent, NULL);
1135 MODULE_VERSION(sound, SOUND_MODVER);