From nobody Thu Oct 24 11:37:33 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XZ3mt23hZz5bMqw; Thu, 24 Oct 2024 11:37:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZ3ms68kyz3x2c; Thu, 24 Oct 2024 11:37:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729769853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cYp8D4jql1PaREtdAEucq7SiKmRpXYposAtYp/1qcrg=; b=q6GDDKJ8S8FK5f1LvKZKrHt0FTH11iWESpi4pwHFBegR4CqZHoWK2hu1Qd/gU6LXr6N2fp dbjFB7LgzqbC+U6gF7fnR6PJeQITzlnadJjE8TRO7GK32D4+fPwszeLO3iuWNZxkda+pHP Gil7UZHUvst6VIBeWyLLUayE03iZW1EYNYFajPvX4WFlenXHExNsmOxnCbycoTjJRrt0TB bFpd40QtIRL0TeSJ9FewwdTZeVo3iq6BEXgqOdbkm0ujsX3GnuBHuIoe+J6q42BYQq8L+Q BNg6Lu5b6eB+D0FhQFi0JDUaN5fFihWmymvr7TEDUL3pSwcT5N5JWJNY/bjQog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729769853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cYp8D4jql1PaREtdAEucq7SiKmRpXYposAtYp/1qcrg=; b=E9bRKl6N204kQZi9k4JsYham9hAioj2PgQFcDt0rfShW+VaYhLTssOEwfXHKXcu9TdeiuX 6lmDp++aEZeHsmEXlbYcTUuKaxsVJibDT2di43MUW+raCxrixS4zI+0HRZmedAvYr1ZP+m G32++430xqBLxRSP2StZQlDVtdYZqTZUgXENXD7RgmsAxl3X0x+/nmk40UvupEHsEdBDFv Q/IddTPKTCyHmuygp8stFwHGSrdIzfEQSbGBeo3/9x+SAj+c7jHBM/4SrnxCVOj08xl0K7 /pEz3EizBJrMPh4iRB8kibIwfn4mwgn0G2pQ13ZHnexJ6KpL3H1kIA8ebGvuyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729769853; a=rsa-sha256; cv=none; b=kP0N7kWn03hcLeNKEAB0m3eus9xEUVQtaRfx7sNe+k3QYhVg9YMuvn2qzg0qYqVaFj2jLZ SHlLmdViTb6XwTcgdp/4qKUMuZps319rAEhzu8umHFnIyYRGY/nT4Gl5/w7OPhBM0UN0zA 5r8sDBGojVpU+CbFxLedgm2f5TP+GPaySF2mDIm/KWdkrSZNa6INMemnl6yYb2865bGTaU 7aMOidO2OjnJh/6H4AoEyxUUhybD4sr2m/D8NbLFBs8guKGfr2pxFOpYJ5awTjY0Oeph4j qIIoc2oXm6awPp4vnR7z9xjpiyYLgp0G1ZzUUZibsDLzKKotX1bPEwhnvl2elg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XZ3ms5MbZzgpn; Thu, 24 Oct 2024 11:37:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49OBbX9t071722; Thu, 24 Oct 2024 11:37:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49OBbXc6071719; Thu, 24 Oct 2024 11:37:33 GMT (envelope-from git) Date: Thu, 24 Oct 2024 11:37:33 GMT Message-Id: <202410241137.49OBbXc6071719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 802c78f5194e - main - sound: Untangle dsp_cdevs[] and dsp_unit2name() confusion List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 802c78f5194e4524faa30ea57adbf00f28fc72c6 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=802c78f5194e4524faa30ea57adbf00f28fc72c6 commit 802c78f5194e4524faa30ea57adbf00f28fc72c6 Author: Christos Margiolis AuthorDate: 2024-10-24 11:37:23 +0000 Commit: Christos Margiolis CommitDate: 2024-10-24 11:37:23 +0000 sound: Untangle dsp_cdevs[] and dsp_unit2name() confusion Before de8c0d15a64fa ("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)"), sound(4) would create one device for each allocated channel. The device names would be chosen from dsp_cdevs[], and created with dsp_unit2name(). Additionally, dsp_cdevs[] was also used to match these devices names, as well as OSSv4 aliases in dsp_clone(). Since sound(4) does not create separate devices for each channel anymore, the meaning and use dsp_cdevs[] has changed. Part of it no longer corresponds to devices at all, but instead is used to create channel names, and another part is used to match only OSSv4 aliases in dsp_clone(). To address this confusion, separate dsp_cdevs[] into a dsp_aliases[] array, and move dsp_unit2name() to pcm/channel.c and rename it to chn_mkname(). While here, get rid of the SND_DEV_DSPHW_* channel types, and simply use the existing PCMDIR_* constants as the channel types. There is no need to duplicate the same meaning twice. Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D47199 --- sys/dev/sound/pcm/channel.c | 70 +++++++---- sys/dev/sound/pcm/channel.h | 1 + sys/dev/sound/pcm/dsp.c | 290 +++++++++++++++++++------------------------- sys/dev/sound/pcm/dsp.h | 1 - sys/dev/sound/pcm/sound.h | 4 - sys/dev/sound/pcm/vchan.c | 11 +- 6 files changed, 175 insertions(+), 202 deletions(-) diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 6b8f00f9aa83..b1d3ebc0d0f7 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1161,13 +1161,13 @@ static struct unrhdr * chn_getunr(struct snddev_info *d, int type) { switch (type) { - case SND_DEV_DSPHW_PLAY: + case PCMDIR_PLAY: return (d->p_unr); - case SND_DEV_DSPHW_VPLAY: + case PCMDIR_PLAY_VIRTUAL: return (d->vp_unr); - case SND_DEV_DSPHW_REC: + case PCMDIR_REC: return (d->r_unr); - case SND_DEV_DSPHW_VREC: + case PCMDIR_REC_VIRTUAL: return (d->vr_unr); default: __assert_unreachable(); @@ -1175,6 +1175,37 @@ chn_getunr(struct snddev_info *d, int type) } +char * +chn_mkname(char *buf, size_t len, struct pcm_channel *c) +{ + const char *str; + + KASSERT(buf != NULL && len != 0, + ("%s(): bogus buf=%p len=%lu", __func__, buf, len)); + + switch (c->type) { + case PCMDIR_PLAY: + str = "play"; + break; + case PCMDIR_PLAY_VIRTUAL: + str = "virtual_play"; + break; + case PCMDIR_REC: + str = "record"; + break; + case PCMDIR_REC_VIRTUAL: + str = "virtual_record"; + break; + default: + __assert_unreachable(); + } + + snprintf(buf, len, "dsp%d.%s.%d", + device_get_unit(c->dev), str, c->unit); + + return (buf); +} + struct pcm_channel * chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo) @@ -1183,27 +1214,19 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, struct feeder_class *fc; struct snd_dbuf *b, *bs; char buf[CHN_NAMELEN]; - int i, direction, type; + int i, direction; PCM_BUSYASSERT(d); PCM_LOCKASSERT(d); switch (dir) { case PCMDIR_PLAY: - direction = PCMDIR_PLAY; - type = SND_DEV_DSPHW_PLAY; - break; case PCMDIR_PLAY_VIRTUAL: direction = PCMDIR_PLAY; - type = SND_DEV_DSPHW_VPLAY; break; case PCMDIR_REC: - direction = PCMDIR_REC; - type = SND_DEV_DSPHW_REC; - break; case PCMDIR_REC_VIRTUAL: direction = PCMDIR_REC; - type = SND_DEV_DSPHW_VREC; break; default: device_printf(d->dev, @@ -1222,7 +1245,7 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, CHN_INIT(c, children); CHN_INIT(c, children.busy); c->direction = direction; - c->type = type; + c->type = dir; c->unit = alloc_unr(chn_getunr(d, c->type)); c->format = SND_FORMAT(AFMT_U8, 1, 0); c->speed = DSP_DEFAULT_SPEED; @@ -1234,8 +1257,7 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, c->parentchannel = parent; c->dev = d->dev; c->trigger = PCMTRIG_STOP; - - strlcpy(c->name, dsp_unit2name(buf, sizeof(buf), c), sizeof(c->name)); + strlcpy(c->name, chn_mkname(buf, sizeof(buf), c), sizeof(c->name)); c->matrix = *feeder_matrix_id_map(SND_CHN_MATRIX_1_0); c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL; @@ -1303,16 +1325,16 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, CHN_INSERT_SORT_ASCEND(d, c, channels.pcm); switch (c->type) { - case SND_DEV_DSPHW_PLAY: + case PCMDIR_PLAY: d->playcount++; break; - case SND_DEV_DSPHW_VPLAY: + case PCMDIR_PLAY_VIRTUAL: d->pvchancount++; break; - case SND_DEV_DSPHW_REC: + case PCMDIR_REC: d->reccount++; break; - case SND_DEV_DSPHW_VREC: + case PCMDIR_REC_VIRTUAL: d->rvchancount++; break; default: @@ -1354,16 +1376,16 @@ chn_kill(struct pcm_channel *c) CHN_REMOVE(d, c, channels.pcm); switch (c->type) { - case SND_DEV_DSPHW_PLAY: + case PCMDIR_PLAY: d->playcount--; break; - case SND_DEV_DSPHW_VPLAY: + case PCMDIR_PLAY_VIRTUAL: d->pvchancount--; break; - case SND_DEV_DSPHW_REC: + case PCMDIR_REC: d->reccount--; break; - case SND_DEV_DSPHW_VREC: + case PCMDIR_REC_VIRTUAL: d->rvchancount--; break; default: diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index 13efbef15d8b..6c6692fa8bc2 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -260,6 +260,7 @@ int chn_sync(struct pcm_channel *c, int threshold); int chn_flush(struct pcm_channel *c); int chn_poll(struct pcm_channel *c, int ev, struct thread *td); +char *chn_mkname(char *buf, size_t len, struct pcm_channel *c); struct pcm_channel *chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo); void chn_kill(struct pcm_channel *c); diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 92bfb4d58b86..7d80a82d31c8 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -164,25 +164,6 @@ dsp_unlock_chans(struct dsp_cdevpriv *priv, uint32_t prio) #define DSP_F_READ(x) ((x) & FREAD) #define DSP_F_WRITE(x) ((x) & FWRITE) -static const struct { - int type; - char *name; - char *sep; - char *alias; -} dsp_cdevs[] = { - { SND_DEV_DSP, "dsp", ".", NULL }, - { SND_DEV_DSPHW_PLAY, "dsp", ".play.", NULL }, - { SND_DEV_DSPHW_VPLAY, "dsp", ".virtual_play.", NULL }, - { SND_DEV_DSPHW_REC, "dsp", ".record.", NULL }, - { SND_DEV_DSPHW_VREC, "dsp", ".virtual_record.", NULL }, - /* Low priority, OSSv4 aliases. */ - { SND_DEV_DSP, "dsp_ac3", ".", "dsp" }, - { SND_DEV_DSP, "dsp_mmap", ".", "dsp" }, - { SND_DEV_DSP, "dsp_multich", ".", "dsp" }, - { SND_DEV_DSP, "dsp_spdifout", ".", "dsp" }, - { SND_DEV_DSP, "dsp_spdifin", ".", "dsp" }, -}; - static void dsp_close(void *data) { @@ -1941,6 +1922,14 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, return (0); } +static const char *dsp_aliases[] = { + "dsp_ac3", + "dsp_mmap", + "dsp_multich", + "dsp_spdifout", + "dsp_spdifin", +}; + static void dsp_clone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev) @@ -1952,9 +1941,8 @@ dsp_clone(void *arg, struct ucred *cred, char *name, int namelen, return; if (strcmp(name, "dsp") == 0 && dsp_basename_clone) goto found; - for (i = 0; i < nitems(dsp_cdevs); i++) { - if (dsp_cdevs[i].alias != NULL && - strcmp(name, dsp_cdevs[i].name) == 0) + for (i = 0; i < nitems(dsp_aliases); i++) { + if (strcmp(name, dsp_aliases[i]) == 0) goto found; } return; @@ -1994,26 +1982,6 @@ dsp_sysuninit(void *p) SYSINIT(dsp_sysinit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dsp_sysinit, NULL); SYSUNINIT(dsp_sysuninit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, dsp_sysuninit, NULL); -char * -dsp_unit2name(char *buf, size_t len, struct pcm_channel *ch) -{ - size_t i; - - KASSERT(buf != NULL && len != 0, - ("bogus buf=%p len=%ju", buf, (uintmax_t)len)); - - for (i = 0; i < nitems(dsp_cdevs); i++) { - if (ch->type != dsp_cdevs[i].type || dsp_cdevs[i].alias != NULL) - continue; - snprintf(buf, len, "%s%d%s%d", - dsp_cdevs[i].name, device_get_unit(ch->dev), - dsp_cdevs[i].sep, ch->unit); - return (buf); - } - - return (NULL); -} - static void dsp_oss_audioinfo_unavail(oss_audioinfo *ai, int unit) { @@ -2233,7 +2201,6 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai) struct snddev_info *d; uint32_t fmts; int i, nchan, *rates, minch, maxch, unit; - char *devname, buf[CHN_NAMELEN]; /* * If probing the device that received the ioctl, make sure it's a @@ -2244,9 +2211,7 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai) return (EINVAL); ch = NULL; - devname = NULL; nchan = 0; - bzero(buf, sizeof(buf)); /* * Search for the requested audio device (channel). Start by @@ -2267,147 +2232,142 @@ dsp_oss_engineinfo(struct cdev *i_dev, oss_audioinfo *ai) CHN_FOREACH(ch, d, channels.pcm) { CHN_UNLOCKASSERT(ch); CHN_LOCK(ch); - if (ai->dev == -1) { - if (devfs_foreach_cdevpriv(i_dev, - dsp_oss_engineinfo_cb, ch) != 0) { - devname = dsp_unit2name(buf, - sizeof(buf), ch); - } - } else if (ai->dev == nchan) - devname = dsp_unit2name(buf, sizeof(buf), ch); - if (devname != NULL) + if ((ai->dev == -1 && devfs_foreach_cdevpriv( + i_dev, dsp_oss_engineinfo_cb, ch) != 0) || + ai->dev == nchan) break; CHN_UNLOCK(ch); ++nchan; } - if (devname != NULL) { - /* - * At this point, the following synchronization stuff - * has happened: - * - a specific PCM device is locked. - * - a specific audio channel has been locked, so be - * sure to unlock when exiting; - */ + if (ch == NULL) { + PCM_UNLOCK(d); + continue; + } - caps = chn_getcaps(ch); + /* + * At this point, the following synchronization stuff + * has happened: + * - a specific PCM device is locked. + * - a specific audio channel has been locked, so be + * sure to unlock when exiting; + */ - /* - * With all handles collected, zero out the user's - * container and begin filling in its fields. - */ - bzero((void *)ai, sizeof(oss_audioinfo)); + caps = chn_getcaps(ch); - ai->dev = nchan; - strlcpy(ai->name, ch->name, sizeof(ai->name)); + /* + * With all handles collected, zero out the user's + * container and begin filling in its fields. + */ + bzero((void *)ai, sizeof(oss_audioinfo)); - if ((ch->flags & CHN_F_BUSY) == 0) - ai->busy = 0; - else - ai->busy = (ch->direction == PCMDIR_PLAY) ? OPEN_WRITE : OPEN_READ; + ai->dev = nchan; + strlcpy(ai->name, ch->name, sizeof(ai->name)); - ai->pid = ch->pid; - strlcpy(ai->cmd, ch->comm, sizeof(ai->cmd)); + if ((ch->flags & CHN_F_BUSY) == 0) + ai->busy = 0; + else + ai->busy = (ch->direction == PCMDIR_PLAY) ? OPEN_WRITE : OPEN_READ; - /* - * These flags stolen from SNDCTL_DSP_GETCAPS handler. - * Note, however, that a single channel operates in - * only one direction, so PCM_CAP_DUPLEX is out. - */ - /** - * @todo @c SNDCTL_AUDIOINFO::caps - Make drivers keep - * these in pcmchan::caps? - */ - ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER | - ((ch->flags & CHN_F_VIRTUAL) ? PCM_CAP_VIRTUAL : 0) | - ((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : PCM_CAP_INPUT); + ai->pid = ch->pid; + strlcpy(ai->cmd, ch->comm, sizeof(ai->cmd)); - /* - * Collect formats supported @b natively by the - * device. Also determine min/max channels. - */ - minch = INT_MAX; - maxch = 0; - fmts = 0; - for (i = 0; caps->fmtlist[i]; i++) { - fmts |= AFMT_ENCODING(caps->fmtlist[i]); - minch = min(AFMT_CHANNEL(caps->fmtlist[i]), minch); - maxch = max(AFMT_CHANNEL(caps->fmtlist[i]), maxch); - } + /* + * These flags stolen from SNDCTL_DSP_GETCAPS handler. + * Note, however, that a single channel operates in + * only one direction, so PCM_CAP_DUPLEX is out. + */ + /** + * @todo @c SNDCTL_AUDIOINFO::caps - Make drivers keep + * these in pcmchan::caps? + */ + ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER | + ((ch->flags & CHN_F_VIRTUAL) ? PCM_CAP_VIRTUAL : 0) | + ((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : PCM_CAP_INPUT); - if (ch->direction == PCMDIR_PLAY) - ai->oformats = fmts; - else - ai->iformats = fmts; - - /** - * @note - * @c magic - OSSv4 docs: "Reserved for internal use - * by OSS." - * - * @par - * @c card_number - OSSv4 docs: "Number of the sound - * card where this device belongs or -1 if this - * information is not available. Applications - * should normally not use this field for any - * purpose." - */ - ai->card_number = unit; - /** - * @todo @c song_name - depends first on - * SNDCTL_[GS]ETSONG @todo @c label - depends - * on SNDCTL_[GS]ETLABEL - * @todo @c port_number - routing information? - */ - ai->port_number = unit; - ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1; - /** - * @note - * @c legacy_device - OSSv4 docs: "Obsolete." - */ - ai->legacy_device = unit; - snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit); - ai->enabled = device_is_attached(d->dev) ? 1 : 0; - /** - * @note - * @c flags - OSSv4 docs: "Reserved for future use." - * - * @note - * @c binding - OSSv4 docs: "Reserved for future use." - * - * @todo @c handle - haven't decided how to generate - * this yet; bus, vendor, device IDs? - */ + /* + * Collect formats supported @b natively by the + * device. Also determine min/max channels. + */ + minch = INT_MAX; + maxch = 0; + fmts = 0; + for (i = 0; caps->fmtlist[i]; i++) { + fmts |= AFMT_ENCODING(caps->fmtlist[i]); + minch = min(AFMT_CHANNEL(caps->fmtlist[i]), minch); + maxch = max(AFMT_CHANNEL(caps->fmtlist[i]), maxch); + } - if ((ch->flags & CHN_F_EXCLUSIVE) || - (pcm_getflags(d->dev) & SD_F_BITPERFECT)) { - ai->min_rate = caps->minspeed; - ai->max_rate = caps->maxspeed; - } else { - ai->min_rate = feeder_rate_min; - ai->max_rate = feeder_rate_max; - } + if (ch->direction == PCMDIR_PLAY) + ai->oformats = fmts; + else + ai->iformats = fmts; + + /** + * @note + * @c magic - OSSv4 docs: "Reserved for internal use + * by OSS." + * + * @par + * @c card_number - OSSv4 docs: "Number of the sound + * card where this device belongs or -1 if this + * information is not available. Applications + * should normally not use this field for any + * purpose." + */ + ai->card_number = unit; + /** + * @todo @c song_name - depends first on + * SNDCTL_[GS]ETSONG @todo @c label - depends + * on SNDCTL_[GS]ETLABEL + * @todo @c port_number - routing information? + */ + ai->port_number = unit; + ai->mixer_dev = (d->mixer_dev != NULL) ? unit : -1; + /** + * @note + * @c legacy_device - OSSv4 docs: "Obsolete." + */ + ai->legacy_device = unit; + snprintf(ai->devnode, sizeof(ai->devnode), "/dev/dsp%d", unit); + ai->enabled = device_is_attached(d->dev) ? 1 : 0; + /** + * @note + * @c flags - OSSv4 docs: "Reserved for future use." + * + * @note + * @c binding - OSSv4 docs: "Reserved for future use." + * + * @todo @c handle - haven't decided how to generate + * this yet; bus, vendor, device IDs? + */ - ai->min_channels = minch; - ai->max_channels = maxch; + if ((ch->flags & CHN_F_EXCLUSIVE) || + (pcm_getflags(d->dev) & SD_F_BITPERFECT)) { + ai->min_rate = caps->minspeed; + ai->max_rate = caps->maxspeed; + } else { + ai->min_rate = feeder_rate_min; + ai->max_rate = feeder_rate_max; + } - ai->nrates = chn_getrates(ch, &rates); - if (ai->nrates > OSS_MAX_SAMPLE_RATES) - ai->nrates = OSS_MAX_SAMPLE_RATES; + ai->min_channels = minch; + ai->max_channels = maxch; - for (i = 0; i < ai->nrates; i++) - ai->rates[i] = rates[i]; - - ai->next_play_engine = 0; - ai->next_rec_engine = 0; + ai->nrates = chn_getrates(ch, &rates); + if (ai->nrates > OSS_MAX_SAMPLE_RATES) + ai->nrates = OSS_MAX_SAMPLE_RATES; - CHN_UNLOCK(ch); - } + for (i = 0; i < ai->nrates; i++) + ai->rates[i] = rates[i]; + + ai->next_play_engine = 0; + ai->next_rec_engine = 0; + CHN_UNLOCK(ch); PCM_UNLOCK(d); - if (devname != NULL) - return (0); + return (0); } /* Exhausted the search -- nothing is locked, so return. */ diff --git a/sys/dev/sound/pcm/dsp.h b/sys/dev/sound/pcm/dsp.h index 7559e855d4e1..1eab42ca91c8 100644 --- a/sys/dev/sound/pcm/dsp.h +++ b/sys/dev/sound/pcm/dsp.h @@ -35,7 +35,6 @@ extern struct cdevsw dsp_cdevsw; int dsp_make_dev(device_t); void dsp_destroy_dev(device_t); -char *dsp_unit2name(char *, size_t, struct pcm_channel *); int dsp_oss_audioinfo(struct cdev *, oss_audioinfo *, bool); int dsp_oss_engineinfo(struct cdev *, oss_audioinfo *); diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index f96638081cb9..126b3411b035 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -225,10 +225,6 @@ enum { SND_DEV_MIDIN, /* Raw midi access */ SND_DEV_DSP, /* Digitized voice /dev/dsp */ SND_DEV_STATUS, /* /dev/sndstat */ - SND_DEV_DSPHW_PLAY, /* specific playback channel */ - SND_DEV_DSPHW_VPLAY, /* specific virtual playback channel */ - SND_DEV_DSPHW_REC, /* specific record channel */ - SND_DEV_DSPHW_VREC, /* specific virtual record channel */ }; #define DSP_DEFAULT_SPEED 8000 diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index 4da6f83dc0a2..c9db9d79847b 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -886,14 +886,9 @@ vchan_sync(struct pcm_channel *c) c->flags |= CHN_F_DIRTY; #ifdef SND_DEBUG - if (snd_passthrough_verbose != 0) { - char *devname, buf[CHN_NAMELEN]; - - devname = dsp_unit2name(buf, sizeof(buf), c); - device_printf(c->dev, - "%s(%s/%s) %s() -> re-sync err=%d\n", - __func__, (devname != NULL) ? devname : "dspX", c->comm, - caller, ret); + if (snd_passthrough_verbose) { + device_printf(c->dev, "%s(%s/%s) %s() -> re-sync err=%d\n", + __func__, c->name, c->comm, caller, ret); } #endif