Lines Matching +full:- +full:c
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
5 * Portions Copyright (c) Ryan Beasley <ryan.beasley@gmail.com> - GSoC 2006
6 * Copyright (c) 1999 Cameron Grant <cg@FreeBSD.org>
7 * Portions Copyright (c) Luigi Rizzo <luigi@FreeBSD.org> - 1997-99
43 &report_soft_formats, 0, "report software-emulated formats");
47 &report_soft_matrix, 0, "report software-emulated channel matrixing");
58 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_latency()
81 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_latency_profile()
104 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_timeout()
116 "interrupt timeout (1 - 10) seconds");
128 struct pcm_channel *c; in chn_vpc_proc() local
139 CHN_FOREACH(c, d, channels.pcm) { in chn_vpc_proc()
140 CHN_LOCK(c); in chn_vpc_proc()
141 CHN_SETVOLUME(c, SND_VOL_C_PCM, SND_CHN_T_VOL_0DB, db); in chn_vpc_proc()
143 chn_vpc_reset(c, SND_VOL_C_PCM, 1); in chn_vpc_proc()
144 CHN_UNLOCK(c); in chn_vpc_proc()
158 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_vpc_0db()
180 if (err != 0 || req->newptr == NULL || val == 0) in sysctl_hw_snd_vpc_reset()
194 static int chn_syncdelay = -1;
200 "append (0-1000) millisecond trailing buffer delay on each sync");
221 chn_lockinit(struct pcm_channel *c, int dir) in chn_lockinit() argument
225 c->lock = snd_mtxcreate(c->name, "pcm play channel"); in chn_lockinit()
226 cv_init(&c->intr_cv, "pcmwr"); in chn_lockinit()
229 c->lock = snd_mtxcreate(c->name, "pcm virtual play channel"); in chn_lockinit()
230 cv_init(&c->intr_cv, "pcmwrv"); in chn_lockinit()
233 c->lock = snd_mtxcreate(c->name, "pcm record channel"); in chn_lockinit()
234 cv_init(&c->intr_cv, "pcmrd"); in chn_lockinit()
237 c->lock = snd_mtxcreate(c->name, "pcm virtual record channel"); in chn_lockinit()
238 cv_init(&c->intr_cv, "pcmrdv"); in chn_lockinit()
245 cv_init(&c->cv, "pcmchn"); in chn_lockinit()
249 chn_lockdestroy(struct pcm_channel *c) in chn_lockdestroy() argument
251 CHN_LOCKASSERT(c); in chn_lockdestroy()
253 CHN_BROADCAST(&c->cv); in chn_lockdestroy()
254 CHN_BROADCAST(&c->intr_cv); in chn_lockdestroy()
256 cv_destroy(&c->cv); in chn_lockdestroy()
257 cv_destroy(&c->intr_cv); in chn_lockdestroy()
259 snd_mtxfree(c->lock); in chn_lockdestroy()
269 chn_polltrigger(struct pcm_channel *c) in chn_polltrigger() argument
271 struct snd_dbuf *bs = c->bufsoft; in chn_polltrigger()
274 CHN_LOCKASSERT(c); in chn_polltrigger()
276 if (c->flags & CHN_F_MMAP) { in chn_polltrigger()
277 if (sndbuf_getprevtotal(bs) < c->lw) in chn_polltrigger()
278 delta = c->lw; in chn_polltrigger()
280 delta = sndbuf_gettotal(bs) - sndbuf_getprevtotal(bs); in chn_polltrigger()
282 if (c->direction == PCMDIR_PLAY) in chn_polltrigger()
288 return ((delta < c->lw) ? 0 : 1); in chn_polltrigger()
292 chn_pollreset(struct pcm_channel *c) in chn_pollreset() argument
295 CHN_LOCKASSERT(c); in chn_pollreset()
296 sndbuf_updateprevtotal(c->bufsoft); in chn_pollreset()
300 chn_wakeup(struct pcm_channel *c) in chn_wakeup() argument
305 CHN_LOCKASSERT(c); in chn_wakeup()
307 bs = c->bufsoft; in chn_wakeup()
309 if (CHN_EMPTY(c, children.busy)) { in chn_wakeup()
310 if (SEL_WAITING(sndbuf_getsel(bs)) && chn_polltrigger(c)) in chn_wakeup()
312 CHN_BROADCAST(&c->intr_cv); in chn_wakeup()
314 CHN_FOREACH(ch, c, children.busy) { in chn_wakeup()
323 chn_sleep(struct pcm_channel *c, int timeout) in chn_sleep() argument
327 CHN_LOCKASSERT(c); in chn_sleep()
329 if (c->flags & CHN_F_DEAD) in chn_sleep()
332 c->sleeping++; in chn_sleep()
333 ret = cv_timedwait_sig(&c->intr_cv, c->lock, timeout); in chn_sleep()
334 c->sleeping--; in chn_sleep()
336 return ((c->flags & CHN_F_DEAD) ? EINVAL : ret); in chn_sleep()
345 chn_dmaupdate(struct pcm_channel *c) in chn_dmaupdate() argument
347 struct snd_dbuf *b = c->bufhard; in chn_dmaupdate()
351 CHN_LOCKASSERT(c); in chn_dmaupdate()
354 hwptr = chn_getptr(c); in chn_dmaupdate()
355 delta = (sndbuf_getsize(b) + hwptr - old) % sndbuf_getsize(b); in chn_dmaupdate()
358 if (c->direction == PCMDIR_PLAY) { in chn_dmaupdate()
360 amt -= amt % sndbuf_getalign(b); in chn_dmaupdate()
365 amt -= amt % sndbuf_getalign(b); in chn_dmaupdate()
369 if (snd_verbose > 3 && CHN_STARTED(c) && delta == 0) { in chn_dmaupdate()
370 device_printf(c->dev, "WARNING: %s DMA completion " in chn_dmaupdate()
373 CHN_DIRSTR(c), hwptr, old, delta, amt, in chn_dmaupdate()
381 chn_wrfeed(struct pcm_channel *c) in chn_wrfeed() argument
383 struct snd_dbuf *b = c->bufhard; in chn_wrfeed()
384 struct snd_dbuf *bs = c->bufsoft; in chn_wrfeed()
387 CHN_LOCKASSERT(c); in chn_wrfeed()
389 if ((c->flags & CHN_F_MMAP) && !(c->flags & CHN_F_CLOSING)) in chn_wrfeed()
394 imax(0, sndbuf_xbytes(sndbuf_getsize(bs), bs, b) - in chn_wrfeed()
398 sndbuf_feed(bs, b, c, c->feeder, amt); in chn_wrfeed()
404 c->xruns++; in chn_wrfeed()
407 chn_wakeup(c); in chn_wrfeed()
411 chn_wrintr(struct pcm_channel *c) in chn_wrintr() argument
414 CHN_LOCKASSERT(c); in chn_wrintr()
416 chn_dmaupdate(c); in chn_wrintr()
418 chn_wrfeed(c); in chn_wrintr()
420 chn_trigger(c, PCMTRIG_EMLDMAWR); in chn_wrintr()
424 * user write routine - uiomove data into secondary buffer, trigger if necessary
431 chn_write(struct pcm_channel *c, struct uio *buf) in chn_write() argument
433 struct snd_dbuf *bs = c->bufsoft; in chn_write()
437 CHN_LOCKASSERT(c); in chn_write()
442 while (ret == 0 && buf->uio_resid > 0) { in chn_write()
443 sz = min(buf->uio_resid, sndbuf_getfree(bs)); in chn_write()
448 * unlock-uiomove-lock sequence. in chn_write()
452 t = min(sz, sndbuf_getsize(bs) - p); in chn_write()
454 CHN_UNLOCK(c); in chn_write()
456 CHN_LOCK(c); in chn_write()
457 sz -= t; in chn_write()
461 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { in chn_write()
462 ret = chn_start(c, 0); in chn_write()
464 c->flags |= CHN_F_DEAD; in chn_write()
466 } else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER)) { in chn_write()
479 ret = chn_sleep(c, timeout); in chn_write()
482 c->flags |= CHN_F_DEAD; in chn_write()
483 device_printf(c->dev, "%s(): %s: " in chn_write()
485 __func__, c->name); in chn_write()
487 c->flags |= CHN_F_ABORTING; in chn_write()
498 chn_rdfeed(struct pcm_channel *c) in chn_rdfeed() argument
500 struct snd_dbuf *b = c->bufhard; in chn_rdfeed()
501 struct snd_dbuf *bs = c->bufsoft; in chn_rdfeed()
504 CHN_LOCKASSERT(c); in chn_rdfeed()
506 if (c->flags & CHN_F_MMAP) in chn_rdfeed()
511 sndbuf_feed(b, bs, c, c->feeder, amt); in chn_rdfeed()
515 c->xruns++; in chn_rdfeed()
520 chn_wakeup(c); in chn_rdfeed()
525 chn_rdintr(struct pcm_channel *c) in chn_rdintr() argument
528 CHN_LOCKASSERT(c); in chn_rdintr()
529 /* tell the driver to update the primary buffer if non-dma */ in chn_rdintr()
530 chn_trigger(c, PCMTRIG_EMLDMARD); in chn_rdintr()
532 chn_dmaupdate(c); in chn_rdintr()
534 chn_rdfeed(c); in chn_rdintr()
538 * user read routine - trigger if necessary, uiomove data from secondary buffer
545 chn_read(struct pcm_channel *c, struct uio *buf) in chn_read() argument
547 struct snd_dbuf *bs = c->bufsoft; in chn_read()
551 CHN_LOCKASSERT(c); in chn_read()
553 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { in chn_read()
554 ret = chn_start(c, 0); in chn_read()
556 c->flags |= CHN_F_DEAD; in chn_read()
564 while (ret == 0 && buf->uio_resid > 0) { in chn_read()
565 sz = min(buf->uio_resid, sndbuf_getready(bs)); in chn_read()
570 * unlock-uiomove-lock sequence. in chn_read()
574 t = min(sz, sndbuf_getsize(bs) - p); in chn_read()
576 CHN_UNLOCK(c); in chn_read()
578 CHN_LOCK(c); in chn_read()
579 sz -= t; in chn_read()
583 } else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER)) in chn_read()
586 ret = chn_sleep(c, timeout); in chn_read()
589 c->flags |= CHN_F_DEAD; in chn_read()
590 device_printf(c->dev, "%s(): %s: " in chn_read()
592 __func__, c->name); in chn_read()
594 c->flags |= CHN_F_ABORTING; in chn_read()
602 chn_intr_locked(struct pcm_channel *c) in chn_intr_locked() argument
605 CHN_LOCKASSERT(c); in chn_intr_locked()
607 c->interrupts++; in chn_intr_locked()
609 if (c->direction == PCMDIR_PLAY) in chn_intr_locked()
610 chn_wrintr(c); in chn_intr_locked()
612 chn_rdintr(c); in chn_intr_locked()
616 chn_intr(struct pcm_channel *c) in chn_intr() argument
619 if (CHN_LOCKOWNED(c)) { in chn_intr()
620 chn_intr_locked(c); in chn_intr()
624 CHN_LOCK(c); in chn_intr()
625 chn_intr_locked(c); in chn_intr()
626 CHN_UNLOCK(c); in chn_intr()
630 chn_start(struct pcm_channel *c, int force) in chn_start() argument
633 struct snd_dbuf *b = c->bufhard; in chn_start()
634 struct snd_dbuf *bs = c->bufsoft; in chn_start()
637 CHN_LOCKASSERT(c); in chn_start()
639 if (CHN_STARTED(c) || ((c->flags & CHN_F_NOTRIGGER) && !force)) in chn_start()
648 if (c->direction == PCMDIR_REC) { in chn_start()
658 pb = CHN_BUF_PARENT(c, b); in chn_start()
663 if (snd_verbose > 3 && CHN_EMPTY(c, children)) in chn_start()
664 device_printf(c->dev, "%s(): %s (%s) threshold " in chn_start()
665 "i=%d j=%d\n", __func__, CHN_DIRSTR(c), in chn_start()
666 (c->flags & CHN_F_VIRTUAL) ? "virtual" : in chn_start()
671 c->flags |= CHN_F_TRIGGERED; in chn_start()
673 if (c->flags & CHN_F_CLOSING) in chn_start()
674 c->feedcount = 2; in chn_start()
676 c->feedcount = 0; in chn_start()
677 c->interrupts = 0; in chn_start()
678 c->xruns = 0; in chn_start()
680 if (c->parentchannel == NULL) { in chn_start()
681 if (c->direction == PCMDIR_PLAY) in chn_start()
685 device_printf(c->dev, in chn_start()
690 (c->flags & CHN_F_HAS_VCHAN) ? in chn_start()
691 "VCHAN PARENT" : "HW", CHN_DIRSTR(c), in chn_start()
692 (c->flags & CHN_F_CLOSING) ? "closing" : in chn_start()
695 force, i, j, c->timeout, in chn_start()
699 err = chn_trigger(c, PCMTRIG_START); in chn_start()
706 chn_resetbuf(struct pcm_channel *c) in chn_resetbuf() argument
708 struct snd_dbuf *b = c->bufhard; in chn_resetbuf()
709 struct snd_dbuf *bs = c->bufsoft; in chn_resetbuf()
711 c->blocks = 0; in chn_resetbuf()
722 chn_sync(struct pcm_channel *c, int threshold) in chn_sync() argument
728 CHN_LOCKASSERT(c); in chn_sync()
730 if (c->direction != PCMDIR_PLAY) in chn_sync()
733 bs = c->bufsoft; in chn_sync()
735 if ((c->flags & (CHN_F_DEAD | CHN_F_ABORTING)) || in chn_sync()
740 if (CHN_STOPPED(c)) { in chn_sync()
742 ret = chn_start(c, 1); in chn_sync()
749 b = CHN_BUF_PARENT(c, c->bufhard); in chn_sync()
759 * Append (0-1000) millisecond trailing buffer (if needed) in chn_sync()
767 minflush -= minflush % sndbuf_getalign(bs); in chn_sync()
773 minflush -= threshold; in chn_sync()
780 device_printf(c->dev, in chn_sync()
794 device_printf(c->dev, "%s(): [begin] timeout=%d count=%d " in chn_sync()
795 "minflush=%d resid=%d\n", __func__, c->timeout, count, in chn_sync()
798 cflag = c->flags & CHN_F_CLOSING; in chn_sync()
799 c->flags |= CHN_F_CLOSING; in chn_sync()
801 ret = chn_sleep(c, c->timeout); in chn_sync()
803 c->flags |= CHN_F_ABORTING; in chn_sync()
808 --count; in chn_sync()
810 device_printf(c->dev, in chn_sync()
814 __func__, c->timeout, count, in chn_sync()
819 device_printf(c->dev, in chn_sync()
823 __func__, c->timeout, count, in chn_sync()
832 minflush -= threshold; in chn_sync()
838 c->flags &= ~CHN_F_CLOSING; in chn_sync()
839 c->flags |= cflag; in chn_sync()
842 device_printf(c->dev, in chn_sync()
845 __func__, c->timeout, count, hcount, resid, residp, in chn_sync()
853 chn_poll(struct pcm_channel *c, int ev, struct thread *td) in chn_poll() argument
855 struct snd_dbuf *bs = c->bufsoft; in chn_poll()
858 CHN_LOCKASSERT(c); in chn_poll()
860 if (!(c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED))) { in chn_poll()
861 ret = chn_start(c, 1); in chn_poll()
867 if (chn_polltrigger(c)) { in chn_poll()
868 chn_pollreset(c); in chn_poll()
883 chn_abort(struct pcm_channel *c) in chn_abort() argument
886 struct snd_dbuf *b = c->bufhard; in chn_abort()
887 struct snd_dbuf *bs = c->bufsoft; in chn_abort()
889 CHN_LOCKASSERT(c); in chn_abort()
890 if (CHN_STOPPED(c)) in chn_abort()
892 c->flags |= CHN_F_ABORTING; in chn_abort()
894 c->flags &= ~CHN_F_TRIGGERED; in chn_abort()
896 chn_trigger(c, PCMTRIG_ABORT); in chn_abort()
898 if (!(c->flags & CHN_F_VIRTUAL)) in chn_abort()
899 chn_dmaupdate(c); in chn_abort()
902 c->flags &= ~CHN_F_ABORTING; in chn_abort()
918 chn_flush(struct pcm_channel *c) in chn_flush() argument
920 struct snd_dbuf *b = c->bufhard; in chn_flush()
922 CHN_LOCKASSERT(c); in chn_flush()
923 KASSERT(c->direction == PCMDIR_PLAY, ("chn_flush on bad channel")); in chn_flush()
924 DEB(printf("chn_flush: c->flags 0x%08x\n", c->flags)); in chn_flush()
926 c->flags |= CHN_F_CLOSING; in chn_flush()
927 chn_sync(c, 0); in chn_flush()
928 c->flags &= ~CHN_F_TRIGGERED; in chn_flush()
930 chn_trigger(c, PCMTRIG_ABORT); in chn_flush()
933 c->flags &= ~CHN_F_CLOSING; in chn_flush()
1078 afmt_tab[i].name, ch - ext, ext); in snd_afmt2str()
1085 chn_reset(struct pcm_channel *c, uint32_t fmt, uint32_t spd) in chn_reset() argument
1089 CHN_LOCKASSERT(c); in chn_reset()
1090 c->feedcount = 0; in chn_reset()
1091 c->flags &= CHN_F_RESET; in chn_reset()
1092 c->interrupts = 0; in chn_reset()
1093 c->timeout = 1; in chn_reset()
1094 c->xruns = 0; in chn_reset()
1096 c->flags |= (pcm_getflags(c->dev) & SD_F_BITPERFECT) ? in chn_reset()
1099 r = CHANNEL_RESET(c->methods, c->devinfo); in chn_reset()
1101 r = chn_setparam(c, fmt, spd); in chn_reset()
1106 r = chn_setformat(c, fmt); in chn_reset()
1108 r = chn_setspeed(c, spd); in chn_reset()
1110 r = chn_setlatency(c, chn_latency); in chn_reset()
1112 chn_resetbuf(c); in chn_reset()
1113 r = CHANNEL_RESETDONE(c->methods, c->devinfo); in chn_reset()
1123 return (d->p_unr); in chn_getunr()
1125 return (d->vp_unr); in chn_getunr()
1127 return (d->r_unr); in chn_getunr()
1129 return (d->vr_unr); in chn_getunr()
1137 chn_mkname(char *buf, size_t len, struct pcm_channel *c) in chn_mkname() argument
1144 switch (c->type) { in chn_mkname()
1162 device_get_unit(c->dev), str, c->unit); in chn_mkname()
1171 struct pcm_channel *c; in chn_init() local
1190 device_printf(d->dev, in chn_init()
1200 c = malloc(sizeof(*c), M_DEVBUF, M_WAITOK | M_ZERO); in chn_init()
1201 c->methods = kobj_create(cls, M_DEVBUF, M_WAITOK | M_ZERO); in chn_init()
1202 chn_lockinit(c, dir); in chn_init()
1203 CHN_INIT(c, children); in chn_init()
1204 CHN_INIT(c, children.busy); in chn_init()
1205 c->direction = direction; in chn_init()
1206 c->type = dir; in chn_init()
1207 c->unit = alloc_unr(chn_getunr(d, c->type)); in chn_init()
1208 c->format = SND_FORMAT(AFMT_U8, 1, 0); in chn_init()
1209 c->speed = DSP_DEFAULT_SPEED; in chn_init()
1210 c->pid = -1; in chn_init()
1211 c->latency = -1; in chn_init()
1212 c->timeout = 1; in chn_init()
1213 strlcpy(c->comm, CHN_COMM_UNUSED, sizeof(c->comm)); in chn_init()
1214 c->parentsnddev = d; in chn_init()
1215 c->parentchannel = parent; in chn_init()
1216 c->dev = d->dev; in chn_init()
1217 c->trigger = PCMTRIG_STOP; in chn_init()
1218 strlcpy(c->name, chn_mkname(buf, sizeof(buf), c), sizeof(c->name)); in chn_init()
1220 c->matrix = *feeder_matrix_id_map(SND_CHN_MATRIX_1_0); in chn_init()
1221 c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL; in chn_init()
1224 c->volume[SND_VOL_C_MASTER][i] = SND_VOL_0DB_MASTER; in chn_init()
1226 c->volume[SND_VOL_C_MASTER][SND_CHN_T_VOL_0DB] = SND_VOL_0DB_MASTER; in chn_init()
1227 c->volume[SND_VOL_C_PCM][SND_CHN_T_VOL_0DB] = chn_vol_0db_pcm; in chn_init()
1229 CHN_LOCK(c); in chn_init()
1230 chn_vpc_reset(c, SND_VOL_C_PCM, 1); in chn_init()
1231 CHN_UNLOCK(c); in chn_init()
1235 device_printf(d->dev, "%s(): failed to get feeder class\n", in chn_init()
1239 if (feeder_add(c, fc, NULL)) { in chn_init()
1240 device_printf(d->dev, "%s(): failed to add feeder\n", __func__); in chn_init()
1244 b = sndbuf_create(c->dev, c->name, "primary", c); in chn_init()
1245 bs = sndbuf_create(c->dev, c->name, "secondary", c); in chn_init()
1247 device_printf(d->dev, "%s(): failed to create %s buffer\n", in chn_init()
1251 c->bufhard = b; in chn_init()
1252 c->bufsoft = bs; in chn_init()
1254 c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, direction); in chn_init()
1255 if (c->devinfo == NULL) { in chn_init()
1256 device_printf(d->dev, "%s(): CHANNEL_INIT() failed\n", __func__); in chn_init()
1260 if ((sndbuf_getsize(b) == 0) && ((c->flags & CHN_F_VIRTUAL) == 0)) { in chn_init()
1261 device_printf(d->dev, "%s(): hardware buffer's size is 0\n", in chn_init()
1266 sndbuf_setfmt(b, c->format); in chn_init()
1267 sndbuf_setspd(b, c->speed); in chn_init()
1268 sndbuf_setfmt(bs, c->format); in chn_init()
1269 sndbuf_setspd(bs, c->speed); in chn_init()
1277 if (c->direction == PCMDIR_PLAY) { in chn_init()
1278 bs->sl = sndbuf_getmaxsize(bs); in chn_init()
1279 bs->shadbuf = malloc(bs->sl, M_DEVBUF, M_WAITOK); in chn_init()
1283 CHN_INSERT_SORT_ASCEND(d, c, channels.pcm); in chn_init()
1285 switch (c->type) { in chn_init()
1287 d->playcount++; in chn_init()
1290 d->pvchancount++; in chn_init()
1293 d->reccount++; in chn_init()
1296 d->rvchancount++; in chn_init()
1302 return (c); in chn_init()
1305 free_unr(chn_getunr(d, c->type), c->unit); in chn_init()
1306 feeder_remove(c); in chn_init()
1307 if (c->devinfo && CHANNEL_FREE(c->methods, c->devinfo)) in chn_init()
1313 CHN_LOCK(c); in chn_init()
1314 chn_lockdestroy(c); in chn_init()
1316 kobj_delete(c->methods, M_DEVBUF); in chn_init()
1317 free(c, M_DEVBUF); in chn_init()
1325 chn_kill(struct pcm_channel *c) in chn_kill() argument
1327 struct snddev_info *d = c->parentsnddev; in chn_kill()
1328 struct snd_dbuf *b = c->bufhard; in chn_kill()
1329 struct snd_dbuf *bs = c->bufsoft; in chn_kill()
1331 PCM_BUSYASSERT(c->parentsnddev); in chn_kill()
1334 CHN_REMOVE(d, c, channels.pcm); in chn_kill()
1336 switch (c->type) { in chn_kill()
1338 d->playcount--; in chn_kill()
1341 d->pvchancount--; in chn_kill()
1344 d->reccount--; in chn_kill()
1347 d->rvchancount--; in chn_kill()
1354 if (CHN_STARTED(c)) { in chn_kill()
1355 CHN_LOCK(c); in chn_kill()
1356 chn_trigger(c, PCMTRIG_ABORT); in chn_kill()
1357 CHN_UNLOCK(c); in chn_kill()
1359 free_unr(chn_getunr(c->parentsnddev, c->type), c->unit); in chn_kill()
1360 feeder_remove(c); in chn_kill()
1361 if (CHANNEL_FREE(c->methods, c->devinfo)) in chn_kill()
1365 CHN_LOCK(c); in chn_kill()
1366 c->flags |= CHN_F_DEAD; in chn_kill()
1367 chn_lockdestroy(c); in chn_kill()
1368 kobj_delete(c->methods, M_DEVBUF); in chn_kill()
1369 free(c, M_DEVBUF); in chn_kill()
1373 chn_shutdown(struct pcm_channel *c) in chn_shutdown() argument
1375 CHN_LOCKASSERT(c); in chn_shutdown()
1377 chn_wakeup(c); in chn_shutdown()
1378 c->flags |= CHN_F_DEAD; in chn_shutdown()
1383 chn_release(struct pcm_channel *c) in chn_release() argument
1385 PCM_BUSYASSERT(c->parentsnddev); in chn_release()
1386 CHN_LOCKASSERT(c); in chn_release()
1388 c->flags &= ~CHN_F_BUSY; in chn_release()
1389 c->pid = -1; in chn_release()
1390 strlcpy(c->comm, CHN_COMM_UNUSED, sizeof(c->comm)); in chn_release()
1391 CHN_UNLOCK(c); in chn_release()
1397 chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right, in chn_setvolume_multi() argument
1406 ret |= chn_setvolume_matrix(c, vc, i, left); in chn_setvolume_multi()
1408 ret |= chn_setvolume_matrix(c, vc, i, right) << 8; in chn_setvolume_multi()
1410 ret |= chn_setvolume_matrix(c, vc, i, center) << 16; in chn_setvolume_multi()
1417 chn_setvolume_matrix(struct pcm_channel *c, int vc, int vt, int val) in chn_setvolume_matrix() argument
1421 KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && in chn_setvolume_matrix()
1426 ("%s(): invalid volume matrix c=%p vc=%d vt=%d val=%d", in chn_setvolume_matrix()
1427 __func__, c, vc, vt, val)); in chn_setvolume_matrix()
1428 CHN_LOCKASSERT(c); in chn_setvolume_matrix()
1435 c->volume[vc][vt] = val; in chn_setvolume_matrix()
1444 c->volume[SND_VOL_C_VAL(vc)][vt] = in chn_setvolume_matrix()
1445 SND_VOL_CALC_VAL(c->volume, vc, vt); in chn_setvolume_matrix()
1450 c->volume[SND_VOL_C_VAL(vc)][i] = in chn_setvolume_matrix()
1451 SND_VOL_CALC_VAL(c->volume, vc, i); in chn_setvolume_matrix()
1454 c->volume[SND_VOL_C_VAL(vc)][vt] = in chn_setvolume_matrix()
1455 SND_VOL_CALC_VAL(c->volume, vc, vt); in chn_setvolume_matrix()
1462 chn_getvolume_matrix(struct pcm_channel *c, int vc, int vt) in chn_getvolume_matrix() argument
1464 KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && in chn_getvolume_matrix()
1467 ("%s(): invalid volume matrix c=%p vc=%d vt=%d", in chn_getvolume_matrix()
1468 __func__, c, vc, vt)); in chn_getvolume_matrix()
1469 CHN_LOCKASSERT(c); in chn_getvolume_matrix()
1471 return (c->volume[vc][vt]); in chn_getvolume_matrix()
1475 chn_setmute_multi(struct pcm_channel *c, int vc, int mute) in chn_setmute_multi() argument
1483 ret |= chn_setmute_matrix(c, vc, i, mute); in chn_setmute_multi()
1485 ret |= chn_setmute_matrix(c, vc, i, mute) << 8; in chn_setmute_multi()
1487 ret |= chn_setmute_matrix(c, vc, i, mute) << 16; in chn_setmute_multi()
1493 chn_setmute_matrix(struct pcm_channel *c, int vc, int vt, int mute) in chn_setmute_matrix() argument
1497 KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && in chn_setmute_matrix()
1500 ("%s(): invalid mute matrix c=%p vc=%d vt=%d mute=%d", in chn_setmute_matrix()
1501 __func__, c, vc, vt, mute)); in chn_setmute_matrix()
1503 CHN_LOCKASSERT(c); in chn_setmute_matrix()
1507 c->muted[vc][vt] = mute; in chn_setmute_matrix()
1516 c->muted[SND_VOL_C_VAL(vc)][vt] = mute; in chn_setmute_matrix()
1521 c->muted[SND_VOL_C_VAL(vc)][i] = mute; in chn_setmute_matrix()
1524 c->muted[SND_VOL_C_VAL(vc)][vt] = mute; in chn_setmute_matrix()
1531 chn_getmute_matrix(struct pcm_channel *c, int vc, int vt) in chn_getmute_matrix() argument
1533 KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && in chn_getmute_matrix()
1536 ("%s(): invalid mute matrix c=%p vc=%d vt=%d", in chn_getmute_matrix()
1537 __func__, c, vc, vt)); in chn_getmute_matrix()
1538 CHN_LOCKASSERT(c); in chn_getmute_matrix()
1540 return (c->muted[vc][vt]); in chn_getmute_matrix()
1544 chn_getmatrix(struct pcm_channel *c) in chn_getmatrix() argument
1547 KASSERT(c != NULL, ("%s(): NULL channel", __func__)); in chn_getmatrix()
1548 CHN_LOCKASSERT(c); in chn_getmatrix()
1550 if (!(c->format & AFMT_CONVERTIBLE)) in chn_getmatrix()
1553 return (&c->matrix); in chn_getmatrix()
1557 chn_setmatrix(struct pcm_channel *c, struct pcmchan_matrix *m) in chn_setmatrix() argument
1560 KASSERT(c != NULL && m != NULL, in chn_setmatrix()
1562 CHN_LOCKASSERT(c); in chn_setmatrix()
1564 if (!(c->format & AFMT_CONVERTIBLE)) in chn_setmatrix()
1567 c->matrix = *m; in chn_setmatrix()
1568 c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL; in chn_setmatrix()
1570 return (chn_setformat(c, SND_FORMAT(c->format, m->channels, m->ext))); in chn_setmatrix()
1577 chn_oss_getorder(struct pcm_channel *c, unsigned long long *map) in chn_oss_getorder() argument
1580 KASSERT(c != NULL && map != NULL, in chn_oss_getorder()
1582 CHN_LOCKASSERT(c); in chn_oss_getorder()
1584 if (!(c->format & AFMT_CONVERTIBLE)) in chn_oss_getorder()
1587 return (feeder_matrix_oss_get_channel_order(&c->matrix, map)); in chn_oss_getorder()
1591 chn_oss_setorder(struct pcm_channel *c, unsigned long long *map) in chn_oss_setorder() argument
1596 KASSERT(c != NULL && map != NULL, in chn_oss_setorder()
1598 CHN_LOCKASSERT(c); in chn_oss_setorder()
1600 if (!(c->format & AFMT_CONVERTIBLE)) in chn_oss_setorder()
1603 m = c->matrix; in chn_oss_setorder()
1608 return (chn_setmatrix(c, &m)); in chn_oss_setorder()
1617 chn_oss_getmask(struct pcm_channel *c, uint32_t *retmask) in chn_oss_getmask() argument
1623 KASSERT(c != NULL && retmask != NULL, in chn_oss_getmask()
1625 CHN_LOCKASSERT(c); in chn_oss_getmask()
1627 caps = chn_getcaps(c); in chn_oss_getmask()
1628 if (caps == NULL || caps->fmtlist == NULL) in chn_oss_getmask()
1631 for (i = 0; caps->fmtlist[i] != 0; i++) { in chn_oss_getmask()
1632 format = caps->fmtlist[i]; in chn_oss_getmask()
1637 m = CHANNEL_GETMATRIX(c->methods, c->devinfo, format); in chn_oss_getmask()
1640 if (m->mask & SND_CHN_OSS_FRONT) in chn_oss_getmask()
1642 if (m->mask & SND_CHN_OSS_SURR) in chn_oss_getmask()
1644 if (m->mask & SND_CHN_OSS_CENTER_LFE) in chn_oss_getmask()
1646 if (m->mask & SND_CHN_OSS_REAR) in chn_oss_getmask()
1650 /* report software-supported binding mask */ in chn_oss_getmask()
1651 if (!CHN_BITPERFECT(c) && report_soft_matrix) in chn_oss_getmask()
1659 chn_vpc_reset(struct pcm_channel *c, int vc, int force) in chn_vpc_reset() argument
1663 KASSERT(c != NULL && vc >= SND_VOL_C_BEGIN && vc <= SND_VOL_C_END, in chn_vpc_reset()
1664 ("%s(): invalid reset c=%p vc=%d", __func__, c, vc)); in chn_vpc_reset()
1665 CHN_LOCKASSERT(c); in chn_vpc_reset()
1671 CHN_SETVOLUME(c, vc, i, c->volume[vc][SND_CHN_T_VOL_0DB]); in chn_vpc_reset()
1684 ret = 1 << (ret - 1); in round_pow2()
1703 tmp = ret - (ret % round); in round_blksz()
1706 tmp = ret - (ret % round); in round_blksz()
1719 * +---------+------------+-----------+------------+
1721 * +---------+------------+-----------+------------+
1723 * +---------+------------+-----------+------------+
1725 * +---------+------------+-----------+------------+
1727 * +---------+------------+-----------+------------+
1729 * +---------+------------+-----------+------------+
1731 * +---------+------------+-----------+------------+
1733 * +---------+------------+-----------+------------+
1735 * +---------+------------+-----------+------------+
1737 * +---------+------------+-----------+------------+
1739 * +---------+------------+-----------+------------+
1741 * +---------+------------+-----------+------------+
1743 * +---------+------------+-----------+------------+
1750 * +---------+------------+-----------+------------+
1752 * +---------+------------+-----------+------------+
1754 * +---------+------------+-----------+------------+
1756 * +---------+------------+-----------+------------+
1758 * +---------+------------+-----------+------------+
1760 * +---------+------------+-----------+------------+
1762 * +---------+------------+-----------+------------+
1764 * +---------+------------+-----------+------------+
1766 * +---------+------------+-----------+------------+
1768 * +---------+------------+-----------+------------+
1770 * +---------+------------+-----------+------------+
1772 * +---------+------------+-----------+------------+
1774 * +---------+------------+-----------+------------+
1853 chn_resizebuf(struct pcm_channel *c, int latency, in chn_resizebuf() argument
1860 CHN_LOCKASSERT(c); in chn_resizebuf()
1862 if ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) || in chn_resizebuf()
1863 !(c->direction == PCMDIR_PLAY || c->direction == PCMDIR_REC)) in chn_resizebuf()
1866 if (latency == -1) { in chn_resizebuf()
1867 c->latency = -1; in chn_resizebuf()
1869 } else if (latency == -2) { in chn_resizebuf()
1870 latency = c->latency; in chn_resizebuf()
1876 c->latency = latency; in chn_resizebuf()
1879 bs = c->bufsoft; in chn_resizebuf()
1880 b = c->bufhard; in chn_resizebuf()
1882 if (!(blksz == 0 || blkcnt == -1) && in chn_resizebuf()
1887 chn_calclatency(c->direction, latency, sndbuf_getalign(bs), in chn_resizebuf()
1891 if (blksz == 0 || blkcnt == -1) { in chn_resizebuf()
1892 if (blkcnt == -1) in chn_resizebuf()
1893 c->flags &= ~CHN_F_HAS_SIZE; in chn_resizebuf()
1894 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1899 c->flags |= CHN_F_HAS_SIZE; in chn_resizebuf()
1901 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1913 if (c->parentchannel != NULL) { in chn_resizebuf()
1914 pb = c->parentchannel->bufsoft; in chn_resizebuf()
1915 CHN_UNLOCK(c); in chn_resizebuf()
1916 CHN_LOCK(c->parentchannel); in chn_resizebuf()
1917 chn_notify(c->parentchannel, CHN_N_BLOCKSIZE); in chn_resizebuf()
1918 CHN_UNLOCK(c->parentchannel); in chn_resizebuf()
1919 CHN_LOCK(c); in chn_resizebuf()
1920 if (c->direction == PCMDIR_PLAY) { in chn_resizebuf()
1929 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1934 chn_calclatency(c->direction, latency, in chn_resizebuf()
1950 hblksz -= hblksz % sndbuf_getalign(b); in chn_resizebuf()
1952 CHN_UNLOCK(c); in chn_resizebuf()
1954 CHANNEL_SETFRAGMENTS(c->methods, c->devinfo, in chn_resizebuf()
1956 sndbuf_setblksz(b, CHANNEL_SETBLOCKSIZE(c->methods, in chn_resizebuf()
1957 c->devinfo, hblksz)); in chn_resizebuf()
1958 CHN_LOCK(c); in chn_resizebuf()
1960 if (!CHN_EMPTY(c, children)) { in chn_resizebuf()
1965 if (c->direction == PCMDIR_PLAY) { in chn_resizebuf()
1967 nsblkcnt--; in chn_resizebuf()
1992 sblksz -= sblksz % sndbuf_getalign(bs); in chn_resizebuf()
1998 device_printf(c->dev, "%s(): Failed: %d %d\n", in chn_resizebuf()
2007 c->timeout = ((u_int64_t)hz * sndbuf_getsize(bs)) / in chn_resizebuf()
2009 if (c->parentchannel != NULL) in chn_resizebuf()
2010 c->timeout = min(c->timeout, c->parentchannel->timeout); in chn_resizebuf()
2011 if (c->timeout < 1) in chn_resizebuf()
2012 c->timeout = 1; in chn_resizebuf()
2018 c->lw = sndbuf_getblksz(bs); in chn_resizebuf()
2019 chn_resetbuf(c); in chn_resizebuf()
2022 device_printf(c->dev, "%s(): %s (%s) timeout=%u " in chn_resizebuf()
2024 __func__, CHN_DIRSTR(c), in chn_resizebuf()
2025 (c->flags & CHN_F_VIRTUAL) ? "virtual" : "hardware", in chn_resizebuf()
2026 c->timeout, in chn_resizebuf()
2036 chn_setlatency(struct pcm_channel *c, int latency) in chn_setlatency() argument
2038 CHN_LOCKASSERT(c); in chn_setlatency()
2040 return chn_resizebuf(c, latency, -1, 0); in chn_setlatency()
2044 chn_setblocksize(struct pcm_channel *c, int blkcnt, int blksz) in chn_setblocksize() argument
2046 CHN_LOCKASSERT(c); in chn_setblocksize()
2048 return chn_resizebuf(c, -1, blkcnt, blksz); in chn_setblocksize()
2052 chn_setparam(struct pcm_channel *c, uint32_t format, uint32_t speed) in chn_setparam() argument
2058 CHN_LOCKASSERT(c); in chn_setparam()
2060 if (speed < 1 || format == 0 || CHN_STARTED(c)) in chn_setparam()
2063 c->format = format; in chn_setparam()
2064 c->speed = speed; in chn_setparam()
2066 caps = chn_getcaps(c); in chn_setparam()
2069 RANGE(hwspeed, caps->minspeed, caps->maxspeed); in chn_setparam()
2071 sndbuf_setspd(c->bufhard, CHANNEL_SETSPEED(c->methods, c->devinfo, in chn_setparam()
2073 hwspeed = sndbuf_getspd(c->bufhard); in chn_setparam()
2075 delta = (hwspeed > speed) ? (hwspeed - speed) : (speed - hwspeed); in chn_setparam()
2078 c->speed = hwspeed; in chn_setparam()
2080 ret = feeder_chain(c); in chn_setparam()
2083 ret = CHANNEL_SETFORMAT(c->methods, c->devinfo, in chn_setparam()
2084 sndbuf_getfmt(c->bufhard)); in chn_setparam()
2087 ret = chn_resizebuf(c, -2, 0, 0); in chn_setparam()
2093 chn_setspeed(struct pcm_channel *c, uint32_t speed) in chn_setspeed() argument
2098 oldformat = c->format; in chn_setspeed()
2099 oldspeed = c->speed; in chn_setspeed()
2102 ret = chn_setparam(c, format, speed); in chn_setspeed()
2105 device_printf(c->dev, in chn_setspeed()
2109 chn_setparam(c, c->format, oldspeed); in chn_setspeed()
2116 chn_setformat(struct pcm_channel *c, uint32_t format) in chn_setformat() argument
2127 oldformat = c->format; in chn_setformat()
2128 oldspeed = c->speed; in chn_setformat()
2131 ret = chn_setparam(c, format, speed); in chn_setformat()
2134 device_printf(c->dev, in chn_setformat()
2138 chn_setparam(c, oldformat, oldspeed); in chn_setformat()
2145 chn_syncstate(struct pcm_channel *c) in chn_syncstate() argument
2150 d = (c != NULL) ? c->parentsnddev : NULL; in chn_syncstate()
2151 m = (d != NULL && d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 : in chn_syncstate()
2157 CHN_LOCKASSERT(c); in chn_syncstate()
2159 if (c->feederflags & (1 << FEEDER_VOLUME)) { in chn_syncstate()
2163 if (c->direction == PCMDIR_PLAY && in chn_syncstate()
2164 (d->flags & SD_F_SOFTPCMVOL)) { in chn_syncstate()
2165 /* CHN_UNLOCK(c); */ in chn_syncstate()
2172 /* CHN_LOCK(c); */ in chn_syncstate()
2178 if (vol == -1) { in chn_syncstate()
2179 device_printf(c->dev, in chn_syncstate()
2185 if (pvol == -1) { in chn_syncstate()
2186 device_printf(c->dev, in chn_syncstate()
2196 chn_setvolume_multi(c, SND_VOL_C_MASTER, left, right, center); in chn_syncstate()
2199 if (c->feederflags & (1 << FEEDER_EQ)) { in chn_syncstate()
2203 /* CHN_UNLOCK(c); */ in chn_syncstate()
2206 /* CHN_LOCK(c); */ in chn_syncstate()
2208 if (treble == -1) in chn_syncstate()
2214 if (bass == -1) in chn_syncstate()
2219 f = feeder_find(c, FEEDER_EQ); in chn_syncstate()
2222 device_printf(c->dev, in chn_syncstate()
2223 "EQ: Failed to set treble -- %d\n", in chn_syncstate()
2226 device_printf(c->dev, in chn_syncstate()
2227 "EQ: Failed to set bass -- %d\n", in chn_syncstate()
2229 if (FEEDER_SET(f, FEEDEQ_PREAMP, d->eqpreamp) != 0) in chn_syncstate()
2230 device_printf(c->dev, in chn_syncstate()
2231 "EQ: Failed to set preamp -- %d\n", in chn_syncstate()
2232 d->eqpreamp); in chn_syncstate()
2233 if (d->flags & SD_F_EQ_BYPASSED) in chn_syncstate()
2235 else if (d->flags & SD_F_EQ_ENABLED) in chn_syncstate()
2240 device_printf(c->dev, in chn_syncstate()
2241 "EQ: Failed to set state -- %d\n", state); in chn_syncstate()
2247 chn_trigger(struct pcm_channel *c, int go) in chn_trigger() argument
2249 struct snddev_info *d = c->parentsnddev; in chn_trigger()
2252 CHN_LOCKASSERT(c); in chn_trigger()
2254 return (CHANNEL_TRIGGER(c->methods, c->devinfo, go)); in chn_trigger()
2256 if (go == c->trigger) in chn_trigger()
2260 device_printf(c->dev, "%s() %s: calling go=0x%08x , " in chn_trigger()
2261 "prev=0x%08x\n", __func__, c->name, go, c->trigger); in chn_trigger()
2264 c->trigger = go; in chn_trigger()
2265 ret = CHANNEL_TRIGGER(c->methods, c->devinfo, go); in chn_trigger()
2269 CHN_UNLOCK(c); in chn_trigger()
2271 CHN_LOCK(c); in chn_trigger()
2277 if (go != c->trigger) { in chn_trigger()
2288 CHN_INSERT_HEAD_SAFE(d, c, channels.pcm.busy); in chn_trigger()
2290 chn_syncstate(c); in chn_trigger()
2294 CHN_REMOVE(d, c, channels.pcm.busy); in chn_trigger()
2306 * @brief Queries sound driver for sample-aligned hardware buffer pointer index
2309 * the current bytes-per-sample value before returning. (E.g., a channel
2311 * hwptr value ranging from 32-35 would be returned as 32.)
2313 * @param c PCM channel context
2314 * @returns sample-aligned hardware buffer pointer index
2317 chn_getptr(struct pcm_channel *c) in chn_getptr() argument
2321 CHN_LOCKASSERT(c); in chn_getptr()
2322 hwptr = (CHN_STARTED(c)) ? CHANNEL_GETPTR(c->methods, c->devinfo) : 0; in chn_getptr()
2323 return (hwptr - (hwptr % sndbuf_getalign(c->bufhard))); in chn_getptr()
2327 chn_getcaps(struct pcm_channel *c) in chn_getcaps() argument
2329 CHN_LOCKASSERT(c); in chn_getcaps()
2330 return CHANNEL_GETCAPS(c->methods, c->devinfo); in chn_getcaps()
2334 chn_getformats(struct pcm_channel *c) in chn_getformats() argument
2339 fmtlist = chn_getcaps(c)->fmtlist; in chn_getformats()
2344 /* report software-supported formats */ in chn_getformats()
2345 if (!CHN_BITPERFECT(c) && report_soft_formats) in chn_getformats()
2352 chn_notify(struct pcm_channel *c, u_int32_t flags) in chn_notify() argument
2360 CHN_LOCKASSERT(c); in chn_notify()
2362 if (CHN_EMPTY(c, children)) in chn_notify()
2371 run = (CHN_STARTED(c)) ? 1 : 0; in chn_notify()
2403 chn_setlatency(c, chn_latency); in chn_notify()
2406 if ((flags & CHN_N_TRIGGER) && !(c->flags & CHN_F_VCHAN_DYNAMIC)) { in chn_notify()
2407 nrun = CHN_EMPTY(c, children.busy) ? 0 : 1; in chn_notify()
2409 err = chn_start(c, 1); in chn_notify()
2411 chn_abort(c); in chn_notify()
2416 if (c->direction == PCMDIR_PLAY) { in chn_notify()
2417 vchanformat = &c->parentsnddev->pvchanformat; in chn_notify()
2418 vchanrate = &c->parentsnddev->pvchanrate; in chn_notify()
2420 vchanformat = &c->parentsnddev->rvchanformat; in chn_notify()
2421 vchanrate = &c->parentsnddev->rvchanrate; in chn_notify()
2425 if (!(c->flags & CHN_F_VCHAN_ADAPTIVE)) { in chn_notify()
2435 caps = chn_getcaps(c); in chn_notify()
2439 CHN_FOREACH(ch, c, children.busy) { in chn_notify()
2441 if ((ch->format & AFMT_PASSTHROUGH) && in chn_notify()
2442 snd_fmtvalid(ch->format, caps->fmtlist)) { in chn_notify()
2443 bestformat = ch->format; in chn_notify()
2444 bestspeed = ch->speed; in chn_notify()
2450 if ((ch->flags & CHN_F_EXCLUSIVE) && vpflags == 0) { in chn_notify()
2451 if (c->flags & CHN_F_VCHAN_ADAPTIVE) { in chn_notify()
2452 bestspeed = ch->speed; in chn_notify()
2453 RANGE(bestspeed, caps->minspeed, in chn_notify()
2454 caps->maxspeed); in chn_notify()
2455 besthwformat = snd_fmtbest(ch->format, in chn_notify()
2456 caps->fmtlist); in chn_notify()
2465 if (!(c->flags & CHN_F_VCHAN_ADAPTIVE) || in chn_notify()
2471 if (ch->speed > bestspeed) { in chn_notify()
2472 bestspeed = ch->speed; in chn_notify()
2473 RANGE(bestspeed, caps->minspeed, in chn_notify()
2474 caps->maxspeed); in chn_notify()
2476 besthwformat = snd_fmtbest(ch->format, caps->fmtlist); in chn_notify()
2494 bestformat = c->format; in chn_notify()
2496 bestspeed = c->speed; in chn_notify()
2498 if (bestformat != c->format || bestspeed != c->speed) in chn_notify()
2501 c->flags &= ~(CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE); in chn_notify()
2502 c->flags |= vpflags; in chn_notify()
2506 bestspeed = CHANNEL_SETSPEED(c->methods, in chn_notify()
2507 c->devinfo, bestspeed); in chn_notify()
2508 err = chn_reset(c, bestformat, bestspeed); in chn_notify()
2511 CHN_FOREACH(ch, c, children.busy) { in chn_notify()
2520 c->flags |= CHN_F_DIRTY; in chn_notify()
2521 err = chn_start(c, 1); in chn_notify()
2526 chn_abort(c); in chn_notify()
2527 bestspeed = CHANNEL_SETSPEED(c->methods, c->devinfo, in chn_notify()
2529 err = chn_reset(c, bestformat, bestspeed); in chn_notify()
2531 CHN_FOREACH(ch, c, children.busy) { in chn_notify()
2539 c->flags |= CHN_F_DIRTY; in chn_notify()
2540 err = chn_start(c, 1); in chn_notify()
2551 c->flags &= ~(CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE); in chn_notify()
2554 chn_abort(c); in chn_notify()
2555 if (c->format != bestformat || c->speed != bestspeed) in chn_notify()
2556 chn_reset(c, bestformat, bestspeed); in chn_notify()
2571 * should examine rates @b only if this function returns non-zero.
2573 * @param c pcm channel to examine
2576 * @return number of rates in the array pointed to be @c rates
2579 chn_getrates(struct pcm_channel *c, int **rates) in chn_getrates() argument
2582 CHN_LOCKASSERT(c); in chn_getrates()
2583 return CHANNEL_GETRATES(c->methods, c->devinfo, rates); in chn_getrates()
2590 * - Starting a syncgroup (@c SNDCTL_DSP_SYNCSTART ioctl)
2591 * - Closing a device. (A channel can't be destroyed if it's still in use.)
2595 * whether @c c is locked or not.)
2597 * @param c channel device to be started or closed
2604 chn_syncdestroy(struct pcm_channel *c) in chn_syncdestroy() argument
2614 if (c->sm != NULL) { in chn_syncdestroy()
2615 sm = c->sm; in chn_syncdestroy()
2616 sg = sm->parent; in chn_syncdestroy()
2617 c->sm = NULL; in chn_syncdestroy()
2621 SLIST_REMOVE(&sg->members, sm, pcmchan_syncmember, link); in chn_syncdestroy()
2624 if (SLIST_EMPTY(&sg->members)) { in chn_syncdestroy()
2626 sg_id = sg->id; in chn_syncdestroy()
2636 chn_getpeaks(struct pcm_channel *c, int *lpeak, int *rpeak) in chn_getpeaks() argument
2638 CHN_LOCKASSERT(c); in chn_getpeaks()
2639 return CHANNEL_GETPEAKS(c->methods, c->devinfo, lpeak, rpeak); in chn_getpeaks()