git: 00731aaaed76 - main - sound: Remove dead code from pcm/

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Mon, 02 Dec 2024 16:27:21 UTC
The branch main has been updated by christos:

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

commit 00731aaaed76785af8befe13e9a4e85b3554b3f5
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-12-02 16:26:27 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-12-02 16:26:27 +0000

    sound: Remove dead code from pcm/
    
    No functional change intended.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch, markj
    Differential Revision:  https://reviews.freebsd.org/D47733
---
 sys/dev/sound/pcm/ac97.c        | 23 ------------------
 sys/dev/sound/pcm/buffer.c      |  9 -------
 sys/dev/sound/pcm/channel.c     | 53 -----------------------------------------
 sys/dev/sound/pcm/dsp.c         | 22 -----------------
 sys/dev/sound/pcm/feeder.h      | 26 --------------------
 sys/dev/sound/pcm/feeder_rate.c | 21 ----------------
 6 files changed, 154 deletions(-)

diff --git a/sys/dev/sound/pcm/ac97.c b/sys/dev/sound/pcm/ac97.c
index 71eb387afa1b..f5ca06cd3942 100644
--- a/sys/dev/sound/pcm/ac97.c
+++ b/sys/dev/sound/pcm/ac97.c
@@ -322,12 +322,6 @@ ac97_rdcd(struct ac97_info *codec, int reg)
 		i[1] = AC97_READ(codec->methods, codec->devinfo, reg);
 		while (i[0] != i[1] && j)
 			i[j-- & 1] = AC97_READ(codec->methods, codec->devinfo, reg);
-#if 0
-		if (j < 100) {
-			device_printf(codec->dev, "%s(): Inconsistent register value at"
-					" 0x%08x (retry: %d)\n", __func__, reg, 100 - j);
-		}
-#endif
 		return i[!(j & 1)];
 	}
 	return AC97_READ(codec->methods, codec->devinfo, reg);
@@ -512,9 +506,6 @@ ac97_setmixer(struct ac97_info *codec, unsigned channel, unsigned left, unsigned
 		snd_mtxunlock(codec->lock);
 		return left | (right << 8);
 	} else {
-#if 0
-		printf("ac97_setmixer: reg=%d, bits=%d, enable=%d\n", e->reg, e->bits, e->enable);
-#endif
 		return -1;
 	}
 }
@@ -737,10 +728,6 @@ ac97_initmixer(struct ac97_info *codec)
 				for (j = 0; k >> j; j++)
 					;
 				if (j != 0) {
-#if 0
-					device_printf(codec->dev, "%2d: [ac97_rdcd() = %d] [Testbit = %d] %d -> %d\n",
-						i, k, bit, codec->mix[i].bits, j);
-#endif
 					codec->mix[i].enable = 1;
 					codec->mix[i].bits = j;
 				} else if (reg == AC97_MIX_BEEP) {
@@ -756,9 +743,6 @@ ac97_initmixer(struct ac97_info *codec)
 				codec->mix[i].enable = 0;
 			ac97_wrcd(codec, reg, old);
 		}
-#if 0
-		printf("mixch %d, en=%d, b=%d\n", i, codec->mix[i].enable, codec->mix[i].bits);
-#endif
 	}
 
 	device_printf(codec->dev, "<%s>\n",
@@ -1097,13 +1081,6 @@ ac97mix_init(struct snd_mixer *m)
 
 	if (pcm_getflags(codec->dev) & SD_F_SOFTPCMVOL)
 		ac97_wrcd(codec, AC97_MIX_PCM, 0);
-#if 0
-	/* XXX For the sake of debugging purposes */
-	mix_setparentchild(m, SOUND_MIXER_VOLUME,
-	    SOUND_MASK_PCM | SOUND_MASK_CD);
-	mix_setrealdev(m, SOUND_MIXER_VOLUME, SOUND_MIXER_NONE);
-	ac97_wrcd(codec, AC97_MIX_MASTER, 0);
-#endif
 
 	mask = 0;
 	for (i = 0; i < AC97_MIXER_SIZE; i++)
diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c
index afb4b95e357a..8bf3631afb7a 100644
--- a/sys/dev/sound/pcm/buffer.c
+++ b/sys/dev/sound/pcm/buffer.c
@@ -356,15 +356,6 @@ sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt)
 	b->fmt = fmt;
 	b->bps = AFMT_BPS(b->fmt);
 	b->align = AFMT_ALIGN(b->fmt);
-#if 0
-	b->bps = AFMT_CHANNEL(b->fmt);
-	if (b->fmt & AFMT_16BIT)
-		b->bps <<= 1;
-	else if (b->fmt & AFMT_24BIT)
-		b->bps *= 3;
-	else if (b->fmt & AFMT_32BIT)
-		b->bps <<= 2;
-#endif
 	return 0;
 }
 
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index f619ddd4bc35..728284b055e5 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -405,23 +405,6 @@ chn_wrfeed(struct pcm_channel *c)
 		chn_wakeup(c);
 }
 
-#if 0
-static void
-chn_wrupdate(struct pcm_channel *c)
-{
-
-	CHN_LOCKASSERT(c);
-	KASSERT(c->direction == PCMDIR_PLAY, ("%s(): bad channel", __func__));
-
-	if ((c->flags & (CHN_F_MMAP | CHN_F_VIRTUAL)) || CHN_STOPPED(c))
-		return;
-	chn_dmaupdate(c);
-	chn_wrfeed(c);
-	/* tell the driver we've updated the primary buffer */
-	chn_trigger(c, PCMTRIG_EMLDMAWR);
-}
-#endif
-
 static void
 chn_wrintr(struct pcm_channel *c)
 {
@@ -535,22 +518,6 @@ chn_rdfeed(struct pcm_channel *c)
 		chn_wakeup(c);
 }
 
-#if 0
-static void
-chn_rdupdate(struct pcm_channel *c)
-{
-
-	CHN_LOCKASSERT(c);
-	KASSERT(c->direction == PCMDIR_REC, ("chn_rdupdate on bad channel"));
-
-	if ((c->flags & (CHN_F_MMAP | CHN_F_VIRTUAL)) || CHN_STOPPED(c))
-		return;
-	chn_trigger(c, PCMTRIG_EMLDMARD);
-	chn_dmaupdate(c);
-	chn_rdfeed(c);
-}
-#endif
-
 /* read interrupt routine. Must be called with interrupts blocked. */
 static void
 chn_rdintr(struct pcm_channel *c)
@@ -1980,12 +1947,6 @@ chn_resizebuf(struct pcm_channel *c, int latency,
 
 		hblksz -= hblksz % sndbuf_getalign(b);
 
-#if 0
-		hblksz = sndbuf_getmaxsize(b) >> 1;
-		hblksz -= hblksz % sndbuf_getalign(b);
-		hblkcnt = 2;
-#endif
-
 		CHN_UNLOCK(c);
 		if (chn_usefrags == 0 ||
 		    CHANNEL_SETFRAGMENTS(c->methods, c->devinfo,
@@ -2016,14 +1977,6 @@ chn_resizebuf(struct pcm_channel *c, int latency,
 	if (limit > CHN_2NDBUFMAXSIZE)
 		limit = CHN_2NDBUFMAXSIZE;
 
-#if 0
-	while (limit > 0 && (sblksz * sblkcnt) > limit) {
-		if (sblkcnt < 4)
-			break;
-		sblkcnt >>= 1;
-	}
-#endif
-
 	while ((sblksz * sblkcnt) < limit)
 		sblkcnt <<= 1;
 
@@ -2140,12 +2093,6 @@ chn_setspeed(struct pcm_channel *c, uint32_t speed)
 	uint32_t oldformat, oldspeed, format;
 	int ret;
 
-#if 0
-	/* XXX force 48k */
-	if (c->format & AFMT_PASSTHROUGH)
-		speed = AFMT_PASSTHROUGH_RATE;
-#endif
-
 	oldformat = c->format;
 	oldspeed = c->speed;
 	format = oldformat;
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index ccf240681a25..dcbdd581c82a 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -1257,7 +1257,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 	        		struct snd_dbuf *bs = wrch->bufsoft;
 
 				CHN_LOCK(wrch);
-				/* XXX abusive DMA update: chn_wrupdate(wrch); */
 				a->bytes = sndbuf_getfree(bs);
 	        		a->fragments = a->bytes / sndbuf_getblksz(bs);
 	        		a->fragstotal = sndbuf_getblkcnt(bs);
@@ -1275,7 +1274,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 	        		struct snd_dbuf *bs = rdch->bufsoft;
 
 				CHN_LOCK(rdch);
-				/* XXX abusive DMA update: chn_rdupdate(rdch); */
 	        		a->bytes = sndbuf_gettotal(bs);
 	        		a->blocks = sndbuf_getblocks(bs) - rdch->blocks;
 	        		a->ptr = sndbuf_getfreeptr(bs);
@@ -1293,7 +1291,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 	        		struct snd_dbuf *bs = wrch->bufsoft;
 
 				CHN_LOCK(wrch);
-				/* XXX abusive DMA update: chn_wrupdate(wrch); */
 	        		a->bytes = sndbuf_gettotal(bs);
 	        		a->blocks = sndbuf_getblocks(bs) - wrch->blocks;
 	        		a->ptr = sndbuf_getreadyptr(bs);
@@ -1385,7 +1382,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 	        	struct snd_dbuf *bs = wrch->bufsoft;
 
 			CHN_LOCK(wrch);
-			/* XXX abusive DMA update: chn_wrupdate(wrch); */
 			*arg_i = sndbuf_getready(bs);
 			CHN_UNLOCK(wrch);
 		} else
@@ -1582,14 +1578,8 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 
 			CHN_LOCK(chn);
 			bs = chn->bufsoft;
-#if 0
-			tmp = (sndbuf_getsize(b) + chn_getptr(chn) - sndbuf_gethwptr(b)) % sndbuf_getsize(b);
-			oc->samples = (sndbuf_gettotal(b) + tmp) / sndbuf_getalign(b);
-			oc->fifo_samples = (sndbuf_getready(b) - tmp) / sndbuf_getalign(b);
-#else
 			oc->samples = sndbuf_gettotal(bs) / sndbuf_getalign(bs);
 			oc->fifo_samples = sndbuf_getready(bs) / sndbuf_getalign(bs);
-#endif
 			CHN_UNLOCK(chn);
 		}
 		break;
@@ -1738,18 +1728,6 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode,
 	case SNDCTL_SETNAME:
 		ret = dsp_oss_setname(wrch, rdch, (oss_longname_t *)arg);
 		break;
-#if 0
-	/**
-	 * @note The S/PDIF interface ioctls, @c SNDCTL_DSP_READCTL and
-	 * @c SNDCTL_DSP_WRITECTL have been omitted at the suggestion of
-	 * 4Front Technologies.
-	 */
-	case SNDCTL_DSP_READCTL:
-	case SNDCTL_DSP_WRITECTL:
-		ret = EINVAL;
-		break;
-#endif	/* !0 (explicitly omitted ioctls) */
-
 #endif	/* !OSSV4_EXPERIMENT */
     	case SNDCTL_DSP_MAPINBUF:
     	case SNDCTL_DSP_MAPOUTBUF:
diff --git a/sys/dev/sound/pcm/feeder.h b/sys/dev/sound/pcm/feeder.h
index 1e240d934e94..60b8280e59ef 100644
--- a/sys/dev/sound/pcm/feeder.h
+++ b/sys/dev/sound/pcm/feeder.h
@@ -167,32 +167,6 @@ int feeder_matrix_oss_get_channel_order(struct pcmchan_matrix *,
 int feeder_matrix_oss_set_channel_order(struct pcmchan_matrix *,
     unsigned long long *);
 
-#if 0
-/* feeder_matrix */
-enum {
-	FEEDMATRIX_TYPE,
-	FEEDMATRIX_RESET,
-	FEEDMATRIX_CHANNELS_IN,
-	FEEDMATRIX_CHANNELS_OUT,
-	FEEDMATRIX_SET_MAP
-};
-
-enum {
-	FEEDMATRIX_TYPE_NONE,
-	FEEDMATRIX_TYPE_AUTO,
-	FEEDMATRIX_TYPE_2X1,
-	FEEDMATRIX_TYPE_1X2,
-	FEEDMATRIX_TYPE_2X2
-};
-
-#define FEEDMATRIX_TYPE_STEREO_TO_MONO	FEEDMATRIX_TYPE_2X1
-#define FEEDMATRIX_TYPE_MONO_TO_STEREO	FEEDMATRIX_TYPE_1X2
-#define FEEDMATRIX_TYPE_SWAP_STEREO	FEEDMATRIX_TYPE_2X2
-#define FEEDMATRIX_MAP(x, y)		((((x) & 0x3f) << 6) | ((y) & 0x3f))
-#define FEEDMATRIX_MAP_SRC(x)		((x) & 0x3f)
-#define FEEDMATRIX_MAP_DST(x)		(((x) >> 6) & 0x3f)
-#endif
-
 /*
  * By default, various feeders only deal with sign 16/32 bit native-endian
  * since it should provide the fastest processing path. Processing 8bit samples
diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c
index 77de21e7a31a..40e5d3018ab4 100644
--- a/sys/dev/sound/pcm/feeder_rate.c
+++ b/sys/dev/sound/pcm/feeder_rate.c
@@ -431,11 +431,6 @@ z_roundpow2(int32_t v)
 static void
 z_feed_zoh(struct z_info *info, uint8_t *dst)
 {
-#if 0
-	z_copy(info->z_delay +
-	    (info->z_start * info->channels * info->bps), dst,
-	    info->channels * info->bps);
-#else
 	uint32_t cnt;
 	uint8_t *src;
 
@@ -449,7 +444,6 @@ z_feed_zoh(struct z_info *info, uint8_t *dst)
 	do {
 		*dst++ = *src++;
 	} while (--cnt != 0);
-#endif
 }
 
 /*
@@ -1171,14 +1165,6 @@ z_setup_adaptive_sinc:
 			info->z_scale = Z_ONE;
 		}
 
-#if 0
-#define Z_SCALE_DIV	10000
-#define Z_SCALE_LIMIT(s, v)						\
-	((((uint64_t)(s) * (v)) + (Z_SCALE_DIV >> 1)) / Z_SCALE_DIV)
-
-		info->z_scale = Z_SCALE_LIMIT(info->z_scale, 9780);
-#endif
-
 		/* Smallest drift increment. */
 		info->z_dx = info->z_dy / info->z_gy;
 
@@ -1672,12 +1658,6 @@ z_resampler_feed_internal(struct pcm_feeder *f, struct pcm_channel *c,
 			 */
 			do {
 				info->z_resample(info, dst);
-#if 0
-				startdrift = z_gy2gx(info, 1);
-				alphadrift = z_drift(info, startdrift, 1);
-				info->z_start += startdrift;
-				info->z_alpha += alphadrift;
-#else
 				info->z_alpha += alphadrift;
 				if (info->z_alpha < info->z_gy)
 					info->z_start += startdrift;
@@ -1685,7 +1665,6 @@ z_resampler_feed_internal(struct pcm_feeder *f, struct pcm_channel *c,
 					info->z_start += startdrift - 1;
 					info->z_alpha -= info->z_gy;
 				}
-#endif
 				dst += align;
 #ifdef Z_DIAGNOSTIC
 				info->z_cycle++;