git: b768f2c7773b - main - sound: Retire SD_F_AUTOVCHAN

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Mon, 10 Mar 2025 20:49:57 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=b768f2c7773b6e306fb43687657414f9f42a27d4

commit b768f2c7773b6e306fb43687657414f9f42a27d4
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-03-10 20:47:35 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-03-10 20:47:35 +0000

    sound: Retire SD_F_AUTOVCHAN
    
    This flag is redundant and essentially a no-op, as it is set when the
    device supports at least playback or recording, which is almost always
    the case. But even if the device is mixer-only (i.e., 0 channels), there
    is no reason to keep this flag; it is only used to bail out of the vchan
    sysctl handlers, but we already bail out anyway if we try to use the
    sysctl in a vchan direction that is not supported.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D49021
---
 sys/dev/sound/pcm/sound.c | 7 +------
 sys/dev/sound/pcm/sound.h | 4 ++--
 sys/dev/sound/pcm/vchan.c | 8 ++++----
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 3e76626f5c57..5759c06725ce 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -369,8 +369,7 @@ pcm_sysinit(device_t dev)
 	    OID_AUTO, "mode", CTLFLAG_RD, NULL, mode,
 	    "mode (1=mixer, 2=play, 4=rec. The values are OR'ed if more than "
 	    "one mode is supported)");
-	if (d->flags & SD_F_AUTOVCHAN)
-		vchan_initsys(dev);
+	vchan_initsys(dev);
 	if (d->flags & SD_F_EQ)
 		feeder_eq_initsys(dev);
 }
@@ -430,10 +429,6 @@ pcm_register(device_t dev, char *str)
 
 	if (d->playcount == 0 || d->reccount == 0)
 		d->flags |= SD_F_SIMPLEX;
-
-	if (d->playcount > 0 || d->reccount > 0)
-		d->flags |= SD_F_AUTOVCHAN;
-
 	if (d->playcount > 0)
 		d->flags |= SD_F_PVCHANS;
 	if (d->reccount > 0)
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index df08b1700869..7f17c710038a 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -99,7 +99,7 @@ struct snd_mixer;
 #define SOUND_MAXVER	SOUND_MODVER
 
 #define SD_F_SIMPLEX		0x00000001
-#define SD_F_AUTOVCHAN		0x00000002
+/* unused			0x00000002 */
 #define SD_F_SOFTPCMVOL		0x00000004
 #define SD_F_BUSY		0x00000008
 #define SD_F_MPSAFE		0x00000010
@@ -122,7 +122,7 @@ struct snd_mixer;
 
 #define SD_F_BITS		"\020"					\
 				"\001SIMPLEX"				\
-				"\002AUTOVCHAN"				\
+				/* "\002 */				\
 				"\003SOFTPCMVOL"			\
 				"\004BUSY"				\
 				"\005MPSAFE"				\
diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 27739fe68852..2b300e90ea4d 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -260,7 +260,7 @@ sysctl_dev_pcm_vchans(SYSCTL_HANDLER_ARGS)
 	int err, enabled, flag;
 
 	d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
-	if (!PCM_REGISTERED(d) || !(d->flags & SD_F_AUTOVCHAN))
+	if (!PCM_REGISTERED(d))
 		return (EINVAL);
 
 	PCM_LOCK(d);
@@ -318,7 +318,7 @@ sysctl_dev_pcm_vchanmode(SYSCTL_HANDLER_ARGS)
 	char dtype[16];
 
 	d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
-	if (!PCM_REGISTERED(d) || !(d->flags & SD_F_AUTOVCHAN))
+	if (!PCM_REGISTERED(d))
 		return (EINVAL);
 
 	PCM_LOCK(d);
@@ -409,7 +409,7 @@ sysctl_dev_pcm_vchanrate(SYSCTL_HANDLER_ARGS)
 	int *vchanrate, direction, ret, newspd, restart;
 
 	d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
-	if (!PCM_REGISTERED(d) || !(d->flags & SD_F_AUTOVCHAN))
+	if (!PCM_REGISTERED(d))
 		return (EINVAL);
 
 	PCM_LOCK(d);
@@ -508,7 +508,7 @@ sysctl_dev_pcm_vchanformat(SYSCTL_HANDLER_ARGS)
 	char fmtstr[AFMTSTR_LEN];
 
 	d = devclass_get_softc(pcm_devclass, VCHAN_SYSCTL_UNIT(oidp->oid_arg1));
-	if (!PCM_REGISTERED(d) || !(d->flags & SD_F_AUTOVCHAN))
+	if (!PCM_REGISTERED(d))
 		return (EINVAL);
 
 	PCM_LOCK(d);