From nobody Tue Apr 02 16:57:04 2024 X-Original-To: dev-commits-src-all@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 4V8DZ86t0Tz5FGQZ; Tue, 2 Apr 2024 16:57:04 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V8DZ84zX6z4f9v; Tue, 2 Apr 2024 16:57:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712077024; 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=WbW+TPMrp25sFV+FZha1D81DEC+UGmbz96fQ+xPd8tg=; b=fDMu4X9qDOfFv8uvZPuBIm9ZA7KtJcCRldd8G7SfylS3BebR0to1PU5qTgQE1URqlM2zgE Pz9MTMoB7Ux6O6wESvOnSKikgWG7sp1SLYUHpTZy6FYxA4mB/tSmgXGPR9vHFIl5RQozSt 6PK+uA0NIQeAtdJmeMzcqy1JX26HBu+8S2N4W/c7Y+liCJPXKk8DLS98ExZQeFEtc0s1mg YXa4K+pBkzyy1OgNmM35GNOHl2+GLqz2RdFcJ6gpKeRCA1uttVPOltA9lcixl8uQEF+HWB ptxtoIImtocAR1qfahsSiqeZsdS1EGkkJwJ3GjJCDUcx+HERobcP7d6EzKixMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712077024; a=rsa-sha256; cv=none; b=V/8QhOwEtHL66hgenrwp+lV/aVROMzVCUTMKJebLekYtSsgfy5j5Xd4wsM0JfED+IFFMr9 puHvRix7K/XoUFo0H2Dj6iIIPPNdRqL1eo73//VV6OH9YJilPaxVyoTC/OPalGt42nI8gn OemQCpLcJPIMD0qiTyv+Heg+56wB5GbBgh7O1wrsqJfvEUsqWO2UdrXxIAKGgwIUvyxT8n DA9qf68VOTG997bzKtbwWMExpYUsu/VVbEpn90eDs0IDe6k4R8jweFost+CsiIE6Js73Ut tw20cnGRbyUBRaTnoQK+HQqIAVvq9i1BDOSb4pSr12r+GPkC/coSHNCHeT29qA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712077024; 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=WbW+TPMrp25sFV+FZha1D81DEC+UGmbz96fQ+xPd8tg=; b=IPZFY5PItoD2eEFh+w/VnNwT6BIkzr4IP5Tq72+2qmiuhV592PP9L4+jRz9RinnKU/W5Lf dm6qAxiSmM3/SKuxwgzdiXxfXNgsvwgP99CRmCKe/BfjAO/+krbaXRcQp1dzvmDB1W0Onr rw219RcueBiTbUTYe6JSSVARUJv4cTRdS9WJaMIUhGeuDQR0NifM0iAMlC9bkBf9r6BSlX 5vCA4upMhQdA78fJTk98dNqqwG/rlSTpKd0pcoZz00z37Cf/J1LiAvdvvePjPyTG2QhWc8 y2eHNC+h8uO6HmywjCkttBEqjjmHYNsYO02TsLkIv5MnHSJ/HCmE7gHtn6/UbQ== 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 4V8DZ84WpLzwl5; Tue, 2 Apr 2024 16:57:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 432Gv4HI026321; Tue, 2 Apr 2024 16:57:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 432Gv4NP026318; Tue, 2 Apr 2024 16:57:04 GMT (envelope-from git) Date: Tue, 2 Apr 2024 16:57:04 GMT Message-Id: <202404021657.432Gv4NP026318@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: 9da3b645dbaa - main - sound: Move sndstat_prepare_pcm() to pcm/sndstat.c and remove sndstat_entry->handler List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 9da3b645dbaaad724d524727d003fed7be05ff7c Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=9da3b645dbaaad724d524727d003fed7be05ff7c commit 9da3b645dbaaad724d524727d003fed7be05ff7c Author: Christos Margiolis AuthorDate: 2024-04-02 16:56:39 +0000 Commit: Christos Margiolis CommitDate: 2024-04-02 16:56:39 +0000 sound: Move sndstat_prepare_pcm() to pcm/sndstat.c and remove sndstat_entry->handler Since all sndstat_entry->handler fields point to sndstat_prepare_pcm(), we can just call the function directly, without assigning it to a function pointer and calling it indirectly. While here, move sndstat_prepare_pcm() to pcm/sndstat.c, as it is more suitable there. No functional change intended. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D44571 --- sys/dev/sound/pcm/sndstat.c | 152 +++++++++++++++++++++++++++++++++++++++++--- sys/dev/sound/pcm/sound.c | 138 +--------------------------------------- sys/dev/sound/pcm/sound.h | 3 +- 3 files changed, 145 insertions(+), 148 deletions(-) diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index 32b47b8ee105..0279060181b3 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -49,6 +49,8 @@ #include #include +#include "feeder_if.h" + #define SS_TYPE_PCM 1 #define SS_TYPE_MIDI 2 #define SS_TYPE_SEQUENCER 3 @@ -73,7 +75,6 @@ struct sndstat_entry { TAILQ_ENTRY(sndstat_entry) link; device_t dev; char *str; - sndstat_handler handler; int type, unit; }; @@ -1050,7 +1051,7 @@ fail: /************************************************************************/ int -sndstat_register(device_t dev, char *str, sndstat_handler handler) +sndstat_register(device_t dev, char *str) { struct sndstat_entry *ent; struct sndstat_entry *pre; @@ -1073,7 +1074,6 @@ sndstat_register(device_t dev, char *str, sndstat_handler handler) ent->str = str; ent->type = type; ent->unit = unit; - ent->handler = handler; SNDSTAT_LOCK(); /* sorted list insertion */ @@ -1119,6 +1119,142 @@ sndstat_unregister(device_t dev) /************************************************************************/ +static int +sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose) +{ + struct snddev_info *d; + struct pcm_channel *c; + struct pcm_feeder *f; + + d = device_get_softc(dev); + PCM_BUSYASSERT(d); + + if (CHN_EMPTY(d, channels.pcm)) { + sbuf_printf(s, " (mixer only)"); + return (0); + } + + if (verbose < 1) { + sbuf_printf(s, " (%s%s%s", + d->playcount ? "play" : "", + (d->playcount && d->reccount) ? "/" : "", + d->reccount ? "rec" : ""); + } else { + sbuf_printf(s, " (%dp:%dv/%dr:%dv", + d->playcount, d->pvchancount, + d->reccount, d->rvchancount); + } + sbuf_printf(s, "%s)%s", + ((d->playcount != 0 && d->reccount != 0) && + (d->flags & SD_F_SIMPLEX)) ? " simplex" : "", + (device_get_unit(dev) == snd_unit) ? " default" : ""); + + if (verbose <= 1) + return (0); + + sbuf_printf(s, "\n\t"); + sbuf_printf(s, "snddev flags=0x%b", d->flags, SD_F_BITS); + + CHN_FOREACH(c, d, channels.pcm) { + KASSERT(c->bufhard != NULL && c->bufsoft != NULL, + ("hosed pcm channel setup")); + + sbuf_printf(s, "\n\t"); + + sbuf_printf(s, "%s[%s]: ", + (c->parentchannel != NULL) ? + c->parentchannel->name : "", c->name); + sbuf_printf(s, "spd %d", c->speed); + if (c->speed != sndbuf_getspd(c->bufhard)) { + sbuf_printf(s, "/%d", + sndbuf_getspd(c->bufhard)); + } + sbuf_printf(s, ", fmt 0x%08x", c->format); + if (c->format != sndbuf_getfmt(c->bufhard)) { + sbuf_printf(s, "/0x%08x", + sndbuf_getfmt(c->bufhard)); + } + sbuf_printf(s, ", flags 0x%08x, 0x%08x", + c->flags, c->feederflags); + if (c->pid != -1) { + sbuf_printf(s, ", pid %d (%s)", + c->pid, c->comm); + } + sbuf_printf(s, "\n\t"); + + sbuf_printf(s, "interrupts %d, ", c->interrupts); + + if (c->direction == PCMDIR_REC) { + sbuf_printf(s, + "overruns %d, feed %u, hfree %d, " + "sfree %d [b:%d/%d/%d|bs:%d/%d/%d]", + c->xruns, c->feedcount, + sndbuf_getfree(c->bufhard), + sndbuf_getfree(c->bufsoft), + sndbuf_getsize(c->bufhard), + sndbuf_getblksz(c->bufhard), + sndbuf_getblkcnt(c->bufhard), + sndbuf_getsize(c->bufsoft), + sndbuf_getblksz(c->bufsoft), + sndbuf_getblkcnt(c->bufsoft)); + } else { + sbuf_printf(s, + "underruns %d, feed %u, ready %d " + "[b:%d/%d/%d|bs:%d/%d/%d]", + c->xruns, c->feedcount, + sndbuf_getready(c->bufsoft), + sndbuf_getsize(c->bufhard), + sndbuf_getblksz(c->bufhard), + sndbuf_getblkcnt(c->bufhard), + sndbuf_getsize(c->bufsoft), + sndbuf_getblksz(c->bufsoft), + sndbuf_getblkcnt(c->bufsoft)); + } + sbuf_printf(s, "\n\t"); + + sbuf_printf(s, "channel flags=0x%b", c->flags, CHN_F_BITS); + sbuf_printf(s, "\n\t"); + + sbuf_printf(s, "{%s}", + (c->direction == PCMDIR_REC) ? "hardware" : "userland"); + sbuf_printf(s, " -> "); + f = c->feeder; + while (f->source != NULL) + f = f->source; + while (f != NULL) { + sbuf_printf(s, "%s", f->class->name); + if (f->desc->type == FEEDER_FORMAT) { + sbuf_printf(s, "(0x%08x -> 0x%08x)", + f->desc->in, f->desc->out); + } else if (f->desc->type == FEEDER_MATRIX) { + sbuf_printf(s, "(%d.%d -> %d.%d)", + AFMT_CHANNEL(f->desc->in) - + AFMT_EXTCHANNEL(f->desc->in), + AFMT_EXTCHANNEL(f->desc->in), + AFMT_CHANNEL(f->desc->out) - + AFMT_EXTCHANNEL(f->desc->out), + AFMT_EXTCHANNEL(f->desc->out)); + } else if (f->desc->type == FEEDER_RATE) { + sbuf_printf(s, + "(0x%08x q:%d %d -> %d)", + f->desc->out, + FEEDER_GET(f, FEEDRATE_QUALITY), + FEEDER_GET(f, FEEDRATE_SRC), + FEEDER_GET(f, FEEDRATE_DST)); + } else { + sbuf_printf(s, "(0x%08x)", + f->desc->out); + } + sbuf_printf(s, " -> "); + f = f->parent; + } + sbuf_printf(s, "{%s}", + (c->direction == PCMDIR_REC) ? "userland" : "hardware"); + } + + return (0); +} + static int sndstat_prepare(struct sndstat_file *pf_self) { @@ -1149,12 +1285,10 @@ sndstat_prepare(struct sndstat_file *pf_self) sbuf_printf(s, " <%s>", device_get_desc(ent->dev)); if (snd_verbose > 0) sbuf_printf(s, " %s", ent->str); - if (ent->handler) { - /* XXX Need Giant magic entry ??? */ - PCM_ACQUIRE_QUICK(d); - ent->handler(s, ent->dev, snd_verbose); - PCM_RELEASE_QUICK(d); - } + /* XXX Need Giant magic entry ??? */ + PCM_ACQUIRE_QUICK(d); + sndstat_prepare_pcm(s, ent->dev, snd_verbose); + PCM_RELEASE_QUICK(d); sbuf_printf(s, "\n"); } if (k == 0) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index b45ca30dc984..1517126210c4 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -74,142 +74,6 @@ SYSCTL_STRING(_hw_snd, OID_AUTO, version, CTLFLAG_RD, &snd_driver_version, */ struct unrhdr *pcmsg_unrhdr = NULL; -static int -sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose) -{ - struct snddev_info *d; - struct pcm_channel *c; - struct pcm_feeder *f; - - d = device_get_softc(dev); - PCM_BUSYASSERT(d); - - if (CHN_EMPTY(d, channels.pcm)) { - sbuf_printf(s, " (mixer only)"); - return (0); - } - - if (verbose < 1) { - sbuf_printf(s, " (%s%s%s", - d->playcount ? "play" : "", - (d->playcount && d->reccount) ? "/" : "", - d->reccount ? "rec" : ""); - } else { - sbuf_printf(s, " (%dp:%dv/%dr:%dv", - d->playcount, d->pvchancount, - d->reccount, d->rvchancount); - } - sbuf_printf(s, "%s)%s", - ((d->playcount != 0 && d->reccount != 0) && - (d->flags & SD_F_SIMPLEX)) ? " simplex" : "", - (device_get_unit(dev) == snd_unit) ? " default" : ""); - - if (verbose <= 1) - return (0); - - sbuf_printf(s, "\n\t"); - sbuf_printf(s, "snddev flags=0x%b", d->flags, SD_F_BITS); - - CHN_FOREACH(c, d, channels.pcm) { - KASSERT(c->bufhard != NULL && c->bufsoft != NULL, - ("hosed pcm channel setup")); - - sbuf_printf(s, "\n\t"); - - sbuf_printf(s, "%s[%s]: ", - (c->parentchannel != NULL) ? - c->parentchannel->name : "", c->name); - sbuf_printf(s, "spd %d", c->speed); - if (c->speed != sndbuf_getspd(c->bufhard)) { - sbuf_printf(s, "/%d", - sndbuf_getspd(c->bufhard)); - } - sbuf_printf(s, ", fmt 0x%08x", c->format); - if (c->format != sndbuf_getfmt(c->bufhard)) { - sbuf_printf(s, "/0x%08x", - sndbuf_getfmt(c->bufhard)); - } - sbuf_printf(s, ", flags 0x%08x, 0x%08x", - c->flags, c->feederflags); - if (c->pid != -1) { - sbuf_printf(s, ", pid %d (%s)", - c->pid, c->comm); - } - sbuf_printf(s, "\n\t"); - - sbuf_printf(s, "interrupts %d, ", c->interrupts); - - if (c->direction == PCMDIR_REC) { - sbuf_printf(s, - "overruns %d, feed %u, hfree %d, " - "sfree %d [b:%d/%d/%d|bs:%d/%d/%d]", - c->xruns, c->feedcount, - sndbuf_getfree(c->bufhard), - sndbuf_getfree(c->bufsoft), - sndbuf_getsize(c->bufhard), - sndbuf_getblksz(c->bufhard), - sndbuf_getblkcnt(c->bufhard), - sndbuf_getsize(c->bufsoft), - sndbuf_getblksz(c->bufsoft), - sndbuf_getblkcnt(c->bufsoft)); - } else { - sbuf_printf(s, - "underruns %d, feed %u, ready %d " - "[b:%d/%d/%d|bs:%d/%d/%d]", - c->xruns, c->feedcount, - sndbuf_getready(c->bufsoft), - sndbuf_getsize(c->bufhard), - sndbuf_getblksz(c->bufhard), - sndbuf_getblkcnt(c->bufhard), - sndbuf_getsize(c->bufsoft), - sndbuf_getblksz(c->bufsoft), - sndbuf_getblkcnt(c->bufsoft)); - } - sbuf_printf(s, "\n\t"); - - sbuf_printf(s, "channel flags=0x%b", c->flags, CHN_F_BITS); - sbuf_printf(s, "\n\t"); - - sbuf_printf(s, "{%s}", - (c->direction == PCMDIR_REC) ? "hardware" : "userland"); - sbuf_printf(s, " -> "); - f = c->feeder; - while (f->source != NULL) - f = f->source; - while (f != NULL) { - sbuf_printf(s, "%s", f->class->name); - if (f->desc->type == FEEDER_FORMAT) { - sbuf_printf(s, "(0x%08x -> 0x%08x)", - f->desc->in, f->desc->out); - } else if (f->desc->type == FEEDER_MATRIX) { - sbuf_printf(s, "(%d.%d -> %d.%d)", - AFMT_CHANNEL(f->desc->in) - - AFMT_EXTCHANNEL(f->desc->in), - AFMT_EXTCHANNEL(f->desc->in), - AFMT_CHANNEL(f->desc->out) - - AFMT_EXTCHANNEL(f->desc->out), - AFMT_EXTCHANNEL(f->desc->out)); - } else if (f->desc->type == FEEDER_RATE) { - sbuf_printf(s, - "(0x%08x q:%d %d -> %d)", - f->desc->out, - FEEDER_GET(f, FEEDRATE_QUALITY), - FEEDER_GET(f, FEEDRATE_SRC), - FEEDER_GET(f, FEEDRATE_DST)); - } else { - sbuf_printf(s, "(0x%08x)", - f->desc->out); - } - sbuf_printf(s, " -> "); - f = f->parent; - } - sbuf_printf(s, "{%s}", - (c->direction == PCMDIR_REC) ? "userland" : "hardware"); - } - - return (0); -} - void * snd_mtxcreate(const char *desc, const char *type) { @@ -1109,7 +973,7 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec) if (numplay > 0 || numrec > 0) d->flags |= SD_F_AUTOVCHAN; - sndstat_register(dev, d->status, sndstat_prepare_pcm); + sndstat_register(dev, d->status); return (dsp_make_dev(dev)); } diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index d95e3a29521c..b48aed7c2d6e 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -338,8 +338,7 @@ void snd_mtxassert(void *m); #define snd_mtxlock(m) mtx_lock(m) #define snd_mtxunlock(m) mtx_unlock(m) -typedef int (*sndstat_handler)(struct sbuf *s, device_t dev, int verbose); -int sndstat_register(device_t dev, char *str, sndstat_handler handler); +int sndstat_register(device_t dev, char *str); int sndstat_unregister(device_t dev); /* usage of flags in device config entry (config file) */