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
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");
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");
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()
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()
271 struct snd_dbuf *bs = c->bufsoft; 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()
296 sndbuf_updateprevtotal(c->bufsoft); in chn_pollreset()
307 bs = c->bufsoft; in chn_wakeup()
312 CHN_BROADCAST(&c->intr_cv); in chn_wakeup()
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()
347 struct snd_dbuf *b = c->bufhard; 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()
370 device_printf(c->dev, "WARNING: %s DMA completion " in chn_dmaupdate()
383 struct snd_dbuf *b = c->bufhard; in chn_wrfeed()
384 struct snd_dbuf *bs = c->bufsoft; 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()
424 * user write routine - uiomove data into secondary buffer, trigger if necessary
433 struct snd_dbuf *bs = c->bufsoft; in chn_write()
440 timeout = chn_timeout * hz; 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()
457 sz -= t; in chn_write()
461 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { 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()
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()
500 struct snd_dbuf *b = c->bufhard; in chn_rdfeed()
501 struct snd_dbuf *bs = c->bufsoft; 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()
529 /* tell the driver to update the primary buffer if non-dma */ in chn_rdintr()
538 * user read routine - trigger if necessary, uiomove data from secondary buffer
547 struct snd_dbuf *bs = c->bufsoft; in chn_read()
553 if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) { in chn_read()
556 c->flags |= CHN_F_DEAD; in chn_read()
562 timeout = chn_timeout * hz; 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()
579 sz -= t; in chn_read()
583 } else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER)) 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()
607 c->interrupts++; in chn_intr_locked()
609 if (c->direction == PCMDIR_PLAY) in chn_intr_locked()
633 struct snd_dbuf *b = c->bufhard; in chn_start()
634 struct snd_dbuf *bs = c->bufsoft; 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()
664 device_printf(c->dev, "%s(): %s (%s) threshold " 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()
692 (c->flags & CHN_F_CLOSING) ? "closing" : in chn_start()
695 force, i, j, c->timeout, in chn_start()
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()
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()
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()
855 struct snd_dbuf *bs = c->bufsoft; in chn_poll()
860 if (!(c->flags & (CHN_F_MMAP | CHN_F_TRIGGERED))) { in chn_poll()
886 struct snd_dbuf *b = c->bufhard; in chn_abort()
887 struct snd_dbuf *bs = c->bufsoft; in chn_abort()
892 c->flags |= CHN_F_ABORTING; in chn_abort()
894 c->flags &= ~CHN_F_TRIGGERED; in chn_abort()
898 if (!(c->flags & CHN_F_VIRTUAL)) in chn_abort()
902 c->flags &= ~CHN_F_ABORTING; in chn_abort()
920 struct snd_dbuf *b = c->bufhard; 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()
928 c->flags &= ~CHN_F_TRIGGERED; in chn_flush()
933 c->flags &= ~CHN_F_CLOSING; in chn_flush()
1078 afmt_tab[i].name, ch - ext, ext); in snd_afmt2str()
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()
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()
1144 switch (c->type) { in chn_mkname()
1162 device_get_unit(c->dev), str, c->unit); in chn_mkname()
1190 device_printf(d->dev, in chn_init()
1201 c->methods = kobj_create(cls, M_DEVBUF, M_WAITOK | M_ZERO); 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()
1235 device_printf(d->dev, "%s(): failed to get feeder class\n", 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()
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()
1305 free_unr(chn_getunr(d, c->type), c->unit); in chn_init()
1307 if (c->devinfo && CHANNEL_FREE(c->methods, c->devinfo)) in chn_init()
1316 kobj_delete(c->methods, M_DEVBUF); in chn_init()
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()
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()
1359 free_unr(chn_getunr(c->parentsnddev, c->type), c->unit); in chn_kill()
1361 if (CHANNEL_FREE(c->methods, c->devinfo)) in chn_kill()
1366 c->flags |= CHN_F_DEAD; in chn_kill()
1368 kobj_delete(c->methods, M_DEVBUF); in chn_kill()
1378 c->flags |= CHN_F_DEAD; in chn_shutdown()
1385 PCM_BUSYASSERT(c->parentsnddev); 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()
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()
1471 return (c->volume[vc][vt]); in chn_getvolume_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()
1540 return (c->muted[vc][vt]); in chn_getmute_matrix()
1550 if (!(c->format & AFMT_CONVERTIBLE)) in chn_getmatrix()
1553 return (&c->matrix); in chn_getmatrix()
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()
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()
1600 if (!(c->format & AFMT_CONVERTIBLE)) in chn_oss_setorder()
1603 m = c->matrix; in chn_oss_setorder()
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()
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 * +---------+------------+-----------+------------+
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()
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()
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()
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()
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()
2022 device_printf(c->dev, "%s(): %s (%s) timeout=%u " in chn_resizebuf()
2025 (c->flags & CHN_F_VIRTUAL) ? "virtual" : "hardware", in chn_resizebuf()
2026 c->timeout, in chn_resizebuf()
2040 return chn_resizebuf(c, latency, -1, 0); in chn_setlatency()
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
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()
2068 hwspeed = speed; 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()
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()
2106 "%s(): Setting speed %d failed, " in chn_setspeed()
2108 __func__, speed, oldspeed); in chn_setspeed()
2109 chn_setparam(c, c->format, oldspeed); in chn_setspeed()
2118 uint32_t oldformat, oldspeed, speed; in chn_setformat() local
2127 oldformat = c->format; in chn_setformat()
2128 oldspeed = c->speed; in chn_setformat()
2129 speed = oldspeed; in chn_setformat()
2131 ret = chn_setparam(c, format, speed); in chn_setformat()
2134 device_printf(c->dev, in chn_setformat()
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()
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()
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()
2199 if (c->feederflags & (1 << FEEDER_EQ)) { in chn_syncstate()
2208 if (treble == -1) in chn_syncstate()
2214 if (bass == -1) 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()
2249 struct snddev_info *d = c->parentsnddev; 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()
2277 if (go != c->trigger) { 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.)
2314 * @returns sample-aligned hardware buffer pointer index
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()
2330 return CHANNEL_GETCAPS(c->methods, c->devinfo); in chn_getcaps()
2339 fmtlist = chn_getcaps(c)->fmtlist; in chn_getformats()
2344 /* report software-supported formats */ in chn_getformats()
2406 if ((flags & CHN_N_TRIGGER) && !(c->flags & CHN_F_VCHAN_DYNAMIC)) { 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()
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()
2520 c->flags |= CHN_F_DIRTY; in chn_notify()
2527 bestspeed = CHANNEL_SETSPEED(c->methods, c->devinfo, in chn_notify()
2539 c->flags |= CHN_F_DIRTY; in chn_notify()
2551 c->flags &= ~(CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE); in chn_notify()
2555 if (c->format != bestformat || c->speed != bestspeed) in chn_notify()
2571 * should examine rates @b only if this function returns non-zero.
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.)
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()
2639 return CHANNEL_GETPEAKS(c->methods, c->devinfo, lpeak, rpeak); in chn_getpeaks()