Lines Matching +full:d +full:-
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
51 int snd_unit = -1;
53 static int snd_unit_auto = -1;
99 struct snddev_info *d;
103 d = device_get_softc(dev);
104 if (d != NULL && (flags & INTR_MPSAFE))
105 d->flags |= SD_F_MPSAFE;
111 pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction,
118 KASSERT(d != NULL && ch != NULL &&
120 ("%s(): invalid d=%p ch=%p direction=%d pid=%d",
121 __func__, d, ch, direction, pid));
122 PCM_BUSYASSERT(d);
125 vchancount = (direction == PCMDIR_PLAY) ? d->pvchancount :
126 d->rvchancount;
131 CHN_FOREACH(c, d, channels.pcm) {
133 if (c->direction != direction) {
137 if (!(c->flags & CHN_F_BUSY)) {
138 c->flags |= CHN_F_BUSY;
139 c->pid = pid;
140 strlcpy(c->comm, (comm != NULL) ? comm :
141 CHN_COMM_UNKNOWN, sizeof(c->comm));
157 err = vchan_setnew(d, direction, vchancount + 1);
169 struct snddev_info *d;
174 if (error == 0 && req->newptr != NULL) {
175 d = devclass_get_softc(pcm_devclass, unit);
176 if (!PCM_REGISTERED(d) || CHN_EMPTY(d, channels.pcm))
192 struct snddev_info *d = device_get_softc(dev);
195 PCM_BUSYASSERT(d);
197 PCM_LOCK(d);
198 ch = chn_init(d, NULL, cls, dir, devinfo);
200 device_printf(d->dev, "chn_init(%s, %d, %p) failed\n",
201 cls->name, dir, devinfo);
202 PCM_UNLOCK(d);
205 PCM_UNLOCK(d);
211 pcm_killchans(struct snddev_info *d)
216 PCM_BUSYASSERT(d);
217 KASSERT(!PCM_REGISTERED(d), ("%s(): still registered\n", __func__));
222 CHN_FOREACH(ch, d, channels.pcm) {
224 if (ch->inprog == 0 && ch->sleeping == 0 &&
230 if (ch->direction == PCMDIR_PLAY)
248 while (!CHN_EMPTY(d, channels.pcm)) {
249 ch = CHN_FIRST(d, channels.pcm);
253 if (d->p_unr != NULL)
254 delete_unrhdr(d->p_unr);
255 if (d->vp_unr != NULL)
256 delete_unrhdr(d->vp_unr);
257 if (d->r_unr != NULL)
258 delete_unrhdr(d->r_unr);
259 if (d->vr_unr != NULL)
260 delete_unrhdr(d->vr_unr);
266 struct snddev_info *d;
269 best = -1;
270 bestprio = -100;
273 d = devclass_get_softc(pcm_devclass, i);
274 if (!PCM_REGISTERED(d))
277 if (d->playcount == 0)
278 prio -= 10;
279 if (d->reccount == 0)
280 prio -= 2;
292 struct snddev_info *d = device_get_softc(dev);
294 return d->flags;
300 struct snddev_info *d = device_get_softc(dev);
302 d->flags = val;
308 struct snddev_info *d = device_get_softc(dev);
310 return d->devinfo;
316 struct snddev_info *d = device_get_softc(dev);
324 device_printf(dev, "'buffersize=%d' hint is out of range (%d-%d), using %d\n", x, minbufsz, maxbufsz, sz);
331 device_printf(dev, "'buffersize=%d' hint is not a power of 2, using %d\n", sz, x);
338 d->bufsz = sz;
346 struct snddev_info *d;
349 d = oidp->oid_arg1;
350 if (!PCM_REGISTERED(d))
353 PCM_LOCK(d);
354 PCM_WAIT(d);
355 val = (d->flags & SD_F_BITPERFECT) ? 1 : 0;
356 PCM_ACQUIRE(d);
357 PCM_UNLOCK(d);
361 if (err == 0 && req->newptr != NULL) {
363 PCM_RELEASE_QUICK(d);
367 PCM_LOCK(d);
369 d->flags &= ~SD_F_BITPERFECT;
370 d->flags |= (val != 0) ? SD_F_BITPERFECT : 0;
372 PCM_RELEASE(d);
373 PCM_UNLOCK(d);
375 PCM_RELEASE_QUICK(d);
381 pcm_mode_init(struct snddev_info *d)
385 if (d->playcount > 0)
387 if (d->reccount > 0)
389 if (d->mixer_dev != NULL)
398 struct snddev_info *d = device_get_softc(dev);
401 mode = pcm_mode_init(d);
403 sysctl_ctx_init(&d->play_sysctl_ctx);
404 d->play_sysctl_tree = SYSCTL_ADD_NODE(&d->play_sysctl_ctx,
407 sysctl_ctx_init(&d->rec_sysctl_ctx);
408 d->rec_sysctl_tree = SYSCTL_ADD_NODE(&d->rec_sysctl_ctx,
416 OID_AUTO, "buffersize", CTLFLAG_RD, &d->bufsz, 0, "allocated buffer size");
419 "bitperfect", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, d,
420 sizeof(d), sysctl_dev_pcm_bitperfect, "I",
421 "bit-perfect playback/recording (0=disable, 1=enable)");
427 if (d->flags & SD_F_AUTOVCHAN)
429 if (d->flags & SD_F_EQ)
440 struct snddev_info *d;
443 d = device_get_softc(dev);
444 d->dev = dev;
445 d->lock = snd_mtxcreate(device_get_nameunit(dev), "sound cdev");
446 cv_init(&d->cv, device_get_nameunit(dev));
447 PCM_ACQUIRE_QUICK(d);
452 d->flags |= SD_F_VPC;
456 d->flags |= SD_F_BITPERFECT;
458 d->devinfo = devinfo;
459 d->reccount = 0;
460 d->playcount = 0;
461 d->pvchancount = 0;
462 d->rvchancount = 0;
463 d->pvchanrate = 0;
464 d->pvchanformat = 0;
465 d->rvchanrate = 0;
466 d->rvchanformat = 0;
467 d->p_unr = new_unrhdr(0, INT_MAX, NULL);
468 d->vp_unr = new_unrhdr(0, INT_MAX, NULL);
469 d->r_unr = new_unrhdr(0, INT_MAX, NULL);
470 d->vr_unr = new_unrhdr(0, INT_MAX, NULL);
472 CHN_INIT(d, channels.pcm);
473 CHN_INIT(d, channels.pcm.busy);
474 CHN_INIT(d, channels.pcm.opened);
480 struct snddev_info *d = device_get_softc(dev);
483 if (d->flags & SD_F_REGISTERED)
486 PCM_BUSYASSERT(d);
488 if (d->playcount == 0 || d->reccount == 0)
489 d->flags |= SD_F_SIMPLEX;
491 if (d->playcount > 0 || d->reccount > 0)
492 d->flags |= SD_F_AUTOVCHAN;
494 vchan_setmaxauto(d, snd_maxautovchans);
496 strlcpy(d->status, str, SND_STATUSLEN);
497 sndstat_register(dev, d->status);
499 PCM_LOCK(d);
502 d->flags |= SD_F_REGISTERED;
504 PCM_RELEASE(d);
506 PCM_UNLOCK(d);
527 struct snddev_info *d;
529 d = device_get_softc(dev);
531 if (!PCM_ALIVE(d)) {
536 PCM_LOCK(d);
537 PCM_WAIT(d);
539 d->flags &= ~SD_F_REGISTERED;
541 PCM_ACQUIRE(d);
542 PCM_UNLOCK(d);
544 pcm_killchans(d);
546 PCM_RELEASE_QUICK(d);
548 if (d->play_sysctl_tree != NULL) {
549 sysctl_ctx_free(&d->play_sysctl_ctx);
550 d->play_sysctl_tree = NULL;
552 if (d->rec_sysctl_tree != NULL) {
553 sysctl_ctx_free(&d->rec_sysctl_ctx);
554 d->rec_sysctl_tree = NULL;
561 cv_destroy(&d->cv);
562 snd_mtxfree(d->lock);
565 snd_unit = pcm_best_unit(-1);
600 struct snddev_info *d;
605 strlcpy(si->product, si_product, sizeof(si->product));
606 strlcpy(si->version, si_version, sizeof(si->version));
607 si->versionnum = SOUND_VERSION;
608 strlcpy(si->license, si_license, sizeof(si->license));
614 si->numaudioengines = 0;
615 bzero((void *)&si->openedaudio, sizeof(si->openedaudio));
621 d = devclass_get_softc(pcm_devclass, i);
622 if (!PCM_REGISTERED(d))
628 PCM_UNLOCKASSERT(d);
629 PCM_LOCK(d);
631 si->numaudioengines += PCM_CHANCOUNT(d);
633 CHN_FOREACH(c, d, channels.pcm) {
636 if (c->flags & CHN_F_BUSY)
637 si->openedaudio[j / intnbits] |=
643 PCM_UNLOCK(d);
646 si->numsynths = 0; /* OSSv4 docs: this field is obsolete */
658 si->nummidis = 0;
659 si->numtimers = 0;
665 si->nummixers = devclass_get_maxunit(pcm_devclass);
666 si->numcards = devclass_get_maxunit(pcm_devclass);
667 si->numaudios = devclass_get_maxunit(pcm_devclass);
675 * si->openedmidi = " MIDI devices
677 bzero((void *)&si->openedmidi, sizeof(si->openedmidi));
680 * Si->filler is a reserved array, but according to docs each
681 * element should be set to -1.
683 for (i = 0; i < nitems(si->filler); i++)
684 si->filler[i] = -1;
690 struct snddev_info *d;
695 d = devclass_get_softc(pcm_devclass, i);
696 if (i != si->card)
699 if (!PCM_REGISTERED(d)) {
700 snprintf(si->shortname, sizeof(si->shortname),
701 "pcm%d (n/a)", i);
702 strlcpy(si->longname, "Device unavailable",
703 sizeof(si->longname));
704 si->hw_info[0] = '\0';
705 si->intr_count = si->ack_count = 0;
707 PCM_UNLOCKASSERT(d);
708 PCM_LOCK(d);
710 strlcpy(si->shortname, device_get_nameunit(d->dev),
711 sizeof(si->shortname));
712 strlcpy(si->longname, device_get_desc(d->dev),
713 sizeof(si->longname));
714 strlcpy(si->hw_info, d->status, sizeof(si->hw_info));
715 si->intr_count = si->ack_count = 0;
717 PCM_UNLOCK(d);
734 snd_unit = -1;
762 printf("%s: snd_unit=%d snd_maxautovchans=%d "
763 "latency=%d "
764 "feeder_rate_min=%d feeder_rate_max=%d "
765 "feeder_rate_round=%d\n",