sound: Retire FEEDEQ_BYPASS

In effect, this is the same as the disable state. There is a comment
that says the bypass state skips EQ altogether, which is what the
disable should be. The disable state according to the comment disables
EQ but keeps the EQ preamp (dev.pcm.%d.eq_preamp), however after testing
it seems that the preamp does not really take effect, because with EQ
disabled, feeder_eq is non existent, so we never execute any EQ code in
the first place.

Make things simpler and clearer and have 2 states; enable and disable,
and do what they should do intuitively.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Pull Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/15
This commit is contained in:
Christos Margiolis committed 2026-05-27 17:27:11 +02:00
1 parent a0011c74f8
commit 54a03b44ae
4 files changed
+10 -25

No files matched your search

+1 -3
View File
@@ -2209,9 +2209,7 @@ chn_syncstate(struct pcm_channel *c)
device_printf(c->dev,
"EQ: Failed to set preamp -- %d\n",
d->eqpreamp);
if (d->flags & SD_F_EQ_BYPASSED)
state = FEEDEQ_BYPASS;
else if (d->flags & SD_F_EQ_ENABLED)
if (d->flags & SD_F_EQ_ENABLED)
state = FEEDEQ_ENABLE;
else
state = FEEDEQ_DISABLE;
-1
View File
@@ -122,7 +122,6 @@ enum {
FEEDEQ_STATE,
FEEDEQ_DISABLE,
FEEDEQ_ENABLE,
FEEDEQ_BYPASS,
FEEDEQ_UNKNOWN
};
+7 -19
View File
@@ -334,8 +334,7 @@ feed_eq_set(struct pcm_feeder *f, int what, int value)
info->preamp = FEEDEQ_PREAMP2IDX(value);
break;
case FEEDEQ_STATE:
if (!(value == FEEDEQ_BYPASS || value == FEEDEQ_ENABLE ||
value == FEEDEQ_DISABLE))
if (!(value == FEEDEQ_ENABLE || value == FEEDEQ_DISABLE))
return (EINVAL);
info->state = value;
feed_eq_reset(info);
@@ -370,13 +369,7 @@ feed_eq_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
info = f->data;
/*
* 3 major states:
* FEEDEQ_BYPASS - Bypass entirely, nothing happened.
* FEEDEQ_ENABLE - Preamp+biquad filtering.
* FEEDEQ_DISABLE - Preamp only.
*/
if (info->state == FEEDEQ_BYPASS)
if (info->state == FEEDEQ_DISABLE)
return (FEEDER_FEED(f->source, c, b, count, source));
dst = b;
@@ -482,9 +475,7 @@ sysctl_dev_pcm_eq(SYSCTL_HANDLER_ARGS)
PCM_LOCK(d);
PCM_WAIT(d);
if (d->flags & SD_F_EQ_BYPASSED)
val = 2;
else if (d->flags & SD_F_EQ_ENABLED)
if (d->flags & SD_F_EQ_ENABLED)
val = 1;
else
val = 0;
@@ -495,18 +486,15 @@ sysctl_dev_pcm_eq(SYSCTL_HANDLER_ARGS)
err = sysctl_handle_int(oidp, &val, 0, req);
if (err == 0 && req->newptr != NULL && val != oval) {
if (!(val == 0 || val == 1 || val == 2)) {
if (!(val == 0 || val == 1)) {
PCM_RELEASE_QUICK(d);
return (EINVAL);
}
PCM_LOCK(d);
d->flags &= ~(SD_F_EQ_ENABLED | SD_F_EQ_BYPASSED);
if (val == 2) {
val = FEEDEQ_BYPASS;
d->flags |= SD_F_EQ_BYPASSED;
} else if (val == 1) {
d->flags &= ~(SD_F_EQ_ENABLED);
if (val == 1) {
val = FEEDEQ_ENABLE;
d->flags |= SD_F_EQ_ENABLED;
} else
@@ -612,7 +600,7 @@ feeder_eq_initsys(device_t dev)
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"eq", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, d,
sizeof(d), sysctl_dev_pcm_eq, "I",
"Bass/Treble Equalizer (0=disable, 1=enable, 2=bypass)");
"Bass/Treble Equalizer (0=disable, 1=enable)");
(void)snprintf(buf, sizeof(buf), "Bass/Treble Equalizer Preamp "
"(-/+ %d.0dB , %d.%ddB step)",
+2 -2
View File
@@ -107,7 +107,7 @@ struct snd_mixer;
#define SD_F_VPC 0x00000080 /* volume-per-channel */
/* unused 0x00000100 */
#define SD_F_EQ_ENABLED 0x00000200 /* EQ enabled */
#define SD_F_EQ_BYPASSED 0x00000400 /* EQ bypassed */
/* unused 0x00000400 */
#define SD_F_EQ_PC 0x00000800 /* EQ per-channel */
#define SD_F_PVCHANS 0x00001000 /* Playback vchans enabled */
#define SD_F_RVCHANS 0x00002000 /* Recording vchans enabled */
@@ -123,7 +123,7 @@ struct snd_mixer;
"\010VPC" \
/* "\011 */ \
"\012EQ_ENABLED" \
"\013EQ_BYPASSED" \
/* "\013 */ \
"\014EQ_PC" \
"\015PVCHANS" \
"\016RVCHANS"