From nobody Tue Apr 16 01:48:03 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 4VJRkq5Jrwz5HWRR; Tue, 16 Apr 2024 01:48:03 +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 4VJRkq4r4Lz4Bnq; Tue, 16 Apr 2024 01:48:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713232083; 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=0eSAM7leZEq3Xb1SsCHjt5MJty3cstjSMmuSkhOYW/w=; b=Zyf9h42JF/eBL9umXe0NZvbNAQUARE9wv3f2QrjBPcb/Er/p4kO086J1Nl+dQWL/tg5Hfb 8sxCju2GSSli+hlu//58mFjA5xcTbXeXoDaPIk7uRx2JXt7ePzuuPKKS4OPN02pPnfe0Of 19J+96SK+ww07vK0rbGGN30AOQG/zqSiYFrDTPnIBkSAfnkOC23Z78TdzHn7HwRckJasSi UPOZSYymqpKMCkZPBSOnNzCZFxUGil5cDtmXm79tLG4dfCRUW0urpoOiSpfXJ0n/rwrwx6 2laRnHLFQpzsdPW91MO+pu+zgMZJQXAyGDYbA4cJ8H/pn1TM4HrrXjfCgWjeqA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713232083; a=rsa-sha256; cv=none; b=O6Yojqnv2FpKTRQxWwWoHOcF5G+RM/HRM8k7SFGRg+TcfPOf03ob90GRMhSRWGjJS6pYex m7L1frM99OQJdUD20okOwGvCGDA4gU+YBrQ7donVUr8z8cwOstWzcsOD4vN+nnC35o//Pb FuI6tUVA+D1gqeLeDdTMRY+8IWw6P+pU7CFBy5zo1bUMzLvnNcwTntdLht8avHxYTTP3We jS0fqAn/a/6AQxZJcHJZ769e6m6pe5GYRoyEvgusRnu9fjKiDLXSqspKPf/5PtlYFfMdRL fxZM1Aqaa+inLNEbKiZzOnIaNNvF3apjwVo5DaL8854WYqfcza1vIm+7q+d3rA== 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=1713232083; 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=0eSAM7leZEq3Xb1SsCHjt5MJty3cstjSMmuSkhOYW/w=; b=CJKAcAFVhazfLy+NbGJwtNoJCb8DWK15PLVHLxRs2udNEAbPY2NRwEYBKj6QEK0X894Dgm rQS0OKKTW6a19tXygf86zvjTWJN8wEr3uuyg5Z1PmfHsV7PIHe+Moq/42zz32ZTMsf21Wb KMH1B4gG7SZqnw4QJF+pq5NtgUwW90fCiRwdWeVDIef6n2NulJ3+FPn6U0ZgSktO/WIg1d voRpkbIvqllza86qWALyewPJEbK24/TLmhKJ/askvVAKCNRbg9KN/hniOCnYkf0i8eAMRE iZhoaWwI03bBUlM4ZBO3r3g8xfsWDo+o/QPSmA6Hn2jmXK9abCB1T+xEQNZaBg== 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 4VJRkq4Jp0zNyJ; Tue, 16 Apr 2024 01:48:03 +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 43G1m3QZ052462; Tue, 16 Apr 2024 01:48:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43G1m3ox052459; Tue, 16 Apr 2024 01:48:03 GMT (envelope-from git) Date: Tue, 16 Apr 2024 01:48:03 GMT Message-Id: <202404160148.43G1m3ox052459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 72eb6d65ede2 - stable/14 - 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/stable/14 X-Git-Reftype: branch X-Git-Commit: 72eb6d65ede22a235886bfa610217a33247f3de8 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=72eb6d65ede22a235886bfa610217a33247f3de8 commit 72eb6d65ede22a235886bfa610217a33247f3de8 Author: Christos Margiolis AuthorDate: 2024-04-02 16:56:39 +0000 Commit: Christos Margiolis CommitDate: 2024-04-16 01:47:57 +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 (cherry picked from commit 9da3b645dbaaad724d524727d003fed7be05ff7c) --- 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 c03e4fa435e1..5f5fced9b7f0 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) { @@ -1276,7 +1140,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 0; } diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index 51d1624b2d7e..e3405a85f3c9 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -341,8 +341,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) */