[Midnightbsd-cvs] src [10065] trunk/sys/dev/sound: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 19:06:34 EDT 2018


Revision: 10065
          http://svnweb.midnightbsd.org/src/?rev=10065
Author:   laffer1
Date:     2018-05-27 19:06:34 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/dev/sound/chip.h
    trunk/sys/dev/sound/clone.c
    trunk/sys/dev/sound/clone.h
    trunk/sys/dev/sound/driver.c
    trunk/sys/dev/sound/isa/ad1816.c
    trunk/sys/dev/sound/isa/ad1816.h
    trunk/sys/dev/sound/isa/ess.c
    trunk/sys/dev/sound/isa/gusc.c
    trunk/sys/dev/sound/isa/mss.c
    trunk/sys/dev/sound/isa/mss.h
    trunk/sys/dev/sound/isa/sb.h
    trunk/sys/dev/sound/isa/sb16.c
    trunk/sys/dev/sound/isa/sb8.c
    trunk/sys/dev/sound/isa/sbc.c
    trunk/sys/dev/sound/isa/sndbuf_dma.c
    trunk/sys/dev/sound/macio/aoa.c
    trunk/sys/dev/sound/macio/aoa.h
    trunk/sys/dev/sound/macio/davbus.c
    trunk/sys/dev/sound/macio/davbusreg.h
    trunk/sys/dev/sound/macio/i2s.c
    trunk/sys/dev/sound/macio/snapper.c
    trunk/sys/dev/sound/macio/tumbler.c
    trunk/sys/dev/sound/midi/midi.c
    trunk/sys/dev/sound/midi/midi.h
    trunk/sys/dev/sound/midi/midiq.h
    trunk/sys/dev/sound/midi/mpu401.c
    trunk/sys/dev/sound/midi/mpu401.h
    trunk/sys/dev/sound/midi/mpu_if.m
    trunk/sys/dev/sound/midi/mpufoi_if.m
    trunk/sys/dev/sound/midi/sequencer.c
    trunk/sys/dev/sound/midi/sequencer.h
    trunk/sys/dev/sound/midi/synth_if.m
    trunk/sys/dev/sound/pci/allegro_code.h
    trunk/sys/dev/sound/pci/allegro_reg.h
    trunk/sys/dev/sound/pci/als4000.c
    trunk/sys/dev/sound/pci/als4000.h
    trunk/sys/dev/sound/pci/atiixp.c
    trunk/sys/dev/sound/pci/atiixp.h
    trunk/sys/dev/sound/pci/aureal.c
    trunk/sys/dev/sound/pci/aureal.h
    trunk/sys/dev/sound/pci/cmi.c
    trunk/sys/dev/sound/pci/cmireg.h
    trunk/sys/dev/sound/pci/cs4281.c
    trunk/sys/dev/sound/pci/cs4281.h
    trunk/sys/dev/sound/pci/cs461x_dsp.h
    trunk/sys/dev/sound/pci/csa.c
    trunk/sys/dev/sound/pci/csapcm.c
    trunk/sys/dev/sound/pci/csareg.h
    trunk/sys/dev/sound/pci/csavar.h
    trunk/sys/dev/sound/pci/ds1-fw.h
    trunk/sys/dev/sound/pci/ds1.c
    trunk/sys/dev/sound/pci/ds1.h
    trunk/sys/dev/sound/pci/emu10k1.c
    trunk/sys/dev/sound/pci/emu10kx-midi.c
    trunk/sys/dev/sound/pci/emu10kx-pcm.c
    trunk/sys/dev/sound/pci/emu10kx.c
    trunk/sys/dev/sound/pci/emu10kx.h
    trunk/sys/dev/sound/pci/emuxkireg.h
    trunk/sys/dev/sound/pci/envy24.c
    trunk/sys/dev/sound/pci/envy24.h
    trunk/sys/dev/sound/pci/envy24ht.c
    trunk/sys/dev/sound/pci/envy24ht.h
    trunk/sys/dev/sound/pci/es137x.c
    trunk/sys/dev/sound/pci/es137x.h
    trunk/sys/dev/sound/pci/fm801.c
    trunk/sys/dev/sound/pci/hda/hda_reg.h
    trunk/sys/dev/sound/pci/hda/hdaa.c
    trunk/sys/dev/sound/pci/hda/hdaa.h
    trunk/sys/dev/sound/pci/hda/hdaa_patches.c
    trunk/sys/dev/sound/pci/hda/hdac.c
    trunk/sys/dev/sound/pci/hda/hdac.h
    trunk/sys/dev/sound/pci/hda/hdac_if.m
    trunk/sys/dev/sound/pci/hda/hdac_private.h
    trunk/sys/dev/sound/pci/hda/hdac_reg.h
    trunk/sys/dev/sound/pci/hda/hdacc.c
    trunk/sys/dev/sound/pci/hdspe-pcm.c
    trunk/sys/dev/sound/pci/hdspe.c
    trunk/sys/dev/sound/pci/hdspe.h
    trunk/sys/dev/sound/pci/ich.c
    trunk/sys/dev/sound/pci/ich.h
    trunk/sys/dev/sound/pci/maestro.c
    trunk/sys/dev/sound/pci/maestro3.c
    trunk/sys/dev/sound/pci/maestro_reg.h
    trunk/sys/dev/sound/pci/neomagic-coeff.h
    trunk/sys/dev/sound/pci/neomagic.c
    trunk/sys/dev/sound/pci/neomagic.h
    trunk/sys/dev/sound/pci/solo.c
    trunk/sys/dev/sound/pci/spicds.c
    trunk/sys/dev/sound/pci/spicds.h
    trunk/sys/dev/sound/pci/t4dwave.c
    trunk/sys/dev/sound/pci/t4dwave.h
    trunk/sys/dev/sound/pci/via8233.c
    trunk/sys/dev/sound/pci/via8233.h
    trunk/sys/dev/sound/pci/via82c686.c
    trunk/sys/dev/sound/pci/via82c686.h
    trunk/sys/dev/sound/pci/vibes.c
    trunk/sys/dev/sound/pci/vibes.h
    trunk/sys/dev/sound/pcm/ac97.c
    trunk/sys/dev/sound/pcm/ac97.h
    trunk/sys/dev/sound/pcm/ac97_if.m
    trunk/sys/dev/sound/pcm/ac97_patch.c
    trunk/sys/dev/sound/pcm/ac97_patch.h
    trunk/sys/dev/sound/pcm/buffer.c
    trunk/sys/dev/sound/pcm/buffer.h
    trunk/sys/dev/sound/pcm/channel.c
    trunk/sys/dev/sound/pcm/channel.h
    trunk/sys/dev/sound/pcm/channel_if.m
    trunk/sys/dev/sound/pcm/dsp.c
    trunk/sys/dev/sound/pcm/dsp.h
    trunk/sys/dev/sound/pcm/feeder.c
    trunk/sys/dev/sound/pcm/feeder.h
    trunk/sys/dev/sound/pcm/feeder_chain.c
    trunk/sys/dev/sound/pcm/feeder_eq.c
    trunk/sys/dev/sound/pcm/feeder_format.c
    trunk/sys/dev/sound/pcm/feeder_if.m
    trunk/sys/dev/sound/pcm/feeder_matrix.c
    trunk/sys/dev/sound/pcm/feeder_mixer.c
    trunk/sys/dev/sound/pcm/feeder_rate.c
    trunk/sys/dev/sound/pcm/feeder_volume.c
    trunk/sys/dev/sound/pcm/g711.h
    trunk/sys/dev/sound/pcm/intpcm.h
    trunk/sys/dev/sound/pcm/matrix.h
    trunk/sys/dev/sound/pcm/matrix_map.h
    trunk/sys/dev/sound/pcm/mixer.c
    trunk/sys/dev/sound/pcm/mixer.h
    trunk/sys/dev/sound/pcm/mixer_if.m
    trunk/sys/dev/sound/pcm/pcm.h
    trunk/sys/dev/sound/pcm/sndstat.c
    trunk/sys/dev/sound/pcm/sndstat.h
    trunk/sys/dev/sound/pcm/sound.c
    trunk/sys/dev/sound/pcm/sound.h
    trunk/sys/dev/sound/pcm/vchan.c
    trunk/sys/dev/sound/pcm/vchan.h
    trunk/sys/dev/sound/sbus/apcdmareg.h
    trunk/sys/dev/sound/sbus/cs4231.c
    trunk/sys/dev/sound/sbus/cs4231.h
    trunk/sys/dev/sound/unit.c
    trunk/sys/dev/sound/unit.h
    trunk/sys/dev/sound/usb/uaudio.c
    trunk/sys/dev/sound/usb/uaudio.h
    trunk/sys/dev/sound/usb/uaudio_pcm.c
    trunk/sys/dev/sound/usb/uaudioreg.h

Property Changed:
----------------
    trunk/sys/dev/sound/midi/mpu_if.m
    trunk/sys/dev/sound/midi/mpufoi_if.m
    trunk/sys/dev/sound/midi/synth_if.m
    trunk/sys/dev/sound/pci/hda/hdac_if.m
    trunk/sys/dev/sound/pcm/ac97_if.m
    trunk/sys/dev/sound/pcm/channel_if.m
    trunk/sys/dev/sound/pcm/feeder_if.m
    trunk/sys/dev/sound/pcm/mixer_if.m

Modified: trunk/sys/dev/sound/chip.h
===================================================================
--- trunk/sys/dev/sound/chip.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/chip.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/chip.h 55320 2000-01-03 02:51:16Z tanimura $
  */
 
 /*

Modified: trunk/sys/dev/sound/clone.c
===================================================================
--- trunk/sys/dev/sound/clone.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/clone.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/clone.c 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/sound/clone.h
===================================================================
--- trunk/sys/dev/sound/clone.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/clone.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/clone.h 170719 2007-06-14 11:10:21Z ariff $
  */
 
 #ifndef _SND_CLONE_H_

Modified: trunk/sys/dev/sound/driver.c
===================================================================
--- trunk/sys/dev/sound/driver.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/driver.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/driver.c 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS

Modified: trunk/sys/dev/sound/isa/ad1816.c
===================================================================
--- trunk/sys/dev/sound/isa/ad1816.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/ad1816.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * Copyright (c) 1997,1998 Luigi Rizzo
@@ -37,7 +38,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/ad1816.c 193640 2009-06-07 19:12:08Z ariff $");
 
 struct ad1816_info;
 

Modified: trunk/sys/dev/sound/isa/ad1816.h
===================================================================
--- trunk/sys/dev/sound/isa/ad1816.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/ad1816.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997 Luigi Rizzo
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/isa/ad1816.h 172568 2007-10-12 06:03:46Z kevlo $
  */
 
 /*

Modified: trunk/sys/dev/sound/isa/ess.c
===================================================================
--- trunk/sys/dev/sound/isa/ess.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/ess.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * Copyright (c) 1997,1998 Luigi Rizzo
@@ -42,7 +43,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/ess.c 193640 2009-06-07 19:12:08Z ariff $");
 
 #define ESS_BUFFSIZE (4096)
 #define ABS(x) (((x) < 0)? -(x) : (x))

Modified: trunk/sys/dev/sound/isa/gusc.c
===================================================================
--- trunk/sys/dev/sound/isa/gusc.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/gusc.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * Copyright (c) 1999 Ville-Pertti Keinonen
@@ -46,7 +47,7 @@
 #include <isa/isavar.h>
 #include <isa/isa_common.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/gusc.c 227843 2011-11-22 21:28:20Z marius $");
 
 #define LOGICALID_NOPNP 0
 #define LOGICALID_PCM   0x0000561e

Modified: trunk/sys/dev/sound/isa/mss.c
===================================================================
--- trunk/sys/dev/sound/isa/mss.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/mss.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 George Reid <greid at ukug.uk.freebsd.org>
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
@@ -33,7 +34,7 @@
 
 #include <dev/sound/pcm/sound.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/mss.c 193640 2009-06-07 19:12:08Z ariff $");
 
 /* board-specific include files */
 #include <dev/sound/isa/mss.h>

Modified: trunk/sys/dev/sound/isa/mss.h
===================================================================
--- trunk/sys/dev/sound/isa/mss.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/mss.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Doug Rabson
  * Copyright (c) 1997 Luigi Rizzo
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/isa/mss.h 166427 2007-02-02 13:44:09Z joel $
  */
 
 /*

Modified: trunk/sys/dev/sound/isa/sb.h
===================================================================
--- trunk/sys/dev/sound/isa/sb.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/sb.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997,1998 Luigi Rizzo
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/isa/sb.h 166425 2007-02-02 13:33:35Z joel $
  */
 
 #ifndef SB_H

Modified: trunk/sys/dev/sound/isa/sb16.c
===================================================================
--- trunk/sys/dev/sound/isa/sb16.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/sb16.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * Copyright (c) 1997,1998 Luigi Rizzo
@@ -42,7 +43,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/sb16.c 193640 2009-06-07 19:12:08Z ariff $");
 
 #define SB16_BUFFSIZE	4096
 #define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)

Modified: trunk/sys/dev/sound/isa/sb8.c
===================================================================
--- trunk/sys/dev/sound/isa/sb8.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/sb8.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * Copyright (c) 1997,1998 Luigi Rizzo
@@ -42,7 +43,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/sb8.c 193640 2009-06-07 19:12:08Z ariff $");
 
 #define SB_DEFAULT_BUFSZ	4096
 

Modified: trunk/sys/dev/sound/isa/sbc.c
===================================================================
--- trunk/sys/dev/sound/isa/sbc.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/sbc.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -34,7 +35,7 @@
 
 #include <isa/isavar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/sbc.c 227843 2011-11-22 21:28:20Z marius $");
 
 #define IO_MAX	3
 #define IRQ_MAX	1

Modified: trunk/sys/dev/sound/isa/sndbuf_dma.c
===================================================================
--- trunk/sys/dev/sound/isa/sndbuf_dma.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/isa/sndbuf_dma.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -32,7 +33,7 @@
 
 #include <isa/isavar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/isa/sndbuf_dma.c 193640 2009-06-07 19:12:08Z ariff $");
 
 int
 sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq)

Modified: trunk/sys/dev/sound/macio/aoa.c
===================================================================
--- trunk/sys/dev/sound/macio/aoa.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/aoa.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/aoa.c 193640 2009-06-07 19:12:08Z ariff $
  */
 
 /*

Modified: trunk/sys/dev/sound/macio/aoa.h
===================================================================
--- trunk/sys/dev/sound/macio/aoa.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/aoa.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/aoa.h 188259 2009-02-07 01:15:13Z nwhitehorn $
  */
 
 #ifndef SOUND_AOA_H

Modified: trunk/sys/dev/sound/macio/davbus.c
===================================================================
--- trunk/sys/dev/sound/macio/davbus.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/davbus.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/davbus.c 193640 2009-06-07 19:12:08Z ariff $
  */
 
 /*

Modified: trunk/sys/dev/sound/macio/davbusreg.h
===================================================================
--- trunk/sys/dev/sound/macio/davbusreg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/davbusreg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/davbusreg.h 187692 2009-01-25 18:20:15Z nwhitehorn $
  */
 
 /*

Modified: trunk/sys/dev/sound/macio/i2s.c
===================================================================
--- trunk/sys/dev/sound/macio/i2s.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/i2s.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/i2s.c 223554 2011-06-26 00:35:11Z nwhitehorn $
  */
 /*-
  * Copyright (c) 2002, 2003 Tsubai Masanari.  All rights reserved.

Modified: trunk/sys/dev/sound/macio/snapper.c
===================================================================
--- trunk/sys/dev/sound/macio/snapper.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/snapper.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/snapper.c 239245 2012-08-14 05:16:35Z andreast $
  */
 /*-
  * Copyright (c) 2002, 2003 Tsubai Masanari.  All rights reserved.
@@ -174,7 +175,7 @@
 #define  SNAPPER_MCR1_W_16	0x00	/*  16 bit */
 #define  SNAPPER_MCR1_W_18	0x01	/*  18 bit */
 #define  SNAPPER_MCR1_W_20	0x02	/*  20 bit */
-#define  SNAPPER_MCR1_W_24	0x03	/*  20 bit */
+#define  SNAPPER_MCR1_W_24	0x03	/*  24 bit */
 #define SNAPPER_MCR2_DL	0x80	/* Download */
 #define SNAPPER_MCR2_AP	0x02	/* All pass mode */
 #define SNAPPER_ACR_ADM	0x80	/* ADC output mode */

Modified: trunk/sys/dev/sound/macio/tumbler.c
===================================================================
--- trunk/sys/dev/sound/macio/tumbler.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/macio/tumbler.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright 2008 by Marco Trillo. All rights reserved.
  *
@@ -22,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/macio/tumbler.c 193694 2009-06-08 08:10:52Z ariff $
  */
 /*-
  * Copyright (c) 2002, 2003 Tsubai Masanari.  All rights reserved.

Modified: trunk/sys/dev/sound/midi/midi.c
===================================================================
--- trunk/sys/dev/sound/midi/midi.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/midi.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +36,7 @@
   */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/sound/midi/midi.c 299632 2016-05-13 09:01:20Z ngie $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -86,7 +87,7 @@
 };
 
 /*
- * The MPU interface current has init() uninit() inqsize(( outqsize()
+ * The MPU interface current has init() uninit() inqsize() outqsize()
  * callback() : fiddle with the tx|rx status.
  */
 
@@ -160,11 +161,16 @@
 /*
  * Module Exports & Interface
  *
- * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan) int
- * midi_uninit(struct snd_midi *) 0 == no error EBUSY or other error int
- * Midi_in(struct midi_chan *, char *buf, int count) int Midi_out(struct
- * midi_chan *, char *buf, int count)
+ * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan,
+ *     void *cookie)
+ * int midi_uninit(struct snd_midi *)
  *
+ * 0 == no error
+ * EBUSY or other error
+ *
+ * int midi_in(struct snd_midi *, char *buf, int count)
+ * int midi_out(struct snd_midi *, char *buf, int count)
+ *
  * midi_{in,out} return actual size transfered
  *
  */
@@ -314,6 +320,8 @@
 		goto err0;
 
 	m->synth = malloc(sizeof(*m->synth), M_MIDI, M_NOWAIT | M_ZERO);
+	if (m->synth == NULL)
+		goto err1;
 	kobj_init((kobj_t)m->synth, &midisynth_class);
 	m->synth->m = m;
 	kobj_init((kobj_t)m, cls);
@@ -322,7 +330,7 @@
 
 	MIDI_DEBUG(1, printf("midiinit queues %d/%d.\n", inqsize, outqsize));
 	if (!inqsize && !outqsize)
-		goto err1;
+		goto err2;
 
 	mtx_init(&m->lock, "raw midi", NULL, 0);
 	mtx_init(&m->qlock, "q raw midi", NULL, 0);
@@ -347,7 +355,7 @@
 
 	if ((inqsize && !MIDIQ_BUF(m->inq)) ||
 	    (outqsize && !MIDIQ_BUF(m->outq)))
-		goto err2;
+		goto err3;
 
 
 	m->busy = 0;
@@ -357,7 +365,7 @@
 	m->cookie = cookie;
 
 	if (MPU_INIT(m, cookie))
-		goto err2;
+		goto err3;
 
 	mtx_unlock(&m->lock);
 	mtx_unlock(&m->qlock);
@@ -373,7 +381,7 @@
 
 	return m;
 
-err2:	mtx_destroy(&m->qlock);
+err3:	mtx_destroy(&m->qlock);
 	mtx_destroy(&m->lock);
 
 	if (MIDIQ_BUF(m->inq))
@@ -380,6 +388,7 @@
 		free(MIDIQ_BUF(m->inq), M_MIDI);
 	if (MIDIQ_BUF(m->outq))
 		free(MIDIQ_BUF(m->outq), M_MIDI);
+err2:	free(m->synth, M_MIDI);
 err1:	free(m, M_MIDI);
 err0:	mtx_unlock(&midistat_lock);
 	MIDI_DEBUG(1, printf("midi_init ended in error\n"));
@@ -388,7 +397,7 @@
 
 /*
  * midi_uninit does not call MIDI_UNINIT, as since this is the implementors
- * entry point. midi_unint if fact, does not send any methods. A call to
+ * entry point. midi_uninit if fact, does not send any methods. A call to
  * midi_uninit is a defacto promise that you won't manipulate ch anymore
  *
  */
@@ -398,7 +407,7 @@
 {
 	int err;
 
-	err = ENXIO;
+	err = EBUSY;
 	mtx_lock(&midistat_lock);
 	mtx_lock(&m->lock);
 	if (m->busy) {
@@ -1383,6 +1392,7 @@
 	free(MIDIQ_BUF(m->outq), M_MIDI);
 	mtx_destroy(&m->qlock);
 	mtx_destroy(&m->lock);
+	free(m->synth, M_MIDI);
 	free(m, M_MIDI);
 	return 0;
 }
@@ -1392,7 +1402,7 @@
  */
 
 static int
-midi_load()
+midi_load(void)
 {
 	mtx_init(&midistat_lock, "midistat lock", NULL, 0);
 	TAILQ_INIT(&midi_devs);		/* Initialize the queue. */
@@ -1405,9 +1415,9 @@
 }
 
 static int
-midi_unload()
+midi_unload(void)
 {
-	struct snd_midi *m;
+	struct snd_midi *m, *tmp;
 	int retval;
 
 	MIDI_DEBUG(1, printf("midi_unload()\n"));
@@ -1416,7 +1426,7 @@
 	if (midistat_isopen)
 		goto exit0;
 
-	TAILQ_FOREACH(m, &midi_devs, link) {
+	TAILQ_FOREACH_SAFE(m, &midi_devs, link, tmp) {
 		mtx_lock(&m->lock);
 		if (m->busy)
 			retval = EBUSY;

Modified: trunk/sys/dev/sound/midi/midi.h
===================================================================
--- trunk/sys/dev/sound/midi/midi.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/midi.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/midi/midi.h 166971 2007-02-25 13:51:52Z netchild $
  */
 
 #ifndef MIDI_H

Modified: trunk/sys/dev/sound/midi/midiq.h
===================================================================
--- trunk/sys/dev/sound/midi/midiq.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/midiq.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/midi/midiq.h 166971 2007-02-25 13:51:52Z netchild $
  */
 
 #ifndef MIDIQ_H

Modified: trunk/sys/dev/sound/midi/mpu401.c
===================================================================
--- trunk/sys/dev/sound/midi/mpu401.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/mpu401.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/sound/midi/mpu401.c 314667 2017-03-04 13:03:31Z avg $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -185,7 +186,7 @@
 
 	kobj_init((kobj_t)m, cls);
 
-	callout_init(&m->timer, CALLOUT_MPSAFE);
+	callout_init(&m->timer, 1);
 
 	m->si = softintr;
 	m->cookie = cookie;

Modified: trunk/sys/dev/sound/midi/mpu401.h
===================================================================
--- trunk/sys/dev/sound/midi/mpu401.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/mpu401.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/midi/mpu401.h 166971 2007-02-25 13:51:52Z netchild $
  */
 
 #ifndef MPU401_H

Modified: trunk/sys/dev/sound/midi/mpu_if.m
===================================================================
--- trunk/sys/dev/sound/midi/mpu_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/mpu_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2003 Mathew Kanner
 # All rights reserved.
@@ -23,7 +24,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/midi/mpu_if.m 166971 2007-02-25 13:51:52Z netchild $
 #
 
 #include <dev/sound/midi/midi.h>


Property changes on: trunk/sys/dev/sound/midi/mpu_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/midi/mpufoi_if.m
===================================================================
--- trunk/sys/dev/sound/midi/mpufoi_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/mpufoi_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2003 Mathew Kanner
 # All rights reserved.
@@ -23,7 +24,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/midi/mpufoi_if.m 166971 2007-02-25 13:51:52Z netchild $
 #
 
 #include <sys/bus.h>


Property changes on: trunk/sys/dev/sound/midi/mpufoi_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/midi/sequencer.c
===================================================================
--- trunk/sys/dev/sound/midi/sequencer.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/sequencer.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * Copyright (c) 1993 Hannu Savolainen
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/sound/midi/sequencer.c 194990 2009-06-25 18:46:30Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>

Modified: trunk/sys/dev/sound/midi/sequencer.h
===================================================================
--- trunk/sys/dev/sound/midi/sequencer.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/sequencer.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Mathew Kanner
  * Copyright (c) 1999 Seigo Tanimura
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/midi/sequencer.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 /*

Modified: trunk/sys/dev/sound/midi/synth_if.m
===================================================================
--- trunk/sys/dev/sound/midi/synth_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/midi/synth_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # Copyright (c) 2003 Mathew Kanner
 # All rights reserved.
@@ -23,7 +24,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/midi/synth_if.m 166971 2007-02-25 13:51:52Z netchild $
 #
 
 INTERFACE synth;


Property changes on: trunk/sys/dev/sound/midi/synth_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pci/allegro_code.h
===================================================================
--- trunk/sys/dev/sound/pci/allegro_code.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/allegro_code.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/pci/allegro_code.h 230401 2012-01-20 22:37:10Z pfg $ */
 /*-
  * Copyright (C) 1996-2008, 4Front Technologies
  * Copyright (C) 1997-1999 ESS Technology, Inc

Modified: trunk/sys/dev/sound/pci/allegro_reg.h
===================================================================
--- trunk/sys/dev/sound/pci/allegro_reg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/allegro_reg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/pci/allegro_reg.h 230401 2012-01-20 22:37:10Z pfg $ */
 /*-
  * Copyright (c) 1996-2008, 4Front Technologies
  * Copyright (C) 1992-2000  Don Kim (don.kim at esstech.com)

Modified: trunk/sys/dev/sound/pci/als4000.c
===================================================================
--- trunk/sys/dev/sound/pci/als4000.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/als4000.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Orion Hodson <oho at acm.org>
  * All rights reserved.
@@ -46,7 +47,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/als4000.c 312398 2017-01-18 23:23:46Z marius $");
 
 /* Debugging macro's */
 #undef DEB
@@ -760,8 +761,8 @@
 als_resource_grab(device_t dev, struct sc_info *sc)
 {
 	sc->regid = PCIR_BAR(0);
-	sc->reg = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->regid, 0, ~0,
-				     ALS_CONFIG_SPACE_BYTES, RF_ACTIVE);
+	sc->reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->regid,
+					 RF_ACTIVE);
 	if (sc->reg == 0) {
 		device_printf(dev, "unable to allocate register space\n");
 		goto bad;
@@ -806,7 +807,6 @@
 als_pci_attach(device_t dev)
 {
 	struct sc_info *sc;
-	u_int32_t data;
 	char status[SND_STATUSLEN];
 
 	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -813,9 +813,7 @@
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_als4000 softc");
 	sc->dev = dev;
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
+	pci_enable_busmaster(dev);
 	/*
 	 * By default the power to the various components on the
          * ALS4000 is entirely controlled by the pci powerstate.  We

Modified: trunk/sys/dev/sound/pci/als4000.h
===================================================================
--- trunk/sys/dev/sound/pci/als4000.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/als4000.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/als4000.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #define ALS_PCI_ID0 		0x40004005

Modified: trunk/sys/dev/sound/pci/atiixp.c
===================================================================
--- trunk/sys/dev/sound/pci/atiixp.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/atiixp.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -67,7 +68,7 @@
 
 #include <dev/sound/pci/atiixp.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/atiixp.c 314667 2017-03-04 13:03:31Z avg $");
 
 #define ATI_IXP_DMA_RETRY_MAX	100
 
@@ -1193,7 +1194,7 @@
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_atiixp softc");
 	sc->dev = dev;
 
-	callout_init(&sc->poll_timer, CALLOUT_MPSAFE);
+	callout_init(&sc->poll_timer, 1);
 	sc->poll_ticks = 1;
 
 	if (resource_int_value(device_get_name(sc->dev),

Modified: trunk/sys/dev/sound/pci/atiixp.h
===================================================================
--- trunk/sys/dev/sound/pci/atiixp.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/atiixp.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/atiixp.h 180110 2008-06-30 05:14:44Z delphij $
  */
 
 #ifndef _ATIIXP_H_

Modified: trunk/sys/dev/sound/pci/aureal.c
===================================================================
--- trunk/sys/dev/sound/pci/aureal.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/aureal.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -35,7 +36,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/aureal.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* PCI IDs of supported chips */
 #define AU8820_PCI_ID 0x000112eb
@@ -550,7 +551,6 @@
 static int
 au_pci_attach(device_t dev)
 {
-	u_int32_t	data;
 	struct au_info *au;
 	int		type[10];
 	int		regid[10];
@@ -565,10 +565,7 @@
 	au = malloc(sizeof(*au), M_DEVBUF, M_WAITOK | M_ZERO);
 	au->unit = device_get_unit(dev);
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	j=0;
 	/* XXX dfr: is this strictly necessary? */

Modified: trunk/sys/dev/sound/pci/aureal.h
===================================================================
--- trunk/sys/dev/sound/pci/aureal.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/aureal.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/aureal.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #ifndef _AU8820_REG_H

Modified: trunk/sys/dev/sound/pci/cmi.c
===================================================================
--- trunk/sys/dev/sound/pci/cmi.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/cmi.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -59,7 +60,7 @@
 #include "mixer_if.h"
 #include "mpufoi_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/cmi.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* Supported chip ID's */
 #define CMI8338A_PCI_ID   0x010013f6
@@ -935,15 +936,11 @@
 cmi_attach(device_t dev)
 {
 	struct sc_info		*sc;
-	u_int32_t		data;
 	char			status[SND_STATUSLEN];
 
 	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_cmi softc");
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	sc->dev = dev;
 	sc->regid = PCIR_BAR(0);

Modified: trunk/sys/dev/sound/pci/cmireg.h
===================================================================
--- trunk/sys/dev/sound/pci/cmireg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/cmireg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -26,7 +27,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/cmireg.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 /* C-Media CMI8x38 Audio Chip Support */

Modified: trunk/sys/dev/sound/pci/cs4281.c
===================================================================
--- trunk/sys/dev/sound/pci/cs4281.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/cs4281.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -43,7 +44,7 @@
 
 #include <dev/sound/pci/cs4281.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/cs4281.c 312398 2017-01-18 23:23:46Z marius $");
 
 #define CS4281_DEFAULT_BUFSZ 16384
 
@@ -760,7 +761,6 @@
 {
     struct sc_info *sc;
     struct ac97_info *codec = NULL;
-    u_int32_t data;
     char status[SND_STATUSLEN];
 
     sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -767,9 +767,7 @@
     sc->dev = dev;
     sc->type = pci_get_devid(dev);
 
-    data = pci_read_config(dev, PCIR_COMMAND, 2);
-    data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
-    pci_write_config(dev, PCIR_COMMAND, data, 2);
+    pci_enable_busmaster(dev);
 
 #if __FreeBSD_version > 500000
     if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
@@ -793,12 +791,11 @@
 
     sc->regid   = PCIR_BAR(0);
     sc->regtype = SYS_RES_MEMORY;
-    sc->reg = bus_alloc_resource(dev, sc->regtype, &sc->regid,
-				 0, ~0, CS4281PCI_BA0_SIZE, RF_ACTIVE);
+    sc->reg = bus_alloc_resource_any(dev, sc->regtype, &sc->regid, RF_ACTIVE);
     if (!sc->reg) {
 	sc->regtype = SYS_RES_IOPORT;
-	sc->reg = bus_alloc_resource(dev, sc->regtype, &sc->regid,
-				     0, ~0, CS4281PCI_BA0_SIZE, RF_ACTIVE);
+	sc->reg = bus_alloc_resource_any(dev, sc->regtype, &sc->regid,
+					 RF_ACTIVE);
 	if (!sc->reg) {
 	    device_printf(dev, "unable to allocate register space\n");
 	    goto bad;
@@ -808,8 +805,8 @@
     sc->sh = rman_get_bushandle(sc->reg);
 
     sc->memid = PCIR_BAR(1);
-    sc->mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->memid, 0,
-				 ~0, CS4281PCI_BA1_SIZE, RF_ACTIVE);
+    sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->memid,
+				     RF_ACTIVE);
     if (sc->mem == NULL) {
 	device_printf(dev, "unable to allocate fifo space\n");
 	goto bad;

Modified: trunk/sys/dev/sound/pci/cs4281.h
===================================================================
--- trunk/sys/dev/sound/pci/cs4281.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/cs4281.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/cs4281.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #ifndef _CS4281_H_

Modified: trunk/sys/dev/sound/pci/cs461x_dsp.h
===================================================================
--- trunk/sys/dev/sound/pci/cs461x_dsp.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/cs461x_dsp.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/pci/cs461x_dsp.h 230897 2012-02-01 21:38:01Z pfg $ */
 /*-
  * Copyright (C) 1996-2008, 4Front Technologies
  * All rights reserved.

Modified: trunk/sys/dev/sound/pci/csa.c
===================================================================
--- trunk/sys/dev/sound/pci/csa.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/csa.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -52,7 +53,7 @@
 
 #include <dev/sound/pci/cs461x_dsp.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/csa.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* This is the pci device id. */
 #define CS4610_PCI_ID 0x60011013
@@ -242,7 +243,6 @@
 static int
 csa_attach(device_t dev)
 {
-	u_int32_t stcmd;
 	sc_p scp;
 	csa_res *resp;
 	struct sndcard_func *func;
@@ -254,12 +254,7 @@
 	bzero(scp, sizeof(*scp));
 	scp->dev = dev;
 
-	/* Wake up the device. */
-	stcmd = pci_read_config(dev, PCIR_COMMAND, 2);
-	if ((stcmd & PCIM_CMD_MEMEN) == 0 || (stcmd & PCIM_CMD_BUSMASTEREN) == 0) {
-		stcmd |= (PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
-		pci_write_config(dev, PCIR_COMMAND, stcmd, 2);
-	}
+	pci_enable_busmaster(dev);
 
 	/* Allocate the resources. */
 	resp = &scp->res;

Modified: trunk/sys/dev/sound/pci/csapcm.c
===================================================================
--- trunk/sys/dev/sound/pci/csapcm.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/csapcm.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -41,7 +42,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/csapcm.c 193640 2009-06-07 19:12:08Z ariff $");
 
 /* Buffer size on dma transfer. Fixed for CS416x. */
 #define CS461x_BUFFSIZE   (4 * 1024)

Modified: trunk/sys/dev/sound/pci/csareg.h
===================================================================
--- trunk/sys/dev/sound/pci/csareg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/csareg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -27,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/csareg.h 230897 2012-02-01 21:38:01Z pfg $
  */
 
 #ifndef _CSA_REG_H

Modified: trunk/sys/dev/sound/pci/csavar.h
===================================================================
--- trunk/sys/dev/sound/pci/csavar.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/csavar.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/csavar.h 147626 2005-06-27 07:43:57Z glebius $
  */
 
 #ifndef _CSA_VAR_H

Modified: trunk/sys/dev/sound/pci/ds1-fw.h
===================================================================
--- trunk/sys/dev/sound/pci/ds1-fw.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/ds1-fw.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * =============================================================================
  *  Copyright (c) 1997-1999	Yamaha Corporation.	All Rights Reserved.
@@ -30,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/ds1-fw.h 230133 2012-01-15 13:23:33Z uqs $
  */
 #ifndef _HWMCODE_
 #define _HWMCODE_
@@ -822,9 +823,9 @@
 	1999/06/21
 	Buf441 slot is Enabled.
    --------------------------------------------
-   04/09\x81 at creat
+   04/09  @creat
    04/12  stop nise fix
-   06/21\x81 at WorkingOff timming
+   06/21  @WorkingOff timming
 */
 
 static u_int32_t	CntrlInst1E[] = {

Modified: trunk/sys/dev/sound/pci/ds1.c
===================================================================
--- trunk/sys/dev/sound/pci/ds1.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/ds1.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -37,7 +38,7 @@
 #include <dev/sound/pci/ds1.h>
 #include <dev/sound/pci/ds1-fw.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/ds1.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* -------------------------------------------------------------------- */
 
@@ -365,7 +366,7 @@
 }
 
 static int
-ds_initpbank(volatile struct pbank *pb, int ch, int b16, int stereo, u_int32_t rate, bus_addr_t base, u_int32_t len)
+ds_initpbank(volatile struct pbank *pb, int ch, int stereo, int b16, u_int32_t rate, bus_addr_t base, u_int32_t len)
 {
 	u_int32_t lv[] = {1, 1, 0, 0, 0};
 	u_int32_t rv[] = {1, 0, 1, 0, 0};
@@ -941,7 +942,6 @@
 static int
 ds_pci_attach(device_t dev)
 {
-	u_int32_t	data;
 	u_int32_t subdev, i;
 	struct sc_info *sc;
 	struct ac97_info *codec = NULL;
@@ -954,10 +954,7 @@
 	sc->type = ds_finddev(pci_get_devid(dev), subdev);
 	sc->rev = pci_get_revid(dev);
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	sc->regid = PCIR_BAR(0);
 	sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regid,

Modified: trunk/sys/dev/sound/pci/ds1.h
===================================================================
--- trunk/sys/dev/sound/pci/ds1.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/ds1.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * =======================================================================
  *	title		: define
@@ -5,7 +6,7 @@
  *	author		: Taichi Sugiyama
  *	create Data     : 28/Sep/99
  * =======================================================================
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/ds1.h 61108 2000-05-31 03:21:36Z cg $
  */
 
 

Modified: trunk/sys/dev/sound/pci/emu10k1.c
===================================================================
--- trunk/sys/dev/sound/pci/emu10k1.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emu10k1.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 David O'Brien <obrien at FreeBSD.org>
  * Copyright (c) 2003 Orlando Bassotto <orlando.bassotto at ieo-research.it>
@@ -41,7 +42,7 @@
 #include <dev/sound/midi/mpu401.h>
 #include "mpufoi_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/emu10k1.c 267043 2014-06-04 09:54:01Z marius $");
 
 /* -------------------------------------------------------------------- */
 
@@ -1378,7 +1379,7 @@
 	ofs = 0;
 	for (idx = start; idx < start + blksz; idx++) {
 		mem->bmap[idx >> 3] |= 1 << (idx & 7);
-		tmp = (u_int32_t)(u_long)((u_int8_t *)blk->buf_addr + ofs);
+		tmp = (uint32_t)(blk->buf_addr + ofs);
 #ifdef EMUDEBUG
 		printf("pte[%d] -> %x phys, %x virt\n", idx, tmp,
 		    ((u_int32_t)buf) + ofs);
@@ -2067,7 +2068,6 @@
 {
 	struct ac97_info *codec = NULL;
 	struct sc_info *sc;
-	u_int32_t data;
 	int i, gotmic;
 	char status[SND_STATUSLEN];
 
@@ -2081,10 +2081,7 @@
 	sc->nchans = sc->audigy ? 8 : 4;
 	sc->addrmask = sc->audigy ? EMU_A_PTR_ADDR_MASK : EMU_PTR_ADDR_MASK;
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	i = PCIR_BAR(0);
 	sc->reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &i, RF_ACTIVE);
@@ -2186,7 +2183,7 @@
 	DEVMETHOD(device_attach,	emu_pci_attach),
 	DEVMETHOD(device_detach,	emu_pci_detach),
 
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t emu_driver = {
@@ -2195,7 +2192,7 @@
 	PCM_SOFTC_SIZE,
 };
 
-DRIVER_MODULE(snd_emu10k1, pci, emu_driver, pcm_devclass, 0, 0);
+DRIVER_MODULE(snd_emu10k1, pci, emu_driver, pcm_devclass, NULL, NULL);
 MODULE_DEPEND(snd_emu10k1, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
 MODULE_VERSION(snd_emu10k1, 1);
 MODULE_DEPEND(snd_emu10k1, midi, 1, 1, 1);
@@ -2224,6 +2221,7 @@
 static int
 emujoy_pci_attach(device_t dev)
 {
+
 	return 0;
 }
 
@@ -2230,6 +2228,7 @@
 static int
 emujoy_pci_detach(device_t dev)
 {
+
 	return 0;
 }
 
@@ -2238,16 +2237,15 @@
 	DEVMETHOD(device_attach,	emujoy_pci_attach),
 	DEVMETHOD(device_detach,	emujoy_pci_detach),
 
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t emujoy_driver = {
 	"emujoy",
 	emujoy_methods,
-	8,
+	1	/* no softc */
 };
 
 static devclass_t emujoy_devclass;
 
-DRIVER_MODULE(emujoy, pci, emujoy_driver, emujoy_devclass, 0, 0);
-
+DRIVER_MODULE(emujoy, pci, emujoy_driver, emujoy_devclass, NULL, NULL);

Modified: trunk/sys/dev/sound/pci/emu10kx-midi.c
===================================================================
--- trunk/sys/dev/sound/pci/emu10kx-midi.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emu10kx-midi.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Seigo Tanimura
  * Copyright (c) 2003 Mathew Kanner
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/emu10kx-midi.c 246128 2013-01-30 18:01:20Z sbz $
  */
 
 #include <sys/param.h>
@@ -239,7 +240,7 @@
 	DEVMETHOD(device_attach, emu_midi_attach),
 	DEVMETHOD(device_detach, emu_midi_detach),
 
-	{0, 0},
+	DEVMETHOD_END
 };
 
 static driver_t emu_midi_driver = {

Modified: trunk/sys/dev/sound/pci/emu10kx-pcm.c
===================================================================
--- trunk/sys/dev/sound/pci/emu10kx-pcm.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emu10kx-pcm.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <gandalf at vilnya.demon.co.uk>
  * Copyright (c) 2003-2007 Yuriy Tsibizov <yuriy.tsibizov at gfk.ru>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/emu10kx-pcm.c 246128 2013-01-30 18:01:20Z sbz $
  */
 
 #include <sys/param.h>
@@ -1520,7 +1521,8 @@
 	DEVMETHOD(device_probe, emu_pcm_probe),
 	DEVMETHOD(device_attach, emu_pcm_attach),
 	DEVMETHOD(device_detach, emu_pcm_detach),
-	{0, 0}
+
+	DEVMETHOD_END
 };
 
 static driver_t emu_pcm_driver = {

Modified: trunk/sys/dev/sound/pci/emu10kx.c
===================================================================
--- trunk/sys/dev/sound/pci/emu10kx.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emu10kx.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * Copyright (c) 2003-2007 Yuriy Tsibizov <yuriy.tsibizov at gfk.ru>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/emu10kx.c 254263 2013-08-12 23:30:01Z scottl $
  */
 
 #include <sys/param.h>
@@ -158,7 +159,7 @@
 #define	OUT_ADC_REC	OUT_ADC_REC_L
 #define	OUT_MIC_CAP	0x0c
 
-/* Live! 5.1 Digital, non-standart 5.1 (center & sub) outputs */
+/* Live! 5.1 Digital, non-standard 5.1 (center & sub) outputs */
 #define	OUT_A_CENTER	0x11
 #define	OUT_A_SUB	0x12
 
@@ -806,7 +807,7 @@
 
 
 /*
- * emu_timer_ - HW timer managment
+ * emu_timer_ - HW timer management
  */
 int
 emu_timer_create(struct emu_sc_info *sc)
@@ -913,7 +914,7 @@
 }
 
 /*
- * emu_intr_ - HW interrupt handler managment
+ * emu_intr_ - HW interrupt handler management
  */
 int
 emu_intr_register(struct emu_sc_info *sc, uint32_t inte_mask, uint32_t intr_mask, uint32_t(*func) (void *softc, uint32_t irq), void *isc)
@@ -1012,7 +1013,7 @@
 			if (sc->dbg_level > 1)
 				device_printf(sc->dev, "EMU_IPR2: %08x\n", stat);
 
-			break;	/* to avoid infinite loop. shoud be removed
+			break;	/* to avoid infinite loop. should be removed
 				 * after completion of P16V interface. */
 		}
 
@@ -1928,7 +1929,7 @@
 			/*
 			 * Substream map (in byte offsets, each substream is 2 bytes):
 			 *	0x00..0x1E - outputs
-			 *	0x20..0x3E - FX, inputs ans sync stream
+			 *	0x20..0x3E - FX, inputs and sync stream
 			 */
 
 			/* First 2 channels (offset 0x20,0x22) are empty */
@@ -3040,7 +3041,6 @@
 #if 0
 	struct emu_midiinfo *midiinfo;
 #endif
-	uint32_t data;
 	int i;
 	int device_flags;
 	char status[255];
@@ -3168,7 +3168,7 @@
 		sc->output_base = 0x20;
 		/*
 		 * XXX 5.1 Analog outputs are inside efxc address space!
-		 * They use ouput+0x11/+0x12 (=efxc+1/+2).
+		 * They use output+0x11/+0x12 (=efxc+1/+2).
 		 * Don't use this efx registers for recording on SB Live! 5.1!
 		 */
 		sc->efxc_base = 0x30;
@@ -3182,11 +3182,6 @@
 	if (sc->opcode_shift == 0)
 		goto bad;
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-
 	pci_enable_busmaster(dev);
 
 	i = PCIR_BAR(0);
@@ -3529,7 +3524,7 @@
 	DEVMETHOD(bus_read_ivar, emu_read_ivar),
 	DEVMETHOD(bus_write_ivar, emu_write_ivar),
 
-	{0, 0}
+	DEVMETHOD_END
 };
 
 

Modified: trunk/sys/dev/sound/pci/emu10kx.h
===================================================================
--- trunk/sys/dev/sound/pci/emu10kx.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emu10kx.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <gandalf at vilnya.demon.co.uk>
  * Copyright (c) 2003-2006 Yuriy Tsibizov <yuriy.tsibizov at gfk.ru>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/emu10kx.h 229981 2012-01-11 21:17:14Z pfg $
  */
 
 #ifndef EMU10KX_H

Modified: trunk/sys/dev/sound/pci/emuxkireg.h
===================================================================
--- trunk/sys/dev/sound/pci/emuxkireg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/emuxkireg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/pci/emuxkireg.h 229981 2012-01-11 21:17:14Z pfg $ */
 /*	$NetBSD: emuxkireg.h,v 1.8 2008/04/28 20:23:54 martin Exp $	*/
 
 /*-

Modified: trunk/sys/dev/sound/pci/envy24.c
===================================================================
--- trunk/sys/dev/sound/pci/envy24.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/envy24.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
  * All rights reserved.
@@ -39,7 +40,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/envy24.c 254263 2013-08-12 23:30:01Z scottl $");
 
 static MALLOC_DEFINE(M_ENVY24, "envy24", "envy24 audio");
 
@@ -2547,7 +2548,6 @@
 static int
 envy24_pci_attach(device_t dev)
 {
-	u_int32_t		data;
 	struct sc_info 		*sc;
 	char 			status[SND_STATUSLEN];
 	int			err = 0;
@@ -2567,10 +2567,7 @@
 	sc->dev = dev;
 
 	/* initialize PCI interface */
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	/* allocate resources */
 	err = envy24_alloc_resource(sc);

Modified: trunk/sys/dev/sound/pci/envy24.h
===================================================================
--- trunk/sys/dev/sound/pci/envy24.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/envy24.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/envy24.h 205859 2010-03-29 20:27:17Z joel $
  */
 
 

Modified: trunk/sys/dev/sound/pci/envy24ht.c
===================================================================
--- trunk/sys/dev/sound/pci/envy24ht.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/envy24ht.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov at gmail.com>
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
@@ -51,7 +52,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/envy24ht.c 254263 2013-08-12 23:30:01Z scottl $");
 
 static MALLOC_DEFINE(M_ENVY24HT, "envy24ht", "envy24ht audio");
 
@@ -2450,7 +2451,6 @@
 static int
 envy24ht_pci_attach(device_t dev)
 {
-	u_int32_t		data;
 	struct sc_info 		*sc;
 	char 			status[SND_STATUSLEN];
 	int			err = 0;
@@ -2471,10 +2471,7 @@
 	sc->dev = dev;
 
 	/* initialize PCI interface */
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	/* allocate resources */
 	err = envy24ht_alloc_resource(sc);

Modified: trunk/sys/dev/sound/pci/envy24ht.h
===================================================================
--- trunk/sys/dev/sound/pci/envy24ht.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/envy24ht.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov at gmail.com>
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/envy24ht.h 250286 2013-05-05 19:09:34Z mav $
  */
 
 

Modified: trunk/sys/dev/sound/pci/es137x.c
===================================================================
--- trunk/sys/dev/sound/pci/es137x.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/es137x.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Russell Cattelan <cattelan at thebarn.com>
  * Copyright (c) 1998 Joachim Kuebart <joachim.kuebart at gmx.net>
@@ -88,7 +89,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/es137x.c 314667 2017-03-04 13:03:31Z avg $");
 
 #define MEM_MAP_REG 0x14
 
@@ -1704,7 +1705,6 @@
 static int
 es_pci_attach(device_t dev)
 {
-	uint32_t	data;
 	struct es_info *es = NULL;
 	int		mapped, i, numplay, dac_cfg;
 	char		status[SND_STATUSLEN];
@@ -1719,11 +1719,7 @@
 	mapped = 0;
 
 	pci_enable_busmaster(dev);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	if (mapped == 0 && (data & PCIM_CMD_MEMEN)) {
+	if (mapped == 0) {
 		es->regid = MEM_MAP_REG;
 		es->regtype = SYS_RES_MEMORY;
 		es->reg = bus_alloc_resource_any(dev, es->regtype, &es->regid,
@@ -1731,7 +1727,7 @@
 		if (es->reg)
 			mapped++;
 	}
-	if (mapped == 0 && (data & PCIM_CMD_PORTEN)) {
+	if (mapped == 0) {
 		es->regid = PCIR_BAR(0);
 		es->regtype = SYS_RES_IOPORT;
 		es->reg = bus_alloc_resource_any(dev, es->regtype, &es->regid,
@@ -1746,7 +1742,7 @@
 
 	es->st = rman_get_bustag(es->reg);
 	es->sh = rman_get_bushandle(es->reg);
-	callout_init(&es->poll_timer, CALLOUT_MPSAFE);
+	callout_init(&es->poll_timer, 1);
 	es->poll_ticks = 1;
 
 	if (resource_int_value(device_get_name(dev),

Modified: trunk/sys/dev/sound/pci/es137x.h
===================================================================
--- trunk/sys/dev/sound/pci/es137x.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/es137x.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Joachim Kuebart <joachim.kuebart at gmx.net>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/es137x.h 204875 2010-03-08 18:51:28Z joel $
  */
 
 /* This supports the ENSONIQ AudioPCI board based on the ES1370. */

Modified: trunk/sys/dev/sound/pci/fm801.c
===================================================================
--- trunk/sys/dev/sound/pci/fm801.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/fm801.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Dmitry Dicky diwil at dataart.com
  * All rights reserved.
@@ -33,7 +34,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/fm801.c 254263 2013-08-12 23:30:01Z scottl $");
 
 #define PCI_VENDOR_FORTEMEDIA	0x1319
 #define PCI_DEVICE_FORTEMEDIA1	0x08011319	/* Audio controller */
@@ -573,7 +574,6 @@
 static int
 fm801_pci_attach(device_t dev)
 {
-	u_int32_t 		data;
 	struct ac97_info 	*codec = 0;
 	struct fm801_info 	*fm801;
 	int 			i;
@@ -583,10 +583,7 @@
 	fm801 = malloc(sizeof(*fm801), M_DEVBUF, M_WAITOK | M_ZERO);
 	fm801->type = pci_get_devid(dev);
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	for (i = 0; (mapped == 0) && (i < PCI_MAXMAPS_0); i++) {
 		fm801->regid = PCIR_BAR(i);

Modified: trunk/sys/dev/sound/pci/hda/hda_reg.h
===================================================================
--- trunk/sys/dev/sound/pci/hda/hda_reg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hda_reg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hda/hda_reg.h 230312 2012-01-18 19:12:33Z mav $
  */
 
 #ifndef _HDA_REG_H_

Modified: trunk/sys/dev/sound/pci/hda/hdaa.c
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdaa.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdaa.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2006 Ariff Abdullah <ariff at FreeBSD.org>
@@ -45,7 +46,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hda/hdaa.c 314667 2017-03-04 13:03:31Z avg $");
 
 #define hdaa_lock(devinfo)	snd_mtxlock((devinfo)->lock)
 #define hdaa_unlock(devinfo)	snd_mtxunlock((devinfo)->lock)
@@ -53,7 +54,7 @@
 #define hdaa_lockowned(devinfo)	mtx_owned((devinfo)->lock)
 
 static const struct {
-	char *key;
+	const char *key;
 	uint32_t value;
 } hdaa_quirks_tab[] = {
 	{ "softpcmvol", HDAA_QUIRK_SOFTPCMVOL },
@@ -71,28 +72,26 @@
 	{ "ovref", HDAA_QUIRK_OVREF },
 	{ "vref", HDAA_QUIRK_VREF },
 };
-#define HDAA_QUIRKS_TAB_LEN	\
-		(sizeof(hdaa_quirks_tab) / sizeof(hdaa_quirks_tab[0]))
 
 #define HDA_PARSE_MAXDEPTH	10
 
 MALLOC_DEFINE(M_HDAA, "hdaa", "HDA Audio");
 
-const char *HDA_COLORS[16] = {"Unknown", "Black", "Grey", "Blue", "Green", "Red",
-    "Orange", "Yellow", "Purple", "Pink", "Res.A", "Res.B", "Res.C", "Res.D",
-    "White", "Other"};
+static const char *HDA_COLORS[16] = {"Unknown", "Black", "Grey", "Blue",
+    "Green", "Red", "Orange", "Yellow", "Purple", "Pink", "Res.A", "Res.B",
+    "Res.C", "Res.D", "White", "Other"};
 
-const char *HDA_DEVS[16] = {"Line-out", "Speaker", "Headphones", "CD",
+static const char *HDA_DEVS[16] = {"Line-out", "Speaker", "Headphones", "CD",
     "SPDIF-out", "Digital-out", "Modem-line", "Modem-handset", "Line-in",
     "AUX", "Mic", "Telephony", "SPDIF-in", "Digital-in", "Res.E", "Other"};
 
-const char *HDA_CONNS[4] = {"Jack", "None", "Fixed", "Both"};
+static const char *HDA_CONNS[4] = {"Jack", "None", "Fixed", "Both"};
 
-const char *HDA_CONNECTORS[16] = {
+static const char *HDA_CONNECTORS[16] = {
     "Unknown", "1/8", "1/4", "ATAPI", "RCA", "Optical", "Digital", "Analog",
     "DIN", "XLR", "RJ-11", "Combo", "0xc", "0xd", "0xe", "Other" };
 
-const char *HDA_LOCS[64] = {
+static const char *HDA_LOCS[64] = {
     "0x00", "Rear", "Front", "Left", "Right", "Top", "Bottom", "Rear-panel",
 	"Drive-bay", "0x09", "0x0a", "0x0b", "0x0c", "0x0d", "0x0e", "0x0f",
     "Internal", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "Riser",
@@ -102,10 +101,10 @@
     "Other", "0x31", "0x32", "0x33", "0x34", "0x35", "Other-Bott", "Lid-In",
 	"Lid-Out", "0x39", "0x3a", "0x3b", "0x3c", "0x3d", "0x3e", "0x3f" };
 
-const char *HDA_GPIO_ACTIONS[8] = {
+static const char *HDA_GPIO_ACTIONS[8] = {
     "keep", "set", "clear", "disable", "input", "0x05", "0x06", "0x07"};
 
-const char *HDA_HDMI_CODING_TYPES[18] = {
+static const char *HDA_HDMI_CODING_TYPES[18] = {
     "undefined", "LPCM", "AC-3", "MPEG1", "MP3", "MPEG2", "AAC-LC", "DTS",
     "ATRAC", "DSD", "E-AC-3", "DTS-HD", "MLP", "DST", "WMAPro", "HE-AAC",
     "HE-AACv2", "MPEG-Surround"
@@ -238,7 +237,143 @@
 	return (NULL);
 }
 
+static const struct matrix {
+	struct pcmchan_matrix	m;
+	int			analog;
+} matrixes[]  = {
+    { SND_CHN_MATRIX_MAP_1_0,	1 },
+    { SND_CHN_MATRIX_MAP_2_0,	1 },
+    { SND_CHN_MATRIX_MAP_2_1,	0 },
+    { SND_CHN_MATRIX_MAP_3_0,	0 },
+    { SND_CHN_MATRIX_MAP_3_1,	0 },
+    { SND_CHN_MATRIX_MAP_4_0,	1 },
+    { SND_CHN_MATRIX_MAP_4_1,	0 },
+    { SND_CHN_MATRIX_MAP_5_0,	0 },
+    { SND_CHN_MATRIX_MAP_5_1,	1 },
+    { SND_CHN_MATRIX_MAP_6_0,	0 },
+    { SND_CHN_MATRIX_MAP_6_1,	0 },
+    { SND_CHN_MATRIX_MAP_7_0,	0 },
+    { SND_CHN_MATRIX_MAP_7_1,	1 },
+};
+
+static const char *channel_names[] = SND_CHN_T_NAMES;
+
 /*
+ * Connected channels change handler.
+ */
+static void
+hdaa_channels_handler(struct hdaa_audio_as *as)
+{
+	struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo;
+	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
+	struct hdaa_chan *ch = &devinfo->chans[as->chans[0]];
+	struct hdaa_widget *w;
+	uint8_t *eld;
+	int i, total, sub, assume, channels;
+	uint16_t cpins, upins, tpins;
+
+	cpins = upins = 0;
+	eld = NULL;
+	for (i = 0; i < 16; i++) {
+		if (as->pins[i] <= 0)
+			continue;
+		w = hdaa_widget_get(devinfo, as->pins[i]);
+		if (w == NULL)
+			continue;
+		if (w->wclass.pin.connected == 1)
+			cpins |= (1 << i);
+		else if (w->wclass.pin.connected != 0)
+			upins |= (1 << i);
+		if (w->eld != NULL && w->eld_len >= 8)
+			eld = w->eld;
+	}
+	tpins = cpins | upins;
+	if (as->hpredir >= 0)
+		tpins &= 0x7fff;
+	if (tpins == 0)
+		tpins = as->pinset;
+
+	total = sub = assume = channels = 0;
+	if (eld) {
+		/* Map CEA speakers to sound(4) channels. */
+		if (eld[7] & 0x01) /* Front Left/Right */
+			channels |= SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR;
+		if (eld[7] & 0x02) /* Low Frequency Effect */
+			channels |= SND_CHN_T_MASK_LF;
+		if (eld[7] & 0x04) /* Front Center */
+			channels |= SND_CHN_T_MASK_FC;
+		if (eld[7] & 0x08) { /* Rear Left/Right */
+			/* If we have both RLR and RLRC, report RLR as side. */
+			if (eld[7] & 0x40) /* Rear Left/Right Center */
+			    channels |= SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR;
+			else
+			    channels |= SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR;
+		}
+		if (eld[7] & 0x10) /* Rear center */
+			channels |= SND_CHN_T_MASK_BC;
+		if (eld[7] & 0x20) /* Front Left/Right Center */
+			channels |= SND_CHN_T_MASK_FLC | SND_CHN_T_MASK_FRC;
+		if (eld[7] & 0x40) /* Rear Left/Right Center */
+			channels |= SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR;
+	} else if (as->pinset != 0 && (tpins & 0xffe0) == 0) {
+		/* Map UAA speakers to sound(4) channels. */
+		if (tpins & 0x0001)
+			channels |= SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR;
+		if (tpins & 0x0002)
+			channels |= SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF;
+		if (tpins & 0x0004)
+			channels |= SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR;
+		if (tpins & 0x0008)
+			channels |= SND_CHN_T_MASK_FLC | SND_CHN_T_MASK_FRC;
+		if (tpins & 0x0010) {
+			/* If there is no back pin, report side as back. */
+			if ((as->pinset & 0x0004) == 0)
+			    channels |= SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR;
+			else
+			    channels |= SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR;
+		}
+	} else if (as->mixed) {
+		/* Mixed assoc can be only stereo or theoretically mono. */
+		if (ch->channels == 1)
+			channels |= SND_CHN_T_MASK_FC;
+		else
+			channels |= SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR;
+	}
+	if (channels) {	/* We have some usable channels info. */
+		HDA_BOOTVERBOSE(
+			device_printf(pdevinfo->dev, "%s channel set is: ",
+			    as->dir == HDAA_CTL_OUT ? "Playback" : "Recording");
+			for (i = 0; i < SND_CHN_T_MAX; i++)
+				if (channels & (1 << i))
+					printf("%s, ", channel_names[i]);
+			printf("\n");
+		);
+		/* Look for maximal fitting matrix. */
+		for (i = 0; i < sizeof(matrixes) / sizeof(struct matrix); i++) {
+			if (as->pinset != 0 && matrixes[i].analog == 0)
+				continue;
+			if ((matrixes[i].m.mask & ~channels) == 0) {
+				total = matrixes[i].m.channels;
+				sub = matrixes[i].m.ext;
+			}
+		}
+	}
+	if (total == 0) {
+		assume = 1;
+		total = ch->channels;
+		sub = (total == 6 || total == 8) ? 1 : 0;
+	}
+	HDA_BOOTVERBOSE(
+		device_printf(pdevinfo->dev,
+		    "%s channel matrix is: %s%d.%d (%s)\n",
+		    as->dir == HDAA_CTL_OUT ? "Playback" : "Recording",
+		    assume ? "unknown, assuming " : "", total - sub, sub,
+		    cpins != 0 ? "connected" :
+		    (upins != 0 ? "unknown" : "disconnected"));
+	);
+}
+
+/*
  * Headphones redirection change handler.
  */
 static void
@@ -421,7 +556,7 @@
 	HDA_BOOTVERBOSE(
 		if (connected || old != 2) {
 			device_printf(devinfo->dev,
-			    "Pin sense: nid=%d sence=0x%08x (%sconnected)\n",
+			    "Pin sense: nid=%d sense=0x%08x (%sconnected)\n",
 			    w->nid, res, !connected ? "dis" : "");
 		}
 	);
@@ -431,6 +566,8 @@
 		hdaa_hpredir_handler(w);
 	if (as->dir == HDAA_CTL_IN && old != 2)
 		hdaa_autorecsrc_handler(as, w);
+	if (old != 2)
+		hdaa_channels_handler(as);
 }
 
 /*
@@ -568,7 +705,7 @@
 	}
 	HDA_BOOTVERBOSE(
 		device_printf(devinfo->dev,
-		    "Pin sense: nid=%d sence=0x%08x "
+		    "Pin sense: nid=%d sense=0x%08x "
 		    "(%sconnected, ELD %svalid)\n",
 		    w->nid, res,
 		    (res & HDA_CMD_GET_PIN_SENSE_PRESENCE_DETECT) ? "" : "dis",
@@ -598,6 +735,7 @@
 	HDA_BOOTVERBOSE(
 		hdaa_eld_dump(w);
 	);
+	hdaa_channels_handler(&devinfo->as[w->bindas]);
 }
 
 /*
@@ -839,7 +977,253 @@
 	w->wclass.pin.newconf = w->wclass.pin.config = config;
 }
 
+static void
+hdaa_dump_audio_formats_sb(struct sbuf *sb, uint32_t fcap, uint32_t pcmcap)
+{
+	uint32_t cap;
+
+	cap = fcap;
+	if (cap != 0) {
+		sbuf_printf(sb, "     Stream cap: 0x%08x", cap);
+		if (HDA_PARAM_SUPP_STREAM_FORMATS_AC3(cap))
+			sbuf_printf(sb, " AC3");
+		if (HDA_PARAM_SUPP_STREAM_FORMATS_FLOAT32(cap))
+			sbuf_printf(sb, " FLOAT32");
+		if (HDA_PARAM_SUPP_STREAM_FORMATS_PCM(cap))
+			sbuf_printf(sb, " PCM");
+		sbuf_printf(sb, "\n");
+	}
+	cap = pcmcap;
+	if (cap != 0) {
+		sbuf_printf(sb, "        PCM cap: 0x%08x", cap);
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8BIT(cap))
+			sbuf_printf(sb, " 8");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16BIT(cap))
+			sbuf_printf(sb, " 16");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_20BIT(cap))
+			sbuf_printf(sb, " 20");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_24BIT(cap))
+			sbuf_printf(sb, " 24");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_32BIT(cap))
+			sbuf_printf(sb, " 32");
+		sbuf_printf(sb, " bits,");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8KHZ(cap))
+			sbuf_printf(sb, " 8");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_11KHZ(cap))
+			sbuf_printf(sb, " 11");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16KHZ(cap))
+			sbuf_printf(sb, " 16");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_22KHZ(cap))
+			sbuf_printf(sb, " 22");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_32KHZ(cap))
+			sbuf_printf(sb, " 32");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_44KHZ(cap))
+			sbuf_printf(sb, " 44");
+		sbuf_printf(sb, " 48");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_88KHZ(cap))
+			sbuf_printf(sb, " 88");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_96KHZ(cap))
+			sbuf_printf(sb, " 96");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_176KHZ(cap))
+			sbuf_printf(sb, " 176");
+		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_192KHZ(cap))
+			sbuf_printf(sb, " 192");
+		sbuf_printf(sb, " KHz\n");
+	}
+}
+
+static void
+hdaa_dump_pin_sb(struct sbuf *sb, struct hdaa_widget *w)
+{
+	uint32_t pincap, conf;
+
+	pincap = w->wclass.pin.cap;
+
+	sbuf_printf(sb, "        Pin cap: 0x%08x", pincap);
+	if (HDA_PARAM_PIN_CAP_IMP_SENSE_CAP(pincap))
+		sbuf_printf(sb, " ISC");
+	if (HDA_PARAM_PIN_CAP_TRIGGER_REQD(pincap))
+		sbuf_printf(sb, " TRQD");
+	if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(pincap))
+		sbuf_printf(sb, " PDC");
+	if (HDA_PARAM_PIN_CAP_HEADPHONE_CAP(pincap))
+		sbuf_printf(sb, " HP");
+	if (HDA_PARAM_PIN_CAP_OUTPUT_CAP(pincap))
+		sbuf_printf(sb, " OUT");
+	if (HDA_PARAM_PIN_CAP_INPUT_CAP(pincap))
+		sbuf_printf(sb, " IN");
+	if (HDA_PARAM_PIN_CAP_BALANCED_IO_PINS(pincap))
+		sbuf_printf(sb, " BAL");
+	if (HDA_PARAM_PIN_CAP_HDMI(pincap))
+		sbuf_printf(sb, " HDMI");
+	if (HDA_PARAM_PIN_CAP_VREF_CTRL(pincap)) {
+		sbuf_printf(sb, " VREF[");
+		if (HDA_PARAM_PIN_CAP_VREF_CTRL_50(pincap))
+			sbuf_printf(sb, " 50");
+		if (HDA_PARAM_PIN_CAP_VREF_CTRL_80(pincap))
+			sbuf_printf(sb, " 80");
+		if (HDA_PARAM_PIN_CAP_VREF_CTRL_100(pincap))
+			sbuf_printf(sb, " 100");
+		if (HDA_PARAM_PIN_CAP_VREF_CTRL_GROUND(pincap))
+			sbuf_printf(sb, " GROUND");
+		if (HDA_PARAM_PIN_CAP_VREF_CTRL_HIZ(pincap))
+			sbuf_printf(sb, " HIZ");
+		sbuf_printf(sb, " ]");
+	}
+	if (HDA_PARAM_PIN_CAP_EAPD_CAP(pincap))
+		sbuf_printf(sb, " EAPD");
+	if (HDA_PARAM_PIN_CAP_DP(pincap))
+		sbuf_printf(sb, " DP");
+	if (HDA_PARAM_PIN_CAP_HBR(pincap))
+		sbuf_printf(sb, " HBR");
+	sbuf_printf(sb, "\n");
+	conf = w->wclass.pin.config;
+	sbuf_printf(sb, "     Pin config: 0x%08x", conf);
+	sbuf_printf(sb, " as=%d seq=%d "
+	    "device=%s conn=%s ctype=%s loc=%s color=%s misc=%d\n",
+	    HDA_CONFIG_DEFAULTCONF_ASSOCIATION(conf),
+	    HDA_CONFIG_DEFAULTCONF_SEQUENCE(conf),
+	    HDA_DEVS[HDA_CONFIG_DEFAULTCONF_DEVICE(conf)],
+	    HDA_CONNS[HDA_CONFIG_DEFAULTCONF_CONNECTIVITY(conf)],
+	    HDA_CONNECTORS[HDA_CONFIG_DEFAULTCONF_CONNECTION_TYPE(conf)],
+	    HDA_LOCS[HDA_CONFIG_DEFAULTCONF_LOCATION(conf)],
+	    HDA_COLORS[HDA_CONFIG_DEFAULTCONF_COLOR(conf)],
+	    HDA_CONFIG_DEFAULTCONF_MISC(conf));
+	sbuf_printf(sb, "    Pin control: 0x%08x", w->wclass.pin.ctrl);
+	if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE)
+		sbuf_printf(sb, " HP");
+	if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE)
+		sbuf_printf(sb, " IN");
+	if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE)
+		sbuf_printf(sb, " OUT");
+	if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
+		if ((w->wclass.pin.ctrl &
+		    HDA_CMD_SET_PIN_WIDGET_CTRL_VREF_ENABLE_MASK) == 0x03)
+			sbuf_printf(sb, " HBR");
+		else if ((w->wclass.pin.ctrl &
+		    HDA_CMD_SET_PIN_WIDGET_CTRL_VREF_ENABLE_MASK) != 0)
+			sbuf_printf(sb, " EPTs");
+	} else {
+		if ((w->wclass.pin.ctrl &
+		    HDA_CMD_SET_PIN_WIDGET_CTRL_VREF_ENABLE_MASK) != 0)
+			sbuf_printf(sb, " VREFs");
+	}
+	sbuf_printf(sb, "\n");
+}
+
+static void
+hdaa_dump_amp_sb(struct sbuf *sb, uint32_t cap, const char *banner)
+{
+	int offset, size, step;
+
+	offset = HDA_PARAM_OUTPUT_AMP_CAP_OFFSET(cap);
+	size = HDA_PARAM_OUTPUT_AMP_CAP_STEPSIZE(cap);
+	step = HDA_PARAM_OUTPUT_AMP_CAP_NUMSTEPS(cap);
+	sbuf_printf(sb, "     %s amp: 0x%08x "
+	    "mute=%d step=%d size=%d offset=%d (%+d/%+ddB)\n",
+	    banner, cap,
+	    HDA_PARAM_OUTPUT_AMP_CAP_MUTE_CAP(cap),
+	    step, size, offset,
+	    ((0 - offset) * (size + 1)) / 4,
+	    ((step - offset) * (size + 1)) / 4);
+}
+
+
 static int
+hdaa_sysctl_caps(SYSCTL_HANDLER_ARGS)
+{
+	struct hdaa_devinfo *devinfo;
+	struct hdaa_widget *w, *cw;
+	struct sbuf sb;
+	char buf[64];
+	int error, j;
+
+	w = (struct hdaa_widget *)oidp->oid_arg1;
+	devinfo = w->devinfo;
+	sbuf_new_for_sysctl(&sb, NULL, 256, req);
+
+	sbuf_printf(&sb, "%s%s\n", w->name,
+	    (w->enable == 0) ? " [DISABLED]" : "");
+	sbuf_printf(&sb, "     Widget cap: 0x%08x",
+	    w->param.widget_cap);
+	if (w->param.widget_cap & 0x0ee1) {
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap))
+		    sbuf_printf(&sb, " LRSWAP");
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap))
+		    sbuf_printf(&sb, " PWR");
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap))
+		    sbuf_printf(&sb, " DIGITAL");
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap))
+		    sbuf_printf(&sb, " UNSOL");
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap))
+		    sbuf_printf(&sb, " PROC");
+		if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap))
+		    sbuf_printf(&sb, " STRIPE(x%d)",
+			1 << (fls(w->wclass.conv.stripecap) - 1));
+		j = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap);
+		if (j == 1)
+		    sbuf_printf(&sb, " STEREO");
+		else if (j > 1)
+		    sbuf_printf(&sb, " %dCH", j + 1);
+	}
+	sbuf_printf(&sb, "\n");
+	if (w->bindas != -1) {
+		sbuf_printf(&sb, "    Association: %d (0x%04x)\n",
+		    w->bindas, w->bindseqmask);
+	}
+	if (w->ossmask != 0 || w->ossdev >= 0) {
+		sbuf_printf(&sb, "            OSS: %s",
+		    hdaa_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf)));
+		if (w->ossdev >= 0)
+		    sbuf_printf(&sb, " (%s)", ossnames[w->ossdev]);
+		sbuf_printf(&sb, "\n");
+	}
+	if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
+	    w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
+		hdaa_dump_audio_formats_sb(&sb,
+		    w->param.supp_stream_formats,
+		    w->param.supp_pcm_size_rate);
+	} else if (w->type ==
+	    HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || w->waspin)
+		hdaa_dump_pin_sb(&sb, w);
+	if (w->param.eapdbtl != HDA_INVALID) {
+		sbuf_printf(&sb, "           EAPD: 0x%08x%s%s%s\n",
+		    w->param.eapdbtl,
+		    (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_LR_SWAP) ?
+		     " LRSWAP" : "",
+		    (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD) ?
+		     " EAPD" : "",
+		    (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_BTL) ?
+		     " BTL" : "");
+	}
+	if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) &&
+	    w->param.outamp_cap != 0)
+		hdaa_dump_amp_sb(&sb, w->param.outamp_cap, "Output");
+	if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
+	    w->param.inamp_cap != 0)
+		hdaa_dump_amp_sb(&sb, w->param.inamp_cap, " Input");
+	if (w->nconns > 0)
+		sbuf_printf(&sb, "    Connections: %d\n", w->nconns);
+	for (j = 0; j < w->nconns; j++) {
+		cw = hdaa_widget_get(devinfo, w->conns[j]);
+		sbuf_printf(&sb, "          + %s<- nid=%d [%s]",
+		    (w->connsenable[j] == 0)?"[DISABLED] ":"",
+		    w->conns[j], (cw == NULL) ? "GHOST!" : cw->name);
+		if (cw == NULL)
+			sbuf_printf(&sb, " [UNKNOWN]");
+		else if (cw->enable == 0)
+			sbuf_printf(&sb, " [DISABLED]");
+		if (w->nconns > 1 && w->selconn == j && w->type !=
+		    HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
+			sbuf_printf(&sb, " (selected)");
+		sbuf_printf(&sb, "\n");
+	}
+	error = sbuf_finish(&sb);
+	sbuf_delete(&sb);
+	return (error);
+}
+
+static int
 hdaa_sysctl_config(SYSCTL_HANDLER_ARGS)
 {
 	char buf[256];
@@ -889,7 +1273,7 @@
 			inv = 2;
 		else
 			inv = 0;
-		for (k = 0; len > inv && k < HDAA_QUIRKS_TAB_LEN; k++) {
+		for (k = 0; len > inv && k < nitems(hdaa_quirks_tab); k++) {
 			if (strncmp(str + i + inv,
 			    hdaa_quirks_tab[k].key, len - inv) != 0)
 				continue;
@@ -917,7 +1301,7 @@
 
 	quirks = *(uint32_t *)oidp->oid_arg1;
 	buf[0] = 0;
-	for (i = 0; i < HDAA_QUIRKS_TAB_LEN; i++) {
+	for (i = 0; i < nitems(hdaa_quirks_tab); i++) {
 		if ((quirks & hdaa_quirks_tab[i].value) != 0)
 			n += snprintf(buf + n, sizeof(buf) - n, "%s%s",
 			    n != 0 ? "," : "", hdaa_quirks_tab[i].key);
@@ -1162,29 +1546,36 @@
 			w->param.eapdbtl |= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD;
 		} else
 			w->param.eapdbtl = HDA_INVALID;
+	}
+	w->unsol = -1;
 
-		hdaa_unlock(w->devinfo);
+	hdaa_unlock(w->devinfo);
+	snprintf(buf, sizeof(buf), "nid%d", w->nid);
+	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
+	    buf, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+	    w, 0, hdaa_sysctl_caps, "A", "Node capabilities");
+	if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) {
 		snprintf(buf, sizeof(buf), "nid%d_config", w->nid);
 		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 		    buf, CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-		    &w->wclass.pin.newconf, sizeof(&w->wclass.pin.newconf),
-		    hdaa_sysctl_config, "A", "Current pin configuration");
+		    &w->wclass.pin.newconf, 0, hdaa_sysctl_config, "A",
+		    "Current pin configuration");
 		snprintf(buf, sizeof(buf), "nid%d_original", w->nid);
 		SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 		    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 		    buf, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
-		    &w->wclass.pin.original, sizeof(&w->wclass.pin.original),
-		    hdaa_sysctl_config, "A", "Original pin configuration");
-		hdaa_lock(w->devinfo);
+		    &w->wclass.pin.original, 0, hdaa_sysctl_config, "A",
+		    "Original pin configuration");
 	}
-	w->unsol = -1;
+	hdaa_lock(w->devinfo);
 }
 
 static void
 hdaa_widget_postprocess(struct hdaa_widget *w)
 {
-	char *typestr;
+	const char *typestr;
 
 	w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(w->param.widget_cap);
 	switch (w->type) {
@@ -1455,14 +1846,17 @@
 	uint16_t fmt, dfmt;
 	/* Mapping channel pairs to codec pins/converters. */
 	const static uint16_t convmap[2][5] =
-	    {{ 0x0010, 0x0001, 0x0201, 0x0231, 0x0231 }, /* 5.1 */
-	     { 0x0010, 0x0001, 0x2001, 0x2031, 0x2431 }};/* 7.1 */
+	    /*  1.0     2.0     4.0     5.1     7.1  */
+	    {{ 0x0010, 0x0001, 0x0201, 0x0231, 0x4231 },	/* no dup. */
+	     { 0x0010, 0x0001, 0x2201, 0x2231, 0x4231 }};	/* side dup. */
 	/* Mapping formats to HDMI channel allocations. */
 	const static uint8_t hdmica[2][8] =
+	    /*  1     2     3     4     5     6     7     8  */
 	    {{ 0x02, 0x00, 0x04, 0x08, 0x0a, 0x0e, 0x12, 0x12 }, /* x.0 */
 	     { 0x01, 0x03, 0x01, 0x03, 0x09, 0x0b, 0x0f, 0x13 }}; /* x.1 */
 	/* Mapping formats to HDMI channels order. */
 	const static uint32_t hdmich[2][8] =
+	    /*  1  /  5     2  /  6     3  /  7     4  /  8  */
 	    {{ 0xFFFF0F00, 0xFFFFFF10, 0xFFF2FF10, 0xFF32FF10,
 	       0xFF324F10, 0xF5324F10, 0x54326F10, 0x54326F10 }, /* x.0 */
 	     { 0xFFFFF000, 0xFFFF0100, 0xFFFFF210, 0xFFFF2310,
@@ -1482,10 +1876,9 @@
 	fmt = hdaa_stream_format(ch);
 
 	/* Set channels to I/O converters mapping for known speaker setups. */
-	if ((as->pinset == 0x0007 || as->pinset == 0x0013)) /* Standard 5.1 */
-		convmapid = 0;
-	else if (as->pinset == 0x0017) /* Standard 7.1 */
-		convmapid = 1;
+	if ((as->pinset == 0x0007 || as->pinset == 0x0013) || /* Standard 5.1 */
+	    (as->pinset == 0x0017)) /* Standard 7.1 */
+		convmapid = (ch->dir == PCMDIR_PLAY);
 
 	dfmt = HDA_CMD_SET_DIGITAL_CONV_FMT1_DIGEN;
 	if (ch->fmt & AFMT_AC3)
@@ -2811,7 +3204,7 @@
 
 	/* Scan associations skipping as=0. */
 	cnt = 0;
-	for (j = 1; j < 16; j++) {
+	for (j = 1; j < 16 && cnt < max; j++) {
 		first = 16;
 		hpredir = 0;
 		for (i = devinfo->startnode; i < devinfo->endnode; i++) {
@@ -5158,7 +5551,7 @@
 	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
 	struct hdaa_audio_ctl *ctl;
 	char buf[64];
-	int i, j, printed;
+	int i, j, printed = 0;
 
 	if (flag == 0) {
 		flag = ~(SOUND_MASK_VOLUME | SOUND_MASK_PCM |
@@ -5186,7 +5579,6 @@
 				continue;
 
 			if (printed == 0) {
-				device_printf(pdevinfo->dev, "\n");
 				if (banner != NULL) {
 					device_printf(pdevinfo->dev, "%s", banner);
 				} else {
@@ -5201,7 +5593,6 @@
 					    pdevinfo->maxamp[j] / 4);
 				} else
 					printf("\n");
-				device_printf(pdevinfo->dev, "   |\n");
 				printed = 1;
 			}
 			device_printf(pdevinfo->dev, "   +- ctl %2d (nid %3d %s", i,
@@ -5221,6 +5612,8 @@
 				printf("%s\n", ctl->mute?"mute":"");
 		}
 	}
+	if (printed)
+		device_printf(pdevinfo->dev, "\n");
 }
 
 static void
@@ -5230,8 +5623,7 @@
 
 	cap = fcap;
 	if (cap != 0) {
-		device_printf(dev, "     Stream cap: 0x%08x\n", cap);
-		device_printf(dev, "                ");
+		device_printf(dev, "     Stream cap: 0x%08x", cap);
 		if (HDA_PARAM_SUPP_STREAM_FORMATS_AC3(cap))
 			printf(" AC3");
 		if (HDA_PARAM_SUPP_STREAM_FORMATS_FLOAT32(cap))
@@ -5242,8 +5634,7 @@
 	}
 	cap = pcmcap;
 	if (cap != 0) {
-		device_printf(dev, "        PCM cap: 0x%08x\n", cap);
-		device_printf(dev, "                ");
+		device_printf(dev, "        PCM cap: 0x%08x", cap);
 		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8BIT(cap))
 			printf(" 8");
 		if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16BIT(cap))
@@ -5287,8 +5678,7 @@
 
 	pincap = w->wclass.pin.cap;
 
-	device_printf(w->devinfo->dev, "        Pin cap: 0x%08x\n", pincap);
-	device_printf(w->devinfo->dev, "                ");
+	device_printf(w->devinfo->dev, "        Pin cap: 0x%08x", pincap);
 	if (HDA_PARAM_PIN_CAP_IMP_SENSE_CAP(pincap))
 		printf(" ISC");
 	if (HDA_PARAM_PIN_CAP_TRIGGER_REQD(pincap))
@@ -5387,15 +5777,20 @@
 }
 
 static void
-hdaa_dump_amp(device_t dev, uint32_t cap, char *banner)
+hdaa_dump_amp(device_t dev, uint32_t cap, const char *banner)
 {
-	device_printf(dev, "     %s amp: 0x%08x\n", banner, cap);
-	device_printf(dev, "                 "
-	    "mute=%d step=%d size=%d offset=%d\n",
+	int offset, size, step;
+
+	offset = HDA_PARAM_OUTPUT_AMP_CAP_OFFSET(cap);
+	size = HDA_PARAM_OUTPUT_AMP_CAP_STEPSIZE(cap);
+	step = HDA_PARAM_OUTPUT_AMP_CAP_NUMSTEPS(cap);
+	device_printf(dev, "     %s amp: 0x%08x "
+	    "mute=%d step=%d size=%d offset=%d (%+d/%+ddB)\n",
+	    banner, cap,
 	    HDA_PARAM_OUTPUT_AMP_CAP_MUTE_CAP(cap),
-	    HDA_PARAM_OUTPUT_AMP_CAP_NUMSTEPS(cap),
-	    HDA_PARAM_OUTPUT_AMP_CAP_STEPSIZE(cap),
-	    HDA_PARAM_OUTPUT_AMP_CAP_OFFSET(cap));
+	    step, size, offset,
+	    ((0 - offset) * (size + 1)) / 4,
+	    ((step - offset) * (size + 1)) / 4);
 }
 
 static void
@@ -5406,15 +5801,12 @@
 	int i, j;
 
 	device_printf(devinfo->dev, "\n");
-	device_printf(devinfo->dev, "Default Parameter\n");
-	device_printf(devinfo->dev, "-----------------\n");
+	device_printf(devinfo->dev, "Default parameters:\n");
 	hdaa_dump_audio_formats(devinfo->dev,
 	    devinfo->supp_stream_formats,
 	    devinfo->supp_pcm_size_rate);
-	device_printf(devinfo->dev, "         IN amp: 0x%08x\n",
-	    devinfo->inamp_cap);
-	device_printf(devinfo->dev, "        OUT amp: 0x%08x\n",
-	    devinfo->outamp_cap);
+	hdaa_dump_amp(devinfo->dev, devinfo->inamp_cap, " Input");
+	hdaa_dump_amp(devinfo->dev, devinfo->outamp_cap, "Output");
 	for (i = devinfo->startnode; i < devinfo->endnode; i++) {
 		w = hdaa_widget_get(devinfo, i);
 		if (w == NULL) {
@@ -5425,10 +5817,9 @@
 		device_printf(devinfo->dev, "            nid: %d%s\n", w->nid,
 		    (w->enable == 0) ? " [DISABLED]" : "");
 		device_printf(devinfo->dev, "           Name: %s\n", w->name);
-		device_printf(devinfo->dev, "     Widget cap: 0x%08x\n",
+		device_printf(devinfo->dev, "     Widget cap: 0x%08x",
 		    w->param.widget_cap);
 		if (w->param.widget_cap & 0x0ee1) {
-			device_printf(devinfo->dev, "                ");
 			if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap))
 			    printf(" LRSWAP");
 			if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap))
@@ -5447,10 +5838,10 @@
 			    printf(" STEREO");
 			else if (j > 1)
 			    printf(" %dCH", j + 1);
-			printf("\n");
 		}
+		printf("\n");
 		if (w->bindas != -1) {
-			device_printf(devinfo->dev, "    Association: %d (0x%08x)\n",
+			device_printf(devinfo->dev, "    Association: %d (0x%04x)\n",
 			    w->bindas, w->bindseqmask);
 		}
 		if (w->ossmask != 0 || w->ossdev >= 0) {
@@ -5477,10 +5868,8 @@
 		if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
 		    w->param.inamp_cap != 0)
 			hdaa_dump_amp(devinfo->dev, w->param.inamp_cap, " Input");
-		if (w->nconns > 0) {
-			device_printf(devinfo->dev, "    connections: %d\n", w->nconns);
-			device_printf(devinfo->dev, "          |\n");
-		}
+		if (w->nconns > 0)
+			device_printf(devinfo->dev, "    Connections: %d\n", w->nconns);
 		for (j = 0; j < w->nconns; j++) {
 			cw = hdaa_widget_get(devinfo, w->conns[j]);
 			device_printf(devinfo->dev, "          + %s<- nid=%d [%s]",
@@ -5505,7 +5894,7 @@
 	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
 	struct hdaa_widget *w, *cw;
 	char buf[64];
-	int i, printed = 0;
+	int i;
 
 	if (depth > HDA_PARSE_MAXDEPTH)
 		return;
@@ -5541,10 +5930,6 @@
 		cw = hdaa_widget_get(devinfo, w->conns[i]);
 		if (cw == NULL || cw->enable == 0 || cw->bindas == -1)
 			continue;
-		if (printed == 0) {
-			device_printf(pdevinfo->dev, "%*s  |\n", 4 + (depth) * 7, "");
-			printed = 1;
-		}
 		hdaa_dump_dst_nid(pdevinfo, w->conns[i], depth + 1);
 	}
 
@@ -5556,11 +5941,26 @@
 	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
 	struct hdaa_audio_as *as;
 	struct hdaa_widget *w;
-	int i, printed = 0;
+	nid_t *nids;
+	int chid, i;
 
 	if (pdevinfo->playas < 0)
 		return;
 
+	device_printf(pdevinfo->dev, "Playback:\n");
+
+	chid = devinfo->as[pdevinfo->playas].chans[0];
+	hdaa_dump_audio_formats(pdevinfo->dev,
+	    devinfo->chans[chid].supp_stream_formats,
+	    devinfo->chans[chid].supp_pcm_size_rate);
+	for (i = 0; i < devinfo->as[pdevinfo->playas].num_chans; i++) {
+		chid = devinfo->as[pdevinfo->playas].chans[i];
+		device_printf(pdevinfo->dev, "            DAC:");
+		for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
+			printf(" %d", *nids);
+		printf("\n");
+	}
+
 	as = &devinfo->as[pdevinfo->playas];
 	for (i = 0; i < 16; i++) {
 		if (as->pins[i] <= 0)
@@ -5568,14 +5968,10 @@
 		w = hdaa_widget_get(devinfo, as->pins[i]);
 		if (w == NULL || w->enable == 0)
 			continue;
-		if (printed == 0) {
-			printed = 1;
-			device_printf(pdevinfo->dev, "\n");
-			device_printf(pdevinfo->dev, "Playback:\n");
-		}
 		device_printf(pdevinfo->dev, "\n");
 		hdaa_dump_dst_nid(pdevinfo, as->pins[i], 0);
 	}
+	device_printf(pdevinfo->dev, "\n");
 }
 
 static void
@@ -5583,12 +5979,26 @@
 {
 	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
 	struct hdaa_widget *w;
-	int i;
-	int printed = 0;
+	nid_t *nids;
+	int chid, i;
 
 	if (pdevinfo->recas < 0)
 		return;
 
+	device_printf(pdevinfo->dev, "Record:\n");
+
+	chid = devinfo->as[pdevinfo->recas].chans[0];
+	hdaa_dump_audio_formats(pdevinfo->dev,
+	    devinfo->chans[chid].supp_stream_formats,
+	    devinfo->chans[chid].supp_pcm_size_rate);
+	for (i = 0; i < devinfo->as[pdevinfo->recas].num_chans; i++) {
+		chid = devinfo->as[pdevinfo->recas].chans[i];
+		device_printf(pdevinfo->dev, "            ADC:");
+		for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
+			printf(" %d", *nids);
+		printf("\n");
+	}
+
 	for (i = devinfo->startnode; i < devinfo->endnode; i++) {
 		w = hdaa_widget_get(devinfo, i);
 		if (w == NULL || w->enable == 0)
@@ -5597,14 +6007,10 @@
 			continue;
 		if (w->bindas != pdevinfo->recas)
 			continue;
-		if (printed == 0) {
-			printed = 1;
-			device_printf(pdevinfo->dev, "\n");
-			device_printf(pdevinfo->dev, "Record:\n");
-		}
 		device_printf(pdevinfo->dev, "\n");
 		hdaa_dump_dst_nid(pdevinfo, i, 0);
 	}
+	device_printf(pdevinfo->dev, "\n");
 }
 
 static void
@@ -5625,53 +6031,13 @@
 			continue;
 		if (printed == 0) {
 			printed = 1;
-			device_printf(pdevinfo->dev, "\n");
 			device_printf(pdevinfo->dev, "Input Mix:\n");
 		}
 		device_printf(pdevinfo->dev, "\n");
 		hdaa_dump_dst_nid(pdevinfo, i, 0);
 	}
-}
-
-static void
-hdaa_dump_pcmchannels(struct hdaa_pcm_devinfo *pdevinfo)
-{
-	struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
-	nid_t *nids;
-	int chid, i;
-
-	if (pdevinfo->playas >= 0) {
+	if (printed)
 		device_printf(pdevinfo->dev, "\n");
-		device_printf(pdevinfo->dev, "Playback:\n");
-		device_printf(pdevinfo->dev, "\n");
-		chid = devinfo->as[pdevinfo->playas].chans[0];
-		hdaa_dump_audio_formats(pdevinfo->dev,
-		    devinfo->chans[chid].supp_stream_formats,
-		    devinfo->chans[chid].supp_pcm_size_rate);
-		for (i = 0; i < devinfo->as[pdevinfo->playas].num_chans; i++) {
-			chid = devinfo->as[pdevinfo->playas].chans[i];
-			device_printf(pdevinfo->dev, "            DAC:");
-			for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
-				printf(" %d", *nids);
-			printf("\n");
-		}
-	}
-	if (pdevinfo->recas >= 0) {
-		device_printf(pdevinfo->dev, "\n");
-		device_printf(pdevinfo->dev, "Record:\n");
-		device_printf(pdevinfo->dev, "\n");
-		chid = devinfo->as[pdevinfo->recas].chans[0];
-		hdaa_dump_audio_formats(pdevinfo->dev,
-		    devinfo->chans[chid].supp_stream_formats,
-		    devinfo->chans[chid].supp_pcm_size_rate);
-		for (i = 0; i < devinfo->as[pdevinfo->recas].num_chans; i++) {
-			chid = devinfo->as[pdevinfo->recas].chans[i];
-			device_printf(pdevinfo->dev, "            DAC:");
-			for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
-				printf(" %d", *nids);
-			printf("\n");
-		}
-	}
 }
 
 static void
@@ -5842,7 +6208,7 @@
 	HDA_BOOTVERBOSE(
 		if (devinfo->quirks != 0) {
 			device_printf(dev, "FG config/quirks:");
-			for (i = 0; i < HDAA_QUIRKS_TAB_LEN; i++) {
+			for (i = 0; i < nitems(hdaa_quirks_tab); i++) {
 				if ((devinfo->quirks &
 				    hdaa_quirks_tab[i].value) ==
 				    hdaa_quirks_tab[i].value)
@@ -5850,19 +6216,19 @@
 			}
 			printf("\n");
 		}
+	);
 
+	HDA_BOOTHVERBOSE(
 		device_printf(dev, "\n");
-		device_printf(dev, "+-------------------+\n");
-		device_printf(dev, "| DUMPING HDA NODES |\n");
-		device_printf(dev, "+-------------------+\n");
+		device_printf(dev, "+-----------+\n");
+		device_printf(dev, "| HDA NODES |\n");
+		device_printf(dev, "+-----------+\n");
 		hdaa_dump_nodes(devinfo);
-	);
 
-	HDA_BOOTHVERBOSE(
 		device_printf(dev, "\n");
-		device_printf(dev, "+------------------------+\n");
-		device_printf(dev, "| DUMPING HDA AMPLIFIERS |\n");
-		device_printf(dev, "+------------------------+\n");
+		device_printf(dev, "+----------------+\n");
+		device_printf(dev, "| HDA AMPLIFIERS |\n");
+		device_printf(dev, "+----------------+\n");
 		device_printf(dev, "\n");
 		i = 0;
 		while ((ctl = hdaa_audio_ctl_each(devinfo, &i)) != NULL) {
@@ -5883,9 +6249,6 @@
 			    (ctl->enable == 0) ? " [DISABLED]" : 
 			    ((ctl->ossmask == 0) ? " [UNUSED]" : ""));
 		}
-	);
-
-	HDA_BOOTVERBOSE(
 		device_printf(dev, "\n");
 	);
 }
@@ -6230,7 +6593,7 @@
 	devinfo->newquirks = -1;
 	devinfo->newgpio = -1;
 	devinfo->newgpo = -1;
-	callout_init(&devinfo->poll_jack, CALLOUT_MPSAFE);
+	callout_init(&devinfo->poll_jack, 1);
 	devinfo->poll_ival = hz;
 
 	hdaa_lock(devinfo);
@@ -6279,38 +6642,32 @@
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "config", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	    &devinfo->newquirks, sizeof(&devinfo->newquirks),
-	    hdaa_sysctl_quirks, "A", "Configuration options");
+	    &devinfo->newquirks, 0, hdaa_sysctl_quirks, "A",
+	    "Configuration options");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "gpi_state", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
-	    devinfo, sizeof(devinfo),
-	    hdaa_sysctl_gpi_state, "A", "GPI state");
+	    devinfo, 0, hdaa_sysctl_gpi_state, "A", "GPI state");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "gpio_state", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
-	    devinfo, sizeof(devinfo),
-	    hdaa_sysctl_gpio_state, "A", "GPIO state");
+	    devinfo, 0, hdaa_sysctl_gpio_state, "A", "GPIO state");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "gpio_config", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	    devinfo, sizeof(devinfo),
-	    hdaa_sysctl_gpio_config, "A", "GPIO configuration");
+	    devinfo, 0, hdaa_sysctl_gpio_config, "A", "GPIO configuration");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "gpo_state", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
-	    devinfo, sizeof(devinfo),
-	    hdaa_sysctl_gpo_state, "A", "GPO state");
+	    devinfo, 0, hdaa_sysctl_gpo_state, "A", "GPO state");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "gpo_config", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	    devinfo, sizeof(devinfo),
-	    hdaa_sysctl_gpo_config, "A", "GPO configuration");
+	    devinfo, 0, hdaa_sysctl_gpo_config, "A", "GPO configuration");
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
 	    "reconfig", CTLTYPE_INT | CTLFLAG_RW,
-	    dev, sizeof(dev),
-	    hdaa_sysctl_reconfig, "I", "Reprocess configuration");
+	    dev, 0, hdaa_sysctl_reconfig, "I", "Reprocess configuration");
 	bus_generic_attach(dev);
 	return (0);
 }
@@ -6470,7 +6827,7 @@
 	DEVMETHOD(hdac_stream_intr,	hdaa_stream_intr),
 	DEVMETHOD(hdac_unsol_intr,	hdaa_unsol_intr),
 	DEVMETHOD(hdac_pindump,		hdaa_pindump),
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t hdaa_driver = {
@@ -6481,7 +6838,7 @@
 
 static devclass_t hdaa_devclass;
 
-DRIVER_MODULE(snd_hda, hdacc, hdaa_driver, hdaa_devclass, 0, 0);
+DRIVER_MODULE(snd_hda, hdacc, hdaa_driver, hdaa_devclass, NULL, NULL);
 
 static void
 hdaa_chan_formula(struct hdaa_devinfo *devinfo, int asid,
@@ -6649,21 +7006,9 @@
 	    HDA_BUFSZ_MIN, HDA_BUFSZ_DEFAULT, HDA_BUFSZ_MAX);
 
 	HDA_BOOTVERBOSE(
-		device_printf(dev, "+--------------------------------------+\n");
-		device_printf(dev, "| DUMPING PCM Playback/Record Channels |\n");
-		device_printf(dev, "+--------------------------------------+\n");
-		hdaa_dump_pcmchannels(pdevinfo);
-		device_printf(dev, "\n");
-		device_printf(dev, "+-------------------------------+\n");
-		device_printf(dev, "| DUMPING Playback/Record Paths |\n");
-		device_printf(dev, "+-------------------------------+\n");
 		hdaa_dump_dac(pdevinfo);
 		hdaa_dump_adc(pdevinfo);
 		hdaa_dump_mix(pdevinfo);
-		device_printf(dev, "\n");
-		device_printf(dev, "+-------------------------+\n");
-		device_printf(dev, "| DUMPING Volume Controls |\n");
-		device_printf(dev, "+-------------------------+\n");
 		hdaa_dump_ctls(pdevinfo, "Master Volume", SOUND_MASK_VOLUME);
 		hdaa_dump_ctls(pdevinfo, "PCM Volume", SOUND_MASK_PCM);
 		hdaa_dump_ctls(pdevinfo, "CD Volume", SOUND_MASK_CD);
@@ -6675,7 +7020,6 @@
 		hdaa_dump_ctls(pdevinfo, "Input Mix Level", SOUND_MASK_IMIX);
 		hdaa_dump_ctls(pdevinfo, "Input Monitoring Level", SOUND_MASK_IGAIN);
 		hdaa_dump_ctls(pdevinfo, NULL, 0);
-		device_printf(dev, "\n");
 	);
 
 	if (resource_int_value(device_get_name(dev),
@@ -6743,7 +7087,7 @@
 		    "rec.autosrc", &pdevinfo->autorecsrc);
 		SYSCTL_ADD_INT(&d->rec_sysctl_ctx,
 		    SYSCTL_CHILDREN(d->rec_sysctl_tree), OID_AUTO,
-		    "autosrc", CTLTYPE_INT | CTLFLAG_RW,
+		    "autosrc", CTLFLAG_RW,
 		    &pdevinfo->autorecsrc, 0,
 		    "Automatic recording source selection");
 	}
@@ -6750,12 +7094,17 @@
 
 	if (pdevinfo->mixer != NULL) {
 		hdaa_audio_ctl_set_defaults(pdevinfo);
+		hdaa_lock(devinfo);
+		if (pdevinfo->playas >= 0) {
+			as = &devinfo->as[pdevinfo->playas];
+			hdaa_channels_handler(as);
+		}
 		if (pdevinfo->recas >= 0) {
 			as = &devinfo->as[pdevinfo->recas];
-			hdaa_lock(devinfo);
 			hdaa_autorecsrc_handler(as, NULL);
-			hdaa_unlock(devinfo);
+			hdaa_channels_handler(as);
 		}
+		hdaa_unlock(devinfo);
 	}
 
 	snprintf(status, SND_STATUSLEN, "on %s %s",
@@ -6787,7 +7136,7 @@
 	DEVMETHOD(device_probe,		hdaa_pcm_probe),
 	DEVMETHOD(device_attach,	hdaa_pcm_attach),
 	DEVMETHOD(device_detach,	hdaa_pcm_detach),
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t hdaa_pcm_driver = {
@@ -6796,6 +7145,6 @@
 	PCM_SOFTC_SIZE,
 };
 
-DRIVER_MODULE(snd_hda_pcm, hdaa, hdaa_pcm_driver, pcm_devclass, 0, 0);
+DRIVER_MODULE(snd_hda_pcm, hdaa, hdaa_pcm_driver, pcm_devclass, NULL, NULL);
 MODULE_DEPEND(snd_hda, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
 MODULE_VERSION(snd_hda, 1);

Modified: trunk/sys/dev/sound/pci/hda/hdaa.h
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdaa.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdaa.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-7
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2006 Ariff Abdullah <ariff at FreeBSD.org>
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hda/hdaa.h 261455 2014-02-04 03:36:42Z eadler $
  */
 
 /*
@@ -56,7 +57,7 @@
 #define HDAA_QUIRK_IVREF100	(1 << 28)
 #define HDAA_QUIRK_OVREF50	(1 << 29)
 #define HDAA_QUIRK_OVREF80	(1 << 30)
-#define HDAA_QUIRK_OVREF100	(1 << 31)
+#define HDAA_QUIRK_OVREF100	(1U << 31)
 
 #define HDAA_QUIRK_IVREF	(HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF80 | \
 						HDAA_QUIRK_IVREF100)

Modified: trunk/sys/dev/sound/pci/hda/hdaa_patches.c
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdaa_patches.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdaa_patches.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2006 Ariff Abdullah <ariff at FreeBSD.org>
@@ -42,11 +43,12 @@
 #include <dev/sound/pci/hda/hdaa.h>
 #include <dev/sound/pci/hda/hda_reg.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hda/hdaa_patches.c 312367 2017-01-18 02:57:22Z yongari $");
 
 static const struct {
 	uint32_t model;
 	uint32_t id;
+	uint32_t subsystemid;
 	uint32_t set, unset;
 	uint32_t gpio;
 } hdac_quirks[] = {
@@ -55,77 +57,90 @@
 	 *     on few codecs (especially ALC880) seems broken or
 	 *     perhaps unsupported.
 	 */
-	{ HDA_MATCH_ALL, HDA_MATCH_ALL,
+	{ HDA_MATCH_ALL, HDA_MATCH_ALL, HDA_MATCH_ALL,
 	    HDAA_QUIRK_FORCESTEREO | HDAA_QUIRK_IVREF, 0,
 	    0 },
-	{ ACER_ALL_SUBVENDOR, HDA_MATCH_ALL,
+	{ ACER_ALL_SUBVENDOR, HDA_MATCH_ALL, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_G2K_SUBVENDOR, HDA_CODEC_ALC660,
+	{ ASUS_G2K_SUBVENDOR, HDA_CODEC_ALC660, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_M5200_SUBVENDOR, HDA_CODEC_ALC880,
+	{ ASUS_M5200_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_A7M_SUBVENDOR, HDA_CODEC_ALC880,
+	{ ASUS_A7M_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_A7T_SUBVENDOR, HDA_CODEC_ALC882,
+	{ ASUS_A7T_SUBVENDOR, HDA_CODEC_ALC882, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_W2J_SUBVENDOR, HDA_CODEC_ALC882,
+	{ ASUS_W2J_SUBVENDOR, HDA_CODEC_ALC882, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ ASUS_U5F_SUBVENDOR, HDA_CODEC_AD1986A,
+	{ ASUS_U5F_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
 	    HDAA_QUIRK_EAPDINV, 0,
 	    0 },
-	{ ASUS_A8X_SUBVENDOR, HDA_CODEC_AD1986A,
+	{ ASUS_A8X_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
 	    HDAA_QUIRK_EAPDINV, 0,
 	    0 },
-	{ ASUS_F3JC_SUBVENDOR, HDA_CODEC_ALC861,
+	{ ASUS_F3JC_SUBVENDOR, HDA_CODEC_ALC861, HDA_MATCH_ALL,
 	    HDAA_QUIRK_OVREF, 0,
 	    0 },
-	{ UNIWILL_9075_SUBVENDOR, HDA_CODEC_ALC861,
+	{ UNIWILL_9075_SUBVENDOR, HDA_CODEC_ALC861, HDA_MATCH_ALL,
 	    HDAA_QUIRK_OVREF, 0,
 	    0 },
-	/*{ ASUS_M2N_SUBVENDOR, HDA_CODEC_AD1988,
+	/*{ ASUS_M2N_SUBVENDOR, HDA_CODEC_AD1988, HDA_MATCH_ALL,
 	    HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
 	    0 },*/
-	{ MEDION_MD95257_SUBVENDOR, HDA_CODEC_ALC880,
+	{ MEDION_MD95257_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(1) },
-	{ LENOVO_3KN100_SUBVENDOR, HDA_CODEC_AD1986A,
+	{ LENOVO_3KN100_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
 	    HDAA_QUIRK_EAPDINV | HDAA_QUIRK_SENSEINV, 0,
 	    0 },
-	{ SAMSUNG_Q1_SUBVENDOR, HDA_CODEC_AD1986A,
+	{ SAMSUNG_Q1_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
 	    HDAA_QUIRK_EAPDINV, 0,
 	    0 },
-	{ APPLE_MB3_SUBVENDOR, HDA_CODEC_ALC885,
+	{ APPLE_MB3_SUBVENDOR, HDA_CODEC_ALC885, HDA_MATCH_ALL,
 	    HDAA_QUIRK_OVREF50, 0,
 	    HDAA_GPIO_SET(0) },
-	{ APPLE_INTEL_MAC, HDA_CODEC_STAC9221,
+	{ APPLE_INTEL_MAC, HDA_CODEC_STAC9221, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) | HDAA_GPIO_SET(1) },
-	{ APPLE_MACBOOKPRO55, HDA_CODEC_CS4206,
+	{ APPLE_MACBOOKAIR31, HDA_CODEC_CS4206, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
-	{ DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205X,
+	{ APPLE_MACBOOKPRO55, HDA_CODEC_CS4206, HDA_MATCH_ALL,
 	    0, 0,
+	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
+	{ APPLE_MACBOOKPRO71, HDA_CODEC_CS4206, HDA_MATCH_ALL,
+	    0, 0,
+	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
+	{ HDA_INTEL_MACBOOKPRO92, HDA_CODEC_CS4206, HDA_MATCH_ALL,
+	    0, 0,
+	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
+	{ DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205X, HDA_MATCH_ALL,
+	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ DELL_V1400_SUBVENDOR, HDA_CODEC_STAC9228X,
+	{ DELL_V1400_SUBVENDOR, HDA_CODEC_STAC9228X, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(2) },
-	{ DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205X,
+	{ DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205X, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(0) },
-	{ HDA_MATCH_ALL, HDA_CODEC_AD1988,
+	{ HDA_MATCH_ALL, HDA_CODEC_AD1988, HDA_MATCH_ALL,
 	    HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
 	    0 },
-	{ HDA_MATCH_ALL, HDA_CODEC_AD1988B,
+	{ HDA_MATCH_ALL, HDA_CODEC_AD1988B, HDA_MATCH_ALL,
 	    HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
 	    0 },
-	{ HDA_MATCH_ALL, HDA_CODEC_CX20549,
+	{ HDA_MATCH_ALL, HDA_CODEC_CX20549, HDA_MATCH_ALL,
 	    0, HDAA_QUIRK_FORCESTEREO,
+	    0 },
+	/* Mac Pro 1,1 requires ovref for proper volume level. */
+	{ 0x00000000, HDA_CODEC_ALC885, 0x106b0c00,
+	    0, HDAA_QUIRK_OVREF,
 	    0 }
 };
 #define HDAC_QUIRKS_LEN (sizeof(hdac_quirks) / sizeof(hdac_quirks[0]))
@@ -334,12 +349,57 @@
 			break;
 		}
 	} else if (id == HDA_CODEC_CX20590 &&
-	    subid == LENOVO_X220_SUBVENDOR) {
+	    (subid == LENOVO_X1_SUBVENDOR ||
+	    subid == LENOVO_X220_SUBVENDOR ||
+	    subid == LENOVO_T420_SUBVENDOR ||
+	    subid == LENOVO_T520_SUBVENDOR ||
+	    subid == LENOVO_G580_SUBVENDOR)) {
 		switch (nid) {
 		case 25:
 			patch = "as=1 seq=15";
 			break;
+		/*
+		 * Group onboard mic and headphone mic
+		 * together.  Fixes onboard mic.
+		 */
+		case 27:
+			patch = "as=2 seq=15";
+			break;
+		case 35:
+			patch = "as=2";
+			break;
 		}
+	} else if (id == HDA_CODEC_ALC269 &&
+	    (subid == LENOVO_X1CRBN_SUBVENDOR ||
+	    subid == LENOVO_T430_SUBVENDOR ||
+	    subid == LENOVO_T430S_SUBVENDOR ||
+	    subid == LENOVO_T530_SUBVENDOR)) {
+		switch (nid) {
+		case 21:
+			patch = "as=1 seq=15";
+			break;
+		}
+	} else if (id == HDA_CODEC_ALC269 &&
+	    subid == ASUS_UX31A_SUBVENDOR) {
+		switch (nid) {
+		case 33:
+			patch = "as=1 seq=15";
+			break;
+		}
+	} else if (id == HDA_CODEC_ALC892 &&
+	    subid == INTEL_DH87RL_SUBVENDOR) {
+		switch (nid) {
+		case 27:
+			patch = "as=1 seq=15";
+			break;
+		}
+	} else if (id == HDA_CODEC_ALC292 &&
+	    subid == LENOVO_X120BS_SUBVENDOR) {
+		switch (nid) {
+		case 21:
+			patch = "as=1 seq=15";
+			break;
+		}
 	}
 
 	if (patch != NULL)
@@ -412,11 +472,12 @@
 hdaa_patch(struct hdaa_devinfo *devinfo)
 {
 	struct hdaa_widget *w;
-	uint32_t id, subid;
+	uint32_t id, subid, subsystemid;
 	int i;
 
 	id = hdaa_codec_id(devinfo);
 	subid = hdaa_card_id(devinfo);
+	subsystemid = hda_get_subsystem_id(devinfo->dev);
 
 	/*
 	 * Quirks
@@ -423,7 +484,8 @@
 	 */
 	for (i = 0; i < HDAC_QUIRKS_LEN; i++) {
 		if (!(HDA_DEV_MATCH(hdac_quirks[i].model, subid) &&
-		    HDA_DEV_MATCH(hdac_quirks[i].id, id)))
+		    HDA_DEV_MATCH(hdac_quirks[i].id, id) &&
+		    HDA_DEV_MATCH(hdac_quirks[i].subsystemid, subsystemid)))
 			continue;
 		devinfo->quirks |= hdac_quirks[i].set;
 		devinfo->quirks &= ~(hdac_quirks[i].unset);
@@ -653,6 +715,15 @@
 		hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
 		    0xf88, 0xc0));
 		break;
+	case HDA_CODEC_ALC1150:
+		if (subid == 0xd9781462) {
+			/* Too low volume on MSI H170 GAMING M3. */
+			hda_command(dev, HDA_CMD_SET_COEFF_INDEX(0, 0x20,
+			    0x07));
+			hda_command(dev, HDA_CMD_SET_PROCESSING_COEFF(0, 0x20,
+			    0x7cb));
+		}
+		break;
 	}
 	if (subid == APPLE_INTEL_MAC)
 		hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,

Modified: trunk/sys/dev/sound/pci/hda/hdac.c
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdac.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdac.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2006 Ariff Abdullah <ariff at FreeBSD.org>
@@ -48,7 +49,7 @@
 
 #define HDA_DRV_TEST_REV	"20120126_0002"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hda/hdac.c 314667 2017-03-04 13:03:31Z avg $");
 
 #define hdac_lock(sc)		snd_mtxlock((sc)->lock)
 #define hdac_unlock(sc)		snd_mtxunlock((sc)->lock)
@@ -60,7 +61,7 @@
 #define HDAC_QUIRK_MSI		(1 << 2)
 
 static const struct {
-	char *key;
+	const char *key;
 	uint32_t value;
 } hdac_quirks_tab[] = {
 	{ "64bit", HDAC_QUIRK_DMAPOS },
@@ -67,22 +68,36 @@
 	{ "dmapos", HDAC_QUIRK_DMAPOS },
 	{ "msi", HDAC_QUIRK_MSI },
 };
-#define HDAC_QUIRKS_TAB_LEN	\
-		(sizeof(hdac_quirks_tab) / sizeof(hdac_quirks_tab[0]))
 
 MALLOC_DEFINE(M_HDAC, "hdac", "HDA Controller");
 
 static const struct {
 	uint32_t	model;
-	char		*desc;
+	const char	*desc;
 	char		quirks_on;
 	char		quirks_off;
 } hdac_devices[] = {
+	{ HDA_INTEL_OAK,     "Intel Oaktrail",	0, 0 },
+	{ HDA_INTEL_BAY,     "Intel BayTrail",	0, 0 },
+	{ HDA_INTEL_HSW1,    "Intel Haswell",	0, 0 },
+	{ HDA_INTEL_HSW2,    "Intel Haswell",	0, 0 },
+	{ HDA_INTEL_HSW3,    "Intel Haswell",	0, 0 },
+	{ HDA_INTEL_BDW1,    "Intel Broadwell",	0, 0 },
+	{ HDA_INTEL_BDW2,    "Intel Broadwell",	0, 0 },
 	{ HDA_INTEL_CPT,     "Intel Cougar Point",	0, 0 },
 	{ HDA_INTEL_PATSBURG,"Intel Patsburg",  0, 0 },
 	{ HDA_INTEL_PPT1,    "Intel Panther Point",	0, 0 },
 	{ HDA_INTEL_LPT1,    "Intel Lynx Point",	0, 0 },
 	{ HDA_INTEL_LPT2,    "Intel Lynx Point",	0, 0 },
+	{ HDA_INTEL_WCPT,    "Intel Wildcat Point",	0, 0 },
+	{ HDA_INTEL_WELLS1,  "Intel Wellsburg",	0, 0 },
+	{ HDA_INTEL_WELLS2,  "Intel Wellsburg",	0, 0 },
+	{ HDA_INTEL_LPTLP1,  "Intel Lynx Point-LP",	0, 0 },
+	{ HDA_INTEL_LPTLP2,  "Intel Lynx Point-LP",	0, 0 },
+	{ HDA_INTEL_SRPTLP,  "Intel Sunrise Point-LP",	0, 0 },
+	{ HDA_INTEL_KBLKLP,  "Intel Kabylake-LP",	0, 0 },
+	{ HDA_INTEL_SRPT,    "Intel Sunrise Point",	0, 0 },
+	{ HDA_INTEL_KBLK,    "Intel Kabylake",	0, 0 },
 	{ HDA_INTEL_82801F,  "Intel 82801F",	0, 0 },
 	{ HDA_INTEL_63XXESB, "Intel 631x/632xESB",	0, 0 },
 	{ HDA_INTEL_82801G,  "Intel 82801G",	0, 0 },
@@ -149,6 +164,7 @@
 	{ HDA_ATI_RV940,     "ATI RV940",	0, 0 },
 	{ HDA_ATI_RV970,     "ATI RV970",	0, 0 },
 	{ HDA_ATI_R1000,     "ATI R1000",	0, 0 },
+	{ HDA_AMD_HUDSON2,   "AMD Hudson-2",	0, 0 },
 	{ HDA_RDC_M3010,     "RDC M3010",	0, 0 },
 	{ HDA_VIA_VT82XX,    "VIA VT8251/8237A",0, 0 },
 	{ HDA_SIS_966,       "SiS 966",		0, 0 },
@@ -157,11 +173,11 @@
 	{ HDA_INTEL_ALL,  "Intel",		0, 0 },
 	{ HDA_NVIDIA_ALL, "NVIDIA",		0, 0 },
 	{ HDA_ATI_ALL,    "ATI",		0, 0 },
+	{ HDA_AMD_ALL,    "AMD",		0, 0 },
 	{ HDA_VIA_ALL,    "VIA",		0, 0 },
 	{ HDA_SIS_ALL,    "SiS",		0, 0 },
 	{ HDA_ULI_ALL,    "ULI",		0, 0 },
 };
-#define HDAC_DEVICES_LEN (sizeof(hdac_devices) / sizeof(hdac_devices[0]))
 
 static const struct {
 	uint16_t vendor;
@@ -173,8 +189,6 @@
 	{    ATI_VENDORID, 0x42, 0xf8, 0x02 },
 	{ NVIDIA_VENDORID, 0x4e, 0xf0, 0x0f },
 };
-#define HDAC_PCIESNOOP_LEN	\
-			(sizeof(hdac_pcie_snoop) / sizeof(hdac_pcie_snoop[0]))
 
 /****************************************************************************
  * Function prototypes
@@ -245,7 +259,7 @@
 			inv = 2;
 		else
 			inv = 0;
-		for (k = 0; len > inv && k < HDAC_QUIRKS_TAB_LEN; k++) {
+		for (k = 0; len > inv && k < nitems(hdac_quirks_tab); k++) {
 			if (strncmp(res + i + inv,
 			    hdac_quirks_tab[k].key, len - inv) != 0)
 				continue;
@@ -1015,7 +1029,7 @@
 
 	bzero(desc, sizeof(desc));
 	result = ENXIO;
-	for (i = 0; i < HDAC_DEVICES_LEN; i++) {
+	for (i = 0; i < nitems(hdac_devices); i++) {
 		if (hdac_devices[i].model == model) {
 			strlcpy(desc, hdac_devices[i].desc, sizeof(desc));
 			result = BUS_PROBE_DEFAULT;
@@ -1087,7 +1101,7 @@
 	class = pci_get_class(dev);
 	subclass = pci_get_subclass(dev);
 
-	for (i = 0; i < HDAC_DEVICES_LEN; i++) {
+	for (i = 0; i < nitems(hdac_devices); i++) {
 		if (hdac_devices[i].model == model) {
 			devid = i;
 			break;
@@ -1103,7 +1117,7 @@
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "HDA driver mutex");
 	sc->dev = dev;
 	TASK_INIT(&sc->unsolq_task, 0, hdac_unsolq_task, sc);
-	callout_init(&sc->poll_callout, CALLOUT_MPSAFE);
+	callout_init(&sc->poll_callout, 1);
 	for (i = 0; i < HDAC_CODEC_MAX; i++)
 		sc->codecs[i].dev = NULL;
 	if (devid >= 0) {
@@ -1166,7 +1180,7 @@
 		 *
 		 * http://msdn2.microsoft.com/en-us/library/ms790324.aspx
 		 */
-		for (i = 0; i < HDAC_PCIESNOOP_LEN; i++) {
+		for (i = 0; i < nitems(hdac_pcie_snoop); i++) {
 			if (hdac_pcie_snoop[i].vendor != vendor)
 				continue;
 			sc->flags &= ~HDAC_F_DMA_NOCACHE;
@@ -2069,7 +2083,7 @@
 	DEVMETHOD(hdac_stream_getptr,	hdac_stream_getptr),
 	DEVMETHOD(hdac_unsol_alloc,	hdac_unsol_alloc),
 	DEVMETHOD(hdac_unsol_free,	hdac_unsol_free),
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t hdac_driver = {
@@ -2080,4 +2094,4 @@
 
 static devclass_t hdac_devclass;
 
-DRIVER_MODULE(snd_hda, pci, hdac_driver, hdac_devclass, 0, 0);
+DRIVER_MODULE(snd_hda, pci, hdac_driver, hdac_devclass, NULL, NULL);

Modified: trunk/sys/dev/sound/pci/hda/hdac.h
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdac.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdac.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hda/hdac.h 312367 2017-01-18 02:57:22Z yongari $
  */
 
 #ifndef _HDAC_H_
@@ -41,6 +42,12 @@
 
 /* Intel */
 #define INTEL_VENDORID		0x8086
+#define HDA_INTEL_OAK		HDA_MODEL_CONSTRUCT(INTEL, 0x080a)
+#define HDA_INTEL_BAY		HDA_MODEL_CONSTRUCT(INTEL, 0x0f04)
+#define HDA_INTEL_HSW1		HDA_MODEL_CONSTRUCT(INTEL, 0x0a0c)
+#define HDA_INTEL_HSW2		HDA_MODEL_CONSTRUCT(INTEL, 0x0c0c)
+#define HDA_INTEL_HSW3		HDA_MODEL_CONSTRUCT(INTEL, 0x0d0c)
+#define HDA_INTEL_BDW1		HDA_MODEL_CONSTRUCT(INTEL, 0x160c)
 #define HDA_INTEL_CPT		HDA_MODEL_CONSTRUCT(INTEL, 0x1c20)
 #define HDA_INTEL_PATSBURG	HDA_MODEL_CONSTRUCT(INTEL, 0x1d20)
 #define HDA_INTEL_PPT1		HDA_MODEL_CONSTRUCT(INTEL, 0x1e20)
@@ -53,9 +60,20 @@
 #define HDA_INTEL_82801JD	HDA_MODEL_CONSTRUCT(INTEL, 0x3a6e)
 #define HDA_INTEL_PCH		HDA_MODEL_CONSTRUCT(INTEL, 0x3b56)
 #define HDA_INTEL_PCH2		HDA_MODEL_CONSTRUCT(INTEL, 0x3b57)
+#define HDA_INTEL_MACBOOKPRO92	HDA_MODEL_CONSTRUCT(INTEL, 0x7270)
 #define HDA_INTEL_SCH		HDA_MODEL_CONSTRUCT(INTEL, 0x811b)
 #define HDA_INTEL_LPT1		HDA_MODEL_CONSTRUCT(INTEL, 0x8c20)
 #define HDA_INTEL_LPT2		HDA_MODEL_CONSTRUCT(INTEL, 0x8c21)
+#define HDA_INTEL_WCPT		HDA_MODEL_CONSTRUCT(INTEL, 0x8ca0)
+#define HDA_INTEL_WELLS1	HDA_MODEL_CONSTRUCT(INTEL, 0x8d20)
+#define HDA_INTEL_WELLS2	HDA_MODEL_CONSTRUCT(INTEL, 0x8d21)
+#define HDA_INTEL_LPTLP1	HDA_MODEL_CONSTRUCT(INTEL, 0x9c20)
+#define HDA_INTEL_LPTLP2	HDA_MODEL_CONSTRUCT(INTEL, 0x9c21)
+#define HDA_INTEL_BDW2		HDA_MODEL_CONSTRUCT(INTEL, 0x9ca0)
+#define HDA_INTEL_SRPTLP	HDA_MODEL_CONSTRUCT(INTEL, 0x9d70)
+#define HDA_INTEL_KBLKLP	HDA_MODEL_CONSTRUCT(INTEL, 0x9d71)
+#define HDA_INTEL_SRPT		HDA_MODEL_CONSTRUCT(INTEL, 0xa170)
+#define HDA_INTEL_KBLK		HDA_MODEL_CONSTRUCT(INTEL, 0xa171)
 #define HDA_INTEL_ALL		HDA_MODEL_CONSTRUCT(INTEL, 0xffff)
 
 /* Nvidia */
@@ -123,6 +141,10 @@
 #define HDA_ATI_R1000		HDA_MODEL_CONSTRUCT(ATI, 0xaaa0)
 #define HDA_ATI_ALL		HDA_MODEL_CONSTRUCT(ATI, 0xffff)
 
+#define AMD_VENDORID		0x1022
+#define HDA_AMD_HUDSON2		HDA_MODEL_CONSTRUCT(AMD, 0x780d)
+#define HDA_AMD_ALL		HDA_MODEL_CONSTRUCT(AMD, 0xffff)
+
 /* RDC */
 #define RDC_VENDORID		0x17f3
 #define HDA_RDC_M3010		HDA_MODEL_CONSTRUCT(RDC, 0x3010)
@@ -145,6 +167,7 @@
 /* OEM/subvendors */
 
 /* Intel */
+#define	INTEL_DH87RL_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0x204a)
 #define INTEL_D101GGC_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xd600)
 
 /* HP/Compaq */
@@ -198,6 +221,7 @@
 #define ASUS_F3JC_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1338)
 #define ASUS_G2K_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1339)
 #define ASUS_A7T_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x13c2)
+#define ASUS_UX31A_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1517)
 #define ASUS_W2J_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1971)
 #define ASUS_M5200_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1993)
 #define ASUS_P5PL2_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x817f)
@@ -220,8 +244,17 @@
 #define LENOVO_3KN200_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x384e)
 #define LENOVO_B450_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0x3a0d)
 #define LENOVO_TCA55_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x1015)
+#define	LENOVO_X1_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21e8)
+#define	LENOVO_X1CRBN_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21f9)
+#define	LENOVO_X120BS_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2227)
 #define LENOVO_X220_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21da)
 #define LENOVO_X300_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x20ac)
+#define	LENOVO_T420_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21ce)
+#define	LENOVO_T430_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21f3)
+#define	LENOVO_T430S_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21fb)
+#define	LENOVO_T520_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21cf)
+#define	LENOVO_T530_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21f6)
+#define	LENOVO_G580_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x3977)
 #define LENOVO_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0xffff)
 
 /* Samsung */
@@ -249,7 +282,9 @@
  * (see HDA_CODEC_STAC9221 below).
  */
 #define APPLE_INTEL_MAC		0x76808384
+#define APPLE_MACBOOKAIR31	0x0d9410de
 #define APPLE_MACBOOKPRO55	0xcb7910de
+#define APPLE_MACBOOKPRO71	0xcb8910de
 
 /* LG Electronics */
 #define LG_VENDORID		0x1854
@@ -314,6 +349,8 @@
 #define HDA_CODEC_ALC273	HDA_CODEC_CONSTRUCT(REALTEK, 0x0273)
 #define HDA_CODEC_ALC275	HDA_CODEC_CONSTRUCT(REALTEK, 0x0275)
 #define HDA_CODEC_ALC276	HDA_CODEC_CONSTRUCT(REALTEK, 0x0276)
+#define HDA_CODEC_ALC292	HDA_CODEC_CONSTRUCT(REALTEK, 0x0292)
+#define HDA_CODEC_ALC295	HDA_CODEC_CONSTRUCT(REALTEK, 0x0295)
 #define HDA_CODEC_ALC660	HDA_CODEC_CONSTRUCT(REALTEK, 0x0660)
 #define HDA_CODEC_ALC662	HDA_CODEC_CONSTRUCT(REALTEK, 0x0662)
 #define HDA_CODEC_ALC663	HDA_CODEC_CONSTRUCT(REALTEK, 0x0663)
@@ -331,6 +368,7 @@
 #define HDA_CODEC_ALC889	HDA_CODEC_CONSTRUCT(REALTEK, 0x0889)
 #define HDA_CODEC_ALC892	HDA_CODEC_CONSTRUCT(REALTEK, 0x0892)
 #define HDA_CODEC_ALC899	HDA_CODEC_CONSTRUCT(REALTEK, 0x0899)
+#define HDA_CODEC_ALC1150	HDA_CODEC_CONSTRUCT(REALTEK, 0x0900)
 #define HDA_CODEC_ALCXXXX	HDA_CODEC_CONSTRUCT(REALTEK, 0xffff)
 
 /* Motorola */
@@ -597,6 +635,10 @@
 #define HDA_CODEC_INTELIP2	HDA_CODEC_CONSTRUCT(INTEL, 0x2804)
 #define HDA_CODEC_INTELCPT	HDA_CODEC_CONSTRUCT(INTEL, 0x2805)
 #define HDA_CODEC_INTELPPT	HDA_CODEC_CONSTRUCT(INTEL, 0x2806)
+#define HDA_CODEC_INTELHSW	HDA_CODEC_CONSTRUCT(INTEL, 0x2807)
+#define HDA_CODEC_INTELBDW	HDA_CODEC_CONSTRUCT(INTEL, 0x2808)
+#define HDA_CODEC_INTELSKLK	HDA_CODEC_CONSTRUCT(INTEL, 0x2809)
+#define HDA_CODEC_INTELKBLK	HDA_CODEC_CONSTRUCT(INTEL, 0x280b)
 #define HDA_CODEC_INTELCL	HDA_CODEC_CONSTRUCT(INTEL, 0x29fb)
 #define HDA_CODEC_INTELXXXX	HDA_CODEC_CONSTRUCT(INTEL, 0xffff)
 

Modified: trunk/sys/dev/sound/pci/hda/hdac_if.m
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdac_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdac_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 # Copyright (c) 2012 Alexander Motin <mav at FreeBSD.org>
 # All rights reserved.
 #
@@ -22,7 +23,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/pci/hda/hdac_if.m 230326 2012-01-19 01:55:48Z mav $
 
 #include <sys/rman.h>
 


Property changes on: trunk/sys/dev/sound/pci/hda/hdac_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pci/hda/hdac_private.h
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdac_private.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdac_private.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2008-2012 Alexander Motin <mav at FreeBSD.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hda/hdac_private.h 230326 2012-01-19 01:55:48Z mav $
  */
 
 #ifndef _HDAC_PRIVATE_H_

Modified: trunk/sys/dev/sound/pci/hda/hdac_reg.h
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdac_reg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdac_reg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hda/hdac_reg.h 230130 2012-01-15 13:21:36Z mav $
  */
 
 #ifndef _HDAC_REG_H_

Modified: trunk/sys/dev/sound/pci/hda/hdacc.c
===================================================================
--- trunk/sys/dev/sound/pci/hda/hdacc.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hda/hdacc.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Stephane E. Potvin <sepotvin at videotron.ca>
  * Copyright (c) 2006 Ariff Abdullah <ariff at FreeBSD.org>
@@ -41,7 +42,7 @@
 #include <dev/sound/pci/hda/hda_reg.h>
 #include <dev/sound/pci/hda/hdac.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hda/hdacc.c 312367 2017-01-18 02:57:22Z yongari $");
 
 struct hdacc_fg {
 	device_t	dev;
@@ -71,7 +72,7 @@
 static const struct {
 	uint32_t id;
 	uint16_t revid;
-	char *name;
+	const char *name;
 } hdacc_codecs[] = {
 	{ HDA_CODEC_CS4206, 0,		"Cirrus Logic CS4206" },
 	{ HDA_CODEC_CS4207, 0,		"Cirrus Logic CS4207" },
@@ -87,6 +88,8 @@
 	{ HDA_CODEC_ALC273, 0,		"Realtek ALC273" },
 	{ HDA_CODEC_ALC275, 0,		"Realtek ALC275" },
 	{ HDA_CODEC_ALC276, 0,		"Realtek ALC276" },
+	{ HDA_CODEC_ALC292, 0,		"Realtek ALC292" },
+	{ HDA_CODEC_ALC295, 0,		"Realtek ALC295" },
 	{ HDA_CODEC_ALC660, 0,		"Realtek ALC660-VD" },
 	{ HDA_CODEC_ALC662, 0x0002,	"Realtek ALC662 rev2" },
 	{ HDA_CODEC_ALC662, 0,		"Realtek ALC662" },
@@ -109,6 +112,7 @@
 	{ HDA_CODEC_ALC889, 0,		"Realtek ALC889" },
 	{ HDA_CODEC_ALC892, 0,		"Realtek ALC892" },
 	{ HDA_CODEC_ALC899, 0,		"Realtek ALC899" },
+	{ HDA_CODEC_ALC1150, 0,		"Realtek ALC1150" },
 	{ HDA_CODEC_AD1882, 0,		"Analog Devices AD1882" },
 	{ HDA_CODEC_AD1882A, 0,		"Analog Devices AD1882A" },
 	{ HDA_CODEC_AD1883, 0,		"Analog Devices AD1883" },
@@ -318,6 +322,10 @@
 	{ HDA_CODEC_INTELIP2, 0,	"Intel Ibex Peak" },
 	{ HDA_CODEC_INTELCPT, 0,	"Intel Cougar Point" },
 	{ HDA_CODEC_INTELPPT, 0,	"Intel Panther Point" },
+	{ HDA_CODEC_INTELHSW, 0,	"Intel Haswell" },
+	{ HDA_CODEC_INTELBDW, 0,	"Intel Broadwell" },
+	{ HDA_CODEC_INTELSKLK, 0,	"Intel Skylake" },
+	{ HDA_CODEC_INTELKBLK, 0,	"Intel Kabylake" },
 	{ HDA_CODEC_INTELCL, 0,		"Intel Crestline" },
 	{ HDA_CODEC_SII1390, 0,		"Silicon Image SiI1390" },
 	{ HDA_CODEC_SII1392, 0,		"Silicon Image SiI1392" },
@@ -340,7 +348,6 @@
 	{ HDA_CODEC_STACXXXX, 0,	"Sigmatel" },
 	{ HDA_CODEC_VTXXXX, 0,		"VIA" },
 };
-#define HDACC_CODECS_LEN	(sizeof(hdacc_codecs) / sizeof(hdacc_codecs[0]))
 
 static int
 hdacc_suspend(device_t dev)
@@ -380,7 +387,7 @@
 	id = ((uint32_t)hda_get_vendor_id(dev) << 16) + hda_get_device_id(dev);
 	revid = ((uint32_t)hda_get_revision_id(dev) << 8) + hda_get_stepping_id(dev);
 
-	for (i = 0; i < HDACC_CODECS_LEN; i++) {
+	for (i = 0; i < nitems(hdacc_codecs); i++) {
 		if (!HDA_DEV_MATCH(hdacc_codecs[i].id, id))
 			continue;
 		if (hdacc_codecs[i].revid != 0 &&
@@ -388,7 +395,7 @@
 			continue;
 		break;
 	}
-	if (i < HDACC_CODECS_LEN) {
+	if (i < nitems(hdacc_codecs)) {
 		if ((hdacc_codecs[i].id & 0xffff) != 0xffff)
 			strlcpy(buf, hdacc_codecs[i].name, sizeof(buf));
 		else
@@ -460,8 +467,12 @@
 static int
 hdacc_detach(device_t dev)
 {
+	struct hdacc_softc *codec = device_get_softc(dev);
+	int error;
 
-	return (device_delete_children(dev));
+	error = device_delete_children(dev);
+	free(codec->fgs, M_HDACC);
+	return (error);
 }
 
 static int
@@ -708,7 +719,7 @@
 	DEVMETHOD(hdac_unsol_free,	hdacc_unsol_free),
 	DEVMETHOD(hdac_unsol_intr,	hdacc_unsol_intr),
 	DEVMETHOD(hdac_pindump,		hdacc_pindump),
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
 static driver_t hdacc_driver = {
@@ -719,4 +730,4 @@
 
 static devclass_t hdacc_devclass;
 
-DRIVER_MODULE(snd_hda, hdac, hdacc_driver, hdacc_devclass, 0, 0);
+DRIVER_MODULE(snd_hda, hdac, hdacc_driver, hdacc_devclass, NULL, NULL);

Modified: trunk/sys/dev/sound/pci/hdspe-pcm.c
===================================================================
--- trunk/sys/dev/sound/pci/hdspe-pcm.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hdspe-pcm.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Ruslan Bukin <br at bsdpad.com>
  * All rights reserved.
@@ -38,7 +39,7 @@
 
 #include <mixer_if.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hdspe-pcm.c 241066 2012-09-30 09:21:10Z kevlo $");
 
 struct hdspe_latency {
 	uint32_t n;
@@ -207,6 +208,7 @@
 		}
 	}
 
+	free(devlist, M_TEMP);
 	return 0;
 bad:
 
@@ -214,6 +216,7 @@
 	device_printf(sc->dev,"hdspe is running\n");
 #endif
 
+	free(devlist, M_TEMP);
 	return 1;
 }
 

Modified: trunk/sys/dev/sound/pci/hdspe.c
===================================================================
--- trunk/sys/dev/sound/pci/hdspe.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hdspe.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Ruslan Bukin <br at bsdpad.com>
  * All rights reserved.
@@ -38,7 +39,7 @@
 
 #include <mixer_if.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/hdspe.c 254263 2013-08-12 23:30:01Z scottl $");
 
 static struct hdspe_channel chan_map_aio[] = {
 	{  0,  1,   "line", 1, 1 },
@@ -107,6 +108,7 @@
 		}
 
 		hdspe_write_1(sc, HDSPE_INTERRUPT_ACK, 0);
+		free(devlist, M_TEMP);
 	}
 
 	snd_mtxunlock(sc->lock);
@@ -242,20 +244,6 @@
 }
 
 static int
-set_pci_config(device_t dev)
-{
-	uint32_t data;
-
-	pci_enable_busmaster(dev);
-
-	data = pci_get_revid(dev);
-	data |= PCIM_CMD_PORTEN;
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-
-	return 0;
-}
-
-static int
 hdspe_init(struct sc_info *sc)
 {
 	long long period;
@@ -306,13 +294,12 @@
 	device_printf(dev, "hdspe_attach()\n");
 #endif
 
-	set_pci_config(dev);
-
 	sc = device_get_softc(dev);
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev),
 	    "snd_hdspe softc");
 	sc->dev = dev;
 
+	pci_enable_busmaster(dev);
 	rev = pci_get_revid(dev);
 	switch (rev) {
 	case PCI_REVISION_AIO:

Modified: trunk/sys/dev/sound/pci/hdspe.h
===================================================================
--- trunk/sys/dev/sound/pci/hdspe.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/hdspe.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Ruslan Bukin <br at bsdpad.com>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/hdspe.h 232337 2012-03-01 13:10:18Z mav $
  */
 
 #define PCI_VENDOR_XILINX		0x10ee

Modified: trunk/sys/dev/sound/pci/ich.c
===================================================================
--- trunk/sys/dev/sound/pci/ich.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/ich.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
  * Copyright (c) 2001 Cameron Grant <cg at freebsd.org>
@@ -36,7 +37,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/ich.c 216518 2010-12-18 14:21:28Z tijl $");
 
 /* -------------------------------------------------------------------- */
 

Modified: trunk/sys/dev/sound/pci/ich.h
===================================================================
--- trunk/sys/dev/sound/pci/ich.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/ich.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
  * Copyright (c) 2001 Cameron Grant <cg at freebsd.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/ich.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #define PCIR_NAMBAR 0x10

Modified: trunk/sys/dev/sound/pci/maestro.c
===================================================================
--- trunk/sys/dev/sound/pci/maestro.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/maestro.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000-2004 Taku YAMAMOTO <taku at tackymt.homeip.net>
  * All rights reserved.
@@ -58,7 +59,7 @@
 
 #include <dev/sound/pci/maestro_reg.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/maestro.c 260298 2014-01-04 23:12:01Z dim $");
 
 /*
  * PCI IDs of supported chips:
@@ -207,9 +208,11 @@
 
 static void	agg_sleep(struct agg_info*, const char *wmesg, int msec);
 
+#if 0
 static __inline u_int32_t	agg_rd(struct agg_info*, int, int size);
 static __inline void		agg_wr(struct agg_info*, int, u_int32_t data,
 								int size);
+#endif
 static int	agg_rdcodec(struct agg_info*, int);
 static int	agg_wrcodec(struct agg_info*, int, u_int32_t);
 
@@ -286,6 +289,7 @@
 
 /* I/O port */
 
+#if 0
 static __inline u_int32_t
 agg_rd(struct agg_info *sc, int regno, int size)
 {
@@ -300,6 +304,7 @@
 		return ~(u_int32_t)0;
 	}
 }
+#endif
 
 #define AGG_RD(sc, regno, size)           \
 	bus_space_read_##size(            \
@@ -306,6 +311,7 @@
 	    ((struct agg_info*)(sc))->st, \
 	    ((struct agg_info*)(sc))->sh, (regno))
 
+#if 0
 static __inline void
 agg_wr(struct agg_info *sc, int regno, u_int32_t data, int size)
 {
@@ -321,6 +327,7 @@
 		break;
 	}
 }
+#endif
 
 #define AGG_WR(sc, regno, data, size)     \
 	bus_space_write_##size(           \
@@ -1844,15 +1851,10 @@
 	ess->curpwr = PCI_POWERSTATE_D3;
 	pci_set_powerstate(dev, PCI_POWERSTATE_D0);
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	/* Allocate resources. */
-	if (data & PCIM_CMD_PORTEN)
-		reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &regid,
-		    RF_ACTIVE);
+	reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &regid, RF_ACTIVE);
 	if (reg != NULL) {
 		ess->reg = reg;
 		ess->regid = regid;

Modified: trunk/sys/dev/sound/pci/maestro3.c
===================================================================
--- trunk/sys/dev/sound/pci/maestro3.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/maestro3.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Scott Long <scottl at freebsd.org>
  * Copyright (c) 2001 Darrell Anderson <anderson at cs.duke.edu>
@@ -67,7 +68,7 @@
 #include <dev/sound/pci/allegro_reg.h>
 #include <dev/sound/pci/allegro_code.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/maestro3.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* -------------------------------------------------------------------- */
 
@@ -1317,7 +1318,6 @@
 {
 	struct sc_info *sc;
 	struct ac97_info *codec = NULL;
-	u_int32_t data;
 	char status[SND_STATUSLEN];
 	struct m3_card_type *card;
 	int i, len, dacn, adcn;
@@ -1351,9 +1351,7 @@
 
 	adcn = M3_RCHANS;
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
+	pci_enable_busmaster(dev);
 
 	sc->regid = PCIR_BAR(0);
 	sc->regtype = SYS_RES_MEMORY;

Modified: trunk/sys/dev/sound/pci/maestro_reg.h
===================================================================
--- trunk/sys/dev/sound/pci/maestro_reg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/maestro_reg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999-2000 Taku YAMAMOTO <taku at cent.saitama-u.ac.jp>
  * All rights reserved.
@@ -24,7 +25,7 @@
  * SUCH DAMAGE.
  *
  *	maestro_reg.h,v 1.13 2001/11/11 18:29:46 taku Exp
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/maestro_reg.h 137500 2004-11-10 04:29:09Z julian $
  */
 
 #ifndef	MAESTRO_REG_H_INCLUDED

Modified: trunk/sys/dev/sound/pci/neomagic-coeff.h
===================================================================
--- trunk/sys/dev/sound/pci/neomagic-coeff.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/neomagic-coeff.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/neomagic-coeff.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #define NM_TOTAL_COEFF_COUNT 0x3158

Modified: trunk/sys/dev/sound/pci/neomagic.c
===================================================================
--- trunk/sys/dev/sound/pci/neomagic.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/neomagic.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -38,7 +39,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/neomagic.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* -------------------------------------------------------------------- */
 
@@ -599,7 +600,7 @@
 {
 	struct sc_info *sc = NULL;
 	char *s = NULL;
-	u_int32_t subdev, i, data;
+	u_int32_t subdev, i;
 
 	subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
 	switch (pci_get_devid(dev)) {
@@ -616,11 +617,6 @@
 				return ENXIO;
 			}
 
-			data = pci_read_config(dev, PCIR_COMMAND, 2);
-			pci_write_config(dev, PCIR_COMMAND, data |
-					 PCIM_CMD_PORTEN | PCIM_CMD_MEMEN |
-					 PCIM_CMD_BUSMASTEREN, 2);
-
 			sc->regid = PCIR_BAR(1);
 			sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
 							 &sc->regid,
@@ -628,7 +624,6 @@
 
 			if (!sc->reg) {
 				device_printf(dev, "unable to map register space\n");
-				pci_write_config(dev, PCIR_COMMAND, data, 2);
 				free(sc, M_DEVBUF);
 				return ENXIO;
 			}
@@ -645,7 +640,6 @@
 				DEB(device_printf(dev, "subdev = 0x%x - badcard?\n",
 				    subdev));
 			}
-			pci_write_config(dev, PCIR_COMMAND, data, 2);
 			bus_release_resource(dev, SYS_RES_MEMORY, sc->regid,
 					     sc->reg);
 			free(sc, M_DEVBUF);
@@ -670,7 +664,6 @@
 static int
 nm_pci_attach(device_t dev)
 {
-	u_int32_t	data;
 	struct sc_info *sc;
 	struct ac97_info *codec = 0;
 	char 		status[SND_STATUSLEN];
@@ -679,10 +672,7 @@
 	sc->dev = dev;
 	sc->type = pci_get_devid(dev);
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	sc->bufid = PCIR_BAR(0);
 	sc->buf = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->bufid,

Modified: trunk/sys/dev/sound/pci/neomagic.h
===================================================================
--- trunk/sys/dev/sound/pci/neomagic.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/neomagic.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/neomagic.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #ifndef _NM256_H_

Modified: trunk/sys/dev/sound/pci/solo.c
===================================================================
--- trunk/sys/dev/sound/pci/solo.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/solo.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  *
@@ -37,7 +38,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/solo.c 254263 2013-08-12 23:30:01Z scottl $");
 
 #define SOLO_DEFAULT_BUFSZ 16384
 #define ABS(x) (((x) < 0)? -(x) : (x))
@@ -949,15 +950,9 @@
 ess_resume(device_t dev)
 {
 	uint16_t ddma;
-	uint32_t data;
 	struct ess_info *sc = pcm_getdevinfo(dev);
 	
 	ess_lock(sc);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-
 	ddma = rman_get_start(sc->vc) | 1;
 	pci_write_config(dev, ESS_PCI_LEGACYCONTROL, 0x805f, 2);
 	pci_write_config(dev, ESS_PCI_DDMACONTROL, ddma, 2);
@@ -988,13 +983,9 @@
     	struct ess_info *sc;
     	char status[SND_STATUSLEN];
 	u_int16_t ddma;
-	u_int32_t data;
 
 	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
     	if (ess_alloc_resources(sc, dev))
 		goto no;

Modified: trunk/sys/dev/sound/pci/spicds.c
===================================================================
--- trunk/sys/dev/sound/pci/spicds.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/spicds.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov at gmail.com>
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/spicds.c 227293 2011-11-07 06:44:47Z ed $
  */
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS

Modified: trunk/sys/dev/sound/pci/spicds.h
===================================================================
--- trunk/sys/dev/sound/pci/spicds.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/spicds.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov at gmail.com>
  * Copyright (c) 2001 Katsurajima Naoto <raven at katsurajima.seya.yokohama.jp>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/spicds.h 205859 2010-03-29 20:27:17Z joel $
  */
 
 /* supported CODECs */

Modified: trunk/sys/dev/sound/pci/t4dwave.c
===================================================================
--- trunk/sys/dev/sound/pci/t4dwave.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/t4dwave.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -35,7 +36,7 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/t4dwave.c 254263 2013-08-12 23:30:01Z scottl $");
 
 /* -------------------------------------------------------------------- */
 
@@ -822,7 +823,6 @@
 static int
 tr_pci_attach(device_t dev)
 {
-	u_int32_t	data;
 	struct tr_info *tr;
 	struct ac97_info *codec = 0;
 	bus_addr_t	lowaddr;
@@ -831,6 +831,7 @@
 #ifdef __sparc64__
 	device_t	*children;
 	int		nchildren;
+	u_int32_t	data;
 #endif
 
 	tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -857,10 +858,7 @@
 		}
 	}
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	tr->regid = PCIR_BAR(0);
 	tr->regtype = SYS_RES_IOPORT;

Modified: trunk/sys/dev/sound/pci/t4dwave.h
===================================================================
--- trunk/sys/dev/sound/pci/t4dwave.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/t4dwave.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/t4dwave.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #ifndef _T4DWAVE_REG_H

Modified: trunk/sys/dev/sound/pci/via8233.c
===================================================================
--- trunk/sys/dev/sound/pci/via8233.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/via8233.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Orion Hodson <orion at freebsd.org>
  * Portions of this code derived from via82c686.c:
@@ -48,7 +49,7 @@
 
 #include <dev/sound/pci/via8233.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/via8233.c 314667 2017-03-04 13:03:31Z avg $");
 
 #define VIA8233_PCI_ID 0x30591106
 
@@ -1175,7 +1176,7 @@
 	    "snd_via8233 softc");
 	via->dev = dev;
 
-	callout_init(&via->poll_timer, CALLOUT_MPSAFE);
+	callout_init(&via->poll_timer, 1);
 	via->poll_ticks = 1;
 
 	if (resource_int_value(device_get_name(dev),

Modified: trunk/sys/dev/sound/pci/via8233.h
===================================================================
--- trunk/sys/dev/sound/pci/via8233.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/via8233.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Orion Hodson <orion at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/via8233.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 #ifndef _SYS_SOUND_PCI_VIA8233_H_

Modified: trunk/sys/dev/sound/pci/via82c686.c
===================================================================
--- trunk/sys/dev/sound/pci/via82c686.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/via82c686.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 David Jones <dej at ox.org>
  * All rights reserved.
@@ -37,7 +38,7 @@
 
 #include <dev/sound/pci/via82c686.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/via82c686.c 254263 2013-08-12 23:30:01Z scottl $");
 
 #define VIA_PCI_ID 0x30581106
 #define	NSEGS		4	/* Number of segments in SGD table */
@@ -485,11 +486,7 @@
 	via->lock = snd_mtxcreate(device_get_nameunit(dev),
 	    "snd_via82c686 softc");
 
-	/* Get resources */
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 	/* Wake up and reset AC97 if necessary */
 	data = pci_read_config(dev, VIA_AC97STATUS, 1);

Modified: trunk/sys/dev/sound/pci/via82c686.h
===================================================================
--- trunk/sys/dev/sound/pci/via82c686.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/via82c686.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -26,7 +27,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/via82c686.h 192457 2009-05-20 18:31:11Z joel $
  */
 
 #ifndef _VIA_H

Modified: trunk/sys/dev/sound/pci/vibes.c
===================================================================
--- trunk/sys/dev/sound/pci/vibes.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/vibes.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -42,7 +43,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pci/vibes.c 312398 2017-01-18 23:23:46Z marius $");
 
 /* ------------------------------------------------------------------------- */
 /* Constants */
@@ -728,10 +729,7 @@
 	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
 	sc->dev = dev;
 
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
-	data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
-	pci_write_config(dev, PCIR_COMMAND, data, 2);
-	data = pci_read_config(dev, PCIR_COMMAND, 2);
+	pci_enable_busmaster(dev);
 
 #if __FreeBSD_version > 500000
         if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
@@ -742,9 +740,8 @@
 #endif
 	sc->enh_rid  = SV_PCI_ENHANCED;
 	sc->enh_type = SYS_RES_IOPORT;
-	sc->enh_reg  = bus_alloc_resource(dev, sc->enh_type,
-					  &sc->enh_rid, 0, ~0,
-					  SV_PCI_ENHANCED_SIZE, RF_ACTIVE);
+	sc->enh_reg  = bus_alloc_resource_any(dev, sc->enh_type,
+					      &sc->enh_rid, RF_ACTIVE);
 	if (sc->enh_reg == NULL) {
 		device_printf(dev, "sv_attach: cannot allocate enh\n");
 		return ENXIO;
@@ -835,9 +832,8 @@
 	/* Cache resource short-cuts for dma_a */
 	sc->dmaa_rid = SV_PCI_DMAA;
 	sc->dmaa_type = SYS_RES_IOPORT;
-	sc->dmaa_reg  = bus_alloc_resource(dev, sc->dmaa_type,
-					   &sc->dmaa_rid, 0, ~0,
-					   SV_PCI_ENHANCED_SIZE, RF_ACTIVE);
+	sc->dmaa_reg  = bus_alloc_resource_any(dev, sc->dmaa_type,
+					       &sc->dmaa_rid, RF_ACTIVE);
 	if (sc->dmaa_reg == NULL) {
 		device_printf(dev, "sv_attach: cannot allocate dmaa\n");
 		goto fail;
@@ -854,9 +850,8 @@
 	/* Cache resource short-cuts for dma_c */
 	sc->dmac_rid = SV_PCI_DMAC;
 	sc->dmac_type = SYS_RES_IOPORT;
-	sc->dmac_reg  = bus_alloc_resource(dev, sc->dmac_type,
-					   &sc->dmac_rid, 0, ~0,
-					   SV_PCI_ENHANCED_SIZE, RF_ACTIVE);
+	sc->dmac_reg  = bus_alloc_resource_any(dev, sc->dmac_type,
+					       &sc->dmac_rid, RF_ACTIVE);
 	if (sc->dmac_reg == NULL) {
 		device_printf(dev, "sv_attach: cannot allocate dmac\n");
 		goto fail;

Modified: trunk/sys/dev/sound/pci/vibes.h
===================================================================
--- trunk/sys/dev/sound/pci/vibes.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pci/vibes.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Orion Hodson <O.Hodson at cs.ucl.ac.uk>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pci/vibes.h 139749 2005-01-06 01:43:34Z imp $
  */
 
 /* ------------------------------------------------------------------------- */

Modified: trunk/sys/dev/sound/pcm/ac97.c
===================================================================
--- trunk/sys/dev/sound/pcm/ac97.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/ac97.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -36,7 +37,7 @@
 
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/ac97.c 227293 2011-11-07 06:44:47Z ed $");
 
 static MALLOC_DEFINE(M_AC97, "ac97", "ac97 codec");
 

Modified: trunk/sys/dev/sound/pcm/ac97.h
===================================================================
--- trunk/sys/dev/sound/pcm/ac97.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/ac97.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/ac97.h 168861 2007-04-19 13:54:22Z ariff $
  */
 
 #define AC97_MUTE	0x8080

Modified: trunk/sys/dev/sound/pcm/ac97_if.m
===================================================================
--- trunk/sys/dev/sound/pcm/ac97_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/ac97_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # KOBJ
 #
@@ -25,7 +26,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/pcm/ac97_if.m 139749 2005-01-06 01:43:34Z imp $
 #
 
 #include <dev/sound/pcm/sound.h>


Property changes on: trunk/sys/dev/sound/pcm/ac97_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pcm/ac97_patch.c
===================================================================
--- trunk/sys/dev/sound/pcm/ac97_patch.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/ac97_patch.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Orion Hodson
  * All rights reserved.
@@ -32,7 +33,7 @@
 #include <dev/sound/pcm/ac97.h>
 #include <dev/sound/pcm/ac97_patch.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/ac97_patch.c 193640 2009-06-07 19:12:08Z ariff $");
 
 void ad1886_patch(struct ac97_info* codec)
 {

Modified: trunk/sys/dev/sound/pcm/ac97_patch.h
===================================================================
--- trunk/sys/dev/sound/pcm/ac97_patch.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/ac97_patch.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003 Orion Hodson
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/ac97_patch.h 168861 2007-04-19 13:54:22Z ariff $
  */
 
 typedef void (*ac97_patch)(struct ac97_info*);

Modified: trunk/sys/dev/sound/pcm/buffer.c
===================================================================
--- trunk/sys/dev/sound/pcm/buffer.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/buffer.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -35,9 +36,10 @@
 #include "feeder_if.h"
 
 #define SND_USE_FXDIV
+#define	SND_DECLARE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/buffer.c 319066 2017-05-28 10:44:43Z hselasky $");
 
 struct snd_dbuf *
 sndbuf_create(device_t dev, char *drv, char *desc, struct pcm_channel *channel)
@@ -70,7 +72,7 @@
 {
 	struct snd_dbuf *b = (struct snd_dbuf *)arg;
 
-	if (bootverbose) {
+	if (snd_verbose > 3) {
 		device_printf(b->dev, "sndbuf_setmap %lx, %lx; ",
 		    (u_long)segs[0].ds_addr, (u_long)segs[0].ds_len);
 		printf("%p -> %lx\n", b->buf, (u_long)segs[0].ds_addr);

Modified: trunk/sys/dev/sound/pcm/buffer.h
===================================================================
--- trunk/sys/dev/sound/pcm/buffer.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/buffer.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Cameron Grant <cg at freebsd.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/buffer.h 230845 2012-01-31 21:46:28Z mav $
  */
 
 #define SND_DMA(b) (sndbuf_getflags((b)) & SNDBUF_F_DMA)

Modified: trunk/sys/dev/sound/pcm/channel.c
===================================================================
--- trunk/sys/dev/sound/pcm/channel.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/channel.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -38,7 +39,7 @@
 
 #include "feeder_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/channel.c 283950 2015-06-03 15:32:43Z hselasky $");
 
 int report_soft_formats = 1;
 SYSCTL_INT(_hw_snd, OID_AUTO, report_soft_formats, CTLFLAG_RW,
@@ -1029,31 +1030,18 @@
 	{    NULL,  NULL, NULL, 0           }
 };
 
-static const struct {
-	char *name, *alias1, *alias2;
-	int matrix_id;
-} matrix_id_tab[] = {
-	{ "1.0",  "1",   "mono", SND_CHN_MATRIX_1_0     },
-	{ "2.0",  "2", "stereo", SND_CHN_MATRIX_2_0     },
-	{ "2.1", NULL,     NULL, SND_CHN_MATRIX_2_1     },
-	{ "3.0",  "3",     NULL, SND_CHN_MATRIX_3_0     },
-	{ "4.0",  "4",   "quad", SND_CHN_MATRIX_4_0     },
-	{ "4.1", NULL,     NULL, SND_CHN_MATRIX_4_1     },
-	{ "5.0",  "5",     NULL, SND_CHN_MATRIX_5_0     },
-	{ "5.1",  "6",     NULL, SND_CHN_MATRIX_5_1     },
-	{ "6.0", NULL,     NULL, SND_CHN_MATRIX_6_0     },
-	{ "6.1",  "7",     NULL, SND_CHN_MATRIX_6_1     },
-	{ "7.1",  "8",     NULL, SND_CHN_MATRIX_7_1     },
-	{  NULL, NULL,     NULL, SND_CHN_MATRIX_UNKNOWN }
-};
-
 uint32_t
 snd_str2afmt(const char *req)
 {
-	uint32_t i, afmt;
-	int matrix_id;
-	char b1[8], b2[8];
+	int ext;
+	int ch;
+	int i;
+	char b1[8];
+	char b2[8];
 
+	memset(b1, 0, sizeof(b1));
+	memset(b2, 0, sizeof(b2));
+
 	i = sscanf(req, "%5[^:]:%6s", b1, b2);
 
 	if (i == 1) {
@@ -1066,88 +1054,78 @@
 	} else
 		return (0);
 
-	afmt = 0;
-	matrix_id = SND_CHN_MATRIX_UNKNOWN;
+	i = sscanf(b2, "%d.%d", &ch, &ext);
 
-	for (i = 0; afmt == 0 && afmt_tab[i].name != NULL; i++) {
-		if (strcasecmp(afmt_tab[i].name, b1) == 0 ||
-		    (afmt_tab[i].alias1 != NULL &&
-		    strcasecmp(afmt_tab[i].alias1, b1) == 0) ||
-		    (afmt_tab[i].alias2 != NULL &&
-		    strcasecmp(afmt_tab[i].alias2, b1) == 0)) {
-			afmt = afmt_tab[i].afmt;
-			strlcpy(b1, afmt_tab[i].name, sizeof(b1));
-		}
-	}
-
-	if (afmt == 0)
+	if (i == 0) {
+		if (strcasecmp(b2, "mono") == 0) {
+			ch = 1;
+			ext = 0;
+		} else if (strcasecmp(b2, "stereo") == 0) {
+			ch = 2;
+			ext = 0;
+		} else if (strcasecmp(b2, "quad") == 0) {
+			ch = 4;
+			ext = 0;
+		} else
+			return (0);
+	} else if (i == 1) {
+		if (ch < 1 || ch > AFMT_CHANNEL_MAX)
+			return (0);
+		ext = 0;
+	} else if (i == 2) {
+		if (ext < 0 || ext > AFMT_EXTCHANNEL_MAX)
+			return (0);
+		if (ch < 1 || (ch + ext) > AFMT_CHANNEL_MAX)
+			return (0);
+	} else
 		return (0);
 
-	for (i = 0; matrix_id == SND_CHN_MATRIX_UNKNOWN &&
-	    matrix_id_tab[i].name != NULL; i++) {
-		if (strcmp(matrix_id_tab[i].name, b2) == 0 ||
-		    (matrix_id_tab[i].alias1 != NULL &&
-		    strcmp(matrix_id_tab[i].alias1, b2) == 0) ||
-		    (matrix_id_tab[i].alias2 != NULL &&
-		    strcasecmp(matrix_id_tab[i].alias2, b2) == 0)) {
-			matrix_id = matrix_id_tab[i].matrix_id;
-			strlcpy(b2, matrix_id_tab[i].name, sizeof(b2));
+	for (i = 0; afmt_tab[i].name != NULL; i++) {
+		if (strcasecmp(afmt_tab[i].name, b1) != 0) {
+			if (afmt_tab[i].alias1 == NULL)
+				continue;
+			if (strcasecmp(afmt_tab[i].alias1, b1) != 0) {
+				if (afmt_tab[i].alias2 == NULL)
+					continue;
+				if (strcasecmp(afmt_tab[i].alias2, b1) != 0)
+					continue;
+			}
 		}
+		/* found a match */
+		return (SND_FORMAT(afmt_tab[i].afmt, ch + ext, ext));	
 	}
-
-	if (matrix_id == SND_CHN_MATRIX_UNKNOWN)
-		return (0);
-
-#ifndef _KERNEL
-	printf("Parse OK: '%s' -> '%s:%s' %d\n", req, b1, b2,
-	    (int)(b2[0]) - '0' + (int)(b2[2]) - '0');
-#endif
-
-	return (SND_FORMAT(afmt, b2[0] - '0' + b2[2] - '0', b2[2] - '0'));
+	/* not a valid format */
+	return (0);
 }
 
 uint32_t
 snd_afmt2str(uint32_t afmt, char *buf, size_t len)
 {
-	uint32_t i, enc, ch, ext;
-	char tmp[AFMTSTR_LEN];
+	uint32_t enc;
+	uint32_t ext;
+	uint32_t ch;
+	int i;
 
 	if (buf == NULL || len < AFMTSTR_LEN)
 		return (0);
 
-	
-	bzero(tmp, sizeof(tmp));
+	memset(buf, 0, len);
 
 	enc = AFMT_ENCODING(afmt);
 	ch = AFMT_CHANNEL(afmt);
 	ext = AFMT_EXTCHANNEL(afmt);
-
+	/* check there is at least one channel */
+	if (ch <= ext)
+		return (0);
 	for (i = 0; afmt_tab[i].name != NULL; i++) {
-		if (enc == afmt_tab[i].afmt) {
-			strlcpy(tmp, afmt_tab[i].name, sizeof(tmp));
-			strlcat(tmp, ":", sizeof(tmp));
-			break;
-		}
+		if (enc != afmt_tab[i].afmt)
+			continue;
+		/* found a match */
+		snprintf(buf, len, "%s:%d.%d",
+		    afmt_tab[i].name, ch - ext, ext);
+		return (SND_FORMAT(enc, ch, ext));
 	}
-
-	if (strlen(tmp) == 0)
-		return (0);
-	
-	for (i = 0; matrix_id_tab[i].name != NULL; i++) {
-		if (ch == (matrix_id_tab[i].name[0] - '0' +
-		    matrix_id_tab[i].name[2] - '0') &&
-		    ext == (matrix_id_tab[i].name[2] - '0')) {
-			strlcat(tmp, matrix_id_tab[i].name, sizeof(tmp));
-			break;
-		}
-	}
-
-	if (strlen(tmp) == 0)
-		return (0);
-
-	strlcpy(buf, tmp, len);
-
-	return (snd_str2afmt(buf));
+	return (0);
 }
 
 int

Modified: trunk/sys/dev/sound/pcm/channel.h
===================================================================
--- trunk/sys/dev/sound/pcm/channel.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/channel.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/channel.h 283950 2015-06-03 15:32:43Z hselasky $
  */
 
 struct pcmchan_caps {
@@ -162,6 +163,7 @@
 	} channels;
 
 	struct pcmchan_matrix matrix;
+  	struct pcmchan_matrix matrix_scratch;
 
 	int volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX];
 

Modified: trunk/sys/dev/sound/pcm/channel_if.m
===================================================================
--- trunk/sys/dev/sound/pcm/channel_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/channel_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # KOBJ
 #
@@ -27,7 +28,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/pcm/channel_if.m 193640 2009-06-07 19:12:08Z ariff $
 #
 
 #include <dev/sound/pcm/sound.h>


Property changes on: trunk/sys/dev/sound/pcm/channel_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pcm/dsp.c
===================================================================
--- trunk/sys/dev/sound/pcm/dsp.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/dsp.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -32,6 +33,8 @@
 
 #include <dev/sound/pcm/sound.h>
 #include <sys/ctype.h>
+#include <sys/lock.h>
+#include <sys/rwlock.h>
 #include <sys/sysent.h>
 
 #include <vm/vm.h>
@@ -39,7 +42,7 @@
 #include <vm/vm_page.h>
 #include <vm/vm_pager.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/dsp.c 283192 2015-05-21 07:48:06Z hselasky $");
 
 static int dsp_mmap_allow_prot_exec = 0;
 SYSCTL_INT(_hw_snd, OID_AUTO, compat_linux_mmap, CTLFLAG_RW,
@@ -46,6 +49,12 @@
     &dsp_mmap_allow_prot_exec, 0,
     "linux mmap compatibility (-1=force disable 0=auto 1=force enable)");
 
+static int dsp_basename_clone = 1;
+SYSCTL_INT(_hw_snd, OID_AUTO, basename_clone, CTLFLAG_RWTUN,
+    &dsp_basename_clone, 0,
+    "DSP basename cloning (0: Disable; 1: Enabled)");
+TUNABLE_INT("hw.snd.basename_clone", &dsp_basename_clone);
+
 struct dsp_cdevinfo {
 	struct pcm_channel *rdch, *wrch;
 	struct pcm_channel *volch;
@@ -2009,7 +2018,7 @@
 	 * OSSv4 docs:  "All errors and counters will automatically be
 	 * cleared to zeroes after the call so each call will return only
 	 * the errors that occurred after the previous invocation. ... The
-	 * play_underruns and rec_overrun fields are the only usefull fields
+	 * play_underruns and rec_overrun fields are the only useful fields
 	 * returned by OSS 4.0."
 	 */
 		{
@@ -2357,9 +2366,10 @@
 			devname = devcmp;
 		devhw = dsp_cdevs[i].hw;
 		devcmax = dsp_cdevs[i].max - 1;
-		if (strcmp(name, devcmp) == 0)
-			unit = snd_unit;
-		else if (dsp_stdclone(name, devcmp, devsep,
+		if (strcmp(name, devcmp) == 0) {
+			if (dsp_basename_clone != 0)
+				unit = snd_unit;
+		} else if (dsp_stdclone(name, devcmp, devsep,
 		    dsp_cdevs[i].use_sep, &unit, &cunit) != 0) {
 			unit = -1;
 			cunit = -1;

Modified: trunk/sys/dev/sound/pcm/dsp.h
===================================================================
--- trunk/sys/dev/sound/pcm/dsp.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/dsp.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/dsp.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifndef _PCMDSP_H_

Modified: trunk/sys/dev/sound/pcm/feeder.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 1999 Cameron Grant <cg at FreeBSD.org>
@@ -33,7 +34,7 @@
 
 #include "feeder_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder.c 227293 2011-11-07 06:44:47Z ed $");
 
 static MALLOC_DEFINE(M_FEEDER, "feeder", "pcm feeder");
 

Modified: trunk/sys/dev/sound/pcm/feeder.h
===================================================================
--- trunk/sys/dev/sound/pcm/feeder.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 1999 Cameron Grant <cg at FreeBSD.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/feeder.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 struct pcm_feederdesc {

Modified: trunk/sys/dev/sound/pcm/feeder_chain.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_chain.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_chain.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -32,7 +33,7 @@
 
 #include "feeder_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_chain.c 283950 2015-06-03 15:32:43Z hselasky $");
 
 /* chain state */
 struct feeder_chain_state {
@@ -562,6 +563,20 @@
 	((c)->mode == FEEDER_CHAIN_LEAN &&				\
 	!((c)->current.afmt & (AFMT_S16_NE | AFMT_S32_NE)))))
 
+static void
+feeder_default_matrix(struct pcmchan_matrix *m, uint32_t fmt, int id)
+{
+	int x;
+
+	memset(m, 0, sizeof(*m));
+
+	m->id = id;
+	m->channels = AFMT_CHANNEL(fmt);
+	m->ext = AFMT_EXTCHANNEL(fmt);
+	for (x = 0; x != SND_CHN_T_MAX; x++)
+		m->offset[x] = -1;
+}
+
 int
 feeder_chain(struct pcm_channel *c)
 {
@@ -642,10 +657,10 @@
 	 */
 	hwmatrix = CHANNEL_GETMATRIX(c->methods, c->devinfo, hwfmt);
 	if (hwmatrix == NULL) {
-		device_printf(c->dev,
-		    "%s(): failed to acquire hw matrix [0x%08x]\n",
-		    __func__, hwfmt);
-		return (ENODEV);
+		/* setup a default matrix */
+		hwmatrix = &c->matrix_scratch;
+		feeder_default_matrix(hwmatrix, hwfmt,
+		    SND_CHN_MATRIX_UNKNOWN);
 	}
 	/* ..... and rebuild hwfmt. */
 	hwfmt = SND_FORMAT(hwfmt, hwmatrix->channels, hwmatrix->ext);
@@ -657,13 +672,14 @@
 	    softmatrix->ext != AFMT_EXTCHANNEL(softfmt)) {
 		softmatrix = feeder_matrix_format_map(softfmt);
 		if (softmatrix == NULL) {
-			device_printf(c->dev,
-			    "%s(): failed to acquire soft matrix [0x%08x]\n",
-			    __func__, softfmt);
-			return (ENODEV);
+			/* setup a default matrix */
+		  	softmatrix = &c->matrix;
+			feeder_default_matrix(softmatrix, softfmt,
+			    SND_CHN_MATRIX_PCMCHANNEL);
+		} else {
+			c->matrix = *softmatrix;
+			c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL;
 		}
-		c->matrix = *softmatrix;
-		c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL;
 	}
 	softfmt = SND_FORMAT(softfmt, softmatrix->channels, softmatrix->ext);
 	if (softfmt != c->format)

Modified: trunk/sys/dev/sound/pcm/feeder_eq.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_eq.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_eq.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -44,7 +45,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_eq.c 209193 2010-06-15 07:06:54Z avg $");
 #endif
 
 #include "feeder_eq_gen.h"

Modified: trunk/sys/dev/sound/pcm/feeder_format.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_format.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_format.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -42,7 +43,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_format.c 193640 2009-06-07 19:12:08Z ariff $");
 #endif
 
 #define FEEDFORMAT_RESERVOIR	(SND_CHN_MAX * PCM_32_BPS)

Modified: trunk/sys/dev/sound/pcm/feeder_if.m
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # KOBJ
 #
@@ -25,7 +26,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/pcm/feeder_if.m 139749 2005-01-06 01:43:34Z imp $
 #
 
 #include <dev/sound/pcm/sound.h>


Property changes on: trunk/sys/dev/sound/pcm/feeder_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pcm/feeder_matrix.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_matrix.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_matrix.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -52,7 +53,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_matrix.c 317794 2017-05-04 14:50:25Z pfg $");
 #endif
 
 #define FEEDMATRIX_RESERVOIR	(SND_CHN_MAX * PCM_32_BPS)
@@ -86,6 +87,7 @@
 	[SND_CHN_MATRIX_2_0] = SND_CHN_MATRIX_MAP_2_0,
 	[SND_CHN_MATRIX_2_1] = SND_CHN_MATRIX_MAP_2_1,
 	[SND_CHN_MATRIX_3_0] = SND_CHN_MATRIX_MAP_3_0,
+	[SND_CHN_MATRIX_3_1] = SND_CHN_MATRIX_MAP_3_1,
 	[SND_CHN_MATRIX_4_0] = SND_CHN_MATRIX_MAP_4_0,
 	[SND_CHN_MATRIX_4_1] = SND_CHN_MATRIX_MAP_4_1,
 	[SND_CHN_MATRIX_5_0] = SND_CHN_MATRIX_MAP_5_0,
@@ -92,6 +94,7 @@
 	[SND_CHN_MATRIX_5_1] = SND_CHN_MATRIX_MAP_5_1,
 	[SND_CHN_MATRIX_6_0] = SND_CHN_MATRIX_MAP_6_0,
 	[SND_CHN_MATRIX_6_1] = SND_CHN_MATRIX_MAP_6_1,
+	[SND_CHN_MATRIX_7_0] = SND_CHN_MATRIX_MAP_7_0,
 	[SND_CHN_MATRIX_7_1] = SND_CHN_MATRIX_MAP_7_1
 };
 
@@ -748,8 +751,8 @@
 
 	tmpmap = 0x0000000000000000ULL;
 
-	for (i = 0; m->map[i].type != SND_CHN_T_MAX &&
-	    i < SND_CHN_OSS_MAX; i++) {
+	for (i = 0; i < SND_CHN_OSS_MAX && m->map[i].type != SND_CHN_T_MAX;
+	    i++) {
 		if ((1 << m->map[i].type) & ~SND_CHN_OSS_VALIDMASK)
 			return (EINVAL);
 		tmpmap |=

Modified: trunk/sys/dev/sound/pcm/feeder_mixer.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_mixer.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_mixer.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -36,7 +37,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_mixer.c 318979 2017-05-27 08:27:11Z hselasky $");
 #endif
 
 #undef SND_FEEDER_MULTIFORMAT
@@ -131,10 +132,10 @@
 				  sizeof(feed_mixer_info_tab[0])))
 
 #define FEEDMIXER_DATA(i, c)	((void *)				\
-				 ((uintptr_t)((((i) & 0x1f) << 5) |	\
-				 ((c) & 0x1f))))
-#define FEEDMIXER_INFOIDX(d)	((uint32_t)((uintptr_t)(d) >> 5) & 0x1f)
-#define FEEDMIXER_CHANNELS(d)	((uint32_t)((uintptr_t)(d)) & 0x1f)
+				 ((uintptr_t)((((i) & 0x1f) << 7) |	\
+				 ((c) & 0x7f))))
+#define FEEDMIXER_INFOIDX(d)	((uint32_t)((uintptr_t)(d) >> 7) & 0x1f)
+#define FEEDMIXER_CHANNELS(d)	((uint32_t)((uintptr_t)(d)) & 0x7f)
 
 static int
 feed_mixer_init(struct pcm_feeder *f)

Modified: trunk/sys/dev/sound/pcm/feeder_rate.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_rate.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_rate.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -59,7 +60,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_rate.c 209193 2010-06-15 07:06:54Z avg $");
 #endif
 
 #include "feeder_rate_gen.h"

Modified: trunk/sys/dev/sound/pcm/feeder_volume.c
===================================================================
--- trunk/sys/dev/sound/pcm/feeder_volume.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/feeder_volume.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -37,7 +38,7 @@
 #define SND_USE_FXDIV
 #include "snd_fxdiv_gen.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/feeder_volume.c 193640 2009-06-07 19:12:08Z ariff $");
 #endif
 
 typedef void (*feed_volume_t)(int *, int *, uint32_t, uint8_t *, uint32_t);

Modified: trunk/sys/dev/sound/pcm/g711.h
===================================================================
--- trunk/sys/dev/sound/pcm/g711.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/g711.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/g711.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifndef _SND_G711_H_

Modified: trunk/sys/dev/sound/pcm/intpcm.h
===================================================================
--- trunk/sys/dev/sound/pcm/intpcm.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/intpcm.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2008-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/intpcm.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifndef _SND_INTPCM_H_

Modified: trunk/sys/dev/sound/pcm/matrix.h
===================================================================
--- trunk/sys/dev/sound/pcm/matrix.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/matrix.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/matrix.h 243138 2012-11-16 07:05:57Z mav $
  */
 
 #ifndef _SND_MATRIX_H_
@@ -134,29 +135,31 @@
 #define SND_CHN_MATRIX_3_0	3
 #define SND_CHN_MATRIX_3	SND_CHN_MATRIX_3_0
 
-/* 4 @ 4.0 Quadraphonic */
-#define SND_CHN_MATRIX_4_0	4
+/* 4 @ 3.1 (lfe), 4.0 (Quadraphonic, DEFAULT) */
+#define SND_CHN_MATRIX_3_1	4
+#define SND_CHN_MATRIX_4_0	5
 #define SND_CHN_MATRIX_4	SND_CHN_MATRIX_4_0
 
 /* 5 @ 4.1 (lfe), 5.0 (center, DEFAULT) */
-#define SND_CHN_MATRIX_4_1	5
-#define SND_CHN_MATRIX_5_0	6
+#define SND_CHN_MATRIX_4_1	6
+#define SND_CHN_MATRIX_5_0	7
 #define SND_CHN_MATRIX_5	SND_CHN_MATRIX_5_0
 
 /* 6 @ 5.1 (lfe, DEFAULT), 6.0 (rear center) */
-#define SND_CHN_MATRIX_5_1	7
-#define SND_CHN_MATRIX_6_0	8
+#define SND_CHN_MATRIX_5_1	8
+#define SND_CHN_MATRIX_6_0	9
 #define SND_CHN_MATRIX_6	SND_CHN_MATRIX_5_1
 
-/* 7 @ 6.1 (lfe) */
-#define SND_CHN_MATRIX_6_1	9
+/* 7 @ 6.1 (lfe, DEFAULT), 7.0 */
+#define SND_CHN_MATRIX_6_1	10
+#define SND_CHN_MATRIX_7_0	11
 #define SND_CHN_MATRIX_7	SND_CHN_MATRIX_6_1
 
 /* 8 @ 7.1 (lfe) */
-#define SND_CHN_MATRIX_7_1	10
+#define SND_CHN_MATRIX_7_1	12
 #define SND_CHN_MATRIX_8	SND_CHN_MATRIX_7_1
 
-#define SND_CHN_MATRIX_MAX	11
+#define SND_CHN_MATRIX_MAX	13
 
 #define SND_CHN_MATRIX_BEGIN	SND_CHN_MATRIX_1_0
 #define SND_CHN_MATRIX_END	SND_CHN_MATRIX_7_1

Modified: trunk/sys/dev/sound/pcm/matrix_map.h
===================================================================
--- trunk/sys/dev/sound/pcm/matrix_map.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/matrix_map.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/matrix_map.h 243138 2012-11-16 07:05:57Z mav $
  */
 
 #ifndef _SND_MATRIX_MAP_H_
@@ -195,6 +196,49 @@
 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
 }
 
+#define SND_CHN_MATRIX_MAP_3_1	{					\
+	.id = SND_CHN_MATRIX_3_1,					\
+	.channels = 4,							\
+	.ext = 1,							\
+	.map = {							\
+		/* Left */						\
+		[0] = {							\
+			.type = SND_CHN_T_FL,				\
+			.members =					\
+			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
+			    SND_CHN_T_MASK_SL				\
+		},							\
+		/* Right */						\
+		[1] = {							\
+			.type = SND_CHN_T_FR,				\
+			.members =					\
+			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
+			    SND_CHN_T_MASK_SR				\
+		},							\
+		/* LFE */						\
+		[2] = {							\
+			.type = SND_CHN_T_LF,				\
+			.members = SND_CHN_T_MASK_LF			\
+		},							\
+		/* Rear Center */					\
+		[3] = {							\
+			.type = SND_CHN_T_BC,				\
+			.members =					\
+			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |	\
+			    SND_CHN_T_MASK_BC |				\
+			    SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR	\
+		},							\
+		[4] = {							\
+			.type = SND_CHN_T_MAX,				\
+			.members = 0					\
+		}							\
+	},								\
+	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
+		SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BC,			\
+	.offset = {  0,  1, -1,  2, -1, -1, -1, -1,  3,			\
+		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
+}
+
 #define SND_CHN_MATRIX_MAP_4_0	{					\
 	.id = SND_CHN_MATRIX_4_0,					\
 	.channels = 4,							\
@@ -504,6 +548,68 @@
 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
 }
 
+#define SND_CHN_MATRIX_MAP_7_0	{					\
+	.id = SND_CHN_MATRIX_7_0,					\
+	.channels = 7,							\
+	.ext = 0,							\
+	.map = {							\
+		/* Left */						\
+		[0] = {							\
+			.type = SND_CHN_T_FL,				\
+			.members =					\
+			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_LF	\
+		},							\
+		/* Right */						\
+		[1] = {							\
+			.type = SND_CHN_T_FR,				\
+			.members =					\
+			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_LF	\
+		},							\
+		/* Rear Left */						\
+		[2] = {							\
+			.type = SND_CHN_T_BL,				\
+			.members =					\
+			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC |	\
+			    SND_CHN_T_MASK_LF				\
+		},							\
+		/* Rear Right */					\
+		[3] = {							\
+			.type = SND_CHN_T_BR,				\
+			.members =					\
+			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
+			    SND_CHN_T_MASK_LF				\
+		},							\
+		/* Center */						\
+		[4] = {							\
+			.type = SND_CHN_T_FC,				\
+			.members =					\
+			    SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF	\
+		},							\
+		/* Side Left */						\
+		[5] = {							\
+			.type = SND_CHN_T_SL,				\
+			.members =					\
+			    SND_CHN_T_MASK_SL | SND_CHN_T_MASK_LF	\
+		},							\
+		/* Side Right */					\
+		[6] = {							\
+			.type = SND_CHN_T_SR,				\
+			.members =					\
+			    SND_CHN_T_MASK_SR | SND_CHN_T_MASK_LF	\
+		},							\
+		[7] = {							\
+			.type = SND_CHN_T_MAX,				\
+			.members = 0					\
+		}							\
+	},								\
+	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
+		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
+		SND_CHN_T_MASK_FC |					\
+		SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR,			\
+	.offset = {  0,  1,  4, -1,  2,  3, -1, -1, -1,			\
+		     5,  6, -1, -1, -1, -1, -1, -1, -1  }		\
+}
+
 #define SND_CHN_MATRIX_MAP_7_1	{					\
 	.id = SND_CHN_MATRIX_7_1,					\
 	.channels = 8,							\

Modified: trunk/sys/dev/sound/pcm/mixer.c
===================================================================
--- trunk/sys/dev/sound/pcm/mixer.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/mixer.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -35,7 +36,7 @@
 #include "feeder_if.h"
 #include "mixer_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/mixer.c 271193 2014-09-06 15:24:48Z mav $");
 
 static MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
 
@@ -1222,6 +1223,15 @@
 	return (ret);
 }
 
+static void
+mixer_mixerinfo(struct snd_mixer *m, mixer_info *mi)
+{
+	bzero((void *)mi, sizeof(*mi));
+	strlcpy(mi->id, m->name, sizeof(mi->id));
+	strlcpy(mi->name, device_get_desc(m->dev), sizeof(mi->name));
+	mi->modify_counter = m->modify_counter;
+}
+
 /*
  * XXX Make sure you can guarantee concurrency safety before calling this
  *     function, be it through Giant, PCM_*, etc !
@@ -1280,6 +1290,10 @@
 		*arg_i = SOUND_VERSION;
 		ret = 0;
 		goto done;
+	case SOUND_MIXER_INFO:
+		mixer_mixerinfo(m, (mixer_info *)arg);
+		ret = 0;
+		goto done;
 	}
 	if ((cmd & ~0xff) == MIXER_WRITE(0)) {
 		if (j == SOUND_MIXER_RECSRC)

Modified: trunk/sys/dev/sound/pcm/mixer.h
===================================================================
--- trunk/sys/dev/sound/pcm/mixer.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/mixer.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 1999 Cameron Grant <cg at FreeBSD.org>
@@ -24,9 +25,12 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/mixer.h 246454 2013-02-07 08:20:03Z hselasky $
  */
 
+#ifndef _PCM_MIXER_H_
+#define	_PCM_MIXER_H_
+
 struct snd_mixer *mixer_create(device_t dev, kobj_class_t cls, void *devinfo,
     const char *desc);
 int mixer_delete(struct snd_mixer *m);
@@ -79,3 +83,5 @@
 			    sizeof(oss_mixer_enuminfo))
 
 #define MIXER_DECLARE(name) static DEFINE_CLASS(name, name ## _methods, MIXER_SIZE)
+
+#endif				/* _PCM_MIXER_H_ */

Modified: trunk/sys/dev/sound/pcm/mixer_if.m
===================================================================
--- trunk/sys/dev/sound/pcm/mixer_if.m	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/mixer_if.m	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #-
 # KOBJ
 #
@@ -25,7 +26,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/sound/pcm/mixer_if.m 139749 2005-01-06 01:43:34Z imp $
 #
 
 #include <dev/sound/pcm/sound.h>


Property changes on: trunk/sys/dev/sound/pcm/mixer_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/sound/pcm/pcm.h
===================================================================
--- trunk/sys/dev/sound/pcm/pcm.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/pcm.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/pcm.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifndef _SND_PCM_H_

Modified: trunk/sys/dev/sound/pcm/sndstat.c
===================================================================
--- trunk/sys/dev/sound/pcm/sndstat.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/sndstat.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 2001 Cameron Grant <cg at FreeBSD.org>
@@ -34,7 +35,7 @@
 #include <dev/sound/version.h>
 #include <sys/sx.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/sndstat.c 248381 2013-03-16 17:57:00Z joel $");
 
 #define	SS_TYPE_MODULE		0
 #define	SS_TYPE_FIRST		1
@@ -345,8 +346,12 @@
 	struct snddev_info *d;
     	int i, j;
 
-	sbuf_printf(s, "FreeBSD Audio Driver (newpcm: %ubit %d/%s)\n",
-	    (u_int)sizeof(intpcm32_t) << 3, SND_DRV_VERSION, MACHINE_ARCH);
+	if (snd_verbose > 0) {
+		sbuf_printf(s, "FreeBSD Audio Driver (%ubit %d/%s)\n",
+		    (u_int)sizeof(intpcm32_t) << 3, SND_DRV_VERSION,
+		    MACHINE_ARCH);
+	}
+
 	if (SLIST_EMPTY(&sndstat_devlist)) {
 		sbuf_printf(s, "No devices installed.\n");
 		sbuf_finish(s);

Modified: trunk/sys/dev/sound/pcm/sndstat.h
===================================================================
--- trunk/sys/dev/sound/pcm/sndstat.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/sndstat.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/sndstat.h 202267 2010-01-13 22:22:16Z mav $
  */
 
 #ifndef _SND_SNDSTAT_H_

Modified: trunk/sys/dev/sound/pcm/sound.c
===================================================================
--- trunk/sys/dev/sound/pcm/sound.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/sound.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Portions Copyright (c) Ryan Beasley <ryan.beasley at gmail.com> - GSoC 2006
@@ -42,7 +43,7 @@
 
 #include "feeder_if.h"
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/sound.c 243459 2012-11-23 15:31:00Z mav $");
 
 devclass_t pcm_devclass;
 
@@ -1074,13 +1075,6 @@
 	    SND_CLONE_GC_ENABLE | SND_CLONE_GC_UNREF |
 	    SND_CLONE_GC_LASTREF | SND_CLONE_GC_EXPIRED);
 
-	if (bootverbose != 0 || snd_verbose > 3) {
-		device_printf(dev,
-		    "clone manager: deadline=%dms flags=0x%08x\n",
-		    snd_clone_getdeadline(d->clones),
-		    snd_clone_getflags(d->clones));
-	}
-
 	CHN_INIT(d, channels.pcm);
 	CHN_INIT(d, channels.pcm.busy);
 	CHN_INIT(d, channels.pcm.opened);

Modified: trunk/sys/dev/sound/pcm/sound.h
===================================================================
--- trunk/sys/dev/sound/pcm/sound.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/sound.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 1999 Cameron Grant <cg at FreeBSD.org>
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/sound.h 283950 2015-06-03 15:32:43Z hselasky $
  */
 
 /*
@@ -220,10 +221,12 @@
  * ~(0xb00ff7ff)
  */
 #define AFMT_ENCODING_MASK	0xf00fffff
-#define AFMT_CHANNEL_MASK	0x01f00000
+#define AFMT_CHANNEL_MASK	0x07f00000
 #define AFMT_CHANNEL_SHIFT	20
-#define AFMT_EXTCHANNEL_MASK	0x0e000000
-#define AFMT_EXTCHANNEL_SHIFT	25
+#define AFMT_CHANNEL_MAX	0x7f
+#define AFMT_EXTCHANNEL_MASK	0x08000000
+#define AFMT_EXTCHANNEL_SHIFT	27
+#define AFMT_EXTCHANNEL_MAX	1
 
 #define AFMT_ENCODING(v)	((v) & AFMT_ENCODING_MASK)
 

Modified: trunk/sys/dev/sound/pcm/vchan.c
===================================================================
--- trunk/sys/dev/sound/pcm/vchan.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/vchan.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2006-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 2001 Cameron Grant <cg at FreeBSD.org>
@@ -34,7 +35,7 @@
 #include <dev/sound/pcm/sound.h>
 #include <dev/sound/pcm/vchan.h>
 
-SND_DECLARE_FILE("$MidnightBSD$");
+SND_DECLARE_FILE("$FreeBSD: stable/10/sys/dev/sound/pcm/vchan.c 193640 2009-06-07 19:12:08Z ariff $");
 
 /*
  * [ac3 , dts , linear , 0, linear, 0]

Modified: trunk/sys/dev/sound/pcm/vchan.h
===================================================================
--- trunk/sys/dev/sound/pcm/vchan.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/pcm/vchan.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005-2009 Ariff Abdullah <ariff at FreeBSD.org>
  * Copyright (c) 2001 Cameron Grant <cg at FreeBSD.org>
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/pcm/vchan.h 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #ifndef _SND_VCHAN_H_

Modified: trunk/sys/dev/sound/sbus/apcdmareg.h
===================================================================
--- trunk/sys/dev/sound/sbus/apcdmareg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/sbus/apcdmareg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/sound/sbus/apcdmareg.h 139749 2005-01-06 01:43:34Z imp $	*/
 /*	$OpenBSD: apcdmareg.h,v 1.2 2003/06/02 18:53:18 jason Exp $	*/
 
 /*-

Modified: trunk/sys/dev/sound/sbus/cs4231.c
===================================================================
--- trunk/sys/dev/sound/sbus/cs4231.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/sbus/cs4231.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Jason L. Wright (jason at thought.net)
  * Copyright (c) 2004 Pyun YongHyeon
@@ -37,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/sound/sbus/cs4231.c 246128 2013-01-30 18:01:20Z sbz $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -231,7 +232,8 @@
 	DEVMETHOD(device_detach,	cs4231_bus_detach),
 	DEVMETHOD(device_suspend,	cs4231_bus_suspend),
 	DEVMETHOD(device_resume,	cs4231_bus_resume),
-	{0, 0}
+
+	DEVMETHOD_END
 };
 
 static driver_t cs4231_sbus_driver = {
@@ -249,7 +251,8 @@
 	DEVMETHOD(device_detach,	cs4231_bus_detach),
 	DEVMETHOD(device_suspend,	cs4231_bus_suspend),
 	DEVMETHOD(device_resume,	cs4231_bus_resume),
-	{0, 0}
+
+	DEVMETHOD_END
 };
 
 static driver_t cs4231_ebus_driver = {

Modified: trunk/sys/dev/sound/sbus/cs4231.h
===================================================================
--- trunk/sys/dev/sound/sbus/cs4231.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/sbus/cs4231.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/sound/sbus/cs4231.h 192452 2009-05-20 18:04:56Z joel $	*/
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
  * All rights reserved.

Modified: trunk/sys/dev/sound/unit.c
===================================================================
--- trunk/sys/dev/sound/unit.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/unit.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/unit.c 193640 2009-06-07 19:12:08Z ariff $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/sound/unit.h
===================================================================
--- trunk/sys/dev/sound/unit.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/unit.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Ariff Abdullah <ariff at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/sound/unit.h 170159 2007-05-31 18:35:24Z ariff $
  */
 
 #ifndef _SND_UNIT_H_

Modified: trunk/sys/dev/sound/usb/uaudio.c
===================================================================
--- trunk/sys/dev/sound/usb/uaudio.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/usb/uaudio.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $	*/
-/*	$MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/sound/usb/uaudio.c 315249 2017-03-14 15:21:41Z hselasky $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -32,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/sound/usb/uaudio.c 315249 2017-03-14 15:21:41Z hselasky $");
 
 /*
  * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf
@@ -95,6 +96,7 @@
 static int uaudio_default_rate = 0;		/* use rate list */
 static int uaudio_default_bits = 32;
 static int uaudio_default_channels = 0;		/* use default */
+static int uaudio_buffer_ms = 8;
 
 #ifdef USB_DEBUG
 static int uaudio_debug = 0;
@@ -115,11 +117,37 @@
 TUNABLE_INT("hw.usb.uaudio.default_channels", &uaudio_default_channels);
 SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW,
     &uaudio_default_channels, 0, "uaudio default sample channels");
+
+static int
+uaudio_buffer_ms_sysctl(SYSCTL_HANDLER_ARGS)
+{
+	int err, val;
+
+	val = uaudio_buffer_ms;
+	err = sysctl_handle_int(oidp, &val, 0, req);
+
+	if (err != 0 || req->newptr == NULL || val == uaudio_buffer_ms)
+		return (err);
+
+	if (val > 8)
+		val = 8;
+	else if (val < 2)
+		val = 2;
+
+	uaudio_buffer_ms = val;
+
+	return (0);
+}
+SYSCTL_PROC(_hw_usb_uaudio, OID_AUTO, buffer_ms, CTLTYPE_INT | CTLFLAG_RWTUN,
+    0, sizeof(int), uaudio_buffer_ms_sysctl, "I",
+    "uaudio buffering delay from 2ms to 8ms");
 #endif
 
 #define	UAUDIO_NFRAMES		64	/* must be factor of 8 due HS-USB */
 #define	UAUDIO_NCHANBUFS	2	/* number of outstanding request */
 #define	UAUDIO_RECURSE_LIMIT	255	/* rounds */
+#define	UAUDIO_CHANNELS_MAX	MIN(64, AFMT_CHANNEL_MAX)
+#define	UAUDIO_MATRIX_MAX	8	/* channels */
 
 #define	MAKE_WORD(h,l) (((h) << 8) | (l))
 #define	BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
@@ -182,7 +210,7 @@
 	struct uaudio_softc *sc;
 };
 
-#define	CHAN_MAX_ALT 20
+#define	CHAN_MAX_ALT 24
 
 struct uaudio_chan_alt {
 	union uaudio_asf1d p_asf1d;
@@ -217,28 +245,28 @@
 	uint32_t sample_rem;
 	uint32_t sample_curr;
 	uint32_t max_buf;
+	int32_t jitter_rem;
+	int32_t jitter_curr;
 
+	int feedback_rate;
+
 	uint32_t pcm_format[2];
 
 	uint16_t bytes_per_frame[2];
 
-	uint8_t	num_alt;
-	uint8_t cur_alt;
-	uint8_t set_alt;
-	uint8_t operation;
+	uint32_t intr_counter;
+	uint32_t running;
+	uint32_t num_alt;
+	uint32_t cur_alt;
+	uint32_t set_alt;
+	uint32_t operation;
 #define	CHAN_OP_NONE 0
 #define	CHAN_OP_START 1
 #define	CHAN_OP_STOP 2
 #define	CHAN_OP_DRAIN 3
-
-	uint8_t last_sync_time;
-	uint8_t last_sync_state;
-#define	UAUDIO_SYNC_NONE 0
-#define	UAUDIO_SYNC_MORE 1
-#define	UAUDIO_SYNC_LESS 2
 };
 
-#define	UMIDI_CABLES_MAX   16		/* units */
+#define	UMIDI_EMB_JACK_MAX   16		/* units */
 #define	UMIDI_TX_FRAMES	   256		/* units */
 #define	UMIDI_TX_BUFFER    (UMIDI_TX_FRAMES * 4)	/* bytes */
 
@@ -269,7 +297,7 @@
 
 struct umidi_chan {
 
-	struct umidi_sub_chan sub[UMIDI_CABLES_MAX];
+	struct umidi_sub_chan sub[UMIDI_EMB_JACK_MAX];
 	struct mtx mtx;
 
 	struct usb_xfer *xfer[UMIDI_N_TRANSFER];
@@ -281,7 +309,7 @@
 	uint8_t	write_open_refcount;
 
 	uint8_t	curr_cable;
-	uint8_t	max_cable;
+	uint8_t	max_emb_jack;
 	uint8_t	valid;
 	uint8_t single_command;
 };
@@ -316,6 +344,11 @@
 	uint8_t mute_id;
 };
 
+#define	UAUDIO_SPDIF_OUT	0x01	/* Enable S/PDIF output */
+#define	UAUDIO_SPDIF_OUT_48K	0x02	/* Out sample rate = 48K */
+#define	UAUDIO_SPDIF_OUT_96K	0x04	/* Out sample rate = 96K */
+#define	UAUDIO_SPDIF_IN_MIX	0x10	/* Input mix enable */
+
 struct uaudio_softc {
 	struct sbuf sc_sndstat;
 	struct sndcard_func sc_sndcard_func;
@@ -333,6 +366,7 @@
 	struct usb_xfer *sc_mixer_xfer[1];
 	struct uaudio_mixer_node *sc_mixer_root;
 	struct uaudio_mixer_node *sc_mixer_curr;
+	int     (*sc_set_spdif_fn) (struct uaudio_softc *, int);
 
 	uint32_t sc_mix_info;
 	uint32_t sc_recsrc_info;
@@ -351,6 +385,7 @@
 	uint8_t	sc_uq_au_no_xu:1;
 	uint8_t	sc_uq_bad_adc:1;
 	uint8_t	sc_uq_au_vendor_class:1;
+	uint8_t	sc_pcm_bitperfect:1;
 };
 
 struct uaudio_terminal_node {
@@ -659,6 +694,7 @@
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
 		.bufsize = UMIDI_TX_BUFFER,
+		.flags = {.no_pipe_ok = 1},
 		.callback = &umidi_bulk_write_callback,
 	},
 
@@ -667,7 +703,7 @@
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
 		.bufsize = 4,	/* bytes */
-		.flags = {.short_xfer_ok = 1,.proxy_buffer = 1,},
+		.flags = {.short_xfer_ok = 1,.proxy_buffer = 1,.no_pipe_ok = 1},
 		.callback = &umidi_bulk_read_callback,
 	},
 };
@@ -862,7 +898,47 @@
 	return (ENXIO);
 }
 
+/*
+ * Set Cmedia CM6206 S/PDIF settings
+ * Source: CM6206 Datasheet v2.3.
+ */
 static int
+uaudio_set_spdif_cm6206(struct uaudio_softc *sc, int flags)
+{
+	uint8_t cmd[2][4] = {
+		{0x20, 0x20, 0x00, 0},
+		{0x20, 0x30, 0x02, 1}
+	};
+	int i;
+
+	if (flags & UAUDIO_SPDIF_OUT)
+		cmd[1][1] = 0x00;
+	else
+		cmd[1][1] = 0x02;
+
+	if (flags & UAUDIO_SPDIF_OUT_96K)
+		cmd[0][1] = 0x60;	/* 96K: 3'b110 */
+
+	if (flags & UAUDIO_SPDIF_IN_MIX)
+		cmd[1][1] = 0x03;	/* SPDIFMIX */
+
+	for (i = 0; i < 2; i++) {
+		if (usbd_req_set_report(sc->sc_udev, NULL,
+		    cmd[i], sizeof(cmd[0]),
+		    sc->sc_mixer_iface_index, UHID_OUTPUT_REPORT, 0) != 0) {
+			return (ENXIO);
+		}
+	}
+	return (0);
+}
+
+static int
+uaudio_set_spdif_dummy(struct uaudio_softc *sc, int flags)
+{
+	return (0);
+}
+
+static int
 uaudio_attach(device_t dev)
 {
 	struct usb_attach_arg *uaa = device_get_ivars(dev);
@@ -896,6 +972,12 @@
 	if (usb_test_quirk(uaa, UQ_AU_VENDOR_CLASS))
 		sc->sc_uq_au_vendor_class = 1;
 
+	/* set S/PDIF function */
+	if (usb_test_quirk(uaa, UQ_AU_SET_SPDIF_CM6206))
+		sc->sc_set_spdif_fn = uaudio_set_spdif_cm6206;
+	else
+		sc->sc_set_spdif_fn = uaudio_set_spdif_dummy;
+
 	umidi_init(dev);
 
 	device_set_usb_desc(dev);
@@ -1032,6 +1114,11 @@
 	/* reload all mixer settings */
 	uaudio_mixer_reload_all(sc);
 
+	/* enable S/PDIF output, if any */
+	if (sc->sc_set_spdif_fn(sc,
+	    UAUDIO_SPDIF_OUT | UAUDIO_SPDIF_OUT_48K) != 0) {
+		device_printf(dev, "Failed to enable S/PDIF at 48K\n");
+	}
 	return (0);			/* success */
 
 detach:
@@ -1067,6 +1154,10 @@
 		 */
 		uaudio_pcm_setflags(dev, SD_F_SOFTPCMVOL);
 	}
+	if (sc->sc_pcm_bitperfect) {
+		DPRINTF("device needs bitperfect by default\n");
+		uaudio_pcm_setflags(dev, SD_F_BITPERFECT);
+	}
 	if (mixer_init(dev, mixer_class, sc))
 		goto detach;
 	sc->sc_mixer_init = 1;
@@ -1094,6 +1185,11 @@
 
 	uaudio_mixer_register_sysctl(sc, dev);
 
+	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
+	    "feedback_rate", CTLFLAG_RD, &sc->sc_play_chan.feedback_rate,
+	    0, "Feedback sample rate in Hz");
+
 	return (0);			/* success */
 
 detach:
@@ -1107,6 +1203,9 @@
 	struct uaudio_softc *sc = device_get_softc(device_get_parent(dev));
 	int error = 0;
 
+	/* disable S/PDIF output, if any */
+	(void) sc->sc_set_spdif_fn(sc, 0);
+
 repeat:
 	if (sc->sc_pcm_registered) {
 		error = pcm_unregister(dev);
@@ -1270,10 +1369,10 @@
 
 	if (fps < 8000) {
 		/* FULL speed USB */
-		frames = 8;
+		frames = uaudio_buffer_ms;
 	} else {
 		/* HIGH speed USB */
-		frames = UAUDIO_NFRAMES;
+		frames = uaudio_buffer_ms * 8;
 	}
 
 	fps_shift = usbd_xfer_get_fps_shift(chan->xfer[0]);
@@ -1292,7 +1391,6 @@
 	chan->frames_per_second = fps;
 	chan->sample_rem = chan_alt->sample_rate % fps;
 	chan->sample_curr = 0;
-	chan->frames_per_second = fps;
 
 	/* compute required buffer size */
 	buf_size = (chan->bytes_per_frame[1] * frames);
@@ -1487,6 +1585,7 @@
 	union uaudio_asid asid = { NULL };
 	union uaudio_asf1d asf1d = { NULL };
 	union uaudio_sed sed = { NULL };
+	struct usb_midi_streaming_endpoint_descriptor *msid = NULL;
 	usb_endpoint_descriptor_audio_t *ed1 = NULL;
 	const struct usb_audio_control_descriptor *acdp = NULL;
 	struct usb_config_descriptor *cd = usbd_get_config_descriptor(udev);
@@ -1504,6 +1603,7 @@
 	uint8_t bChannels;
 	uint8_t bBitResolution;
 	uint8_t audio_if = 0;
+	uint8_t midi_if = 0;
 	uint8_t uma_if_class;
 
 	while ((desc = usb_desc_foreach(cd, desc))) {
@@ -1539,7 +1639,8 @@
 			    ((id->bInterfaceClass == UICLASS_VENDOR) &&
 			    (sc->sc_uq_au_vendor_class != 0)));
 
-			if ((uma_if_class != 0) && (id->bInterfaceSubClass == UISUBCLASS_AUDIOSTREAM)) {
+			if ((uma_if_class != 0) &&
+			    (id->bInterfaceSubClass == UISUBCLASS_AUDIOSTREAM)) {
 				audio_if = 1;
 			} else {
 				audio_if = 0;
@@ -1551,29 +1652,56 @@
 				/*
 				 * XXX could allow multiple MIDI interfaces
 				 */
+				midi_if = 1;
 
 				if ((sc->sc_midi_chan.valid == 0) &&
-				    usbd_get_iface(udev, curidx)) {
+				    (usbd_get_iface(udev, curidx) != NULL)) {
 					sc->sc_midi_chan.iface_index = curidx;
 					sc->sc_midi_chan.iface_alt_index = alt_index;
 					sc->sc_midi_chan.valid = 1;
 				}
+			} else {
+				midi_if = 0;
 			}
 			asid.v1 = NULL;
 			asf1d.v1 = NULL;
 			ed1 = NULL;
 			sed.v1 = NULL;
+
+			/*
+			 * There can only be one USB audio instance
+			 * per USB device. Grab all USB audio
+			 * interfaces on this USB device so that we
+			 * don't attach USB audio twice:
+			 */
+			if (alt_index == 0 && curidx != sc->sc_mixer_iface_index &&
+			    (id->bInterfaceClass == UICLASS_AUDIO || audio_if != 0 ||
+			    midi_if != 0)) {
+				usbd_set_parent_iface(sc->sc_udev, curidx,
+				    sc->sc_mixer_iface_index);
+			}
 		}
 
 		if (audio_if == 0) {
-			if ((acdp == NULL) &&
-			    (desc->bDescriptorType == UDESC_CS_INTERFACE) &&
-			    (desc->bDescriptorSubtype == UDESCSUB_AC_HEADER) &&
-			    (desc->bLength >= sizeof(*acdp))) {
-				acdp = (void *)desc;
-				audio_rev = UGETW(acdp->bcdADC);
+			if (midi_if == 0) {
+				if ((acdp == NULL) &&
+				    (desc->bDescriptorType == UDESC_CS_INTERFACE) &&
+				    (desc->bDescriptorSubtype == UDESCSUB_AC_HEADER) &&
+				    (desc->bLength >= sizeof(*acdp))) {
+					acdp = (void *)desc;
+					audio_rev = UGETW(acdp->bcdADC);
+				}
+			} else {
+				msid = (void *)desc;
+
+				/* get the maximum number of embedded jacks in use, if any */
+				if (msid->bLength >= sizeof(*msid) &&
+				    msid->bDescriptorType == UDESC_CS_ENDPOINT &&
+				    msid->bDescriptorSubtype == MS_GENERAL &&
+				    msid->bNumEmbMIDIJack > sc->sc_midi_chan.max_emb_jack) {
+					sc->sc_midi_chan.max_emb_jack = msid->bNumEmbMIDIJack;
+				}
 			}
-
 			/*
 			 * Don't collect any USB audio descriptors if
 			 * this is not an USB audio stream interface.
@@ -1665,22 +1793,11 @@
 		} else if (audio_rev >= UAUDIO_VERSION_20) {
 
 			uint32_t dwFormat;
-			uint8_t bSubslotSize;
 
 			dwFormat = UGETDW(asid.v2->bmFormats);
 			bChannels = asid.v2->bNrChannels;
-			bBitResolution = asf1d.v2->bBitResolution;
-			bSubslotSize = asf1d.v2->bSubslotSize;
+			bBitResolution = asf1d.v2->bSubslotSize * 8;
 
-			/* Map 4-byte aligned 24-bit samples into 32-bit */
-			if (bBitResolution == 24 && bSubslotSize == 4)
-				bBitResolution = 32;
-
-			if (bBitResolution != (bSubslotSize * 8)) {
-				DPRINTF("Invalid bSubslotSize\n");
-				goto next_ep;
-			}
-
 			if ((bChannels != channels) ||
 			    (bBitResolution != bit_resolution)) {
 				DPRINTF("Wrong number of channels\n");
@@ -1726,7 +1843,7 @@
 
 			wFormat = UGETW(asid.v1->wFormatTag);
 			bChannels = UAUDIO_MAX_CHAN(asf1d.v1->bNrChannels);
-			bBitResolution = asf1d.v1->bBitResolution;
+			bBitResolution = asf1d.v1->bSubFrameSize * 8;
 
 			if (asf1d.v1->bSamFreqType == 0) {
 				DPRINTFN(16, "Sample rate: %d-%dHz\n",
@@ -1798,9 +1915,6 @@
 		chan_alt->iface_index = curidx;
 		chan_alt->iface_alt_index = alt_index;
 
-		usbd_set_parent_iface(sc->sc_udev, curidx,
-		    sc->sc_mixer_iface_index);
-
 		if (ep_dir == UE_DIR_IN)
 			chan_alt->usb_cfg = uaudio_cfg_record;
 		else
@@ -1821,19 +1935,21 @@
 
 		format = chan_alt->p_fmt->freebsd_fmt;
 
+		/* get default SND_FORMAT() */
+		format = SND_FORMAT(format, chan_alt->channels, 0);
+
 		switch (chan_alt->channels) {
+		uint32_t temp_fmt;
+		case 1:
 		case 2:
-			/* stereo */
-			format = SND_FORMAT(format, 2, 0);
+			/* mono and stereo */
 			break;
-		case 1:
-			/* mono */
-			format = SND_FORMAT(format, 1, 0);
-			break;
 		default:
 			/* surround and more */
-			format = feeder_matrix_default_format(
-			    SND_FORMAT(format, chan_alt->channels, 0));
+			temp_fmt = feeder_matrix_default_format(format);
+			/* if multichannel, then format can be zero */
+			if (temp_fmt != 0)
+				format = temp_fmt;
 			break;
 		}
 
@@ -1860,6 +1976,10 @@
 		chan->pcm_cap.fmtlist = chan->pcm_format;
 		chan->pcm_cap.fmtlist[0] = format;
 
+		/* check if device needs bitperfect */
+		if (chan_alt->channels > UAUDIO_MATRIX_MAX)
+			sc->sc_pcm_bitperfect = 1;
+
 		if (rate < chan->pcm_cap.minspeed || chan->pcm_cap.minspeed == 0)
 			chan->pcm_cap.minspeed = rate;
 		if (rate > chan->pcm_cap.maxspeed || chan->pcm_cap.maxspeed == 0)
@@ -1883,6 +2003,10 @@
 /* This structure defines all the supported rates. */
 
 static const uint32_t uaudio_rate_list[CHAN_MAX_ALT] = {
+	384000,
+	352800,
+	192000,
+	176400,
 	96000,
 	88200,
 	88000,
@@ -1930,15 +2054,15 @@
 			channels = 4;
 			break;
 		default:
-			channels = 16;
+			channels = UAUDIO_CHANNELS_MAX;
 			break;
 		}
-	} else if (channels > 16) {
-		channels = 16;
-	}
-	if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND)) {
+	} else if (channels > UAUDIO_CHANNELS_MAX)
+		channels = UAUDIO_CHANNELS_MAX;
+
+	if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND))
 		sc->sc_sndstat_valid = 1;
-	}
+
 	/* try to search for a valid config */
 
 	for (x = channels; x; x--) {
@@ -1962,7 +2086,7 @@
 {
 	struct uaudio_chan *ch = usbd_xfer_softc(xfer);
 	struct usb_page_cache *pc;
-	uint64_t sample_rate = ch->usb_alt[ch->cur_alt].sample_rate;
+	uint64_t sample_rate;
 	uint8_t buf[4];
 	uint64_t temp;
 	int len;
@@ -2003,29 +2127,42 @@
 		if (temp == 0)
 			break;
 
-		/* correctly scale value */
+		temp *= 125ULL;
 
-		temp = (temp * 125ULL) - 64;
+		sample_rate = ch->usb_alt[ch->cur_alt].sample_rate;
 
 		/* auto adjust */
-
 		while (temp < (sample_rate - (sample_rate / 4)))
 			temp *= 2;
-
+ 
 		while (temp > (sample_rate + (sample_rate / 2)))
 			temp /= 2;
 
-		/* compare */
-
-		DPRINTF("Comparing %d < %d\n",
+		DPRINTF("Comparing %d Hz :: %d Hz\n",
 		    (int)temp, (int)sample_rate);
 
-		if (temp == sample_rate)
-			ch->last_sync_state = UAUDIO_SYNC_NONE;
-		else if (temp > sample_rate)
-			ch->last_sync_state = UAUDIO_SYNC_MORE;
-		else
-			ch->last_sync_state = UAUDIO_SYNC_LESS;
+		/*
+		 * Use feedback value as fallback when there is no
+		 * recording channel:
+		 */
+		if (ch->priv_sc->sc_rec_chan.num_alt == 0) {
+			int32_t jitter_max = howmany(sample_rate, 16000);
+
+			/*
+			 * Range check the jitter values to avoid
+			 * bogus sample rate adjustments. The expected
+			 * deviation should not be more than 1Hz per
+			 * second. The USB v2.0 specification also
+			 * mandates this requirement. Refer to chapter
+			 * 5.12.4.2 about feedback.
+			 */
+			ch->jitter_curr = temp - sample_rate;
+			if (ch->jitter_curr > jitter_max)
+				ch->jitter_curr = jitter_max;
+			else if (ch->jitter_curr < -jitter_max)
+				ch->jitter_curr = -jitter_max;
+		}
+		ch->feedback_rate = temp;
 		break;
 
 	case USB_ST_SETUP:
@@ -2039,30 +2176,58 @@
 	}
 }
 
+static int
+uaudio_chan_is_async(struct uaudio_chan *ch, uint8_t alt)
+{
+	uint8_t attr = ch->usb_alt[alt].p_ed1->bmAttributes;
+	return (UE_GET_ISO_TYPE(attr) == UE_ISO_ASYNC);
+}
+
 static void
 uaudio_chan_play_callback(struct usb_xfer *xfer, usb_error_t error)
 {
 	struct uaudio_chan *ch = usbd_xfer_softc(xfer);
+	struct uaudio_chan *ch_rec;
 	struct usb_page_cache *pc;
-	uint32_t sample_size = ch->usb_alt[ch->cur_alt].sample_size;
 	uint32_t mfl;
 	uint32_t total;
 	uint32_t blockcount;
 	uint32_t n;
 	uint32_t offset;
+	int sample_size;
 	int actlen;
 	int sumlen;
 
-	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
-
-	if (ch->end == ch->start) {
-		DPRINTF("no buffer!\n");
+	if (ch->running == 0 || ch->start == ch->end) {
+		DPRINTF("not running or no buffer!\n");
 		return;
 	}
 
+	/* check if there is a record channel */
+	if (ch->priv_sc->sc_rec_chan.num_alt > 0)
+		ch_rec = &ch->priv_sc->sc_rec_chan;
+	else
+		ch_rec = NULL;
+
+	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
+
 	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_SETUP:
+tr_setup:
+		if (ch_rec != NULL) {
+			/* reset receive jitter counters */
+			mtx_lock(ch_rec->pcm_mtx);
+			ch_rec->jitter_curr = 0;
+			ch_rec->jitter_rem = 0;
+			mtx_unlock(ch_rec->pcm_mtx);
+		}
+
+		/* reset transmit jitter counters */
+		ch->jitter_curr = 0;
+		ch->jitter_rem = 0;
+
+		/* FALLTHROUGH */
 	case USB_ST_TRANSFERRED:
-tr_transferred:
 		if (actlen < sumlen) {
 			DPRINTF("short transfer, "
 			    "%d of %d bytes\n", actlen, sumlen);
@@ -2069,11 +2234,41 @@
 		}
 		chn_intr(ch->pcm_ch);
 
-		/* start SYNC transfer, if any */
-		if ((ch->last_sync_time++ & 7) == 0)
+		/*
+		 * Check for asynchronous playback endpoint and that
+		 * the playback endpoint is properly configured:
+		 */
+		if (ch_rec != NULL &&
+		    uaudio_chan_is_async(ch, ch->cur_alt) != 0) {
+			mtx_lock(ch_rec->pcm_mtx);
+			if (ch_rec->cur_alt < ch_rec->num_alt) {
+				int64_t tx_jitter;
+				int64_t rx_rate;
+
+				/* translate receive jitter into transmit jitter */
+				tx_jitter = ch->usb_alt[ch->cur_alt].sample_rate;
+				tx_jitter = (tx_jitter * ch_rec->jitter_curr) +
+				    ch->jitter_rem;
+
+				/* reset receive jitter counters */
+				ch_rec->jitter_curr = 0;
+				ch_rec->jitter_rem = 0;
+		
+				/* compute exact number of transmit jitter samples */
+				rx_rate = ch_rec->usb_alt[ch_rec->cur_alt].sample_rate;
+				ch->jitter_curr += tx_jitter / rx_rate;
+				ch->jitter_rem = tx_jitter % rx_rate;
+			}
+			mtx_unlock(ch_rec->pcm_mtx);
+		}
+
+		/* start the SYNC transfer one time per second, if any */
+		ch->intr_counter += ch->intr_frames;
+		if (ch->intr_counter >= ch->frames_per_second) {
+			ch->intr_counter -= ch->frames_per_second;
 			usbd_transfer_start(ch->xfer[UAUDIO_NCHANBUFS]);
+		}
 
-	case USB_ST_SETUP:
 		mfl = usbd_xfer_max_framelen(xfer);
 
 		if (ch->bytes_per_frame[1] > mfl) {
@@ -2089,6 +2284,9 @@
 		/* setup number of frames */
 		usbd_xfer_set_frames(xfer, blockcount);
 
+		/* get sample size */
+		sample_size = ch->usb_alt[ch->cur_alt].sample_size;
+
 		/* reset total length */
 		total = 0;
 
@@ -2104,30 +2302,23 @@
 				frame_len = ch->bytes_per_frame[0];
 			}
 
-			if (n == (blockcount - 1)) {
-				switch (ch->last_sync_state) {
-				case UAUDIO_SYNC_MORE:
-					DPRINTFN(6, "sending one sample more\n");
-					if ((frame_len + sample_size) <= mfl)
-						frame_len += sample_size;
-					ch->last_sync_state = UAUDIO_SYNC_NONE;
-					break;
-				case UAUDIO_SYNC_LESS:
-					DPRINTFN(6, "sending one sample less\n");
-					if (frame_len >= sample_size)
-						frame_len -= sample_size;
-					ch->last_sync_state = UAUDIO_SYNC_NONE;
-					break;
-				default:
-					break;
-				}
+			/* handle free running clock case */
+			if (ch->jitter_curr > 0 &&
+			    (frame_len + sample_size) <= mfl) {
+				DPRINTFN(6, "sending one sample more\n");
+				ch->jitter_curr--;
+				frame_len += sample_size;
+			} else if (ch->jitter_curr < 0 &&
+			    frame_len >= sample_size) {
+				DPRINTFN(6, "sending one sample less\n");
+				ch->jitter_curr++;
+				frame_len -= sample_size;
 			}
-
 			usbd_xfer_set_frame_len(xfer, n, frame_len);
 			total += frame_len;
 		}
 
-		DPRINTFN(6, "transfer %d bytes\n", total);
+		DPRINTFN(6, "transferring %d bytes\n", total);
 
 		offset = 0;
 
@@ -2135,9 +2326,9 @@
 		while (total > 0) {
 
 			n = (ch->end - ch->cur);
-			if (n > total) {
+			if (n > total)
 				n = total;
-			}
+
 			usbd_copy_in(pc, offset, ch->cur, n);
 
 			total -= n;
@@ -2144,19 +2335,16 @@
 			ch->cur += n;
 			offset += n;
 
-			if (ch->cur >= ch->end) {
+			if (ch->cur >= ch->end)
 				ch->cur = ch->start;
-			}
 		}
-
 		usbd_transfer_submit(xfer);
 		break;
 
 	default:			/* Error */
-		if (error == USB_ERR_CANCELLED) {
-			break;
-		}
-		goto tr_transferred;
+		if (error != USB_ERR_CANCELLED)
+			goto tr_setup;
+		break;
 	}
 }
 
@@ -2172,7 +2360,6 @@
 	struct uaudio_chan *ch = usbd_xfer_softc(xfer);
 	struct usb_page_cache *pc;
 	uint32_t offset0;
-	uint32_t offset1;
 	uint32_t mfl;
 	int m;
 	int n;
@@ -2179,29 +2366,53 @@
 	int len;
 	int actlen;
 	int nframes;
-	int blockcount;
+	int expected_bytes;
+	int sample_size;
 
-	usbd_xfer_status(xfer, &actlen, NULL, NULL, &nframes);
-	mfl = usbd_xfer_max_framelen(xfer);
-
-	if (ch->end == ch->start) {
+	if (ch->start == ch->end) {
 		DPRINTF("no buffer!\n");
 		return;
 	}
 
+	usbd_xfer_status(xfer, &actlen, NULL, NULL, &nframes);
+	mfl = usbd_xfer_max_framelen(xfer);
+
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
 
-		DPRINTFN(6, "transferred %d bytes\n", actlen);
-
 		offset0 = 0;
 		pc = usbd_xfer_get_frame(xfer, 0);
 
+		/* try to compute the number of expected bytes */
+		ch->sample_curr += (ch->sample_rem * ch->intr_frames);
+
+		/* compute number of expected bytes */
+		expected_bytes = (ch->intr_frames * ch->bytes_per_frame[0]) +
+		    ((ch->sample_curr / ch->frames_per_second) *
+		    (ch->bytes_per_frame[1] - ch->bytes_per_frame[0]));
+
+		/* keep remainder */
+		ch->sample_curr %= ch->frames_per_second;
+
+		/* get current sample size */
+		sample_size = ch->usb_alt[ch->cur_alt].sample_size;
+
 		for (n = 0; n != nframes; n++) {
+			uint32_t offset1 = offset0;
 
-			offset1 = offset0;
 			len = usbd_xfer_frame_len(xfer, n);
 
+			/* make sure we only receive complete samples */
+			len = len - (len % sample_size);
+
+			/* subtract bytes received from expected payload */
+			expected_bytes -= len;
+
+			/* don't receive data when not ready */
+			if (ch->running == 0 || ch->cur_alt != ch->set_alt)
+				continue;
+
+			/* fill ring buffer with samples, if any */
 			while (len > 0) {
 
 				m = (ch->end - ch->cur);
@@ -2215,33 +2426,46 @@
 				offset1 += m;
 				ch->cur += m;
 
-				if (ch->cur >= ch->end) {
+				if (ch->cur >= ch->end)
 					ch->cur = ch->start;
-				}
 			}
 
 			offset0 += mfl;
 		}
 
-		chn_intr(ch->pcm_ch);
+		/* update current jitter */
+		ch->jitter_curr -= (expected_bytes / sample_size);
 
+		/* don't allow a huge amount of jitter to accumulate */
+		nframes = 2 * ch->intr_frames;
+
+		/* range check current jitter */
+		if (ch->jitter_curr < -nframes)
+			ch->jitter_curr = -nframes;
+		else if (ch->jitter_curr > nframes)
+			ch->jitter_curr = nframes;
+
+		DPRINTFN(6, "transferred %d bytes, jitter %d samples\n",
+		    actlen, ch->jitter_curr);
+
+		if (ch->running != 0)
+			chn_intr(ch->pcm_ch);
+
 	case USB_ST_SETUP:
 tr_setup:
-		blockcount = ch->intr_frames;
+		nframes = ch->intr_frames;
 
-		usbd_xfer_set_frames(xfer, blockcount);
-		for (n = 0; n < blockcount; n++) {
+		usbd_xfer_set_frames(xfer, nframes);
+		for (n = 0; n != nframes; n++)
 			usbd_xfer_set_frame_len(xfer, n, mfl);
-		}
 
 		usbd_transfer_submit(xfer);
 		break;
 
 	default:			/* Error */
-		if (error == USB_ERR_CANCELLED) {
-			break;
-		}
-		goto tr_setup;
+		if (error != USB_ERR_CANCELLED)
+			goto tr_setup;
+		break;
 	}
 }
 
@@ -2314,13 +2538,7 @@
 uaudio_chan_set_param_blocksize(struct uaudio_chan *ch, uint32_t blocksize)
 {
 	uint32_t temp = 2 * uaudio_get_buffer_size(ch, ch->set_alt);
-
 	sndbuf_setup(ch->pcm_buf, ch->buf, temp);
-
-	ch->start = ch->buf;
-	ch->end = ch->buf + temp;
-	ch->cur = ch->buf;
-
 	return (temp / 2);
 }
 
@@ -2334,8 +2552,11 @@
 int
 uaudio_chan_set_param_speed(struct uaudio_chan *ch, uint32_t speed)
 {
+	struct uaudio_softc *sc;
 	uint8_t x;
 
+	sc = ch->priv_sc;
+
 	for (x = 0; x < ch->num_alt; x++) {
 		if (ch->usb_alt[x].sample_rate < speed) {
 			/* sample rate is too low */
@@ -2346,7 +2567,9 @@
 	if (x != 0)
 		x--;
 
+	usb_proc_explore_lock(sc->sc_udev);
 	ch->set_alt = x;
+	usb_proc_explore_unlock(sc->sc_udev);
 
 	DPRINTF("Selecting alt %d\n", (int)x);
 
@@ -2417,16 +2640,16 @@
 	return (0);
 }
 
-int
-uaudio_chan_start(struct uaudio_chan *ch)
+static void
+uaudio_chan_start_sub(struct uaudio_chan *ch)
 {
 	struct uaudio_softc *sc = ch->priv_sc;
 	int do_start = 0;
 
-	usb_proc_explore_lock(sc->sc_udev);
 	if (ch->operation != CHAN_OP_DRAIN) {
 		if (ch->cur_alt == ch->set_alt &&
-		    ch->operation == CHAN_OP_NONE) {
+		    ch->operation == CHAN_OP_NONE &&
+		    mtx_owned(ch->pcm_mtx) != 0) {
 			/* save doing the explore task */
 			do_start = 1;
 		} else {
@@ -2435,25 +2658,81 @@
 			    &sc->sc_config_msg[0], &sc->sc_config_msg[1]);
 		}
 	}
-	usb_proc_explore_unlock(sc->sc_udev);
-
 	if (do_start) {
 		usbd_transfer_start(ch->xfer[0]);
 		usbd_transfer_start(ch->xfer[1]);
 	}
-	return (0);
 }
 
-int
-uaudio_chan_stop(struct uaudio_chan *ch)
+static int
+uaudio_chan_need_both(struct uaudio_softc *sc)
 {
+	return (sc->sc_play_chan.num_alt > 0 &&
+	    sc->sc_play_chan.running != 0 &&
+	    uaudio_chan_is_async(&sc->sc_play_chan,
+	    sc->sc_play_chan.set_alt) != 0 &&
+	    sc->sc_rec_chan.num_alt > 0 &&
+	    sc->sc_rec_chan.running == 0);
+}
+
+static int
+uaudio_chan_need_none(struct uaudio_softc *sc)
+{
+	return (sc->sc_play_chan.num_alt > 0 &&
+	    sc->sc_play_chan.running == 0 &&
+	    sc->sc_rec_chan.num_alt > 0 &&
+	    sc->sc_rec_chan.running == 0);
+}
+
+void
+uaudio_chan_start(struct uaudio_chan *ch)
+{
 	struct uaudio_softc *sc = ch->priv_sc;
+
+	/* make operation atomic */
+	usb_proc_explore_lock(sc->sc_udev);
+
+	/* check if not running */
+	if (ch->running == 0) {
+	  	uint32_t temp;
+
+		/* get current buffer size */
+		temp = 2 * uaudio_get_buffer_size(ch, ch->set_alt);
+
+		/* set running flag */
+		ch->running = 1;
+
+		/* ensure the hardware buffer is reset */
+		ch->start = ch->buf;
+		ch->end = ch->buf + temp;
+		ch->cur = ch->buf;
+
+		if (uaudio_chan_need_both(sc)) {
+			/*
+			 * Start both endpoints because of need for
+			 * jitter information:
+			 */
+			uaudio_chan_start_sub(&sc->sc_rec_chan);
+			uaudio_chan_start_sub(&sc->sc_play_chan);
+		} else {
+			uaudio_chan_start_sub(ch);
+		}
+	}
+
+	/* exit atomic operation */
+	usb_proc_explore_unlock(sc->sc_udev);
+}
+
+static void
+uaudio_chan_stop_sub(struct uaudio_chan *ch)
+{
+	struct uaudio_softc *sc = ch->priv_sc;
 	int do_stop = 0;
 
-	usb_proc_explore_lock(sc->sc_udev);
 	if (ch->operation != CHAN_OP_DRAIN) {
 		if (ch->cur_alt == ch->set_alt &&
-		    ch->operation == CHAN_OP_NONE) {
+		    ch->operation == CHAN_OP_NONE &&
+		    mtx_owned(ch->pcm_mtx) != 0) {
 			/* save doing the explore task */
 			do_stop = 1;
 		} else {
@@ -2462,15 +2741,46 @@
 			    &sc->sc_config_msg[0], &sc->sc_config_msg[1]);
 		}
 	}
-	usb_proc_explore_unlock(sc->sc_udev);
-
 	if (do_stop) {
 		usbd_transfer_stop(ch->xfer[0]);
 		usbd_transfer_stop(ch->xfer[1]);
 	}
-	return (0);
 }
 
+void
+uaudio_chan_stop(struct uaudio_chan *ch)
+{
+	struct uaudio_softc *sc = ch->priv_sc;
+
+	/* make operation atomic */
+	usb_proc_explore_lock(sc->sc_udev);
+
+	/* check if running */
+	if (ch->running != 0) {
+		/* clear running flag */
+		ch->running = 0;
+
+		if (uaudio_chan_need_both(sc)) {
+			/*
+			 * Leave the endpoints running because we need
+			 * information about jitter!
+			 */
+		} else if (uaudio_chan_need_none(sc)) {
+			/*
+			 * Stop both endpoints in case the one was used for
+			 * jitter information:
+			 */
+			uaudio_chan_stop_sub(&sc->sc_rec_chan);
+			uaudio_chan_stop_sub(&sc->sc_play_chan);
+		} else {
+			uaudio_chan_stop_sub(ch);
+		}
+	}
+
+	/* exit atomic operation */
+	usb_proc_explore_unlock(sc->sc_udev);
+}
+
 /*========================================================================*
  * AC - Audio Controller - routines
  *========================================================================*/
@@ -2737,7 +3047,7 @@
 
 		uaudio_mixer_add_ctl(sc, &MIX(sc));
 
-		MIX(sc).wValue[0] = MAKE_WORD(9, chy + 1);
+		MIX(sc).wValue[0] = MAKE_WORD(9, chy + 1 + 8);
 		MIX(sc).type = MIX_SIGNED_16;
 		MIX(sc).ctl = SOUND_MIXER_NRDEVICES;
 		MIX(sc).name = "effect_send";
@@ -2744,7 +3054,7 @@
 		MIX(sc).nchan = 1;
 		MIX(sc).update[0] = 1;
 		snprintf(MIX(sc).desc, sizeof(MIX(sc).desc),
-		    "Effect Send DIn%d Volume", chy + 1 + 8);
+		    "Effect Send DIn%d Volume", chy + 1);
 
 		uaudio_mixer_add_ctl(sc, &MIX(sc));
 	}
@@ -5232,8 +5542,7 @@
 			 */
 			sub = &chan->sub[cn];
 
-			if ((cmd_len != 0) &&
-			    (cn < chan->max_cable) &&
+			if ((cmd_len != 0) && (cn < chan->max_emb_jack) &&
 			    (sub->read_open != 0)) {
 
 				/* Send data to the application */
@@ -5469,7 +5778,7 @@
 			}
 
 			chan->curr_cable++;
-			if (chan->curr_cable >= chan->max_cable)
+			if (chan->curr_cable >= chan->max_emb_jack)
 				chan->curr_cable = 0;
 
 			if (chan->curr_cable == start_cable) {
@@ -5506,7 +5815,7 @@
 	struct umidi_sub_chan *sub;
 	uint32_t n;
 
-	for (n = 0; n < UMIDI_CABLES_MAX; n++) {
+	for (n = 0; n < UMIDI_EMB_JACK_MAX; n++) {
 		sub = &chan->sub[n];
 		if ((sub->fifo.fp[USB_FIFO_RX] == fifo) ||
 		    (sub->fifo.fp[USB_FIFO_TX] == fifo)) {
@@ -5552,7 +5861,16 @@
 {
 	struct umidi_chan *chan = usb_fifo_softc(fifo);
 
-	usbd_transfer_start(chan->xfer[UMIDI_TX_TRANSFER]);
+	if (chan->xfer[UMIDI_TX_TRANSFER] == NULL) {
+		uint8_t buf[1];
+		int actlen;
+		do {
+			/* dump data */
+			usb_fifo_get_data_linear(fifo, buf, 1, &actlen, 0);
+		} while (actlen > 0);
+	} else {
+		usbd_transfer_start(chan->xfer[UMIDI_TX_TRANSFER]);
+	}
 }
 
 static void
@@ -5670,13 +5988,38 @@
 		DPRINTF("error=%s\n", usbd_errstr(error));
 		goto detach;
 	}
-	if ((chan->max_cable > UMIDI_CABLES_MAX) ||
-	    (chan->max_cable == 0)) {
-		chan->max_cable = UMIDI_CABLES_MAX;
+	if (chan->xfer[UMIDI_TX_TRANSFER] == NULL &&
+	    chan->xfer[UMIDI_RX_TRANSFER] == NULL) {
+		DPRINTF("no BULK or INTERRUPT MIDI endpoint(s) found\n");
+		goto detach;
 	}
 
-	for (n = 0; n < chan->max_cable; n++) {
+	/*
+	 * Some USB MIDI device makers couldn't resist using
+	 * wMaxPacketSize = 4 for RX and TX BULK endpoints, although
+	 * that size is an unsupported value for FULL speed BULK
+	 * endpoints. The same applies to some HIGH speed MIDI devices
+	 * which are using a wMaxPacketSize different from 512 bytes.
+	 *
+	 * Refer to section 5.8.3 in USB 2.0 PDF: Cite: "All Host
+	 * Controllers are required to have support for 8-, 16-, 32-,
+	 * and 64-byte maximum packet sizes for full-speed bulk
+	 * endpoints and 512 bytes for high-speed bulk endpoints."
+	 */
+	if (chan->xfer[UMIDI_TX_TRANSFER] != NULL &&
+	    usbd_xfer_maxp_was_clamped(chan->xfer[UMIDI_TX_TRANSFER]))
+		chan->single_command = 1;
 
+	if (chan->single_command != 0)
+		device_printf(dev, "Single command MIDI quirk enabled\n");
+
+	if ((chan->max_emb_jack == 0) ||
+	    (chan->max_emb_jack > UMIDI_EMB_JACK_MAX)) {
+		chan->max_emb_jack = UMIDI_EMB_JACK_MAX;
+	}
+
+	for (n = 0; n < chan->max_emb_jack; n++) {
+
 		sub = &chan->sub[n];
 
 		error = usb_fifo_attach(sc->sc_udev, chan, &chan->mtx,
@@ -5713,9 +6056,8 @@
 	struct umidi_chan *chan = &sc->sc_midi_chan;
 	uint32_t n;
 
-	for (n = 0; n < UMIDI_CABLES_MAX; n++) {
+	for (n = 0; n < UMIDI_EMB_JACK_MAX; n++)
 		usb_fifo_detach(&chan->sub[n].fifo);
-	}
 
 	mtx_lock(&chan->mtx);
 
@@ -5894,7 +6236,7 @@
 	usbd_transfer_unsetup(sc->sc_hid.xfer, UAUDIO_HID_N_TRANSFER);
 }
 
-DRIVER_MODULE(uaudio, uhub, uaudio_driver, uaudio_devclass, NULL, 0);
+DRIVER_MODULE_ORDERED(uaudio, uhub, uaudio_driver, uaudio_devclass, NULL, 0, SI_ORDER_ANY);
 MODULE_DEPEND(uaudio, usb, 1, 1, 1);
 MODULE_DEPEND(uaudio, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
 MODULE_VERSION(uaudio, 1);

Modified: trunk/sys/dev/sound/usb/uaudio.h
===================================================================
--- trunk/sys/dev/sound/usb/uaudio.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/usb/uaudio.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/usb/uaudio.h 280591 2015-03-25 13:14:25Z hselasky $ */
 
 /*-
  * Copyright (c) 2000-2002 Hiroyuki Aizu <aizu at navi.org>
@@ -54,8 +55,8 @@
 		    uint32_t format);
 extern int	uaudio_chan_set_param_format(struct uaudio_chan *ch,
 		    uint32_t format);
-extern int	uaudio_chan_start(struct uaudio_chan *ch);
-extern int	uaudio_chan_stop(struct uaudio_chan *ch);
+extern void	uaudio_chan_start(struct uaudio_chan *ch);
+extern void	uaudio_chan_stop(struct uaudio_chan *ch);
 extern int	uaudio_mixer_init_sub(struct uaudio_softc *sc,
 		    struct snd_mixer *m);
 extern int	uaudio_mixer_uninit_sub(struct uaudio_softc *sc);

Modified: trunk/sys/dev/sound/usb/uaudio_pcm.c
===================================================================
--- trunk/sys/dev/sound/usb/uaudio_pcm.c	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/usb/uaudio_pcm.c	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,4 +1,5 @@
 /* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/usb/uaudio_pcm.c 280591 2015-03-25 13:14:25Z hselasky $ */
 
 /*-
  * Copyright (c) 2000-2002 Hiroyuki Aizu <aizu at navi.org>
@@ -81,14 +82,14 @@
 static int
 ua_chan_trigger(kobj_t obj, void *data, int go)
 {
-	if (!PCMTRIG_COMMON(go)) {
-		return (0);
+	if (PCMTRIG_COMMON(go)) {
+		if (go == PCMTRIG_START) {
+			uaudio_chan_start(data);
+		} else {
+			uaudio_chan_stop(data);
+		}
 	}
-	if (go == PCMTRIG_START) {
-		return (uaudio_chan_start(data));
-	} else {
-		return (uaudio_chan_stop(data));
-	}
+	return (0);
 }
 
 static uint32_t
@@ -227,7 +228,7 @@
 	DEVMETHOD(device_attach, ua_attach),
 	DEVMETHOD(device_detach, ua_detach),
 
-	{0, 0}
+	DEVMETHOD_END
 };
 
 static driver_t ua_pcm_driver = {

Modified: trunk/sys/dev/sound/usb/uaudioreg.h
===================================================================
--- trunk/sys/dev/sound/usb/uaudioreg.h	2018-05-27 23:04:23 UTC (rev 10064)
+++ trunk/sys/dev/sound/usb/uaudioreg.h	2018-05-27 23:06:34 UTC (rev 10065)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uaudioreg.h,v 1.12 2004/11/05 19:08:29 kent Exp $	*/
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/sound/usb/uaudioreg.h 272423 2014-10-02 16:57:44Z hselasky $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,6 +120,13 @@
 	uWord	wLockDelay;
 } __packed;
 
+struct usb_midi_streaming_endpoint_descriptor {
+	uByte	bLength;
+	uByte	bDescriptorType;
+	uByte	bDescriptorSubtype;
+	uByte	bNumEmbMIDIJack;
+} __packed;
+
 struct usb_audio_streaming_type1_descriptor {
 	uByte	bLength;
 	uByte	bDescriptorType;
@@ -378,6 +386,7 @@
 
 #define	MASTER_CHAN	0
 
+#define	MS_GENERAL	1
 #define	AS_GENERAL	1
 #define	FORMAT_TYPE	2
 #define	FORMAT_SPECIFIC 3



More information about the Midnightbsd-cvs mailing list