Lines Matching +full:report +full:- +full:speed +full:- +full:hz
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
7 * Portions Copyright (c) Luigi Rizzo <luigi@FreeBSD.org> - 1997-99
9 * Copyright (c) 2024-2025 The FreeBSD Foundation
47 &report_soft_formats, 0, "report software-emulated formats");
51 &report_soft_matrix, 0, "report software-emulated channel matrixing");
62 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_latency()
85 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_latency_profile()
108 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_timeout()
120 "interrupt timeout (1 - 10) seconds");
164 if (err != 0 || req->newptr == NULL) in sysctl_hw_snd_vpc_0db()
186 if (err != 0 || req->newptr == NULL || val == 0) in sysctl_hw_snd_vpc_reset()
200 static int chn_syncdelay = -1;
206 "append (0-1000) millisecond trailing buffer delay on each sync");
231 c->lock = snd_mtxcreate(c->name, "pcm play channel"); in chn_lockinit()
232 cv_init(&c->intr_cv, "pcmwr"); in chn_lockinit()
235 c->lock = snd_mtxcreate(c->name, "pcm virtual play channel"); in chn_lockinit()
236 cv_init(&c->intr_cv, "pcmwrv"); in chn_lockinit()
239 c->lock = snd_mtxcreate(c->name, "pcm record channel"); in chn_lockinit()
240 cv_init(&c->intr_cv, "pcmrd"); in chn_lockinit()
243 c->lock = snd_mtxcreate(c->name, "pcm virtual record channel"); in chn_lockinit()
244 cv_init(&c->intr_cv, "pcmrdv"); in chn_lockinit()
251 cv_init(&c->cv, "pcmchn"); in chn_lockinit()
259 CHN_BROADCAST(&c->cv); in chn_lockdestroy()
260 CHN_BROADCAST(&c->intr_cv); in chn_lockdestroy()
262 cv_destroy(&c->cv); in chn_lockdestroy()
263 cv_destroy(&c->intr_cv); in chn_lockdestroy()
265 snd_mtxfree(c->lock); in chn_lockdestroy()
277 struct snd_dbuf *bs = c->bufsoft; in chn_polltrigger()
282 if (c->flags & CHN_F_MMAP) { in chn_polltrigger()
283 if (sndbuf_getprevtotal(bs) < c->lw) in chn_polltrigger()
284 delta = c->lw; in chn_polltrigger()
286 delta = sndbuf_gettotal(bs) - sndbuf_getprevtotal(bs); in chn_polltrigger()
288 if (c->direction == PCMDIR_PLAY) in chn_polltrigger()
294 return ((delta < c->lw) ? 0 : 1); in chn_polltrigger()
302 sndbuf_updateprevtotal(c->bufsoft); in chn_pollreset()
313 bs = c->bufsoft; in chn_wakeup()
318 CHN_BROADCAST(&c->intr_cv); in chn_wakeup()
335 if (c->flags & CHN_F_DEAD) in chn_sleep()
338 c->sleeping++; in chn_sleep()
339 ret = cv_timedwait_sig(&c->intr_cv, c->lock, timeout); in chn_sleep()
340 c->sleeping--; in chn_sleep()
342 return ((c->flags & CHN_F_DEAD) ? EINVAL : ret); in chn_sleep()
353 struct snd_dbuf *b = c->bufhard; in chn_dmaupdate()
361 delta = (sndbuf_getsize(b) + hwptr - old) % sndbuf_getsize(b); in chn_dmaupdate()
364 if (c->direction == PCMDIR_PLAY) { in chn_dmaupdate()
366 amt -= amt % sndbuf_getalign(b); in chn_dmaupdate()
371 amt -= amt % sndbuf_getalign(b); in chn_dmaupdate()
376 device_printf(c->dev, "WARNING: %s DMA completion " in chn_dmaupdate()
389 struct snd_dbuf *b = c->bufhard; in chn_wrfeed()
390 struct snd_dbuf *bs = c->bufsoft; in chn_wrfeed()
395 if ((c->flags & CHN_F_MMAP) && !(c->flags & CHN_F_CLOSING)) in chn_wrfeed()
400 imax(0, sndbuf_xbytes(sndbuf_getsize(bs), bs, b) - in chn_wrfeed()
404 sndbuf_feed(bs, b, c, c->feeder, amt); in chn_wrfeed()
410 c->xruns++; in chn_wrfeed()
430 * user write routine - uiomove data into secondary buffer, trigger if necessary
439 struct snd_dbuf *bs = c->bufsoft; in chn_write()
446 timeout = chn_timeout * hz; in chn_write()
448 while (ret == 0 && buf->uio_resid > 0) { in chn_write()
449 sz = min(buf->uio_resid, sndbuf_getfree(bs)); in chn_write()
454 * unlock-uiomove-lock sequence. in chn_write()
458 t = min(sz, sndbuf_getsize(bs) - p); in chn_write()
463 sz -= t; in chn_write()
467 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { in chn_write()
470 c->flags |= CHN_F_DEAD; in chn_write()
472 } else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER)) { in chn_write()
488 c->flags |= CHN_F_DEAD; in chn_write()
489 device_printf(c->dev, "%s(): %s: " in chn_write()
491 __func__, c->name); in chn_write()
493 c->flags |= CHN_F_ABORTING; in chn_write()
506 struct snd_dbuf *b = c->bufhard; in chn_rdfeed()
507 struct snd_dbuf *bs = c->bufsoft; in chn_rdfeed()
512 if (c->flags & CHN_F_MMAP) in chn_rdfeed()
517 sndbuf_feed(b, bs, c, c->feeder, amt); in chn_rdfeed()
521 c->xruns++; in chn_rdfeed()
535 /* tell the driver to update the primary buffer if non-dma */ in chn_rdintr()
544 * user read routine - trigger if necessary, uiomove data from secondary buffer
553 struct snd_dbuf *bs = c->bufsoft; in chn_read()
559 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { in chn_read()
562 c->flags |= CHN_F_DEAD; in chn_read()
568 timeout = chn_timeout * hz; in chn_read()
570 while (ret == 0 && buf->uio_resid > 0) { in chn_read()
571 sz = min(buf->uio_resid, sndbuf_getready(bs)); in chn_read()
576 * unlock-uiomove-lock sequence. in chn_read()
580 t = min(sz, sndbuf_getsize(bs) - p); in chn_read()
585 sz -= t; in chn_read()
589 } else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER)) in chn_read()
595 c->flags |= CHN_F_DEAD; in chn_read()
596 device_printf(c->dev, "%s(): %s: " in chn_read()
598 __func__, c->name); in chn_read()
600 c->flags |= CHN_F_ABORTING; in chn_read()
613 c->interrupts++; in chn_intr_locked()
615 if (c->direction == PCMDIR_PLAY) in chn_intr_locked()
639 struct snd_dbuf *b = c->bufhard; in chn_start()
640 struct snd_dbuf *bs = c->bufsoft; in chn_start()
645 if (CHN_STARTED(c) || ((c->flags & CHN_F_NOTRIGGER) && !force)) in chn_start()
654 if (c->direction == PCMDIR_REC) { in chn_start()
670 device_printf(c->dev, "%s(): %s (%s) threshold " in chn_start()
672 (c->flags & CHN_F_VIRTUAL) ? "virtual" : in chn_start()
677 c->flags |= CHN_F_TRIGGERED; in chn_start()
679 if (c->flags & CHN_F_CLOSING) in chn_start()
680 c->feedcount = 2; in chn_start()
682 c->feedcount = 0; in chn_start()
683 c->interrupts = 0; in chn_start()
684 c->xruns = 0; in chn_start()
686 if (c->parentchannel == NULL) { in chn_start()
687 if (c->direction == PCMDIR_PLAY) in chn_start()
691 device_printf(c->dev, in chn_start()
696 (c->flags & CHN_F_HAS_VCHAN) ? in chn_start()
698 (c->flags & CHN_F_CLOSING) ? "closing" : in chn_start()
701 force, i, j, c->timeout, in chn_start()
714 struct snd_dbuf *b = c->bufhard; in chn_resetbuf()
715 struct snd_dbuf *bs = c->bufsoft; in chn_resetbuf()
717 c->blocks = 0; in chn_resetbuf()
736 if (c->direction != PCMDIR_PLAY) in chn_sync()
739 bs = c->bufsoft; in chn_sync()
741 if ((c->flags & (CHN_F_DEAD | CHN_F_ABORTING)) || in chn_sync()
755 b = CHN_BUF_PARENT(c, c->bufhard); in chn_sync()
765 * Append (0-1000) millisecond trailing buffer (if needed) in chn_sync()
773 minflush -= minflush % sndbuf_getalign(bs); in chn_sync()
779 minflush -= threshold; in chn_sync()
786 device_printf(c->dev, in chn_sync()
800 device_printf(c->dev, "%s(): [begin] timeout=%d count=%d " in chn_sync()
801 "minflush=%d resid=%d\n", __func__, c->timeout, count, in chn_sync()
804 cflag = c->flags & CHN_F_CLOSING; in chn_sync()
805 c->flags |= CHN_F_CLOSING; in chn_sync()
807 ret = chn_sleep(c, c->timeout); in chn_sync()
809 c->flags |= CHN_F_ABORTING; in chn_sync()
814 --count; in chn_sync()
816 device_printf(c->dev, in chn_sync()
820 __func__, c->timeout, count, in chn_sync()
825 device_printf(c->dev, in chn_sync()
829 __func__, c->timeout, count, in chn_sync()
838 minflush -= threshold; in chn_sync()
844 c->flags &= ~CHN_F_CLOSING; in chn_sync()
845 c->flags |= cflag; in chn_sync()
848 device_printf(c->dev, in chn_sync()
851 __func__, c->timeout, count, hcount, resid, residp, in chn_sync()
861 struct snd_dbuf *bs = c->bufsoft; in chn_poll()
866 if (!(c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED))) { in chn_poll()
892 struct snd_dbuf *b = c->bufhard; in chn_abort()
893 struct snd_dbuf *bs = c->bufsoft; in chn_abort()
898 c->flags |= CHN_F_ABORTING; in chn_abort()
900 c->flags &= ~CHN_F_TRIGGERED; in chn_abort()
904 if (!(c->flags & CHN_F_VIRTUAL)) in chn_abort()
908 c->flags &= ~CHN_F_ABORTING; in chn_abort()
926 struct snd_dbuf *b = c->bufhard; in chn_flush()
929 KASSERT(c->direction == PCMDIR_PLAY, ("chn_flush on bad channel")); in chn_flush()
930 DEB(printf("chn_flush: c->flags 0x%08x\n", c->flags)); in chn_flush()
932 c->flags |= CHN_F_CLOSING; in chn_flush()
934 c->flags &= ~CHN_F_TRIGGERED; in chn_flush()
939 c->flags &= ~CHN_F_CLOSING; in chn_flush()
1093 afmt_tab[i].name, ch - ext, ext); in snd_afmt2str()
1105 c->feedcount = 0; in chn_reset()
1106 c->flags &= CHN_F_RESET; in chn_reset()
1107 c->interrupts = 0; in chn_reset()
1108 c->timeout = 1; in chn_reset()
1109 c->xruns = 0; in chn_reset()
1111 c->flags |= (pcm_getflags(c->dev) & SD_F_BITPERFECT) ? in chn_reset()
1114 r = CHANNEL_RESET(c->methods, c->devinfo); in chn_reset()
1128 r = CHANNEL_RESETDONE(c->methods, c->devinfo); in chn_reset()
1138 return (d->p_unr); in chn_getunr()
1140 return (d->vp_unr); in chn_getunr()
1142 return (d->r_unr); in chn_getunr()
1144 return (d->vr_unr); in chn_getunr()
1159 switch (c->type) { in chn_mkname()
1177 device_get_unit(c->dev), str, c->unit); in chn_mkname()
1197 d->playcount++; in chn_init()
1201 d->pvchancount++; in chn_init()
1203 vchanrate = &d->pvchanrate; in chn_init()
1204 vchanformat = &d->pvchanformat; in chn_init()
1207 d->reccount++; in chn_init()
1211 d->rvchancount++; in chn_init()
1213 vchanrate = &d->rvchanrate; in chn_init()
1214 vchanformat = &d->rvchanformat; in chn_init()
1217 device_printf(d->dev, in chn_init()
1228 c->methods = kobj_create(cls, M_DEVBUF, M_WAITOK | M_ZERO); in chn_init()
1232 c->direction = direction; in chn_init()
1233 c->type = dir; in chn_init()
1234 c->unit = alloc_unr(chn_getunr(d, c->type)); in chn_init()
1235 c->format = SND_FORMAT(AFMT_S16_LE, 2, 0); in chn_init()
1236 c->speed = 48000; in chn_init()
1237 c->pid = -1; in chn_init()
1238 c->latency = -1; in chn_init()
1239 c->timeout = 1; in chn_init()
1240 strlcpy(c->comm, CHN_COMM_UNUSED, sizeof(c->comm)); in chn_init()
1241 c->parentsnddev = d; in chn_init()
1242 c->parentchannel = parent; in chn_init()
1243 c->dev = d->dev; in chn_init()
1244 c->trigger = PCMTRIG_STOP; in chn_init()
1245 strlcpy(c->name, chn_mkname(buf, sizeof(buf), c), sizeof(c->name)); in chn_init()
1247 c->matrix = *feeder_matrix_id_map(SND_CHN_MATRIX_1_0); in chn_init()
1248 c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL; in chn_init()
1251 c->volume[SND_VOL_C_MASTER][i] = SND_VOL_0DB_MASTER; in chn_init()
1253 c->volume[SND_VOL_C_MASTER][SND_CHN_T_VOL_0DB] = SND_VOL_0DB_MASTER; in chn_init()
1254 c->volume[SND_VOL_C_PCM][SND_CHN_T_VOL_0DB] = chn_vol_0db_pcm; in chn_init()
1262 device_printf(d->dev, "%s(): failed to get feeder class\n", in chn_init()
1267 device_printf(d->dev, "%s(): failed to add feeder\n", __func__); in chn_init()
1271 b = sndbuf_create(c->dev, c->name, "primary", c); in chn_init()
1272 bs = sndbuf_create(c->dev, c->name, "secondary", c); in chn_init()
1274 device_printf(d->dev, "%s(): failed to create %s buffer\n", in chn_init()
1278 c->bufhard = b; in chn_init()
1279 c->bufsoft = bs; in chn_init()
1281 c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, direction); in chn_init()
1282 if (c->devinfo == NULL) { in chn_init()
1283 device_printf(d->dev, "%s(): CHANNEL_INIT() failed\n", __func__); in chn_init()
1287 if ((sndbuf_getsize(b) == 0) && ((c->flags & CHN_F_VIRTUAL) == 0)) { in chn_init()
1288 device_printf(d->dev, "%s(): hardware buffer's size is 0\n", in chn_init()
1293 sndbuf_setfmt(b, c->format); in chn_init()
1294 sndbuf_setspd(b, c->speed); in chn_init()
1295 sndbuf_setfmt(bs, c->format); in chn_init()
1296 sndbuf_setspd(bs, c->speed); in chn_init()
1304 if (c->direction == PCMDIR_PLAY) { in chn_init()
1305 bs->sl = sndbuf_getmaxsize(bs); in chn_init()
1306 bs->shadbuf = malloc(bs->sl, M_DEVBUF, M_WAITOK); in chn_init()
1309 if ((c->flags & CHN_F_VIRTUAL) == 0) { in chn_init()
1311 err = chn_reset(c, c->format, c->speed); in chn_init()
1319 if ((c->flags & CHN_F_VIRTUAL) == 0) { in chn_init()
1322 *vchanrate = sndbuf_getspd(c->bufsoft); in chn_init()
1323 *vchanformat = sndbuf_getfmt(c->bufsoft); in chn_init()
1338 struct snddev_info *d = c->parentsnddev; in chn_kill()
1339 struct snd_dbuf *b = c->bufhard; in chn_kill()
1340 struct snd_dbuf *bs = c->bufsoft; in chn_kill()
1342 PCM_BUSYASSERT(c->parentsnddev); in chn_kill()
1346 if ((c->flags & CHN_F_VIRTUAL) == 0) in chn_kill()
1349 switch (c->type) { in chn_kill()
1351 d->playcount--; in chn_kill()
1354 d->pvchancount--; in chn_kill()
1357 d->reccount--; in chn_kill()
1360 d->rvchancount--; in chn_kill()
1372 free_unr(chn_getunr(d, c->type), c->unit); in chn_kill()
1374 if (c->devinfo && CHANNEL_FREE(c->methods, c->devinfo)) in chn_kill()
1381 c->flags |= CHN_F_DEAD; in chn_kill()
1383 kobj_delete(c->methods, M_DEVBUF); in chn_kill()
1393 c->flags |= CHN_F_DEAD; in chn_shutdown()
1400 PCM_BUSYASSERT(c->parentsnddev); in chn_release()
1403 c->flags &= ~CHN_F_BUSY; in chn_release()
1404 c->pid = -1; in chn_release()
1405 strlcpy(c->comm, CHN_COMM_UNUSED, sizeof(c->comm)); in chn_release()
1450 c->volume[vc][vt] = val; in chn_setvolume_matrix()
1459 c->volume[SND_VOL_C_VAL(vc)][vt] = in chn_setvolume_matrix()
1460 SND_VOL_CALC_VAL(c->volume, vc, vt); in chn_setvolume_matrix()
1465 c->volume[SND_VOL_C_VAL(vc)][i] = in chn_setvolume_matrix()
1466 SND_VOL_CALC_VAL(c->volume, vc, i); in chn_setvolume_matrix()
1469 c->volume[SND_VOL_C_VAL(vc)][vt] = in chn_setvolume_matrix()
1470 SND_VOL_CALC_VAL(c->volume, vc, vt); in chn_setvolume_matrix()
1486 return (c->volume[vc][vt]); in chn_getvolume_matrix()
1522 c->muted[vc][vt] = mute; in chn_setmute_matrix()
1531 c->muted[SND_VOL_C_VAL(vc)][vt] = mute; in chn_setmute_matrix()
1536 c->muted[SND_VOL_C_VAL(vc)][i] = mute; in chn_setmute_matrix()
1539 c->muted[SND_VOL_C_VAL(vc)][vt] = mute; in chn_setmute_matrix()
1555 return (c->muted[vc][vt]); in chn_getmute_matrix()
1565 if (!(c->format & AFMT_CONVERTIBLE)) in chn_getmatrix()
1568 return (&c->matrix); in chn_getmatrix()
1579 if (!(c->format & AFMT_CONVERTIBLE)) in chn_setmatrix()
1582 c->matrix = *m; in chn_setmatrix()
1583 c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL; in chn_setmatrix()
1585 return (chn_setformat(c, SND_FORMAT(c->format, m->channels, m->ext))); in chn_setmatrix()
1599 if (!(c->format & AFMT_CONVERTIBLE)) in chn_oss_getorder()
1602 return (feeder_matrix_oss_get_channel_order(&c->matrix, map)); in chn_oss_getorder()
1615 if (!(c->format & AFMT_CONVERTIBLE)) in chn_oss_setorder()
1618 m = c->matrix; in chn_oss_setorder()
1643 if (caps == NULL || caps->fmtlist == NULL) in chn_oss_getmask()
1646 for (i = 0; caps->fmtlist[i] != 0; i++) { in chn_oss_getmask()
1647 format = caps->fmtlist[i]; in chn_oss_getmask()
1652 m = CHANNEL_GETMATRIX(c->methods, c->devinfo, format); in chn_oss_getmask()
1655 if (m->mask & SND_CHN_OSS_FRONT) in chn_oss_getmask()
1657 if (m->mask & SND_CHN_OSS_SURR) in chn_oss_getmask()
1659 if (m->mask & SND_CHN_OSS_CENTER_LFE) in chn_oss_getmask()
1661 if (m->mask & SND_CHN_OSS_REAR) in chn_oss_getmask()
1665 /* report software-supported binding mask */ in chn_oss_getmask()
1686 CHN_SETVOLUME(c, vc, i, c->volume[vc][SND_CHN_T_VOL_0DB]); in chn_vpc_reset()
1699 ret = 1 << (ret - 1); in round_pow2()
1718 tmp = ret - (ret % round); in round_blksz()
1721 tmp = ret - (ret % round); in round_blksz()
1734 * +---------+------------+-----------+------------+
1736 * +---------+------------+-----------+------------+
1738 * +---------+------------+-----------+------------+
1740 * +---------+------------+-----------+------------+
1742 * +---------+------------+-----------+------------+
1744 * +---------+------------+-----------+------------+
1746 * +---------+------------+-----------+------------+
1748 * +---------+------------+-----------+------------+
1750 * +---------+------------+-----------+------------+
1752 * +---------+------------+-----------+------------+
1754 * +---------+------------+-----------+------------+
1756 * +---------+------------+-----------+------------+
1758 * +---------+------------+-----------+------------+
1765 * +---------+------------+-----------+------------+
1767 * +---------+------------+-----------+------------+
1769 * +---------+------------+-----------+------------+
1771 * +---------+------------+-----------+------------+
1773 * +---------+------------+-----------+------------+
1775 * +---------+------------+-----------+------------+
1777 * +---------+------------+-----------+------------+
1779 * +---------+------------+-----------+------------+
1781 * +---------+------------+-----------+------------+
1783 * +---------+------------+-----------+------------+
1785 * +---------+------------+-----------+------------+
1787 * +---------+------------+-----------+------------+
1789 * +---------+------------+-----------+------------+
1877 if ((c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED)) || in chn_resizebuf()
1878 !(c->direction == PCMDIR_PLAY || c->direction == PCMDIR_REC)) in chn_resizebuf()
1881 if (latency == -1) { in chn_resizebuf()
1882 c->latency = -1; in chn_resizebuf()
1884 } else if (latency == -2) { in chn_resizebuf()
1885 latency = c->latency; in chn_resizebuf()
1891 c->latency = latency; in chn_resizebuf()
1894 bs = c->bufsoft; in chn_resizebuf()
1895 b = c->bufhard; in chn_resizebuf()
1897 if (!(blksz == 0 || blkcnt == -1) && in chn_resizebuf()
1902 chn_calclatency(c->direction, latency, sndbuf_getalign(bs), in chn_resizebuf()
1906 if (blksz == 0 || blkcnt == -1) { in chn_resizebuf()
1907 if (blkcnt == -1) in chn_resizebuf()
1908 c->flags &= ~CHN_F_HAS_SIZE; in chn_resizebuf()
1909 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1914 c->flags |= CHN_F_HAS_SIZE; in chn_resizebuf()
1916 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1928 if (c->parentchannel != NULL) { in chn_resizebuf()
1929 pb = c->parentchannel->bufsoft; in chn_resizebuf()
1931 CHN_LOCK(c->parentchannel); in chn_resizebuf()
1932 chn_notify(c->parentchannel, CHN_N_BLOCKSIZE); in chn_resizebuf()
1933 CHN_UNLOCK(c->parentchannel); in chn_resizebuf()
1935 if (c->direction == PCMDIR_PLAY) { in chn_resizebuf()
1944 if (c->flags & CHN_F_HAS_SIZE) { in chn_resizebuf()
1949 chn_calclatency(c->direction, latency, in chn_resizebuf()
1965 hblksz -= hblksz % sndbuf_getalign(b); in chn_resizebuf()
1969 CHANNEL_SETFRAGMENTS(c->methods, c->devinfo, in chn_resizebuf()
1971 sndbuf_setblksz(b, CHANNEL_SETBLOCKSIZE(c->methods, in chn_resizebuf()
1972 c->devinfo, hblksz)); in chn_resizebuf()
1980 if (c->direction == PCMDIR_PLAY) { in chn_resizebuf()
1982 nsblkcnt--; in chn_resizebuf()
2007 sblksz -= sblksz % sndbuf_getalign(bs); in chn_resizebuf()
2013 device_printf(c->dev, "%s(): Failed: %d %d\n", in chn_resizebuf()
2022 c->timeout = ((u_int64_t)hz * sndbuf_getsize(bs)) / in chn_resizebuf()
2024 if (c->parentchannel != NULL) in chn_resizebuf()
2025 c->timeout = min(c->timeout, c->parentchannel->timeout); in chn_resizebuf()
2026 if (c->timeout < 1) in chn_resizebuf()
2027 c->timeout = 1; in chn_resizebuf()
2033 c->lw = sndbuf_getblksz(bs); in chn_resizebuf()
2037 device_printf(c->dev, "%s(): %s (%s) timeout=%u " in chn_resizebuf()
2040 (c->flags & CHN_F_VIRTUAL) ? "virtual" : "hardware", in chn_resizebuf()
2041 c->timeout, in chn_resizebuf()
2055 return chn_resizebuf(c, latency, -1, 0); in chn_setlatency()
2063 return chn_resizebuf(c, -1, blkcnt, blksz); in chn_setblocksize()
2067 chn_setparam(struct pcm_channel *c, uint32_t format, uint32_t speed) in chn_setparam() argument
2075 if (speed < 1 || format == 0 || CHN_STARTED(c)) in chn_setparam()
2078 c->format = format; in chn_setparam()
2079 c->speed = speed; in chn_setparam()
2083 hwspeed = speed; in chn_setparam()
2084 RANGE(hwspeed, caps->minspeed, caps->maxspeed); in chn_setparam()
2086 sndbuf_setspd(c->bufhard, CHANNEL_SETSPEED(c->methods, c->devinfo, in chn_setparam()
2088 hwspeed = sndbuf_getspd(c->bufhard); in chn_setparam()
2090 delta = (hwspeed > speed) ? (hwspeed - speed) : (speed - hwspeed); in chn_setparam()
2093 c->speed = hwspeed; in chn_setparam()
2098 ret = CHANNEL_SETFORMAT(c->methods, c->devinfo, in chn_setparam()
2099 sndbuf_getfmt(c->bufhard)); in chn_setparam()
2102 ret = chn_resizebuf(c, -2, 0, 0); in chn_setparam()
2108 chn_setspeed(struct pcm_channel *c, uint32_t speed) in chn_setspeed() argument
2113 oldformat = c->format; in chn_setspeed()
2114 oldspeed = c->speed; in chn_setspeed()
2116 if (c->speed == speed) in chn_setspeed()
2119 ret = chn_setparam(c, c->format, speed); in chn_setspeed()
2122 device_printf(c->dev, in chn_setspeed()
2123 "%s(): Setting speed %d failed, " in chn_setspeed()
2125 __func__, speed, oldspeed); in chn_setspeed()
2144 oldformat = c->format; in chn_setformat()
2145 oldspeed = c->speed; in chn_setformat()
2147 if (c->format == format) in chn_setformat()
2150 ret = chn_setparam(c, format, c->speed); in chn_setformat()
2153 device_printf(c->dev, in chn_setformat()
2169 d = (c != NULL) ? c->parentsnddev : NULL; in chn_syncstate()
2170 m = (d != NULL && d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 : in chn_syncstate()
2178 if (c->feederflags & (1 << FEEDER_VOLUME)) { in chn_syncstate()
2182 if (c->direction == PCMDIR_PLAY && in chn_syncstate()
2183 (d->flags & SD_F_SOFTPCMVOL)) { in chn_syncstate()
2197 if (vol == -1) { in chn_syncstate()
2198 device_printf(c->dev, in chn_syncstate()
2204 if (pvol == -1) { in chn_syncstate()
2205 device_printf(c->dev, in chn_syncstate()
2218 if (c->feederflags & (1 << FEEDER_EQ)) { in chn_syncstate()
2227 if (treble == -1) in chn_syncstate()
2233 if (bass == -1) in chn_syncstate()
2241 device_printf(c->dev, in chn_syncstate()
2242 "EQ: Failed to set treble -- %d\n", in chn_syncstate()
2245 device_printf(c->dev, in chn_syncstate()
2246 "EQ: Failed to set bass -- %d\n", in chn_syncstate()
2248 if (FEEDER_SET(f, FEEDEQ_PREAMP, d->eqpreamp) != 0) in chn_syncstate()
2249 device_printf(c->dev, in chn_syncstate()
2250 "EQ: Failed to set preamp -- %d\n", in chn_syncstate()
2251 d->eqpreamp); in chn_syncstate()
2252 if (d->flags & SD_F_EQ_BYPASSED) in chn_syncstate()
2254 else if (d->flags & SD_F_EQ_ENABLED) in chn_syncstate()
2259 device_printf(c->dev, in chn_syncstate()
2260 "EQ: Failed to set state -- %d\n", state); in chn_syncstate()
2268 struct snddev_info *d = c->parentsnddev; in chn_trigger()
2273 return (CHANNEL_TRIGGER(c->methods, c->devinfo, go)); in chn_trigger()
2275 if (go == c->trigger) in chn_trigger()
2279 device_printf(c->dev, "%s() %s: calling go=0x%08x , " in chn_trigger()
2280 "prev=0x%08x\n", __func__, c->name, go, c->trigger); in chn_trigger()
2283 c->trigger = go; in chn_trigger()
2284 ret = CHANNEL_TRIGGER(c->methods, c->devinfo, go); in chn_trigger()
2296 if (go != c->trigger) { in chn_trigger()
2325 * @brief Queries sound driver for sample-aligned hardware buffer pointer index
2328 * the current bytes-per-sample value before returning. (E.g., a channel
2330 * hwptr value ranging from 32-35 would be returned as 32.)
2333 * @returns sample-aligned hardware buffer pointer index
2341 hwptr = (CHN_STARTED(c)) ? CHANNEL_GETPTR(c->methods, c->devinfo) : 0; in chn_getptr()
2342 return (hwptr - (hwptr % sndbuf_getalign(c->bufhard))); in chn_getptr()
2349 return CHANNEL_GETCAPS(c->methods, c->devinfo); in chn_getcaps()
2358 fmtlist = chn_getcaps(c)->fmtlist; in chn_getformats()
2363 /* report software-supported formats */ in chn_getformats()
2425 if ((flags & CHN_N_TRIGGER) && !(c->flags & CHN_F_VCHAN_DYNAMIC)) { in chn_notify()
2435 if (c->direction == PCMDIR_PLAY) { in chn_notify()
2436 vchanformat = &c->parentsnddev->pvchanformat; in chn_notify()
2437 vchanrate = &c->parentsnddev->pvchanrate; in chn_notify()
2439 vchanformat = &c->parentsnddev->rvchanformat; in chn_notify()
2440 vchanrate = &c->parentsnddev->rvchanrate; in chn_notify()
2444 if (!(c->flags & CHN_F_VCHAN_ADAPTIVE)) { in chn_notify()
2460 if ((ch->format & AFMT_PASSTHROUGH) && in chn_notify()
2461 snd_fmtvalid(ch->format, caps->fmtlist)) { in chn_notify()
2462 bestformat = ch->format; in chn_notify()
2463 bestspeed = ch->speed; in chn_notify()
2469 if ((ch->flags & CHN_F_EXCLUSIVE) && vpflags == 0) { in chn_notify()
2470 if (c->flags & CHN_F_VCHAN_ADAPTIVE) { in chn_notify()
2471 bestspeed = ch->speed; in chn_notify()
2472 RANGE(bestspeed, caps->minspeed, in chn_notify()
2473 caps->maxspeed); in chn_notify()
2474 besthwformat = snd_fmtbest(ch->format, in chn_notify()
2475 caps->fmtlist); in chn_notify()
2484 if (!(c->flags & CHN_F_VCHAN_ADAPTIVE) || in chn_notify()
2490 if (ch->speed > bestspeed) { in chn_notify()
2491 bestspeed = ch->speed; in chn_notify()
2492 RANGE(bestspeed, caps->minspeed, in chn_notify()
2493 caps->maxspeed); in chn_notify()
2495 besthwformat = snd_fmtbest(ch->format, caps->fmtlist); in chn_notify()
2513 bestformat = c->format; in chn_notify()
2515 bestspeed = c->speed; in chn_notify()
2517 if (bestformat != c->format || bestspeed != c->speed) in chn_notify()
2520 c->flags &= ~(CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE); in chn_notify()
2521 c->flags |= vpflags; in chn_notify()
2525 bestspeed = CHANNEL_SETSPEED(c->methods, in chn_notify()
2526 c->devinfo, bestspeed); in chn_notify()
2539 c->flags |= CHN_F_DIRTY; in chn_notify()
2546 bestspeed = CHANNEL_SETSPEED(c->methods, c->devinfo, in chn_notify()
2558 c->flags |= CHN_F_DIRTY; in chn_notify()
2570 c->flags &= ~(CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE); in chn_notify()
2574 if (c->format != bestformat || c->speed != bestspeed) in chn_notify()
2590 * should examine rates @b only if this function returns non-zero.
2602 return CHANNEL_GETRATES(c->methods, c->devinfo, rates); in chn_getrates()
2609 * - Starting a syncgroup (@c SNDCTL_DSP_SYNCSTART ioctl)
2610 * - Closing a device. (A channel can't be destroyed if it's still in use.)
2633 if (c->sm != NULL) { in chn_syncdestroy()
2634 sm = c->sm; in chn_syncdestroy()
2635 sg = sm->parent; in chn_syncdestroy()
2636 c->sm = NULL; in chn_syncdestroy()
2640 SLIST_REMOVE(&sg->members, sm, pcmchan_syncmember, link); in chn_syncdestroy()
2643 if (SLIST_EMPTY(&sg->members)) { in chn_syncdestroy()
2645 sg_id = sg->id; in chn_syncdestroy()
2658 return CHANNEL_GETPEAKS(c->methods, c->devinfo, lpeak, rpeak); in chn_getpeaks()