Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Merge isaki-audio2 branch, the overhaul of audio subsystem.



details:   https://anonhg.NetBSD.org/src/rev/254d039792c4
branches:  trunk
changeset: 451167:254d039792c4
user:      isaki <isaki%NetBSD.org@localhost>
date:      Wed May 08 13:40:13 2019 +0000

description:
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly.  Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism.  The encoding/channels/frequency
  conversions are completely handled in the upper layer.  So the hard-
  ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
  - Obsoletes query_encoding and add query_format instead.
  - Obsoletes set_params and add set_format instead.
  - Remove drain, setfd, mappage.
  - The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c         -> dev/audio/audio.c (rewritten)
- dev/audiovar.h      -> dev/audio/audiovar.h
- dev/audio_dai.h     -> dev/audio/audio_dai.h
- dev/audio_if.h      -> dev/audio/audio_if.h
- dev/audiobell.c     -> dev/audio/audiobell.c
- dev/audiobellvar.h  -> dev/audio/audiobellvar.h
- dev/mulaw.[ch]      -> dev/audio/mulaw.[ch] + dev/audio/alaw.c

diffstat:

 sys/arch/amiga/conf/files.amiga             |     6 +-
 sys/arch/amiga/dev/aucc.c                   |   580 +-
 sys/arch/amiga/dev/melody.c                 |     5 +-
 sys/arch/amiga/dev/repulse.c                |   416 +-
 sys/arch/amiga/dev/toccata.c                |    16 +-
 sys/arch/amigappc/conf/files.amigappc       |     6 +-
 sys/arch/arm/broadcom/bcm2835_vcaudio.c     |   119 +-
 sys/arch/arm/broadcom/files.bcm2835         |     4 +-
 sys/arch/arm/imx/imx23_digfilt.c            |    62 +-
 sys/arch/arm/iomd/files.iomd                |     4 +-
 sys/arch/arm/iomd/vidcaudio.c               |   205 +-
 sys/arch/arm/sunxi/files.sunxi              |     6 +-
 sys/arch/arm/sunxi/sun4i_a10_codec.c        |     6 +-
 sys/arch/arm/sunxi/sun50i_a64_acodec.c      |     6 +-
 sys/arch/arm/sunxi/sun6i_a31_codec.c        |     6 +-
 sys/arch/arm/sunxi/sun8i_codec.c            |    23 +-
 sys/arch/arm/sunxi/sun8i_h3_codec.c         |     6 +-
 sys/arch/arm/sunxi/sunxi_codec.c            |    91 +-
 sys/arch/arm/sunxi/sunxi_codec.h            |     6 +-
 sys/arch/arm/sunxi/sunxi_i2s.c              |   102 +-
 sys/arch/arm/xscale/files.pxa2x0            |     4 +-
 sys/arch/arm/xscale/pxa2x0_ac97.c           |   135 +-
 sys/arch/arm/xscale/pxa2x0_i2s.c            |    47 +-
 sys/arch/arm/xscale/pxa2x0_i2s.h            |     5 +-
 sys/arch/dreamcast/conf/files.dreamcast     |     4 +-
 sys/arch/dreamcast/dev/g2/aica.c            |   101 +-
 sys/arch/evbarm/conf/files.mini2440         |     4 +-
 sys/arch/evbarm/mini2440/audio_mini2440.c   |   103 +-
 sys/arch/hp300/dev/arcofi_dio.c             |     9 +-
 sys/arch/hpcmips/vr/vraiu.c                 |   551 +-
 sys/arch/hppa/conf/files.hppa               |     6 +-
 sys/arch/hppa/gsc/harmony.c                 |   217 +-
 sys/arch/hppa/gsc/harmonyvar.h              |     5 +-
 sys/arch/i386/pnpbios/ess_pnpbios.c         |     7 +-
 sys/arch/i386/pnpbios/sb_pnpbios.c          |     7 +-
 sys/arch/i386/pnpbios/wss_pnpbios.c         |     6 +-
 sys/arch/i386/pnpbios/ym_pnpbios.c          |     7 +-
 sys/arch/ibmnws/conf/files.ibmnws           |     4 +-
 sys/arch/macppc/conf/files.macppc           |     6 +-
 sys/arch/macppc/dev/awacs.c                 |   190 +-
 sys/arch/macppc/dev/snapper.c               |   327 +-
 sys/arch/mips/conf/files.alchemy            |     4 +-
 sys/arch/prep/conf/files.prep               |     4 +-
 sys/arch/prep/isa/paud_isa.c                |    11 +-
 sys/arch/sgimips/hpc/files.hpc              |     4 +-
 sys/arch/sgimips/hpc/haltwo.c               |   122 +-
 sys/arch/sgimips/mace/files.mace            |     4 +-
 sys/arch/sgimips/mace/mavb.c                |   229 +-
 sys/arch/sparc/conf/GENERIC                 |     5 +-
 sys/arch/sparc/conf/TADPOLE3GX              |     3 +-
 sys/arch/sparc/dev/audioamd.c               |    14 +-
 sys/arch/usermode/conf/files.usermode       |     4 +-
 sys/arch/usermode/dev/vaudio.c              |   105 +-
 sys/arch/usermode/include/thunk.h           |     3 +-
 sys/arch/usermode/usermode/thunk.c          |    10 +-
 sys/arch/vax/vsa/vsaudio.c                  |    66 +-
 sys/arch/x68k/conf/files.x68k               |     4 +-
 sys/arch/x68k/dev/vs.c                      |   209 +-
 sys/arch/x68k/dev/vsvar.h                   |     4 +-
 sys/arch/zaurus/conf/files.zaurus           |     4 +-
 sys/arch/zaurus/dev/wm8731_zaudio.c         |   149 +-
 sys/arch/zaurus/dev/wm8750_zaudio.c         |   182 +-
 sys/arch/zaurus/dev/zaudio.c                |    54 +-
 sys/arch/zaurus/dev/zaudiovar.h             |     7 +-
 sys/dev/DEVNAMES                            |     5 +-
 sys/dev/acpi/wss_acpi.c                     |     6 +-
 sys/dev/acpi/ym_acpi.c                      |     6 +-
 sys/dev/auconv.c                            |  2503 -------
 sys/dev/auconv.h                            |   179 -
 sys/dev/audio.c                             |  6405 --------------------
 sys/dev/audio/alaw.c                        |   168 +
 sys/dev/audio/audio.c                       |  8605 +++++++++++++++++++++++++++
 sys/dev/audio/audio_dai.h                   |   291 +
 sys/dev/audio/audio_if.h                    |   178 +
 sys/dev/audio/audiobell.c                   |   149 +
 sys/dev/audio/audiobellvar.h                |    41 +
 sys/dev/audio/audiodef.h                    |   423 +
 sys/dev/audio/audiofil.h                    |   109 +
 sys/dev/audio/audiovar.h                    |   327 +
 sys/dev/audio/linear.c                      |   406 +
 sys/dev/audio/linear.h                      |    43 +
 sys/dev/audio/mulaw.c                       |   293 +
 sys/dev/audio/mulaw.h                       |    39 +
 sys/dev/audio_dai.h                         |   307 -
 sys/dev/audio_if.h                          |   285 -
 sys/dev/audiobell.c                         |   185 -
 sys/dev/audiobelldata.h                     |   285 -
 sys/dev/audiobellvar.h                      |    41 -
 sys/dev/audiovar.h                          |   299 -
 sys/dev/aurateconv.c                        |   473 -
 sys/dev/auvolconv.c                         |    98 -
 sys/dev/auvolconv.h                         |    42 -
 sys/dev/bluetooth/btsco.c                   |    97 +-
 sys/dev/bluetooth/files.bluetooth           |     4 +-
 sys/dev/ebus/cs4231_ebus.c                  |    10 +-
 sys/dev/fdt/ausoc.c                         |    48 +-
 sys/dev/fdt/fdtvar.h                        |     4 +-
 sys/dev/files.audio                         |    22 +-
 sys/dev/hdaudio/files.hdaudio               |     4 +-
 sys/dev/hdaudio/hdafg.c                     |   122 +-
 sys/dev/hdaudio/hdaudiovar.h                |     4 +-
 sys/dev/ic/ac97.c                           |     6 +-
 sys/dev/ic/ad1848.c                         |   216 +-
 sys/dev/ic/ad1848var.h                      |    11 +-
 sys/dev/ic/am7930.c                         |   114 +-
 sys/dev/ic/am7930var.h                      |    13 +-
 sys/dev/ic/arcofi.c                         |   337 +-
 sys/dev/ic/arcofivar.h                      |     7 +-
 sys/dev/ic/cs4231.c                         |     6 +-
 sys/dev/ic/interwave.c                      |   165 +-
 sys/dev/ic/interwavevar.h                   |    14 +-
 sys/dev/ic/msm6258.c                        |   333 +-
 sys/dev/ic/msm6258var.h                     |    16 +-
 sys/dev/ic/opl.c                            |     6 +-
 sys/dev/ic/pl041.c                          |    42 +-
 sys/dev/ic/pl041var.h                       |     5 +-
 sys/dev/ic/tms320av110.c                    |   205 +-
 sys/dev/ic/tms320av110var.h                 |     5 +-
 sys/dev/ic/uda1341.c                        |    68 +-
 sys/dev/ic/uda1341var.h                     |    10 +-
 sys/dev/isa/ad1848_isa.c                    |    13 +-
 sys/dev/isa/ad1848var.h                     |     3 +-
 sys/dev/isa/aria.c                          |   191 +-
 sys/dev/isa/cms.c                           |     7 +-
 sys/dev/isa/ess.c                           |   205 +-
 sys/dev/isa/files.isa                       |    16 +-
 sys/dev/isa/gus.c                           |   179 +-
 sys/dev/isa/ics2101.c                       |     6 +-
 sys/dev/isa/joy_ess.c                       |     6 +-
 sys/dev/isa/midi_pcppi.c                    |     6 +-
 sys/dev/isa/mpu_sb.c                        |     6 +-
 sys/dev/isa/mpu_ym.c                        |     6 +-
 sys/dev/isa/opl_ess.c                       |     6 +-
 sys/dev/isa/opl_isa.c                       |     6 +-
 sys/dev/isa/opl_sb.c                        |     6 +-
 sys/dev/isa/opl_wss.c                       |     6 +-
 sys/dev/isa/opl_ym.c                        |     6 +-
 sys/dev/isa/pas.c                           |    11 +-
 sys/dev/isa/sb.c                            |    11 +-
 sys/dev/isa/sb_isa.c                        |     7 +-
 sys/dev/isa/sbdsp.c                         |   617 +-
 sys/dev/isa/sbdspvar.h                      |    14 +-
 sys/dev/isa/wss.c                           |    11 +-
 sys/dev/isa/wss_isa.c                       |     6 +-
 sys/dev/isa/ym.c                            |    11 +-
 sys/dev/isapnp/ess_isapnp.c                 |     7 +-
 sys/dev/isapnp/gus_isapnp.c                 |    14 +-
 sys/dev/isapnp/mpu_isapnp.c                 |     7 +-
 sys/dev/isapnp/sb_isapnp.c                  |     7 +-
 sys/dev/isapnp/wss_isapnp.c                 |     6 +-
 sys/dev/isapnp/ym_isapnp.c                  |     6 +-
 sys/dev/midi.c                              |     6 +-
 sys/dev/midisyn.c                           |     6 +-
 sys/dev/mulaw.c                             |   702 --
 sys/dev/mulaw.h                             |    69 -
 sys/dev/ofisa/ess_ofisa.c                   |     7 +-
 sys/dev/ofisa/sb_ofisa.c                    |     7 +-
 sys/dev/pad/files.pad                       |     4 +-
 sys/dev/pad/pad.c                           |   327 +-
 sys/dev/pad/padvar.h                        |    14 +-
 sys/dev/pci/auacer.c                        |   111 +-
 sys/dev/pci/auich.c                         |   146 +-
 sys/dev/pci/auixp.c                         |   122 +-
 sys/dev/pci/auixpvar.h                      |    16 +-
 sys/dev/pci/autri.c                         |   156 +-
 sys/dev/pci/auvia.c                         |   188 +-
 sys/dev/pci/auviavar.h                      |     6 +-
 sys/dev/pci/azalia.c                        |    53 +-
 sys/dev/pci/azalia.h                        |     3 +-
 sys/dev/pci/cmpci.c                         |   137 +-
 sys/dev/pci/cs4280.c                        |   271 +-
 sys/dev/pci/cs4280reg.h                     |    10 +-
 sys/dev/pci/cs4281.c                        |   173 +-
 sys/dev/pci/cs428x.c                        |    31 +-
 sys/dev/pci/cs428x.h                        |     4 +-
 sys/dev/pci/eap.c                           |   230 +-
 sys/dev/pci/emuxki.c                        |  2954 ++------
 sys/dev/pci/emuxkivar.h                     |   263 -
 sys/dev/pci/esa.c                           |   149 +-
 sys/dev/pci/esm.c                           |   142 +-
 sys/dev/pci/esmvar.h                        |    10 +-
 sys/dev/pci/eso.c                           |   200 +-
 sys/dev/pci/esoreg.h                        |     4 +-
 sys/dev/pci/files.pci                       |    40 +-
 sys/dev/pci/fms.c                           |   214 +-
 sys/dev/pci/gcscaudio.c                     |   188 +-
 sys/dev/pci/igma/files.igma                 |     2 +-
 sys/dev/pci/joy_eap.c                       |     6 +-
 sys/dev/pci/joy_eso.c                       |     6 +-
 sys/dev/pci/mpu_cmpci.c                     |     6 +-
 sys/dev/pci/mpu_eso.c                       |     6 +-
 sys/dev/pci/mpu_fms.c                       |     6 +-
 sys/dev/pci/mpu_yds.c                       |     6 +-
 sys/dev/pci/neo.c                           |   193 +-
 sys/dev/pci/opl_cmpci.c                     |     6 +-
 sys/dev/pci/opl_eso.c                       |     6 +-
 sys/dev/pci/opl_fms.c                       |     6 +-
 sys/dev/pci/opl_sv.c                        |     6 +-
 sys/dev/pci/opl_yds.c                       |     6 +-
 sys/dev/pci/sv.c                            |   166 +-
 sys/dev/pci/voyager/files.voyager           |     2 +-
 sys/dev/pci/yds.c                           |    88 +-
 sys/dev/pci/ydsvar.h                        |     4 +-
 sys/dev/sbus/cs4231_sbus.c                  |    10 +-
 sys/dev/sbus/dbri.c                         |   268 +-
 sys/dev/sbus/dbrivar.h                      |     5 +-
 sys/dev/sbus/files.sbus                     |     6 +-
 sys/dev/spkr_audio.c                        |     9 +-
 sys/dev/tc/bba.c                            |   120 +-
 sys/dev/tc/files.tc                         |     4 +-
 sys/dev/usb/files.usb                       |     4 +-
 sys/dev/usb/uaudio.c                        |   159 +-
 sys/dev/usb/umidi.c                         |     5 +-
 sys/dev/usb/umidi_quirks.c                  |     6 +-
 sys/modules/audio/Makefile                  |    11 +-
 sys/modules/spkr/Makefile                   |    11 +-
 sys/rump/dev/lib/libaudio/Makefile          |     8 +-
 sys/rump/dev/lib/libaudio/audio_component.c |     6 +-
 sys/rump/dev/lib/libaudio/aurateconv.h      |     3 -
 sys/rump/dev/lib/libaudio/mulaw.h           |     3 -
 sys/sys/audioio.h                           |   106 +-
 sys/sys/file.h                              |     4 +-
 222 files changed, 15185 insertions(+), 23162 deletions(-)

diffs (truncated from 47545 to 300 lines):

diff -r 1f3f5bd2ced1 -r 254d039792c4 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Wed May 08 13:18:47 2019 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Wed May 08 13:40:13 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.181 2018/12/19 13:57:45 maxv Exp $
+#      $NetBSD: files.amiga,v 1.182 2019/05/08 13:40:13 isaki Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -118,11 +118,11 @@
 attach melody at zbus
 file   arch/amiga/dev/melody.c         melody
 
-device repulse: audiobus, ac97, mulaw
+device repulse: audiobus, ac97
 attach repulse at zbus
 file   arch/amiga/dev/repulse.c        repulse
 
-device toccata: audiobus, ad1848, auconv
+device toccata: audiobus, ad1848
 attach toccata at zbus
 file   arch/amiga/dev/toccata.c        toccata
 
diff -r 1f3f5bd2ced1 -r 254d039792c4 sys/arch/amiga/dev/aucc.c
--- a/sys/arch/amiga/dev/aucc.c Wed May 08 13:18:47 2019 +0000
+++ b/sys/arch/amiga/dev/aucc.c Wed May 08 13:40:13 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aucc.c,v 1.44 2019/03/16 12:09:56 isaki Exp $ */
+/*     $NetBSD: aucc.c,v 1.45 2019/05/08 13:40:14 isaki Exp $ */
 
 /*
  * Copyright (c) 1999 Bernardo Innocenti
@@ -35,14 +35,7 @@
 
 /* TODO:
  *
- * - mu-law -> 14bit conversion
  * - channel allocation is wrong for 14bit mono
- * - convert the... err... conversion routines to 68k asm for best performance
- *     XXX: NO. aucc audio is limited by chipmem speed, anyway. You dont
- *     want to make life difficult for amigappc work.
- *             -is
- *
- * - rely on auconv.c routines for mu-law/A-law conversions
  * - perhaps use a calibration table for better 14bit output
  * - set 31 kHz AGA video mode to allow 44.1 kHz even if grfcc is missing
  *     in the kernel
@@ -53,7 +46,7 @@
 #if NAUCC > 0
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.44 2019/03/16 12:09:56 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.45 2019/05/08 13:40:14 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -64,7 +57,9 @@
 #include <machine/cpu.h>
 
 #include <sys/audioio.h>
-#include <dev/audio_if.h>
+#include <dev/audio/audio_if.h>
+#include <dev/audio/audiovar.h>        /* for AUDIO_MIN_FREQUENCY */
+
 #include <amiga/amiga/cc.h>
 #include <amiga/amiga/custom.h>
 #include <amiga/amiga/device.h>
@@ -103,7 +98,6 @@
  * Software state.
  */
 struct aucc_softc {
-       int     sc_open;                /* single use device */
        aucc_data_t sc_channel[4];      /* per channel freq, ... */
        u_int   sc_encoding;            /* encoding AUDIO_ENCODING_.*/
        int     sc_channels;            /* # of channels used */
@@ -144,48 +138,13 @@
 struct aucc_softc *aucc = NULL;
 
 
-unsigned char mulaw_to_lin[] = {
-       0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
-       0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
-       0xc1, 0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf,
-       0xd1, 0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf,
-       0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
-       0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
-       0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf3, 0xf3, 0xf4,
-       0xf4, 0xf5, 0xf5, 0xf6, 0xf6, 0xf7, 0xf7, 0xf8,
-       0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa,
-       0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc,
-       0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd,
-       0xfd, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe,
-       0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
-       0x7d, 0x79, 0x75, 0x71, 0x6d, 0x69, 0x65, 0x61,
-       0x5d, 0x59, 0x55, 0x51, 0x4d, 0x49, 0x45, 0x41,
-       0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30,
-       0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,
-       0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17,
-       0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f,
-       0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b,
-       0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07,
-       0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05,
-       0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,
-       0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02,
-       0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01,
-       0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
 /*
  * Define our interface to the higher level audio driver.
  */
 int    aucc_open(void *, int);
 void   aucc_close(void *);
 int    aucc_set_out_sr(void *, u_int);
-int    aucc_query_encoding(void *, struct audio_encoding *);
+int    aucc_query_format(void *, audio_format_query_t *);
 int    aucc_round_blocksize(void *, int, int, const audio_params_t *);
 int    aucc_commit_settings(void *);
 int    aucc_start_output(void *, void *, int, void (*)(void *), void *);
@@ -197,44 +156,24 @@
 int    aucc_get_port(void *, mixer_ctrl_t *);
 int    aucc_query_devinfo(void *, mixer_devinfo_t *);
 void   aucc_encode(int, int, int, int, u_char *, u_short **);
-int    aucc_set_params(void *, int, int, audio_params_t *, audio_params_t *,
-                       stream_filter_list_t *, stream_filter_list_t *);
+int    aucc_set_format(void *, int,
+                       const audio_params_t *, const audio_params_t *,
+                       audio_filter_reg_t *, audio_filter_reg_t *);
 int    aucc_get_props(void *);
 void   aucc_get_locks(void *, kmutex_t **, kmutex_t **);
 
 
-static void aucc_decode_slinear8_1ch(u_char **, u_char *, int);
-static void aucc_decode_slinear8_2ch(u_char **, u_char *, int);
-static void aucc_decode_slinear8_3ch(u_char **, u_char *, int);
-static void aucc_decode_slinear8_4ch(u_char **, u_char *, int);
-
-static void aucc_decode_ulinear8_1ch(u_char **, u_char *, int);
-static void aucc_decode_ulinear8_2ch(u_char **, u_char *, int);
-static void aucc_decode_ulinear8_3ch(u_char **, u_char *, int);
-static void aucc_decode_ulinear8_4ch(u_char **, u_char *, int);
-
-static void aucc_decode_mulaw_1ch(u_char **, u_char *, int);
-static void aucc_decode_mulaw_2ch(u_char **, u_char *, int);
-static void aucc_decode_mulaw_3ch(u_char **, u_char *, int);
-static void aucc_decode_mulaw_4ch(u_char **, u_char *, int);
-
 static void aucc_decode_slinear16_1ch(u_char **, u_char *, int);
 static void aucc_decode_slinear16_2ch(u_char **, u_char *, int);
 static void aucc_decode_slinear16_3ch(u_char **, u_char *, int);
 static void aucc_decode_slinear16_4ch(u_char **, u_char *, int);
 
-static void aucc_decode_slinear16sw_1ch(u_char **, u_char *, int);
-static void aucc_decode_slinear16sw_2ch(u_char **, u_char *, int);
-static void aucc_decode_slinear16sw_3ch(u_char **, u_char *, int);
-static void aucc_decode_slinear16sw_4ch(u_char **, u_char *, int);
-
-
 
 const struct audio_hw_if sa_hw_if = {
        .open                   = aucc_open,
        .close                  = aucc_close,
-       .query_encoding         = aucc_query_encoding,
-       .set_params             = aucc_set_params,
+       .query_format           = aucc_query_format,
+       .set_format             = aucc_set_format,
        .round_blocksize        = aucc_round_blocksize,
        .commit_settings        = aucc_commit_settings,
        .start_output           = aucc_start_output,
@@ -249,6 +188,35 @@
        .get_locks              = aucc_get_locks,
 };
 
+/*
+ * XXX *1 How lower limit of frequency should be?  same as audio(4)?
+ * XXX *2 Should avoid a magic number at the upper limit of frequency.
+ * XXX *3 In fact, there is a number in this range that have minimal errors.
+ *        It would be better if there is a mechanism which such frequency
+ *        is prioritized.
+ * XXX *4 3/4ch modes use 8bits, 1/2ch modes use 14bits,
+ *        so I imagined that 1/2ch modes are better.
+ */
+#define AUCC_FORMAT(prio, ch, chmask) \
+       { \
+               .mode           = AUMODE_PLAY, \
+               .priority       = (prio), \
+               .encoding       = AUDIO_ENCODING_SLINEAR_BE, \
+               .validbits      = 16, \
+               .precision      = 16, \
+               .channels       = (ch), \
+               .channel_mask   = (chmask), \
+               .frequency_type = 0, \
+               .frequency      = { AUDIO_MIN_FREQUENCY, 28867 }, \
+       }
+static const struct audio_format aucc_formats[] = {
+       AUCC_FORMAT(1, 1, AUFMT_MONAURAL),
+       AUCC_FORMAT(1, 2, AUFMT_STEREO),
+       AUCC_FORMAT(0, 3, AUFMT_UNKNOWN_POSITION),
+       AUCC_FORMAT(0, 4, AUFMT_UNKNOWN_POSITION),
+};
+#define AUCC_NFORMATS __arraycount(aucc_formats)
+
 /* autoconfig routines */
 
 int
@@ -319,10 +287,10 @@
 
        sc->sc_channels = 1;
        sc->sc_channelmask = 0xf;
-       sc->sc_precision = 8;
-       sc->sc_14bit = 0;
-       sc->sc_encoding = AUDIO_ENCODING_ULAW;
-       sc->sc_decodefunc = aucc_decode_mulaw_1ch;
+       sc->sc_precision = 16;
+       sc->sc_14bit = 1;
+       sc->sc_encoding = AUDIO_ENCODING_SLINEAR_BE;
+       sc->sc_decodefunc = aucc_decode_slinear16_2ch;
 
        /* clear interrupts and DMA: */
        custom.intena = AUCC_ALLINTF;
@@ -343,9 +311,6 @@
        sc = addr;
        DPRINTF(("sa_open: unit %p\n",sc));
 
-       if (sc->sc_open)
-               return EBUSY;
-       sc->sc_open = 1;
        for (i = 0; i < AUCC_MAXINT; i++) {
                sc->sc_channel[i].nd_intr = NULL;
                sc->sc_channel[i].nd_intrdata = NULL;
@@ -361,15 +326,6 @@
 void
 aucc_close(void *addr)
 {
-       struct aucc_softc *sc;
-
-       sc = addr;
-       DPRINTF(("sa_close: sc=%p\n", sc));
-       /*
-        * halt i/o, clear open flag, and done.
-        */
-       aucc_halt_output(sc);
-       sc->sc_open = 0;
 
        DPRINTF(("sa_close: closed.\n"));
 }
@@ -396,196 +352,41 @@
 }
 
 int
-aucc_query_encoding(void *addr, struct audio_encoding *fp)
+aucc_query_format(void *addr, audio_format_query_t *afp)
 {
 
-       switch (fp->index) {
-       case 0:
-               strcpy(fp->name, AudioEslinear);
-               fp->encoding = AUDIO_ENCODING_SLINEAR;
-               fp->precision = 8;
-               fp->flags = 0;
-               break;
-       case 1:
-               strcpy(fp->name, AudioEmulaw);
-               fp->encoding = AUDIO_ENCODING_ULAW;
-               fp->precision = 8;
-               fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-
-       case 2:
-               strcpy(fp->name, AudioEulinear);
-               fp->encoding = AUDIO_ENCODING_ULINEAR;
-               fp->precision = 8;
-               fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-
-       case 3:
-               strcpy(fp->name, AudioEslinear);
-               fp->encoding = AUDIO_ENCODING_SLINEAR;
-               fp->precision = 16;
-               fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-
-       case 4:
-               strcpy(fp->name, AudioEslinear_be);
-               fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
-               fp->precision = 16;
-               fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-               break;
-
-       case 5:
-               strcpy(fp->name, AudioEslinear_le);
-               fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
-               fp->precision = 16;
-               fp->flags = AUDIO_ENCODINGFLAG_EMULATED;



Home | Main Index | Thread Index | Old Index