History log of /openbsd-current/sys/dev/isa/ad1848.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.50 28-May-2024 jsg

remove unused isa/cs4231var.h


# 1.49 13-Apr-2024 jsg

correct indentation

no functional change, found by smatch warnings
ok miod@ bluhm@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.48 28-Oct-2022 kn

Replace audio(9) get_props() with duplex check in open() in partial duplex drivers

Make drivers which do *not* adverise AUDIO_PROP_FULLDPLEX return ENXIO
in their open() if full-duplex mode was requested.

This way, sys/dev/audio.c:audio_open() will fail immediately rather than
later through the to-be-removed get_props() check.

This is the first round for drivers with logic in their get_props(), i.e.
those that only support full-duplex mode for specific hardware:

ess(4), gus(4), pas(4) and sb(4)

All of these are i386/GENERIC only and share code through
sys/dev/isa/{ad1848,sbdsp}{.c,var.h} which are not used by any other kernel.

i386/GENERIC.MP builds and boots with this diff.
OK ratchov miod


# 1.47 18-Oct-2022 kn

Remove unused AUDIO_PROP_{MMAP,INDEPENDENT}

AUDIO_PROP_FULLDUPLEX is the only audio(9) in use, the other two died with
commit 1cf2860827c8ca659d8097d8da94a5ae5b888c53
Author: ratchov <ratchov@openbsd.org>
Date: Thu Jun 25 06:43:45 2015 +0000

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.

but remained defined and set in drivers.

and the following merely moved them when they were dead code already:

commit 9215aa3dfad387bca877a805534df6dcfe8722eb
Author: ratchov <ratchov@openbsd.org>
Date: Wed Aug 31 07:22:43 2016 +0000

Delete unused ioctls and associated macros. Move macros that are still
used internally by low-level drivers from sys/audioio.h to
dev/audio_if.h instead of deleting them.

None of this is used in base or ports; codesearch.debian.net only shows
AUDIO_PROP_{CAPTURE,PLAYBACK} in firefox-esr, mozjs and cubeb.

ratchov points out that audio_if.h and audioio.h are private interfaces
and the codesearch shows SunOS and NetBSD bits (#ifdef'd out on OpenBSD).

OK ratchov


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.46 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.49 13-Apr-2024 jsg

correct indentation

no functional change, found by smatch warnings
ok miod@ bluhm@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.48 28-Oct-2022 kn

Replace audio(9) get_props() with duplex check in open() in partial duplex drivers

Make drivers which do *not* adverise AUDIO_PROP_FULLDPLEX return ENXIO
in their open() if full-duplex mode was requested.

This way, sys/dev/audio.c:audio_open() will fail immediately rather than
later through the to-be-removed get_props() check.

This is the first round for drivers with logic in their get_props(), i.e.
those that only support full-duplex mode for specific hardware:

ess(4), gus(4), pas(4) and sb(4)

All of these are i386/GENERIC only and share code through
sys/dev/isa/{ad1848,sbdsp}{.c,var.h} which are not used by any other kernel.

i386/GENERIC.MP builds and boots with this diff.
OK ratchov miod


# 1.47 18-Oct-2022 kn

Remove unused AUDIO_PROP_{MMAP,INDEPENDENT}

AUDIO_PROP_FULLDUPLEX is the only audio(9) in use, the other two died with
commit 1cf2860827c8ca659d8097d8da94a5ae5b888c53
Author: ratchov <ratchov@openbsd.org>
Date: Thu Jun 25 06:43:45 2015 +0000

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.

but remained defined and set in drivers.

and the following merely moved them when they were dead code already:

commit 9215aa3dfad387bca877a805534df6dcfe8722eb
Author: ratchov <ratchov@openbsd.org>
Date: Wed Aug 31 07:22:43 2016 +0000

Delete unused ioctls and associated macros. Move macros that are still
used internally by low-level drivers from sys/audioio.h to
dev/audio_if.h instead of deleting them.

None of this is used in base or ports; codesearch.debian.net only shows
AUDIO_PROP_{CAPTURE,PLAYBACK} in firefox-esr, mozjs and cubeb.

ratchov points out that audio_if.h and audioio.h are private interfaces
and the codesearch shows SunOS and NetBSD bits (#ifdef'd out on OpenBSD).

OK ratchov


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.46 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.48 28-Oct-2022 kn

Replace audio(9) get_props() with duplex check in open() in partial duplex drivers

Make drivers which do *not* adverise AUDIO_PROP_FULLDPLEX return ENXIO
in their open() if full-duplex mode was requested.

This way, sys/dev/audio.c:audio_open() will fail immediately rather than
later through the to-be-removed get_props() check.

This is the first round for drivers with logic in their get_props(), i.e.
those that only support full-duplex mode for specific hardware:

ess(4), gus(4), pas(4) and sb(4)

All of these are i386/GENERIC only and share code through
sys/dev/isa/{ad1848,sbdsp}{.c,var.h} which are not used by any other kernel.

i386/GENERIC.MP builds and boots with this diff.
OK ratchov miod


# 1.47 18-Oct-2022 kn

Remove unused AUDIO_PROP_{MMAP,INDEPENDENT}

AUDIO_PROP_FULLDUPLEX is the only audio(9) in use, the other two died with
commit 1cf2860827c8ca659d8097d8da94a5ae5b888c53
Author: ratchov <ratchov@openbsd.org>
Date: Thu Jun 25 06:43:45 2015 +0000

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.

but remained defined and set in drivers.

and the following merely moved them when they were dead code already:

commit 9215aa3dfad387bca877a805534df6dcfe8722eb
Author: ratchov <ratchov@openbsd.org>
Date: Wed Aug 31 07:22:43 2016 +0000

Delete unused ioctls and associated macros. Move macros that are still
used internally by low-level drivers from sys/audioio.h to
dev/audio_if.h instead of deleting them.

None of this is used in base or ports; codesearch.debian.net only shows
AUDIO_PROP_{CAPTURE,PLAYBACK} in firefox-esr, mozjs and cubeb.

ratchov points out that audio_if.h and audioio.h are private interfaces
and the codesearch shows SunOS and NetBSD bits (#ifdef'd out on OpenBSD).

OK ratchov


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.46 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.47 18-Oct-2022 kn

Remove unused AUDIO_PROP_{MMAP,INDEPENDENT}

AUDIO_PROP_FULLDUPLEX is the only audio(9) in use, the other two died with
commit 1cf2860827c8ca659d8097d8da94a5ae5b888c53
Author: ratchov <ratchov@openbsd.org>
Date: Thu Jun 25 06:43:45 2015 +0000

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.

but remained defined and set in drivers.

and the following merely moved them when they were dead code already:

commit 9215aa3dfad387bca877a805534df6dcfe8722eb
Author: ratchov <ratchov@openbsd.org>
Date: Wed Aug 31 07:22:43 2016 +0000

Delete unused ioctls and associated macros. Move macros that are still
used internally by low-level drivers from sys/audioio.h to
dev/audio_if.h instead of deleting them.

None of this is used in base or ports; codesearch.debian.net only shows
AUDIO_PROP_{CAPTURE,PLAYBACK} in firefox-esr, mozjs and cubeb.

ratchov points out that audio_if.h and audioio.h are private interfaces
and the codesearch shows SunOS and NetBSD bits (#ifdef'd out on OpenBSD).

OK ratchov


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.46 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.46 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.45 14-Sep-2016 ratchov

Remove drain(), query_encoding(), mappage() and get_default_params()
methods from all audio drivers and from the audio_if structure as they
are never called.


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.44 25-Jun-2015 ratchov

Reimplement the audio driver in a simpler way, removing unused/unusable
functionality. Same API and ABI except for the removed bits and no
behaviour change for programs using libsndio. With help from armani@
and mpi@, thanks.


# 1.43 11-May-2015 ratchov

Remove support for ADPCM encoding which isn't used nowadays and
not available to programs anyway.


# 1.42 11-May-2015 ratchov

Remove all audio format conversion code from the kernel (btw holding
the kernel_lock), as we already do better conversions in
user-mode. Yet, no need for every single driver to fiddle with the
conversion code as they are done transparently by common MI code. With
help from armani and miod, support from mpi

ok armani@


# 1.41 08-May-2015 jsg

Fix the indentation. While originally I thought this was an if statement
with missing braces ratchov checked the specs to see the current
behaviour is correct, just poorly formatted.

ok ratchov@


Revision tags: OPENBSD_5_7_BASE
# 1.40 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.39 15-May-2013 ratchov

Introduce a global interrupt-aware mutex protecting data
structures (including sound-card registers) from concurent
access by syscall and interrupt code-paths. Since critical
sections remain the same, calls to splraise/spllower can be
safely replaced by calls to mtx_enter/mtx_leave with two
exceptions: (1) mutexes are not reentrant (the inner splraise
is thus removed), and (2) we're not allowed to sleep with a
mutex (either msleep is used or the mutex is released before
sleeping).

ok and help from kettenis, a lot of work from armani


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.38 31-Jul-2010 ratchov

fix typo preventing compilation with AUDIO_DEBUG


# 1.37 24-Jul-2010 jakemsr

missed a couple indents in previous


# 1.36 23-Jul-2010 jakemsr

ANSI/style(9), no binary change


# 1.35 15-Jul-2010 jakemsr

add two new members to structs audio_encoding and audio_prinfo.
for both structs, the new members are 'bps' and 'msb', which
describe the number of bytes per sample and data alignment in the
sample, respectively. drivers must properly set these fields in
the 'query_encoding', 'set_parameters' and 'get_default_params'
hardware interface methods.

discussed with ratchov, deraadt


# 1.34 30-Jun-2010 jakemsr

* use audio(9)'s DMA trigger methods instead of the init/start
methods. the AD1848 DMA engine runs continuously and doesn't
need to be started/stopped or otherwise manipulated for each
block. makes the driver a bit more efficient.
* allow "Mode 2" capable chips such as the CS4231 to work in "Mode 1"
when there is only one DMA channel, instead of forcing it into
"Mode 2", which expects two DMA channels. allows recording to
work for "Mode 2" capable devices when there is only one DMA
channel.
* service both playback and recording interrupts in full-duplex
mode, instead of only playback interrupts. allows "Mode 2"
capable chips to work in full-duplex mode.
* fix checks for sample rate/format recalibration completion. gets
rid of busy loops that briefly "hang" the kernel when the device is
opened and/or reconfigured.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.33 05-Nov-2007 jakemsr

audio encoding conversion cleanup

- the endianness of the conversions don't depend on the endianness
of machine the conversions are built on, but the endianness of the
audio data itself. choose encoding conversions explicitly, instead
of relying on #defines based on the endianness of the machine.
- replace home-grown conversions with comparable conversions in
auconv.c and mulaw.c
- use the proper conversion for ulinear_be:16 -> slinear_le:16 in
auixp(4)

thanks ajacoutot@ and sthen@ for !x86 testing


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 22-May-2005 art

remove "0x" in front of %p in printfs.

eyeballed by krw@


# 1.31 15-Apr-2005 mickey

make sure aligment does not return zero block size


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.30 09-Jan-2004 brad

remove uvm_extern.h

tested on alpha, i386, powerpc, sparc64, m68k.

ok miod@


Revision tags: OPENBSD_3_4_BASE
# 1.29 08-Jun-2003 miod

Do not hardcode the dma channel to 1, use the softc settings instead.
mickey@ ok


Revision tags: UBC_SYNC_A
# 1.28 27-Apr-2003 ho

strcpy/sprintf cleanup of sys/dev. miod@, deraadt@ says to commit.


Revision tags: OPENBSD_3_3_BASE
# 1.27 11-Feb-2003 mickey

be consistant on Hz vs hz


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.26 14-Jun-2002 todd

spelling; from Brian Poole <raj@cerias.purdue.edu>


Revision tags: OPENBSD_3_1_BASE
# 1.25 14-Mar-2002 millert

First round of __P removal in sys


# 1.24 20-Jan-2002 ericj

make all audio drivers use the new allocm and round_buffersize decl's.
will ease porting, and generally cleans up a bit


Revision tags: UBC_BASE
# 1.23 06-Nov-2001 miod

branches: 1.23.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


# 1.22 31-Oct-2001 art

Change the audio_hm_if->mappage interface to return paddr_t and take off_t
as the mmap offset.


Revision tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.21 12-Apr-2001 csapuntz

Call isa_malloc with drq < 4, in case 8-bit DMA channels with more
restrictive boundaries are used


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.20 02-Mar-2000 mickey

protect more reads and rights^Wwrites w/ spl; avoid inline which blows the code in twice


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.19 29-Jul-1999 niklas

branches: 1.19.4;
A probe that fails on an otherwise working card, removed


# 1.18 19-Jul-1999 deraadt

further fixes for strange wss isapnp cards; apollo@slcnet.net


# 1.17 03-May-1999 deraadt

support another version of the chipset


Revision tags: OPENBSD_2_5_BASE
# 1.16 24-Jan-1999 mickey

remove unneeded pio.h inclusion


# 1.15 07-Jan-1999 niklas

Die, NEWCONFIG


# 1.14 29-Dec-1998 deraadt

work around some ugly glitches


Revision tags: OPENBSD_2_4_BASE
# 1.13 16-Jul-1998 deraadt

recognize CS4236B; netbsd


# 1.12 15-Jul-1998 deraadt

Fix the name of the ulinear_be mode; netbsd


# 1.11 08-May-1998 csapuntz

Cleaned up AD1848 driver and added driver for Yamaha OPL3-SA3 to tree.


# 1.10 26-Apr-1998 provos

update audio from NetBSD, mostly by Lennart Augustsson <augustss@cs.chalmers.se>


Revision tags: OPENBSD_2_3_BASE
# 1.9 18-Jan-1998 niklas

move to current OpenBSD isadma API


Revision tags: OPENBSD_2_2_BASE
# 1.8 10-Jul-1997 provos

sync with NETBSD 30/3/97 + adapating aria.c


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.7 23-Aug-1996 deraadt

silence probe more


# 1.6 04-Jul-1996 deraadt

fix recording; from jabaker@grail.cba.csuohio.edu


# 1.5 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.4 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.3 08-Mar-1996 niklas

From NetBSD: merge of 960217


# 1.2 14-Dec-1995 deraadt

from netbsd; Convert IRQ, DRQ, and port numbers to int


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision