git: 5126e5eeeb5e - main - Retire snd_mss ISA sound card driver

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 21 Jun 2022 19:11:39 UTC
The branch main has been updated by emaste:

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

commit 5126e5eeeb5e07ceef3c809452a8c9f508b2d4d1
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-06-21 18:50:04 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-06-21 18:50:04 +0000

    Retire snd_mss ISA sound card driver
    
    The snd_mss driver supported Microsoft Sound System sound cards.
    
    ISA sound card drivers are deprecated as discussed on the current[1] and
    stable[2] mailing lists.  Deprecation notices were added in e39ec8933be4
    and MFCd to stable branches.
    
    Driver removals are being committed individually so that specific
    drivers can be restored if necessary (either in FreeBSD or by downstream
    projects).
    
    [1] https://lists.freebsd.org/archives/freebsd-current/2022-March/001680.html
    [2] https://lists.freebsd.org/archives/freebsd-stable/2022-March/000585.html
    
    Reviewed by:    mav
    Relnotes:       yes
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  Thttps://reviews.freebsd.org/D34671
---
 ObsoleteFiles.inc                     |    1 +
 share/man/man4/Makefile               |    1 -
 share/man/man4/pcm.4                  |    3 -
 share/man/man4/snd_mss.4              |  119 --
 sys/conf/files                        |    1 -
 sys/dev/sound/driver.c                |    1 -
 sys/dev/sound/isa/mss.c               | 2295 ---------------------------------
 sys/dev/sound/isa/mss.h               |  411 ------
 sys/modules/sound/driver/Makefile     |    2 +-
 sys/modules/sound/driver/mss/Makefile |    9 -
 10 files changed, 2 insertions(+), 2841 deletions(-)

diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index aaddf40c5840..1d5ee5863b56 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -57,6 +57,7 @@
 OLD_FILES+=usr/share/man/man4/snd_ad1816.4
 OLD_FILES+=usr/share/man/man4/snd_ess.4
 OLD_FILES+=usr/share/man/man4/snd_gusc.4
+OLD_FILES+=usr/share/man/man4/snd_mss.4
 
 # 20220612: new clang import which bumps version from 14.0.4 to 14.0.5
 OLD_FILES+=usr/lib/clang/14.0.4/include/cuda_wrappers/algorithm
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 866087f5c992..00304c094987 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -516,7 +516,6 @@ MAN=	aac.4 \
 	snd_hdspe.4 \
 	snd_ich.4 \
 	snd_maestro3.4 \
-	snd_mss.4 \
 	snd_neomagic.4 \
 	snd_sbc.4 \
 	snd_solo.4 \
diff --git a/share/man/man4/pcm.4 b/share/man/man4/pcm.4
index 7abebedea4b2..b1ad16eece37 100644
--- a/share/man/man4/pcm.4
+++ b/share/man/man4/pcm.4
@@ -109,8 +109,6 @@ The following bridge device drivers are available:
 .It
 .Xr snd_maestro3 4
 .It
-.Xr snd_mss 4
-.It
 .Xr snd_neomagic 4
 .It
 snd_sb16
@@ -709,7 +707,6 @@ A device node is not created properly.
 .Xr snd_hdspe 4 ,
 .Xr snd_ich 4 ,
 .Xr snd_maestro3 4 ,
-.Xr snd_mss 4 ,
 .Xr snd_neomagic 4 ,
 .Xr snd_sbc 4 ,
 .Xr snd_solo 4 ,
diff --git a/share/man/man4/snd_mss.4 b/share/man/man4/snd_mss.4
deleted file mode 100644
index 10e0985d04b9..000000000000
--- a/share/man/man4/snd_mss.4
+++ /dev/null
@@ -1,119 +0,0 @@
-.\" Copyright (c) 2005 Joel Dahl
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 19, 2022
-.Dt SND_MSS 4
-.Os
-.Sh NAME
-.Nm snd_mss
-.Nd "Microsoft Sound System ISA PnP/non-PnP bridge device driver"
-.Sh DEPRECATION NOTICE
-This driver is scheduled for removal prior to the release of
-.Fx 14.0 .
-.Sh SYNOPSIS
-To compile this driver into the kernel, place the following lines in your
-kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "device sound"
-.Cd "device snd_mss"
-.Ed
-.Pp
-Alternatively, to load the driver as a module at boot time, place the
-following line in
-.Xr loader.conf 5 :
-.Bd -literal -offset indent
-snd_mss_load="YES"
-.Ed
-.Pp
-Non-PnP cards require the following lines in
-.Xr device.hints 5 :
-.Bd -literal -offset indent
-hint.pcm.0.at="isa"
-hint.pcm.0.irq="10"
-hint.pcm.0.drq="1"
-hint.pcm.0.flags="0x0"
-.Ed
-.Sh DESCRIPTION
-The
-.Nm
-bridge driver allows the generic audio driver,
-.Xr sound 4 ,
-to attach to the supported audio devices.
-.Sh HARDWARE
-The
-.Nm
-driver supports the following audio devices:
-.Pp
-.Bl -bullet -compact
-.It
-AD1845
-.It
-AD1848
-.It
-Aztech 2320
-.It
-CMedia CMI8330
-.It
-Crystal Semiconductor CS4231
-.It
-Crystal Semiconductor CS4232
-.It
-Crystal Semiconductor CS4234
-.It
-Crystal Semiconductor CS4235
-.It
-Crystal Semiconductor CS4236
-.It
-Crystal Semiconductor CS4237
-.It
-ENSONIQ SoundscapeVIVO ENS4081
-.It
-NeoMagic 256AV (non-AC97)
-.It
-OPTi 924
-.It
-OPTi 925
-.It
-OPTi 930
-.It
-OPTi 931
-.It
-OPTi 933
-.It
-Yamaha OPL-SA2
-.It
-Yamaha OPL-SA3
-.El
-.Sh SEE ALSO
-.Xr sound 4
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 2.2.6 .
-.Sh AUTHORS
-This manual page was written by
-.An Joel Dahl Aq Mt joel@FreeBSD.org .
diff --git a/sys/conf/files b/sys/conf/files
index fdb653e9ff46..28c2d3b69fe4 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -3089,7 +3089,6 @@ dev/smc/if_smc_fdt.c		optional smc fdt
 dev/snp/snp.c			optional snp
 dev/sound/clone.c		optional sound
 dev/sound/unit.c		optional sound
-dev/sound/isa/mss.c		optional snd_mss isa
 dev/sound/isa/sb16.c		optional snd_sb16 isa
 dev/sound/isa/sb8.c		optional snd_sb8 isa
 dev/sound/isa/sbc.c		optional snd_sbc isa
diff --git a/sys/dev/sound/driver.c b/sys/dev/sound/driver.c
index 1a0e4d30fbdb..ae26de6e8f7a 100644
--- a/sys/dev/sound/driver.c
+++ b/sys/dev/sound/driver.c
@@ -72,7 +72,6 @@ MODULE_DEPEND(snd_driver, snd_fm801, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_hda, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_ich, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_maestro3, 1, 1, 1);
-MODULE_DEPEND(snd_driver, snd_mss, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_neomagic, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_sb16, 1, 1, 1);
 MODULE_DEPEND(snd_driver, snd_sb8, 1, 1, 1);
diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c
deleted file mode 100644
index a26dd9c62ab5..000000000000
--- a/sys/dev/sound/isa/mss.c
+++ /dev/null
@@ -1,2295 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2001 George Reid <greid@ukug.uk.freebsd.org>
- * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
- * Copyright (c) 1997,1998 Luigi Rizzo
- * Copyright (c) 1994,1995 Hannu Savolainen
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifdef HAVE_KERNEL_OPTION_HEADERS
-#include "opt_snd.h"
-#endif
-
-#include <dev/sound/pcm/sound.h>
-
-SND_DECLARE_FILE("$FreeBSD$");
-
-/* board-specific include files */
-#include <dev/sound/isa/mss.h>
-#include <dev/sound/isa/sb.h>
-#include <dev/sound/chip.h>
-
-#include <isa/isavar.h>
-
-#include "mixer_if.h"
-
-#define MSS_DEFAULT_BUFSZ (4096)
-#define MSS_INDEXED_REGS 0x20
-#define OPL_INDEXED_REGS 0x19
-
-struct mss_info;
-
-struct mss_chinfo {
-	struct mss_info *parent;
-	struct pcm_channel *channel;
-	struct snd_dbuf *buffer;
-	int dir;
-	u_int32_t fmt, blksz;
-};
-
-struct mss_info {
-    struct resource *io_base;	/* primary I/O address for the board */
-    int		     io_rid;
-    struct resource *conf_base; /* and the opti931 also has a config space */
-    int		     conf_rid;
-    struct resource *irq;
-    int		     irq_rid;
-    struct resource *drq1; /* play */
-    int		     drq1_rid;
-    struct resource *drq2; /* rec */
-    int		     drq2_rid;
-    void 	    *ih;
-    bus_dma_tag_t    parent_dmat;
-    struct mtx	    *lock;
-
-    char mss_indexed_regs[MSS_INDEXED_REGS];
-    char opl_indexed_regs[OPL_INDEXED_REGS];
-    int bd_id;      /* used to hold board-id info, eg. sb version,
-		     * mss codec type, etc. etc.
-		     */
-    int opti_offset;		/* offset from config_base for opti931 */
-    u_long  bd_flags;       /* board-specific flags */
-    int optibase;		/* base address for OPTi9xx config */
-    struct resource *indir;	/* Indirect register index address */
-    int indir_rid;
-    int password;		/* password for opti9xx cards */
-    int passwdreg;		/* password register */
-    unsigned int bufsize;
-    struct mss_chinfo pch, rch;
-};
-
-static int 		mss_probe(device_t dev);
-static int 		mss_attach(device_t dev);
-
-static driver_intr_t 	mss_intr;
-
-/* prototypes for local functions */
-static int 		mss_detect(device_t dev, struct mss_info *mss);
-static int		opti_detect(device_t dev, struct mss_info *mss);
-static char 		*ymf_test(device_t dev, struct mss_info *mss);
-static void		ad_unmute(struct mss_info *mss);
-
-/* mixer set funcs */
-static int 		mss_mixer_set(struct mss_info *mss, int dev, int left, int right);
-static int 		mss_set_recsrc(struct mss_info *mss, int mask);
-
-/* io funcs */
-static int 		ad_wait_init(struct mss_info *mss, int x);
-static int 		ad_read(struct mss_info *mss, int reg);
-static void 		ad_write(struct mss_info *mss, int reg, u_char data);
-static void 		ad_write_cnt(struct mss_info *mss, int reg, u_short data);
-static void    		ad_enter_MCE(struct mss_info *mss);
-static void             ad_leave_MCE(struct mss_info *mss);
-
-/* OPTi-specific functions */
-static void		opti_write(struct mss_info *mss, u_char reg,
-				   u_char data);
-static u_char		opti_read(struct mss_info *mss, u_char reg);
-static int		opti_init(device_t dev, struct mss_info *mss);
-
-/* io primitives */
-static void 		conf_wr(struct mss_info *mss, u_char reg, u_char data);
-static u_char 		conf_rd(struct mss_info *mss, u_char reg);
-
-static int 		pnpmss_probe(device_t dev);
-static int 		pnpmss_attach(device_t dev);
-
-static driver_intr_t 	opti931_intr;
-
-static u_int32_t mss_fmt[] = {
-	SND_FORMAT(AFMT_U8, 1, 0),
-	SND_FORMAT(AFMT_U8, 2, 0),
-	SND_FORMAT(AFMT_S16_LE, 1, 0),
-	SND_FORMAT(AFMT_S16_LE, 2, 0),
-	SND_FORMAT(AFMT_MU_LAW, 1, 0),
-	SND_FORMAT(AFMT_MU_LAW, 2, 0),
-	SND_FORMAT(AFMT_A_LAW, 1, 0),
-	SND_FORMAT(AFMT_A_LAW, 2, 0),
-	0
-};
-static struct pcmchan_caps mss_caps = {4000, 48000, mss_fmt, 0};
-
-static u_int32_t guspnp_fmt[] = {
-	SND_FORMAT(AFMT_U8, 1, 0),
-	SND_FORMAT(AFMT_U8, 2, 0),
-	SND_FORMAT(AFMT_S16_LE, 1, 0),
-	SND_FORMAT(AFMT_S16_LE, 2, 0),
-	SND_FORMAT(AFMT_A_LAW, 1, 0),
-	SND_FORMAT(AFMT_A_LAW, 2, 0),
-	0
-};
-static struct pcmchan_caps guspnp_caps = {4000, 48000, guspnp_fmt, 0};
-
-static u_int32_t opti931_fmt[] = {
-	SND_FORMAT(AFMT_U8, 1, 0),
-	SND_FORMAT(AFMT_U8, 2, 0),
-	SND_FORMAT(AFMT_S16_LE, 1, 0),
-	SND_FORMAT(AFMT_S16_LE, 2, 0),
-	0
-};
-static struct pcmchan_caps opti931_caps = {4000, 48000, opti931_fmt, 0};
-
-#define MD_AD1848	0x91
-#define MD_AD1845	0x92
-#define MD_CS42XX	0xA1
-#define MD_CS423X	0xA2
-#define MD_OPTI930	0xB0
-#define	MD_OPTI931	0xB1
-#define MD_OPTI925	0xB2
-#define MD_OPTI924	0xB3
-#define	MD_GUSPNP	0xB8
-#define MD_GUSMAX	0xB9
-#define	MD_YM0020	0xC1
-#define	MD_VIVO		0xD1
-
-#define	DV_F_TRUE_MSS	0x00010000	/* mss _with_ base regs */
-
-#define FULL_DUPLEX(x) ((x)->bd_flags & BD_F_DUPLEX)
-
-static void
-mss_lock(struct mss_info *mss)
-{
-	snd_mtxlock(mss->lock);
-}
-
-static void
-mss_unlock(struct mss_info *mss)
-{
-	snd_mtxunlock(mss->lock);
-}
-
-static int
-port_rd(struct resource *port, int off)
-{
-	if (port)
-		return bus_space_read_1(rman_get_bustag(port),
-					rman_get_bushandle(port),
-					off);
-	else
-		return -1;
-}
-
-static void
-port_wr(struct resource *port, int off, u_int8_t data)
-{
-	if (port)
-		bus_space_write_1(rman_get_bustag(port),
-				  rman_get_bushandle(port),
-				  off, data);
-}
-
-static int
-io_rd(struct mss_info *mss, int reg)
-{
-	if (mss->bd_flags & BD_F_MSS_OFFSET) reg -= 4;
-	return port_rd(mss->io_base, reg);
-}
-
-static void
-io_wr(struct mss_info *mss, int reg, u_int8_t data)
-{
-	if (mss->bd_flags & BD_F_MSS_OFFSET) reg -= 4;
-	port_wr(mss->io_base, reg, data);
-}
-
-static void
-conf_wr(struct mss_info *mss, u_char reg, u_char value)
-{
-    	port_wr(mss->conf_base, 0, reg);
-    	port_wr(mss->conf_base, 1, value);
-}
-
-static u_char
-conf_rd(struct mss_info *mss, u_char reg)
-{
-	port_wr(mss->conf_base, 0, reg);
-    	return port_rd(mss->conf_base, 1);
-}
-
-static void
-opti_wr(struct mss_info *mss, u_char reg, u_char value)
-{
-    	port_wr(mss->conf_base, mss->opti_offset + 0, reg);
-    	port_wr(mss->conf_base, mss->opti_offset + 1, value);
-}
-
-static u_char
-opti_rd(struct mss_info *mss, u_char reg)
-{
-	port_wr(mss->conf_base, mss->opti_offset + 0, reg);
-    	return port_rd(mss->conf_base, mss->opti_offset + 1);
-}
-
-static void
-gus_wr(struct mss_info *mss, u_char reg, u_char value)
-{
-    	port_wr(mss->conf_base, 3, reg);
-    	port_wr(mss->conf_base, 5, value);
-}
-
-static u_char
-gus_rd(struct mss_info *mss, u_char reg)
-{
-    	port_wr(mss->conf_base, 3, reg);
-    	return port_rd(mss->conf_base, 5);
-}
-
-static void
-mss_release_resources(struct mss_info *mss, device_t dev)
-{
-    	if (mss->irq) {
-    		if (mss->ih)
-			bus_teardown_intr(dev, mss->irq, mss->ih);
- 		bus_release_resource(dev, SYS_RES_IRQ, mss->irq_rid,
-				     mss->irq);
-		mss->irq = NULL;
-    	}
-    	if (mss->drq2) {
-		if (mss->drq2 != mss->drq1) {
-			isa_dma_release(rman_get_start(mss->drq2));
-			bus_release_resource(dev, SYS_RES_DRQ, mss->drq2_rid,
-				     	mss->drq2);
-		}
-		mss->drq2 = NULL;
-    	}
-     	if (mss->drq1) {
-		isa_dma_release(rman_get_start(mss->drq1));
-		bus_release_resource(dev, SYS_RES_DRQ, mss->drq1_rid,
-				     mss->drq1);
-		mss->drq1 = NULL;
-    	}
-   	if (mss->io_base) {
-		bus_release_resource(dev, SYS_RES_IOPORT, mss->io_rid,
-				     mss->io_base);
-		mss->io_base = NULL;
-    	}
-    	if (mss->conf_base) {
-		bus_release_resource(dev, SYS_RES_IOPORT, mss->conf_rid,
-				     mss->conf_base);
-		mss->conf_base = NULL;
-    	}
-	if (mss->indir) {
-		bus_release_resource(dev, SYS_RES_IOPORT, mss->indir_rid,
-				     mss->indir);
-		mss->indir = NULL;
-	}
-    	if (mss->parent_dmat) {
-		bus_dma_tag_destroy(mss->parent_dmat);
-		mss->parent_dmat = 0;
-    	}
-	if (mss->lock) snd_mtxfree(mss->lock);
-
-     	free(mss, M_DEVBUF);
-}
-
-static int
-mss_alloc_resources(struct mss_info *mss, device_t dev)
-{
-    	int pdma, rdma, ok = 1;
-	if (!mss->io_base)
-    		mss->io_base = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-						      &mss->io_rid, RF_ACTIVE);
-	if (!mss->irq)
-    		mss->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-						  &mss->irq_rid, RF_ACTIVE);
-	if (!mss->drq1)
-    		mss->drq1 = bus_alloc_resource_any(dev, SYS_RES_DRQ,
-						   &mss->drq1_rid,
-						   RF_ACTIVE);
-    	if (mss->conf_rid >= 0 && !mss->conf_base)
-        	mss->conf_base = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
-							&mss->conf_rid,
-							RF_ACTIVE);
-    	if (mss->drq2_rid >= 0 && !mss->drq2)
-        	mss->drq2 = bus_alloc_resource_any(dev, SYS_RES_DRQ,
-						   &mss->drq2_rid,
-						   RF_ACTIVE);
-
-	if (!mss->io_base || !mss->drq1 || !mss->irq) ok = 0;
-	if (mss->conf_rid >= 0 && !mss->conf_base) ok = 0;
-	if (mss->drq2_rid >= 0 && !mss->drq2) ok = 0;
-
-	if (ok) {
-		pdma = rman_get_start(mss->drq1);
-		isa_dma_acquire(pdma);
-		isa_dmainit(pdma, mss->bufsize);
-		mss->bd_flags &= ~BD_F_DUPLEX;
-		if (mss->drq2) {
-			rdma = rman_get_start(mss->drq2);
-			isa_dma_acquire(rdma);
-			isa_dmainit(rdma, mss->bufsize);
-			mss->bd_flags |= BD_F_DUPLEX;
-		} else mss->drq2 = mss->drq1;
-	}
-    	return ok;
-}
-
-/*
- * The various mixers use a variety of bitmasks etc. The Voxware
- * driver had a very nice technique to describe a mixer and interface
- * to it. A table defines, for each channel, which register, bits,
- * offset, polarity to use. This procedure creates the new value
- * using the table and the old value.
- */
-
-static void
-change_bits(mixer_tab *t, u_char *regval, int dev, int chn, int newval)
-{
-    	u_char mask;
-    	int shift;
-
-    	DEB(printf("ch_bits dev %d ch %d val %d old 0x%02x "
-		"r %d p %d bit %d off %d\n",
-		dev, chn, newval, *regval,
-		(*t)[dev][chn].regno, (*t)[dev][chn].polarity,
-		(*t)[dev][chn].nbits, (*t)[dev][chn].bitoffs ) );
-
-    	if ( (*t)[dev][chn].polarity == 1)	/* reverse */
-		newval = 100 - newval ;
-
-    	mask = (1 << (*t)[dev][chn].nbits) - 1;
-    	newval = (int) ((newval * mask) + 50) / 100; /* Scale it */
-    	shift = (*t)[dev][chn].bitoffs /*- (*t)[dev][LEFT_CHN].nbits + 1*/;
-
-    	*regval &= ~(mask << shift);        /* Filter out the previous value */
-    	*regval |= (newval & mask) << shift;        /* Set the new value */
-}
-
-/* -------------------------------------------------------------------- */
-/* only one source can be set... */
-static int
-mss_set_recsrc(struct mss_info *mss, int mask)
-{
-    	u_char   recdev;
-
-    	switch (mask) {
-    	case SOUND_MASK_LINE:
-    	case SOUND_MASK_LINE3:
-		recdev = 0;
-		break;
-
-    	case SOUND_MASK_CD:
-    	case SOUND_MASK_LINE1:
-		recdev = 0x40;
-		break;
-
-    	case SOUND_MASK_IMIX:
-		recdev = 0xc0;
-		break;
-
-    	case SOUND_MASK_MIC:
-    	default:
-		mask = SOUND_MASK_MIC;
-		recdev = 0x80;
-    	}
-    	ad_write(mss, 0, (ad_read(mss, 0) & 0x3f) | recdev);
-    	ad_write(mss, 1, (ad_read(mss, 1) & 0x3f) | recdev);
-    	return mask;
-}
-
-/* there are differences in the mixer depending on the actual sound card. */
-static int
-mss_mixer_set(struct mss_info *mss, int dev, int left, int right)
-{
-    	int        regoffs;
-    	mixer_tab *mix_d;
-    	u_char     old, val;
-
-	switch (mss->bd_id) {
-		case MD_OPTI931:
-			mix_d = &opti931_devices;
-			break;
-		case MD_OPTI930:
-			mix_d = &opti930_devices;
-			break;
-		default:
-			mix_d = &mix_devices;
-	}
-
-    	if ((*mix_d)[dev][LEFT_CHN].nbits == 0) {
-		DEB(printf("nbits = 0 for dev %d\n", dev));
-		return -1;
-    	}
-
-    	if ((*mix_d)[dev][RIGHT_CHN].nbits == 0) right = left; /* mono */
-
-    	/* Set the left channel */
-
-    	regoffs = (*mix_d)[dev][LEFT_CHN].regno;
-    	old = val = ad_read(mss, regoffs);
-    	/* if volume is 0, mute chan. Otherwise, unmute. */
-    	if (regoffs != 0) val = (left == 0)? old | 0x80 : old & 0x7f;
-    	change_bits(mix_d, &val, dev, LEFT_CHN, left);
-    	ad_write(mss, regoffs, val);
-
-    	DEB(printf("LEFT: dev %d reg %d old 0x%02x new 0x%02x\n",
-		dev, regoffs, old, val));
-
-    	if ((*mix_d)[dev][RIGHT_CHN].nbits != 0) { /* have stereo */
-		/* Set the right channel */
-		regoffs = (*mix_d)[dev][RIGHT_CHN].regno;
-		old = val = ad_read(mss, regoffs);
-		if (regoffs != 1) val = (right == 0)? old | 0x80 : old & 0x7f;
-		change_bits(mix_d, &val, dev, RIGHT_CHN, right);
-		ad_write(mss, regoffs, val);
-
-		DEB(printf("RIGHT: dev %d reg %d old 0x%02x new 0x%02x\n",
-	    	dev, regoffs, old, val));
-    	}
-    	return 0; /* success */
-}
-
-/* -------------------------------------------------------------------- */
-
-static int
-mssmix_init(struct snd_mixer *m)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-
-	mix_setdevs(m, MODE2_MIXER_DEVICES);
-	mix_setrecdevs(m, MSS_REC_DEVICES);
-	switch(mss->bd_id) {
-	case MD_OPTI930:
-		mix_setdevs(m, OPTI930_MIXER_DEVICES);
-		break;
-
-	case MD_OPTI931:
-		mix_setdevs(m, OPTI931_MIXER_DEVICES);
-		mss_lock(mss);
-		ad_write(mss, 20, 0x88);
-		ad_write(mss, 21, 0x88);
-		mss_unlock(mss);
-		break;
-
-	case MD_AD1848:
-		mix_setdevs(m, MODE1_MIXER_DEVICES);
-		break;
-
-	case MD_GUSPNP:
-	case MD_GUSMAX:
-		/* this is only necessary in mode 3 ... */
-		mss_lock(mss);
-		ad_write(mss, 22, 0x88);
-		ad_write(mss, 23, 0x88);
-		mss_unlock(mss);
-		break;
-	}
-	return 0;
-}
-
-static int
-mssmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-
-	mss_lock(mss);
-	mss_mixer_set(mss, dev, left, right);
-	mss_unlock(mss);
-
-	return left | (right << 8);
-}
-
-static u_int32_t
-mssmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-
-	mss_lock(mss);
-	src = mss_set_recsrc(mss, src);
-	mss_unlock(mss);
-	return src;
-}
-
-static kobj_method_t mssmix_mixer_methods[] = {
-    	KOBJMETHOD(mixer_init,		mssmix_init),
-    	KOBJMETHOD(mixer_set,		mssmix_set),
-    	KOBJMETHOD(mixer_setrecsrc,	mssmix_setrecsrc),
-	KOBJMETHOD_END
-};
-MIXER_DECLARE(mssmix_mixer);
-
-/* -------------------------------------------------------------------- */
-
-static int
-ymmix_init(struct snd_mixer *m)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-
-	mssmix_init(m);
-	mix_setdevs(m, mix_getdevs(m) | SOUND_MASK_VOLUME | SOUND_MASK_MIC
-				      | SOUND_MASK_BASS | SOUND_MASK_TREBLE);
-	/* Set master volume */
-	mss_lock(mss);
-	conf_wr(mss, OPL3SAx_VOLUMEL, 7);
-	conf_wr(mss, OPL3SAx_VOLUMER, 7);
-	mss_unlock(mss);
-
-	return 0;
-}
-
-static int
-ymmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-	int t, l, r;
-
-	mss_lock(mss);
-	switch (dev) {
-	case SOUND_MIXER_VOLUME:
-		if (left) t = 15 - (left * 15) / 100;
-		else t = 0x80; /* mute */
-		conf_wr(mss, OPL3SAx_VOLUMEL, t);
-		if (right) t = 15 - (right * 15) / 100;
-		else t = 0x80; /* mute */
-		conf_wr(mss, OPL3SAx_VOLUMER, t);
-		break;
-
-	case SOUND_MIXER_MIC:
-		t = left;
-		if (left) t = 31 - (left * 31) / 100;
-		else t = 0x80; /* mute */
-		conf_wr(mss, OPL3SAx_MIC, t);
-		break;
-
-	case SOUND_MIXER_BASS:
-		l = (left * 7) / 100;
-		r = (right * 7) / 100;
-		t = (r << 4) | l;
-		conf_wr(mss, OPL3SAx_BASS, t);
-		break;
-
-	case SOUND_MIXER_TREBLE:
-		l = (left * 7) / 100;
-		r = (right * 7) / 100;
-		t = (r << 4) | l;
-		conf_wr(mss, OPL3SAx_TREBLE, t);
-		break;
-
-	default:
-		mss_mixer_set(mss, dev, left, right);
-	}
-	mss_unlock(mss);
-
-	return left | (right << 8);
-}
-
-static u_int32_t
-ymmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
-{
-	struct mss_info *mss = mix_getdevinfo(m);
-	mss_lock(mss);
-	src = mss_set_recsrc(mss, src);
-	mss_unlock(mss);
-	return src;
-}
-
-static kobj_method_t ymmix_mixer_methods[] = {
-    	KOBJMETHOD(mixer_init,		ymmix_init),
-    	KOBJMETHOD(mixer_set,		ymmix_set),
-    	KOBJMETHOD(mixer_setrecsrc,	ymmix_setrecsrc),
-	KOBJMETHOD_END
-};
-MIXER_DECLARE(ymmix_mixer);
-
-/* -------------------------------------------------------------------- */
-/*
- * XXX This might be better off in the gusc driver.
- */
-static void
-gusmax_setup(struct mss_info *mss, device_t dev, struct resource *alt)
-{
-	static const unsigned char irq_bits[16] = {
-		0, 0, 0, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7
-	};
-	static const unsigned char dma_bits[8] = {
-		0, 1, 0, 2, 0, 3, 4, 5
-	};
-	device_t parent = device_get_parent(dev);
-	unsigned char irqctl, dmactl;
-	int s;
-
-	s = splhigh();
-
-	port_wr(alt, 0x0f, 0x05);
-	port_wr(alt, 0x00, 0x0c);
-	port_wr(alt, 0x0b, 0x00);
-
-	port_wr(alt, 0x0f, 0x00);
-
-	irqctl = irq_bits[isa_get_irq(parent)];
-	/* Share the IRQ with the MIDI driver.  */
-	irqctl |= 0x40;
-	dmactl = dma_bits[isa_get_drq(parent)];
-	if (device_get_flags(parent) & DV_F_DUAL_DMA)
-		dmactl |= dma_bits[device_get_flags(parent) & DV_F_DRQ_MASK]
-		    << 3;
-
-	/*
-	 * Set the DMA and IRQ control latches.
-	 */
-	port_wr(alt, 0x00, 0x0c);
-	port_wr(alt, 0x0b, dmactl | 0x80);
-	port_wr(alt, 0x00, 0x4c);
-	port_wr(alt, 0x0b, irqctl);
-
-	port_wr(alt, 0x00, 0x0c);
-	port_wr(alt, 0x0b, dmactl);
-	port_wr(alt, 0x00, 0x4c);
-	port_wr(alt, 0x0b, irqctl);
-
-	port_wr(mss->conf_base, 2, 0);
-	port_wr(alt, 0x00, 0x0c);
-	port_wr(mss->conf_base, 2, 0);
-
-	splx(s);
-}
-
-static int
-mss_init(struct mss_info *mss, device_t dev)
-{
-       	u_char r6, r9;
-	struct resource *alt;
-	int rid, tmp;
-
-	mss->bd_flags |= BD_F_MCE_BIT;
-	switch(mss->bd_id) {
-	case MD_OPTI931:
-		/*
-		 * The MED3931 v.1.0 allocates 3 bytes for the config
-		 * space, whereas v.2.0 allocates 4 bytes. What I know
-		 * for sure is that the upper two ports must be used,
-		 * and they should end on a boundary of 4 bytes. So I
-		 * need the following trick.
-		 */
-		mss->opti_offset =
-			(rman_get_start(mss->conf_base) & ~3) + 2
-			- rman_get_start(mss->conf_base);
-		BVDDB(printf("mss_init: opti_offset=%d\n", mss->opti_offset));
-    		opti_wr(mss, 4, 0xd6); /* fifo empty, OPL3, audio enable, SB3.2 */
-    		ad_write(mss, 10, 2); /* enable interrupts */
-    		opti_wr(mss, 6, 2);  /* MCIR6: mss enable, sb disable */
-    		opti_wr(mss, 5, 0x28);  /* MCIR5: codec in exp. mode,fifo */
-		break;
-
-	case MD_GUSPNP:
-	case MD_GUSMAX:
-		gus_wr(mss, 0x4c /* _URSTI */, 0);/* Pull reset */
-    		DELAY(1000 * 30);
-    		/* release reset  and enable DAC */
-    		gus_wr(mss, 0x4c /* _URSTI */, 3);
-    		DELAY(1000 * 30);
-    		/* end of reset */
-
-		rid = 0;
-    		alt = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
-					     RF_ACTIVE);
-		if (alt == NULL) {
-			printf("XXX couldn't init GUS PnP/MAX\n");
-			break;
-		}
-    		port_wr(alt, 0, 0xC); /* enable int and dma */
-		if (mss->bd_id == MD_GUSMAX)
-			gusmax_setup(mss, dev, alt);
-		bus_release_resource(dev, SYS_RES_IOPORT, rid, alt);
-
-    		/*
-     		 * unmute left & right line. Need to go in mode3, unmute,
-     		 * and back to mode 2
-     		 */
-    		tmp = ad_read(mss, 0x0c);
-    		ad_write(mss, 0x0c, 0x6c); /* special value to enter mode 3 */
-    		ad_write(mss, 0x19, 0); /* unmute left */
-    		ad_write(mss, 0x1b, 0); /* unmute right */
-    		ad_write(mss, 0x0c, tmp); /* restore old mode */
-
-    		/* send codec interrupts on irq1 and only use that one */
-    		gus_wr(mss, 0x5a, 0x4f);
-
-    		/* enable access to hidden regs */
-    		tmp = gus_rd(mss, 0x5b /* IVERI */);
-    		gus_wr(mss, 0x5b, tmp | 1);
-    		BVDDB(printf("GUS: silicon rev %c\n", 'A' + ((tmp & 0xf) >> 4)));
-		break;
*** 1995 LINES SKIPPED ***